service change code modification
This commit is contained in:
parent
d139a8ef63
commit
9a817c7aa2
|
@ -74,6 +74,7 @@ mg_context_t *megaco_get_context(megaco_profile_t *profile, uint32_t context_id)
|
|||
mg_context_t *megaco_choose_context(megaco_profile_t *profile)
|
||||
{
|
||||
mg_context_t *ctx;
|
||||
int i = 0x0;;
|
||||
|
||||
switch_thread_rwlock_wrlock(profile->contexts_rwlock);
|
||||
/* Try the next one */
|
||||
|
@ -86,7 +87,7 @@ mg_context_t *megaco_choose_context(megaco_profile_t *profile)
|
|||
if ((profile->contexts_bitmap[profile->next_context_id % 8] & (1 << (profile->next_context_id / 8))) == 0) {
|
||||
/* Found! */
|
||||
profile->contexts_bitmap[profile->next_context_id % 8] |= 1 << (profile->next_context_id / 8);
|
||||
int i = profile->next_context_id % MG_CONTEXT_MODULO;
|
||||
i = profile->next_context_id % MG_CONTEXT_MODULO;
|
||||
ctx = malloc(sizeof *ctx);
|
||||
ctx->context_id = profile->next_context_id;
|
||||
ctx->profile = profile;
|
||||
|
|
|
@ -26,6 +26,7 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre
|
|||
int argc;
|
||||
char* argv[10];
|
||||
char* dup = NULL;
|
||||
int wild = 0x00;
|
||||
megaco_profile_t* profile = NULL;
|
||||
|
||||
if (zstr(cmd)) {
|
||||
|
@ -107,12 +108,16 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre
|
|||
}
|
||||
|
||||
if (profile) {
|
||||
if(!zstr(argv[7]) && !strcasecmp(argv[7],"wild")){
|
||||
wild = 0x01;
|
||||
}
|
||||
|
||||
printf("Input to Send Service Change command : "
|
||||
"Profile Name[%s], term-id[%s] method[%s] reason[%s] \n",
|
||||
profile->name, argv[4], argv[5], argv[6]);
|
||||
|
||||
megaco_profile_release(profile);
|
||||
mg_send_service_change(profile->idx, argv[4], atoi(argv[5]), atoi(argv[6]));
|
||||
mg_send_service_change(profile->idx, argv[4], atoi(argv[5]), atoi(argv[6]),wild);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such profile\n");
|
||||
}
|
||||
|
|
|
@ -273,10 +273,14 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq)
|
|||
MgMgcoMediaDesc* media;
|
||||
MgMgcoCtxt ctxt;
|
||||
switch_status_t ret;
|
||||
uint8_t wild = 0x00;
|
||||
|
||||
memset(&reply, 0, sizeof(reply));
|
||||
|
||||
audit = &auditReq->u.mgCmdReq[0]->cmd.u.aval;
|
||||
wild = auditReq->u.mgCmdReq[0]->wild.pres;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"%s :: wild card request = %s \n",__FUNCTION__,(1==wild)?"TRUE":"FALSE");
|
||||
|
||||
if(NOTPRSNT == audit->pres.pres){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Audit structure not present..rejecting \n");
|
||||
|
@ -498,6 +502,11 @@ switch_status_t handle_mg_audit_cmd( SuId suId, MgMgcoCommand *auditReq)
|
|||
reply.cmdType.pres = PRSNT_NODEF;
|
||||
reply.cmdType.val = CH_CMD_TYPE_RSP;
|
||||
|
||||
if(wild){
|
||||
reply.u.mgCmdRsp[0]->wild.pres = PRSNT_NODEF;
|
||||
}
|
||||
|
||||
|
||||
/* send command reply */
|
||||
sng_mgco_send_cmd(suId, &reply);
|
||||
|
||||
|
@ -942,9 +951,12 @@ switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req)
|
|||
int ret = 0x00;
|
||||
MgMgcoTermId *termId;
|
||||
MgMgcoCtxt ctxt;
|
||||
uint8_t wild = 0x00;
|
||||
|
||||
memset(&cmd,0, sizeof(cmd));
|
||||
|
||||
wild = req->u.mgCmdReq[0]->wild.pres;
|
||||
|
||||
/*copy transaction-id*/
|
||||
memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
|
||||
|
||||
|
@ -959,6 +971,10 @@ switch_status_t mg_send_subtract_rsp(SuId suId, MgMgcoCommand *req)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if(wild){
|
||||
cmd.u.mgCmdRsp[0]->wild.pres = PRSNT_NODEF;
|
||||
}
|
||||
|
||||
cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||
cmd.u.mgCmdRsp[0]->type.val = MGT_SUB;
|
||||
|
@ -1007,7 +1023,7 @@ U32 get_txn_id(){
|
|||
* SuId - Service User ID for MG SAP - it will be same like mg_profile_t->idx (refer to media_gateway_xml.c->mg_sap_id)
|
||||
* term_name - String format defined termination name
|
||||
*/
|
||||
switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason)
|
||||
switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason,uint8_t wild)
|
||||
{
|
||||
MgMgcoSvcChgPar srvPar;
|
||||
MgMgcoTermId* termId;
|
||||
|
@ -1054,9 +1070,6 @@ switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t
|
|||
|
||||
/*mgUtlCpyMgMgcoSvcChgPar(&svc->parm, &srvPar, &request.u.mgCmdReq[0]->memCp);*/
|
||||
|
||||
printf("reason[%p = %s], len[%d]\n",svc->parm.reason.val, svc->parm.reason.val, svc->parm.reason.len);
|
||||
|
||||
|
||||
if (mgUtlGrowList((void ***)&svc->termIdLst.terms, sizeof(MgMgcoTermIdLst),
|
||||
&svc->termIdLst.num, &request.u.mgCmdReq[0]->memCp) != ROK)
|
||||
{
|
||||
|
@ -1073,8 +1086,12 @@ switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t
|
|||
|
||||
mg_fill_mgco_termid(termId, (char*)term_name ,strlen(term_name), &request.u.mgCmdReq[0]->memCp);
|
||||
|
||||
if(wild){
|
||||
request.u.mgCmdReq[0]->wild.pres = PRSNT_NODEF;
|
||||
}
|
||||
|
||||
printf("reason[%p = %s], len[%d]\n",svc->parm.reason.val, svc->parm.reason.val, svc->parm.reason.len);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO,"Sending %s Service Change for termId[%s] with reason[%s], len[%d]\n",
|
||||
((1==wild)?"WildCard":"Non Wild Card"), term_name, svc->parm.reason.val, svc->parm.reason.len);
|
||||
|
||||
sng_mgco_send_cmd(suId, &request);
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ switch_status_t mg_send_heartbeat_audit_rsp( SuId suId, MgMgcoCommand *auditReq)
|
|||
void mg_get_time_stamp(MgMgcoTimeStamp *timeStamp);
|
||||
switch_status_t mg_fill_svc_change(MgMgcoSvcChgPar *srvPar, uint8_t method, const char *reason);
|
||||
void mg_fill_null_context(MgMgcoContextId* ctxt);
|
||||
switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason);
|
||||
switch_status_t mg_send_service_change(SuId suId, const char* term_name, uint8_t method, MgServiceChangeReason_e reason,uint8_t wild);
|
||||
switch_status_t mg_create_mgco_command(MgMgcoCommand *cmd, uint8_t apiType, uint8_t cmdType);
|
||||
|
||||
|
||||
|
|
|
@ -19,15 +19,6 @@ 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(SuId suId, MgMgcoCommand *req, 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,58 +160,9 @@ 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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static switch_status_t mgco_parse_local_sdp(mg_termination_t *term, CmSdpInfoSet *sdp)
|
||||
{
|
||||
int i;
|
||||
|
@ -263,7 +205,7 @@ static switch_status_t mgco_parse_local_sdp(mg_termination_t *term, CmSdpInfoSet
|
|||
CmSdpAttr *a = s->attrSet.attr[mediaId];
|
||||
local_sdp->info[i]->attrSet.attr[mediaId] = switch_core_alloc(term->context->pool, sizeof(CmSdpAttr));
|
||||
*(local_sdp->info[i]->attrSet.attr[mediaId]) = *a;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Media %p\n", a);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Media %p\n", (void*)a);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +228,10 @@ static switch_status_t mgco_parse_local_sdp(mg_termination_t *term, CmSdpInfoSet
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
|
||||
{
|
||||
|
@ -530,7 +475,8 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
|||
{
|
||||
case MGT_ADD:
|
||||
{
|
||||
handle_mg_add_cmd(suId, cmd, &cmd->u.mgCmdInd[0]->cmd.u.add);
|
||||
handle_mg_add_cmd(&cmd->u.mgCmdInd[0]->cmd.u.add);
|
||||
mg_send_add_rsp(suId, cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -632,469 +578,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(SuId suId, MgMgcoCommand *req, MgMgcoAmmReq *addReq)
|
||||
{
|
||||
int descId;
|
||||
mg_context_t *ctx = NULL;
|
||||
|
||||
MgMgcoCommand cmd;
|
||||
int ret = 0x00;
|
||||
MgMgcoTermId *termId;
|
||||
MgMgcoCtxt ctxt;
|
||||
|
||||
memset(&cmd,0, sizeof(cmd));
|
||||
|
||||
/*copy transaction-id*/
|
||||
memcpy(&cmd.transId, &req->transId, sizeof(MgMgcoTransId));
|
||||
|
||||
if (req->contextId.type.val == MGT_CXTID_CHOOSE) {
|
||||
ctx = megaco_choose_context(NULL);
|
||||
} else if (req->contextId.type.val == MGT_CXTID_OTHER) {
|
||||
ctx = megaco_get_context(NULL, req->contextId.val.val);
|
||||
}
|
||||
|
||||
|
||||
/*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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
/* FIXME */
|
||||
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, &cmd.contextId,sizeof(MgMgcoContextId));
|
||||
memcpy(&ctxt.peerId, &req->peerId,sizeof(TknU32));
|
||||
ctxt.cmdStatus.pres = PRSNT_NODEF;
|
||||
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN;
|
||||
|
||||
return sng_mgco_send_axn_req(suId, &ctxt);;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
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", _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_free_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:
|
||||
* Local Variables:
|
||||
|
|
Loading…
Reference in New Issue