]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Task #5695 - Need to have RTP IP input field in mod_media_gateway.conf.xml
authorKapil Gupta <kgupta@sangoma.com>
Tue, 4 Sep 2012 15:03:26 +0000 (11:03 -0400)
committerKapil Gupta <kgupta@sangoma.com>
Tue, 4 Sep 2012 15:03:26 +0000 (11:03 -0400)
src/mod/endpoints/mod_media_gateway/media_gateway.c
src/mod/endpoints/mod_media_gateway/media_gateway_xml.c
src/mod/endpoints/mod_media_gateway/mod_media_gateway.h

index 853674d636445de456dcbdfaf47b59e12f4373e5..a52070393314d44149f8dc098e8550c55ecd63bb 100644 (file)
@@ -129,6 +129,8 @@ switch_status_t megaco_activate_termination(mg_termination_t *term)
         switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, kMEDIATYPE, mg_media_type2str(term->u.rtp.media_type));
         switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "fax_enable_t38", "true");
         switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "rtp_execute_on_image", "t38_gateway self nocng");
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s local_add[%s]\n",__FUNCTION__, term->u.rtp.local_addr); 
     } else if (term->type == MG_TERM_TDM) {
         switch_snprintf(dialstring, sizeof dialstring, "tdm/%s", term->name);
         
@@ -276,7 +278,8 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
     
     if (termtype == MG_TERM_RTP) {
         /* Fill in local address and reserve an rtp port */
-        term->u.rtp.local_addr = profile->my_ipaddr;
+        //term->u.rtp.local_addr = profile->my_ipaddr;
+        term->u.rtp.local_addr = profile->rtp_ipaddr;
         term->u.rtp.local_port = switch_rtp_request_port(term->u.rtp.local_addr);
         term->u.rtp.codec = megaco_codec_str(profile->default_codec);
         term->u.rtp.term_id = term_id;
index 8f1a358d3ead65eccd6a90fee9c93e61ebb7dce2..8b278279fe4710f042d63fdbb35411a0dd555811 100644 (file)
@@ -64,6 +64,14 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
                        profile->total_peers++;
                }
 
+               /* If RTP-IP is not defined then default to local-ip */
+               if((!profile->rtp_ipaddr) || 
+                               (profile->rtp_ipaddr && ('\0' == profile->rtp_ipaddr[0]))){
+                       profile->rtp_ipaddr = switch_mprintf("%s", profile->my_ipaddr);
+               }
+
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"rtp_ipaddr[%s], local ip[%s]\n", profile->rtp_ipaddr, profile->my_ipaddr);
+
                if(SWITCH_STATUS_FALSE == (status = modify_mg_profile_mid(profile, &profile->mid))){
                        goto done;
                }
@@ -169,6 +177,7 @@ else
                goto done;
        }
 
+
        /* go through the peer configuration and get the mg profile associated peers only */
        if (!(mg_peers = switch_xml_child(cfg, "mg_peers"))) {
                status = SWITCH_STATUS_FALSE;
@@ -345,6 +354,7 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) {
                //SWITCH_CONFIG_ITEM("tdm-pre-buffer-size", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &profile->tdm_pre_buffer_size, 0, &pre_buffer_len, "", "freetdm pre buffer size"),
                SWITCH_CONFIG_ITEM("codec-prefs", SWITCH_CONFIG_STRING, 0, &profile->codec_prefs, "", &switch_config_string_strdup, "", "codec preferences, coma-separated"),
                SWITCH_CONFIG_ITEM("license", SWITCH_CONFIG_STRING, 0, &profile->license, "/usr/local/nsg/conf/license.txt", &switch_config_string_strdup, "", "License file"),
+               SWITCH_CONFIG_ITEM("rtp-ip", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->rtp_ipaddr, "" , &switch_config_string_strdup, "", "rtp ip"),
                SWITCH_CONFIG_ITEM_END()
        };
        
index 4db322621836e5c80ebd003e0a1658324d52b5a7..b39a6ca51c781c0d61f1e59c041618606bc19f3f 100644 (file)
@@ -215,6 +215,7 @@ struct megaco_profile_s {
        char*                                   mid;         /* MG H.248 MID */
        char*                                   my_domain;   /* local domain name */
        char*                                   my_ipaddr;   /* local domain name */
+       char*                                   rtp_ipaddr;   /* local rtp ip */
        char*                                   port;                        /* port */
        char*                                   protocol_type;               /* MEGACO/MGCP */
        char*                                   license;             /* License file location/name */