提交 b74f70f3 authored 作者: Brian West's avatar Brian West

preserve the transport on SLA interactions, still needs work for TLS but should…

 preserve the transport on SLA interactions, still needs work for TLS but should work for UDP and TCP

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13303 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 6aa139e5
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* Ken Rice, Asteria Solutions Group, Inc <ken@asteriasgi.com> * Ken Rice, Asteria Solutions Group, Inc <ken@asteriasgi.com>
* Paul D. Tinsley <pdt at jackhammer.org> * Paul D. Tinsley <pdt at jackhammer.org>
* Bret McDanel <trixter AT 0xdecafbad.com> * Bret McDanel <trixter AT 0xdecafbad.com>
* * Brian West <brian@freeswitch.org>
* *
* sofia_sla.c -- SOFIA SIP Endpoint (support for shared line appearance) * sofia_sla.c -- SOFIA SIP Endpoint (support for shared line appearance)
* This file (and calls into it) developed by Matthew T Kaufman <matthew@matthew.at> * This file (and calls into it) developed by Matthew T Kaufman <matthew@matthew.at>
...@@ -35,21 +35,17 @@ ...@@ -35,21 +35,17 @@
*/ */
#include "mod_sofia.h" #include "mod_sofia.h"
static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **columnNames); static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **columnNames);
struct sla_helper { struct sla_helper {
char call_id[1024]; char call_id[1024];
}; };
static int get_call_id_callback(void *pArg, int argc, char **argv, char **columnNames) static int get_call_id_callback(void *pArg, int argc, char **argv, char **columnNames)
{ {
struct sla_helper *sh = (struct sla_helper *) pArg; struct sla_helper *sh = (struct sla_helper *) pArg;
switch_set_string(sh->call_id, argv[0]); switch_set_string(sh->call_id, argv[0]);
return 0; return 0;
} }
...@@ -79,7 +75,7 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const ...@@ -79,7 +75,7 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const
char *sql; char *sql;
struct sla_helper sh = { { 0 } }; struct sla_helper sh = { { 0 } };
char *contact_str = strip_uri(full_contact); char *contact_str = strip_uri(full_contact);
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'", sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
mod_sofia_globals.hostname, profile->name, contact_str); mod_sofia_globals.hostname, profile->name, contact_str);
...@@ -103,11 +99,11 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const ...@@ -103,11 +99,11 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const
nua_handle_bind(nh, &mod_sofia_globals.keep_private); nua_handle_bind(nh, &mod_sofia_globals.keep_private);
switch_snprintf(exp_str, sizeof(exp_str), "%ld", exptime + 30); switch_snprintf(exp_str, sizeof(exp_str), "%ld", exptime + 30);
switch_snprintf(my_contact, sizeof(my_contact), "%s;expires=%s", profile->sla_contact, exp_str); switch_snprintf(my_contact, sizeof(my_contact), "<%s;transport=%s>;expires=%s", profile->sla_contact, sofia_glue_transport2str(transport), exp_str);
nua_subscribe(nh, nua_subscribe(nh,
SIPTAG_TO(sip->sip_to), SIPTAG_TO(sip->sip_to),
SIPTAG_FROM(sip->sip_to), // ? SIPTAG_FROM(sip->sip_to),
SIPTAG_CONTACT_STR(my_contact), SIPTAG_CONTACT_STR(my_contact),
SIPTAG_EXPIRES_STR(exp_str), SIPTAG_EXPIRES_STR(exp_str),
SIPTAG_EVENT_STR("dialog;sla"), /* some phones want ;include-session-description too? */ SIPTAG_EVENT_STR("dialog;sla"), /* some phones want ;include-session-description too? */
...@@ -128,6 +124,8 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia ...@@ -128,6 +124,8 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
char *subscriber = NULL; char *subscriber = NULL;
char *sql = NULL; char *sql = NULL;
char *route_uri = NULL; char *route_uri = NULL;
char *sla_contact = NULL;
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
/* /*
* XXX MTK FIXME - we don't look at the tag to see if NUTAG_SUBSTATE(nua_substate_terminated) or * XXX MTK FIXME - we don't look at the tag to see if NUTAG_SUBSTATE(nua_substate_terminated) or
...@@ -143,7 +141,8 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia ...@@ -143,7 +141,8 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
* so we do what openser's pua_bla does and... * so we do what openser's pua_bla does and...
*/ */
aor = switch_mprintf("sip:%s@%s",sip->sip_contact->m_url->url_user, sip->sip_from->a_url->url_host); aor = switch_mprintf("sip:%s@%s;transport=%s", sip->sip_contact->m_url->url_user,
sip->sip_from->a_url->url_host, sofia_glue_transport2str(transport));
/* /*
* ok, and now that we HAVE the AOR, we REALLY should go check in the XML config and see if this particular * ok, and now that we HAVE the AOR, we REALLY should go check in the XML config and see if this particular
...@@ -153,8 +152,8 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia ...@@ -153,8 +152,8 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
/* then the subscriber is the user at their network location... this is arguably the wrong way, but works so far... */ /* then the subscriber is the user at their network location... this is arguably the wrong way, but works so far... */
subscriber = switch_mprintf("sip:%s@%s",sip->sip_from->a_url->url_user, sip->sip_contact->m_url->url_host); subscriber = switch_mprintf("sip:%s@%s;transport=%s", sip->sip_from->a_url->url_user,
sip->sip_contact->m_url->url_host, sofia_glue_transport2str(transport));
if ((sql = if ((sql =
switch_mprintf("delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'", switch_mprintf("delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'",
...@@ -170,7 +169,6 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia ...@@ -170,7 +169,6 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
} }
if (strstr(contact_str, ";fs_nat")) { if (strstr(contact_str, ";fs_nat")) {
char *p; char *p;
route_uri = sofia_glue_get_url_from_contact((char *)contact_str, 1); route_uri = sofia_glue_get_url_from_contact((char *)contact_str, 1);
...@@ -179,7 +177,6 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia ...@@ -179,7 +177,6 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
} }
} }
if (route_uri) { if (route_uri) {
char *p; char *p;
...@@ -191,7 +188,9 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia ...@@ -191,7 +188,9 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
} }
} }
nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(profile->sla_contact), NUTAG_WITH_THIS(nua), sla_contact = switch_mprintf("<%s;transport=%s>", profile->sla_contact, sofia_glue_transport2str(transport));
nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(sla_contact), NUTAG_WITH_THIS(nua),
TAG_IF(route_uri, NUTAG_PROXY(route_uri)), TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */ SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */
SIPTAG_EXPIRES_STR("300"), /* likewise, totally fake - FIXME XXX MTK */ SIPTAG_EXPIRES_STR("300"), /* likewise, totally fake - FIXME XXX MTK */
...@@ -201,6 +200,7 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia ...@@ -201,6 +200,7 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
switch_safe_free(aor); switch_safe_free(aor);
switch_safe_free(subscriber); switch_safe_free(subscriber);
switch_safe_free(route_uri); switch_safe_free(route_uri);
switch_safe_free(sla_contact);
switch_safe_free(sql); switch_safe_free(sql);
} }
...@@ -234,7 +234,6 @@ void sofia_sla_handle_sip_r_subscribe(int status, ...@@ -234,7 +234,6 @@ void sofia_sla_handle_sip_r_subscribe(int status,
free(contact_str); free(contact_str);
} }
} }
void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]) void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[])
...@@ -243,6 +242,7 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han ...@@ -243,6 +242,7 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han
struct sla_notify_helper helper; struct sla_notify_helper helper;
char *aor = NULL; char *aor = NULL;
char *contact = NULL; char *contact = NULL;
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
/* /*
* things we know we don't do: * things we know we don't do:
...@@ -276,7 +276,8 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han ...@@ -276,7 +276,8 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han
} }
/* calculate the AOR we're trying to tell people about. should probably double-check before derferencing XXX MTK */ /* calculate the AOR we're trying to tell people about. should probably double-check before derferencing XXX MTK */
aor = switch_mprintf("sip:%s@%s",sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); aor = switch_mprintf("sip:%s@%s;transport=%s", sip->sip_to->a_url->url_user,
sip->sip_to->a_url->url_host, sofia_glue_transport2str(transport));
/* this isn't sufficient because on things like the polycom, the subscriber is the 'main' ext number, but the /* this isn't sufficient because on things like the polycom, the subscriber is the 'main' ext number, but the
* 'main' ext number isn't in ANY of the headers they send us in the notify. of course. * 'main' ext number isn't in ANY of the headers they send us in the notify. of course.
...@@ -285,7 +286,8 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han ...@@ -285,7 +286,8 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han
* so we don't reflect it back at anyone who is the "boss" config, but we do reflect it back at the "secretary" * so we don't reflect it back at anyone who is the "boss" config, but we do reflect it back at the "secretary"
* config. if that breaks the phone, just set them all up as the "boss" config where ext#==third-party# * config. if that breaks the phone, just set them all up as the "boss" config where ext#==third-party#
*/ */
contact = switch_mprintf("sip:%s@%s",sip->sip_contact->m_url->url_user, sip->sip_contact->m_url->url_host); contact = switch_mprintf("sip:%s@%s;transport=%s",sip->sip_contact->m_url->url_user,
sip->sip_contact->m_url->url_host, sofia_glue_transport2str(transport));
if (sip->sip_payload && sip->sip_payload->pl_data) { if (sip->sip_payload && sip->sip_payload->pl_data) {
sql = switch_mprintf("select subscriber,call_id,aor,profile_name,hostname,contact_str from sip_shared_appearance_subscriptions where " sql = switch_mprintf("select subscriber,call_id,aor,profile_name,hostname,contact_str from sip_shared_appearance_subscriptions where "
...@@ -351,4 +353,3 @@ static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **colu ...@@ -351,4 +353,3 @@ static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **colu
} }
return 0; return 0;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论