adding AUDIT for root Packages response code,
adding media_gateway_cmd_handler.c for all commands related logic/APIs. adding media_gateway_packages.c to have list of all supported packages. adding media_gateway_utils.c for all media gateway utility APIs
This commit is contained in:
parent
cd61d0b59e
commit
c6b5bc2bda
|
@ -7,6 +7,6 @@ ifeq ($(ARCH),x86_64)
|
|||
endif
|
||||
|
||||
BASE=../../../..
|
||||
LOCAL_OBJS=media_gateway.o media_gateway_stack.o media_gateway_xml.o media_gateway_cli.o media_gateway_stack_alarms.o
|
||||
LOCAL_OBJS=media_gateway.o media_gateway_stack.o media_gateway_xml.o media_gateway_cli.o media_gateway_stack_alarms.o media_gateway_cmd_handler.o media_gateway_utils.o media_gateway_packages.o
|
||||
LOCAL_LDFLAGS=-lsng_mg
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
|
|
@ -0,0 +1,642 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Sangoma Technologies
|
||||
* Mathieu Rene <mrene@avgs.ca>
|
||||
* All rights reserved.
|
||||
*
|
||||
* <Insert license here>
|
||||
*/
|
||||
|
||||
#include "mod_media_gateway.h"
|
||||
#include "media_gateway_stack.h"
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
/*
|
||||
*
|
||||
* Fun: handle_mg_add_cmd
|
||||
*
|
||||
* Desc: this api will handle the ADD request received from MG stack
|
||||
*
|
||||
*
|
||||
*/
|
||||
switch_status_t handle_mg_add_cmd(MgMgcoAmmReq *addReq)
|
||||
{
|
||||
int descId;
|
||||
for (descId = 0; descId < addReq->dl.num.val; descId++) {
|
||||
switch (addReq->dl.descs[descId]->type.val) {
|
||||
case MGT_MEDIADESC:
|
||||
{
|
||||
int mediaId;
|
||||
for (mediaId = 0; mediaId < addReq->dl.descs[descId]->u.media.num.val; mediaId++) {
|
||||
MgMgcoMediaPar *mediaPar = addReq->dl.descs[descId]->u.media.parms[mediaId];
|
||||
switch (mediaPar->type.val) {
|
||||
case MGT_MEDIAPAR_LOCAL:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_LOCAL");
|
||||
break;
|
||||
}
|
||||
case MGT_MEDIAPAR_REMOTE:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_REMOTE");
|
||||
break;
|
||||
}
|
||||
|
||||
case MGT_MEDIAPAR_LOCCTL:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_LOCCTL");
|
||||
break;
|
||||
}
|
||||
case MGT_MEDIAPAR_TERMST:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_TERMST");
|
||||
break;
|
||||
}
|
||||
case MGT_MEDIAPAR_STRPAR:
|
||||
{
|
||||
MgMgcoStreamDesc *mgStream = &mediaPar->u.stream;
|
||||
|
||||
if (mgStream->sl.remote.pres.pres) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got remote stream media description:\n");
|
||||
mgco_print_sdp(&mgStream->sl.remote.sdp);
|
||||
}
|
||||
|
||||
if (mgStream->sl.local.pres.pres) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got local stream media description:\n");
|
||||
mgco_print_sdp(&mgStream->sl.local.sdp);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case MGT_MODEMDESC:
|
||||
case MGT_MUXDESC:
|
||||
case MGT_REQEVTDESC:
|
||||
case MGT_EVBUFDESC:
|
||||
case MGT_SIGNALSDESC:
|
||||
case MGT_DIGMAPDESC:
|
||||
case MGT_AUDITDESC:
|
||||
case MGT_STATSDESC:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
/*
|
||||
*
|
||||
* Fun: mg_send_add_rsp
|
||||
*
|
||||
* Desc: this api will send the ADD response based on ADD request received from MG stack
|
||||
*
|
||||
* TODO - Dummy response , needs to have proper ADD response code
|
||||
*/
|
||||
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req)
|
||||
{
|
||||
MgMgcoCommand cmd;
|
||||
int ret = 0x00;
|
||||
MgMgcoTermId *termId;
|
||||
|
||||
memset(&cmd,0, sizeof(cmd));
|
||||
|
||||
/*copy transaction-id*/
|
||||
memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
|
||||
|
||||
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
|
||||
memcpy(&cmd.contextId, &req->contextId,sizeof(MgMgcoContextId));
|
||||
|
||||
/*copy peer identifier */
|
||||
memcpy(&cmd.peerId, &req->peerId,sizeof(TknU32));
|
||||
|
||||
/*fill response structue */
|
||||
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&cmd.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
||||
return ret;
|
||||
}
|
||||
|
||||
cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.val = MGT_ADD;
|
||||
cmd.u.mgCmdRsp[0]->u.add.pres.pres = PRSNT_NODEF;
|
||||
|
||||
|
||||
cmd.u.mgCmdRsp[0]->u.add.termIdLst.num.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->u.add.termIdLst.num.val = 1;
|
||||
|
||||
mgUtlAllocMgMgcoTermIdLst(&cmd.u.mgCmdRsp[0]->u.add.termIdLst, &req->u.mgCmdReq[0]->cmd.u.add.termIdLst);
|
||||
|
||||
#ifdef GCP_VER_2_1
|
||||
termId = cmd.u.mgCmdRsp[0]->u.add.termIdLst.terms[0];
|
||||
#else
|
||||
termId = &(cmd.u.mgCmdRsp[0]->u.add.termId);
|
||||
#endif
|
||||
mg_fill_mgco_termid(termId, (CONSTANT U8*)"term1",&req->u.mgCmdRsp[0]->memCp);
|
||||
|
||||
/* We will always send one command at a time..*/
|
||||
cmd.cmdStatus.pres = PRSNT_NODEF;
|
||||
cmd.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
||||
|
||||
cmd.cmdType.pres = PRSNT_NODEF;
|
||||
cmd.cmdType.val = CH_CMD_TYPE_RSP;
|
||||
|
||||
ret = sng_mgco_send_cmd(suId, &cmd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
/*
|
||||
*
|
||||
* Fun: mg_send_end_of_axn
|
||||
*
|
||||
* Desc: this api will send the END_OF_AXN event to MG stack to indicate that application is done with processing
|
||||
*
|
||||
*
|
||||
*/
|
||||
switch_status_t mg_send_end_of_axn(SuId suId, MgMgcoTransId* transId, MgMgcoContextId* ctxtId, TknU32* peerId)
|
||||
{
|
||||
int ret = 0x00;
|
||||
MgMgcoCtxt ctxt;
|
||||
|
||||
memset(&ctxt,0, sizeof(ctxt));
|
||||
memcpy(&ctxt.transId,transId,sizeof(MgMgcoTransId));
|
||||
memcpy(&ctxt.cntxtId, ctxtId,sizeof(MgMgcoContextId));
|
||||
memcpy(&ctxt.peerId, peerId,sizeof(TknU32));
|
||||
ctxt.cmdStatus.pres = PRSNT_NODEF;
|
||||
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,
|
||||
"mg_send_end_of_axn: Sending END_OF_AXN for transId[%d], peerId[%d], context[type = %s, value = %d]\n",
|
||||
(uint32_t)transId->val, peerId->val, PRNT_MG_CTXT_TYPE(ctxtId->type.val), (uint32_t)ctxtId->val.val);
|
||||
|
||||
ret = sng_mgco_send_axn_req(suId, &ctxt);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
/*
|
||||
*
|
||||
* Fun: mg_build_mgco_err_request
|
||||
*
|
||||
* Desc: this api will send the Error event to MG stack to indicate failure in application
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
switch_status_t mg_build_mgco_err_request(MgMgcoInd **errcmd,U32 trans_id, MgMgcoContextId *ctxt_id, U32 err, MgStr *errTxt)
|
||||
{
|
||||
MgMgcoInd *mgErr;
|
||||
S16 ret;
|
||||
|
||||
mgErr = NULLP;
|
||||
ret = ROK;
|
||||
|
||||
/* Allocate for AG error */
|
||||
mg_stack_alloc_mem((Ptr*)&mgErr, sizeof(MgMgcoInd));
|
||||
if (NULL == mgErr) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " mg_build_mgco_err_request Failed : memory alloc \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/* Set transaction Id in the error request */
|
||||
MG_SET_VAL_PRES(mgErr->transId, trans_id);
|
||||
|
||||
/* Copy the context Id */
|
||||
MG_MEM_COPY(&mgErr->cntxtId,
|
||||
ctxt_id,
|
||||
sizeof(MgMgcoContextId));
|
||||
|
||||
/* Set the peerId */
|
||||
mgErr->peerId.pres = NOTPRSNT;
|
||||
|
||||
/* Set the error code */
|
||||
MG_SET_PRES(mgErr->err.pres.pres);
|
||||
MG_SET_PRES(mgErr->err.code.pres);
|
||||
MG_SET_VAL_PRES(mgErr->err.code, err);
|
||||
|
||||
if(errTxt->len)
|
||||
{
|
||||
MG_GETMEM(mgErr->err.text.val, (errTxt->len)*sizeof(U8), &mgErr->memCp, &ret);
|
||||
if (ROK != ret) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " mg_build_mgco_err_request Failed : memory alloc \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
mgErr->err.text.pres = PRSNT_NODEF;
|
||||
mgErr->err.text.len = errTxt->len;
|
||||
MG_MEM_COPY(mgErr->err.text.val, errTxt->val, errTxt->len);
|
||||
}
|
||||
|
||||
/* Set the output value */
|
||||
*errcmd = mgErr;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq)
|
||||
{
|
||||
MgMgcoContextId *ctxtId;
|
||||
MgMgcoTermIdLst *term_list;
|
||||
MgStr errTxt;
|
||||
MgMgcoInd *mgErr;
|
||||
MgMgcoTermId *termId;
|
||||
MgMgcoSubAudReq *audit;
|
||||
MgMgcoAuditDesc *audit_desc;
|
||||
MgMgcoAuditItem *audit_item;
|
||||
int i;
|
||||
int err_code;
|
||||
|
||||
audit = &auditReq->u.mgCmdReq[0]->cmd.u.aval;
|
||||
|
||||
if(NOTPRSNT == audit->pres.pres){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Audit structure not present..rejecting \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
audit_desc = &audit->audit;
|
||||
|
||||
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..rejecting \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/* dump AUDIT message information */
|
||||
/*mgAccEvntPrntMgMgcoSubAudReq(auditReq,stdout);*/
|
||||
|
||||
/*-- Get context id --*/
|
||||
ctxtId = &auditReq->contextId;
|
||||
|
||||
/*-- Get termination list --*/
|
||||
term_list = mg_get_term_id_list(auditReq);
|
||||
termId = term_list->terms[0];
|
||||
|
||||
/*-- Start with Context level checks --*/
|
||||
/*-- CHOOSE Context not allowed --*/
|
||||
if ((NOTPRSNT != ctxtId->type.pres) &&
|
||||
(MGT_CXTID_CHOOSE == ctxtId->type.val)) {
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,
|
||||
"failed, Ctxt: CHOOSE not allowed in Audit Value\n");
|
||||
|
||||
/* set correct error code */
|
||||
mg_util_set_ctxt_string(&errTxt,ctxtId);
|
||||
err_code = MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER;
|
||||
goto error;
|
||||
}
|
||||
/*-- CHOOSE Termination not allowed --*/
|
||||
else if ((NOTPRSNT != termId->type.pres) &&
|
||||
(MGT_TERMID_CHOOSE == termId->type.val)) {
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,
|
||||
"failed, Term: CHOOSE not allowed in Audit Value\n");
|
||||
|
||||
mg_util_set_term_string(&errTxt,termId);
|
||||
err_code = MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*-- For Audit Values, ROOT Termination is allowed with Context = ALL but not allowed with Other --*/
|
||||
/*-- Check whether the termination is present in the given context --*/
|
||||
if (((NOTPRSNT != termId->type.pres) &&
|
||||
(MGT_TERMID_ROOT == termId->type.val)) &&
|
||||
((NOTPRSNT != ctxtId->type.pres) &&
|
||||
(MGT_CXTID_OTHER == ctxtId->type.val))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,
|
||||
"failed, Term: Invalid combination, ROOT Term with OTHER CONTEXT\n");
|
||||
|
||||
mg_util_set_ctxt_string(&errTxt,ctxtId);
|
||||
err_code = MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* validation done , now processing command */
|
||||
|
||||
for (i = 0; i < audit_desc->num.val; i++) {
|
||||
|
||||
audit_item = audit_desc->al[i];
|
||||
|
||||
if (!audit_item) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,
|
||||
"Audit Descriptor is NULL.. rejecting \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/*TODO - If we are not supporint AUDIT type then can send "MGT_MGCO_RSP_CODE_UNSUPPORTED_DESC" error to MG stack */
|
||||
if (NOTPRSNT != audit_item->auditItem.pres) {
|
||||
|
||||
switch(audit_item->auditItem.val)
|
||||
{
|
||||
case MGT_MEDIADESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing MEDIA \n");
|
||||
break;
|
||||
}
|
||||
case MGT_MODEMDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing MODEM \n");
|
||||
break;
|
||||
}
|
||||
case MGT_MUXDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing MULTIPLEX \n");
|
||||
break;
|
||||
}
|
||||
case MGT_REQEVTDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing Events \n");
|
||||
break;
|
||||
}
|
||||
case MGT_SIGNALSDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing Signals \n");
|
||||
break;
|
||||
}
|
||||
case MGT_DIGMAPDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing Digit Maps \n");
|
||||
break;
|
||||
}
|
||||
case MGT_OBSEVTDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing Buffer Events \n");
|
||||
break;
|
||||
}
|
||||
case MGT_EVBUFDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing Events Buffer \n");
|
||||
break;
|
||||
}
|
||||
case MGT_STATSDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing Statistics \n");
|
||||
break;
|
||||
}
|
||||
case MGT_PKGSDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Auditing Packages \n");
|
||||
handle_pkg_audit(suId, auditReq);
|
||||
break;
|
||||
}
|
||||
case MGT_INDAUD_TERMAUDDESC:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Individual Term Audit \n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Invalid Audit Descriptor[%d] request\n",audit_item->auditItem.val);
|
||||
err_code = MGT_MGCO_RSP_CODE_UNSUPPORTED_DESC;
|
||||
goto error;
|
||||
}
|
||||
}/*switch(audit_item->auditItem.val)*/
|
||||
}/*if (NOTPRSNT != audit_item->auditItem.pres)*/
|
||||
}/*for loop - audit_desc->num.val */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* deallocate the msg */
|
||||
mg_free_cmd(auditReq);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
switch_status_t handle_pkg_audit( SuId suId, MgMgcoCommand *auditReq)
|
||||
{
|
||||
switch_status_t ret;
|
||||
MgMgcoCommand reply;
|
||||
MgMgcoTermIdLst *term_list;
|
||||
MgMgcoTermId *termId;
|
||||
MgMgcoSubAudReq *audit;
|
||||
MgMgcoAuditDesc *audit_desc;
|
||||
MgMgcoAuditReply *adtRep = NULLP;
|
||||
U16 numOfParms;
|
||||
MgMgcoCtxt ctxt;
|
||||
|
||||
memset(&reply, 0, sizeof(reply));
|
||||
audit = &auditReq->u.mgCmdReq[0]->cmd.u.aval;
|
||||
|
||||
if(NOTPRSNT == audit->pres.pres){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Audit structure not present..rejecting \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
audit_desc = &audit->audit;
|
||||
|
||||
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..rejecting \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/* dump AUDIT message information */
|
||||
/*mgAccEvntPrntMgMgcoSubAudReq(auditReq,stdout);*/
|
||||
|
||||
/*-- Get termination list --*/
|
||||
term_list = mg_get_term_id_list(auditReq);
|
||||
termId = term_list->terms[0];
|
||||
|
||||
|
||||
/*copy transaction-id*/
|
||||
memcpy(&reply.transId, &auditReq->transId,sizeof(MgMgcoTransId));
|
||||
/*copy context-id*/
|
||||
memcpy(&reply.contextId, &auditReq->contextId,sizeof(MgMgcoContextId));
|
||||
/*copy peer identifier */
|
||||
memcpy(&reply.peerId, &auditReq->peerId,sizeof(TknU32));
|
||||
|
||||
/*fill response structue */
|
||||
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&reply.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
||||
return ret;
|
||||
}
|
||||
|
||||
reply.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||
reply.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||
reply.u.mgCmdRsp[0]->type.val = MGT_AUDITVAL;
|
||||
|
||||
|
||||
adtRep = &(reply.u.mgCmdRsp[0]->u.aval);
|
||||
|
||||
adtRep->type.pres = PRSNT_NODEF;
|
||||
adtRep->type.val = MGT_TERMAUDIT;
|
||||
adtRep->u.other.pres.pres = PRSNT_NODEF;
|
||||
mgUtlAllocMgMgcoTermIdLst(&adtRep->u.other.termIdLst, term_list);
|
||||
|
||||
/* Grow the list of reply parameters */
|
||||
if (mgUtlGrowList((void ***)&adtRep->u.other.audit.parms, sizeof(MgMgcoAudRetParm),
|
||||
&adtRep->u.other.audit.num, &reply.u.mgCmdRsp[0]->memCp) != ROK)
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
numOfParms = adtRep->u.other.audit.num.val;
|
||||
adtRep->u.other.audit.parms[numOfParms - 1]->type.pres = PRSNT_NODEF;
|
||||
adtRep->u.other.audit.parms[numOfParms - 1]->type.val = MGT_PKGSDESC;
|
||||
|
||||
if(SWITCH_STATUS_FALSE == mg_build_pkg_desc(&adtRep->u.other.audit.parms[numOfParms - 1]->u.pkgs)){
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/* We will always send one command at a time..*/
|
||||
reply.cmdStatus.pres = PRSNT_NODEF;
|
||||
reply.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
||||
|
||||
reply.cmdType.pres = PRSNT_NODEF;
|
||||
reply.cmdType.val = CH_CMD_TYPE_RSP;
|
||||
|
||||
|
||||
ret = sng_mgco_send_cmd(suId, &reply);
|
||||
|
||||
memcpy(&ctxt.transId,&auditReq->transId,sizeof(MgMgcoTransId));
|
||||
memcpy(&ctxt.cntxtId, &auditReq->contextId,sizeof(MgMgcoContextId));
|
||||
memcpy(&ctxt.peerId, &auditReq->peerId,sizeof(TknU32));
|
||||
ctxt.cmdStatus.pres = PRSNT_NODEF;
|
||||
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN;
|
||||
ret = sng_mgco_send_axn_req(suId, &ctxt);
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*****************************************************************************************************************************/
|
||||
switch_status_t mg_send_audit_rsp(SuId suId, MgMgcoCommand *req)
|
||||
{
|
||||
MgMgcoCommand cmd;
|
||||
int ret = 0x00;
|
||||
MgMgcoTermId *termId;
|
||||
MgMgcoCtxt ctxt;
|
||||
MgMgcoAuditReply *adtRep = NULLP;
|
||||
|
||||
memset(&cmd,0, sizeof(cmd));
|
||||
|
||||
/*copy transaction-id*/
|
||||
memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
|
||||
|
||||
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
|
||||
memcpy(&cmd.contextId, &req->contextId,sizeof(MgMgcoContextId));
|
||||
|
||||
/*copy peer identifier */
|
||||
memcpy(&cmd.peerId, &req->peerId,sizeof(TknU32));
|
||||
|
||||
/*fill response structue */
|
||||
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&cmd.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
||||
return ret;
|
||||
}
|
||||
|
||||
cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->wild.pres = NOTPRSNT;
|
||||
cmd.u.mgCmdRsp[0]->type.val = MGT_AUDITVAL;
|
||||
|
||||
adtRep = &(cmd.u.mgCmdRsp[0]->u.aval);
|
||||
|
||||
/* Set type as Cxt Audit */
|
||||
MG_INIT_TOKEN_VALUE(&(adtRep->type), MGT_CXTAUDIT);
|
||||
/* Set no of Terminations to 1 */
|
||||
MG_INIT_TOKEN_VALUE(&(adtRep->u.cxt.num), 1);
|
||||
|
||||
|
||||
|
||||
cmd.u.mgCmdRsp[0]->u.aval.u.cxt.num.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->u.aval.u.cxt.num.val = 1;
|
||||
|
||||
mgUtlAllocMgMgcoTermIdLst(&cmd.u.mgCmdRsp[0]->u.aval.u.cxt, &req->u.mgCmdReq[0]->cmd.u.aval.termIdLst);
|
||||
|
||||
#ifdef GCP_VER_2_1
|
||||
termId = cmd.u.mgCmdRsp[0]->u.add.termIdLst.terms[0];
|
||||
#else
|
||||
termId = &(cmd.u.mgCmdRsp[0]->u.add.termId);
|
||||
#endif
|
||||
mg_fill_mgco_termid(termId, (CONSTANT U8*)"term1",&req->u.mgCmdRsp[0]->memCp);
|
||||
|
||||
/* We will always send one command at a time..*/
|
||||
cmd.cmdStatus.pres = PRSNT_NODEF;
|
||||
cmd.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
||||
|
||||
cmd.cmdType.pres = PRSNT_NODEF;
|
||||
cmd.cmdType.val = CH_CMD_TYPE_RSP;
|
||||
|
||||
|
||||
ret = sng_mgco_send_cmd(suId, &cmd);
|
||||
|
||||
memcpy(&ctxt.transId,&req->transId,sizeof(MgMgcoTransId));
|
||||
memcpy(&ctxt.cntxtId, &req->contextId,sizeof(MgMgcoContextId));
|
||||
memcpy(&ctxt.peerId, &req->peerId,sizeof(TknU32));
|
||||
ctxt.cmdStatus.pres = PRSNT_NODEF;
|
||||
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN;
|
||||
ret = sng_mgco_send_axn_req(suId, &ctxt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
switch_status_t mg_send_modify_rsp(SuId suId, MgMgcoCommand *req)
|
||||
{
|
||||
MgMgcoCommand cmd;
|
||||
int ret = 0x00;
|
||||
MgMgcoTermId *termId;
|
||||
MgMgcoCtxt ctxt;
|
||||
|
||||
memset(&cmd,0, sizeof(cmd));
|
||||
|
||||
/*copy transaction-id*/
|
||||
memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
|
||||
|
||||
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
|
||||
memcpy(&cmd.contextId, &req->contextId,sizeof(MgMgcoContextId));
|
||||
|
||||
/*copy peer identifier */
|
||||
memcpy(&cmd.peerId, &req->peerId,sizeof(TknU32));
|
||||
|
||||
/*fill response structue */
|
||||
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&cmd.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
||||
return ret;
|
||||
}
|
||||
|
||||
cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.val = MGT_MODIFY;
|
||||
cmd.u.mgCmdRsp[0]->u.mod.pres.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->u.mod.termIdLst.num.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->u.mod.termIdLst.num.val = 1;
|
||||
|
||||
mgUtlAllocMgMgcoTermIdLst(&cmd.u.mgCmdRsp[0]->u.mod.termIdLst, &req->u.mgCmdReq[0]->cmd.u.mod.termIdLst);
|
||||
|
||||
#ifdef GCP_VER_2_1
|
||||
termId = cmd.u.mgCmdRsp[0]->u.mod.termIdLst.terms[0];
|
||||
#else
|
||||
termId = &(cmd.u.mgCmdRsp[0]->u.mod.termId);
|
||||
#endif
|
||||
mg_fill_mgco_termid(termId, (CONSTANT U8*)"term1",&req->u.mgCmdRsp[0]->memCp);
|
||||
|
||||
/* We will always send one command at a time..*/
|
||||
cmd.cmdStatus.pres = PRSNT_NODEF;
|
||||
cmd.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
||||
|
||||
cmd.cmdType.pres = PRSNT_NODEF;
|
||||
cmd.cmdType.val = CH_CMD_TYPE_RSP;
|
||||
|
||||
|
||||
ret = sng_mgco_send_cmd(suId, &cmd);
|
||||
|
||||
memcpy(&ctxt.transId,&req->transId,sizeof(MgMgcoTransId));
|
||||
memcpy(&ctxt.cntxtId, &req->contextId,sizeof(MgMgcoContextId));
|
||||
memcpy(&ctxt.peerId, &req->peerId,sizeof(TknU32));
|
||||
ctxt.cmdStatus.pres = PRSNT_NODEF;
|
||||
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN;
|
||||
ret = sng_mgco_send_axn_req(suId, &ctxt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Sangoma Technologies
|
||||
* Mathieu Rene <mrene@avgs.ca>
|
||||
* All rights reserved.
|
||||
*
|
||||
* <Insert license here>
|
||||
*/
|
||||
|
||||
#include "mod_media_gateway.h"
|
||||
#include "media_gateway_stack.h"
|
||||
|
||||
|
||||
MgPackage_t mg_pkg_list [] =
|
||||
{
|
||||
{ /* INDEX : 0 */
|
||||
MGT_PKG_GENERIC, /* Package Id 1 : Generic package */
|
||||
1, /* Version 1 */
|
||||
"g", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 1 */
|
||||
MGT_PKG_ROOT,
|
||||
2, /* Version 1 */
|
||||
"root", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 2 */
|
||||
MGT_PKG_TONEDET, /*4*/
|
||||
1, /* Version 1 */
|
||||
"tonedet", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 3 */
|
||||
MGT_PKG_DTMFDET, /*6*/
|
||||
1, /* Version 1 */
|
||||
"dd", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 4 */
|
||||
MGT_PKG_NETWORK, /*11*/
|
||||
1, /* Version 1 */
|
||||
"nt", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 5 */
|
||||
MGT_PKG_RTP, /*12*/
|
||||
1, /* Version 1 */
|
||||
"rtp", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 6 */
|
||||
MGT_PKG_TDM_CKT, /*13*/
|
||||
1, /* Version 1 */
|
||||
"tdmc", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 7 */
|
||||
MGT_PKG_QTY_ALT, /*55*/
|
||||
1, /* Version 1 */
|
||||
"qac", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 8 */
|
||||
MGT_PKG_EN_ALERT, /*59*/
|
||||
2, /* Version 2 */
|
||||
"alert", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 9 */
|
||||
MGT_PKG_AN_DISP, /*60*/
|
||||
2, /* Version 1 */
|
||||
"andisp", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 10 */
|
||||
MGT_PKG_INACTTIMER, /*69*/
|
||||
1, /* Version 1 */
|
||||
"it", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 11 */
|
||||
MGT_PKG_STIMAL, /* 147 */
|
||||
1, /* Version 1 */
|
||||
"stimal ", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 12 */
|
||||
MGT_PKG_CALLPROGGEN, /* 7 */
|
||||
1, /* Version 1 */
|
||||
"cg", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 13 */
|
||||
MGT_PKG_GENERIC_ANNC, /* 29 */
|
||||
1, /* Version 1 */
|
||||
"an", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 14 */
|
||||
MGT_PKG_XD_CALPG_TNGN, /* 36 */
|
||||
1, /* Version 1 */
|
||||
"xcg", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 15 */
|
||||
MGT_PKG_BSC_SRV_TN, /* 37 */
|
||||
1, /* Version 1 */
|
||||
"srvtn", /* Package name */
|
||||
},
|
||||
{ /* INDEX : 16 */
|
||||
MGT_PKG_ETSI_NR,
|
||||
1, /* Version 1 */
|
||||
"etsi_nr", /* Package name */
|
||||
},
|
||||
/* Add more packages */
|
||||
};
|
||||
|
||||
/***************************************************************************************/
|
||||
switch_status_t mg_build_pkg_desc(MgMgcoPkgsDesc* pkg)
|
||||
{
|
||||
uint16_t i = 0x00;
|
||||
uint16_t num_of_pkgs = sizeof(mg_pkg_list)/sizeof(MgPackage_t);
|
||||
|
||||
printf("mg_build_pkg_desc: num_of_pkgs[%d]\n",num_of_pkgs);
|
||||
|
||||
for (i = 0; i < num_of_pkgs; i++) {
|
||||
|
||||
if (mgUtlGrowList((void ***)&pkg->items,
|
||||
sizeof(MgMgcoPkgsItem), &pkg->num, NULLP) != ROK) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"Package descriptor Grow List failed\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
pkg->items[pkg->num.val - 1 ]->pres.pres = PRSNT_NODEF;
|
||||
pkg->items[pkg->num.val - 1 ]->name.type.pres = PRSNT_NODEF;
|
||||
pkg->items[pkg->num.val - 1 ]->name.type.val = MGT_GEN_TYPE_KNOWN;
|
||||
|
||||
pkg->items[pkg->num.val - 1 ]->name.u.val.pres = PRSNT_NODEF;
|
||||
pkg->items[pkg->num.val - 1 ]->name.u.val.val = mg_pkg_list[i].package_id;
|
||||
|
||||
pkg->items[pkg->num.val - 1 ]->ver.pres = PRSNT_NODEF;
|
||||
pkg->items[pkg->num.val - 1 ]->ver.val = mg_pkg_list[i].version;
|
||||
|
||||
printf("mg_build_pkg_desc: Inserted pkg_id[%d] with version[%d] into pkg list index[%d]\n",mg_pkg_list[i].package_id,mg_pkg_list[i].version,i);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
/***************************************************************************************/
|
||||
|
|
@ -49,29 +49,55 @@ typedef struct _mgStr
|
|||
U8 val[128];
|
||||
} MgStr;
|
||||
|
||||
#define MAX_PACKAGE_NAME 128
|
||||
|
||||
typedef struct _mgPackage
|
||||
{
|
||||
uint8_t package_id;
|
||||
uint16_t version;
|
||||
uint8_t name[MAX_PACKAGE_NAME+1];
|
||||
}MgPackage_t;
|
||||
|
||||
extern MgPackage_t mg_pkg_list[];
|
||||
|
||||
|
||||
#define MG_TXN_INVALID 0
|
||||
|
||||
#define mg_zero(_buf, _size) {cmMemset((U8 *)(_buf), 0, _size);}
|
||||
#define MG_ZERO(_buf, _size) {cmMemset((U8 *)(_buf), 0, _size);}
|
||||
|
||||
/* Set pres field */
|
||||
#define mg_util_set_pres(_pres) \
|
||||
#define MG_SET_PRES(_pres) \
|
||||
(_pres) = PRSNT_NODEF;
|
||||
|
||||
/* Set token value */
|
||||
#define mg_util_set_val_pres(tkn,_val) \
|
||||
mg_util_set_pres((tkn).pres); \
|
||||
#define MG_SET_VAL_PRES(tkn,_val) \
|
||||
MG_SET_PRES((tkn).pres); \
|
||||
(tkn).val = _val;
|
||||
|
||||
|
||||
#define mg_mem_copy(_dst, _src, _len) \
|
||||
#define MG_MEM_COPY(_dst, _src, _len) \
|
||||
cmMemcpy((U8*) (_dst), (const U8*) (_src), _len)
|
||||
|
||||
#define mg_get_mem(_memPtr, _size, _allocPtr, ret) \
|
||||
|
||||
#define MG_INIT_TOKEN_VALUE(_tkn, _val) \
|
||||
{ \
|
||||
(*ret) = cmGetMem((Ptr *)(_memPtr),(_size) ,(Ptr *)&(_allocPtr)); \
|
||||
(_tkn)->pres = PRSNT_NODEF; \
|
||||
(_tkn)->val = (_val); \
|
||||
}
|
||||
|
||||
#define MG_GETMEM(_ptr,_len,_memCp,_ret) \
|
||||
{ \
|
||||
ret = cmGetMem((_memCp), (_len), (Ptr *)&(_ptr)); \
|
||||
if( ret == ROK) \
|
||||
cmMemset((U8 *)(_ptr), (U8)0, (PTR)(_len)); \
|
||||
}
|
||||
|
||||
#define MG_INIT_TKNSTR(_tkn, _val, _len) \
|
||||
{ \
|
||||
(_tkn)->pres = PRSNT_NODEF; \
|
||||
(_tkn)->len = (U8)(_len); \
|
||||
cmMemcpy((U8 *)(_tkn)->val, (CONSTANT U8 *)(_val), (_len)); \
|
||||
}
|
||||
|
||||
void handle_sng_log(uint8_t level, char *fmt, ...);
|
||||
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* msg);
|
||||
|
@ -91,6 +117,28 @@ switch_status_t sng_mgco_init(sng_mg_event_interface_t* event);
|
|||
switch_status_t sng_mgco_stack_shutdown(void);
|
||||
int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg, mg_peer_profile_t* mg_peer);
|
||||
|
||||
switch_status_t mg_send_end_of_axn(SuId suId, MgMgcoTransId* transId, MgMgcoContextId* ctxtId, TknU32* peerId);
|
||||
void mgco_print_sdp(CmSdpInfoSet *sdp);
|
||||
void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId);
|
||||
switch_status_t handle_mg_add_cmd(MgMgcoAmmReq *addReq);
|
||||
switch_status_t mg_stack_free_mem(MgMgcoMsg* msg);
|
||||
switch_status_t mg_stack_free_mem(MgMgcoMsg* msg);
|
||||
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize );
|
||||
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req);
|
||||
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, 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 mg_send_modify_rsp(SuId suId, MgMgcoCommand *req);
|
||||
void mg_util_set_term_string ( MgStr *errTxt, MgMgcoTermId *termId);
|
||||
MgMgcoTermIdLst *mg_get_term_id_list(MgMgcoCommand *cmd);
|
||||
switch_status_t handle_pkg_audit( SuId suId, MgMgcoCommand *auditReq);
|
||||
switch_status_t mg_build_pkg_desc(MgMgcoPkgsDesc* pkg);
|
||||
|
||||
|
||||
|
||||
/****************************************************************************************************************/
|
||||
/* MG Stack defines */
|
||||
|
||||
|
|
|
@ -0,0 +1,430 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Sangoma Technologies
|
||||
* Mathieu Rene <mrene@avgs.ca>
|
||||
* All rights reserved.
|
||||
*
|
||||
* <Insert license here>
|
||||
*/
|
||||
|
||||
#include "mod_media_gateway.h"
|
||||
#include "media_gateway_stack.h"
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize )
|
||||
{
|
||||
Mem sMem;
|
||||
|
||||
sMem.region = 0;
|
||||
sMem.pool = 0;
|
||||
|
||||
if ( _memSize <= 0 )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_alloc_mem: invalid size\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ( ROK != cmAllocEvnt( _memSize, MG_MAXBLKSIZE, &sMem, _memPtr ) )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_alloc_mem: cmAllocEvnt return failure for _memSize=%d\n",(int)_memSize);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
// Note: memset done inside stack api
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
switch_status_t mg_stack_get_mem(MgMgcoMsg* msg, Ptr* _memPtr, Size _memSize )
|
||||
{
|
||||
if ( _memSize <= 0 )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid size\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ( !msg )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid message\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ( cmGetMem( (Ptr)msg, _memSize, (Ptr*)_memPtr ) != ROK )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed alloc_mg_stack_mem: get memory failed _memSize=%d\n", (int)_memSize );
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
// Note: memset done inside stack api
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
switch_status_t mg_stack_free_mem(MgMgcoMsg* msg)
|
||||
{
|
||||
if ( !msg )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid message\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
cmFreeMem( (Ptr)msg );
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, CmMemListCp *memCp)
|
||||
{
|
||||
#ifdef GCP_ASN
|
||||
Size size;
|
||||
#endif
|
||||
S16 ret = ROK;
|
||||
|
||||
termId->name.pres.pres = PRSNT_NODEF;
|
||||
/* mg011.105: Bug fixes */
|
||||
termId->name.lcl.pres = PRSNT_NODEF;
|
||||
termId->name.lcl.len = cmStrlen((CONSTANT U8*)str);
|
||||
MG_GETMEM(termId->name.lcl.val, termId->name.lcl.len, memCp, ret);
|
||||
if( ret != ROK)
|
||||
RETVALUE(ret);
|
||||
|
||||
cmMemcpy((U8*)(termId->name.lcl.val), (CONSTANT U8*)str,termId->name.lcl.len);
|
||||
|
||||
#ifdef GCP_ASN
|
||||
/* Remove comment to fill other term ID
|
||||
termId->wildcard.num.pres = NOTPRSNT; */
|
||||
/* Remove comment to fill wilcard term ID */
|
||||
termId->wildcard.num.pres = PRSNT_NODEF;
|
||||
termId->wildcard.num.val = 1;
|
||||
size = ((sizeof(MgMgcoWildcardField*)));
|
||||
MG_GETMEM((termId->wildcard.wildcard),size,memCp, ret);
|
||||
if( ret != ROK)
|
||||
RETVALUE(ret);
|
||||
|
||||
MG_GETMEM( ((termId->wildcard.wildcard)[0]),sizeof(MgMgcoWildcardField),
|
||||
memCp, ret);
|
||||
if( ret != ROK)
|
||||
RETVALUE(ret);
|
||||
|
||||
termId->wildcard.wildcard[0]->pres = PRSNT_NODEF;
|
||||
termId->wildcard.wildcard[0]->len = 1;
|
||||
termId->wildcard.wildcard[0]->val[0] = 0x55;
|
||||
#endif /* GCP_ASN */
|
||||
|
||||
RETVALUE(ROK);
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
/*
|
||||
*
|
||||
* Fun: mg_get_term_id_list
|
||||
*
|
||||
* Desc: Utility function to get MgMgcoTermIdLst structure
|
||||
* from MgMgcoCommand structure.
|
||||
* GCP_VER_2_1 - we will have term id list instead of single term id
|
||||
*
|
||||
* Ret: If success, return pointer to MgMgcoTermIdLst.
|
||||
* If failure, return Null.
|
||||
*
|
||||
* Notes: None
|
||||
*
|
||||
*/
|
||||
|
||||
MgMgcoTermIdLst *mg_get_term_id_list(MgMgcoCommand *cmd)
|
||||
{
|
||||
uint8_t cmd_type = MGT_NONE;
|
||||
uint8_t api_type = CM_CMD_TYPE_NONE;
|
||||
MgMgcoTermIdLst * term_id = NULL;
|
||||
|
||||
|
||||
/*-- mgCmdInd type represents the data structure for both
|
||||
* incoming and outgoing requests, hence we can get the
|
||||
* command type from there itself --*/
|
||||
cmd_type = cmd->u.mgCmdInd[0]->cmd.type.val;
|
||||
|
||||
/*-- Find apiType --*/
|
||||
api_type = cmd->cmdType.val;
|
||||
|
||||
switch (api_type)
|
||||
{
|
||||
case CH_CMD_TYPE_REQ:
|
||||
case CH_CMD_TYPE_IND:
|
||||
/* Based on Command Type, get to the TermId structure */
|
||||
switch (cmd_type)
|
||||
{
|
||||
case MGT_ADD:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.add.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.add.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MOVE:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.move.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.move.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MODIFY:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.mod.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.mod.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SUB:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.sub.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.sub.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITCAP:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.acap.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.acap.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITVAL:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.aval.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.aval.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_NTFY:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.ntfy.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.ntfy.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SVCCHG:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.svc.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.svc.termIdLst;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported Command[%s]\n", __PRETTY_FUNCTION__, PRNT_MG_CMD(cmd_type));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CH_CMD_TYPE_RSP:
|
||||
case CH_CMD_TYPE_CFM:
|
||||
|
||||
cmd_type = cmd->u.mgCmdRsp[0]->type.val;
|
||||
|
||||
switch (cmd_type)
|
||||
{
|
||||
case MGT_ADD:
|
||||
if (cmd->u.mgCmdRsp[0]->u.add.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.add.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MOVE:
|
||||
if (cmd->u.mgCmdRsp[0]->u.move.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.move.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MODIFY:
|
||||
if (cmd->u.mgCmdRsp[0]->u.mod.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.mod.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SUB:
|
||||
if (cmd->u.mgCmdRsp[0]->u.sub.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.sub.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SVCCHG:
|
||||
if (cmd->u.mgCmdRsp[0]->u.svc.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.svc.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITVAL:
|
||||
if (cmd->u.mgCmdRsp[0]->u.aval.u.other.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.aval.u.other.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITCAP:
|
||||
if (cmd->u.mgCmdRsp[0]->u.acap.u.other.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.acap.u.other.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_NTFY:
|
||||
if (cmd->u.mgCmdRsp[0]->u.ntfy.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.ntfy.termIdLst;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported Command[%s]\n", __PRETTY_FUNCTION__, PRNT_MG_CMD(cmd_type));
|
||||
} /* switch command type for reply */
|
||||
break;
|
||||
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported api_type[%s]!\n", __PRETTY_FUNCTION__, PRNT_MG_CMD_TYPE(api_type));
|
||||
break;
|
||||
} /* switch -api_type */
|
||||
|
||||
return (term_id);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId)
|
||||
{
|
||||
MG_ZERO(errTxt->val, sizeof(errTxt->val));
|
||||
errTxt->len = 0;
|
||||
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
|
||||
if (MG_TXN_INVALID == txnId )
|
||||
{
|
||||
MG_MEM_COPY((&errTxt->val[errTxt->len]), "TransactionId=0", 15);
|
||||
errTxt->len += 15;
|
||||
}
|
||||
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s:"
|
||||
"info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val);
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
void mg_util_set_ctxt_string ( MgStr *errTxt, MgMgcoContextId *ctxtId)
|
||||
{
|
||||
MG_ZERO((errTxt->val), sizeof(errTxt->val));
|
||||
errTxt->len = 0;
|
||||
if(ctxtId->type.pres != NOTPRSNT)
|
||||
{
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
if(ctxtId->type.val == MGT_CXTID_NULL)
|
||||
{
|
||||
errTxt->val[errTxt->len] = '-';
|
||||
errTxt->len += 1;
|
||||
}
|
||||
else if(ctxtId->type.val == MGT_CXTID_ALL)
|
||||
{
|
||||
errTxt->val[errTxt->len] = '*';
|
||||
errTxt->len += 1;
|
||||
}
|
||||
else if(ctxtId->type.val == MGT_CXTID_CHOOSE)
|
||||
{
|
||||
errTxt->val[errTxt->len] = '$';
|
||||
errTxt->len += 1;
|
||||
}
|
||||
else if((ctxtId->type.val == MGT_CXTID_OTHER) && (ctxtId->val.pres != NOTPRSNT))
|
||||
{
|
||||
sprintf((char*)&errTxt->val[errTxt->len], "%d", ctxtId->val.val);
|
||||
errTxt->len += cmStrlen((U8*)(&errTxt->val[errTxt->len]));
|
||||
}
|
||||
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s:"
|
||||
"info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
void mgco_print_sdp(CmSdpInfoSet *sdp)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (sdp->numComp.pres == NOTPRSNT) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sdp->numComp.val; i++) {
|
||||
CmSdpInfo *s = sdp->info[i];
|
||||
int mediaId;
|
||||
|
||||
if (s->conn.addrType.pres && s->conn.addrType.val == CM_SDP_ADDR_TYPE_IPV4 &&
|
||||
s->conn.netType.type.val == CM_SDP_NET_TYPE_IN &&
|
||||
s->conn.u.ip4.addrType.val == CM_SDP_IPV4_IP_UNI) {
|
||||
|
||||
if (s->conn.u.ip4.addrType.pres) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Address: %d.%d.%d.%d\n",
|
||||
s->conn.u.ip4.u.uniIp.b[0].val,
|
||||
s->conn.u.ip4.u.uniIp.b[1].val,
|
||||
s->conn.u.ip4.u.uniIp.b[2].val,
|
||||
s->conn.u.ip4.u.uniIp.b[3].val);
|
||||
}
|
||||
if (s->attrSet.numComp.pres) {
|
||||
for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) {
|
||||
/*CmSdpAttr *a = s->attrSet.attr[mediaId];*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (s->mediaDescSet.numComp.pres) {
|
||||
for (mediaId = 0; mediaId < s->mediaDescSet.numComp.val; mediaId++) {
|
||||
CmSdpMediaDesc *desc = s->mediaDescSet.mediaDesc[mediaId];
|
||||
|
||||
if (desc->field.mediaType.val == CM_SDP_MEDIA_AUDIO &&
|
||||
desc->field.id.type.val == CM_SDP_VCID_PORT &&
|
||||
desc->field.id.u.port.type.val == CM_SDP_PORT_INT &&
|
||||
desc->field.id.u.port.u.portInt.port.type.val == CM_SDP_SPEC) {
|
||||
int port = desc->field.id.u.port.u.portInt.port.val.val;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Port: %d\n", port);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
void mg_util_set_term_string ( MgStr *errTxt, MgMgcoTermId *termId)
|
||||
{
|
||||
MG_ZERO((errTxt->val), sizeof(errTxt->val));
|
||||
errTxt->len = 0;
|
||||
|
||||
if(termId->type.pres != NOTPRSNT)
|
||||
{
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
|
||||
if(termId->type.val == MGT_TERMID_ROOT)
|
||||
{
|
||||
MG_MEM_COPY((&errTxt->val[errTxt->len]), "ROOT", 4);
|
||||
errTxt->len += 4;
|
||||
}
|
||||
else if(termId->type.val == MGT_TERMID_ALL)
|
||||
{
|
||||
errTxt->val[errTxt->len] = '*';
|
||||
errTxt->len += 1;
|
||||
}
|
||||
else if(termId->type.val == MGT_TERMID_CHOOSE)
|
||||
{
|
||||
errTxt->val[errTxt->len] = '$';
|
||||
errTxt->len += 1;
|
||||
}
|
||||
else if((termId->type.val == MGT_TERMID_OTHER) && (termId->name.pres.pres != NOTPRSNT))
|
||||
{
|
||||
if(termId->name.lcl.pres != NOTPRSNT)
|
||||
{
|
||||
MG_MEM_COPY(&(errTxt->val[errTxt->len]), termId->name.lcl.val, sizeof(U8) * termId->name.lcl.len);
|
||||
errTxt->len += termId->name.lcl.len;
|
||||
}
|
||||
if(termId->name.dom.pres != NOTPRSNT)
|
||||
{
|
||||
MG_MEM_COPY(&(errTxt->val[errTxt->len]),
|
||||
termId->name.dom.val, sizeof(U8) * termId->name.dom.len);
|
||||
errTxt->len += termId->name.dom.len;
|
||||
}
|
||||
}
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s:"
|
||||
"info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val);
|
||||
}
|
||||
/*****************************************************************************************************************************/
|
|
@ -18,15 +18,6 @@ static sng_mg_event_interface_t sng_event;
|
|||
SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load);
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_media_gateway_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_media_gateway, mod_media_gateway_load, mod_media_gateway_shutdown, NULL);
|
||||
switch_status_t handle_mg_add_cmd(MgMgcoAmmReq *addReq);
|
||||
switch_status_t mg_stack_free_mem(MgMgcoMsg* msg);
|
||||
switch_status_t mg_stack_free_mem(MgMgcoMsg* msg);
|
||||
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize );
|
||||
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req);
|
||||
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, 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_STANDARD_API(megaco_function)
|
||||
|
@ -169,57 +160,8 @@ void handle_sng_log(uint8_t level, char *fmt, ...)
|
|||
va_end(ptr);
|
||||
}
|
||||
|
||||
static void mgco_print_sdp(CmSdpInfoSet *sdp)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (sdp->numComp.pres == NOTPRSNT) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sdp->numComp.val; i++) {
|
||||
CmSdpInfo *s = sdp->info[i];
|
||||
int mediaId;
|
||||
|
||||
if (s->conn.addrType.pres && s->conn.addrType.val == CM_SDP_ADDR_TYPE_IPV4 &&
|
||||
s->conn.netType.type.val == CM_SDP_NET_TYPE_IN &&
|
||||
s->conn.u.ip4.addrType.val == CM_SDP_IPV4_IP_UNI) {
|
||||
|
||||
if (s->conn.u.ip4.addrType.pres) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Address: %d.%d.%d.%d\n",
|
||||
s->conn.u.ip4.u.uniIp.b[0].val,
|
||||
s->conn.u.ip4.u.uniIp.b[1].val,
|
||||
s->conn.u.ip4.u.uniIp.b[2].val,
|
||||
s->conn.u.ip4.u.uniIp.b[3].val);
|
||||
}
|
||||
if (s->attrSet.numComp.pres) {
|
||||
for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) {
|
||||
/*CmSdpAttr *a = s->attrSet.attr[mediaId];*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (s->mediaDescSet.numComp.pres) {
|
||||
for (mediaId = 0; mediaId < s->mediaDescSet.numComp.val; mediaId++) {
|
||||
CmSdpMediaDesc *desc = s->mediaDescSet.mediaDesc[mediaId];
|
||||
|
||||
if (desc->field.mediaType.val == CM_SDP_MEDIA_AUDIO &&
|
||||
desc->field.id.type.val == CM_SDP_VCID_PORT &&
|
||||
desc->field.id.u.port.type.val == CM_SDP_PORT_INT &&
|
||||
desc->field.id.u.port.u.portInt.port.type.val == CM_SDP_SPEC) {
|
||||
int port = desc->field.id.u.port.u.portInt.port.val.val;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Port: %d\n", port);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
|
||||
|
@ -415,27 +357,26 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
|||
MgMgcoInd *mgErr;
|
||||
MgStr errTxt;
|
||||
MgMgcoContextId ctxtId;
|
||||
MgMgcoTermIdLst* termLst;
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Received Command Type[%s] \n", __PRETTY_FUNCTION__, PRNT_MG_CMD_TYPE(cmd->cmdType.val));
|
||||
|
||||
/* validate Transaction Id */
|
||||
if (NOTPRSNT != cmd->transId.pres)
|
||||
if (NOTPRSNT != cmd->transId.pres){
|
||||
txn_id = cmd->transId.val;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Transaction Id not present, rejecting\n", __PRETTY_FUNCTION__);
|
||||
|
||||
/*-- Send Error to MG Stack --*/
|
||||
mg_zero(&ctxtId, sizeof(MgMgcoContextId));
|
||||
MG_ZERO(&ctxtId, sizeof(MgMgcoContextId));
|
||||
ctxtId.type.pres = NOTPRSNT;
|
||||
ctxtId.val.pres = NOTPRSNT;
|
||||
|
||||
mg_util_set_txn_string(&errTxt, &txn_id);
|
||||
mg_util_set_txn_string(&errTxt, (U32*)&txn_id);
|
||||
|
||||
if (SWITCH_STATUS_FALSE == mg_build_mgco_err_request(&mgErr, txn_id, &ctxtId,
|
||||
MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER, &errTxt))
|
||||
{
|
||||
if (SWITCH_STATUS_SUCCESS == mg_build_mgco_err_request(&mgErr, txn_id, &ctxtId,
|
||||
MGT_MGCO_RSP_CODE_INVLD_IDENTIFIER, &errTxt)) {
|
||||
sng_mgco_send_err(suId, mgErr);
|
||||
}
|
||||
|
||||
|
@ -444,7 +385,16 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
|||
return ;
|
||||
}
|
||||
|
||||
mgAccEvntPrntMgMgcoCommand(cmd, stdout);
|
||||
/* Get the termination Id list from the command(Note: GCP_2_1 has termination list , else it will be termination Id) */
|
||||
termLst = mg_get_term_id_list(cmd);
|
||||
if ((NULL == termLst) || (NOTPRSNT == termLst->num.pres)) {
|
||||
/* termination-id not present , error */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Termination-Id Not received..rejecting command \n");
|
||||
mg_free_cmd(cmd);
|
||||
return ;
|
||||
}
|
||||
|
||||
/*mgAccEvntPrntMgMgcoCommand(cmd, stdout);*/
|
||||
|
||||
switch(cmd->cmdType.val)
|
||||
{
|
||||
|
@ -465,6 +415,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
|||
case MGT_MODIFY:
|
||||
{
|
||||
/*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod;*/
|
||||
mg_send_modify_rsp(suId, cmd);
|
||||
break;
|
||||
}
|
||||
case MGT_MOVE:
|
||||
|
@ -478,9 +429,27 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
|||
/*MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub;*/
|
||||
}
|
||||
case MGT_SVCCHG:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Service-Change Method Not Yet Supported\n");
|
||||
break;
|
||||
}
|
||||
case MGT_NTFY:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NOTIFY Method Not Yet Supported\n");
|
||||
break;
|
||||
}
|
||||
case MGT_AUDITCAP:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Audit-Capability Method Not Yet Supported\n");
|
||||
break;
|
||||
}
|
||||
case MGT_AUDITVAL:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received Audit-Value Method \n");
|
||||
handle_mg_audit_cmd(suId, cmd);
|
||||
mg_send_audit_rsp(suId,cmd);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -538,468 +507,6 @@ void handle_mgco_audit_cfm(Pst *pst, SuId suId, MgMgtAudit* audit, Reason reason
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
/*
|
||||
*
|
||||
* Fun: mg_get_term_id_list
|
||||
*
|
||||
* Desc: Utility function to get MgMgcoTermIdLst structure
|
||||
* from MgMgcoCommand structure.
|
||||
* GCP_VER_2_1 - we will have term id list instead of single term id
|
||||
*
|
||||
* Ret: If success, return pointer to MgMgcoTermIdLst.
|
||||
* If failure, return Null.
|
||||
*
|
||||
* Notes: None
|
||||
*
|
||||
*/
|
||||
|
||||
MgMgcoTermIdLst *mg_get_term_id_list(MgMgcoCommand *cmd)
|
||||
{
|
||||
uint8_t cmd_type = MGT_NONE;
|
||||
uint8_t api_type = CM_CMD_TYPE_NONE;
|
||||
MgMgcoTermIdLst * term_id = NULL;
|
||||
|
||||
|
||||
/*-- mgCmdInd type represents the data structure for both
|
||||
* incoming and outgoing requests, hence we can get the
|
||||
* command type from there itself --*/
|
||||
cmd_type = cmd->u.mgCmdInd[0]->cmd.type.val;
|
||||
|
||||
/*-- Find apiType --*/
|
||||
api_type = cmd->cmdType.val;
|
||||
|
||||
switch (api_type)
|
||||
{
|
||||
case CH_CMD_TYPE_REQ:
|
||||
case CH_CMD_TYPE_IND:
|
||||
/* Based on Command Type, get to the TermId structure */
|
||||
switch (cmd_type)
|
||||
{
|
||||
case MGT_ADD:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.add.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.add.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MOVE:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.move.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.move.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MODIFY:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.mod.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.mod.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SUB:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.sub.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.sub.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITCAP:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.acap.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.acap.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITVAL:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.aval.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.aval.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_NTFY:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.ntfy.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.ntfy.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SVCCHG:
|
||||
if (cmd->u.mgCmdInd[0]->cmd.u.svc.pres.pres)
|
||||
term_id = &cmd->u.mgCmdInd[0]->cmd.u.svc.termIdLst;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported Command[%s]\n", __PRETTY_FUNCTION__, PRNT_MG_CMD(cmd_type));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CH_CMD_TYPE_RSP:
|
||||
case CH_CMD_TYPE_CFM:
|
||||
|
||||
cmd_type = cmd->u.mgCmdRsp[0]->type.val;
|
||||
|
||||
switch (cmd_type)
|
||||
{
|
||||
case MGT_ADD:
|
||||
if (cmd->u.mgCmdRsp[0]->u.add.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.add.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MOVE:
|
||||
if (cmd->u.mgCmdRsp[0]->u.move.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.move.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_MODIFY:
|
||||
if (cmd->u.mgCmdRsp[0]->u.mod.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.mod.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SUB:
|
||||
if (cmd->u.mgCmdRsp[0]->u.sub.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.sub.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_SVCCHG:
|
||||
if (cmd->u.mgCmdRsp[0]->u.svc.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.svc.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITVAL:
|
||||
if (cmd->u.mgCmdRsp[0]->u.aval.u.other.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.aval.u.other.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_AUDITCAP:
|
||||
if (cmd->u.mgCmdRsp[0]->u.acap.u.other.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.acap.u.other.termIdLst;
|
||||
break;
|
||||
|
||||
case MGT_NTFY:
|
||||
if (cmd->u.mgCmdRsp[0]->u.ntfy.pres.pres)
|
||||
term_id = &cmd->u.mgCmdRsp[0]->u.ntfy.termIdLst;
|
||||
break;
|
||||
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported Command[%s]\n", __PRETTY_FUNCTION__, PRNT_MG_CMD(cmd_type));
|
||||
} /* switch command type for reply */
|
||||
break;
|
||||
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported api_type[%s]!\n", __PRETTY_FUNCTION__, PRNT_MG_CMD_TYPE(api_type));
|
||||
break;
|
||||
} /* switch -api_type */
|
||||
|
||||
return (term_id);
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
switch_status_t handle_mg_add_cmd(MgMgcoAmmReq *addReq)
|
||||
{
|
||||
int descId;
|
||||
for (descId = 0; descId < addReq->dl.num.val; descId++) {
|
||||
switch (addReq->dl.descs[descId]->type.val) {
|
||||
case MGT_MEDIADESC:
|
||||
{
|
||||
int mediaId;
|
||||
for (mediaId = 0; mediaId < addReq->dl.descs[descId]->u.media.num.val; mediaId++) {
|
||||
MgMgcoMediaPar *mediaPar = addReq->dl.descs[descId]->u.media.parms[mediaId];
|
||||
switch (mediaPar->type.val) {
|
||||
case MGT_MEDIAPAR_LOCAL:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_LOCAL");
|
||||
break;
|
||||
}
|
||||
case MGT_MEDIAPAR_REMOTE:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_REMOTE");
|
||||
break;
|
||||
}
|
||||
|
||||
case MGT_MEDIAPAR_LOCCTL:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_LOCCTL");
|
||||
break;
|
||||
}
|
||||
case MGT_MEDIAPAR_TERMST:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_TERMST");
|
||||
break;
|
||||
}
|
||||
case MGT_MEDIAPAR_STRPAR:
|
||||
{
|
||||
MgMgcoStreamDesc *mgStream = &mediaPar->u.stream;
|
||||
|
||||
if (mgStream->sl.remote.pres.pres) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got remote stream media description:\n");
|
||||
mgco_print_sdp(&mgStream->sl.remote.sdp);
|
||||
}
|
||||
|
||||
if (mgStream->sl.local.pres.pres) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got local stream media description:\n");
|
||||
mgco_print_sdp(&mgStream->sl.local.sdp);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case MGT_MODEMDESC:
|
||||
case MGT_MUXDESC:
|
||||
case MGT_REQEVTDESC:
|
||||
case MGT_EVBUFDESC:
|
||||
case MGT_SIGNALSDESC:
|
||||
case MGT_DIGMAPDESC:
|
||||
case MGT_AUDITDESC:
|
||||
case MGT_STATSDESC:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req)
|
||||
{
|
||||
MgMgcoCommand cmd;
|
||||
int ret = 0x00;
|
||||
MgMgcoTermId *termId;
|
||||
MgMgcoCtxt ctxt;
|
||||
|
||||
memset(&cmd,0, sizeof(cmd));
|
||||
|
||||
/*copy transaction-id*/
|
||||
memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
|
||||
|
||||
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
|
||||
memcpy(&cmd.contextId, &req->contextId,sizeof(MgMgcoContextId));
|
||||
|
||||
/*copy peer identifier */
|
||||
memcpy(&cmd.peerId, &req->peerId,sizeof(TknU32));
|
||||
|
||||
/*fill response structue */
|
||||
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&cmd.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
||||
return ret;
|
||||
}
|
||||
|
||||
cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.val = MGT_ADD;
|
||||
cmd.u.mgCmdRsp[0]->u.add.pres.pres = PRSNT_NODEF;
|
||||
|
||||
|
||||
cmd.u.mgCmdRsp[0]->u.add.termIdLst.num.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->u.add.termIdLst.num.val = 1;
|
||||
|
||||
mgUtlAllocMgMgcoTermIdLst(&cmd.u.mgCmdRsp[0]->u.add.termIdLst, &req->u.mgCmdReq[0]->cmd.u.add.termIdLst);
|
||||
|
||||
#ifdef GCP_VER_2_1
|
||||
termId = cmd.u.mgCmdRsp[0]->u.add.termIdLst.terms[0];
|
||||
#else
|
||||
termId = &(cmd.u.mgCmdRsp[0]->u.add.termId);
|
||||
#endif
|
||||
mg_fill_mgco_termid(termId, (CONSTANT U8*)"term1",&req->u.mgCmdRsp[0]->memCp);
|
||||
|
||||
/* We will always send one command at a time..*/
|
||||
cmd.cmdStatus.pres = PRSNT_NODEF;
|
||||
cmd.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
||||
|
||||
cmd.cmdType.pres = PRSNT_NODEF;
|
||||
cmd.cmdType.val = CH_CMD_TYPE_RSP;
|
||||
|
||||
|
||||
ret = sng_mgco_send_cmd(suId, &cmd);
|
||||
|
||||
memcpy(&ctxt.transId,&req->transId,sizeof(MgMgcoTransId));
|
||||
memcpy(&ctxt.cntxtId, &req->contextId,sizeof(MgMgcoContextId));
|
||||
memcpy(&ctxt.peerId, &req->peerId,sizeof(TknU32));
|
||||
ctxt.cmdStatus.pres = PRSNT_NODEF;
|
||||
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN;
|
||||
ret = sng_mgco_send_axn_req(suId, &ctxt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize )
|
||||
{
|
||||
Mem sMem;
|
||||
|
||||
sMem.region = 0;
|
||||
sMem.pool = 0;
|
||||
|
||||
if ( _memSize <= 0 )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_alloc_mem: invalid size\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ( ROK != cmAllocEvnt( _memSize, MG_MAXBLKSIZE, &sMem, _memPtr ) )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_alloc_mem: cmAllocEvnt return failure for _memSize=%d\n",_memSize);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
// Note: memset done inside stack api
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_status_t mg_stack_get_mem(MgMgcoMsg* msg, Ptr* _memPtr, Size _memSize )
|
||||
{
|
||||
if ( _memSize <= 0 )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid size\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ( !msg )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid message\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if ( cmGetMem( (Ptr)msg, _memSize, (Ptr*)_memPtr ) != ROK )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed alloc_mg_stack_mem: get memory failed _memSize=%d\n", _memSize );
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
// Note: memset done inside stack api
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
switch_status_t mg_stack_free_mem(MgMgcoMsg* msg)
|
||||
{
|
||||
if ( !msg )
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid message\n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
cmFreeMem( (Ptr)msg );
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define MG_ACC_GETMEM(_ptr,_len,_memCp,_ret) \
|
||||
{ \
|
||||
ret = cmGetMem((_memCp), (_len), (Ptr *)&(_ptr)); \
|
||||
if( ret == ROK) \
|
||||
cmMemset((U8 *)(_ptr), (U8)0, (PTR)(_len)); \
|
||||
}
|
||||
|
||||
|
||||
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, CmMemListCp *memCp)
|
||||
{
|
||||
#ifdef GCP_ASN
|
||||
Size size;
|
||||
#endif
|
||||
S16 ret = ROK;
|
||||
|
||||
termId->name.pres.pres = PRSNT_NODEF;
|
||||
/* mg011.105: Bug fixes */
|
||||
termId->name.lcl.pres = PRSNT_NODEF;
|
||||
termId->name.lcl.len = cmStrlen((CONSTANT U8*)str);
|
||||
MG_ACC_GETMEM((termId->name.lcl.val), termId->name.lcl.len, memCp, ret);
|
||||
if( ret != ROK)
|
||||
RETVALUE(ret);
|
||||
|
||||
cmMemcpy((U8*)(termId->name.lcl.val), (CONSTANT U8*)str,termId->name.lcl.len);
|
||||
|
||||
#ifdef GCP_ASN
|
||||
/* Remove comment to fill other term ID
|
||||
termId->wildcard.num.pres = NOTPRSNT; */
|
||||
/* Remove comment to fill wilcard term ID */
|
||||
termId->wildcard.num.pres = PRSNT_NODEF;
|
||||
termId->wildcard.num.val = 1;
|
||||
size = ((sizeof(MgMgcoWildcardField*)));
|
||||
MG_ACC_GETMEM((termId->wildcard.wildcard),size,memCp, ret);
|
||||
if( ret != ROK)
|
||||
RETVALUE(ret);
|
||||
|
||||
MG_ACC_GETMEM( ((termId->wildcard.wildcard)[0]),sizeof(MgMgcoWildcardField),
|
||||
memCp, ret);
|
||||
if( ret != ROK)
|
||||
RETVALUE(ret);
|
||||
|
||||
termId->wildcard.wildcard[0]->pres = PRSNT_NODEF;
|
||||
termId->wildcard.wildcard[0]->len = 1;
|
||||
termId->wildcard.wildcard[0]->val[0] = 0x55;
|
||||
#endif /* GCP_ASN */
|
||||
|
||||
RETVALUE(ROK);
|
||||
}
|
||||
|
||||
switch_status_t mg_build_mgco_err_request(MgMgcoInd **errcmd,U32 trans_id, MgMgcoContextId *ctxt_id, U32 err, MgStr *errTxt)
|
||||
{
|
||||
MgMgcoInd *mgErr;
|
||||
S16 ret;
|
||||
|
||||
mgErr = NULLP;
|
||||
ret = ROK;
|
||||
|
||||
/* Allocate for AG error */
|
||||
mg_stack_alloc_mem((Ptr*)&mgErr, sizeof(MgMgcoInd));
|
||||
if (NULL == mgErr) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " mg_build_mgco_err_request Failed : memory alloc \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
/* Set transaction Id in the error request */
|
||||
mg_util_set_val_pres(mgErr->transId, trans_id);
|
||||
|
||||
/* Copy the context Id */
|
||||
mg_mem_copy(&mgErr->cntxtId,
|
||||
ctxt_id,
|
||||
sizeof(MgMgcoContextId));
|
||||
|
||||
/* Set the peerId */
|
||||
mgErr->peerId.pres = NOTPRSNT;
|
||||
|
||||
/* Set the error code */
|
||||
mg_util_set_pres(mgErr->err.pres.pres);
|
||||
mg_util_set_pres(mgErr->err.code.pres);
|
||||
mg_util_set_val_pres(mgErr->err.code, err);
|
||||
|
||||
if(errTxt->len)
|
||||
{
|
||||
mg_get_mem(&mgErr->memCp, (errTxt->len)*sizeof(U8), mgErr->err.text.val, &ret);
|
||||
if (ROK != ret) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " mg_build_mgco_err_request Failed : memory alloc \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
mgErr->err.text.pres = PRSNT_NODEF;
|
||||
mgErr->err.text.len = errTxt->len;
|
||||
mg_mem_copy(mgErr->err.text.val, errTxt->val, errTxt->len);
|
||||
}
|
||||
|
||||
/* Set the output value */
|
||||
*errcmd = mgErr;
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void mg_util_set_txn_string(MgStr *errTxt, U32 *txnId)
|
||||
{
|
||||
mg_zero((errTxt->val), sizeof(errTxt->val));
|
||||
errTxt->len = 0;
|
||||
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
|
||||
if (MG_TXN_INVALID == txnId )
|
||||
{
|
||||
mg_mem_copy((&errTxt->val[errTxt->len]), "TransactionId=0", 15);
|
||||
errTxt->len += 15;
|
||||
}
|
||||
|
||||
errTxt->val[errTxt->len] = '\"';
|
||||
errTxt->len += 1;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s:"
|
||||
"info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
|
||||
/* For Emacs:
|
||||
|
|
Loading…
Reference in New Issue