From 5c3e8955de563a7a5b4c881351aa828d9a9dbbec Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Tue, 4 Sep 2012 11:03:26 -0400 Subject: [PATCH] Task #5695 - Need to have RTP IP input field in mod_media_gateway.conf.xml --- src/mod/endpoints/mod_media_gateway/media_gateway.c | 5 ++++- .../endpoints/mod_media_gateway/media_gateway_xml.c | 10 ++++++++++ .../endpoints/mod_media_gateway/mod_media_gateway.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway.c b/src/mod/endpoints/mod_media_gateway/media_gateway.c index 853674d636..a520703933 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway.c @@ -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; diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index 8f1a358d3e..8b278279fe 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -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() }; diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h index 4db3226218..b39a6ca51c 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h @@ -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 */