adding code to return Audit of termination state based on termination's state(in-service/oos)

This commit is contained in:
root 2012-07-30 13:44:40 -04:00
parent 0c87442dd7
commit 4fd24d6172
4 changed files with 27 additions and 13 deletions

View File

@ -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; MgMgcoContextId *ctxtId;
MgMgcoTermIdLst *term_list; 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)){ 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"); 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 */ /* 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.pres = PRSNT_NODEF;
adtRep->u.other.audit.parms[numOfParms - 1]->type.val = MGT_MEDIADESC; 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){ if(!media){
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -1780,7 +1780,7 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq)
/* send command reply */ /* 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 */ /* send indication to stack , so he can send response back to peer */
memcpy(&ctxt.transId,&auditReq->transId,sizeof(MgMgcoTransId)); 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)); memcpy(&ctxt.peerId, &auditReq->peerId,sizeof(TknU32));
ctxt.cmdStatus.pres = PRSNT_NODEF; ctxt.cmdStatus.pres = PRSNT_NODEF;
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN; 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; return SWITCH_STATUS_SUCCESS;
error: error:
if (SWITCH_STATUS_SUCCESS == mg_build_mgco_err_request(&mgErr, auditReq->transId.val, ctxtId, err_code, &errTxt)) { 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 */ /* deallocate the msg */

View File

@ -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 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_free_mem(void* msg);
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize ); 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 handle_media_audit( SuId suId, MgMgcoCommand *auditReq);
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req); 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); 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); 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_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 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); 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_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); void mg_util_set_cmd_name_string (MgStr *errTxt, MgMgcoCommand *cmd);

View File

@ -1214,7 +1214,7 @@ void mg_util_set_term_string ( MgStr *errTxt, MgMgcoTermId *termId)
"info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val); "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; MgMgcoMediaDesc *media = NULL;
MgMgcoMediaPar *mediaPar = NULL; MgMgcoMediaPar *mediaPar = NULL;
@ -1268,8 +1268,20 @@ MgMgcoMediaDesc* get_default_media_desc()
trmStPar->type.pres = PRSNT_NODEF; trmStPar->type.pres = PRSNT_NODEF;
trmStPar->type.val = MGT_TERMST_SVCST; trmStPar->type.val = MGT_TERMST_SVCST;
trmStPar->u.svcState.pres = PRSNT_NODEF; trmStPar->u.svcState.pres = PRSNT_NODEF;
/*TODO - ADD CHECK if term is in svc or not */
if ((NOTPRSNT != termId->type.pres) &&
(MGT_TERMID_ROOT == termId->type.val)){
trmStPar->u.svcState.val = MGT_SVCST_INSVC; 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; mediaPar->u.tstate.trmStPar[0] = trmStPar;
media->parms[0] = mediaPar; media->parms[0] = mediaPar;

View File

@ -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 */ /*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) && 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)){ 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); 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); 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: case MGT_AUDITVAL:
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received Audit-Value Method \n"); 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;
} }
break; break;