]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add register-proxy option to gateways so you can send outbound reg to your local...
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 19 Sep 2007 15:28:16 +0000 (15:28 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 19 Sep 2007 15:28:16 +0000 (15:28 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5713 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/directory.xml
conf/sofia.conf.xml
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_reg.c

index 0b93e075d42fc365a782a2e282dfb19bf3257c25..101286fbc87ce29dc4003a569bb79e3937d447f4 100644 (file)
@@ -19,6 +19,8 @@
       <!--<param name="extension" value="cluecon"/>-->
       <!--/// proxy host: *optional* same as realm, if blank ///-->
       <!--<param name="proxy" value="asterlink.com"/>-->
+      <!--/// send register to this proxy: *optional* same as proxy, if blank ///-->
+      <!--<param name="register-proxy" value="mysbc.com"/>-->
       <!--/// expire in seconds: *optional* 3600, if blank ///-->
       <!--<param name="expire-seconds" value="60"/>-->
       <!--/// do not register ///-->
index a4fafabb063dc5e53ffd85736e07c43325afdbb2..2b56d22277eb909640ee67163d29611bd0226e7d 100644 (file)
@@ -22,6 +22,8 @@
          <!--<param name="extension" value="cluecon"/>-->
          <!--/// proxy host: *optional* same as realm, if blank ///-->
          <!--<param name="proxy" value="asterlink.com"/>-->
+         <!--/// send register to this proxy: *optional* same as proxy, if blank ///-->
+         <!--<param name="register-proxy" value="mysbc.com"/>-->
          <!--/// expire in seconds: *optional* 3600, if blank ///-->
          <!--<param name="expire-seconds" value="60"/>-->
          <!--/// do not register ///-->
index 8b2178e1cf75ef4fed80ead4112279babcb66536..b52dede84e652d5f6a61fe858df765ef57d84b0f 100644 (file)
@@ -196,6 +196,7 @@ struct sofia_gateway {
        char *register_proxy;
        char *register_context;
        char *expires_str;
+       char *register_url;
        uint32_t freq;
        time_t expires;
        time_t retry;
index dd7f158167ecc686e61dcb79b720c3627eab7278..406b176dfe2cec99bfdfb0428fe48eab68a5cb4d 100644 (file)
@@ -501,7 +501,8 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
                                *expire_seconds = "3600",
                                *retry_seconds = "30",
                                *from_domain = "",
-                               *to_domain = "";
+                               *to_domain = "",
+                               *register_proxy = NULL;
                        
                        gateway->pool = profile->pool;
                        gateway->profile = profile;
@@ -539,13 +540,11 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
                                        from_domain = val;
                                } else if (!strcmp(var, "to-domain")) {
                                        to_domain = val;
+                               } else if (!strcmp(var, "register-proxy")) {
+                                       register_proxy = val;
                                }
                        }
-
-                       if (switch_strlen_zero(to_domain)) {
-                               to_domain = proxy;
-                       }
-
+                       
                        if (switch_strlen_zero(realm)) {
                                realm = name;
                        }
@@ -563,7 +562,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
                        if (switch_strlen_zero(extension)) {
                                extension = username;
                        }
-
+                       
                        if (switch_strlen_zero(proxy)) {
                                proxy = realm;
                        }
@@ -576,6 +575,14 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
                                from_domain = realm;
                        }
 
+                       if (switch_strlen_zero(register_proxy)) {
+                               register_proxy = proxy;
+                       }
+
+                       if (switch_strlen_zero(to_domain)) {
+                               to_domain = proxy;
+                       }
+
                        gateway->retry_seconds = atoi(retry_seconds);
                        if (gateway->retry_seconds < 10) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "INVALID: retry_seconds correcting the value to 30\n");
@@ -589,6 +596,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag)
                        if (switch_true(caller_id_in_from)) {
                                switch_set_flag(gateway, REG_FLAG_CALLERID);
                        }
+                       gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s", register_proxy);
                        gateway->register_from = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, from_domain);
                        gateway->register_contact = switch_core_sprintf(gateway->pool, "sip:%s@%s:%d", extension,
                                                                                                                        profile->extsipip ? profile->extsipip : profile->sipip, profile->sip_port);
index 7d05816dafb28d763cd042c0ee6d812618fdbf9a..22e715ecbe182d01d8b8d7e17255f4765eac4a86 100644 (file)
@@ -73,6 +73,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
 
                case REG_STATE_UNREGISTER:
                        nua_unregister(gateway_ptr->nh,
+                                                  NUTAG_URL(gateway_ptr->register_url),
                                                   SIPTAG_FROM_STR(gateway_ptr->register_from),
                                                   SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
                                                   SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
@@ -97,6 +98,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
 
                                if (now) {
                                        nua_register(gateway_ptr->nh,
+                                                                NUTAG_URL(gateway_ptr->register_url),
                                                                 SIPTAG_FROM_STR(gateway_ptr->register_from),
                                                                 SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
                                                                 SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
@@ -105,6 +107,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
                                        gateway_ptr->retry = now + gateway_ptr->retry_seconds;
                                } else {
                                        nua_unregister(gateway_ptr->nh,
+                                                                  NUTAG_URL(gateway_ptr->register_url),
                                                                   SIPTAG_FROM_STR(gateway_ptr->register_from),
                                                                   SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
                                                                   SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
@@ -700,7 +703,7 @@ void sofia_reg_handle_sip_r_challenge(int status,
                        goto cancel;
                }
        }
-       
+
        snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->register_username, gateway->register_password);
 
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Authenticating '%s' with '%s'.\n", profile->username, authentication);