Freeswitch-trunk
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
February 2008
- 11 participants
- 306 discussions
Author: anthm
Date: Fri Feb 29 12:11:40 2008
New Revision: 7767
Modified:
freeswitch/trunk/src/switch_ivr_originate.c
Log:
add debug line
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Fri Feb 29 12:11:40 2008
@@ -591,6 +591,7 @@
if ((var_count = switch_separate_string(vars, ',', var_array, (sizeof(var_array) / sizeof(var_array[0]))))) {
int x = 0;
for (x = 0; x < var_count; x++) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"variable string %d = [%s]\n", x, var_array[x]);
char *inner_var_array[2] = { 0 };
int inner_var_count;
if ((inner_var_count =
1
0
[commit] r7766 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket
by Freeswitch SVN 29 Feb '08
by Freeswitch SVN 29 Feb '08
29 Feb '08
Author: mikej
Date: Fri Feb 29 10:39:56 2008
New Revision: 7766
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
Log:
tweak error handling on socket app
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Fri Feb 29 10:39:56 2008
@@ -223,18 +223,18 @@
return;
}
- switch_channel_set_variable(channel, "socket_host", host);
-
if ((port_name = strchr(host, ':'))) {
*port_name++ = '\0';
port = (switch_port_t) atoi(port_name);
}
- if ((path = strchr(port_name, '/'))) {
+ if ((path = strchr((port_name ? port_name : host), '/'))) {
*path++ = '\0';
switch_channel_set_variable(channel, "socket_path", path);
}
+ switch_channel_set_variable(channel, "socket_host", host);
+
if (switch_sockaddr_info_get(&sa, host, AF_INET, port, 0, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
return;
1
0
28 Feb '08
Author: silik0n
Date: Thu Feb 28 11:23:20 2008
New Revision: 7765
Modified:
freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
Log:
White space cleanup
Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c Thu Feb 28 11:23:20 2008
@@ -39,11 +39,11 @@
SWITCH_MODULE_DEFINITION(mod_limit, mod_limit_load, NULL, NULL);
static struct {
- switch_memory_pool_t *pool;
- char hostname[256];
- char *dbname;
- char *odbc_dsn;
- switch_mutex_t *mutex;
+ switch_memory_pool_t *pool;
+ char hostname[256];
+ char *dbname;
+ char *odbc_dsn;
+ switch_mutex_t *mutex;
#ifdef SWITCH_HAVE_ODBC
switch_odbc_handle_t *master_odbc;
#else
@@ -81,7 +81,7 @@
static switch_status_t limit_execute_sql(char *sql, switch_mutex_t *mutex)
{
switch_core_db_t *db;
- switch_status_t status = SWITCH_STATUS_SUCCESS;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
if (mutex) {
switch_mutex_lock(mutex);
@@ -95,14 +95,14 @@
err_str = switch_odbc_handle_get_error(globals.master_odbc, stmt);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERR: [%s]\n[%s]\n", sql, switch_str_nil(err_str));
switch_safe_free(err_str);
- status = SWITCH_STATUS_FALSE;
+ status = SWITCH_STATUS_FALSE;
}
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
} else {
#endif
if (!(db = switch_core_db_open_file(globals.dbname))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", globals.dbname);
- status = SWITCH_STATUS_FALSE;
+ status = SWITCH_STATUS_FALSE;
goto end;
}
@@ -133,24 +133,20 @@
char *errmsg = NULL;
if (mutex) {
- switch_mutex_lock(mutex);
- }
+ switch_mutex_lock(mutex);
+ }
#ifdef SWITCH_HAVE_ODBC
- if (globals.odbc_dsn) {
+ if (globals.odbc_dsn) {
switch_odbc_handle_callback_exec(globals.master_odbc, sql, callback, pdata);
} else {
#endif
-
-
-
if (!(db = switch_core_db_open_file(globals.dbname))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", globals.dbname);
goto end;
}
-
switch_core_db_exec(db, sql, callback, pdata, &errmsg);
if (errmsg) {
@@ -161,19 +157,14 @@
if (db) {
switch_core_db_close(db);
}
-
#ifdef SWITCH_HAVE_ODBC
- }
+ }
#endif
-
end:
-
if (mutex) {
- switch_mutex_unlock(mutex);
- }
-
-
+ switch_mutex_unlock(mutex);
+ }
return ret;
@@ -184,11 +175,11 @@
{
char *cf = "limit.conf";
switch_xml_t cfg, xml, settings, param;
- switch_core_db_t *db;
- switch_status_t status = SWITCH_STATUS_SUCCESS;
- char *odbc_user = NULL;
- char *odbc_pass = NULL;
- char *sql = NULL;
+ switch_core_db_t *db;
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ char *odbc_user = NULL;
+ char *odbc_pass = NULL;
+ char *sql = NULL;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
@@ -198,114 +189,114 @@
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = NULL;
- char *val = NULL;
+ char *val = NULL;
- var = (char *) switch_xml_attr_soft(param, "name");
- val = (char *) switch_xml_attr_soft(param, "value");
+ var = (char *) switch_xml_attr_soft(param, "name");
+ val = (char *) switch_xml_attr_soft(param, "value");
- if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
+ if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) {
#ifdef SWITCH_HAVE_ODBC
- globals.odbc_dsn = switch_core_strdup(globals.pool, val);
- if ((odbc_user = strchr(globals.odbc_dsn, ':'))) {
- *odbc_user++ = '\0';
- if ((odbc_pass = strchr(odbc_user, ':'))) {
- *odbc_pass++ = '\0';
- }
- }
+ globals.odbc_dsn = switch_core_strdup(globals.pool, val);
+ if ((odbc_user = strchr(globals.odbc_dsn, ':'))) {
+ *odbc_user++ = '\0';
+ if ((odbc_pass = strchr(odbc_user, ':'))) {
+ *odbc_pass++ = '\0';
+ }
+ }
#else
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif
- }
- }
- }
+ }
+ }
+ }
- if (switch_strlen_zero(globals.odbc_dsn) || switch_strlen_zero(odbc_user) || switch_strlen_zero(odbc_pass)) {
- globals.dbname = "call_limit";
- }
+ if (switch_strlen_zero(globals.odbc_dsn) || switch_strlen_zero(odbc_user) || switch_strlen_zero(odbc_pass)) {
+ globals.dbname = "call_limit";
+ }
#ifdef SWITCH_HAVE_ODBC
- if (globals.odbc_dsn) {
- if (!(globals.master_odbc = switch_odbc_handle_new(globals.odbc_dsn, odbc_user, odbc_pass))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
- status = SWITCH_STATUS_FALSE;
- goto done;
- }
- if (switch_odbc_handle_connect(globals.master_odbc) != SWITCH_ODBC_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
- status = SWITCH_STATUS_FALSE;
- goto done;
- }
+ if (globals.odbc_dsn) {
+ if (!(globals.master_odbc = switch_odbc_handle_new(globals.odbc_dsn, odbc_user, odbc_pass))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
+ if (switch_odbc_handle_connect(globals.master_odbc) != SWITCH_ODBC_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", globals.odbc_dsn);
- if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from limit_data", NULL) != SWITCH_STATUS_SUCCESS) {
- if (switch_odbc_handle_exec(globals.master_odbc, limit_sql, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
- }
- }
- if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from db_data", NULL) != SWITCH_STATUS_SUCCESS) {
- if (switch_odbc_handle_exec(globals.master_odbc, db_sql, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
- }
- }
- if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from group_data", NULL) != SWITCH_STATUS_SUCCESS) {
- if (switch_odbc_handle_exec(globals.master_odbc, group_sql, NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
- }
- }
- } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", globals.odbc_dsn);
+ if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from limit_data", NULL) != SWITCH_STATUS_SUCCESS) {
+ if (switch_odbc_handle_exec(globals.master_odbc, limit_sql, NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
+ }
+ }
+ if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from db_data", NULL) != SWITCH_STATUS_SUCCESS) {
+ if (switch_odbc_handle_exec(globals.master_odbc, db_sql, NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
+ }
+ }
+ if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from group_data", NULL) != SWITCH_STATUS_SUCCESS) {
+ if (switch_odbc_handle_exec(globals.master_odbc, group_sql, NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Create SQL Database!\n");
+ }
+ }
+ } else {
#endif
- if ((db = switch_core_db_open_file(globals.dbname))) {
- switch_core_db_test_reactive(db, "select * from limit_data", NULL, limit_sql);
- switch_core_db_test_reactive(db, "select * from db_data", NULL, db_sql);
- switch_core_db_test_reactive(db, "select * from group_data", NULL, group_sql);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n");
- status = SWITCH_STATUS_FALSE;
- goto done;
- }
- switch_core_db_close(db);
+ if ((db = switch_core_db_open_file(globals.dbname))) {
+ switch_core_db_test_reactive(db, "select * from limit_data", NULL, limit_sql);
+ switch_core_db_test_reactive(db, "select * from db_data", NULL, db_sql);
+ switch_core_db_test_reactive(db, "select * from group_data", NULL, group_sql);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n");
+ status = SWITCH_STATUS_FALSE;
+ goto done;
+ }
+ switch_core_db_close(db);
#ifdef SWITCH_HAVE_ODBC
- }
+ }
#endif
done:
- sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname);
- limit_execute_sql(sql, globals.mutex);
- switch_safe_free(sql);
+ sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname);
+ limit_execute_sql(sql, globals.mutex);
+ switch_safe_free(sql);
- switch_xml_free(xml);
+ switch_xml_free(xml);
- return status;
+ return status;
}
static switch_status_t hanguphook(switch_core_session_t *session)
{
- switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_state_t state = switch_channel_get_state(channel);
- const char *realm = NULL;
- const char *id = NULL;
- char *sql = NULL;
+ const char *realm = NULL;
+ const char *id = NULL;
+ char *sql = NULL;
if (state == CS_HANGUP || state == CS_RING) {
- id = switch_channel_get_variable(channel, "limit_id");
- realm = switch_channel_get_variable(channel, "limit_realm");
- sql = switch_mprintf("delete from limit_data where uuid='%q' and hostname='%q' and realm='%q'and id='%q';",
+ id = switch_channel_get_variable(channel, "limit_id");
+ realm = switch_channel_get_variable(channel, "limit_realm");
+ sql = switch_mprintf("delete from limit_data where uuid='%q' and hostname='%q' and realm='%q'and id='%q';",
switch_core_session_get_uuid(session), globals.hostname, realm, id);
- limit_execute_sql(sql, globals.mutex);
- switch_safe_free(sql);
- switch_core_event_hook_remove_state_change(session, hanguphook);
- }
- return SWITCH_STATUS_SUCCESS;
+ limit_execute_sql(sql, globals.mutex);
+ switch_safe_free(sql);
+ switch_core_event_hook_remove_state_change(session, hanguphook);
+ }
+ return SWITCH_STATUS_SUCCESS;
}
struct callback {
- char *buf;
- size_t len;
- int matches;
+ char *buf;
+ size_t len;
+ int matches;
};
typedef struct callback callback_t;
static int sql2str_callback(void *pArg, int argc, char **argv, char **columnNames)
@@ -321,7 +312,7 @@
static int group_callback(void *pArg, int argc, char **argv, char **columnNames)
{
callback_t *cbt = (callback_t *) pArg;
- switch_snprintf(cbt->buf + strlen(cbt->buf), cbt->len - strlen(cbt->buf), "%s%c", argv[0], *argv[1]);
+ switch_snprintf(cbt->buf + strlen(cbt->buf), cbt->len - strlen(cbt->buf), "%s%c", argv[0], *argv[1]);
cbt->matches++;
return 0;
}
@@ -329,69 +320,69 @@
SWITCH_STANDARD_API(db_api_function)
{
- int argc = 0;
- char *argv[4] = { 0 };
- char *mydata = NULL;
- char *sql;
-
- switch_mutex_lock(globals.mutex);
-
- if (!switch_strlen_zero(cmd)) {
- mydata = strdup(cmd);
- argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
- }
+ int argc = 0;
+ char *argv[4] = { 0 };
+ char *mydata = NULL;
+ char *sql;
- if (argc < 1 || !argv[0]) {
- goto error;
- }
+ switch_mutex_lock(globals.mutex);
+
+ if (!switch_strlen_zero(cmd)) {
+ mydata = strdup(cmd);
+ argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
- if (!strcasecmp(argv[0], "insert")) {
- if (argc < 4) {
- goto error;
- }
- sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
- assert(sql);
- limit_execute_sql(sql, NULL);
- switch_safe_free(sql);
- sql = switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
- assert(sql);
- limit_execute_sql(sql, NULL);
- switch_safe_free(sql);
- stream->write_function(stream, "+OK");
- goto done;
- } else if (!strcasecmp(argv[0], "delete")) {
- if (argc < 2) {
- goto error;
- }
- sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
- assert(sql);
- limit_execute_sql(sql, NULL);
- switch_safe_free(sql);
- stream->write_function(stream, "+OK");
- goto done;
- } else if (!strcasecmp(argv[0], "select")) {
- char buf[256] = "";
- callback_t cbt = { 0 };
- if (argc < 3) {
- goto error;
- }
- cbt.buf = buf;
- cbt.len = sizeof(buf);
- sql = switch_mprintf("select data from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
- limit_execute_sql_callback(NULL, sql, sql2str_callback, &cbt);
- stream->write_function(stream, "%s", buf);
- goto done;
- }
+ if (argc < 1 || !argv[0]) {
+ goto error;
+ }
+
+ if (!strcasecmp(argv[0], "insert")) {
+ if (argc < 4) {
+ goto error;
+ }
+ sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
+ assert(sql);
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
+ sql = switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
+ assert(sql);
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
+ stream->write_function(stream, "+OK");
+ goto done;
+ } else if (!strcasecmp(argv[0], "delete")) {
+ if (argc < 2) {
+ goto error;
+ }
+ sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
+ assert(sql);
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
+ stream->write_function(stream, "+OK");
+ goto done;
+ } else if (!strcasecmp(argv[0], "select")) {
+ char buf[256] = "";
+ callback_t cbt = { 0 };
+ if (argc < 3) {
+ goto error;
+ }
+ cbt.buf = buf;
+ cbt.len = sizeof(buf);
+ sql = switch_mprintf("select data from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
+ limit_execute_sql_callback(NULL, sql, sql2str_callback, &cbt);
+ stream->write_function(stream, "%s", buf);
+ goto done;
+ }
error:
- stream->write_function(stream, "!err!");
+ stream->write_function(stream, "!err!");
done:
- switch_mutex_unlock(globals.mutex);
- switch_safe_free(mydata);
- return SWITCH_STATUS_SUCCESS;
+ switch_mutex_unlock(globals.mutex);
+ switch_safe_free(mydata);
+ return SWITCH_STATUS_SUCCESS;
}
@@ -401,119 +392,119 @@
SWITCH_STANDARD_APP(db_function)
{
- int argc = 0;
- char *argv[4] = { 0 };
- char *mydata = NULL;
- char *sql = NULL;
+ int argc = 0;
+ char *argv[4] = { 0 };
+ char *mydata = NULL;
+ char *sql = NULL;
if (!switch_strlen_zero(data)) {
- mydata = switch_core_session_strdup(session, data);
- argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
- }
+ mydata = switch_core_session_strdup(session, data);
+ argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
- if (argc < 4 || !argv[0]) {
- goto error;
- }
+ if (argc < 4 || !argv[0]) {
+ goto error;
+ }
if (!strcasecmp(argv[0], "insert")) {
- sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
- switch_assert(sql);
- limit_execute_sql(sql, globals.mutex);
- switch_safe_free(sql);
+ sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
+ switch_assert(sql);
+ limit_execute_sql(sql, globals.mutex);
+ switch_safe_free(sql);
- sql = switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
- } else if (!strcasecmp(argv[0], "delete")) {
- sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
- }
+ sql = switch_mprintf("insert into db_data (hostname, realm, data_key, data) values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
+ } else if (!strcasecmp(argv[0], "delete")) {
+ sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
+ }
- switch_assert(sql);
- limit_execute_sql(sql, globals.mutex);
- switch_safe_free(sql);
- return;
+ switch_assert(sql);
+ limit_execute_sql(sql, globals.mutex);
+ switch_safe_free(sql);
+ return;
error:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
}
SWITCH_STANDARD_API(group_api_function)
{
- int argc = 0;
- char *argv[4] = { 0 };
- char *mydata = NULL;
- char *sql;
-
- switch_mutex_lock(globals.mutex);
-
- if (!switch_strlen_zero(cmd)) {
- mydata = strdup(cmd);
- argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
- }
+ int argc = 0;
+ char *argv[4] = { 0 };
+ char *mydata = NULL;
+ char *sql;
- if (argc < 2 || !argv[0]) {
- goto error;
- }
+ switch_mutex_lock(globals.mutex);
+
+ if (!switch_strlen_zero(cmd)) {
+ mydata = strdup(cmd);
+ argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
- if (!strcasecmp(argv[0], "insert")) {
- if (argc < 3) {
- goto error;
- }
- sql = switch_mprintf("delete from group_data where groupname='%q' and url='%q';", argv[1], argv[2]);
- assert(sql);
-
- limit_execute_sql(sql, NULL);
- switch_safe_free(sql);
- sql = switch_mprintf("insert into group_data (hostname, groupname, url) values('%q','%q','%q');", globals.hostname, argv[1], argv[2]);
- assert(sql);
- limit_execute_sql(sql, NULL);
- switch_safe_free(sql);
- stream->write_function(stream, "+OK");
- goto done;
- } else if (!strcasecmp(argv[0], "delete")) {
- if (argc < 3) {
- goto error;
- }
- if (!strcmp(argv[2], "*")) {
- sql = switch_mprintf("delete from group_data where groupname='%q';", argv[1]);
- } else {
- sql = switch_mprintf("delete from group_data where groupname='%q' and url='%q';", argv[1], argv[2]);
- }
- assert(sql);
- limit_execute_sql(sql, NULL);
- switch_safe_free(sql);
- stream->write_function(stream, "+OK");
- goto done;
- } else if (!strcasecmp(argv[0], "call")) {
- char buf[4096] = "";
- char *how = ",";
- callback_t cbt = { 0 };
- cbt.buf = buf;
- cbt.len = sizeof(buf);
+ if (argc < 2 || !argv[0]) {
+ goto error;
+ }
+
+ if (!strcasecmp(argv[0], "insert")) {
+ if (argc < 3) {
+ goto error;
+ }
+ sql = switch_mprintf("delete from group_data where groupname='%q' and url='%q';", argv[1], argv[2]);
+ assert(sql);
+
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
+ sql = switch_mprintf("insert into group_data (hostname, groupname, url) values('%q','%q','%q');", globals.hostname, argv[1], argv[2]);
+ assert(sql);
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
+ stream->write_function(stream, "+OK");
+ goto done;
+ } else if (!strcasecmp(argv[0], "delete")) {
+ if (argc < 3) {
+ goto error;
+ }
+ if (!strcmp(argv[2], "*")) {
+ sql = switch_mprintf("delete from group_data where groupname='%q';", argv[1]);
+ } else {
+ sql = switch_mprintf("delete from group_data where groupname='%q' and url='%q';", argv[1], argv[2]);
+ }
+ assert(sql);
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
+ stream->write_function(stream, "+OK");
+ goto done;
+ } else if (!strcasecmp(argv[0], "call")) {
+ char buf[4096] = "";
+ char *how = ",";
+ callback_t cbt = { 0 };
+ cbt.buf = buf;
+ cbt.len = sizeof(buf);
- if (argc > 2) {
- if (!strcasecmp(argv[2], "order")) {
- how = "|";
- }
- }
-
- sql = switch_mprintf("select url,'%q' from group_data where groupname='%q'", how, argv[1]);
- assert(sql);
-
- limit_execute_sql_callback(NULL, sql, group_callback, &cbt);
- *(buf + (strlen(buf) - 1)) = '\0';
- stream->write_function(stream, "%s", buf);
- goto done;
- }
+ if (argc > 2) {
+ if (!strcasecmp(argv[2], "order")) {
+ how = "|";
+ }
+ }
+
+ sql = switch_mprintf("select url,'%q' from group_data where groupname='%q'", how, argv[1]);
+ assert(sql);
+
+ limit_execute_sql_callback(NULL, sql, group_callback, &cbt);
+ *(buf + (strlen(buf) - 1)) = '\0';
+ stream->write_function(stream, "%s", buf);
+ goto done;
+ }
error:
- stream->write_function(stream, "!err!");
+ stream->write_function(stream, "!err!");
done:
- switch_mutex_unlock(globals.mutex);
- switch_safe_free(mydata);
- return SWITCH_STATUS_SUCCESS;
+ switch_mutex_unlock(globals.mutex);
+ switch_safe_free(mydata);
+ return SWITCH_STATUS_SUCCESS;
}
@@ -522,32 +513,32 @@
SWITCH_STANDARD_APP(group_function)
{
- int argc = 0;
- char *argv[3] = { 0 };
- char *mydata = NULL;
- char *sql;
+ int argc = 0;
+ char *argv[3] = { 0 };
+ char *mydata = NULL;
+ char *sql;
if (!switch_strlen_zero(data)) {
- mydata = switch_core_session_strdup(session, data);
- argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
- }
+ mydata = switch_core_session_strdup(session, data);
+ argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
- if (argc < 3 || !argv[0]) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: group %s\n", DB_USAGE);
- return;
- }
+ if (argc < 3 || !argv[0]) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: group %s\n", DB_USAGE);
+ return;
+ }
- if (!strcasecmp(argv[0], "insert")) {
- sql = switch_mprintf("insert into group_data (hostname, groupname, url) values('%q','%q','%q');", globals.hostname, argv[1], argv[2]);
- assert(sql);
- limit_execute_sql(sql, globals.mutex);
- switch_safe_free(sql);
- } else if (!strcasecmp(argv[0], "delete")) {
- sql = switch_mprintf("delete from group_data where groupname='%q' and url='%q';", argv[1], argv[2]);
- assert(sql);
- limit_execute_sql(sql, globals.mutex);
- switch_safe_free(sql);
- }
+ if (!strcasecmp(argv[0], "insert")) {
+ sql = switch_mprintf("insert into group_data (hostname, groupname, url) values('%q','%q','%q');", globals.hostname, argv[1], argv[2]);
+ assert(sql);
+ limit_execute_sql(sql, globals.mutex);
+ switch_safe_free(sql);
+ } else if (!strcasecmp(argv[0], "delete")) {
+ sql = switch_mprintf("delete from group_data where groupname='%q' and url='%q';", argv[1], argv[2]);
+ assert(sql);
+ limit_execute_sql(sql, globals.mutex);
+ switch_safe_free(sql);
+ }
}
@@ -557,87 +548,87 @@
SWITCH_STANDARD_APP(limit_function)
{
- int argc = 0;
- char *argv[6] = { 0 };
- char *mydata = NULL;
- char *sql = NULL;
- char *realm = NULL;
- char *id = NULL;
- char *xfer_exten = NULL;
- int max = 0, got = 0;
- char buf[80] = "";
- callback_t cbt = { 0 };
- switch_channel_t *channel = switch_core_session_get_channel(session);
-
- if (!switch_strlen_zero(data)) {
- mydata = switch_core_session_strdup(session, data);
- argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
- }
+ int argc = 0;
+ char *argv[6] = { 0 };
+ char *mydata = NULL;
+ char *sql = NULL;
+ char *realm = NULL;
+ char *id = NULL;
+ char *xfer_exten = NULL;
+ int max = 0, got = 0;
+ char buf[80] = "";
+ callback_t cbt = { 0 };
+ switch_channel_t *channel = switch_core_session_get_channel(session);
- if (argc < 3) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: limit %s\n", LIMIT_USAGE);
- return;
- }
+ if (!switch_strlen_zero(data)) {
+ mydata = switch_core_session_strdup(session, data);
+ argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+ }
+
+ if (argc < 3) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: limit %s\n", LIMIT_USAGE);
+ return;
+ }
switch_mutex_lock(globals.mutex);
realm = argv[0];
- id = argv[1];
- max = atoi(argv[2]);
+ id = argv[1];
+ max = atoi(argv[2]);
- if (argc == 4) {
- xfer_exten = argv[3];
- } else {
- xfer_exten = limit_def_xfer_exten;
- }
+ if (argc == 4) {
+ xfer_exten = argv[3];
+ } else {
+ xfer_exten = limit_def_xfer_exten;
+ }
- if (max < 0) {
- max = 0;
- }
+ if (max < 0) {
+ max = 0;
+ }
- switch_channel_set_variable(channel, "limit_realm", realm);
- switch_channel_set_variable(channel, "limit_id", id);
- switch_channel_set_variable(channel, "limit_max", argv[2]);
-
- cbt.buf = buf;
- cbt.len = sizeof(buf);
- sql = switch_mprintf("select count(hostname) from limit_data where realm='%q' and id like '%q'", realm, id);
- limit_execute_sql_callback(NULL, sql, sql2str_callback, &cbt);
- got = atoi(buf);
-
- if (got + 1 > max) {
- switch_ivr_session_transfer(session, xfer_exten, NULL, NULL);
- goto done;
- }
+ switch_channel_set_variable(channel, "limit_realm", realm);
+ switch_channel_set_variable(channel, "limit_id", id);
+ switch_channel_set_variable(channel, "limit_max", argv[2]);
+
+ cbt.buf = buf;
+ cbt.len = sizeof(buf);
+ sql = switch_mprintf("select count(hostname) from limit_data where realm='%q' and id like '%q'", realm, id);
+ limit_execute_sql_callback(NULL, sql, sql2str_callback, &cbt);
+ got = atoi(buf);
+
+ if (got + 1 > max) {
+ switch_ivr_session_transfer(session, xfer_exten, NULL, NULL);
+ goto done;
+ }
- switch_core_event_hook_add_state_change(session, hanguphook);
- sql = switch_mprintf("insert into limit_data (hostname, realm, id, uuid) values('%q','%q','%q','%q');", globals.hostname, realm, id, switch_core_session_get_uuid(session));
- limit_execute_sql(sql, NULL);
- switch_safe_free(sql);
+ switch_core_event_hook_add_state_change(session, hanguphook);
+ sql = switch_mprintf("insert into limit_data (hostname, realm, id, uuid) values('%q','%q','%q','%q');", globals.hostname, realm, id, switch_core_session_get_uuid(session));
+ limit_execute_sql(sql, NULL);
+ switch_safe_free(sql);
done:
- switch_mutex_unlock(globals.mutex);
+ switch_mutex_unlock(globals.mutex);
}
SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load)
{
- switch_status_t status;
+ switch_status_t status;
switch_application_interface_t *app_interface;
switch_api_interface_t *commands_api_interface;
- memset(&globals, 0, sizeof(&globals));
- gethostname(globals.hostname, sizeof(globals.hostname));
- globals.pool = pool;
+ memset(&globals, 0, sizeof(&globals));
+ gethostname(globals.hostname, sizeof(globals.hostname));
+ globals.pool = pool;
- if ((status = do_config() != SWITCH_STATUS_SUCCESS)) {
- return status;
- }
+ if ((status = do_config() != SWITCH_STATUS_SUCCESS)) {
+ return status;
+ }
- switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
+ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
- /* connect my internal structure to the blank pointer passed to me */
- *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+ /* connect my internal structure to the blank pointer passed to me */
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_APP(app_interface, "limit", "Limit", LIMIT_DESC, limit_function, LIMIT_USAGE, SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "db", "Insert to the db", DB_DESC, db_function, DB_USAGE, SAF_SUPPORT_NOMEDIA);
@@ -646,8 +637,8 @@
SWITCH_ADD_API(commands_api_interface, "db", "db get/set", db_api_function, "[get|set]/<realm>/<key>/<value>");
SWITCH_ADD_API(commands_api_interface, "group", "group [insert|delete|call]", group_api_function, "[insert|delete|call]:<group name>:<url>");
- /* indicate that the module should continue to be loaded */
- return SWITCH_STATUS_SUCCESS;
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
}
1
0
Author: anthm
Date: Wed Feb 27 22:22:26 2008
New Revision: 7764
Modified:
freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
Log:
silence broken compiler
Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c Wed Feb 27 22:22:26 2008
@@ -74,6 +74,8 @@
static inline void free_context(shout_context_t * context)
{
+ int ret;
+
if (context) {
context->err++;
@@ -87,7 +89,10 @@
int len;
while ((len = lame_encode_flush(context->gfp, mp3buffer, sizeof(mp3buffer))) > 0) {
- fwrite(mp3buffer, 1, len, context->fp);
+ ret = fwrite(mp3buffer, 1, len, context->fp);
+ if (ret < 0) {
+ break;
+ }
}
lame_mp3_tags_fid(context->gfp, context->fp);
@@ -857,7 +862,8 @@
}
if (rlen) {
- if (fwrite(mp3buf, 1, rlen, context->fp) < 0) {
+ int ret = fwrite(mp3buf, 1, rlen, context->fp);
+ if (ret < 0) {
return SWITCH_STATUS_FALSE;
}
}
1
0
Author: brian
Date: Wed Feb 27 21:04:20 2008
New Revision: 7763
Modified:
freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
Log:
Fix MODFORM-6
Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c Wed Feb 27 21:04:20 2008
@@ -583,7 +583,8 @@
lame_set_num_channels(context->gfp, handle->channels);
lame_set_in_samplerate(context->gfp, handle->samplerate);
- lame_set_brate(context->gfp, 24);
+ lame_set_brate(context->gfp, 64);
+ lame_set_out_samplerate(context->gfp, handle->samplerate);
if (handle->channels == 2) {
lame_set_mode(context->gfp, STEREO);
} else {
1
0
[commit] r7762 - in freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua: . sofia-sip
by Freeswitch SVN 27 Feb '08
by Freeswitch SVN 27 Feb '08
27 Feb '08
Author: mikej
Date: Wed Feb 27 17:12:16 2008
New Revision: 7762
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
Log:
rollback
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.c Wed Feb 27 17:12:16 2008
@@ -373,12 +373,8 @@
/* Destroy saved client request */
if (nua_client_is_bound(du->du_cr)) {
nua_client_bind(cr = du->du_cr, NULL);
-
- if (nua_client_is_queued(cr))
- nua_client_request_complete(cr);
- else if (nua_client_is_reporting(cr))
- ;
- else
+ if (!nua_client_is_queued(cr) &&
+ !nua_client_is_reporting(cr))
nua_client_request_destroy(cr);
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_dialog.h Wed Feb 27 17:12:16 2008
@@ -253,11 +253,11 @@
nta_outgoing_t *orq,
tagi_t const *tags);
- /** @a crm_complete is called when a client-side request is destroyed.
+ /** @a crm_deinit is called when a client-side request is destroyed.
*
* @return The return value should be 0. It is currently ignored.
*/
- int (*crm_complete)(nua_client_request_t *);
+ int (*crm_deinit)(nua_client_request_t *);
} nua_client_methods_t;
@@ -516,8 +516,6 @@
return (void *)(cr + 1);
}
-void nua_client_request_complete(nua_client_request_t *);
-
void nua_client_request_destroy(nua_client_request_t *);
int nua_client_request_queue(nua_client_request_t *cr);
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_extension.c Wed Feb 27 17:12:16 2008
@@ -74,21 +74,18 @@
*/
static nua_client_methods_t const nua_method_client_methods = {
- SIP_METHOD_UNKNOWN, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_UNKNOWN,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 0,
/* target_refresh */ 1,
},
- NULL, /* crm_template */
- NULL, /* crm_init */
- NULL, /* crm_send */
- NULL, /* crm_check_restart */
- NULL, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ /* nua_method_client_template */ NULL,
+ /* nua_method_client_init */ NULL,
+ /* nua_method_client_request */ NULL,
+ /* nua_method_client_check_restart */ NULL,
+ /* nua_method_client_response */ NULL
};
int
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_message.c Wed Feb 27 17:12:16 2008
@@ -77,22 +77,18 @@
tagi_t const *tags);
static nua_client_methods_t const nua_message_client_methods = {
- SIP_METHOD_MESSAGE, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_MESSAGE,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 0,
/* target refresh */ 0
},
- NULL, /* crm_template */
- nua_message_client_init, /* crm_init */
- NULL, /* crm_send */
- NULL, /* crm_check_restart */
- NULL, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
-
+ /* nua_message_client_template */ NULL,
+ nua_message_client_init,
+ /*nua_message_client_request*/ NULL,
+ /* nua_message_client_check_restart */ NULL,
+ /*nua_message_client_response*/ NULL
};
int
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c Wed Feb 27 17:12:16 2008
@@ -237,8 +237,7 @@
sip_event_t *o = sip->sip_event;
char const *event = o ? o->o_type : NULL;
/* Maximum expiration time */
- unsigned long expires = sip->sip_expires ? sip->sip_expires->ex_delta : 3600;
- sip_time_t now = sip_now();
+ unsigned long expires = 3600;
assert(nh && nh->nh_nua->nua_dhandle != nh);
@@ -260,10 +259,9 @@
nu = nua_dialog_usage_private(du);
- if (now + expires >= now)
- nu->nu_requested = now + expires;
- else
- nu->nu_requested = SIP_TIME_MAX - 1;
+ if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
+ expires = sip->sip_expires->ex_delta;
+ nu->nu_requested = sip_now() + expires;
#if SU_HAVE_EXPERIMENTAL
nu->nu_etags =
@@ -297,23 +295,9 @@
sip_time_t now = sip_now();
if (nu->nu_requested) {
- if (sip->sip_expires) {
- /* Expires in response can only shorten the expiration time */
- if (nu->nu_requested > now + sip->sip_expires->ex_delta)
- nu->nu_requested = now + sip->sip_expires->ex_delta;
- }
- else {
- unsigned sub_expires = NH_PGET(sr->sr_owner, sub_expires);
- if (nu->nu_requested > now + sub_expires)
- nu->nu_requested = now + sub_expires;
- }
-
- if (nu->nu_requested >= now)
+ if (nu->nu_requested > nu->nu_expires)
nu->nu_expires = nu->nu_requested;
- else
- nu->nu_expires = now;
-
- if (nu->nu_expires <= now)
+ else if (nu->nu_expires <= now || nu->nu_requested <= now)
nu->nu_substate = nua_substate_terminated;
}
@@ -321,7 +305,7 @@
ex->ex_delta = nu->nu_expires - now;
}
else {
- /* Always add header Expires: 0 */
+ /* Add header Expires: 0 */
}
if (!sip->sip_expires || sip->sip_expires->ex_delta > ex->ex_delta)
@@ -436,21 +420,20 @@
tagi_t const *tags);
static nua_client_methods_t const nua_notify_client_methods = {
- SIP_METHOD_NOTIFY, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_NOTIFY,
+ 0,
+ {
/* create_dialog */ 1,
/* in_dialog */ 1,
/* target refresh */ 1
},
- NULL, /* crm_template */
- nua_notify_client_init, /* crm_init */
- nua_notify_client_request, /* crm_send */
- NULL, /* crm_check_restart */
- NULL, /* crm_recv */
- NULL, /* crm_preliminary */
- nua_notify_client_report, /* crm_report */
- NULL, /* crm_complete */
+ /* nua_notify_client_template */ NULL,
+ nua_notify_client_init,
+ nua_notify_client_request,
+ /* nua_notify_client_check_restart */ NULL,
+ /* nua_notify_client_response */ NULL,
+ /* nua_notify_client_preliminary */ NULL,
+ nua_notify_client_report
};
/**@internal Send NOTIFY. */
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_options.c Wed Feb 27 17:12:16 2008
@@ -88,21 +88,18 @@
*/
static nua_client_methods_t const nua_options_client_methods = {
- SIP_METHOD_OPTIONS, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_OPTIONS,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 0,
/* target refresh */ 0
},
- NULL, /* crm_template */
- NULL, /* crm_init */
- NULL, /* crm_send */
- NULL, /* crm_check_restart */
- NULL, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ /*nua_options_client_template*/ NULL,
+ /*nua_options_client_init*/ NULL,
+ /*nua_options_client_request*/ NULL,
+ /* nua_options_client_check_restart */ NULL,
+ /*nua_options_client_response*/ NULL
};
int nua_stack_options(nua_t *nua,
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c Wed Feb 27 17:12:16 2008
@@ -77,27 +77,19 @@
su_inline void nhp_or_set(nua_handle_preferences_t *a,
nua_handle_preferences_t const *b)
{
- memcpy(a, b, offsetof(nua_handle_preferences_t, nhp_set));
-
- /* Bitwise or of bitfields, casted to unsigned */
- a->nhp_set_.set_unsigned[0] |= b->nhp_set_.set_unsigned[0];
- a->nhp_set_.set_unsigned[1] |= b->nhp_set_.set_unsigned[1];
-
- /*
- unsigned *ap, const *bp;
+ unsigned *ap = a->nhp_set_.set_unsigned;
+ unsigned const *bp = b->nhp_set_.set_unsigned;
size_t i;
- ap = a->nhp_set_.set_unsigned;
- bp = b->nhp_set_.set_unsigned;
+ memcpy(a, b, offsetof(nua_handle_preferences_t, nhp_set));
+
for (i = 0; i < (sizeof a->nhp_set); i += (sizeof *ap))
*ap++ |= *bp++;
-
- */
}
static int nhp_set_tags(su_home_t *home,
nua_handle_preferences_t *nhp,
- nua_global_preferences_t *ngp,
+ int global,
tagi_t const *tags);
static int nhp_merge_lists(su_home_t *home,
@@ -109,11 +101,11 @@
int always_merge,
tag_value_t value);
-static int nhp_save_params(nua_handle_t *nh,
- su_home_t *tmphome,
- nua_global_preferences_t *gsrc,
- nua_handle_preferences_t *src);
-
+static
+nua_handle_preferences_t *nhp_move_params(su_home_t *home,
+ nua_handle_preferences_t *dst,
+ su_home_t *tmphome,
+ nua_handle_preferences_t const *src);
/* ====================================================================== */
/* Magical NUTAG_USER_AGENT() - add NHP_USER_AGENT there if it is not there */
@@ -177,7 +169,6 @@
NHP_SET(nhp, refer_with_id, 1);
NHP_SET(nhp, substate, nua_substate_active);
- NHP_SET(nhp, sub_expires, 3600);
NHP_SET(nhp, allow, sip_allow_make(home, nua_allow_str));
NHP_SET(nhp, supported, sip_supported_make(home, "timer, 100rel"));
@@ -207,12 +198,20 @@
sip_from_t *f = NULL, f0[1];
int set;
+ char const *uicc_name = "default";
+
tl_gets(tags,
/* By nua_stack_set_from() */
SIPTAG_FROM_REF(from),
SIPTAG_FROM_STR_REF(str),
+ NUTAG_UICC_REF(uicc_name),
TAG_END());
+#if HAVE_UICC_H
+ if (initial && uicc_name)
+ nua->nua_uicc = uicc_create(root, uicc_name);
+#endif
+
if (!initial && from == NONE && str == NONE)
return 0;
@@ -326,7 +325,6 @@
* NUTAG_SMIME_SIGNATURE() \n
* NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n
- * NUTAG_SUB_EXPIRES() \n
* NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n
* NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n
@@ -439,7 +437,6 @@
* NUTAG_SESSION_TIMER() \n
* NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n
- * NUTAG_SUB_EXPIRES() \n
* NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n
* NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n
@@ -478,124 +475,146 @@
tagi_t const *tags)
{
nua_handle_t *dnh = nua->nua_dhandle;
-
- int status;
- char const *phrase;
+ nua_handle_preferences_t tmp[1], *nhp = nh->nh_prefs;
+ nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
+
+ su_home_t tmphome[1] = { SU_HOME_INIT(tmphome) };
+
+ tagi_t const *ptags;
+
+ int error, global;
+ int status = 900;
+ char const *phrase = "Error storing parameters";
+ sip_supported_t const *supported = NULL;
+ sip_allow_t const *allow = NULL;
+ sip_allow_events_t const *allow_events = NULL;
+ sip_allow_t const *appl_method = NULL;
enter;
- {
- su_home_t tmphome[1] = { SU_HOME_INIT(tmphome) };
- nua_handle_preferences_t *nhp = nh->nh_prefs;
- nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
- nua_handle_preferences_t tmp[1];
- nua_global_preferences_t gtmp[1], *ngp = NULL;
-
- *tmp = *nhp; NHP_UNSET_ALL(tmp);
-
- /*
- * Supported features, allowed methods and events are merged
- * with previous or default settings.
- *
- * Here we just copy pointers from default settings. However when saving
- * settings we have to be extra careful so that we
- * 1) zero the pointers if the setting has not been modified
- * 2) do not free pointer if the setting has been modified
- * See NHP_ZAP_OVERRIDEN() below for gorier details.
- */
- if (!NHP_ISSET(nhp, supported))
- tmp->nhp_supported = dnhp->nhp_supported;
- if (!NHP_ISSET(nhp, allow))
- tmp->nhp_allow = dnhp->nhp_allow;
- if (!NHP_ISSET(nhp, allow_events))
- tmp->nhp_allow_events = dnhp->nhp_allow_events;
- if (!NHP_ISSET(nhp, appl_method))
- tmp->nhp_appl_method = dnhp->nhp_appl_method;
+ ptags = !nh->nh_used_ptags ? nh->nh_ptags : NULL;
+
+ *tmp = *nhp; NHP_UNSET_ALL(tmp);
+
+ /* Supported features, allowed methods and events are merged
+ with previous ones */
+ if (!NHP_ISSET(nhp, supported))
+ supported = tmp->nhp_supported = dnhp->nhp_supported;
+ if (!NHP_ISSET(nhp, allow))
+ allow = tmp->nhp_allow = dnhp->nhp_allow;
+ if (!NHP_ISSET(nhp, allow_events))
+ allow_events = tmp->nhp_allow_events = dnhp->nhp_allow_events;
+ if (!NHP_ISSET(nhp, appl_method))
+ appl_method = tmp->nhp_appl_method = dnhp->nhp_appl_method;
+
+ error = 0;
+ global = nh == dnh; /* save also stack-specific params */
- if (nh == dnh) /* nua_set_params() call, save stack-wide params, too */
- ngp = gtmp, *gtmp = *nua->nua_prefs;
+ /* Set and save parameters to tmp */
+ if (nhp_set_tags(tmphome, tmp, global, ptags) < 0)
+ error = 1, phrase = "Error storing default handle parameters";
+ else if (nhp_set_tags(tmphome, tmp, global, tags) < 0)
+ error = 1, phrase = "Error storing parameters";
+ else {
+ if (NHP_IS_ANY_SET(tmp)) {
+ if (tmp->nhp_supported == supported)
+ tmp->nhp_supported = NULL;
+
+ if (tmp->nhp_allow == allow)
+ tmp->nhp_allow = NULL;
+
+ if (tmp->nhp_allow_events == allow_events)
+ tmp->nhp_allow_events = NULL;
+
+ if (tmp->nhp_appl_method == appl_method)
+ tmp->nhp_appl_method = NULL;
+
+ /* Move parameters from tmp to nhp (or allocate new nhp) */
+ if (nh != dnh && nhp == dnh->nh_prefs)
+ nhp = NULL;
+ nhp = nhp_move_params(nh->nh_home, nhp, tmphome, tmp);
- /* Set and save parameters to tmp */
- if (!nh->nh_used_ptags &&
- nhp_set_tags(tmphome, tmp, NULL, nh->nh_ptags) < 0)
- status = 900, phrase = "Error storing default handle parameters";
- else if (nhp_set_tags(tmphome, tmp, ngp, tags) < 0)
- status = 900, phrase = "Error storing parameters";
- else if (nhp_save_params(nh, tmphome, ngp, tmp) < 0)
- status = 900, phrase = su_strerror(ENOMEM);
- else
- status = 200, phrase = "OK", nh->nh_used_ptags = 1;
+ if (nhp)
+ nh->nh_prefs = nhp;
+ else
+ /* Fail miserably with ENOMEM */
+ error = 1, status = 900, phrase = su_strerror(ENOMEM);
+ }
- su_home_deinit(tmphome);
+ if (!error)
+ nh->nh_used_ptags = 1;
}
- if (status == 200) {
- nua_handle_preferences_t const *nhp = nh->nh_prefs;
- nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
+ su_home_deinit(tmphome);
- if (!nh->nh_soa && NHP_GET(nhp, dnhp, media_enable)) {
- /* Create soa when needed */
- char const *soa_name = NHP_GET(nhp, dnhp, soa_name);
+ if (error)
+ ;
+ else if (!nh->nh_soa && NHP_GET(nhp, dnhp, media_enable)) {
+ /* Create soa when needed */
+ char const *soa_name = NHP_GET(nhp, dnhp, soa_name);
- if (dnh->nh_soa)
- nh->nh_soa = soa_clone(dnh->nh_soa, nua->nua_root, nh);
- else
- nh->nh_soa = soa_create(soa_name, nua->nua_root, nh);
-
- if (!nh->nh_soa)
- status = 900, phrase = "Error Creating SOA Object";
- else if (soa_set_params(nh->nh_soa, TAG_NEXT(nh->nh_ptags)) < 0)
- status = 900, phrase = "Error Setting SOA Parameters";
- }
- else if (nh->nh_soa && !NHP_GET(nhp, dnhp, media_enable)) {
- /* ... destroy soa when not needed */
- soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
- }
+ if (dnh->nh_soa)
+ nh->nh_soa = soa_clone(dnh->nh_soa, nua->nua_root, nh);
+ else
+ nh->nh_soa = soa_create(soa_name, nua->nua_root, nh);
- if (status == 200 && tags && nh->nh_soa &&
- soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0)
- status = 900, phrase = "Error Setting SOA Parameters";
+ ptags = nh->nh_ptags;
+
+ if (!nh->nh_soa)
+ error = 1, status = 900, phrase = "Error Creating SOA Object";
+ }
+ else if (nh->nh_soa && !NHP_GET(nhp, dnhp, media_enable)) {
+ /* ... destroy soa when not needed */
+ soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
}
- if (status == 200 && nh == dnh) {
- /* Set stack-specific things below */
- if (nua_stack_set_smime_params(nua, tags) < 0) {
- status = 900, phrase = "Error setting S/MIME parameters";
- }
- else if (nua->nua_nta && nta_agent_set_params(nua->nua_nta, TAG_NEXT(tags)) < 0) {
- status = 900, phrase = "Error setting NTA parameters";
- }
- else {
- nua_stack_set_from(nua, 0, tags);
+ if (!error && nh->nh_soa) {
+ if ((ptags && soa_set_params(nh->nh_soa, TAG_NEXT(ptags)) < 0) ||
+ (tags && soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0))
+ error = 1, status = 900, phrase = "Error Setting SOA Parameters";
+ }
- if (nua->nua_prefs->ngp_detect_network_updates)
- nua_stack_launch_network_change_detector(nua);
- }
+ if (error || nh != dnh) {
+ ;
+ }
+ else if (nua_stack_set_smime_params(nua, tags) < 0) {
+ error = 1, status = 900, phrase = "Error setting S/MIME parameters";
+ }
+ else if (!nua->nua_nta) {
+ }
+ /* Set stack-specific things below */
+ else if (nta_agent_set_params(nua->nua_nta, TAG_NEXT(tags)) < 0) {
+ status = 900, phrase = "Error setting NTA parameters";
+ error = 1;
+ }
+ else {
+ nua_stack_set_from(nua, 0, tags);
+ if (NHP_ISSET(nhp, detect_network_updates))
+ nua_stack_launch_network_change_detector(nua);
}
- if (status != 200) {
+ if (error) {
if (e == nua_i_none)
SU_DEBUG_1(("nua_set_params(): failed: %s\n", phrase));
return UA_EVENT2(e, status, phrase), -1;
}
- else {
- if (e == nua_r_set_params)
- UA_EVENT2(e, status, phrase);
- return 0;
- }
-}
+ if (e == nua_r_set_params)
+ UA_EVENT2(e, 200, "OK");
+
+ return 0;
+}
-/** Parse parameters from tags to @a nhp or @a ngp.
+/** Parse parameters from tags to @a nhp.
*
* @param home allocate new values from @a home
* @param nhp structure to store handle preferences
- * @param ngp structure to store global preferences
+ * @param global if true, save also global parameters
* @param tags list of tags to parse
*/
static int nhp_set_tags(su_home_t *home,
nua_handle_preferences_t *nhp,
- nua_global_preferences_t *ngp,
+ int global,
tagi_t const *tags)
{
@@ -807,10 +826,6 @@
else if (tag == nutag_substate) {
NHP_SET(nhp, substate, (int)value);
}
- /* NUTAG_SUB_EXPIRES(sub_expires) */
- else if (tag == nutag_sub_expires) {
- NHP_SET(nhp, sub_expires, value);
- }
/* NUTAG_KEEPALIVE(keepalive) */
else if (tag == nutag_keepalive) {
NHP_SET(nhp, keepalive, (unsigned)value);
@@ -982,7 +997,7 @@
NHP_SET_STR(nhp, outbound, value);
}
/* NUTAG_DETECT_NETWORK_UPDATES(detect_network_updates) */
- else if (ngp && tag == nutag_detect_network_updates) {
+ else if (global && tag == nutag_detect_network_updates) {
int detector = (int)value;
if (detector < NUA_NW_DETECT_NOTHING)
@@ -990,13 +1005,7 @@
else if (detector > NUA_NW_DETECT_TRY_FULL)
detector = NUA_NW_DETECT_TRY_FULL;
- ngp->ngp_detect_network_updates = detector;
- ngp->ngp_set.ngp_detect_network_updates = 1;
- }
- /* NUTAG_SHUTDOWN_EVENTS() */
- else if (ngp && tag == nutag_shutdown_events) {
- ngp->ngp_shutdown_events = value != 0;
- ngp->ngp_set.ngp_shutdown_events = 1;
+ NHP_SET(nhp, detect_network_updates, detector);
}
}
@@ -1069,70 +1078,54 @@
return 1;
}
-/** Save parameters in @a gtmp and @a tmp.
- */
-static
-int nhp_save_params(nua_handle_t *nh,
- su_home_t *tmphome,
- nua_global_preferences_t *gsrc,
- nua_handle_preferences_t *src)
+static
+nua_handle_preferences_t *nhp_move_params(su_home_t *home,
+ nua_handle_preferences_t *dst,
+ su_home_t *tmphome,
+ nua_handle_preferences_t const *src)
{
- su_home_t *home = nh->nh_home;
- nua_t *nua = nh->nh_nua;
- nua_handle_t *dnh = nua->nua_dhandle;
- nua_handle_preferences_t *dst = nh->nh_prefs, old[1];
-
- if (gsrc) {
- *nua->nua_prefs = *gsrc; /* No pointers this far */
- }
+ /* Update prefs structure */
+ nua_handle_preferences_t tbf[1];
- if (!NHP_IS_ANY_SET(src))
- return 0;
+ if (dst == NULL)
+ dst = su_zalloc(home, sizeof *dst);
+ if (dst == NULL)
+ return NULL;
+ if (su_home_move(home, tmphome) < 0)
+ return NULL;
- if (nh == dnh || nh->nh_prefs != dnh->nh_prefs) {
- dst = nh->nh_prefs, *old = *dst;
- assert(dst);
- }
- else {
- dst = su_zalloc(home, sizeof *dst), memset(old, 0, sizeof *old);
- if (!dst)
- return -1;
- }
-
- /* Move allocations from tmphome to home */
- su_home_move(nh->nh_home, tmphome);
-
- /* Copy parameters that are set from src to dst */
+ *tbf = *dst;
nhp_or_set(dst, src);
/* Handle pointer items. Free changed ones and zap unset ones. */
- /* Note that pointer items where !NHP_ISSET(old, pref) are not freed
- (because they were just on loan from the default preference set) */
-#define NHP_ZAP_OVERRIDEN(old, dst, free, pref) \
- (((NHP_ISSET(old, pref) && \
- (old)->nhp_##pref && (old)->nhp_##pref != (dst)->nhp_##pref) \
- ? (free)(home, (void *)(old)->nhp_##pref) : (void)0), \
- (void)(!(dst)->nhp_set.nhb_##pref ? (dst)->nhp_##pref = NULL : NULL))
-
- NHP_ZAP_OVERRIDEN(old, dst, su_free, soa_name);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, registrar);
- NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, allow);
- NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, supported);
- NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, allow_events);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, user_agent);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, organization);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, m_display);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, m_username);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, m_params);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, m_features);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, instance);
- NHP_ZAP_OVERRIDEN(old, dst, su_free, outbound);
- NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, appl_method);
- NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, initial_route);
+#define NHP_ZAP_OVERRIDEN(tbf, nhp, pref) \
+ (((tbf)->nhp_set.nhb_##pref \
+ && (tbf)->nhp_##pref != (nhp)->nhp_##pref \
+ ? su_free(home, (void *)(tbf)->nhp_##pref) : (void)0), \
+ (void)(!(nhp)->nhp_set.nhb_##pref ? (nhp)->nhp_##pref = NULL : NULL))
+
+ NHP_ZAP_OVERRIDEN(tbf, dst, soa_name);
+ NHP_ZAP_OVERRIDEN(tbf, dst, registrar);
+ NHP_ZAP_OVERRIDEN(tbf, dst, supported);
+ NHP_ZAP_OVERRIDEN(tbf, dst, allow);
+ NHP_ZAP_OVERRIDEN(tbf, dst, user_agent);
+ NHP_ZAP_OVERRIDEN(tbf, dst, organization);
+ NHP_ZAP_OVERRIDEN(tbf, dst, instance);
+ NHP_ZAP_OVERRIDEN(tbf, dst, m_display);
+ NHP_ZAP_OVERRIDEN(tbf, dst, m_username);
+ NHP_ZAP_OVERRIDEN(tbf, dst, m_params);
+ NHP_ZAP_OVERRIDEN(tbf, dst, m_features);
+ NHP_ZAP_OVERRIDEN(tbf, dst, outbound);
+
+#define NHP_ZAP_OVERRIDEN_HDR(tbf, nhp, pref) \
+ (((tbf)->nhp_set.nhb_##pref \
+ && (tbf)->nhp_##pref != (nhp)->nhp_##pref \
+ ? msg_header_free(home, (void *)(tbf)->nhp_##pref) : (void)0), \
+ (void)(!(nhp)->nhp_set.nhb_##pref ? (nhp)->nhp_##pref = NULL : NULL))
- nh->nh_prefs = dst;
-
- return 0;
+ NHP_ZAP_OVERRIDEN_HDR(tbf, dst, initial_route);
+
+ return dst;
}
static int nua_handle_tags_filter(tagi_t const *f, tagi_t const *t);
@@ -1482,7 +1475,6 @@
* NUTAG_SMIME_SIGNATURE() \n
* NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n
- * NUTAG_SUB_EXPIRES() \n
* NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT() \n
* SIPTAG_ALLOW() \n
@@ -1523,7 +1515,6 @@
tagi_t const *tags)
{
nua_handle_t *dnh = nua->nua_dhandle;
- nua_global_preferences_t const *ngp = nua->nua_prefs;
nua_handle_preferences_t const *nhp = nh->nh_prefs;
tagi_t *lst;
@@ -1549,6 +1540,8 @@
enter;
+ su_home_auto(tmphome, sizeof(tmphome));
+
nta_agent_get_params(nua->nua_nta,
NTATAG_UDP_MTU_REF(udp_mtu),
NTATAG_MAX_PROCEEDING_REF(max_proceeding),
@@ -1597,8 +1590,6 @@
? sip_##pref##_make(tmphome, (char *)nhp->nhp_##pref) \
: NULL))
- su_home_auto(tmphome, sizeof(tmphome));
-
lst = tl_filtered_tlist
(tmphome, tags,
TAG_IF(has_from, SIPTAG_FROM(from)),
@@ -1639,7 +1630,6 @@
TIF(NUTAG_REFER_WITH_ID, refer_with_id),
TIF(NUTAG_SUBSTATE, substate),
- TIF(NUTAG_SUB_EXPIRES, sub_expires),
TIF(SIPTAG_SUPPORTED, supported),
TIF_STR(SIPTAG_SUPPORTED_STR, supported),
@@ -1668,18 +1658,11 @@
TIF(NUTAG_M_PARAMS, m_params),
TIF(NUTAG_M_FEATURES, m_features),
TIF(NUTAG_OUTBOUND, outbound),
+ TIF(NUTAG_DETECT_NETWORK_UPDATES, detect_network_updates),
/* Skip user-agent-level parameters if parameters are for handle only */
TAG_IF(nh != dnh, TAG_NEXT(media_params)),
- /* Include tag in the list returned to user
- * if it has been earlier set (by user) */
-#define GIF(TAG, pref) \
- TAG_IF(ngp->ngp_set.ngp_##pref, TAG(ngp->ngp_##pref))
-
- GIF(NUTAG_DETECT_NETWORK_UPDATES, detect_network_updates),
- GIF(NUTAG_SHUTDOWN_EVENTS, shutdown_events),
-
NTATAG_CONTACT(m),
#if HAVE_SOFIA_SMIME
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h Wed Feb 27 17:12:16 2008
@@ -107,7 +107,6 @@
/* Subscriber state, i.e. nua_substate_pending */
unsigned nhp_substate;
- unsigned nhp_sub_expires;
/* REGISTER keepalive intervals */
unsigned nhp_keepalive, nhp_keepalive_stream;
@@ -128,6 +127,9 @@
/** Outbound OPTIONS */
char const *nhp_outbound;
+ /** Network detection: NONE, INFORMAL, TRY_FULL */
+ int nhp_detect_network_updates;
+
sip_allow_t *nhp_appl_method;
/** Initial route set */
@@ -135,12 +137,6 @@
union { struct {
/* A bit for each feature set by application */
- /* NOTE:
- Some compilers behave weird if there are bitfields
- together with width > 32
- So there should be a padding field (unsigned:0;)
- every 32 bits.
- */
unsigned nhb_retry_count:1;
unsigned nhb_max_subscriptions:1;
@@ -170,15 +166,13 @@
unsigned nhb_refer_with_id:1;
unsigned nhb_refer_expires:1;
unsigned nhb_substate:1;
- unsigned nhb_sub_expires:1;
unsigned nhb_keepalive:1;
unsigned nhb_keepalive_stream:1;
unsigned nhb_registrar:1;
unsigned nhb_allow:1;
- unsigned :0; /* at most 32 bits before this point */
unsigned nhb_supported:1;
-
+ unsigned :0; /* at most 32 bits ... */
unsigned nhb_allow_events:1;
unsigned nhb_user_agent:1;
unsigned nhb_organization:1;
@@ -189,6 +183,7 @@
unsigned nhb_m_features:1;
unsigned nhb_instance:1;
unsigned nhb_outbound:1;
+ unsigned nhb_detect_network_updates:1;
unsigned nhb_appl_method:1;
unsigned nhb_initial_route:1;
unsigned :0;
@@ -199,26 +194,6 @@
#define nhp_set nhp_set_.set_bits
-/** Global preferences for nua. */
-typedef struct {
- /** Network detection: NONE, INFORMAL, TRY_FULL */
- signed int ngp_detect_network_updates:3;
- /** Pass events during shutdown, too */
- int ngp_shutdown_events:1;
-
- unsigned :0; /* pad */
- union { struct {
- /* A bit for each feature set by application */
- unsigned ngp_detect_network_updates:1;
- unsigned ngp_shutdown_events:1;
- unsigned :0;
- } set_bits;
- unsigned set_unsigned[2];
- } ngp_set_;
-} nua_global_preferences_t;
-
-#define ngp_set ngp_set_.set_bits
-
#define DNHP_GET(dnhp, pref) ((dnhp)->nhp_##pref)
#define NHP_GET(nhp, dnhp, pref) \
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_publish.c Wed Feb 27 17:12:16 2008
@@ -244,21 +244,19 @@
sip_t const *sip);
static nua_client_methods_t const nua_publish_client_methods = {
- SIP_METHOD_PUBLISH, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_PUBLISH,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 0,
/* target refresh */ 0
},
- nua_publish_client_template, /* crm_template */
- nua_publish_client_init, /* crm_init */
- nua_publish_client_request, /* crm_send */
- nua_publish_client_check_restart, /* crm_check_restart */
- nua_publish_client_response, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ nua_publish_client_template,
+ nua_publish_client_init,
+ nua_publish_client_request,
+ nua_publish_client_check_restart,
+ nua_publish_client_response,
+ /* nua_publish_client_preliminary */ NULL
};
/**@internal Send PUBLISH. */
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_register.c Wed Feb 27 17:12:16 2008
@@ -570,21 +570,18 @@
sip_t const *sip);
static nua_client_methods_t const nua_register_client_methods = {
- SIP_METHOD_REGISTER, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_REGISTER,
+ 0,
+ {
/* create_dialog */ 1,
/* in_dialog */ 0,
/* target refresh */ 0
},
- nua_register_client_template, /* crm_template */
- nua_register_client_init, /* crm_init */
- nua_register_client_request, /* crm_send */
- nua_register_client_check_restart, /* crm_check_restart */
- nua_register_client_response, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ nua_register_client_template,
+ nua_register_client_init,
+ nua_register_client_request,
+ nua_register_client_check_restart,
+ nua_register_client_response
};
/**@internal Send REGISTER. */
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c Wed Feb 27 17:12:16 2008
@@ -191,7 +191,7 @@
nua_dialog_usage_t *);
static int nua_invite_client_ack(nua_client_request_t *cr, tagi_t const *tags);
-static int nua_invite_client_complete(nua_client_request_t *cr);
+static int nua_invite_client_deinit(nua_client_request_t *cr);
static nua_usage_class const nua_session_usage[1] = {
{
@@ -238,8 +238,7 @@
cr = du->du_cr;
- if (cr && cr->cr_orq && cr->cr_status >= 200 &&
- cr->cr_method == sip_method_invite) {
+ if (cr && cr->cr_orq && cr->cr_status >= 200) {
ss->ss_reporting = 1;
nua_invite_client_ack(cr, NULL);
ss->ss_reporting = 0;
@@ -251,17 +250,14 @@
if (cr->cr_method != sip_method_invite)
continue;
-
if (cr == du->du_cr)
continue;
- if (cr->cr_status < 200) {
- nua_stack_event(nh->nh_nua, nh,
- NULL,
- cr->cr_event,
- SIP_481_NO_TRANSACTION,
- NULL);
- }
+ nua_stack_event(nh->nh_nua, nh,
+ NULL,
+ cr->cr_event,
+ SIP_481_NO_TRANSACTION,
+ NULL);
nua_client_request_destroy(cr);
@@ -546,21 +542,21 @@
tagi_t const *tags);
nua_client_methods_t const nua_invite_client_methods = {
- SIP_METHOD_INVITE, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_INVITE,
+ 0,
+ {
/* create_dialog */ 1,
/* in_dialog */ 1,
/* target refresh */ 1
},
- NULL, /* crm_template */
- nua_invite_client_init, /* crm_init */
- nua_invite_client_request, /* crm_send */
- session_timer_check_restart, /* crm_check_restart */
- nua_invite_client_response, /* crm_recv */
- nua_invite_client_preliminary, /* crm_preliminary */
- nua_invite_client_report, /* crm_report */
- nua_invite_client_complete, /* crm_complete */
+ NULL,
+ nua_invite_client_init,
+ nua_invite_client_request,
+ session_timer_check_restart,
+ nua_invite_client_response,
+ nua_invite_client_preliminary,
+ nua_invite_client_report,
+ nua_invite_client_deinit
};
extern nua_client_methods_t const nua_bye_client_methods;
@@ -608,15 +604,10 @@
if (!du)
return -1;
- ss = nua_dialog_usage_private(du);
-
- if (ss->ss_state >= nua_callstate_terminating)
- return nua_client_return(cr, 900, "Session is terminating", msg);
-
if (nua_client_bind(cr, du) < 0)
return nua_client_return(cr, 900, "INVITE already in progress", msg);
- cr->cr_neutral = 0;
+ ss = nua_dialog_usage_private(du);
session_timer_preferences(ss->ss_timer,
sip,
@@ -626,6 +617,8 @@
NH_PGET(nh, refresher),
NH_PGET(nh, min_se));
+ cr->cr_neutral = 0;
+
return 0;
}
@@ -642,9 +635,6 @@
if (du == NULL) /* Call terminated */
return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
- if (ss->ss_state >= nua_callstate_terminating)
- return nua_client_return(cr, 900, "Session is terminating", msg);
-
assert(ss);
invite_timeout = NH_PGET(nh, invite_timeout);
@@ -1057,7 +1047,7 @@
if (error < 0) {
if (ss->ss_reason == NULL)
ss->ss_reason = "SIP;cause=500;text=\"Internal Error\"";
- ss->ss_reporting = 1; /* We report terminated state here if BYE fails */
+ ss->ss_reporting = 1; /* We report state here if BYE fails */
error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
ss->ss_reporting = 0;
signal_call_state_change(nh, ss, 500, "Internal Error",
@@ -1100,7 +1090,6 @@
char const *invite_branch;
assert(cr->cr_orq);
- assert(cr->cr_method == sip_method_invite);
if (!ds->ds_leg) {
@@ -1237,8 +1226,8 @@
return error;
}
-/** Complete client request */
-static int nua_invite_client_complete(nua_client_request_t *cr)
+/** Deinitialize client request */
+static int nua_invite_client_deinit(nua_client_request_t *cr)
{
if (cr->cr_orq == NULL)
/* Xyzzy */;
@@ -1274,21 +1263,18 @@
tagi_t const *tags);
nua_client_methods_t const nua_cancel_client_methods = {
- SIP_METHOD_CANCEL, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_CANCEL,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 1,
/* target refresh */ 0
},
- NULL, /* crm_template */
- NULL, /* crm_init */
- nua_cancel_client_request, /* crm_send */
- NULL, /* crm_check_restart */
- NULL, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ NULL,
+ NULL,
+ nua_cancel_client_request,
+ /* nua_cancel_client_check_restart */ NULL,
+ /* nua_cancel_client_response */ NULL
};
int nua_stack_cancel(nua_t *nua, nua_handle_t *nh, nua_event_t e,
@@ -1507,21 +1493,20 @@
tagi_t const *tags);
nua_client_methods_t const nua_prack_client_methods = {
- SIP_METHOD_PRACK, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_PRACK,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 1,
/* target refresh */ 0
},
- NULL, /* crm_template */
- nua_prack_client_init, /* crm_init */
- nua_prack_client_request, /* crm_send */
- NULL, /* crm_check_restart */
- nua_prack_client_response, /* crm_recv */
- NULL, /* crm_preliminary */
- nua_prack_client_report, /* crm_report */
- NULL, /* crm_complete */
+ NULL,
+ nua_prack_client_init,
+ nua_prack_client_request,
+ /* nua_prack_client_check_restart */ NULL,
+ nua_prack_client_response,
+ NULL,
+ nua_prack_client_report
};
int nua_stack_prack(nua_t *nua, nua_handle_t *nh, nua_event_t e,
@@ -1557,8 +1542,6 @@
if (du == NULL) /* Call terminated */
return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
assert(ss);
- if (ss->ss_state >= nua_callstate_terminating)
- return nua_client_return(cr, 900, "Session is terminating", msg);
cri = du->du_cr;
@@ -1837,7 +1820,6 @@
{
nua_handle_t *nh = sr->sr_owner;
nua_t *nua = nh->nh_nua;
- nua_session_usage_t *ss;
sr->sr_neutral = 1;
@@ -1854,8 +1836,9 @@
nua_client_request_t const *cr;
for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) {
- /* Previous INVITE has not been ACKed */
- if (sr0->sr_method == sip_method_invite)
+ /* Final response have not been sent to previous INVITE */
+ if (sr0->sr_method == sip_method_invite &&
+ nua_server_request_is_pending(sr0))
break;
/* Or we have sent offer but have not received an answer */
if (sr->sr_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
@@ -1875,13 +1858,6 @@
/* Glare - RFC 3261 14.2 and RFC 3311 section 5.2 */
return SR_STATUS1(sr, SIP_491_REQUEST_PENDING);
}
-
- ss = nua_dialog_usage_private(sr->sr_usage);
-
- if (ss->ss_state < nua_callstate_ready &&
- ss->ss_state != nua_callstate_init) {
- return nua_server_retry_after(sr, 500, "Overlapping Requests 2", 0, 10);
- }
}
sr->sr_neutral = 0;
@@ -1911,11 +1887,6 @@
/* UPDATE/PRACK sent within an existing dialog? */
return SR_STATUS(sr, 481, "Call Does Not Exist");
}
- else if (sr->sr_usage) {
- nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
- if (ss->ss_state >= nua_callstate_terminating)
- return SR_STATUS(sr, 481, "Call is being terminated");
- }
if (nh->nh_soa) {
sip_accept_t *a = nua->nua_invite_accept;
@@ -2001,10 +1972,8 @@
session_timer_store(ss->ss_timer, request);
-#if 0 /* The glare and overlap tests should take care of this. */
- assert(ss->ss_state >= nua_callstate_completed ||
- ss->ss_state == nua_callstate_init);
-#endif
+ if (!(ss->ss_state >= nua_callstate_ready || ss->ss_state == nua_callstate_init))
+ return SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
if (NH_PGET(nh, auto_answer) ||
/* Auto-answer to re-INVITE unless auto_answer is set to 0 on handle */
@@ -2350,7 +2319,7 @@
nua_stack_event(nh->nh_nua, nh, NULL,
nua_i_media_error, status, phrase, NULL);
- ss->ss_reporting = 1; /* We report terminated state here if BYE fails */
+ ss->ss_reporting = 1; /* We report state here if BYE fails */
error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
ss->ss_reporting = 0;
@@ -2447,7 +2416,7 @@
/* send BYE, too, if 200 OK (or 183 to re-INVITE) timeouts */
ss->ss_reason = reason;
- ss->ss_reporting = 1; /* We report terminated state here if BYE fails */
+ ss->ss_reporting = 1; /* We report state here if BYE fails */
error = nua_client_create(nh, nua_r_bye, &nua_bye_client_methods, NULL);
ss->ss_reporting = 0;
@@ -2818,21 +2787,18 @@
tagi_t const *tags);
nua_client_methods_t const nua_info_client_methods = {
- SIP_METHOD_INFO, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_INFO,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 1,
/* target refresh */ 0
},
- NULL, /* crm_template */
- nua_info_client_init, /* crm_init */
- nua_info_client_request, /* crm_send */
- NULL, /* crm_check_restart */
- NULL, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ /*nua_info_client_template*/ NULL,
+ nua_info_client_init,
+ nua_info_client_request,
+ /*nua_info_client_check_restart*/ NULL,
+ /*nua_info_client_response*/ NULL
};
int
@@ -2968,21 +2934,20 @@
tagi_t const *tags);
nua_client_methods_t const nua_update_client_methods = {
- SIP_METHOD_UPDATE, /* crm_method, crm_method_name */
- 0, /* crm_extrasize of private data */
- { /* crm_flags */
+ SIP_METHOD_UPDATE,
+ 0, /* size of private data */
+ {
/* create_dialog */ 0,
/* in_dialog */ 1,
/* target refresh */ 1
},
- NULL, /* crm_template */
- nua_update_client_init, /* crm_init */
- nua_update_client_request, /* crm_send */
- session_timer_check_restart, /* crm_check_restart */
- nua_update_client_response, /* crm_recv */
- NULL, /* crm_preliminary */
- nua_update_client_report, /* crm_report */
- NULL, /* crm_complete */
+ NULL,
+ nua_update_client_init,
+ nua_update_client_request,
+ session_timer_check_restart,
+ nua_update_client_response,
+ NULL,
+ nua_update_client_report
};
int nua_stack_update(nua_t *nua, nua_handle_t *nh, nua_event_t e,
@@ -3017,8 +2982,6 @@
if (du == NULL) /* Call terminated */
return nua_client_return(cr, SIP_481_NO_TRANSACTION, msg);
assert(ss);
- if (ss->ss_state >= nua_callstate_terminating)
- return nua_client_return(cr, 900, "Session is terminating", msg);
cri = du->du_cr;
@@ -3434,21 +3397,20 @@
tagi_t const *tags);
nua_client_methods_t const nua_bye_client_methods = {
- SIP_METHOD_BYE, /* crm_method, crm_method_name */
- 0, /* crm_extrasize */
- { /* crm_flags */
+ SIP_METHOD_BYE,
+ 0,
+ {
/* create_dialog */ 0,
/* in_dialog */ 1,
/* target refresh */ 0
},
- NULL, /* crm_template */
- nua_bye_client_init, /* crm_init */
- nua_bye_client_request, /* crm_send */
- NULL, /* crm_check_restart */
- NULL, /* crm_recv */
- NULL, /* crm_preliminary */
- nua_bye_client_report, /* crm_report */
- NULL, /* crm_complete */
+ NULL,
+ nua_bye_client_init,
+ nua_bye_client_request,
+ /*nua_bye_client_check_restart*/ NULL,
+ /*nua_bye_client_response*/ NULL,
+ /*nua_bye_client_preliminary*/ NULL,
+ nua_bye_client_report
};
int
@@ -3481,9 +3443,7 @@
if (nh->nh_soa)
soa_terminate(nh->nh_soa, 0);
-
- du->du_cr = NULL;
- nua_client_bind(cr, du);
+ cr->cr_usage = du;
return 0;
}
@@ -3555,23 +3515,17 @@
else {
nua_session_usage_t *ss = nua_dialog_usage_private(du);
- if (ss->ss_reporting) {
- return 1; /* Somebody else's problem */
- }
- else if (cr->cr_waiting) {
- return 1; /* Application problem */
- }
-
signal_call_state_change(nh, ss, status, "to BYE",
nua_callstate_terminated);
- if (du &&
- (du->du_cr == NULL ||
- !nua_client_is_queued(du->du_cr) ||
- du->du_cr->cr_status >= 200)) {
- /* INVITE is completed, we can zap the session... */;
- cr->cr_usage = NULL;
- nua_session_usage_destroy(nh, ss);
+ if (ss && !ss->ss_reporting) {
+ if (du->du_cr == NULL ||
+ !nua_client_is_queued(du->du_cr) ||
+ du->du_cr->cr_status >= 200) {
+ /* INVITE is completed, we can zap the session... */;
+ cr->cr_usage = NULL;
+ nua_session_usage_destroy(nh, ss);
+ }
}
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c Wed Feb 27 17:12:16 2008
@@ -209,7 +209,7 @@
if (nua_stack_set_from(nua, 1, nua->nua_args) < 0)
return -1;
- if (nua->nua_prefs->ngp_detect_network_updates)
+ if (NHP_ISSET(dnh->nh_prefs, detect_network_updates))
nua_stack_launch_network_change_detector(nua);
nua_stack_timer(nua, nua->nua_timer, NULL);
@@ -293,8 +293,7 @@
if ((event > nua_r_authenticate && event <= nua_r_ack)
|| event < nua_i_error
|| (nh && !nh->nh_valid)
- || (nua->nua_shutdown && event != nua_r_shutdown &&
- !nua->nua_prefs->ngp_shutdown_events)) {
+ ) {
if (msg)
msg_destroy(msg);
return event;
@@ -2076,13 +2075,6 @@
return cr;
}
-void nua_client_request_complete(nua_client_request_t *cr)
-{
- nua_client_request_remove(cr);
- if (cr && cr->cr_methods->crm_complete)
- cr->cr_methods->crm_complete(cr);
-}
-
void nua_client_request_destroy(nua_client_request_t *cr)
{
nua_handle_t *nh;
@@ -2090,12 +2082,14 @@
if (cr == NULL)
return;
- nua_client_request_complete(cr);
+ if (cr->cr_methods->crm_deinit)
+ cr->cr_methods->crm_deinit(cr);
nh = cr->cr_owner;
nua_destroy_signal(cr->cr_signal);
+ nua_client_request_remove(cr);
nua_client_bind(cr, NULL);
if (cr->cr_msg)
@@ -2104,6 +2098,7 @@
if (cr->cr_orq)
nta_outgoing_destroy(cr->cr_orq);
+
cr->cr_orq = NULL;
if (cr->cr_timer)
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h Wed Feb 27 17:12:16 2008
@@ -217,31 +217,28 @@
su_clone_r nua_clone;
su_task_r nua_client;
+ su_network_changed_t *nua_nw_changed;
+
nua_callback_f nua_callback;
nua_magic_t *nua_magic;
nua_event_frame_t *nua_current;
nua_saved_event_t nua_signal[1];
- /**< Used by stop-and-wait args calls */
- tagi_t const *nua_args;
-
/* Engine state flags */
- sip_time_t nua_shutdown;
-
unsigned nua_shutdown_started:1; /**< Shutdown initiated */
unsigned nua_shutdown_final:1; /**< Shutdown is complete */
unsigned nua_from_is_set;
unsigned :0;
- /**< Local SIP address. Contents are kept around for ever. */
- sip_from_t nua_from[1];
+ /**< Used by stop-and-wait args calls */
+ tagi_t const *nua_args;
- /* ---------------------------------------------------------------------- */
+ /**< Local SIP address. Contents are kept around for ever. */
+ sip_from_t nua_from[1];
/* Protocol (server) side */
- su_network_changed_t *nua_nw_changed;
nua_registration_t *nua_registrations; /**< Active registrations */
@@ -253,8 +250,21 @@
nta_agent_t *nua_nta;
su_timer_t *nua_timer;
+ void *nua_sip_parser;
+
+ sip_time_t nua_shutdown;
+
+ /* Route */
+ sip_service_route_t *nua_service_route;
+
/* User-agent parameters */
- nua_global_preferences_t nua_prefs[1];
+ unsigned nua_media_enable:1;
+
+ unsigned :0;
+
+#if HAVE_SMIME /* Start NRC Boston */
+ sm_object_t *sm;
+#endif /* End NRC Boston */
nua_handle_t *nua_handles;
nua_handle_t **nua_handles_tail;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c Wed Feb 27 17:12:16 2008
@@ -183,21 +183,18 @@
sip_t const *sip);
static nua_client_methods_t const nua_subscribe_client_methods = {
- SIP_METHOD_SUBSCRIBE, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_SUBSCRIBE,
+ 0,
+ {
/* create_dialog */ 1,
/* in_dialog */ 1,
/* target refresh */ 1
},
- NULL, /* crm_template */
- nua_subscribe_client_init, /* crm_init */
- nua_subscribe_client_request, /* crm_send */
- NULL, /* crm_check_restart */
- nua_subscribe_client_response, /* crm_recv */
- NULL, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ NULL,
+ nua_subscribe_client_init,
+ nua_subscribe_client_request,
+ /* nua_subscribe_client_check_restart */ NULL,
+ nua_subscribe_client_response
};
int
@@ -371,9 +368,6 @@
else
delta = 0;
- if (delta > eu->eu_expires)
- delta = eu->eu_expires;
-
if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) {
/* Notify from messanger does not match with dialog tag */
nh->nh_ds->ds_remote_tag = su_strdup(nh->nh_home, "");
@@ -653,6 +647,8 @@
if (substate == nua_substate_active || substate == nua_substate_pending) {
if (subs && subs->ss_expires)
delta = strtoul(subs->ss_expires, NULL, 10);
+ else
+ delta = eu->eu_expires;
}
else if (substate == nua_substate_embryonic) {
if (subs && subs->ss_reason) {
@@ -690,8 +686,7 @@
nua_dialog_usage_set_refresh_range(du, retry, retry + 5);
}
else {
- if (delta < SIP_TIME_MAX)
- nua_dialog_usage_set_refresh(du, delta);
+ nua_dialog_usage_set_refresh(du, delta);
}
return retval;
@@ -782,21 +777,20 @@
sip_t const *sip);
static nua_client_methods_t const nua_refer_client_methods = {
- SIP_METHOD_REFER, /* crm_method, crm_method_name */
- 0, /* crm_extra */
- { /* crm_flags */
+ SIP_METHOD_REFER,
+ 0,
+ {
/* create_dialog */ 1,
/* in_dialog */ 1,
/* target refresh */ 1
},
- NULL, /* crm_template */
- nua_refer_client_init, /* crm_init */
- nua_refer_client_request, /* crm_send */
- NULL, /* crm_check_restart */
- nua_refer_client_response, /* crm_recv */
- nua_refer_client_response, /* crm_preliminary */
- NULL, /* crm_report */
- NULL, /* crm_complete */
+ /*nua_refer_client_template*/ NULL,
+ nua_refer_client_init,
+ nua_refer_client_request,
+ /* nua_refer_client_check_restart */ NULL,
+ nua_refer_client_response,
+ nua_refer_client_response, /* Preliminary */
+ NULL
};
int
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c Wed Feb 27 17:12:16 2008
@@ -227,22 +227,21 @@
* - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and
* SIPTAG_ALLOW_EVENTS_STR()
* - NUTAG_MAX_SUBSCRIPTIONS()
- * - NUTAG_SUBSTATE(), NUTAG_SUB_EXPIRES()
+ * - NUTAG_SUBSTATE()
* @par Specifications
* - @RFC3265
*
* @par SIP Event Subscriber
* - nua_subscribe(), #nua_r_subscribe, #nua_i_notify, NUTAG_SUBSTATE(),
- * SIPTAG_EVENT(), SIPTAG_EXPIRES()
+ * SIPTAG_EVENT(), SIPTAG_EXPIRES(),
* - nua_unsubscribe(), #nua_r_unsubscribe()
* @par Specifications
* - @RFC3265
*
* @par SIP Event Notifier
* - #nua_i_subscribe(), nua_notify(), #nua_r_notify,
- * NUTAG_SUBSTATE(), NUTAG_SUB_EXPIRES(), SIPTAG_EVENT()
+ * NUTAG_SUBSTATE(), SIPTAG_EVENT()
* Settings:
- * - NUTAG_SUB_EXPIRES()
* - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and
* SIPTAG_ALLOW_EVENTS_STR()
* - NUTAG_ALLOW("SUBSCRIBE"), NUTAG_APPL_METHOD("SUBSCRIBE")
@@ -268,8 +267,6 @@
* Settings:
* - NUTAG_ALLOW(x), NUTAG_APPL_METHOD(x)
*
- * @par Server Shutdown
- * - nua_shutdown(), NUTAG_SHUTDOWN_EVENTS(), nua_destroy().
*/
/* @par S/MIME
@@ -770,14 +767,14 @@
*
* @par Used with
* - with nua_create(), nua_set_params(), nua_get_params(),
- * nua_handle(), nua_set_hparams(), nua_get_hparams(), and
- * nua_notifier() to change the default subscription state returned by
- * the internal event server
+ * nua_handle(), nua_set_hparams(), nua_get_hparams(), and
+ * nua_notifier() to change the default subscription state returned by
+ * the intenal event server
* - with nua_notify() and nua_respond() to SUBSCRIBE to determine the
- * subscription state (if application include @SubscriptionState
- * header in the tag list, the NUTAG_SUBSTATE() value is ignored)
+ * subscription state (if application include @SubscriptionState
+ * header in the tag list, the NUTAG_SUBSTATE() value is ignored)
* - with #nua_r_subscribe, #nua_i_notify, #nua_i_subscribe, and #nua_r_notify
- * to indicate the current subscription state
+ * to indicate the current subscription state
*
* @par Parameter type
* int
@@ -809,39 +806,6 @@
*/
-/**@def NUTAG_SUB_EXPIRES()
- *
- * Default expiration time of subscriptions.
- *
- * @par Used with
- * - with nua_create(), nua_set_params(), nua_get_params(), nua_handle(),
- * nua_set_hparams(), nua_get_hparams(), nua_respond(), nua_notify(), and
- * nua_notifier() to change the default expiration time of subscriptions
- *
- * @par Parameter type
- * unsigned int
- *
- * @par Values
- * - default expiration time in seconds
- *
- * Note that the expires parameter in @SubscriptionState or @Expires header
- * in the nua_response() to the SUBSCRIBE overrides the default subscription
- * expiration specified by NUTAG_SUB_EXPIRES().
- *
- * @sa @RFC3265, NUTAG_REFER_EXPIRES(), @Expires, SIPTAG_EXPIRES(),
- * SIPTAG_EXPIRES_STR(), @SubscriptionState, nua_respond(), nua_notifier(),
- * #nua_r_subscribe, #nua_i_subscribe, #nua_r_refer, #nua_r_notify,
- * #nua_i_notify.
- *
- * Corresponding tag taking reference parameter is NUTAG_SUB_EXPIRES_REF().
- */
-tag_typedef_t nutag_sub_expires = UINTTAG_TYPEDEF(substate);
-
-/**@def NUTAG_SUB_EXPIRES_REF(x)
- * Reference tag for NUTAG_SUB_EXPIRES().
- */
-
-
/**@def NUTAG_NEWSUB()
*
* Send unsolicited NOTIFY request.
@@ -1111,17 +1075,17 @@
* REFER.
*
* @par Used with
- * nua_handle(), nua_respond() \n
- * nua_set_params() or nua_set_hparams() \n
- * nua_get_params() or nua_get_hparams()
+ * nua_set_params() \n
+ * nua_get_params() \n
+ * nua_set_hparams() \n
+ * nua_get_hparams() \n
*
* @par Parameter type
* unsigned int
*
* @par Values
- * - default interval in seconds
- *
- * @sa NUTAG_SUB_EXPIRES()
+ * @c 0 disable \n
+ * @c >0 interval in seconds
*
* Corresponding tag taking reference parameter is NUTAG_REFER_EXPIRES_REF().
*/
@@ -1606,9 +1570,6 @@
* NUTAG_INITIAL_ROUTE_STR() tags, the route set is constructed from them
* all.
*
- * The initial route is inserted into request message before the route
- * entries set with SIPTAG_ROUTE() or SIPTAG_ROUTE_STR().
- *
* @par Used with
* nua_set_params() \n
* nua_set_hparams() \n
@@ -2775,39 +2736,6 @@
* Reference tag for NUTAG_SIP_PARSER().
*/
-
-/**@def NUTAG_SHUTDOWN_EVENTS(x)
- *
- * Allow passing of normal events when stack is being shut down.
- *
- * By default, only #nua_r_shutdown events are passed to application after
- * calling nua_shutdown(). If application is interested in nua events during
- * shutdown, it should give NUTAG_SHUTDOWN_EVENTS(1) to nua_create() or
- * nua_set_params() called before nua_shutdown().
- *
- * @par Used with
- * nua_create(), nua_set_params().
- *
- * @par Parameter type
- * int (boolean)
- *
- * @par Values
- * @c 0 False \n
- * @c !=0 True
- *
- * Corresponding tag taking reference parameter is NUTAG_SHUTDOWN_EVENTS_REF().
- *
- * @sa nua_shutdown(), nua_destroy().
- *
- * @NEW_1_12_9.
- */
-tag_typedef_t nutag_shutdown_events = BOOLTAG_TYPEDEF(shutdown_events);
-
-/**@def NUTAG_SHUTDOWN_EVENTS_REF(x)
- * Reference tag for NUTAG_SHUTDOWN_EVENTS().
- */
-
-
/* ---------------------------------------------------------------------- */
tag_typedef_t nutag_soa_session = PTRTAG_TYPEDEF(soa_session);
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h Wed Feb 27 17:12:16 2008
@@ -497,16 +497,12 @@
/** Convert string to enum nua_substate. @NEW_1_12_5. */
SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate);
-#define NUTAG_SUB_EXPIRES(x) nutag_sub_expires, tag_uint_v(x)
-SOFIAPUBVAR tag_typedef_t nutag_sub_expires;
-#define NUTAG_SUB_EXPIRES_REF(x) nutag_sub_expires_ref, tag_uint_vr(&(x))
-SOFIAPUBVAR tag_typedef_t nutag_sub_expires_ref;
-
#define NUTAG_NEWSUB(x) nutag_newsub, tag_bool_v(x)
SOFIAPUBVAR tag_typedef_t nutag_newsub;
#define NUTAG_NEWSUB_REF(x) nutag_newsub_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_newsub_ref;
+
#define NUTAG_REFER_EXPIRES(x) nutag_refer_expires, tag_uint_v((x))
SOFIAPUBVAR tag_typedef_t nutag_refer_expires;
#define NUTAG_REFER_EXPIRES_REF(x) nutag_refer_expires_ref, tag_uint_vr((&(x)))
@@ -573,13 +569,6 @@
nutag_detect_network_updates_ref, tag_int_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_detect_network_updates_ref;
-#define NUTAG_SHUTDOWN_EVENTS(x) \
- nutag_shutdown_events, tag_bool_v(x)
-SOFIAPUBVAR tag_typedef_t nutag_shutdown_events;
-#define NUTAG_SHUTDOWN_EVENTS_REF(x) \
- nutag_shutdown_events_ref, tag_bool_vr(&(x))
-SOFIAPUBVAR tag_typedef_t nutag_shutdown_events_ref;
-
/* Pass nua handle as tagged argument */
#if SU_INLINE_TAG_CAST
su_inline tag_value_t nutag_handle_v(nua_handle_t *v) { return (tag_value_t)v; }
1
0
27 Feb '08
Author: mikej
Date: Wed Feb 27 17:11:44 2008
New Revision: 7761
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am
Log:
undo my oops
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am Wed Feb 27 17:11:44 2008
@@ -51,10 +51,9 @@
test_call_reject.c test_cancel_bye.c \
test_call_hold.c test_session_timer.c \
test_refer.c test_100rel.c \
- test_sip_events.c test_simple.c \
+ test_simple.c test_sip_events.c \
test_extension.c
-
libtestproxy_la_SOURCES = test_proxy.h test_proxy.c
libtestnat_la_SOURCES = test_nat.h test_nat.c test_nat_tags.c
1
0
[commit] r7760 - in freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua: . sofia-sip
by Freeswitch SVN 27 Feb '08
by Freeswitch SVN 27 Feb '08
27 Feb '08
Author: mikej
Date: Wed Feb 27 16:58:17 2008
New Revision: 7760
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c
Log:
can't pull patches one at a time because they don't compile
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c Wed Feb 27 16:58:17 2008
@@ -1854,9 +1854,8 @@
nua_client_request_t const *cr;
for (sr0 = nh->nh_ds->ds_sr; sr0; sr0 = sr0->sr_next) {
- /* Final response have not been sent to previous INVITE */
- if (sr0->sr_method == sip_method_invite &&
- nua_server_request_is_pending(sr0))
+ /* Previous INVITE has not been ACKed */
+ if (sr0->sr_method == sip_method_invite)
break;
/* Or we have sent offer but have not received an answer */
if (sr->sr_sdp && sr0->sr_offer_sent && !sr0->sr_answer_recv)
@@ -1879,10 +1878,8 @@
ss = nua_dialog_usage_private(sr->sr_usage);
- if (ss->ss_state < nua_callstate_completed &&
+ if (ss->ss_state < nua_callstate_ready &&
ss->ss_state != nua_callstate_init) {
- /* We should never trigger this,
- but better not to assert() on network input */
return nua_server_retry_after(sr, 500, "Overlapping Requests 2", 0, 10);
}
}
@@ -1917,7 +1914,7 @@
else if (sr->sr_usage) {
nua_session_usage_t *ss = nua_dialog_usage_private(sr->sr_usage);
if (ss->ss_state >= nua_callstate_terminating)
- return SR_STATUS1(sr, 481, "Call is being terminated");
+ return SR_STATUS(sr, 481, "Call is being terminated");
}
if (nh->nh_soa) {
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c Wed Feb 27 16:58:17 2008
@@ -293,7 +293,8 @@
if ((event > nua_r_authenticate && event <= nua_r_ack)
|| event < nua_i_error
|| (nh && !nh->nh_valid)
- || (nua->nua_shutdown && event != nua_r_shutdown)) {
+ || (nua->nua_shutdown && event != nua_r_shutdown &&
+ !nua->nua_prefs->ngp_shutdown_events)) {
if (msg)
msg_destroy(msg);
return event;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h Wed Feb 27 16:58:17 2008
@@ -507,7 +507,6 @@
#define NUTAG_NEWSUB_REF(x) nutag_newsub_ref, tag_bool_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_newsub_ref;
-
#define NUTAG_REFER_EXPIRES(x) nutag_refer_expires, tag_uint_v((x))
SOFIAPUBVAR tag_typedef_t nutag_refer_expires;
#define NUTAG_REFER_EXPIRES_REF(x) nutag_refer_expires_ref, tag_uint_vr((&(x)))
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c Wed Feb 27 16:58:17 2008
@@ -1433,6 +1433,9 @@
a_call->sdp = "m=audio 5008 RTP/AVP 8";
c_call->sdp = "m=audio 5010 RTP/AVP 0 8";
+ if (!ctx->proxy_tests)
+ return 0;
+
/* BYE after receiving 401
A C
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua.h Wed Feb 27 16:58:17 2008
@@ -178,7 +178,10 @@
unsigned bit4:1, bit5:1, bit6:1, bit7:1;
unsigned :0;
} flags;
-
+ /* Accross-run state information */
+ struct {
+ unsigned n;
+ } state;
} a, b, c;
struct proxy *p;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c Wed Feb 27 16:58:17 2008
@@ -182,6 +182,12 @@
ep->name, (void *)nh, nua_event_name(event), phrase,
nua_substate_name(t ? t->t_value : 0));
}
+ else if ((int)event >= nua_i_bye ||
+ event == nua_i_invite || event == nua_i_cancel ||
+ event == nua_i_ack) {
+ fprintf(stderr, "%s %s.nua(%p): event %s %03d %s\n", timestamp,
+ ep->name, (void *)nh, nua_event_name(event), status, phrase);
+ }
else if ((int)event >= 0) {
fprintf(stderr, "%s %s.nua(%p): event %s %s\n", timestamp,
ep->name, (void *)nh, nua_event_name(event), phrase);
1
0
[commit] r7759 - in freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua: . sofia-sip
by Freeswitch SVN 27 Feb '08
by Freeswitch SVN 27 Feb '08
27 Feb '08
Author: mikej
Date: Wed Feb 27 16:57:19 2008
New Revision: 7759
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c
Log:
Wed Feb 6 12:05:46 EST 2008 Pekka.Pessi(a)nokia.com
* nua: using global preferences. Added NUTAG_SHUTDOWN_EVENTS().
Mon Feb 25 14:14:15 EST 2008 Pekka.Pessi(a)nokia.com
* nua: added NUTAG_SUB_EXPIRES()
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_notifier.c Wed Feb 27 16:57:19 2008
@@ -237,7 +237,8 @@
sip_event_t *o = sip->sip_event;
char const *event = o ? o->o_type : NULL;
/* Maximum expiration time */
- unsigned long expires = 3600;
+ unsigned long expires = sip->sip_expires ? sip->sip_expires->ex_delta : 3600;
+ sip_time_t now = sip_now();
assert(nh && nh->nh_nua->nua_dhandle != nh);
@@ -259,9 +260,10 @@
nu = nua_dialog_usage_private(du);
- if (sip->sip_expires && sip->sip_expires->ex_delta < expires)
- expires = sip->sip_expires->ex_delta;
- nu->nu_requested = sip_now() + expires;
+ if (now + expires >= now)
+ nu->nu_requested = now + expires;
+ else
+ nu->nu_requested = SIP_TIME_MAX - 1;
#if SU_HAVE_EXPERIMENTAL
nu->nu_etags =
@@ -295,9 +297,23 @@
sip_time_t now = sip_now();
if (nu->nu_requested) {
- if (nu->nu_requested > nu->nu_expires)
+ if (sip->sip_expires) {
+ /* Expires in response can only shorten the expiration time */
+ if (nu->nu_requested > now + sip->sip_expires->ex_delta)
+ nu->nu_requested = now + sip->sip_expires->ex_delta;
+ }
+ else {
+ unsigned sub_expires = NH_PGET(sr->sr_owner, sub_expires);
+ if (nu->nu_requested > now + sub_expires)
+ nu->nu_requested = now + sub_expires;
+ }
+
+ if (nu->nu_requested >= now)
nu->nu_expires = nu->nu_requested;
- else if (nu->nu_expires <= now || nu->nu_requested <= now)
+ else
+ nu->nu_expires = now;
+
+ if (nu->nu_expires <= now)
nu->nu_substate = nua_substate_terminated;
}
@@ -305,7 +321,7 @@
ex->ex_delta = nu->nu_expires - now;
}
else {
- /* Add header Expires: 0 */
+ /* Always add header Expires: 0 */
}
if (!sip->sip_expires || sip->sip_expires->ex_delta > ex->ex_delta)
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.c Wed Feb 27 16:57:19 2008
@@ -77,19 +77,27 @@
su_inline void nhp_or_set(nua_handle_preferences_t *a,
nua_handle_preferences_t const *b)
{
- unsigned *ap = a->nhp_set_.set_unsigned;
- unsigned const *bp = b->nhp_set_.set_unsigned;
- size_t i;
-
memcpy(a, b, offsetof(nua_handle_preferences_t, nhp_set));
+ /* Bitwise or of bitfields, casted to unsigned */
+ a->nhp_set_.set_unsigned[0] |= b->nhp_set_.set_unsigned[0];
+ a->nhp_set_.set_unsigned[1] |= b->nhp_set_.set_unsigned[1];
+
+ /*
+ unsigned *ap, const *bp;
+ size_t i;
+
+ ap = a->nhp_set_.set_unsigned;
+ bp = b->nhp_set_.set_unsigned;
for (i = 0; i < (sizeof a->nhp_set); i += (sizeof *ap))
*ap++ |= *bp++;
+
+ */
}
static int nhp_set_tags(su_home_t *home,
nua_handle_preferences_t *nhp,
- int global,
+ nua_global_preferences_t *ngp,
tagi_t const *tags);
static int nhp_merge_lists(su_home_t *home,
@@ -101,11 +109,11 @@
int always_merge,
tag_value_t value);
-static
-nua_handle_preferences_t *nhp_move_params(su_home_t *home,
- nua_handle_preferences_t *dst,
- su_home_t *tmphome,
- nua_handle_preferences_t const *src);
+static int nhp_save_params(nua_handle_t *nh,
+ su_home_t *tmphome,
+ nua_global_preferences_t *gsrc,
+ nua_handle_preferences_t *src);
+
/* ====================================================================== */
/* Magical NUTAG_USER_AGENT() - add NHP_USER_AGENT there if it is not there */
@@ -199,20 +207,12 @@
sip_from_t *f = NULL, f0[1];
int set;
- char const *uicc_name = "default";
-
tl_gets(tags,
/* By nua_stack_set_from() */
SIPTAG_FROM_REF(from),
SIPTAG_FROM_STR_REF(str),
- NUTAG_UICC_REF(uicc_name),
TAG_END());
-#if HAVE_UICC_H
- if (initial && uicc_name)
- nua->nua_uicc = uicc_create(root, uicc_name);
-#endif
-
if (!initial && from == NONE && str == NONE)
return 0;
@@ -326,6 +326,7 @@
* NUTAG_SMIME_SIGNATURE() \n
* NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n
+ * NUTAG_SUB_EXPIRES() \n
* NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n
* NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n
@@ -438,6 +439,7 @@
* NUTAG_SESSION_TIMER() \n
* NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n
+ * NUTAG_SUB_EXPIRES() \n
* NUTAG_SUPPORTED(), SIPTAG_SUPPORTED(), and SIPTAG_SUPPORTED_STR() \n
* NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT(), SIPTAG_USER_AGENT() and SIPTAG_USER_AGENT_STR() \n
@@ -476,146 +478,124 @@
tagi_t const *tags)
{
nua_handle_t *dnh = nua->nua_dhandle;
- nua_handle_preferences_t tmp[1], *nhp = nh->nh_prefs;
- nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
-
- su_home_t tmphome[1] = { SU_HOME_INIT(tmphome) };
-
- tagi_t const *ptags;
-
- int error, global;
- int status = 900;
- char const *phrase = "Error storing parameters";
- sip_supported_t const *supported = NULL;
- sip_allow_t const *allow = NULL;
- sip_allow_events_t const *allow_events = NULL;
- sip_allow_t const *appl_method = NULL;
+
+ int status;
+ char const *phrase;
enter;
- ptags = !nh->nh_used_ptags ? nh->nh_ptags : NULL;
-
- *tmp = *nhp; NHP_UNSET_ALL(tmp);
-
- /* Supported features, allowed methods and events are merged
- with previous ones */
- if (!NHP_ISSET(nhp, supported))
- supported = tmp->nhp_supported = dnhp->nhp_supported;
- if (!NHP_ISSET(nhp, allow))
- allow = tmp->nhp_allow = dnhp->nhp_allow;
- if (!NHP_ISSET(nhp, allow_events))
- allow_events = tmp->nhp_allow_events = dnhp->nhp_allow_events;
- if (!NHP_ISSET(nhp, appl_method))
- appl_method = tmp->nhp_appl_method = dnhp->nhp_appl_method;
-
- error = 0;
- global = nh == dnh; /* save also stack-specific params */
+ {
+ su_home_t tmphome[1] = { SU_HOME_INIT(tmphome) };
+ nua_handle_preferences_t *nhp = nh->nh_prefs;
+ nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
+ nua_handle_preferences_t tmp[1];
+ nua_global_preferences_t gtmp[1], *ngp = NULL;
+
+ *tmp = *nhp; NHP_UNSET_ALL(tmp);
+
+ /*
+ * Supported features, allowed methods and events are merged
+ * with previous or default settings.
+ *
+ * Here we just copy pointers from default settings. However when saving
+ * settings we have to be extra careful so that we
+ * 1) zero the pointers if the setting has not been modified
+ * 2) do not free pointer if the setting has been modified
+ * See NHP_ZAP_OVERRIDEN() below for gorier details.
+ */
+ if (!NHP_ISSET(nhp, supported))
+ tmp->nhp_supported = dnhp->nhp_supported;
+ if (!NHP_ISSET(nhp, allow))
+ tmp->nhp_allow = dnhp->nhp_allow;
+ if (!NHP_ISSET(nhp, allow_events))
+ tmp->nhp_allow_events = dnhp->nhp_allow_events;
+ if (!NHP_ISSET(nhp, appl_method))
+ tmp->nhp_appl_method = dnhp->nhp_appl_method;
- /* Set and save parameters to tmp */
- if (nhp_set_tags(tmphome, tmp, global, ptags) < 0)
- error = 1, phrase = "Error storing default handle parameters";
- else if (nhp_set_tags(tmphome, tmp, global, tags) < 0)
- error = 1, phrase = "Error storing parameters";
- else {
- if (NHP_IS_ANY_SET(tmp)) {
- if (tmp->nhp_supported == supported)
- tmp->nhp_supported = NULL;
-
- if (tmp->nhp_allow == allow)
- tmp->nhp_allow = NULL;
-
- if (tmp->nhp_allow_events == allow_events)
- tmp->nhp_allow_events = NULL;
-
- if (tmp->nhp_appl_method == appl_method)
- tmp->nhp_appl_method = NULL;
-
- /* Move parameters from tmp to nhp (or allocate new nhp) */
- if (nh != dnh && nhp == dnh->nh_prefs)
- nhp = NULL;
- nhp = nhp_move_params(nh->nh_home, nhp, tmphome, tmp);
+ if (nh == dnh) /* nua_set_params() call, save stack-wide params, too */
+ ngp = gtmp, *gtmp = *nua->nua_prefs;
- if (nhp)
- nh->nh_prefs = nhp;
- else
- /* Fail miserably with ENOMEM */
- error = 1, status = 900, phrase = su_strerror(ENOMEM);
- }
+ /* Set and save parameters to tmp */
+ if (!nh->nh_used_ptags &&
+ nhp_set_tags(tmphome, tmp, NULL, nh->nh_ptags) < 0)
+ status = 900, phrase = "Error storing default handle parameters";
+ else if (nhp_set_tags(tmphome, tmp, ngp, tags) < 0)
+ status = 900, phrase = "Error storing parameters";
+ else if (nhp_save_params(nh, tmphome, ngp, tmp) < 0)
+ status = 900, phrase = su_strerror(ENOMEM);
+ else
+ status = 200, phrase = "OK", nh->nh_used_ptags = 1;
- if (!error)
- nh->nh_used_ptags = 1;
+ su_home_deinit(tmphome);
}
- su_home_deinit(tmphome);
-
- if (error)
- ;
- else if (!nh->nh_soa && NHP_GET(nhp, dnhp, media_enable)) {
- /* Create soa when needed */
- char const *soa_name = NHP_GET(nhp, dnhp, soa_name);
+ if (status == 200) {
+ nua_handle_preferences_t const *nhp = nh->nh_prefs;
+ nua_handle_preferences_t const *dnhp = dnh->nh_prefs;
- if (dnh->nh_soa)
- nh->nh_soa = soa_clone(dnh->nh_soa, nua->nua_root, nh);
- else
- nh->nh_soa = soa_create(soa_name, nua->nua_root, nh);
+ if (!nh->nh_soa && NHP_GET(nhp, dnhp, media_enable)) {
+ /* Create soa when needed */
+ char const *soa_name = NHP_GET(nhp, dnhp, soa_name);
- ptags = nh->nh_ptags;
+ if (dnh->nh_soa)
+ nh->nh_soa = soa_clone(dnh->nh_soa, nua->nua_root, nh);
+ else
+ nh->nh_soa = soa_create(soa_name, nua->nua_root, nh);
+
+ if (!nh->nh_soa)
+ status = 900, phrase = "Error Creating SOA Object";
+ else if (soa_set_params(nh->nh_soa, TAG_NEXT(nh->nh_ptags)) < 0)
+ status = 900, phrase = "Error Setting SOA Parameters";
+ }
+ else if (nh->nh_soa && !NHP_GET(nhp, dnhp, media_enable)) {
+ /* ... destroy soa when not needed */
+ soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
+ }
- if (!nh->nh_soa)
- error = 1, status = 900, phrase = "Error Creating SOA Object";
- }
- else if (nh->nh_soa && !NHP_GET(nhp, dnhp, media_enable)) {
- /* ... destroy soa when not needed */
- soa_destroy(nh->nh_soa), nh->nh_soa = NULL;
+ if (status == 200 && tags && nh->nh_soa &&
+ soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0)
+ status = 900, phrase = "Error Setting SOA Parameters";
}
- if (!error && nh->nh_soa) {
- if ((ptags && soa_set_params(nh->nh_soa, TAG_NEXT(ptags)) < 0) ||
- (tags && soa_set_params(nh->nh_soa, TAG_NEXT(tags)) < 0))
- error = 1, status = 900, phrase = "Error Setting SOA Parameters";
- }
+ if (status == 200 && nh == dnh) {
+ /* Set stack-specific things below */
+ if (nua_stack_set_smime_params(nua, tags) < 0) {
+ status = 900, phrase = "Error setting S/MIME parameters";
+ }
+ else if (nua->nua_nta && nta_agent_set_params(nua->nua_nta, TAG_NEXT(tags)) < 0) {
+ status = 900, phrase = "Error setting NTA parameters";
+ }
+ else {
+ nua_stack_set_from(nua, 0, tags);
- if (error || nh != dnh) {
- ;
- }
- else if (nua_stack_set_smime_params(nua, tags) < 0) {
- error = 1, status = 900, phrase = "Error setting S/MIME parameters";
- }
- else if (!nua->nua_nta) {
- }
- /* Set stack-specific things below */
- else if (nta_agent_set_params(nua->nua_nta, TAG_NEXT(tags)) < 0) {
- status = 900, phrase = "Error setting NTA parameters";
- error = 1;
- }
- else {
- nua_stack_set_from(nua, 0, tags);
- if (NHP_ISSET(nhp, detect_network_updates))
- nua_stack_launch_network_change_detector(nua);
+ if (nua->nua_prefs->ngp_detect_network_updates)
+ nua_stack_launch_network_change_detector(nua);
+ }
}
- if (error) {
+ if (status != 200) {
if (e == nua_i_none)
SU_DEBUG_1(("nua_set_params(): failed: %s\n", phrase));
return UA_EVENT2(e, status, phrase), -1;
}
-
- if (e == nua_r_set_params)
- UA_EVENT2(e, 200, "OK");
-
- return 0;
+ else {
+ if (e == nua_r_set_params)
+ UA_EVENT2(e, status, phrase);
+ return 0;
+ }
}
-/** Parse parameters from tags to @a nhp.
+
+/** Parse parameters from tags to @a nhp or @a ngp.
*
* @param home allocate new values from @a home
* @param nhp structure to store handle preferences
- * @param global if true, save also global parameters
+ * @param ngp structure to store global preferences
* @param tags list of tags to parse
*/
static int nhp_set_tags(su_home_t *home,
nua_handle_preferences_t *nhp,
- int global,
+ nua_global_preferences_t *ngp,
tagi_t const *tags)
{
@@ -827,6 +807,10 @@
else if (tag == nutag_substate) {
NHP_SET(nhp, substate, (int)value);
}
+ /* NUTAG_SUB_EXPIRES(sub_expires) */
+ else if (tag == nutag_sub_expires) {
+ NHP_SET(nhp, sub_expires, value);
+ }
/* NUTAG_KEEPALIVE(keepalive) */
else if (tag == nutag_keepalive) {
NHP_SET(nhp, keepalive, (unsigned)value);
@@ -998,7 +982,7 @@
NHP_SET_STR(nhp, outbound, value);
}
/* NUTAG_DETECT_NETWORK_UPDATES(detect_network_updates) */
- else if (global && tag == nutag_detect_network_updates) {
+ else if (ngp && tag == nutag_detect_network_updates) {
int detector = (int)value;
if (detector < NUA_NW_DETECT_NOTHING)
@@ -1006,7 +990,13 @@
else if (detector > NUA_NW_DETECT_TRY_FULL)
detector = NUA_NW_DETECT_TRY_FULL;
- NHP_SET(nhp, detect_network_updates, detector);
+ ngp->ngp_detect_network_updates = detector;
+ ngp->ngp_set.ngp_detect_network_updates = 1;
+ }
+ /* NUTAG_SHUTDOWN_EVENTS() */
+ else if (ngp && tag == nutag_shutdown_events) {
+ ngp->ngp_shutdown_events = value != 0;
+ ngp->ngp_set.ngp_shutdown_events = 1;
}
}
@@ -1079,54 +1069,70 @@
return 1;
}
-static
-nua_handle_preferences_t *nhp_move_params(su_home_t *home,
- nua_handle_preferences_t *dst,
- su_home_t *tmphome,
- nua_handle_preferences_t const *src)
+/** Save parameters in @a gtmp and @a tmp.
+ */
+static
+int nhp_save_params(nua_handle_t *nh,
+ su_home_t *tmphome,
+ nua_global_preferences_t *gsrc,
+ nua_handle_preferences_t *src)
{
- /* Update prefs structure */
- nua_handle_preferences_t tbf[1];
+ su_home_t *home = nh->nh_home;
+ nua_t *nua = nh->nh_nua;
+ nua_handle_t *dnh = nua->nua_dhandle;
+ nua_handle_preferences_t *dst = nh->nh_prefs, old[1];
+
+ if (gsrc) {
+ *nua->nua_prefs = *gsrc; /* No pointers this far */
+ }
- if (dst == NULL)
- dst = su_zalloc(home, sizeof *dst);
- if (dst == NULL)
- return NULL;
- if (su_home_move(home, tmphome) < 0)
- return NULL;
+ if (!NHP_IS_ANY_SET(src))
+ return 0;
- *tbf = *dst;
+ if (nh == dnh || nh->nh_prefs != dnh->nh_prefs) {
+ dst = nh->nh_prefs, *old = *dst;
+ assert(dst);
+ }
+ else {
+ dst = su_zalloc(home, sizeof *dst), memset(old, 0, sizeof *old);
+ if (!dst)
+ return -1;
+ }
+
+ /* Move allocations from tmphome to home */
+ su_home_move(nh->nh_home, tmphome);
+
+ /* Copy parameters that are set from src to dst */
nhp_or_set(dst, src);
/* Handle pointer items. Free changed ones and zap unset ones. */
-#define NHP_ZAP_OVERRIDEN(tbf, nhp, pref) \
- (((tbf)->nhp_set.nhb_##pref \
- && (tbf)->nhp_##pref != (nhp)->nhp_##pref \
- ? su_free(home, (void *)(tbf)->nhp_##pref) : (void)0), \
- (void)(!(nhp)->nhp_set.nhb_##pref ? (nhp)->nhp_##pref = NULL : NULL))
-
- NHP_ZAP_OVERRIDEN(tbf, dst, soa_name);
- NHP_ZAP_OVERRIDEN(tbf, dst, registrar);
- NHP_ZAP_OVERRIDEN(tbf, dst, supported);
- NHP_ZAP_OVERRIDEN(tbf, dst, allow);
- NHP_ZAP_OVERRIDEN(tbf, dst, user_agent);
- NHP_ZAP_OVERRIDEN(tbf, dst, organization);
- NHP_ZAP_OVERRIDEN(tbf, dst, instance);
- NHP_ZAP_OVERRIDEN(tbf, dst, m_display);
- NHP_ZAP_OVERRIDEN(tbf, dst, m_username);
- NHP_ZAP_OVERRIDEN(tbf, dst, m_params);
- NHP_ZAP_OVERRIDEN(tbf, dst, m_features);
- NHP_ZAP_OVERRIDEN(tbf, dst, outbound);
-
-#define NHP_ZAP_OVERRIDEN_HDR(tbf, nhp, pref) \
- (((tbf)->nhp_set.nhb_##pref \
- && (tbf)->nhp_##pref != (nhp)->nhp_##pref \
- ? msg_header_free(home, (void *)(tbf)->nhp_##pref) : (void)0), \
- (void)(!(nhp)->nhp_set.nhb_##pref ? (nhp)->nhp_##pref = NULL : NULL))
-
- NHP_ZAP_OVERRIDEN_HDR(tbf, dst, initial_route);
+ /* Note that pointer items where !NHP_ISSET(old, pref) are not freed
+ (because they were just on loan from the default preference set) */
+#define NHP_ZAP_OVERRIDEN(old, dst, free, pref) \
+ (((NHP_ISSET(old, pref) && \
+ (old)->nhp_##pref && (old)->nhp_##pref != (dst)->nhp_##pref) \
+ ? (free)(home, (void *)(old)->nhp_##pref) : (void)0), \
+ (void)(!(dst)->nhp_set.nhb_##pref ? (dst)->nhp_##pref = NULL : NULL))
+
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, soa_name);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, registrar);
+ NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, allow);
+ NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, supported);
+ NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, allow_events);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, user_agent);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, organization);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, m_display);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, m_username);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, m_params);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, m_features);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, instance);
+ NHP_ZAP_OVERRIDEN(old, dst, su_free, outbound);
+ NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, appl_method);
+ NHP_ZAP_OVERRIDEN(old, dst, msg_header_free, initial_route);
- return dst;
+ nh->nh_prefs = dst;
+
+ return 0;
}
static int nua_handle_tags_filter(tagi_t const *f, tagi_t const *t);
@@ -1476,6 +1482,7 @@
* NUTAG_SMIME_SIGNATURE() \n
* NUTAG_SOA_NAME() \n
* NUTAG_SUBSTATE() \n
+ * NUTAG_SUB_EXPIRES() \n
* NUTAG_UPDATE_REFRESH() \n
* NUTAG_USER_AGENT() \n
* SIPTAG_ALLOW() \n
@@ -1516,6 +1523,7 @@
tagi_t const *tags)
{
nua_handle_t *dnh = nua->nua_dhandle;
+ nua_global_preferences_t const *ngp = nua->nua_prefs;
nua_handle_preferences_t const *nhp = nh->nh_prefs;
tagi_t *lst;
@@ -1541,8 +1549,6 @@
enter;
- su_home_auto(tmphome, sizeof(tmphome));
-
nta_agent_get_params(nua->nua_nta,
NTATAG_UDP_MTU_REF(udp_mtu),
NTATAG_MAX_PROCEEDING_REF(max_proceeding),
@@ -1591,6 +1597,8 @@
? sip_##pref##_make(tmphome, (char *)nhp->nhp_##pref) \
: NULL))
+ su_home_auto(tmphome, sizeof(tmphome));
+
lst = tl_filtered_tlist
(tmphome, tags,
TAG_IF(has_from, SIPTAG_FROM(from)),
@@ -1631,6 +1639,7 @@
TIF(NUTAG_REFER_WITH_ID, refer_with_id),
TIF(NUTAG_SUBSTATE, substate),
+ TIF(NUTAG_SUB_EXPIRES, sub_expires),
TIF(SIPTAG_SUPPORTED, supported),
TIF_STR(SIPTAG_SUPPORTED_STR, supported),
@@ -1659,11 +1668,18 @@
TIF(NUTAG_M_PARAMS, m_params),
TIF(NUTAG_M_FEATURES, m_features),
TIF(NUTAG_OUTBOUND, outbound),
- TIF(NUTAG_DETECT_NETWORK_UPDATES, detect_network_updates),
/* Skip user-agent-level parameters if parameters are for handle only */
TAG_IF(nh != dnh, TAG_NEXT(media_params)),
+ /* Include tag in the list returned to user
+ * if it has been earlier set (by user) */
+#define GIF(TAG, pref) \
+ TAG_IF(ngp->ngp_set.ngp_##pref, TAG(ngp->ngp_##pref))
+
+ GIF(NUTAG_DETECT_NETWORK_UPDATES, detect_network_updates),
+ GIF(NUTAG_SHUTDOWN_EVENTS, shutdown_events),
+
NTATAG_CONTACT(m),
#if HAVE_SOFIA_SMIME
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_params.h Wed Feb 27 16:57:19 2008
@@ -107,6 +107,7 @@
/* Subscriber state, i.e. nua_substate_pending */
unsigned nhp_substate;
+ unsigned nhp_sub_expires;
/* REGISTER keepalive intervals */
unsigned nhp_keepalive, nhp_keepalive_stream;
@@ -127,9 +128,6 @@
/** Outbound OPTIONS */
char const *nhp_outbound;
- /** Network detection: NONE, INFORMAL, TRY_FULL */
- int nhp_detect_network_updates;
-
sip_allow_t *nhp_appl_method;
/** Initial route set */
@@ -137,6 +135,12 @@
union { struct {
/* A bit for each feature set by application */
+ /* NOTE:
+ Some compilers behave weird if there are bitfields
+ together with width > 32
+ So there should be a padding field (unsigned:0;)
+ every 32 bits.
+ */
unsigned nhb_retry_count:1;
unsigned nhb_max_subscriptions:1;
@@ -166,13 +170,15 @@
unsigned nhb_refer_with_id:1;
unsigned nhb_refer_expires:1;
unsigned nhb_substate:1;
+ unsigned nhb_sub_expires:1;
unsigned nhb_keepalive:1;
unsigned nhb_keepalive_stream:1;
unsigned nhb_registrar:1;
unsigned nhb_allow:1;
+ unsigned :0; /* at most 32 bits before this point */
unsigned nhb_supported:1;
- unsigned :0; /* at most 32 bits ... */
+
unsigned nhb_allow_events:1;
unsigned nhb_user_agent:1;
unsigned nhb_organization:1;
@@ -183,7 +189,6 @@
unsigned nhb_m_features:1;
unsigned nhb_instance:1;
unsigned nhb_outbound:1;
- unsigned nhb_detect_network_updates:1;
unsigned nhb_appl_method:1;
unsigned nhb_initial_route:1;
unsigned :0;
@@ -194,6 +199,26 @@
#define nhp_set nhp_set_.set_bits
+/** Global preferences for nua. */
+typedef struct {
+ /** Network detection: NONE, INFORMAL, TRY_FULL */
+ signed int ngp_detect_network_updates:3;
+ /** Pass events during shutdown, too */
+ int ngp_shutdown_events:1;
+
+ unsigned :0; /* pad */
+ union { struct {
+ /* A bit for each feature set by application */
+ unsigned ngp_detect_network_updates:1;
+ unsigned ngp_shutdown_events:1;
+ unsigned :0;
+ } set_bits;
+ unsigned set_unsigned[2];
+ } ngp_set_;
+} nua_global_preferences_t;
+
+#define ngp_set ngp_set_.set_bits
+
#define DNHP_GET(dnhp, pref) ((dnhp)->nhp_##pref)
#define NHP_GET(nhp, dnhp, pref) \
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.c Wed Feb 27 16:57:19 2008
@@ -209,7 +209,7 @@
if (nua_stack_set_from(nua, 1, nua->nua_args) < 0)
return -1;
- if (NHP_ISSET(dnh->nh_prefs, detect_network_updates))
+ if (nua->nua_prefs->ngp_detect_network_updates)
nua_stack_launch_network_change_detector(nua);
nua_stack_timer(nua, nua->nua_timer, NULL);
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_stack.h Wed Feb 27 16:57:19 2008
@@ -217,28 +217,31 @@
su_clone_r nua_clone;
su_task_r nua_client;
- su_network_changed_t *nua_nw_changed;
-
nua_callback_f nua_callback;
nua_magic_t *nua_magic;
nua_event_frame_t *nua_current;
nua_saved_event_t nua_signal[1];
+ /**< Used by stop-and-wait args calls */
+ tagi_t const *nua_args;
+
/* Engine state flags */
+ sip_time_t nua_shutdown;
+
unsigned nua_shutdown_started:1; /**< Shutdown initiated */
unsigned nua_shutdown_final:1; /**< Shutdown is complete */
unsigned nua_from_is_set;
unsigned :0;
- /**< Used by stop-and-wait args calls */
- tagi_t const *nua_args;
-
/**< Local SIP address. Contents are kept around for ever. */
- sip_from_t nua_from[1];
+ sip_from_t nua_from[1];
+
+ /* ---------------------------------------------------------------------- */
/* Protocol (server) side */
+ su_network_changed_t *nua_nw_changed;
nua_registration_t *nua_registrations; /**< Active registrations */
@@ -250,21 +253,8 @@
nta_agent_t *nua_nta;
su_timer_t *nua_timer;
- void *nua_sip_parser;
-
- sip_time_t nua_shutdown;
-
- /* Route */
- sip_service_route_t *nua_service_route;
-
/* User-agent parameters */
- unsigned nua_media_enable:1;
-
- unsigned :0;
-
-#if HAVE_SMIME /* Start NRC Boston */
- sm_object_t *sm;
-#endif /* End NRC Boston */
+ nua_global_preferences_t nua_prefs[1];
nua_handle_t *nua_handles;
nua_handle_t **nua_handles_tail;
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_tag.c Wed Feb 27 16:57:19 2008
@@ -227,21 +227,22 @@
* - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and
* SIPTAG_ALLOW_EVENTS_STR()
* - NUTAG_MAX_SUBSCRIPTIONS()
- * - NUTAG_SUBSTATE()
+ * - NUTAG_SUBSTATE(), NUTAG_SUB_EXPIRES()
* @par Specifications
* - @RFC3265
*
* @par SIP Event Subscriber
* - nua_subscribe(), #nua_r_subscribe, #nua_i_notify, NUTAG_SUBSTATE(),
- * SIPTAG_EVENT(), SIPTAG_EXPIRES(),
+ * SIPTAG_EVENT(), SIPTAG_EXPIRES()
* - nua_unsubscribe(), #nua_r_unsubscribe()
* @par Specifications
* - @RFC3265
*
* @par SIP Event Notifier
* - #nua_i_subscribe(), nua_notify(), #nua_r_notify,
- * NUTAG_SUBSTATE(), SIPTAG_EVENT()
+ * NUTAG_SUBSTATE(), NUTAG_SUB_EXPIRES(), SIPTAG_EVENT()
* Settings:
+ * - NUTAG_SUB_EXPIRES()
* - NUTAG_ALLOW_EVENTS(), SIPTAG_ALLOW_EVENTS(), and
* SIPTAG_ALLOW_EVENTS_STR()
* - NUTAG_ALLOW("SUBSCRIBE"), NUTAG_APPL_METHOD("SUBSCRIBE")
@@ -267,6 +268,8 @@
* Settings:
* - NUTAG_ALLOW(x), NUTAG_APPL_METHOD(x)
*
+ * @par Server Shutdown
+ * - nua_shutdown(), NUTAG_SHUTDOWN_EVENTS(), nua_destroy().
*/
/* @par S/MIME
@@ -767,14 +770,14 @@
*
* @par Used with
* - with nua_create(), nua_set_params(), nua_get_params(),
- * nua_handle(), nua_set_hparams(), nua_get_hparams(), and
- * nua_notifier() to change the default subscription state returned by
- * the intenal event server
+ * nua_handle(), nua_set_hparams(), nua_get_hparams(), and
+ * nua_notifier() to change the default subscription state returned by
+ * the internal event server
* - with nua_notify() and nua_respond() to SUBSCRIBE to determine the
- * subscription state (if application include @SubscriptionState
- * header in the tag list, the NUTAG_SUBSTATE() value is ignored)
+ * subscription state (if application include @SubscriptionState
+ * header in the tag list, the NUTAG_SUBSTATE() value is ignored)
* - with #nua_r_subscribe, #nua_i_notify, #nua_i_subscribe, and #nua_r_notify
- * to indicate the current subscription state
+ * to indicate the current subscription state
*
* @par Parameter type
* int
@@ -806,6 +809,39 @@
*/
+/**@def NUTAG_SUB_EXPIRES()
+ *
+ * Default expiration time of subscriptions.
+ *
+ * @par Used with
+ * - with nua_create(), nua_set_params(), nua_get_params(), nua_handle(),
+ * nua_set_hparams(), nua_get_hparams(), nua_respond(), nua_notify(), and
+ * nua_notifier() to change the default expiration time of subscriptions
+ *
+ * @par Parameter type
+ * unsigned int
+ *
+ * @par Values
+ * - default expiration time in seconds
+ *
+ * Note that the expires parameter in @SubscriptionState or @Expires header
+ * in the nua_response() to the SUBSCRIBE overrides the default subscription
+ * expiration specified by NUTAG_SUB_EXPIRES().
+ *
+ * @sa @RFC3265, NUTAG_REFER_EXPIRES(), @Expires, SIPTAG_EXPIRES(),
+ * SIPTAG_EXPIRES_STR(), @SubscriptionState, nua_respond(), nua_notifier(),
+ * #nua_r_subscribe, #nua_i_subscribe, #nua_r_refer, #nua_r_notify,
+ * #nua_i_notify.
+ *
+ * Corresponding tag taking reference parameter is NUTAG_SUB_EXPIRES_REF().
+ */
+tag_typedef_t nutag_sub_expires = UINTTAG_TYPEDEF(substate);
+
+/**@def NUTAG_SUB_EXPIRES_REF(x)
+ * Reference tag for NUTAG_SUB_EXPIRES().
+ */
+
+
/**@def NUTAG_NEWSUB()
*
* Send unsolicited NOTIFY request.
@@ -1075,17 +1111,17 @@
* REFER.
*
* @par Used with
- * nua_set_params() \n
- * nua_get_params() \n
- * nua_set_hparams() \n
- * nua_get_hparams() \n
+ * nua_handle(), nua_respond() \n
+ * nua_set_params() or nua_set_hparams() \n
+ * nua_get_params() or nua_get_hparams()
*
* @par Parameter type
* unsigned int
*
* @par Values
- * @c 0 disable \n
- * @c >0 interval in seconds
+ * - default interval in seconds
+ *
+ * @sa NUTAG_SUB_EXPIRES()
*
* Corresponding tag taking reference parameter is NUTAG_REFER_EXPIRES_REF().
*/
@@ -1570,6 +1606,9 @@
* NUTAG_INITIAL_ROUTE_STR() tags, the route set is constructed from them
* all.
*
+ * The initial route is inserted into request message before the route
+ * entries set with SIPTAG_ROUTE() or SIPTAG_ROUTE_STR().
+ *
* @par Used with
* nua_set_params() \n
* nua_set_hparams() \n
@@ -2736,6 +2775,39 @@
* Reference tag for NUTAG_SIP_PARSER().
*/
+
+/**@def NUTAG_SHUTDOWN_EVENTS(x)
+ *
+ * Allow passing of normal events when stack is being shut down.
+ *
+ * By default, only #nua_r_shutdown events are passed to application after
+ * calling nua_shutdown(). If application is interested in nua events during
+ * shutdown, it should give NUTAG_SHUTDOWN_EVENTS(1) to nua_create() or
+ * nua_set_params() called before nua_shutdown().
+ *
+ * @par Used with
+ * nua_create(), nua_set_params().
+ *
+ * @par Parameter type
+ * int (boolean)
+ *
+ * @par Values
+ * @c 0 False \n
+ * @c !=0 True
+ *
+ * Corresponding tag taking reference parameter is NUTAG_SHUTDOWN_EVENTS_REF().
+ *
+ * @sa nua_shutdown(), nua_destroy().
+ *
+ * @NEW_1_12_9.
+ */
+tag_typedef_t nutag_shutdown_events = BOOLTAG_TYPEDEF(shutdown_events);
+
+/**@def NUTAG_SHUTDOWN_EVENTS_REF(x)
+ * Reference tag for NUTAG_SHUTDOWN_EVENTS().
+ */
+
+
/* ---------------------------------------------------------------------- */
tag_typedef_t nutag_soa_session = PTRTAG_TYPEDEF(soa_session);
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/sofia-sip/nua_tag.h Wed Feb 27 16:57:19 2008
@@ -497,6 +497,11 @@
/** Convert string to enum nua_substate. @NEW_1_12_5. */
SOFIAPUBFUN enum nua_substate nua_substate_make(char const *sip_substate);
+#define NUTAG_SUB_EXPIRES(x) nutag_sub_expires, tag_uint_v(x)
+SOFIAPUBVAR tag_typedef_t nutag_sub_expires;
+#define NUTAG_SUB_EXPIRES_REF(x) nutag_sub_expires_ref, tag_uint_vr(&(x))
+SOFIAPUBVAR tag_typedef_t nutag_sub_expires_ref;
+
#define NUTAG_NEWSUB(x) nutag_newsub, tag_bool_v(x)
SOFIAPUBVAR tag_typedef_t nutag_newsub;
#define NUTAG_NEWSUB_REF(x) nutag_newsub_ref, tag_bool_vr(&(x))
@@ -569,6 +574,13 @@
nutag_detect_network_updates_ref, tag_int_vr(&(x))
SOFIAPUBVAR tag_typedef_t nutag_detect_network_updates_ref;
+#define NUTAG_SHUTDOWN_EVENTS(x) \
+ nutag_shutdown_events, tag_bool_v(x)
+SOFIAPUBVAR tag_typedef_t nutag_shutdown_events;
+#define NUTAG_SHUTDOWN_EVENTS_REF(x) \
+ nutag_shutdown_events_ref, tag_bool_vr(&(x))
+SOFIAPUBVAR tag_typedef_t nutag_shutdown_events_ref;
+
/* Pass nua handle as tagged argument */
#if SU_INLINE_TAG_CAST
su_inline tag_value_t nutag_handle_v(nua_handle_t *v) { return (tag_value_t)v; }
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_nua_params.c Wed Feb 27 16:57:19 2008
@@ -203,6 +203,7 @@
NUTAG_REFER_EXPIRES(333),
NUTAG_REFER_WITH_ID(0),
NUTAG_SUBSTATE(nua_substate_pending),
+ NUTAG_SUB_EXPIRES(3700),
NUTAG_KEEPALIVE(66),
NUTAG_KEEPALIVE_STREAM(33),
@@ -284,6 +285,7 @@
int auth_cache = -1;
unsigned refer_expires = (unsigned)-1;
int refer_with_id = -1;
+ unsigned sub_expires = (unsigned)-1;
int substate = -1;
sip_allow_t const *allow = NONE;
@@ -352,6 +354,7 @@
NUTAG_REFER_EXPIRES_REF(refer_expires),
NUTAG_REFER_WITH_ID_REF(refer_with_id),
NUTAG_SUBSTATE_REF(substate),
+ NUTAG_SUB_EXPIRES_REF(sub_expires),
SIPTAG_SUPPORTED_REF(supported),
SIPTAG_SUPPORTED_STR_REF(supported_str),
@@ -382,7 +385,7 @@
NUTAG_INSTANCE_REF(instance),
TAG_END());
- TEST(n, 50);
+ TEST(n, 51);
TEST_S(sip_header_as_string(tmphome, (void *)from), Alice);
TEST_S(from_str, Alice);
@@ -416,6 +419,7 @@
TEST(refer_expires, 333);
TEST(refer_with_id, 0);
TEST(substate, nua_substate_pending);
+ TEST(sub_expires, 3700);
TEST_S(sip_header_as_string(tmphome, (void *)allow), "OPTIONS, INFO, ACK");
TEST_S(allow_str, "OPTIONS, INFO, ACK");
@@ -492,6 +496,7 @@
unsigned refer_expires = (unsigned)-1;
int refer_with_id = -1;
int substate = -1;
+ unsigned sub_expires = (unsigned)-1;
sip_allow_t const *allow = NONE;
char const *allow_str = "NONE";
@@ -552,6 +557,7 @@
NUTAG_PATH_ENABLE_REF(path_enable),
NUTAG_AUTH_CACHE_REF(auth_cache),
NUTAG_SUBSTATE_REF(substate),
+ NUTAG_SUB_EXPIRES_REF(sub_expires),
SIPTAG_SUPPORTED_REF(supported),
SIPTAG_SUPPORTED_STR_REF(supported_str),
@@ -607,6 +613,7 @@
TEST(refer_expires, (unsigned)-1);
TEST(refer_with_id, -1);
TEST(substate, -1);
+ TEST(sub_expires, -1);
TEST_P(allow, NONE);
TEST_S(allow_str, "NONE");
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_simple.c Wed Feb 27 16:57:19 2008
@@ -45,6 +45,9 @@
extern int accept_request(CONDITION_PARAMS);
+int save_until_nth_final_response(CONDITION_PARAMS);
+int accept_n_notifys(CONDITION_PARAMS);
+
int test_message(struct context *ctx)
{
BEGIN();
@@ -564,6 +567,47 @@
"</presence>\n";
+int accept_and_notify_twice(CONDITION_PARAMS)
+{
+ msg_t *with = nua_current_request(nua);
+
+ if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+ return 0;
+
+ save_event_in_list(ctx, event, ep, call);
+
+ switch (event) {
+ case nua_i_subscribe:
+ if (status < 200) {
+ NOTIFY(ep, call, nh,
+ SIPTAG_EVENT(sip->sip_event),
+ SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"),
+ SIPTAG_PAYLOAD_STR(presence_closed),
+ NUTAG_SUBSTATE(nua_substate_pending),
+ TAG_END());
+ NOTIFY(ep, call, nh,
+ SIPTAG_EVENT(sip->sip_event),
+ SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"),
+ SIPTAG_PAYLOAD_STR(presence_open),
+ NUTAG_SUBSTATE(nua_substate_active),
+ TAG_END());
+ RESPOND(ep, call, nh, SIP_202_ACCEPTED,
+ NUTAG_WITH(with),
+ SIPTAG_EXPIRES_STR("360"),
+ TAG_END());
+ }
+ return 0;
+
+ case nua_r_notify:
+ return status >= 200 &&
+ tl_find(tags, nutag_substate)->t_value == nua_substate_active;
+
+ default:
+ return 0;
+ }
+}
+
+
int accept_and_notify(CONDITION_PARAMS)
{
msg_t *with = nua_current_request(nua);
@@ -580,12 +624,14 @@
NUTAG_WITH(with),
SIPTAG_EXPIRES_STR("360"),
TAG_END());
+
NOTIFY(ep, call, nh,
SIPTAG_EVENT(sip->sip_event),
SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"),
SIPTAG_PAYLOAD_STR(presence_closed),
NUTAG_SUBSTATE(nua_substate_pending),
TAG_END());
+
}
return 0;
@@ -597,6 +643,31 @@
}
}
+int save_and_notify(CONDITION_PARAMS)
+{
+ if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
+ return 0;
+
+ save_event_in_list(ctx, event, ep, call);
+
+ switch (event) {
+ case nua_i_subscribe:
+ NOTIFY(ep, call, nh,
+ SIPTAG_EVENT(sip->sip_event),
+ SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"),
+ SIPTAG_PAYLOAD_STR(presence_closed),
+ NUTAG_SUBSTATE(nua_substate_active),
+ TAG_END());
+ return 0;
+
+ case nua_r_notify:
+ return status >= 200;
+
+ default:
+ return 0;
+ }
+}
+
extern int save_until_notified_and_responded(CONDITION_PARAMS);
extern int save_until_notified(CONDITION_PARAMS);
@@ -606,7 +677,7 @@
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
- struct event *e;
+ struct event *e, *en1, *en2, *es;
sip_t const *sip;
tagi_t const *n_tags, *r_tags;
@@ -620,44 +691,47 @@
SUBSCRIBE(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
SIPTAG_EVENT_STR("presence"),
+ SIPTAG_EXPIRES_STR("333"),
SIPTAG_ACCEPT_STR("application/xpidf, application/pidf+xml"),
TAG_END());
run_ab_until(ctx, -1, save_until_notified_and_responded,
- -1, accept_and_notify);
+ -1, accept_and_notify_twice);
/* Client events:
- nua_subscribe(), nua_i_notify/nua_r_subscribe
+ nua_subscribe(), nua_i_notify/nua_r_subscribe/nua_i_notify
*/
- TEST_1(e = a->events->head);
- if (e->data->e_event == nua_i_notify) {
- TEST_E(e->data->e_event, nua_i_notify);
- TEST_1(sip = sip_object(e->data->e_msg));
- n_tags = e->data->e_tags;
- TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_subscribe);
- r_tags = e->data->e_tags;
- TEST_1(tl_find(r_tags, nutag_substate));
- TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_pending);
- }
- else {
- TEST_E(e->data->e_event, nua_r_subscribe);
- TEST(e->data->e_status, 202);
- r_tags = e->data->e_tags;
- TEST_1(tl_find(r_tags, nutag_substate));
- TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_embryonic);
- TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
- TEST_1(sip = sip_object(e->data->e_msg));
- n_tags = e->data->e_tags;
+ for (en1 = en2 = es = NULL, e = a->events->head; e; e = e->next) {
+ if (en1 == NULL && e->data->e_event == nua_i_notify)
+ en1 = e;
+ else if (en2 == NULL && e->data->e_event == nua_i_notify)
+ en2 = e;
+ else if (e->data->e_event == nua_r_subscribe)
+ es = e;
+ else
+ TEST_1(!e);
}
+
+ TEST_1(e = en1);
+ TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(tl_find(e->data->e_tags, nutag_substate));
+ TEST(tl_find(e->data->e_tags, nutag_substate)->t_value, nua_substate_pending);
+ TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
TEST_1(sip->sip_content_type);
TEST_S(sip->sip_content_type->c_type, "application/pidf+xml");
TEST_1(sip->sip_subscription_state);
TEST_S(sip->sip_subscription_state->ss_substate, "pending");
TEST_1(sip->sip_subscription_state->ss_expires);
- TEST_1(tl_find(n_tags, nutag_substate));
- TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_pending);
- TEST_1(!e->next);
+
+ TEST_1(e = es); TEST_E(e->data->e_event, nua_r_subscribe);
+ TEST_1(e->data->e_status == 202 || e->data->e_status == 200);
+ TEST_1(tl_find(e->data->e_tags, nutag_substate));
+ TEST(tl_find(e->data->e_tags, nutag_substate)->t_value, nua_substate_pending);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_expires);
+ TEST_1(sip->sip_expires->ex_delta <= 333);
+
free_events_in_list(ctx, a->events);
/* Server events: nua_i_subscribe, nua_r_notify */
@@ -731,6 +805,80 @@
/* ---------------------------------------------------------------------- */
+/* Re-SUBSCRIBE
+
+ A B
+ | |
+ |<------NOTIFY-------|
+ |-------200 OK------>|
+ | |
+*/
+ if (print_headings)
+ printf("TEST NUA-11.4.3: re-SUBSCRIBE\n");
+
+ /* Set default expiration time */
+ nua_set_hparams(b_call->nh, NUTAG_SUB_EXPIRES(365), TAG_END());
+ run_b_until(ctx, nua_r_set_params, until_final_response);
+
+ SUBSCRIBE(a, a_call, a_call->nh, NUTAG_URL(b->contact->m_url),
+ SIPTAG_EVENT_STR("presence"),
+ SIPTAG_EXPIRES_STR("3600"),
+ SIPTAG_ACCEPT_STR("application/xpidf, application/pidf+xml"),
+ TAG_END());
+
+ run_ab_until(ctx, -1, save_until_notified_and_responded,
+ -1, save_until_final_response);
+
+ /* Client events:
+ nua_subscribe(), nua_i_notify/nua_r_subscribe
+ */
+ for (en1 = en2 = es = NULL, e = a->events->head; e; e = e->next) {
+ if (en1 == NULL && e->data->e_event == nua_i_notify)
+ en1 = e;
+ else if (e->data->e_event == nua_r_subscribe)
+ es = e;
+ else
+ TEST_1(!e);
+ }
+ TEST_1(e = en1);
+ TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
+ TEST_1(sip->sip_content_type);
+ TEST_S(sip->sip_content_type->c_type, "application/pidf+xml");
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "active");
+ TEST_1(sip->sip_subscription_state->ss_expires);
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
+
+ TEST_1(e = es); TEST_E(e->data->e_event, nua_r_subscribe);
+ TEST_1(tl_find(e->data->e_tags, nutag_substate));
+ TEST(tl_find(e->data->e_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_expires);
+ TEST_1(sip->sip_expires->ex_delta <= 365);
+
+ free_events_in_list(ctx, a->events);
+
+ /* Server events: nua_i_subscribe, nua_r_notify */
+ TEST_1(e = b->events->head);
+ TEST_E(e->data->e_event, nua_i_subscribe);
+ TEST_E(e->data->e_status, 100);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_active);
+
+ free_events_in_list(ctx, b->events);
+
+ if (print_headings)
+ printf("TEST NUA-11.4.3: PASSED\n");
+
+ /* ---------------------------------------------------------------------- */
+
/* un-SUBSCRIBE
A B
@@ -742,7 +890,7 @@
| |
*/
if (print_headings)
- printf("TEST NUA-11.4.3: un-SUBSCRIBE\n");
+ printf("TEST NUA-11.4.4: un-SUBSCRIBE\n");
UNSUBSCRIBE(a, a_call, a_call->nh, TAG_END());
@@ -752,31 +900,35 @@
/* Client events:
nua_unsubscribe(), nua_i_notify/nua_r_unsubscribe
*/
- TEST_1(e = a->events->head);
- if (e->data->e_event == nua_i_notify) {
- TEST_E(e->data->e_event, nua_i_notify);
- n_tags = e->data->e_tags;
+ for (en1 = en2 = es = NULL, e = a->events->head; e; e = e->next) {
+ if (en1 == NULL && e->data->e_event == nua_i_notify)
+ en1 = e;
+ else if (e->data->e_event == nua_r_unsubscribe)
+ es = e;
+ else
+ TEST_1(!e);
+ }
+ if (en1) {
+ TEST_1(e = en1); TEST_E(e->data->e_event, nua_i_notify);
TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_event);
TEST_1(sip->sip_subscription_state);
TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
TEST_1(!sip->sip_subscription_state->ss_expires);
+ n_tags = e->data->e_tags;
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
- TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_unsubscribe);
- TEST(e->data->e_status, 200);
- r_tags = e->data->e_tags;
- TEST_1(tl_find(r_tags, nutag_substate));
- TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
- }
- else {
- TEST_E(e->data->e_event, nua_r_unsubscribe);
- TEST(e->data->e_status, 200);
- r_tags = e->data->e_tags;
- TEST_1(tl_find(r_tags, nutag_substate));
- TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
}
- TEST_1(!e->next);
+
+ TEST_1(e = es); TEST_E(e->data->e_event, nua_r_unsubscribe);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_expires);
+ TEST_1(sip->sip_expires->ex_delta == 0);
+
free_events_in_list(ctx, a->events);
/* Notifier events: nua_r_notify */
@@ -799,7 +951,7 @@
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
- printf("TEST NUA-11.4.3: PASSED\n");
+ printf("TEST NUA-11.4.4: PASSED\n");
if (print_headings)
printf("TEST NUA-11.4: PASSED\n");
@@ -825,7 +977,7 @@
struct endpoint *a = &ctx->a, *b = &ctx->b;
struct call *a_call = a->call, *b_call = b->call;
- struct event *e;
+ struct event *e, *en1, *en2, *es;
sip_t const *sip;
tagi_t const *n_tags, *r_tags;
struct nat_filter *f;
@@ -846,35 +998,33 @@
/* Client events:
nua_subscribe(), nua_i_notify/nua_r_subscribe
*/
- TEST_1(e = a->events->head);
- if (e->data->e_event == nua_i_notify) {
- TEST_E(e->data->e_event, nua_i_notify);
- TEST_1(sip = sip_object(e->data->e_msg));
- n_tags = e->data->e_tags;
- TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_subscribe);
- r_tags = e->data->e_tags;
- TEST_1(tl_find(r_tags, nutag_substate));
- TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_pending);
- }
- else {
- TEST_E(e->data->e_event, nua_r_subscribe);
- TEST(e->data->e_status, 202);
- r_tags = e->data->e_tags;
- TEST_1(tl_find(r_tags, nutag_substate));
- TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_embryonic);
- TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
- TEST_1(sip = sip_object(e->data->e_msg));
- n_tags = e->data->e_tags;
+ for (en1 = en2 = es = NULL, e = a->events->head; e; e = e->next) {
+ if (en1 == NULL && e->data->e_event == nua_i_notify)
+ en1 = e;
+ else if (es == NULL && e->data->e_event == nua_r_subscribe)
+ es = e;
+ else
+ TEST_1(!e);
}
+ TEST_1(e = en1); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
TEST_1(sip->sip_event); TEST_S(sip->sip_event->o_type, "presence");
TEST_1(sip->sip_content_type);
TEST_S(sip->sip_content_type->c_type, "application/pidf+xml");
TEST_1(sip->sip_subscription_state);
TEST_S(sip->sip_subscription_state->ss_substate, "pending");
TEST_1(sip->sip_subscription_state->ss_expires);
+ n_tags = e->data->e_tags;
TEST_1(tl_find(n_tags, nutag_substate));
TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_pending);
- TEST_1(!e->next);
+
+ TEST_1(e = es); TEST_E(e->data->e_event, nua_r_subscribe);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ if (es == a->events->head)
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_embryonic);
+ else
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_pending);
free_events_in_list(ctx, a->events);
/* Server events: nua_i_subscribe, nua_r_notify */
@@ -1011,7 +1161,6 @@
return ep->flags.bit0 && ep->flags.bit1;
}
-
/* ---------------------------------------------------------------------- */
/* Unsolicited NOTIFY */
@@ -1028,6 +1177,8 @@
sip_call_id_t *i;
tagi_t const *n_tags, *r_tags;
+#if 0
+
if (print_headings)
printf("TEST NUA-11.7.1: rejecting NOTIFY without subscription locally\n");
@@ -1161,6 +1312,298 @@
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+#else
+ (void)i;
+ nua_set_params(b->nua, NUTAG_APPL_METHOD("NOTIFY"), TAG_END());
+ run_b_until(ctx, nua_r_set_params, until_final_response);
+#endif
+
+ /* ---------------------------------------------------------------------- */
+
+ if (print_headings)
+ printf("TEST NUA-11.7.4: multiple unsolicited NOTIFYs\n");
+
+ TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_EXPIRES_STR("10"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.4aa"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
+ TAG_END());
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("active; expires=333"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.4a"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
+ TAG_END());
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("active; expires=3000"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.4b"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+ TAG_END());
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("terminated"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.4c"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+ TAG_END());
+
+ a->state.n = 4;
+ b->state.n = 4;
+
+ run_ab_until(ctx, -1, save_until_nth_final_response,
+ -1, accept_n_notifys);
+
+ /* Notifier events: nua_r_notify nua_r_notify */
+ TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+ TEST_1(!e->next);
+
+ /* subscriber events:
+ nua_i_notify
+ */
+ TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
+
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "active");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "active");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
+ TEST_1(!e->next);
+
+ free_events_in_list(ctx, a->events);
+ free_events_in_list(ctx, b->events);
+
+ nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+ nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+ if (print_headings)
+ printf("TEST NUA-11.7.4: PASSED\n");
+
+ /* ---------------------------------------------------------------------- */
+
+ if (print_headings)
+ printf("TEST NUA-11.7.5: multiple unsolicited NOTIFYs\n");
+
+ TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("active; expires=333"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.5a"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
+ TAG_END());
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("active; expires=3000"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.5b"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+ TAG_END());
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("terminated"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.5c"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+ TAG_END());
+
+ a->state.n = 3;
+ b->state.n = 3;
+
+ run_ab_until(ctx, -1, save_until_nth_final_response,
+ -1, accept_n_notifys);
+
+ /* Notifier events: nua_r_notify nua_r_notify */
+ TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_r_notify);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_r_notify);
+ TEST(e->data->e_status, 200);
+ r_tags = e->data->e_tags;
+ TEST_1(tl_find(r_tags, nutag_substate));
+ TEST(tl_find(r_tags, nutag_substate)->t_value, nua_substate_terminated);
+ TEST_1(!e->next);
+
+ /* subscriber events:
+ nua_i_notify
+ */
+ TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "active");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "active");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
+ TEST_1(!e->next);
+
+ free_events_in_list(ctx, a->events);
+ free_events_in_list(ctx, b->events);
+
+ nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+ nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+ if (print_headings)
+ printf("TEST NUA-11.7.5: PASSED\n");
+
+ /* ---------------------------------------------------------------------- */
+
+#if 0
+
+ if (print_headings)
+ printf("TEST NUA-11.7.6: unsolicited NOTIFY handle destroyed\n");
+
+ TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("active; expires=333"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.6a"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
+ TAG_END());
+
+ NOTIFY(a, a_call, a_call->nh,
+ NUTAG_URL(b->contact->m_url),
+ NUTAG_NEWSUB(1),
+ SIPTAG_SUBSCRIPTION_STATE_STR("active; expires=3000"),
+ SIPTAG_SUBJECT_STR("NUA-11.7.6b"),
+ SIPTAG_EVENT_STR("message-summary"),
+ SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
+ SIPTAG_PAYLOAD_STR("Messages-Waiting: yes"),
+ TAG_END());
+
+ nua_handle_destroy(a_call->nh), a_call->nh = NULL;
+
+ a->state.n = 3;
+ b->state.n = 3;
+
+ run_b_until(ctx, -1, accept_n_notifys);
+
+ /* subscriber events:
+ nua_i_notify
+ */
+ TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "active");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "active");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_active);
+ TEST_1(e = e->next); TEST_E(e->data->e_event, nua_i_notify);
+ TEST_1(sip = sip_object(e->data->e_msg));
+ TEST_1(sip->sip_subscription_state);
+ TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
+ n_tags = e->data->e_tags;
+ TEST_1(tl_find(n_tags, nutag_substate));
+ TEST(tl_find(n_tags, nutag_substate)->t_value, nua_substate_terminated);
+ TEST_1(!e->next);
+
+ free_events_in_list(ctx, b->events);
+
+ if (print_headings)
+ printf("TEST NUA-11.7.6: PASSED\n");
+
+ nua_handle_destroy(b_call->nh), b_call->nh = NULL;
+
+#endif
+
if (print_headings)
printf("TEST NUA-11.7: PASSED\n");
@@ -1183,6 +1626,50 @@
return event == nua_i_notify;
}
+int save_until_nth_final_response(CONDITION_PARAMS)
+{
+ save_event_in_list(ctx, event, ep, call);
+
+ if (nua_r_set_params <= event && event < nua_i_network_changed
+ && status >= 200) {
+ if (ep->state.n > 0)
+ ep->state.n--;
+ return ep->state.n == 0;
+ }
+
+ return 0;
+}
+
+int accept_n_notifys(CONDITION_PARAMS)
+{
+ tagi_t const *substate = tl_find(tags, nutag_substate);
+
+ if (event == nua_i_notify && status < 200)
+ RESPOND(ep, call, nh, SIP_200_OK,
+ NUTAG_WITH_THIS(ep->nua),
+ TAG_END());
+
+ save_event_in_list(ctx, event, ep, call);
+
+ if (event != nua_i_notify)
+ return 0;
+
+ if (ep->state.n > 0)
+ ep->state.n--;
+
+ if (ep->state.n == 0)
+ return 1;
+
+ if (substate && substate->t_value == nua_substate_terminated) {
+ if (call && call->nh == nh) {
+ call->nh = NULL;
+ nua_handle_destroy(nh);
+ }
+ }
+
+ return 0;
+}
+
/* ======================================================================== */
int save_until_subscription_terminated(CONDITION_PARAMS);
@@ -1336,8 +1823,8 @@
int test_simple(struct context *ctx)
{
- return
- test_message(ctx)
+ return 0
+ || test_message(ctx)
|| test_publish(ctx)
|| test_subscribe_notify(ctx)
|| test_subscribe_notify_graceful(ctx)
1
0
27 Feb '08
Author: mikej
Date: Wed Feb 27 16:55:20 2008
New Revision: 7758
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
Log:
Merge back a couple patches (curse you darcs)
Wed Feb 13 09:23:24 EST 2008 Pekka Pessi <Pekka.Pessi(a)nokia.com>
* nua_subnotref.c: do not terminate subscriptions immediately after receiving 200 OK to un-SUBSCRIBE
Mon Feb 25 09:49:39 EST 2008 Pekka.Pessi(a)nokia.com
* nua_subnotref.c: fixed problems re-calculating the subscription duration upon NOTIFY
Thanks for Colin Whittaker for reporting this problem.
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_subnotref.c Wed Feb 27 16:55:20 2008
@@ -371,6 +371,9 @@
else
delta = 0;
+ if (delta > eu->eu_expires)
+ delta = eu->eu_expires;
+
if (win_messenger_enable && !nua_dialog_is_established(nh->nh_ds)) {
/* Notify from messanger does not match with dialog tag */
nh->nh_ds->ds_remote_tag = su_strdup(nh->nh_home, "");
@@ -379,23 +382,23 @@
if (delta > 0) {
nua_dialog_usage_set_refresh(du, delta);
}
- else if (!eu->eu_notified) {
- /* This is a fetch: subscription was really terminated
- but we wait 32 seconds for NOTIFY. */
- delta = 64 * NTA_SIP_T1 / 1000;
-
- if (win_messenger_enable)
- delta = 4 * 60; /* Wait 4 minutes for NOTIFY from Messenger */
+ else {
+ if (eu->eu_substate == nua_substate_terminated) {
+ if (!eu->eu_notified)
+ eu->eu_substate = nua_substate_embryonic;
+ }
- eu->eu_final_wait = 1;
+ if (eu->eu_substate != nua_substate_terminated) {
+ /* Wait 32 seconds for NOTIFY. */
+ delta = 64 * NTA_SIP_T1 / 1000;
- if (eu->eu_substate == nua_substate_terminated)
- eu->eu_substate = nua_substate_embryonic;
+ eu->eu_final_wait = 1;
- nua_dialog_usage_set_refresh_range(du, delta, delta);
- }
- else {
- eu->eu_substate = nua_substate_terminated;
+ if (!eu->eu_notified && win_messenger_enable)
+ delta = 4 * 60; /* Wait 4 minutes for NOTIFY from Messenger */
+
+ nua_dialog_usage_set_refresh_range(du, delta, delta);
+ }
}
substate = eu->eu_substate;
@@ -650,8 +653,6 @@
if (substate == nua_substate_active || substate == nua_substate_pending) {
if (subs && subs->ss_expires)
delta = strtoul(subs->ss_expires, NULL, 10);
- else
- delta = eu->eu_expires;
}
else if (substate == nua_substate_embryonic) {
if (subs && subs->ss_reason) {
@@ -689,7 +690,8 @@
nua_dialog_usage_set_refresh_range(du, retry, retry + 5);
}
else {
- nua_dialog_usage_set_refresh(du, delta);
+ if (delta < SIP_TIME_MAX)
+ nua_dialog_usage_set_refresh(du, delta);
}
return retval;
1
0