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
November 2007
- 8 participants
- 332 discussions
[commit] r6353 - in freeswitch/trunk/src/mod/applications: mod_conference mod_dptools mod_rss
by Freeswitch SVN 20 Nov '07
by Freeswitch SVN 20 Nov '07
20 Nov '07
Author: mikej
Date: Mon Nov 19 22:44:19 2007
New Revision: 6353
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c
Log:
merge MODAPP-50 (modified for changes in api)
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Mon Nov 19 22:44:19 2007
@@ -3127,7 +3127,7 @@
static switch_status_t conf_api_sub_transfer(conference_obj_t * conference, switch_stream_handle_t *stream, int argc, char **argv)
{
switch_status_t ret_status = SWITCH_STATUS_SUCCESS;
- char *params = NULL;
+ char *params = NULL, *chanvars = NULL;
assert(conference != NULL);
assert(stream != NULL);
@@ -3170,8 +3170,9 @@
profile_name = "default";
}
params = switch_mprintf("conf_name=%s&profile_name=%s", conf_name, profile_name);
+ chanvars = switch_channel_build_param_string(channel, NULL, params);
/* Open the config from the xml registry */
- if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, params))) {
+ if (!(cxml = switch_xml_open_cfg(global_cf_name, &cfg, chanvars))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", global_cf_name);
goto done;
}
@@ -3243,6 +3244,8 @@
done:
switch_safe_free(params);
+ switch_safe_free(chanvars);
+
return ret_status;
}
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Mon Nov 19 22:44:19 2007
@@ -853,13 +853,14 @@
SWITCH_STANDARD_APP(ivr_application_function)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- char *params;
+ char *params,*chanvars;
if (channel && data && (params = switch_core_session_strdup(session, data))) {
switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
// Open the config from the xml registry
- if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, NULL)) != NULL) {
+ chanvars = switch_channel_build_param_string(channel, NULL, NULL);
+ if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, chanvars)) != NULL) {
if ((xml_menus = switch_xml_child(cfg, "menus"))) {
xml_menu = switch_xml_find_child(xml_menus, "menu", "name", params);
@@ -890,6 +891,7 @@
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", ivr_cf_name);
}
+ switch_safe_free(chanvars);
}
}
Modified: freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c Mon Nov 19 22:44:19 2007
@@ -186,6 +186,7 @@
uint32_t matches = 0;
switch_input_args_t args = { 0 };
const char *vcf = NULL;
+ char *chanvars = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -194,10 +195,12 @@
cf = vcf;
}
+ chanvars = switch_channel_build_param_string(channel, NULL, NULL);
if (!(cxml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return;
}
+ switch_safe_free(chanvars);
if ((feeds = switch_xml_child(cfg, "feeds"))) {
for (feed = switch_xml_child(feeds, "feed"); feed; feed = feed->next) {
1
0
Author: mikej
Date: Mon Nov 19 22:31:57 2007
New Revision: 6352
Modified:
freeswitch/trunk/src/switch_xml.cpp
Log:
fix FSCORE-61
Modified: freeswitch/trunk/src/switch_xml.cpp
==============================================================================
--- freeswitch/trunk/src/switch_xml.cpp (original)
+++ freeswitch/trunk/src/switch_xml.cpp Mon Nov 19 22:31:57 2007
@@ -718,7 +718,7 @@
: (char *)malloc(2); // mem for list of maloced vals
strcpy(attr[l + 3] + (l / 2), " "); // value is not malloced
attr[l + 2] = NULL; // null terminate list
- attr[l + 1] = ""; // temporary attribute value
+ attr[l + 1] = (char *)""; // temporary attribute value
attr[l] = s; // set attribute name
s += strcspn(s, SWITCH_XML_WS "=/>");
@@ -1765,7 +1765,7 @@
'\0', sizeof(struct switch_xml_root));
root->xml.name = (char *) name;
root->cur = &root->xml;
- strcpy(root->err, root->xml.txt = "");
+ strcpy(root->err, root->xml.txt = (char *)"");
root->ent = (char **)memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
root->attr = root->pi = (char ***) (root->xml.attr = SWITCH_XML_NIL);
return &root->xml;
@@ -1824,7 +1824,7 @@
child->attr = SWITCH_XML_NIL;
child->off = off;
child->parent = xml;
- child->txt = "";
+ child->txt = (char *)"";
return switch_xml_insert(child, xml, off);
}
1
0
20 Nov '07
Author: mikej
Date: Mon Nov 19 22:26:40 2007
New Revision: 6351
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
Log:
re-factor, reduce indentation in some function, whitespace and comment cleanup.
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Mon Nov 19 22:26:40 2007
@@ -48,60 +48,63 @@
nua_handle_t *msg_nh;
char *contact;
- if (to && (user = strdup(to))) {
- if ((host = strchr(user, '@'))) {
- *host++ = '\0';
- }
+ if (!to) {
+ return SWITCH_STATUS_SUCCESS;
+ }
- if (!host || !(profile = sofia_glue_find_profile(host))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", proto, from, to,
- body ? body : "[no body]", host ? host : "NULL");
- return SWITCH_STATUS_FALSE;
- }
+ user = strdup(to);
+ assert(user);
- if (!sofia_reg_find_reg_url(profile, user, host, buf, sizeof(buf))) {
- return SWITCH_STATUS_FALSE;
- }
+ if ((host = strchr(user, '@'))) {
+ *host++ = '\0';
+ }
- if (!strcmp(proto, SOFIA_CHAT_PROTO)) {
- from = hint;
- } else {
- char *fp, *p, *fu = NULL;
+ if (!host || !(profile = sofia_glue_find_profile(host))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nInvalid Profile %s\n", proto, from, to,
+ body ? body : "[no body]", host ? host : "NULL");
+ return SWITCH_STATUS_FALSE;
+ }
- if (!(fp = strdup(from))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
- return SWITCH_STATUS_FALSE;
- }
+ if (!sofia_reg_find_reg_url(profile, user, host, buf, sizeof(buf))) {
+ return SWITCH_STATUS_FALSE;
+ }
- if ((p = strchr(fp, '@'))) {
- *p = '\0';
- fu = strdup(fp);
- *p = '+';
- }
+ if (!strcmp(proto, SOFIA_CHAT_PROTO)) {
+ from = hint;
+ } else {
+ char *fp, *p, *fu = NULL;
+ fp = strdup(from);
+ if (!fp) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+ return SWITCH_STATUS_FALSE;
+ }
- ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fu, proto, fp, profile->name);
- from = ffrom;
- switch_safe_free(fu);
- switch_safe_free(fp);
+ if ((p = strchr(fp, '@'))) {
+ *p = '\0';
+ fu = strdup(fp);
+ *p = '+';
}
- contact = sofia_glue_get_url_from_contact(buf, 1);
- msg_nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(buf), // if this cries, add contact here too, change the 1 to 0 and omit the safe_free
- SIPTAG_CONTACT_STR(profile->url), TAG_END());
+ ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fu, proto, fp, profile->name);
+ from = ffrom;
+ switch_safe_free(fu);
+ switch_safe_free(fp);
+ }
- switch_safe_free(contact);
+ contact = sofia_glue_get_url_from_contact(buf, 1);
+ msg_nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(buf), // if this cries, add contact here too, change the 1 to 0 and omit the safe_free
+ SIPTAG_CONTACT_STR(profile->url), TAG_END());
+ switch_safe_free(contact);
- nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
-
+ nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR("text/html"), SIPTAG_PAYLOAD_STR(body), TAG_END());
- switch_safe_free(ffrom);
- free(user);
+ switch_safe_free(ffrom);
+ free(user);
- if (profile) {
- switch_thread_rwlock_unlock(profile->rwlock);
- }
+ if (profile) {
+ switch_thread_rwlock_unlock(profile->rwlock);
}
return SWITCH_STATUS_SUCCESS;
@@ -149,8 +152,6 @@
}
}
-
-
char *sofia_presence_translate_rpid(char *in, char *ext)
{
char *r = in;
@@ -233,7 +234,6 @@
sofia_presence_mwi_callback,
profile);
-
switch_safe_free(sql);
switch_safe_free(dup_account);
if (profile) {
@@ -241,7 +241,6 @@
}
}
-
void sofia_presence_event_handler(switch_event_t *event)
{
sofia_profile_t *profile = NULL;
@@ -252,11 +251,9 @@
char *rpid = switch_event_get_header(event, "rpid");
char *status = switch_event_get_header(event, "status");
char *event_type = switch_event_get_header(event, "event_type");
- //char *event_subtype = switch_event_get_header(event, "event_subtype");
char *sql = NULL;
char *euser = NULL, *user = NULL, *host = NULL;
-
if (rpid && !strcasecmp(rpid, "n/a")) {
rpid = NULL;
}
@@ -304,15 +301,12 @@
continue;
}
-
sofia_glue_execute_sql_callback(profile,
SWITCH_FALSE,
profile->ireg_mutex,
sql,
sofia_presence_sub_callback,
profile);
-
-
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
free(sql);
@@ -339,12 +333,10 @@
} else {
euser = user;
}
-
} else {
return;
}
-
switch (event->event_id) {
case SWITCH_EVENT_PRESENCE_PROBE:
if (proto) {
@@ -374,9 +366,7 @@
sofia_presence_resub_callback,
profile);
-
sofia_glue_release_profile(profile);
-
switch_safe_free(sql);
}
switch_safe_free(user);
@@ -413,7 +403,6 @@
sql,
sofia_presence_sub_callback,
profile);
-
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
@@ -425,7 +414,6 @@
static int sofia_presence_sub_reg_callback(void *pArg, int argc, char **argv, char **columnNames)
{
sofia_profile_t *profile = (sofia_profile_t *) pArg;
- //char *proto = argv[0];
char *user = argv[1];
char *host = argv[2];
switch_event_t *event;
@@ -603,8 +591,6 @@
SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=3600"),
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
-
-
if (done) {
switch_core_hash_delete(profile->sub_hash, call_id);
}
@@ -621,7 +607,7 @@
{
//char *proto = argv[0];
//char *user = argv[1];
- char *host = argv[2];
+ //char *host = argv[2];
char *sub_to_user = argv[3];
char *sub_to_host = argv[4];
char *event = argv[5];
@@ -638,7 +624,7 @@
int expire_sec = atoi(expires);
if (!(profile = sofia_glue_find_profile(sub_to_host))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile for host %s\n", host);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find profile for host %s\n", sub_to_host);
return 0;
}
@@ -658,17 +644,14 @@
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
-
switch_safe_free(id);
switch_safe_free(exp);
sofia_glue_release_profile(profile);
-
return 0;
}
-
void sofia_presence_handle_sip_i_subscribe(int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
@@ -678,10 +661,9 @@
sip_to_t const *to = sip->sip_to;
sip_from_t const *from = sip->sip_from;
sip_contact_t const *contact = sip->sip_contact;
- char *from_user = NULL;
- char *from_host = NULL;
- char *to_user = NULL;
- char *to_host = NULL;
+ const char *from_user = NULL, *from_host = NULL;
+ const char *to_user = NULL, *to_host = NULL;
+ char *my_to_user = NULL;
char *sql, *event = NULL;
char *proto = "sip";
char *d_user = NULL;
@@ -698,7 +680,6 @@
tl_gets(tags,
NUTAG_SUBSTATE_REF(sub_state), TAG_END());
-
if (contact) {
char *port = (char *) contact->m_url->url_port;
@@ -732,13 +713,13 @@
}
if (to) {
- to_user = (char *) to->a_url->url_user;
- to_host = (char *) to->a_url->url_host;
+ to_user = to->a_url->url_user;
+ to_host = to->a_url->url_host;
}
if (sip && sip->sip_from) {
- from_user = (char *) sip->sip_from->a_url->url_user;
- from_host = (char *) sip->sip_from->a_url->url_host;
+ from_user = sip->sip_from->a_url->url_user;
+ from_host = sip->sip_from->a_url->url_host;
} else {
from_user = "n/a";
from_host = "n/a";
@@ -776,8 +757,9 @@
if (strchr(to_user, '+')) {
char *h;
if ((proto = (d_user = strdup(to_user)))) {
- if ((to_user = strchr(d_user, '+'))) {
- *to_user++ = '\0';
+ if ((my_to_user = strchr(d_user, '+'))) {
+ *my_to_user++ = '\0';
+ to_user = my_to_user;
if ((h = strchr(to_user, '+')) || (h = strchr(to_user, '@'))) {
*h++ = '\0';
to_host = h;
@@ -791,7 +773,7 @@
}
}
- call_id = sip->sip_call_id->i_id; //sip_header_as_string(profile->home, (void *) sip->sip_call_id);
+ call_id = sip->sip_call_id->i_id;
event = sip_header_as_string(profile->home, (void *) sip->sip_event);
full_from = sip_header_as_string(profile->home, (void *) sip->sip_from);
full_via = sip_header_as_string(profile->home, (void *) sip->sip_via);
@@ -799,8 +781,6 @@
exp_raw = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
exp = (long) time(NULL) + exp_raw;
-
-
switch_mutex_lock(profile->ireg_mutex);
sql = switch_mprintf("delete from sip_subscriptions where "
@@ -827,11 +807,9 @@
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
free(sql);
-
switch_mutex_unlock(profile->ireg_mutex);
sstr = switch_mprintf("active;expires=%ld", exp_raw);
switch_core_hash_insert(profile->sub_hash, call_id, nh);
-
}
nua_respond(nh, SIP_202_ACCEPTED,
@@ -862,12 +840,6 @@
su_free(profile->home, event);
}
- /*
- if (call_id) {
- su_free(profile->home, call_id);
- }
- */
-
if (full_from) {
su_free(profile->home, full_from);
}
@@ -975,70 +947,52 @@
if (event_type) {
su_free(profile->home, event_type);
}
-
switch_xml_free(xml);
}
-
}
-
}
-
nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
-
}
void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip)
{
-
- snprintf(hash_key, len, "%s%s%s", (char *) sip->sip_from->a_url->url_user, (char *) sip->sip_from->a_url->url_host,
- (char *) sip->sip_to->a_url->url_user);
-
-
-#if 0
- /* nicer one we cant use in both directions >=0 */
- snprintf(hash_key, len, "%s%s%s%s%s%s",
- (char *) sip->sip_to->a_url->url_user,
- (char *) sip->sip_to->a_url->url_host,
- (char *) sip->sip_to->a_url->url_params,
- (char *) sip->sip_from->a_url->url_user, (char *) sip->sip_from->a_url->url_host, (char *) sip->sip_from->a_url->url_params);
-#endif
-
+ url_t *to = sip->sip_to->a_url;
+ url_t *from = sip->sip_from->a_url;
+ snprintf(hash_key, len, "%s%s%s", from->url_user, from->url_host, to->url_user);
}
-
void sofia_presence_handle_sip_i_message(int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{
if (sip) {
sip_from_t const *from = sip->sip_from;
- char *from_user = NULL;
- char *from_host = NULL;
+ const char *from_user = NULL;
+ const char *from_host = NULL;
sip_to_t const *to = sip->sip_to;
- char *to_user = NULL;
- char *to_host = NULL;
+ const char *to_user = NULL;
+ const char *to_host = NULL;
sip_subject_t const *sip_subject = sip->sip_subject;
sip_payload_t *payload = sip->sip_payload;
const char *subject = "n/a";
char *msg = NULL;
if (sip->sip_content_type) {
- if (strstr((char *) sip->sip_content_type->c_subtype, "composing")) {
+ if (strstr(sip->sip_content_type->c_subtype, "composing")) {
return;
}
}
if (from) {
- from_user = (char *) from->a_url->url_user;
- from_host = (char *) from->a_url->url_host;
+ from_user = from->a_url->url_user;
+ from_host = from->a_url->url_host;
}
if (to) {
- to_user = (char *) to->a_url->url_user;
- to_host = (char *) to->a_url->url_host;
+ to_user = to->a_url->url_user;
+ to_host = to->a_url->url_host;
}
-
if (!to_user) {
return;
}
@@ -1074,14 +1028,12 @@
*p = '@';
}
}
-
} else {
to_addr = switch_mprintf("%s@%s", to_user, to_host);
}
from_addr = switch_mprintf("%s@%s", from_user, from_host);
-
sofia_presence_set_hash_key(hash_key, sizeof(hash_key), sip);
if ((tech_pvt = (private_object_t *) switch_core_hash_find(profile->chat_hash, hash_key))) {
channel = switch_core_session_get_channel(tech_pvt->session);
@@ -1107,7 +1059,6 @@
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
}
-
}
switch_safe_free(to_addr);
switch_safe_free(from_addr);
@@ -1115,7 +1066,6 @@
su_free(profile->home, full_from);
}
}
-
}
}
1
0
20 Nov '07
Author: mikej
Date: Mon Nov 19 22:24:55 2007
New Revision: 6350
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
whoops
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Nov 19 22:24:55 2007
@@ -2054,7 +2054,9 @@
}
if ((alert_info = sip_alert_info(sip))) {
- switch_channel_set_variable(channel, "alert_info", sip_header_as_string(profile->home, (void *) alert_info));
+ char *tmp = sip_header_as_string(profile->home, (void *) alert_info);
+ switch_channel_set_variable(channel, "alert_info", tmp);
+ su_free(profile->home, tmp);
}
check_decode(displayname, session);
1
0
[commit] r6349 - in freeswitch/trunk/src: include mod/endpoints/mod_sofia
by Freeswitch SVN 20 Nov '07
by Freeswitch SVN 20 Nov '07
20 Nov '07
Author: mikej
Date: Mon Nov 19 21:27:48 2007
New Revision: 6349
Modified:
freeswitch/trunk/src/include/switch_odbc.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
Log:
re-factor, cleanup ODBC ifdefs, whitespace and comment cleanup.
Modified: freeswitch/trunk/src/include/switch_odbc.h
==============================================================================
--- freeswitch/trunk/src/include/switch_odbc.h (original)
+++ freeswitch/trunk/src/include/switch_odbc.h Mon Nov 19 21:27:48 2007
@@ -54,7 +54,6 @@
SWITCH_ODBC_STATE_CONNECTED,
SWITCH_ODBC_STATE_ERROR
} switch_odbc_state_t;
-typedef struct switch_odbc_handle switch_odbc_handle_t;
typedef enum {
SWITCH_ODBC_SUCCESS = 0,
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Mon Nov 19 21:27:48 2007
@@ -1047,7 +1047,7 @@
typedef struct switch_codec_implementation switch_codec_implementation_t;
typedef struct switch_buffer switch_buffer_t;
typedef struct switch_codec_settings switch_codec_settings_t;
-
+typedef struct switch_odbc_handle switch_odbc_handle_t;
typedef struct switch_io_routines switch_io_routines_t;
typedef struct switch_speech_handle switch_speech_handle_t;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Mon Nov 19 21:27:48 2007
@@ -254,17 +254,10 @@
uint32_t session_timeout;
uint32_t max_proceeding;
uint32_t rtp_timeout_sec;
-#ifdef SWITCH_HAVE_ODBC
char *odbc_dsn;
char *odbc_user;
char *odbc_pass;
switch_odbc_handle_t *master_odbc;
-#else
- void *filler1;
- void *filler2;
- void *filler3;
- void *filler4;
-#endif
};
struct private_object {
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Mon Nov 19 21:27:48 2007
@@ -67,7 +67,6 @@
}
}
-
if (!sr) {
sr = "sendrecv";
}
@@ -182,7 +181,6 @@
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
}
-
if (switch_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding) {
sofia_glue_tech_choose_video_port(tech_pvt);
if ((v_port = tech_pvt->adv_sdp_video_port)) {
@@ -190,7 +188,6 @@
sofia_glue_tech_set_video_codec(tech_pvt, 0);
-
/*****************************/
if (tech_pvt->video_rm_encoding) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->video_pt);
@@ -208,7 +205,6 @@
if (already_did[imp->ianacode]) {
continue;
}
-
already_did[imp->ianacode] = 1;
}
@@ -241,15 +237,13 @@
if (already_did[imp->ianacode]) {
continue;
}
-
already_did[imp->ianacode] = 1;
}
if (!rate) {
rate = imp->samples_per_second;
}
-
-
+
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%d\n", imp->ianacode, imp->iananame, imp->samples_per_second);
if (imp->fmtp) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", imp->ianacode, imp->fmtp);
@@ -258,7 +252,6 @@
}
}
}
- /*****************************/
tech_pvt->local_sdp_str = switch_core_session_strdup(tech_pvt->session, buf);
}
@@ -278,7 +271,6 @@
assert(tech_pvt->session != NULL);
-
if ((abs = switch_channel_get_variable(tech_pvt->channel, "absolute_codec_string"))) {
codec_string = abs;
} else {
@@ -308,14 +300,10 @@
}
} else {
tech_pvt->num_codecs =
- switch_loadable_module_get_codecs(tech_pvt->codecs,
- sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
+ switch_loadable_module_get_codecs(tech_pvt->codecs, sizeof(tech_pvt->codecs) / sizeof(tech_pvt->codecs[0]));
}
-
end:
-
sofia_glue_check_video_codecs(tech_pvt);
-
}
void sofia_glue_check_video_codecs(private_object_t *tech_pvt)
@@ -345,7 +333,6 @@
switch_core_session_add_stream(session, NULL);
-
switch_mutex_lock(tech_pvt->flag_mutex);
switch_mutex_lock(profile->flag_mutex);
tech_pvt->flags = profile->flags;
@@ -373,8 +360,6 @@
snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
switch_channel_set_name(tech_pvt->channel, name);
- //sofia_glue_tech_prepare_codecs(tech_pvt);
-
}
switch_status_t sofia_glue_ext_address_lookup(char **ip, switch_port_t *port, char *sourceip, switch_memory_pool_t *pool)
@@ -402,14 +387,12 @@
return SWITCH_STATUS_SUCCESS;
}
-
switch_status_t sofia_glue_tech_choose_port(private_object_t *tech_pvt)
{
char *ip = tech_pvt->profile->rtpip;
switch_port_t sdp_port;
char tmp[50];
-
if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_audio_port) {
return SWITCH_STATUS_SUCCESS;
}
@@ -432,24 +415,19 @@
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
-
return SWITCH_STATUS_SUCCESS;
}
-
-
switch_status_t sofia_glue_tech_choose_video_port(private_object_t *tech_pvt)
{
char *ip = tech_pvt->profile->rtpip;
switch_port_t sdp_port;
char tmp[50];
-
if (switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA) || tech_pvt->adv_sdp_video_port) {
return SWITCH_STATUS_SUCCESS;
}
-
tech_pvt->local_sdp_video_port = switch_rtp_request_port();
sdp_port = tech_pvt->local_sdp_video_port;
@@ -466,7 +444,6 @@
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
-
return SWITCH_STATUS_SUCCESS;
}
@@ -497,7 +474,6 @@
return new_uri;
}
-
switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
{
char *rpid = NULL;
@@ -544,11 +520,8 @@
cid_num,
!switch_strlen_zero(cid_num) ? "@" : "",
tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip);
-
}
- assert(tech_pvt->from_str != NULL);
-
if ((alertbuf = switch_channel_get_variable(channel, "alert_info"))) {
alert_info = switch_core_session_sprintf(tech_pvt->session, "Alert-Info: %s", alertbuf);
}
@@ -566,7 +539,7 @@
switch_set_flag_locked(tech_pvt, TFLAG_READY);
- // forge a RPID for now KHR -- Should wrap this in an if statement so it can be turned on and off
+ /* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */
if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
const char *priv = "off";
const char *screen = "no";
@@ -652,7 +625,6 @@
tech_pvt->sofia_private = sofia_private;
switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid));
nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private);
-
}
if (tech_pvt->e_dest) {
@@ -691,7 +663,6 @@
const char *hname = name + strlen(SOFIA_SIP_HEADER_PREFIX);
stream.write_function(&stream, "%s: %s\r\n", hname, value);
}
-
}
switch_channel_variable_last(channel);
}
@@ -717,16 +688,11 @@
SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
-
-
switch_safe_free(stream.data);
return SWITCH_STATUS_SUCCESS;
-
}
-
-
void sofia_glue_do_xfer_invite(switch_core_session_t *session)
{
private_object_t *tech_pvt;
@@ -741,20 +707,19 @@
caller_profile = switch_channel_get_caller_profile(channel);
-
-
if ((tech_pvt->from_str = switch_core_session_sprintf(session, "\"%s\" <sip:%s@%s>",
- (char *) caller_profile->caller_id_name,
- (char *) caller_profile->caller_id_number,
+ caller_profile->caller_id_name,
+ caller_profile->caller_id_number,
tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip))) {
const char *rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
tech_pvt->nh2 = nua_handle(tech_pvt->profile->nua, NULL,
- SIPTAG_TO_STR(tech_pvt->dest), SIPTAG_FROM_STR(tech_pvt->from_str), SIPTAG_CONTACT_STR(tech_pvt->profile->url),
+ SIPTAG_TO_STR(tech_pvt->dest),
+ SIPTAG_FROM_STR(tech_pvt->from_str),
+ SIPTAG_CONTACT_STR(tech_pvt->profile->url),
TAG_END());
-
nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private);
nua_invite(tech_pvt->nh2,
@@ -764,7 +729,6 @@
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
}
-
}
void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt)
@@ -833,14 +797,12 @@
tech_pvt->video_read_codec.implementation->iananame, tech_pvt->video_rm_encoding);
switch_core_codec_destroy(&tech_pvt->video_read_codec);
switch_core_codec_destroy(&tech_pvt->video_write_codec);
- //switch_core_session_reset(tech_pvt->session);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->video_read_codec.implementation->iananame);
return SWITCH_STATUS_SUCCESS;
}
}
-
if (!tech_pvt->video_rm_encoding) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec with no name?\n");
return SWITCH_STATUS_FALSE;
@@ -851,7 +813,6 @@
tech_pvt->video_rm_fmtp,
tech_pvt->video_rm_rate,
0,
- //tech_pvt->video_codec_ms,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
@@ -862,7 +823,7 @@
tech_pvt->video_rm_encoding,
tech_pvt->video_rm_fmtp,
tech_pvt->video_rm_rate,
- 0,//tech_pvt->video_codec_ms,
+ 0,
1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
@@ -876,8 +837,6 @@
switch_channel_get_name(tech_pvt->channel), tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate, tech_pvt->video_codec_ms);
tech_pvt->video_read_frame.codec = &tech_pvt->video_read_codec;
- //switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
- //switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
tech_pvt->fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->video_write_codec.fmtp_out);
}
}
@@ -949,10 +908,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
-
-
-
switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_flag_t myflags)
{
int bw, ms;
@@ -1010,7 +965,9 @@
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_audio_port,
tech_pvt->remote_sdp_audio_ip,
- tech_pvt->remote_sdp_audio_port, tech_pvt->agreed_pt, tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
+ tech_pvt->remote_sdp_audio_port,
+ tech_pvt->agreed_pt,
+ tech_pvt->read_codec.implementation->microseconds_per_frame / 1000);
snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
@@ -1086,7 +1043,6 @@
}
}
-
if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_timeout_sec"))) {
int v = atoi(val);
if (v >= 0) {
@@ -1120,28 +1076,25 @@
tech_pvt->remote_sdp_video_port,
tech_pvt->video_agreed_pt,
tech_pvt->video_read_codec.implementation->samples_per_frame,
- 0,//tech_pvt->video_codec_ms * 1000,
+ 0,
(switch_rtp_flag_t) flags,
NULL,
- NULL,//tech_pvt->profile->timer_name,
+ NULL,
&err, switch_core_session_get_pool(tech_pvt->session));
-
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s:%d->%s:%d codec: %u ms: %d [%s]\n",
switch_channel_get_name(tech_pvt->channel),
tech_pvt->local_sdp_audio_ip,
tech_pvt->local_sdp_video_port,
tech_pvt->remote_sdp_video_ip,
tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt,
- 0,//tech_pvt->video_read_codec.implementation->microseconds_per_frame / 1000,
+ 0,
switch_rtp_ready(tech_pvt->video_rtp_session) ? "SUCCESS" : err);
-
if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
}
}
-
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
@@ -1272,13 +1225,11 @@
}
}
-
for (m = sdp->sdp_media; m; m = m->m_next) {
sdp_connection_t *connection;
ptime = dptime;
-
if (m->m_type == sdp_media_audio) {
sdp_rtpmap_t *map;
@@ -1504,7 +1455,6 @@
}
}
}
-
}
switch_set_flag_locked(tech_pvt, TFLAG_SDP);
@@ -1512,7 +1462,7 @@
return match;
}
-// map sip responses to QSIG cause codes ala RFC4497 section 8.4.4
+/* map sip responses to QSIG cause codes ala RFC4497 section 8.4.4 */
switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status)
{
switch (status) {
@@ -1571,21 +1521,17 @@
return SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR;
case 487:
return SWITCH_CAUSE_ORIGINATOR_CANCEL;
-
default:
return SWITCH_CAUSE_NORMAL_UNSPECIFIED;
-
}
}
-
void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp)
{
const char *val;
switch_core_session_t *other_session;
switch_channel_t *other_channel;
-
if ((val = switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE))
&& (other_session = switch_core_session_locate(val))) {
other_channel = switch_core_session_get_channel(other_session);
@@ -1593,18 +1539,15 @@
switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
if (!switch_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
- //switch_channel_test_flag(other_channel, CF_BYPASS_MEDIA) &&
switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) &&
switch_channel_test_flag(tech_pvt->channel, CF_BYPASS_MEDIA))) {
switch_ivr_nomedia(val, SMF_FORCE);
switch_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
}
-
switch_core_session_rwunlock(other_session);
}
}
-
char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup)
{
char *url = NULL, *e;
@@ -1624,7 +1567,6 @@
url = buf;
}
}
-
return url;
}
@@ -1655,7 +1597,6 @@
return profile;
}
-
void sofia_glue_release_profile__(const char *file, const char *func, int line, sofia_profile_t *profile)
{
if (profile) {
@@ -1713,13 +1654,10 @@
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
-
}
int sofia_glue_init_sql(sofia_profile_t *profile)
{
-
-
char reg_sql[] =
"CREATE TABLE sip_registrations (\n"
" call_id VARCHAR(255),\n"
@@ -1731,7 +1669,6 @@
" expires INTEGER"
");\n";
-
char sub_sql[] =
"CREATE TABLE sip_subscriptions (\n"
" proto VARCHAR(255),\n"
@@ -1754,8 +1691,8 @@
" expires INTEGER"
");\n";
-#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) {
+#ifdef SWITCH_HAVE_ODBC
if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) {
return 0;
}
@@ -1780,8 +1717,10 @@
switch_odbc_handle_exec(profile->master_odbc, "DROP TABLE sip_authentication", NULL);
switch_odbc_handle_exec(profile->master_odbc, auth_sql, NULL);
}
- } else {
+#else
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif
+ } else {
if (!(profile->master_db = switch_core_db_open_file(profile->dbname))) {
return 0;
}
@@ -1790,9 +1729,7 @@
switch_core_db_test_reactive(profile->master_db, "delete from sip_subscriptions where sip_user != ''", "DROP TABLE sip_subscriptions", sub_sql);
switch_core_db_test_reactive(profile->master_db, "select * from sip_authentication", "DROP TABLE sip_authentication", auth_sql);
-#ifdef SWITCH_HAVE_ODBC
}
-#endif
#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) {
@@ -1801,8 +1738,6 @@
#endif
return profile->master_db ? 1: 0;
-
-
}
void sofia_glue_sql_close(sofia_profile_t *profile)
@@ -1810,13 +1745,12 @@
#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) {
switch_odbc_handle_destroy(&profile->master_odbc);
- } else {
-#endif
- switch_core_db_close(profile->master_db);
- profile->master_db = NULL;
-#ifdef SWITCH_HAVE_ODBC
+ return;
}
#endif
+
+ switch_core_db_close(profile->master_db);
+ profile->master_db = NULL;
}
@@ -1828,8 +1762,8 @@
switch_mutex_lock(mutex);
}
-#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) {
+#ifdef SWITCH_HAVE_ODBC
SQLHSTMT stmt;
if (switch_odbc_handle_exec(profile->master_odbc, sql, &stmt) != SWITCH_ODBC_SUCCESS) {
char *err_str;
@@ -1838,28 +1772,23 @@
switch_safe_free(err_str);
}
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
- } else {
+#else
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif
-
-
- if (master) {
- db = profile->master_db;
} else {
- if (!(db = switch_core_db_open_file(profile->dbname))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
- goto end;
+ if (master) {
+ db = profile->master_db;
+ } else {
+ if (!(db = switch_core_db_open_file(profile->dbname))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+ goto end;
+ }
+ }
+ switch_core_db_persistant_execute(db, sql, 25);
+ if (!master) {
+ switch_core_db_close(db);
}
- }
- switch_core_db_persistant_execute(db, sql, 25);
- if (!master) {
- switch_core_db_close(db);
- }
-
-
-#ifdef SWITCH_HAVE_ODBC
}
-#endif
-
end:
if (mutex) {
@@ -1867,7 +1796,6 @@
}
}
-
switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
switch_bool_t master,
switch_mutex_t *mutex,
@@ -1884,48 +1812,40 @@
}
-#ifdef SWITCH_HAVE_ODBC
if (profile->odbc_dsn) {
+#ifdef SWITCH_HAVE_ODBC
switch_odbc_handle_callback_exec(profile->master_odbc, sql, callback, pdata);
- } else {
+#else
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ODBC IS NOT AVAILABLE!\n");
#endif
-
-
- if (master) {
- db = profile->master_db;
} else {
- if (!(db = switch_core_db_open_file(profile->dbname))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
- goto end;
- }
- }
-
- switch_core_db_exec(db, sql, callback, pdata, &errmsg);
- if (errmsg) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
- free(errmsg);
- }
+ if (master) {
+ db = profile->master_db;
+ } else {
+ if (!(db = switch_core_db_open_file(profile->dbname))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
+ goto end;
+ }
+ }
+
+ switch_core_db_exec(db, sql, callback, pdata, &errmsg);
- if (!master && db) {
- switch_core_db_close(db);
- }
+ if (errmsg) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
+ free(errmsg);
+ }
-#ifdef SWITCH_HAVE_ODBC
+ if (!master && db) {
+ switch_core_db_close(db);
+ }
}
-#endif
-
end:
-
if (mutex) {
switch_mutex_unlock(mutex);
}
-
-
-
return ret;
-
}
#ifdef SWITCH_HAVE_ODBC
@@ -1957,7 +1877,6 @@
return ret;
}
-
#endif
char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len)
@@ -2008,9 +1927,7 @@
switch_core_db_finalize(stmt);
}
-
fail:
-
switch_core_db_close(db);
end:
@@ -2048,5 +1965,4 @@
*host = h;
return 1;
-
}
1
0
20 Nov '07
Author: mikej
Date: Mon Nov 19 20:53:32 2007
New Revision: 6348
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
Log:
whitespace cleanup.
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Mon Nov 19 20:53:32 2007
@@ -87,8 +87,6 @@
sofia_gateway_t *gateway;
};
-
-
#define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);}
#define set_anchor(t,m) if (t->Anchor) {delete t->Anchor;} t->Anchor = new SipMessage(m);
@@ -118,7 +116,6 @@
PFLAG_SUPRESS_CNG = (1 << 12)
} PFLAGS;
-
typedef enum {
PFLAG_NDLB_TO_IN_200_CONTACT = (1 << 0),
PFLAG_NDLB_BROKEN_AUTH_HASH = (1 << 1)
@@ -166,7 +163,6 @@
};
extern struct mod_sofia_globals mod_sofia_globals;
-
typedef enum {
REG_FLAG_AUTHED = (1 << 0),
REG_FLAG_CALLERID = (1 << 1)
@@ -210,7 +206,6 @@
struct sofia_gateway *next;
};
-
struct sofia_profile {
int debug;
char *name;
@@ -272,7 +267,6 @@
#endif
};
-
struct private_object {
sofia_private_t *sofia_private;
uint32_t flags;
@@ -289,10 +283,8 @@
uint32_t codec_ms;
switch_caller_profile_t *caller_profile;
uint32_t timestamp_send;
- //int32_t timestamp_recv;
switch_rtp_t *rtp_session;
int ssrc;
- //switch_time_t last_read;
sofia_profile_t *profile;
char *local_sdp_audio_ip;
switch_port_t local_sdp_audio_port;
@@ -378,7 +370,6 @@
AUTH_STALE,
} auth_res_t;
-
#define sofia_test_pflag(obj, flag) ((obj)->pflags & flag)
#define sofia_set_pflag(obj, flag) (obj)->pflags |= (flag)
#define sofia_set_pflag_locked(obj, flag) assert(obj->flag_mutex != NULL);\
@@ -392,7 +383,6 @@
/* Function Prototypes */
/*************************************************************************************************************************************************************/
-
switch_status_t sofia_glue_activate_rtp(private_object_t *tech_pvt, switch_rtp_flag_t myflags);
void sofia_glue_deactivate_rtp(private_object_t *tech_pvt);
@@ -424,7 +414,6 @@
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
-
void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void *obj);
void launch_sofia_profile_thread(sofia_profile_t *profile);
@@ -461,7 +450,6 @@
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
-
void sofia_glue_execute_sql(sofia_profile_t *profile, switch_bool_t master, char *sql, switch_mutex_t *mutex);
void sofia_reg_check_expire(sofia_profile_t *profile, time_t now);
void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now);
@@ -499,12 +487,10 @@
sofia_profile_t *sofia_glue_find_profile__(const char *file, const char *func, int line, char *key);
#define sofia_glue_find_profile(x) sofia_glue_find_profile__(__FILE__, __SWITCH_FUNC__, __LINE__, x)
-
switch_status_t sofia_reg_add_gateway(char *key, sofia_gateway_t *gateway);
sofia_gateway_t *sofia_reg_find_gateway__(const char *file, const char *func, int line, char *key);
#define sofia_reg_find_gateway(x) sofia_reg_find_gateway__(__FILE__, __SWITCH_FUNC__, __LINE__, x)
-
void sofia_reg_release_gateway__(const char *file, const char *func, int line, sofia_gateway_t *gateway);
#define sofia_reg_release_gateway(x) sofia_reg_release_gateway__(__FILE__, __SWITCH_FUNC__, __LINE__, x);
1
0
20 Nov '07
Author: mikej
Date: Mon Nov 19 20:44:07 2007
New Revision: 6347
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Log:
re-factor, reduce indentation in some function, whitespace and comment cleanup.
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Mon Nov 19 20:44:07 2007
@@ -35,7 +35,6 @@
/* Best viewed in a 160 x 60 VT100 Terminal or so the line below at least fits across your screen*/
/*************************************************************************************************************************************************************/
-
#include "mod_sofia.h"
SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load);
@@ -47,14 +46,12 @@
static switch_frame_t silence_frame = { 0 };
static char silence_data[13] = "";
-
#define STRLEN 15
static switch_memory_pool_t *module_pool = NULL;
static switch_status_t sofia_on_init(switch_core_session_t *session);
-
static switch_status_t sofia_on_loopback(switch_core_session_t *session);
static switch_status_t sofia_on_transmit(switch_core_session_t *session);
static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session,
@@ -66,11 +63,9 @@
static switch_status_t sofia_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id);
static switch_status_t sofia_kill_channel(switch_core_session_t *session, int sig);
-
/* BODY OF THE MODULE */
/*************************************************************************************************************************************************************/
-
/*
State methods they get called when the state changes to the specific state
returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
@@ -122,7 +117,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
static switch_status_t sofia_on_execute(switch_core_session_t *session)
{
switch_channel_t *channel = NULL;
@@ -139,7 +133,7 @@
return SWITCH_STATUS_SUCCESS;
}
-// map QSIG cause codes to SIP from RFC4497 section 8.4.1
+/* map QSIG cause codes to SIP from RFC4497 section 8.4.1 */
static int hangup_cause_to_sip(switch_call_cause_t cause)
{
switch (cause) {
@@ -192,7 +186,6 @@
default:
return 480;
}
-
}
switch_status_t sofia_on_hangup(switch_core_session_t *session)
@@ -229,22 +222,20 @@
switch_mutex_lock(tech_pvt->profile->flag_mutex);
- if (tech_pvt->nh) {
- if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
- if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
- nua_bye(tech_pvt->nh, TAG_END());
+ if (tech_pvt->nh && !switch_test_flag(tech_pvt, TFLAG_BYE)) {
+ if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
+ nua_bye(tech_pvt->nh, TAG_END());
+ } else {
+ if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
+ nua_cancel(tech_pvt->nh, TAG_END());
} else {
- if (!switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
- nua_respond(tech_pvt->nh, sip_cause, NULL, TAG_END());
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending CANCEL to %s\n", switch_channel_get_name(channel));
- nua_cancel(tech_pvt->nh, TAG_END());
- }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
+ nua_respond(tech_pvt->nh, sip_cause, NULL, TAG_END());
}
- switch_set_flag(tech_pvt, TFLAG_BYE);
}
+ switch_set_flag(tech_pvt, TFLAG_BYE);
}
switch_clear_flag(tech_pvt, TFLAG_IO);
@@ -285,62 +276,66 @@
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
- if (!switch_test_flag(tech_pvt, TFLAG_ANS) && !switch_channel_test_flag(channel, CF_OUTBOUND)) {
- switch_set_flag_locked(tech_pvt, TFLAG_ANS);
-
- if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
- const char *sdp = NULL;
- if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
- tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
- }
- } else {
- if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
- switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
- if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
- const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
- tech_pvt->num_codecs = 0;
- sofia_glue_tech_prepare_codecs(tech_pvt);
- if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
- switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
- nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
- return SWITCH_STATUS_FALSE;
- }
- }
- }
-
- if ((status = sofia_glue_tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
- switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- return status;
- }
+ if (switch_test_flag(tech_pvt, TFLAG_ANS) || switch_channel_test_flag(channel, CF_OUTBOUND)) {
+ return SWITCH_STATUS_SUCCESS;
+ }
- sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
- if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
- switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
- }
+ switch_set_flag_locked(tech_pvt, TFLAG_ANS);
- if (tech_pvt->nh) {
- if (tech_pvt->local_sdp_str) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n", switch_channel_get_name(channel),
- tech_pvt->local_sdp_str);
+ if (switch_channel_test_flag(channel, CF_BYPASS_MEDIA)) {
+ const char *sdp = NULL;
+ if ((sdp = switch_channel_get_variable(channel, SWITCH_B_SDP_VARIABLE))) {
+ tech_pvt->local_sdp_str = switch_core_session_strdup(session, sdp);
+ }
+ } else {
+ if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
+ switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
+ if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
+ const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
+ tech_pvt->num_codecs = 0;
+ sofia_glue_tech_prepare_codecs(tech_pvt);
+ if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
+ nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
+ return SWITCH_STATUS_FALSE;
}
}
}
+ if ((status = sofia_glue_tech_choose_port(tech_pvt)) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ return status;
+ }
+
+ sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
+ if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
- if ((val = switch_channel_get_variable(channel, SOFIA_SESSION_TIMEOUT))) {
- int v_session_timeout = atoi(val);
- if (v_session_timeout >= 0) {
- session_timeout = v_session_timeout;
+ if (tech_pvt->nh) {
+ if (tech_pvt->local_sdp_str) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n", switch_channel_get_name(channel),
+ tech_pvt->local_sdp_str);
}
}
+ }
- nua_respond(tech_pvt->nh, SIP_200_OK,
- NUTAG_SESSION_TIMER(session_timeout),
- SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
- SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
+ if ((val = switch_channel_get_variable(channel, SOFIA_SESSION_TIMEOUT))) {
+ int v_session_timeout = atoi(val);
+ if (v_session_timeout >= 0) {
+ session_timeout = v_session_timeout;
+ }
}
+ nua_respond(tech_pvt->nh, SIP_200_OK,
+ NUTAG_SESSION_TIMER(session_timeout),
+ SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
+ SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
+ SOATAG_AUDIO_AUX("cn telephone-event"),
+ NUTAG_INCLUDE_EXTRA_SDP(1),
+ TAG_END());
+
return SWITCH_STATUS_SUCCESS;
}
@@ -477,7 +472,6 @@
}
}
-
tech_pvt->read_frame.datalen = 0;
switch_set_flag_locked(tech_pvt, TFLAG_READING);
@@ -539,7 +533,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
static switch_status_t sofia_write_frame(switch_core_session_t *session, switch_frame_t *frame, int timeout, switch_io_flag_t flags, int stream_id)
{
private_object_t *tech_pvt;
@@ -584,14 +577,8 @@
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
}
-#if 0
- printf("%s %s->%s send %d bytes %d samples in %d frames ts=%d\n",
- switch_channel_get_name(channel),
- tech_pvt->local_sdp_audio_ip, tech_pvt->remote_sdp_audio_ip, frame->datalen, samples, frames, tech_pvt->timestamp_send);
-#endif
tech_pvt->timestamp_send += samples;
- //switch_rtp_write_frame(tech_pvt->rtp_session, frame, tech_pvt->timestamp_send);
switch_rtp_write_frame(tech_pvt->rtp_session, frame, 0);
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
@@ -634,9 +621,7 @@
}
break;
}
-
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t sofia_waitfor_read(switch_core_session_t *session, int ms, int stream_id)
@@ -653,7 +638,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
static switch_status_t sofia_waitfor_write(switch_core_session_t *session, int ms, int stream_id)
{
private_object_t *tech_pvt;
@@ -666,7 +650,6 @@
assert(tech_pvt != NULL);
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t sofia_send_dtmf(switch_core_session_t *session, char *digits)
@@ -678,7 +661,6 @@
return switch_rtp_queue_rfc2833(tech_pvt->rtp_session,
digits, tech_pvt->profile->dtmf_duration * (tech_pvt->read_codec.implementation->samples_per_second / 1000));
-
}
static switch_status_t sofia_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
@@ -693,7 +675,6 @@
tech_pvt = (private_object_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_BROADCAST: {
const char *ip = NULL, *port = NULL;
@@ -704,7 +685,10 @@
}
nua_respond(tech_pvt->nh, SIP_200_OK,
SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
- SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), TAG_END());
+ SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
+ SOATAG_AUDIO_AUX("cn telephone-event"),
+ NUTAG_INCLUDE_EXTRA_SDP(1),
+ TAG_END());
switch_channel_mark_answered(channel);
}
break;
@@ -817,7 +801,6 @@
switch_core_session_rwunlock(a_session);
}
-
msg->pointer_arg = NULL;
return SWITCH_STATUS_FALSE;
}
@@ -955,7 +938,6 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
-
if (!(body = switch_event_get_body(event))) {
body = "";
}
@@ -973,7 +955,6 @@
typedef switch_status_t (*sofia_command_t) (char **argv, int argc, switch_stream_handle_t *stream);
-
static const char *sofia_state_names[] = { "UNREGED",
"TRYING",
"REGISTER",
@@ -997,7 +978,6 @@
char exp_buf[128] = "";
switch_time_exp_t tm;
-
if (argv[6]) {
switch_time_t etime = atoi(argv[6]);
switch_size_t retsize;
@@ -1005,8 +985,7 @@
switch_time_exp_lt(&tm, switch_time_from_sec(etime));
switch_strftime(exp_buf, &retsize, sizeof(exp_buf), "%Y-%m-%d %T", &tm);
}
-
-
+
cb->stream->write_function(cb->stream,
"Call-ID \t%s\n"
"User \t%s@%s\n"
@@ -1028,7 +1007,6 @@
int ac = 0;
const char *line = "=================================================================================================";
-
if (argc > 0) {
if (argc == 1) {
stream->write_function(stream, "Invalid Syntax!\n");
@@ -1085,10 +1063,7 @@
stream->write_function(stream, "CNG \t%d\n", profile->cng_pt);
stream->write_function(stream, "SESSION-TO \t%d\n", profile->session_timeout);
stream->write_function(stream, "MAX-DIALOG \t%d\n", profile->max_proceeding);
-
-
stream->write_function(stream, "\nRegistrations:\n%s\n", line);
-
cb.profile = profile;
cb.stream = stream;
@@ -1097,7 +1072,6 @@
"select * from sip_registrations",
show_reg_callback, &cb);
-
stream->write_function(stream, "%s\n", line);
sofia_glue_release_profile(profile);
@@ -1107,12 +1081,10 @@
} else {
stream->write_function(stream, "Invalid Syntax!\n");
}
-
return SWITCH_STATUS_SUCCESS;
}
-
stream->write_function(stream, "%25s\t%s\t %32s\t%s\n", "Name", " Type", "Data", "State");
stream->write_function(stream, "%s\n", line);
switch_mutex_lock(mod_sofia_globals.hash_mutex);
@@ -1138,15 +1110,12 @@
stream->write_function(stream, "\n");
}
}
-
-
}
}
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
stream->write_function(stream, "%s\n", line);
stream->write_function(stream, "%d profile%s %d alias%s\n", c, c == 1 ? "" : "s", ac, ac == 1 ? "" : "es");
return SWITCH_STATUS_SUCCESS;
-
}
static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t *stream)
@@ -1161,7 +1130,6 @@
return SWITCH_STATUS_SUCCESS;
}
-
if (!strcasecmp(argv[1], "start")) {
if (argc > 2 && !strcasecmp(argv[2], "reloadxml")) {
if ((xml_root = switch_xml_open_root(1, &err))) {
@@ -1215,7 +1183,6 @@
goto done;
}
-
if (!strcasecmp(argv[1], "unregister")) {
char *gname = argv[2];
sofia_gateway_t *gateway_ptr;
@@ -1239,11 +1206,9 @@
} else {
stream->write_function(stream, "Invalid gateway!\n");
}
-
goto done;
}
-
if (!strcasecmp(argv[1], "stop") || !strcasecmp(argv[1], "restart")) {
int rsec = 3;
int diff = (int) (time(NULL) - profile->started);
@@ -1274,9 +1239,7 @@
stream->write_function(stream, "-ERR Unknown command!\n");
-
done:
-
if (profile) {
sofia_glue_release_profile(profile);
}
@@ -1368,8 +1331,8 @@
}
stream->write_function(stream, "%s", "");
- end:
+end:
switch_safe_free(data);
return SWITCH_STATUS_SUCCESS;
}
@@ -1423,14 +1386,9 @@
stream->write_function(stream, "Unknown Command [%s]\n", argv[0]);
}
-
done:
-
switch_safe_free(mycmd);
-
return status;
-
-
}
switch_io_routines_t sofia_io_routines = {
@@ -1611,8 +1569,6 @@
*new_session = nsession;
cause = SWITCH_CAUSE_SUCCESS;
if (session) {
- //char *val;
- //switch_channel_t *channel = switch_core_session_get_channel(session);
switch_ivr_transfer_variable(session, nsession, SOFIA_REPLACES_HEADER);
switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_HEADER_PREFIX_T);
if (switch_core_session_compare(session, nsession)) {
@@ -1631,7 +1587,6 @@
if (profile) {
sofia_glue_release_profile(profile);
}
-
return cause;
}
@@ -1646,7 +1601,6 @@
silence_frame.buflen = sizeof(silence_data);
silence_frame.flags = SFF_CNG;
-
module_pool = pool;
memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals));
@@ -1654,7 +1608,6 @@
switch_find_local_ip(mod_sofia_globals.guess_ip, sizeof(mod_sofia_globals.guess_ip), AF_INET);
-
switch_core_hash_init(&mod_sofia_globals.profile_hash, module_pool);
switch_core_hash_init(&mod_sofia_globals.gateway_hash, module_pool);
switch_mutex_init(&mod_sofia_globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
@@ -1722,15 +1675,12 @@
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
-
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sofia_shutdown)
{
int sanity = 0;
- //sofia_presence_cancel();
-
switch_mutex_lock(mod_sofia_globals.mutex);
if (mod_sofia_globals.running == 1) {
mod_sofia_globals.running = 0;
@@ -1762,5 +1712,3 @@
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
*/
-
-
1
0
20 Nov '07
Author: mikej
Date: Mon Nov 19 20:15:47 2007
New Revision: 6346
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
fix message.
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Nov 19 20:15:47 2007
@@ -2140,7 +2140,7 @@
"Green laserfire moves past the beeping little robot as his head turns. "
"After a few beeps and a twist of his mechanical arm,\n"
"Artoo reduces the max sessions to %d thus, saving the switch from certian doom.\n",
- sess_count < 10);
+ sess_count - 10);
switch_mutex_unlock(profile->flag_mutex);
}
1
0
20 Nov '07
Author: mikej
Date: Mon Nov 19 20:09:39 2007
New Revision: 6345
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
re-factor, reduce indentation in some function, whitespace and comment cleanup.
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Nov 19 20:09:39 2007
@@ -47,70 +47,66 @@
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{
-#if 0
- if (status > 299) {
- nua_handle_destroy(nh);
- switch_core_hash_delete(profile->sub_hash, sip->sip_call_id->i_id);
- }
-#endif
}
void sofia_handle_sip_i_notify(switch_core_session_t *session, int status,
char const *phrase,
- nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
+ nua_t *nua,
+ sofia_profile_t *profile,
+ nua_handle_t *nh,
+ sofia_private_t *sofia_private,
+ sip_t const *sip,
+ tagi_t tags[])
{
switch_channel_t *channel = NULL;
- if (sip && sip->sip_event) {
- char *type = (char *)sip->sip_event->o_type;
-
- if (!strcasecmp(type, "talk")) {
- if (session) {
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- if (!switch_channel_test_flag(channel, CF_OUTBOUND)) {
- switch_channel_answer(channel);
- switch_channel_set_variable(channel, "auto_answer_destination", switch_channel_get_variable(channel, "destination_number"));
- switch_ivr_session_transfer(session, "auto_answer", NULL , NULL);
- nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
- return;
- }
- }
- }
+ /* make sure we have a proper "talk" event */
+ if (!session || !sip || !sip->sip_event || strcasecmp(sip->sip_event->o_type, "talk")) {
+ goto error;
+ }
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+ if (!switch_channel_test_flag(channel, CF_OUTBOUND)) {
+ switch_channel_answer(channel);
+ switch_channel_set_variable(channel, "auto_answer_destination", switch_channel_get_variable(channel, "destination_number"));
+ switch_ivr_session_transfer(session, "auto_answer", NULL , NULL);
+ nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
+ return;
}
+error:
nua_respond(nh, 481, "Subscription Does Not Exist", NUTAG_WITH_THIS(nua), TAG_END());
-
+ return;
}
-
-
-
void sofia_event_callback(nua_event_t event,
int status,
char const *phrase,
- nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
+ nua_t *nua,
+ sofia_profile_t *profile,
+ nua_handle_t *nh,
+ sofia_private_t *sofia_private,
+ sip_t const *sip,
+ tagi_t tags[])
{
struct private_object *tech_pvt = NULL;
auth_res_t auth_res = AUTH_FORBIDDEN;
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
- if (sofia_private) {
- if (!switch_strlen_zero(sofia_private->uuid)) {
-
- if ((session = switch_core_session_locate(sofia_private->uuid))) {
- tech_pvt = switch_core_session_get_private(session);
- channel = switch_core_session_get_channel(tech_pvt->session);
- if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
- tech_pvt->call_id = switch_core_session_strdup(session, (char *) sip->sip_call_id->i_id);
- switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id);
- }
- } else {
- /* too late */
- return;
+ if (sofia_private && !switch_strlen_zero(sofia_private->uuid)) {
+ if ((session = switch_core_session_locate(sofia_private->uuid))) {
+ tech_pvt = switch_core_session_get_private(session);
+ channel = switch_core_session_get_channel(tech_pvt->session);
+ if (!tech_pvt->call_id && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
+ tech_pvt->call_id = switch_core_session_strdup(session, sip->sip_call_id->i_id);
+ switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id);
}
+ } else {
+ /* too late */
+ return;
}
}
@@ -339,7 +335,6 @@
goto end;
}
-
profile->nua = nua_create(profile->s_root, /* Event loop */
sofia_event_callback, /* Callback for processing events */
profile, /* Additional data to pass to callback */
@@ -351,14 +346,12 @@
goto end;
}
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created agent for %s\n", profile->name);
nua_set_params(profile->nua,
NUTAG_APPL_METHOD("OPTIONS"),
NUTAG_APPL_METHOD("NOTIFY"),
NUTAG_APPL_METHOD("INFO"),
- //NUTAG_EARLY_MEDIA(1),
NUTAG_AUTOANSWER(0),
NUTAG_AUTOALERT(0),
NUTAG_ALLOW("REGISTER"),
@@ -369,7 +362,6 @@
NUTAG_SESSION_TIMER(profile->session_timeout),
NTATAG_MAX_PROCEEDING(profile->max_proceeding),
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("PUBLISH")),
- //TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("NOTIFY")),
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW("SUBSCRIBE")),
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ENABLEMESSAGE(1)),
TAG_IF((profile->pflags & PFLAG_PRESENCE), NUTAG_ALLOW_EVENTS("presence")),
@@ -399,8 +391,6 @@
}
-
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "activated db for %s\n", profile->name);
switch_mutex_init(&profile->ireg_mutex, SWITCH_MUTEX_NESTED, profile->pool);
@@ -445,16 +435,11 @@
su_root_step(profile->s_root, 1000);
}
-
- //sofia_reg_check_expire(profile, 0);
- //sofia_reg_check_gateway(profile, 0);
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock %s\n", profile->name);
switch_thread_rwlock_wrlock(profile->rwlock);
sofia_reg_unregister(profile);
nua_shutdown(profile->nua);
-
su_root_run(profile->s_root);
nua_destroy(profile->nua);
@@ -475,7 +460,6 @@
su_root_destroy(profile->s_root);
pool = profile->pool;
-
sofia_glue_del_profile(profile);
switch_core_hash_destroy(&profile->chat_hash);
switch_core_hash_destroy(&profile->sub_hash);
@@ -489,10 +473,7 @@
switch_core_destroy_memory_pool(&pool);
-
end:
-
-
switch_mutex_lock(mod_sofia_globals.mutex);
mod_sofia_globals.threads--;
switch_mutex_unlock(mod_sofia_globals.mutex);
@@ -680,13 +661,11 @@
params = switch_core_sprintf(gateway->pool, ";transport=%s", register_transport);
}
-
gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s;transport=%s", register_proxy,register_transport);
gateway->register_from = switch_core_sprintf(gateway->pool, "<sip:%s@%s;transport=%s>", from_user, from_domain, register_transport);
gateway->register_contact = switch_core_sprintf(gateway->pool, "<sip:%s@%s:%d%s>", extension,
profile->extsipip ? profile->extsipip : profile->sipip, profile->sip_port, params);
-
if (!strncasecmp(proxy, "sip:", 4)) {
gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
@@ -695,8 +674,6 @@
gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy);
}
-
-
gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
@@ -750,7 +727,6 @@
su_log_redirect(tport_log, logger, NULL);
}
-
if (!switch_strlen_zero(profile_name) && (profile = sofia_glue_find_profile(profile_name))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile [%s] Already exists.\n", switch_str_nil(profile_name));
status = SWITCH_STATUS_FALSE;
@@ -809,8 +785,6 @@
goto done;
}
-
-
profile->pool = pool;
profile->name = switch_core_strdup(profile->pool, xprofilename);
@@ -823,7 +797,6 @@
switch_mutex_init(&profile->flag_mutex, SWITCH_MUTEX_NESTED, profile->pool);
profile->dtmf_duration = 100;
-
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
@@ -1100,7 +1073,6 @@
}
}
-
if (profile->sipip) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Started Profile %s [%s]\n", profile->name, url);
launch_sofia_profile_thread(profile);
@@ -1143,7 +1115,6 @@
switch_channel_t *other_channel = NULL;
char st[80] = "";
-
tl_gets(tags,
NUTAG_CALLSTATE_REF(ss_state),
NUTAG_OFFER_RECV_REF(offer_recv),
@@ -1159,8 +1130,6 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
assert(tech_pvt->nh != NULL);
-
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Channel %s entering state [%s]\n",
switch_channel_get_name(channel), nua_callstate_name(ss_state));
@@ -1176,7 +1145,6 @@
if (status == 988) {
goto done;
}
-
if (channel && (status == 180 || status == 183) && switch_channel_test_flag(channel, CF_OUTBOUND)) {
const char *val;
@@ -1185,7 +1153,6 @@
}
}
-
switch ((enum nua_callstate) ss_state) {
case nua_callstate_init:
break;
@@ -1254,7 +1221,6 @@
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED_NOMEDIA");
switch_set_flag_locked(tech_pvt, TFLAG_READY);
switch_channel_set_state(channel, CS_INIT);
- //switch_core_session_thread_launch(session);
goto done;
} else {
sdp_parser_t *parser;
@@ -1277,7 +1243,6 @@
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "RECEIVED");
switch_set_flag_locked(tech_pvt, TFLAG_READY);
switch_channel_set_state(channel, CS_INIT);
- //switch_core_session_thread_launch(session);
if (replaces_str) {
home = su_home_new(sizeof(*home));
@@ -1470,7 +1435,6 @@
switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
}
}
-
}
break;
@@ -1510,7 +1474,6 @@
}
done:
-
return;
}
@@ -1608,8 +1571,13 @@
switch_set_flag_locked(b_tech_pvt, TFLAG_XFER);
b_tech_pvt->xferto = switch_core_session_strdup(b_session, switch_core_session_get_uuid(session));
switch_set_flag_locked(tech_pvt, TFLAG_BYE);
- nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
- NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
+ nua_notify(tech_pvt->nh,
+ NUTAG_NEWSUB(1),
+ SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+ NUTAG_SUBSTATE(nua_substate_terminated),
+ SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
+ SIPTAG_EVENT_STR(etmp),
+ TAG_END());
} else {
switch_core_session_t *t_session;
switch_channel_t *hup_channel;
@@ -1622,15 +1590,19 @@
t_session = switch_core_session_locate(br_b);
hup_channel = channel_a;
switch_channel_hangup(channel_b, SWITCH_CAUSE_ATTENDED_TRANSFER);
-
}
if (t_session) {
ext = switch_channel_get_variable(hup_channel, "destination_number");
switch_ivr_session_transfer(t_session, ext, NULL, NULL);
- nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
- NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"), SIPTAG_EVENT_STR(etmp), TAG_END());
+ nua_notify(tech_pvt->nh,
+ NUTAG_NEWSUB(1),
+ SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
+ NUTAG_SUBSTATE(nua_substate_terminated),
+ SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK"),
+ SIPTAG_EVENT_STR(etmp),
+ TAG_END());
switch_core_session_rwunlock(t_session);
switch_channel_hangup(hup_channel, SWITCH_CAUSE_ATTENDED_TRANSFER);
} else {
@@ -1660,7 +1632,9 @@
exten = switch_mprintf("sofia/%s/%s@%s:%s",
profile->name,
- (char *) refer_to->r_url->url_user, (char *) refer_to->r_url->url_host, refer_to->r_url->url_port);
+ refer_to->r_url->url_user,
+ refer_to->r_url->url_host,
+ refer_to->r_url->url_port);
switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, rep);
@@ -1731,7 +1705,6 @@
nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden"), SIPTAG_EVENT_STR(etmp),
TAG_END());
-
}
}
@@ -1747,59 +1720,57 @@
if (etmp) {
switch_safe_free(etmp);
}
-
-
}
void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[])
{
+ struct private_object *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+ char dtmf_digit[2] = { 0, 0 };
- //placeholder for string searching
+ /* placeholder for string searching */
char *signal_ptr;
- //Try and find signal information in the payload
+ /* Try and find signal information in the payload */
signal_ptr = strstr(sip->sip_payload->pl_data, "Signal=");
- //See if we found a match
- if (signal_ptr) {
- struct private_object *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
- char dtmf_digit[2] = { 0, 0 };
-
- //Get the channel
- channel = switch_core_session_get_channel(session);
-
- //Barf if we didn't get it
- assert(channel != NULL);
+ /* unknown info type */
+ if (!signal_ptr) {
+ sip_from_t const *from = sip->sip_from;
- //make sure we have our privates
- tech_pvt = switch_core_session_get_private(session);
+ /* print in the logs if something comes through we don't understand */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown INFO Recieved: %s%s" URL_PRINT_FORMAT "[%s]\n",
+ from->a_display ? from->a_display : "",
+ from->a_display ? " " : "",
+ URL_PRINT_ARGS(from->a_url),
+ sip->sip_payload->pl_data);
+ return;
+ }
- //Barf if we didn't get it
- assert(tech_pvt != NULL);
+ /* Get the channel */
+ channel = switch_core_session_get_channel(session);
- //move signal_ptr where we need it (right past Signal=)
- signal_ptr = signal_ptr + 7;
+ /* Barf if we didn't get it */
+ assert(channel != NULL);
- //put the digit somewhere we can muck with
- strncpy(dtmf_digit, signal_ptr, 1);
+ /* make sure we have our privates */
+ tech_pvt = switch_core_session_get_private(session);
- //queue it up
- switch_channel_queue_dtmf(channel, dtmf_digit);
+ /* Barf if we didn't get it */
+ assert(tech_pvt != NULL);
- //print debug info
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%s)\n", dtmf_digit);
+ /* move signal_ptr where we need it (right past Signal=) */
+ signal_ptr = signal_ptr + 7;
- } else { //unknown info type
- sip_from_t const *from;
+ /* put the digit somewhere we can muck with */
+ strncpy(dtmf_digit, signal_ptr, 1);
- from = sip->sip_from;
+ /* queue it up */
+ switch_channel_queue_dtmf(channel, dtmf_digit);
- //print in the logs if something comes through we don't understand
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown INFO Recieved: %s%s" URL_PRINT_FORMAT "[%s]\n",
- from->a_display ? from->a_display : "", from->a_display ? " " : "", URL_PRINT_ARGS(from->a_url), sip->sip_payload->pl_data);
- }
+ /* print debug info */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INFO DTMF(%s)\n", dtmf_digit);
return;
}
@@ -1874,7 +1845,6 @@
int is_auth = 0;
su_addrinfo_t *my_addrinfo = msg_addrinfo(nua_current_request(nua));
-
if (sess_count >= sess_max) {
nua_respond(nh, 480, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
return;
@@ -1886,7 +1856,6 @@
return;
}
-
if (!(sip->sip_contact && sip->sip_contact->m_url)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
nua_respond(nh, 400, "Missing Contact Header", TAG_END());
@@ -1920,7 +1889,6 @@
tech_pvt->key = switch_core_session_strdup(session, key);
}
-
get_addr(network_ip, sizeof(network_ip), &((struct sockaddr_in *) my_addrinfo->ai_addr)->sin_addr);
channel = switch_core_session_get_channel(session);
@@ -1928,7 +1896,6 @@
switch_channel_set_variable(channel, "sip_authorized", "true");
}
-
if (v_event) {
switch_event_header_t *hp;
@@ -1946,7 +1913,6 @@
check_decode(from_user, session);
-
if (!switch_strlen_zero(from_user)) {
if (*from_user == '+') {
switch_channel_set_variable(channel, "sip_from_user_stripped", (const char *) (from_user + 1));
@@ -1964,7 +1930,6 @@
}
}
-
if ((rpid = sip_remote_party_id(sip))) {
if (rpid->rpid_url && rpid->rpid_url->url_user) {
from_user = rpid->rpid_url->url_user;
@@ -2026,7 +1991,6 @@
sofia_glue_tech_prepare_codecs(tech_pvt);
switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "INBOUND CALL");
-
if (switch_test_flag(tech_pvt, TFLAG_INB_NOMEDIA)) {
switch_channel_set_flag(channel, CF_BYPASS_MEDIA);
@@ -2059,15 +2023,12 @@
switch_channel_set_variable(channel, SWITCH_MAX_FORWARDS_VARIABLE, max_forwards);
}
-
if (sip->sip_request->rq_url) {
sofia_gateway_t *gateway;
char *from_key;
char *user = (char *) sip->sip_request->rq_url->url_user;
check_decode(user, session);
- from_key = switch_core_session_sprintf(session, "sip:%s@%s",
- user,
- (char *) sip->sip_request->rq_url->url_host);
+ from_key = switch_core_session_sprintf(session, "sip:%s@%s", user, sip->sip_request->rq_url->url_host);
if ((gateway = sofia_reg_find_gateway(from_key))) {
context = gateway->register_context;
@@ -2127,11 +2088,12 @@
switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN);
}
}
+
/* Loop thru unknown Headers Here so we can do something with them */
for (un = sip->sip_unknown; un; un = un->un_next) {
if (!strncasecmp(un->un_name, "Diversion", 9)) {
- // Basic Diversion Support for Diversion Indication in SIP
- // draft-levy-sip-diversion-08
+ /* Basic Diversion Support for Diversion Indication in SIP */
+ /* draft-levy-sip-diversion-08 */
if (!switch_strlen_zero(un->un_value)) {
char *tmp_name;
if ((tmp_name = switch_mprintf("%s%s", SOFIA_SIP_HEADER_PREFIX, un->un_name))) {
@@ -2199,15 +2161,6 @@
{
nua_respond(nh, SIP_200_OK,
NUTAG_WITH_THIS(nua),
- //SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
- //SOATAG_AUDIO_AUX("cn telephone-event"),
- //NUTAG_INCLUDE_EXTRA_SDP(1),
TAG_END());
nua_handle_destroy(nh);
}
-
-
-
-
-
-
1
0
19 Nov '07
Author: mikej
Date: Mon Nov 19 18:29:32 2007
New Revision: 6344
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
use the sofia parsers for Alert-Info and Remote-Party-ID headers instead of our own. Further fix for MODENDP-45
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Mon Nov 19 18:29:32 2007
@@ -741,12 +741,10 @@
if (!reload) {
su_init();
-#if 0
if (sip_update_default_mclass(sip_extend_mclass(NULL)) < 0) {
su_deinit();
return SWITCH_STATUS_FALSE;
}
-#endif
su_log_redirect(NULL, logger, NULL);
su_log_redirect(tport_log, logger, NULL);
@@ -1853,91 +1851,14 @@
return uri;
}
-void process_rpid(const char *val, private_object_t *tech_pvt)
-{
- int argc, x, screen = 1;
- char *mydata, *argv[10] = { 0 };
-
- if (!switch_strlen_zero(val)) {
- if ((mydata = strdup(val))) {
- char *name = argv[0];
- char *num;
- argc = switch_separate_string(mydata, ';', argv, (sizeof(argv) / sizeof(argv[0])));
-
- if ((num = strchr(argv[0], '<'))) {
- char *end;
- *num++ = '\0';
-
- if (!strncasecmp(num, "sip:", 4)) {
- num += 4;
- }
-
- if ((end = strchr(num, '@'))) {
- *end = '\0';
- }
-
- if (*name == '"') {
- name++;
- }
-
- if ((end = strchr(name, '"'))) {
- *end = '\0';
- }
-
- if (name) {
- check_decode(name, tech_pvt->session);
- tech_pvt->caller_profile->caller_id_number = switch_core_session_strdup(tech_pvt->session, name);
- }
-
- if (num) {
- check_decode(num, tech_pvt->session);
- tech_pvt->caller_profile->caller_id_number = switch_core_session_strdup(tech_pvt->session, num);
- }
- }
-
- for (x = 1; x < argc && argv[x]; x++) {
- // we dont need to do anything with party yet we should only be seeing party=calling here anyway
- // maybe thats a dangerous assumption bit oh well yell at me later
- // if (!strncasecmp(argv[x], "party", 5)) {
- // party = argv[x];
- // } else
- if (!strncasecmp(argv[x], "privacy=", 8)) {
- char *arg = argv[x] + 8;
-
- if (!strcasecmp(arg, "yes")) {
- switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
- } else if (!strcasecmp(arg, "full")) {
- switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
- } else if (!strcasecmp(arg, "name")) {
- switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
- } else if (!strcasecmp(arg, "number")) {
- switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
- } else {
- switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
- switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
- }
-
- } else if (!strncasecmp(argv[x], "screen=", 7) && screen > 0) {
- char *arg = argv[x] + 8;
- if (!strcasecmp(arg, "no")) {
- screen = 0;
- switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN);
- }
- }
- }
- free(mydata);
- }
- }
-}
void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
{
switch_core_session_t *session = NULL;
char key[128] = "";
sip_unknown_t *un;
-#if 0
sip_remote_party_id_t *rpid = NULL;
-#endif
+ sip_alert_info_t *alert_info = NULL;
private_object_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
const char *channel_name = NULL;
@@ -2037,22 +1958,24 @@
switch_channel_set_variable(channel, "sofia_profile_name", profile->name);
if (!switch_strlen_zero(sip->sip_from->a_display)) {
- char *tmp;
- tmp = switch_core_session_strdup(session, sip->sip_from->a_display);
- if (*tmp == '"') {
- char *p;
-
- tmp++;
- if ((p = strchr(tmp, '"'))) {
- *p = '\0';
- }
- }
- displayname = tmp;
+ displayname = sip->sip_from->a_display;
} else {
displayname = switch_strlen_zero(from_user) ? "unknown" : from_user;
}
}
+
+ if ((rpid = sip_remote_party_id(sip))) {
+ if (rpid->rpid_url && rpid->rpid_url->url_user) {
+ from_user = rpid->rpid_url->url_user;
+ check_decode(from_user, session);
+ }
+
+ if (rpid->rpid_display) {
+ displayname = rpid->rpid_display;
+ }
+ }
+
if (sip->sip_request->rq_url) {
const char *req_uri = url_set_chanvars(session, sip->sip_request->rq_url, sip_req);
if (profile->pflags & PFLAG_FULL_ID) {
@@ -2169,9 +2092,9 @@
dialplan = profile->dialplan;
}
-#if 0
- rpid = sip_remote_party_id(sip);
-#endif
+ if ((alert_info = sip_alert_info(sip))) {
+ switch_channel_set_variable(channel, "alert_info", sip_header_as_string(profile->home, (void *) alert_info));
+ }
check_decode(displayname, session);
tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
@@ -2183,15 +2106,30 @@
NULL, NULL, NULL, MODNAME, context, destination_number);
if (tech_pvt->caller_profile) {
+
+ if (rpid) {
+ if (rpid->rpid_privacy) {
+ if (!strcasecmp(rpid->rpid_privacy, "yes")) {
+ switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+ } else if (!strcasecmp(rpid->rpid_privacy, "full")) {
+ switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+ } else if (!strcasecmp(rpid->rpid_privacy, "name")) {
+ switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
+ } else if (!strcasecmp(rpid->rpid_privacy, "number")) {
+ switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
+ } else {
+ switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
+ switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
+ }
+ }
+
+ if (rpid->rpid_screen && !strcasecmp(rpid->rpid_screen, "no")) {
+ switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN);
+ }
+ }
/* Loop thru unknown Headers Here so we can do something with them */
for (un = sip->sip_unknown; un; un = un->un_next) {
- if (!strncasecmp(un->un_name, "Alert-Info", 10)) {
- if (!switch_strlen_zero(un->un_value)) {
- switch_channel_set_variable(channel, "alert_info", un->un_value);
- }
- } else if (!strncasecmp(un->un_name, "Remote-Party-ID", 15)) {
- process_rpid(un->un_value, tech_pvt);
- } else if (!strncasecmp(un->un_name, "Diversion", 9)) {
+ if (!strncasecmp(un->un_name, "Diversion", 9)) {
// Basic Diversion Support for Diversion Indication in SIP
// draft-levy-sip-diversion-08
if (!switch_strlen_zero(un->un_value)) {
1
0