[Freeswitch-svn] [commit] r13559 - freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia
FreeSWITCH SVN
brian at freeswitch.org
Tue Jun 2 16:42:44 PDT 2009
Author: brian
Date: Tue Jun 2 18:42:43 2009
New Revision: 13559
Log:
reboot packets now work correctly
Modified:
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Tue Jun 2 18:42:43 2009
@@ -843,7 +843,7 @@
const char *sofia_glue_strip_proto(const char *uri);
switch_status_t reconfig_sofia(sofia_profile_t *profile);
void sofia_glue_del_gateway(sofia_gateway_t *gp);
-void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent);
+void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip);
void sofia_glue_restart_all_profiles(void);
void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly);
const char * sofia_state_string(int state);
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Tue Jun 2 18:42:43 2009
@@ -1423,17 +1423,28 @@
if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(network_ip, profile->local_network)) {
char *ptr = NULL;
+ const char *transport_str = NULL;
if ((ptr = sofia_glue_find_parameter(o_contact, "transport="))) {
sofia_transport_t transport = sofia_glue_str2transport(ptr);
- user_via = switch_mprintf("SIP/2.0/%s %s;rport", sofia_glue_transport2str(transport), profile->extsipip);
+ transport_str = sofia_glue_transport2str(transport);
+ user_via = switch_mprintf("SIP/2.0/%s %s;rport", transport_str, profile->extsipip);
} else {
user_via = switch_mprintf("SIP/2.0/UDP %s;rport", profile->extsipip);
}
-
- contact_str = profile->public_url;
+
+ if (switch_stristr("udp", transport_str)) {
+ contact_str = profile->public_url;
+ } else if (switch_stristr("tcp", transport_str)) {
+ contact_str = profile->tcp_public_contact;
+ } else if (switch_stristr("tls", transport_str)) {
+ contact_str = profile->tls_public_contact;
+ } else {
+ contact_str = profile->public_url;
+ }
} else {
contact_str = profile->url;
}
+
if ((route = strstr(contact, ";fs_path=")) && (route = strdup(route + 9))) {
for (p = route; p && *p ; p++) {
Modified: freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (original)
+++ freeswitch/branches/brian/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c Tue Jun 2 18:42:43 2009
@@ -402,11 +402,13 @@
return 0;
}
-void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent)
+void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip)
{
const char *event = "check-sync";
nua_handle_t *nh;
char *contact_url = NULL;
+ char *contact_str = NULL;
+ char *user_via = NULL;
char *id = NULL;
if (switch_stristr("snom", user_agent)) {
@@ -417,22 +419,47 @@
if ((contact_url = sofia_glue_get_url_from_contact((char *)contact, 1))) {
char *p;
- id = switch_mprintf("sip:%s@%s", user, host);
+ id = switch_mprintf("sip:%s@%s", user, network_ip);
if ((p = strstr(contact_url, ";fs_"))) {
*p = '\0';
}
-
+
+ if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && !switch_check_network_list_ip(network_ip, profile->local_network)) {
+ char *ptr = NULL;
+ const char *transport_str = NULL;
+ if ((ptr = sofia_glue_find_parameter(contact_url, "transport="))) {
+ sofia_transport_t transport = sofia_glue_str2transport(ptr);
+ transport_str = sofia_glue_transport2str(transport);
+ user_via = switch_mprintf("SIP/2.0/%s %s;rport", transport_str, profile->extsipip);
+ } else {
+ user_via = switch_mprintf("SIP/2.0/UDP %s;rport", profile->extsipip);
+ }
+
+ if (switch_stristr("udp", transport_str)) {
+ contact_str = profile->public_url;
+ } else if (switch_stristr("tcp", transport_str)) {
+ contact_str = profile->tcp_public_contact;
+ } else if (switch_stristr("tls", transport_str)) {
+ contact_str = profile->tls_public_contact;
+ } else {
+ contact_str = profile->public_url;
+ }
+ } else {
+ contact_str = profile->url;
+ }
+
nh = nua_handle(profile->nua, NULL,
NUTAG_URL(contact_url),
SIPTAG_FROM_STR(id),
SIPTAG_TO_STR(id),
- SIPTAG_CONTACT_STR(profile->url),
+ SIPTAG_CONTACT_STR(contact_str),
TAG_END());
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
nua_notify(nh,
NUTAG_NEWSUB(1),
+ TAG_IF(!switch_strlen_zero(user_via), SIPTAG_VIA_STR(user_via)),
SIPTAG_EVENT_STR(event),
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
SIPTAG_PAYLOAD_STR(""),
@@ -462,8 +489,8 @@
switch_event_t *s_event;
sofia_profile_t *profile = (sofia_profile_t *) pArg;
- if (argc > 11 && atoi(argv[11]) == 1) {
- sofia_reg_send_reboot(profile, argv[1], argv[2], argv[3], argv[7]);
+ if (argc > 12 && atoi(argv[12]) == 1) {
+ sofia_reg_send_reboot(profile, argv[1], argv[2], argv[3], argv[7], argv[11]);
}
if (argc >= 3) {
@@ -508,7 +535,8 @@
switch_snprintf(sqlextra, sizeof(sqlextra), " or (sip_user='%s' and sip_host='%s')", user, host);
}
- switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name"
+ switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires"
+ ",user_agent,server_user,server_host,profile_name,network_ip"
",%d from sip_registrations where call_id='%s' %s",
reboot, call_id, sqlextra);
@@ -548,7 +576,8 @@
switch_mutex_lock(profile->ireg_mutex);
if (now) {
- switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name"
+ switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires"
+ ",user_agent,server_user,server_host,profile_name,network_ip"
",%d from sip_registrations where expires > 0 and expires <= %ld", reboot, (long) now);
} else {
switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name"
More information about the Freeswitch-svn
mailing list