diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c index dff9da3294..97b3d1c79d 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c @@ -886,6 +886,10 @@ switch_status_t handle_show_stats(switch_stream_handle_t *stream, megaco_profile return SWITCH_STATUS_FALSE; } + stream->write_function(stream, "Total Number of IN-Service Service change sent = %d \n", + mg_profile->mg_stats->total_num_of_term_in_service_change_sent); + stream->write_function(stream, "Total Number of Out-Of-Service Service change sent = %d \n", + mg_profile->mg_stats->total_num_of_term_oos_service_change_sent); stream->write_function(stream, "Total Number of Physical ADD received = %d \n", mg_profile->mg_stats->total_num_of_phy_add_recvd); stream->write_function(stream, "Total Number of RTP ADD received = %d \n", mg_profile->mg_stats->total_num_of_rtp_add_recvd); stream->write_function(stream, "Total Number of SUB received = %d \n", mg_profile->mg_stats->total_num_of_sub_recvd); diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c index 0cf98ed137..9ed09d8b7b 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c @@ -848,11 +848,6 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i ret = sng_mgco_send_cmd( mg_profile->idx, &rsp); - - if(is_rtp){ - /* releasing memory allocated for term->lcl.val */ - MG_STACK_MEM_FREE(out_termId->name.lcl.val, ((sizeof(U8)* strlen(term->name)))); - } } /*************************************************************************************************************************/ @@ -1936,6 +1931,7 @@ switch_status_t mg_send_ins_service_change(megaco_profile_t* mg_profile, const c "Sending In-Service Service Change for termination[%s] configured in mg profile[%s], suId[%d]\n", term_name, mg_profile->name, mg_profile->idx); + mg_profile->mg_stats->total_num_of_term_in_service_change_sent++; return mg_send_service_change(mg_profile->idx, term_name, MGT_SVCCHGMETH_RESTART, MG_SVC_REASON_900_RESTORED, wild); } @@ -1952,6 +1948,8 @@ switch_status_t mg_send_oos_service_change(megaco_profile_t* mg_profile, const c "Sending Out-Of-Service Service Change for termination[%s] configured in mg profile[%s], suId[%d]\n", term_name, mg_profile->name, mg_profile->idx); + mg_profile->mg_stats->total_num_of_term_oos_service_change_sent++; + return mg_send_service_change(mg_profile->idx, term_name, MGT_SVCCHGMETH_FORCED, MG_SVC_REASON_905_TERM_OOS, wild); } /*****************************************************************************************************************************/ @@ -2029,9 +2027,6 @@ switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_ sng_mgco_send_cmd(suId, &request); - /* releasing memory allocated for term->lcl.val */ - MG_STACK_MEM_FREE(termId->name.lcl.val, ((sizeof(U8)* strlen(term_name)))); - return SWITCH_STATUS_SUCCESS; err: @@ -2471,9 +2466,6 @@ switch_status_t mg_send_notify(megaco_profile_t* mg_profile, const char* term_n sng_mgco_send_cmd(mg_profile->idx, &request); - /* releasing memory allocated for term->lcl.val */ - MG_STACK_MEM_FREE(termId->name.lcl.val, ((sizeof(U8)* strlen(term_name)))); - return SWITCH_STATUS_SUCCESS; } /*****************************************************************************************************************************/ diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c b/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c index 9ff581f916..8594e41d97 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c @@ -111,6 +111,8 @@ S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, char* term_str, int term_len, C Size size; #endif S16 ret = ROK; + Ptr* ptr = NULL; + memset(&prnt_buf,0,sizeof(prnt_buf)); termId->type.pres = PRSNT_NODEF; @@ -121,18 +123,33 @@ S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, char* term_str, int term_len, C termId->type.val = MGT_TERMID_OTHER; - termId->name.dom.pres = NOTPRSNT; - termId->name.dom.len = 0x00; - termId->name.pres.pres = PRSNT_NODEF; - termId->name.lcl.pres = PRSNT_NODEF; - termId->name.lcl.len = cmStrlen((U8*)term_str); - size = ((sizeof(U8)* term_len)); - MG_STACK_MEM_ALLOC(&termId->name.lcl.val, size); - cmMemcpy((U8*)(termId->name.lcl.val),(CONSTANT U8*)term_str,termId->name.lcl.len); + /* domain */ + termId->name.dom.pres = NOTPRSNT; + termId->name.dom.len = 0x00; - MG_MEM_COPY(&prnt_buf, termId->name.lcl.val, sizeof(U8) * termId->name.lcl.len); + ptr = (Ptr*)&termId->name.dom.val; + if( cmGetMem(memCp, 128, ptr) != ROK ){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"cmGetMem failed \n"); + RETVALUE(RFAILED); + } + + /* term name */ + termId->name.lcl.pres = PRSNT_NODEF; + termId->name.lcl.len = cmStrlen((CONSTANT U8*)term_str); + + ptr = (Ptr*)&termId->name.lcl.val; + if( cmGetMem(memCp, termId->name.lcl.len, ptr) != ROK ){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"cmGetMem failed \n"); + RETVALUE(RFAILED); + } + + cmMemset((U8 *)(termId->name.lcl.val), (U8)0, (PTR)(termId->name.lcl.len)); + + cmMemcpy((U8*)(termId->name.lcl.val), (CONSTANT U8*)term_str,termId->name.lcl.len); + + cmMemcpy((U8*)(prnt_buf), (CONSTANT U8*)termId->name.lcl.val,termId->name.lcl.len); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mg_fill_mgco_termid: Megaco termination name[%s], len[%d], input_term_str[%s], input_term_len[%d]\n", 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 a8438cc109..fba52c881d 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h @@ -63,6 +63,8 @@ typedef struct mg_peer_profile_s{ typedef struct mg_stats_s{ uint32_t total_num_of_phy_add_recvd; + uint32_t total_num_of_term_in_service_change_sent; + uint32_t total_num_of_term_oos_service_change_sent; uint32_t total_num_of_rtp_add_recvd; uint32_t total_num_of_sub_recvd; uint32_t total_num_of_call_recvd;