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 5fa9d45663..a1fd12b3df 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 @@ -1526,7 +1526,7 @@ switch_status_t mg_build_mgco_err_request(MgMgcoInd **errcmd,U32 trans_id, MgM /*****************************************************************************************************************************/ -switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq) +switch_status_t handle_mg_audit_cmd( megaco_profile_t* mg_profile, MgMgcoCommand *auditReq) { MgMgcoContextId *ctxtId; MgMgcoTermIdLst *term_list; @@ -1562,7 +1562,7 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq) if((NOTPRSNT == audit_desc->pres.pres) || ( NOTPRSNT == audit_desc->num.pres)){ switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Audit Descriptor not present.. Could be HeartBeat message\n"); - return mg_send_heartbeat_audit_rsp(suId, auditReq); + return mg_send_heartbeat_audit_rsp(mg_profile->idx, auditReq); } /* dump AUDIT message information */ @@ -1682,7 +1682,7 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq) adtRep->u.other.audit.parms[numOfParms - 1]->type.pres = PRSNT_NODEF; adtRep->u.other.audit.parms[numOfParms - 1]->type.val = MGT_MEDIADESC; - media = get_default_media_desc(); + media = get_default_media_desc(mg_profile, termId); if(!media){ return SWITCH_STATUS_FALSE; } @@ -1780,7 +1780,7 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq) /* send command reply */ - sng_mgco_send_cmd(suId, &reply); + sng_mgco_send_cmd(mg_profile->idx, &reply); /* send indication to stack , so he can send response back to peer */ memcpy(&ctxt.transId,&auditReq->transId,sizeof(MgMgcoTransId)); @@ -1788,14 +1788,14 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq) memcpy(&ctxt.peerId, &auditReq->peerId,sizeof(TknU32)); ctxt.cmdStatus.pres = PRSNT_NODEF; ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN; - sng_mgco_send_axn_req(suId, &ctxt); + sng_mgco_send_axn_req(mg_profile->idx, &ctxt); /***********************************************************************************************************************************/ return SWITCH_STATUS_SUCCESS; error: if (SWITCH_STATUS_SUCCESS == mg_build_mgco_err_request(&mgErr, auditReq->transId.val, ctxtId, err_code, &errTxt)) { - sng_mgco_send_err(suId, mgErr); + sng_mgco_send_err(mg_profile->idx, mgErr); } /* deallocate the msg */ diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h index 994b1a573a..4d79a96078 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -181,14 +181,14 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *cmd); switch_status_t mg_stack_free_mem(void* msg); switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize ); -MgMgcoMediaDesc* get_default_media_desc(void); +MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTermId* termId); switch_status_t handle_media_audit( SuId suId, MgMgcoCommand *auditReq); switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req); S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, char* term_str, int term_len, CmMemListCp *memCp); void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId); switch_status_t mg_build_mgco_err_request(MgMgcoInd **errcmd,U32 trans_id, MgMgcoContextId *ctxt_id, U32 err, MgStr *errTxt); switch_status_t mg_send_audit_rsp(SuId suId, MgMgcoCommand *req); -switch_status_t handle_mg_audit_cmd(SuId suId, MgMgcoCommand *auditReq); +switch_status_t handle_mg_audit_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *auditReq); switch_status_t mg_stack_termination_is_in_service(megaco_profile_t* mg_profile, char* term_str, int len); void mg_create_tdm_term(megaco_profile_t *profile, const char *tech, const char *channel_prefix, const char *prefix, int j); void mg_util_set_cmd_name_string (MgStr *errTxt, MgMgcoCommand *cmd); 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 c565da7e6b..b4b3663fa4 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_utils.c @@ -1214,7 +1214,7 @@ void mg_util_set_term_string ( MgStr *errTxt, MgMgcoTermId *termId) "info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val); } /*****************************************************************************************************************************/ -MgMgcoMediaDesc* get_default_media_desc() +MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTermId* termId) { MgMgcoMediaDesc *media = NULL; MgMgcoMediaPar *mediaPar = NULL; @@ -1268,8 +1268,20 @@ MgMgcoMediaDesc* get_default_media_desc() trmStPar->type.pres = PRSNT_NODEF; trmStPar->type.val = MGT_TERMST_SVCST; trmStPar->u.svcState.pres = PRSNT_NODEF; - /*TODO - ADD CHECK if term is in svc or not */ - trmStPar->u.svcState.val = MGT_SVCST_INSVC; + + if ((NOTPRSNT != termId->type.pres) && + (MGT_TERMID_ROOT == termId->type.val)){ + trmStPar->u.svcState.val = MGT_SVCST_INSVC; + }else{ + /*not root termination */ + mg_termination_t* term = NULL; + term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val); + if(term && switch_test_flag(term, MG_OUT_OF_SERVICE)){ + trmStPar->u.svcState.val = MGT_SVCST_OUTOFSVC; + }else{ + trmStPar->u.svcState.val = MGT_SVCST_INSVC; + } + } mediaPar->u.tstate.trmStPar[0] = trmStPar; media->parms[0] = mediaPar; diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 95f9d3b2cb..d650ef7637 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -546,8 +546,10 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd) } /*If term type is other then check if that term is configured with us..for term type CHOOSE/ALL , no need to check */ + /* check is only if command is not AUDIT */ if ((CH_CMD_TYPE_IND == cmd->cmdType.val) && - (MGT_TERMID_OTHER == termId->type.val)){ + (MGT_TERMID_OTHER == termId->type.val) && + (MGT_AUDITVAL != cmd->u.mgCmdInd[0]->cmd.type.val)){ if(SWITCH_STATUS_FALSE == mg_stack_termination_is_in_service(mg_profile, (char*)termId->name.lcl.val, termId->name.lcl.len)){ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Termination[%s] not in service \n", (char*)termId->name.lcl.val); mg_util_set_term_string(&errTxt, termId); @@ -643,7 +645,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd) case MGT_AUDITVAL: { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received Audit-Value Method \n"); - handle_mg_audit_cmd(suId, cmd); + handle_mg_audit_cmd(mg_profile, cmd); break; } break;