fixing issues found during seagull testing and add single common descriptors api
This commit is contained in:
parent
0bb82599c5
commit
63c53a858b
|
@ -166,6 +166,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
|
||||||
term = switch_core_alloc(pool, sizeof *term);
|
term = switch_core_alloc(pool, sizeof *term);
|
||||||
term->pool = pool;
|
term->pool = pool;
|
||||||
term->type = termtype;
|
term->type = termtype;
|
||||||
|
term->active_events = NULL;
|
||||||
|
|
||||||
if (termtype == MG_TERM_RTP) {
|
if (termtype == MG_TERM_RTP) {
|
||||||
/* Fill in local address and reserve an rtp port */
|
/* Fill in local address and reserve an rtp port */
|
||||||
|
|
|
@ -23,108 +23,85 @@ const char *mg_service_change_reason[] = {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Fun: handle_mg_add_cmd
|
* Fun: mg_prc_descriptors
|
||||||
*
|
*
|
||||||
* Desc: this api will handle the ADD request received from MG stack
|
* Desc: this api will process the descriptors received from MG stack
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, MgMgcoContextId* new_ctxtId)
|
switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *cmd, mg_termination_t* term)
|
||||||
{
|
{
|
||||||
MgMgcoContextId *ctxtId;
|
|
||||||
int descId;
|
|
||||||
MgStr errTxt;
|
|
||||||
MgMgcoInd *mgErr;
|
|
||||||
MgMgcoTermId *termId;
|
|
||||||
MgMgcoTermIdLst* termLst;
|
|
||||||
int err_code;
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
int is_rtp = 0x00;
|
|
||||||
char rtp_term_name[32];
|
|
||||||
int fmtCnt;
|
|
||||||
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add;
|
|
||||||
U32 txn_id = inc_cmd->transId.val;
|
|
||||||
MgMgcoLocalDesc *local;
|
|
||||||
MgMgcoRemoteDesc *remote;
|
|
||||||
MgMgcoLclCtlDesc *locCtl;
|
|
||||||
CmSdpInfo *sdp;
|
|
||||||
MgMgcoLocalParm *lclParm;
|
|
||||||
MgMgcoTermStateDesc *tstate;
|
|
||||||
CmSdpMedFmtRtpList *fmt_list;
|
|
||||||
MgMgcoTermStateParm *tsp;
|
|
||||||
TknU8 *fmt;
|
|
||||||
CmSdpMedProtoFmts *format;
|
CmSdpMedProtoFmts *format;
|
||||||
MgMgcoMediaDesc* inc_med_desc;
|
TknU8 *fmt;
|
||||||
MgMgcoAudRetParm *desc;
|
CmSdpMedFmtRtpList *fmt_list;
|
||||||
mg_context_t* mg_ctxt;
|
MgMgcoTermStateDesc *tstate;
|
||||||
|
int fmtCnt;
|
||||||
|
int i;
|
||||||
|
int descId = 0x00;
|
||||||
|
int j;
|
||||||
|
MgMgcoLocalParm *lclParm;
|
||||||
|
CmSdpInfo *sdp;
|
||||||
|
MgMgcoLclCtlDesc *locCtl;
|
||||||
|
MgMgcoTermStateParm *tsp;
|
||||||
|
MgMgcoAmmReq* desc = NULL;
|
||||||
|
MgMgcoLocalDesc *local;
|
||||||
|
MgMgcoRemoteDesc* remote;
|
||||||
|
|
||||||
memset(&rtp_term_name[0], 0, 32);
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"cmd->cmdType.val[%d]\n",cmd->cmdType.val);
|
||||||
|
|
||||||
|
switch (cmd->cmdType.val)
|
||||||
/********************************************************************/
|
{
|
||||||
ctxtId = &inc_cmd->contextId;
|
case CH_CMD_TYPE_IND:
|
||||||
termLst = mg_get_term_id_list(inc_cmd);
|
switch(cmd->u.mgCmdInd[0]->cmd.type.val)
|
||||||
termId = termLst->terms[0];
|
{
|
||||||
/* For Matt - termId->name.lcl.val - to get the termination id name */
|
case MGT_ADD:
|
||||||
|
{
|
||||||
/********************************************************************/
|
desc = &cmd->u.mgCmdInd[0]->cmd.u.add;
|
||||||
/* Validating ADD request *******************************************/
|
break;
|
||||||
|
}
|
||||||
/*-- NULL Context & ALL Context not applicable for ADD request --*/
|
case MGT_MOVE:
|
||||||
if ((NOTPRSNT != ctxtId->type.pres) &&
|
{
|
||||||
((MGT_CXTID_ALL == ctxtId->type.val) ||
|
desc = &cmd->u.mgCmdInd[0]->cmd.u.move;
|
||||||
(MGT_CXTID_NULL == ctxtId->type.val))) {
|
break;
|
||||||
|
}
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," ADD Request processing failed, Context ALL/NULL not allowed\n");
|
case MGT_MODIFY:
|
||||||
|
{
|
||||||
mg_util_set_ctxt_string(&errTxt, ctxtId);
|
desc = &cmd->u.mgCmdInd[0]->cmd.u.mod;
|
||||||
err_code = MGT_MGCO_RSP_CODE_PROT_ERROR;
|
break;
|
||||||
goto error;
|
}
|
||||||
|
default:
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Invalid cmd.type[%d] for descriptor processing \n",
|
||||||
|
cmd->u.mgCmdInd[0]->cmd.type.val);
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************/
|
if(NULL == desc){
|
||||||
/* Allocate context - if context type is CHOOSE */
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"No Valid descriptor found \n");
|
||||||
if ((NOTPRSNT != ctxtId->type.pres) &&
|
return SWITCH_STATUS_FALSE;
|
||||||
(MGT_CXTID_CHOOSE == ctxtId->type.val)){
|
|
||||||
|
|
||||||
mg_ctxt = megaco_choose_context(mg_profile);
|
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Context[%p] with context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);
|
|
||||||
|
|
||||||
/* fill Trillium Context structure with allocated context */
|
|
||||||
MG_SET_VAL_PRES(new_ctxtId->type, MGT_CXTID_OTHER);
|
|
||||||
MG_SET_VAL_PRES(new_ctxtId->val, mg_ctxt->context_id);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* context already present */
|
|
||||||
memcpy(new_ctxtId, &inc_cmd->contextId,sizeof(MgMgcoContextId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************/
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"descriptors[%d] found in-coming megaco request \n", desc->dl.num.val);
|
||||||
/* Allocate new RTP termination - If term type is CHOOSE */
|
|
||||||
if ((NOTPRSNT != termId->type.pres) &&
|
|
||||||
(MGT_TERMID_CHOOSE == termId->type.val)){
|
|
||||||
|
|
||||||
is_rtp = 0x01;
|
if(NOTPRSNT == desc->dl.num.pres){
|
||||||
strcpy(rtp_term_name,"rtp/1");
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"No descriptor found in-coming megaco request \n");
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
/* TODO - Matt */
|
|
||||||
/* allocate rtp term and associated the same to context */
|
|
||||||
/********************************************************************/
|
|
||||||
}else{ /* Physical termination */
|
|
||||||
/* TODO - Matt - associate physical termination to context */
|
|
||||||
}
|
}
|
||||||
/********************************************************************/
|
|
||||||
|
|
||||||
for (descId = 0; descId < cmd->dl.num.val; descId++) {
|
|
||||||
switch (cmd->dl.descs[descId]->type.val) {
|
for (descId = 0; descId < desc->dl.num.val; descId++) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"descriptors[%d] type in-coming megaco request \n", desc->dl.descs[descId]->type.val);
|
||||||
|
switch (desc->dl.descs[descId]->type.val) {
|
||||||
case MGT_MEDIADESC:
|
case MGT_MEDIADESC:
|
||||||
{
|
{
|
||||||
int mediaId;
|
int mediaId;
|
||||||
inc_med_desc = &cmd->dl.descs[descId]->u.media;
|
for (mediaId = 0; mediaId < desc->dl.descs[descId]->u.media.num.val; mediaId++) {
|
||||||
for (mediaId = 0; mediaId < cmd->dl.descs[descId]->u.media.num.val; mediaId++) {
|
MgMgcoMediaPar *mediaPar = desc->dl.descs[descId]->u.media.parms[mediaId];
|
||||||
MgMgcoMediaPar *mediaPar = cmd->dl.descs[descId]->u.media.parms[mediaId];
|
|
||||||
switch (mediaPar->type.val) {
|
switch (mediaPar->type.val) {
|
||||||
case MGT_MEDIAPAR_LOCAL:
|
case MGT_MEDIAPAR_LOCAL:
|
||||||
{
|
{
|
||||||
|
@ -269,19 +246,160 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MGT_REQEVTDESC:
|
||||||
|
{
|
||||||
|
MgMgcoReqEvtDesc* evt = &desc->dl.descs[descId]->u.evts;
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," Requested Event descriptor\n");
|
||||||
|
|
||||||
|
/* If we receive events from MGC , means clear any ongoing events */
|
||||||
|
/* as such we dont apply any events to term, so for us (as of now) clear events means clear active_events structure*/
|
||||||
|
|
||||||
|
if(NULL != term->active_events){
|
||||||
|
mgUtlDelMgMgcoReqEvtDesc(term->active_events);
|
||||||
|
free(term->active_events);
|
||||||
|
term->active_events = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
term->active_events = malloc(sizeof(*term->active_events));
|
||||||
|
|
||||||
|
/* copy requested event */
|
||||||
|
if(RFAILED == mgUtlCpyMgMgcoReqEvtDesc(term->active_events, evt, NULLP)){
|
||||||
|
free(term->active_events);
|
||||||
|
term->active_events = NULL;
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* print Requested event descriptor */
|
||||||
|
mgAccEvntPrntMgMgcoReqEvtDesc(term->active_events, stdout);
|
||||||
|
|
||||||
|
/* TODO - We can check for it/ito package*/
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MGT_SIGNALSDESC:
|
||||||
|
{
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," Requested Signal descriptor\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case MGT_MODEMDESC:
|
case MGT_MODEMDESC:
|
||||||
case MGT_MUXDESC:
|
case MGT_MUXDESC:
|
||||||
case MGT_REQEVTDESC:
|
|
||||||
case MGT_EVBUFDESC:
|
case MGT_EVBUFDESC:
|
||||||
case MGT_SIGNALSDESC:
|
|
||||||
case MGT_DIGMAPDESC:
|
case MGT_DIGMAPDESC:
|
||||||
case MGT_AUDITDESC:
|
case MGT_AUDITDESC:
|
||||||
case MGT_STATSDESC:
|
case MGT_STATSDESC:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Fun: handle_mg_add_cmd
|
||||||
|
*
|
||||||
|
* Desc: this api will handle the ADD request received from MG stack
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, MgMgcoContextId* new_ctxtId)
|
||||||
|
{
|
||||||
|
switch_status_t ret;
|
||||||
|
MgMgcoContextId *ctxtId;
|
||||||
|
MgStr errTxt;
|
||||||
|
MgMgcoInd *mgErr;
|
||||||
|
MgMgcoTermId *termId;
|
||||||
|
MgMgcoTermIdLst* termLst;
|
||||||
|
int err_code;
|
||||||
|
int is_rtp = 0x00;
|
||||||
|
char rtp_term_name[32];
|
||||||
|
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add;
|
||||||
|
U32 txn_id = inc_cmd->transId.val;
|
||||||
|
mg_termination_t* term = NULL;
|
||||||
|
MgMgcoMediaDesc* inc_med_desc;
|
||||||
|
MgMgcoAudRetParm *desc;
|
||||||
|
mg_context_t* mg_ctxt;
|
||||||
|
MgMgcoStreamDesc *stream;
|
||||||
|
MgMgcoLocalDesc *local;
|
||||||
|
MgMgcoRemoteDesc* remote;
|
||||||
|
CmSdpInfoSet *psdp;
|
||||||
|
CmSdpInfoSet *prsdp;
|
||||||
|
char* ipAddress = "192.168.1.1";
|
||||||
|
|
||||||
|
/* TODO - Kapil dummy line , will need to add with proper code */
|
||||||
|
inc_med_desc = &cmd->dl.descs[0]->u.media;
|
||||||
|
|
||||||
|
memset(&rtp_term_name[0], 0, 32);
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
ctxtId = &inc_cmd->contextId;
|
||||||
|
termLst = mg_get_term_id_list(inc_cmd);
|
||||||
|
termId = termLst->terms[0];
|
||||||
|
/* For Matt - termId->name.lcl.val - to get the termination id name */
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
/* Validating ADD request *******************************************/
|
||||||
|
|
||||||
|
/*-- NULL Context & ALL Context not applicable for ADD request --*/
|
||||||
|
if ((NOTPRSNT != ctxtId->type.pres) &&
|
||||||
|
((MGT_CXTID_ALL == ctxtId->type.val) ||
|
||||||
|
(MGT_CXTID_NULL == ctxtId->type.val))) {
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR," ADD Request processing failed, Context ALL/NULL not allowed\n");
|
||||||
|
|
||||||
|
mg_util_set_ctxt_string(&errTxt, ctxtId);
|
||||||
|
err_code = MGT_MGCO_RSP_CODE_PROT_ERROR;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
/* Allocate context - if context type is CHOOSE */
|
||||||
|
if ((NOTPRSNT != ctxtId->type.pres) &&
|
||||||
|
(MGT_CXTID_CHOOSE == ctxtId->type.val)){
|
||||||
|
|
||||||
|
mg_ctxt = megaco_choose_context(mg_profile);
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Context[%p] with context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);
|
||||||
|
|
||||||
|
/* fill Trillium Context structure with allocated context */
|
||||||
|
MG_SET_VAL_PRES(new_ctxtId->type, MGT_CXTID_OTHER);
|
||||||
|
MG_SET_VAL_PRES(new_ctxtId->val, mg_ctxt->context_id);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* context already present */
|
||||||
|
memcpy(new_ctxtId, &inc_cmd->contextId,sizeof(MgMgcoContextId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
/* Allocate new RTP termination - If term type is CHOOSE */
|
||||||
|
if ((NOTPRSNT != termId->type.pres) &&
|
||||||
|
(MGT_TERMID_CHOOSE == termId->type.val)){
|
||||||
|
|
||||||
|
is_rtp = 0x01;
|
||||||
|
strcpy(rtp_term_name,"rtp/1");
|
||||||
|
|
||||||
|
/* TODO - Matt */
|
||||||
|
/* allocate rtp term and associated the same to context */
|
||||||
|
/********************************************************************/
|
||||||
|
}else{ /* Physical termination */
|
||||||
|
/* TODO - Matt - associate physical termination to context */
|
||||||
|
}
|
||||||
|
/********************************************************************/
|
||||||
|
|
||||||
|
ret = mg_prc_descriptors(mg_profile, inc_cmd, term);
|
||||||
|
|
||||||
|
/* TODO - locally assigned SDP must be the part of termination...which we can use to fill responses*/
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
|
||||||
/* Matt - to provide the response SDP structure which needs to fill in ADD command response */
|
/* Matt - to provide the response SDP structure which needs to fill in ADD command response */
|
||||||
|
|
||||||
/* Matt - to indicate if there is any failure while processing add message */
|
/* Matt - to indicate if there is any failure while processing add message */
|
||||||
|
@ -362,81 +480,168 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
|
||||||
desc->type.val = MGT_MEDIADESC;
|
desc->type.val = MGT_MEDIADESC;
|
||||||
mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp);
|
mgUtlCpyMgMgcoMediaDesc(&desc->u.media, inc_med_desc, &rsp.u.mgCmdRsp[0]->memCp);
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
/* Most probably we need to add local descriptor */
|
/* Most probably we need to add local descriptor */
|
||||||
{
|
|
||||||
MgMgcoStreamDesc *stream;
|
|
||||||
MgMgcoLocalDesc *local;
|
|
||||||
MgMgcoRemoteDesc* remote;
|
|
||||||
CmSdpInfoSet *psdp;
|
|
||||||
CmSdpInfoSet *prsdp;
|
|
||||||
char* ipAddress = "192.168.1.1";
|
|
||||||
|
|
||||||
/* TODO - considering only one descriptor*/
|
/* TODO - considering only one descriptor*/
|
||||||
stream = &desc->u.media.parms[0]->u.stream;
|
stream = &desc->u.media.parms[0]->u.stream;
|
||||||
|
stream->pres.pres = PRSNT_NODEF;
|
||||||
|
stream->sl.pres.pres = PRSNT_NODEF;
|
||||||
|
local = &stream->sl.local;
|
||||||
|
remote = &stream->sl.remote;
|
||||||
|
|
||||||
|
if(!local->pres.pres) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Local stream media not present adding it \n");
|
||||||
|
|
||||||
|
/* allocating mem for local descriptor */
|
||||||
|
if (mgUtlGrowList((void ***)&desc->u.media.parms, sizeof(MgMgcoMediaPar),
|
||||||
|
&desc->u.media.num, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
||||||
|
{
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
desc->u.media.parms[desc->u.media.num.val-1]->type.pres = PRSNT_NODEF;
|
||||||
|
desc->u.media.parms[desc->u.media.num.val-1]->type.val = MGT_MEDIAPAR_STRPAR;
|
||||||
|
|
||||||
|
|
||||||
|
stream = &desc->u.media.parms[desc->u.media.num.val-1]->u.stream;
|
||||||
|
stream->pres.pres = PRSNT_NODEF;
|
||||||
|
stream->pres.val = 0x01;
|
||||||
|
stream->sl.pres.pres = PRSNT_NODEF;
|
||||||
|
stream->sl.pres.val = 0x01;
|
||||||
local = &stream->sl.local;
|
local = &stream->sl.local;
|
||||||
remote = &stream->sl.remote;
|
remote = &stream->sl.remote;
|
||||||
|
|
||||||
if(!local->pres.pres) {
|
memcpy(&stream->streamId, &desc->u.media.parms[0]->u.stream.streamId, sizeof(MgMgcoStreamId));
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Local stream media not present adding it \n");
|
|
||||||
local->pres.pres = PRSNT_NODEF;
|
|
||||||
psdp = &(local->sdp);
|
|
||||||
prsdp = &(remote->sdp);
|
|
||||||
|
|
||||||
if (mgUtlGrowList((void ***)&psdp->info, sizeof(CmSdpInfo),
|
local->pres.pres = PRSNT_NODEF;
|
||||||
&psdp->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
psdp = &(local->sdp);
|
||||||
|
prsdp = &(remote->sdp);
|
||||||
|
|
||||||
|
if (mgUtlGrowList((void ***)&psdp->info, sizeof(CmSdpInfo),
|
||||||
|
&psdp->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
||||||
|
{
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
psdp->info[0]->pres.pres = PRSNT_NODEF;
|
||||||
|
|
||||||
|
/* fill version */
|
||||||
|
/*memcpy(&psdp->info[0]->ver, &prsdp->info[0]->ver, sizeof(TknU16)); */
|
||||||
|
MG_INIT_TOKEN_VALUE(&(psdp->info[0]->ver),1);
|
||||||
|
|
||||||
|
/* fill orig */
|
||||||
|
MG_SET_TKNSTROSXL(psdp->info[0]->orig.orig.usrName, 1, "-",
|
||||||
|
&rsp.u.mgCmdRsp[0]->memCp);
|
||||||
|
MG_SET_TKNSTROSXL(psdp->info[0]->orig.orig.sessId, 1, "0",
|
||||||
|
&rsp.u.mgCmdRsp[0]->memCp);
|
||||||
|
MG_SET_TKNSTROSXL(psdp->info[0]->orig.orig.sessVer, 1, "0",
|
||||||
|
&rsp.u.mgCmdRsp[0]->memCp);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.netType.type),
|
||||||
|
CM_SDP_NET_TYPE_IN);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.addrType),
|
||||||
|
CM_SDP_ADDR_TYPE_IPV4);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.addrType),
|
||||||
|
CM_SDP_IPV4_IP_UNI);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.addrType),
|
||||||
|
CM_SDP_IPV4_IP_UNI);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[0]),
|
||||||
|
ipAddress[0]);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[1]),
|
||||||
|
ipAddress[1]);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[2]),
|
||||||
|
ipAddress[2]);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[3]),
|
||||||
|
ipAddress[3]);
|
||||||
|
|
||||||
|
/* fill session name */
|
||||||
|
/*memcpy(&psdp->info[0]->sessName, &prsdp->info[0]->sessName, sizeof(TknStrOSXL));*/
|
||||||
|
MG_SET_TKNSTROSXL(psdp->info[0]->sessName, 1, "-",&rsp.u.mgCmdRsp[0]->memCp);
|
||||||
|
|
||||||
|
|
||||||
|
/* fill info */
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[0]), ipAddress[0]);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[1]), ipAddress[1]);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[2]), ipAddress[2]);
|
||||||
|
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[3]), ipAddress[3]);
|
||||||
|
|
||||||
|
/* Fill the SDP Connection Info */
|
||||||
|
/* "c=" line - ipaddress */
|
||||||
|
/*memcpy(&psdp->info[0]->conn, &prsdp->info[0]->conn, sizeof(CmSdpConn));*/
|
||||||
|
|
||||||
|
/* fill media descriptors */
|
||||||
|
{
|
||||||
|
CmSdpMediaDescSet* med = &psdp->info[0]->mediaDescSet;
|
||||||
|
CmSdpMediaDesc* media;
|
||||||
|
|
||||||
|
if (mgUtlGrowList((void ***)&med->mediaDesc, sizeof(CmSdpMediaDesc),
|
||||||
|
&med->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
||||||
{
|
{
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
psdp->info[0]->pres.pres = PRSNT_NODEF;
|
media = med->mediaDesc[0];
|
||||||
|
|
||||||
/* fill version */
|
MG_INIT_TOKEN_VALUE(&(media->pres),1);
|
||||||
memcpy(&psdp->info[0]->ver, &prsdp->info[0]->ver, sizeof(TknU16));
|
|
||||||
|
|
||||||
/* fill orig */
|
/* Fill CmSdpMediaField */
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[0]), ipAddress[0]);
|
MG_INIT_TOKEN_VALUE(&(media->field.pres),1);
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[1]), ipAddress[1]);
|
MG_INIT_TOKEN_VALUE(&(media->field.mediaType),CM_SDP_MEDIA_AUDIO);
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[2]), ipAddress[2]);
|
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->orig.orig.sdpAddr.u.ip4.u.ip.b[3]), ipAddress[3]);
|
|
||||||
|
|
||||||
/* fill session name */
|
MG_INIT_TOKEN_VALUE(&(media->field.id.type),CM_SDP_VCID_PORT);
|
||||||
memcpy(&psdp->info[0]->sessName, &prsdp->info[0]->sessName, sizeof(TknStrOSXL));
|
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.type),CM_SDP_PORT_INT);
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.pres),1);
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.port.type),
|
||||||
|
CM_SDP_SPEC);
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.id.u.port.u.portInt.port.val), 2904);
|
||||||
|
|
||||||
/* fill info */
|
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[0]), ipAddress[0]);
|
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[1]), ipAddress[1]);
|
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[2]), ipAddress[2]);
|
|
||||||
MG_SET_VAL_PRES( (psdp->info[0]->conn.u.ip4.u.uniIp.b[3]), ipAddress[3]);
|
|
||||||
|
|
||||||
/* Fill the SDP Connection Info */
|
MG_INIT_TOKEN_VALUE(&(media->field.par.numProtFmts),1);
|
||||||
/* "c=" line - ipaddress */
|
MG_GETMEM((media->field.par.pflst),1*sizeof(CmSdpMedProtoFmts*),&rsp.u.mgCmdRsp[0]->memCp, ret);
|
||||||
memcpy(&psdp->info[0]->conn, &prsdp->info[0]->conn, sizeof(CmSdpConn));
|
MG_GETMEM((media->field.par.pflst[0]),sizeof(CmSdpMedProtoFmts),&rsp.u.mgCmdRsp[0]->memCp, ret);
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->prot.type),
|
||||||
|
CM_SDP_MEDIA_PROTO_RTP)
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->prot.u.subtype.type),
|
||||||
|
CM_SDP_PROTO_RTP_AVP);
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->protType),
|
||||||
|
CM_SDP_MEDIA_PROTO_RTP);
|
||||||
|
|
||||||
/* fill media descriptors */
|
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->u.rtp.num),1);
|
||||||
|
|
||||||
|
MG_GETMEM((media->field.par.pflst[0]->u.rtp.fmts),
|
||||||
|
1*sizeof(CmSdpU8OrNil *), &rsp.u.mgCmdRsp[0]->memCp, ret);
|
||||||
|
|
||||||
|
MG_GETMEM((media->field.par.pflst[0]->u.rtp.fmts[0]),
|
||||||
|
sizeof(CmSdpU8OrNil), &rsp.u.mgCmdRsp[0]->memCp, ret);
|
||||||
|
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->u.rtp.fmts[0]->type),
|
||||||
|
CM_SDP_SPEC);
|
||||||
|
|
||||||
|
MG_INIT_TOKEN_VALUE(&(media->field.par.pflst[0]->u.rtp.fmts[0]->val),
|
||||||
|
4);
|
||||||
|
|
||||||
|
/* Fill attribute if reqd */
|
||||||
{
|
{
|
||||||
CmSdpMediaDescSet* med = &psdp->mediaDescSet;
|
MG_INIT_TOKEN_VALUE(&(media->attrSet.numComp),1);
|
||||||
CmSdpMediaDesc* m;
|
MG_GETMEM((media->attrSet.attr),sizeof(CmSdpAttr*),&rsp.u.mgCmdRsp[0]->memCp, ret);
|
||||||
|
MG_GETMEM((media->attrSet.attr[0]),sizeof(CmSdpAttr),&rsp.u.mgCmdRsp[0]->memCp, ret);
|
||||||
if (mgUtlGrowList((void ***)&med->mediaDesc, sizeof(CmSdpMediaDesc),
|
MG_INIT_TOKEN_VALUE(&(media->attrSet.attr[0]->type),CM_SDP_ATTR_PTIME);
|
||||||
&med->numComp, &rsp.u.mgCmdRsp[0]->memCp) != ROK)
|
media->attrSet.attr[0]->u.ptime.pres = PRSNT_NODEF;
|
||||||
{
|
media->attrSet.attr[0]->u.ptime.val = 30;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR,"Grow List failed\n");
|
|
||||||
return SWITCH_STATUS_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m = med->mediaDesc[0];
|
}
|
||||||
|
|
||||||
|
printf("ret[%d]\n",ret);
|
||||||
|
|
||||||
m->pres.pres = PRSNT_NODEF;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("!local->pres.pres false \n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
else {
|
||||||
|
printf("!local->pres.pres false \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,27 +684,15 @@ error:
|
||||||
switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd)
|
switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd)
|
||||||
{
|
{
|
||||||
MgMgcoContextId *ctxtId;
|
MgMgcoContextId *ctxtId;
|
||||||
int descId;
|
|
||||||
MgStr errTxt;
|
MgStr errTxt;
|
||||||
MgMgcoInd *mgErr;
|
MgMgcoInd *mgErr;
|
||||||
MgMgcoTermId *termId;
|
MgMgcoTermId *termId;
|
||||||
MgMgcoTermIdLst* termLst;
|
MgMgcoTermIdLst* termLst;
|
||||||
|
mg_termination_t* term = NULL;
|
||||||
|
switch_status_t ret;
|
||||||
int err_code;
|
int err_code;
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
int fmtCnt;
|
|
||||||
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.mod;
|
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.mod;
|
||||||
U32 txn_id = inc_cmd->transId.val;
|
U32 txn_id = inc_cmd->transId.val;
|
||||||
MgMgcoLocalDesc *local;
|
|
||||||
MgMgcoRemoteDesc *remote;
|
|
||||||
MgMgcoLclCtlDesc *locCtl;
|
|
||||||
CmSdpInfo *sdp;
|
|
||||||
MgMgcoLocalParm *lclParm;
|
|
||||||
MgMgcoTermStateDesc *tstate;
|
|
||||||
CmSdpMedFmtRtpList *fmt_list;
|
|
||||||
MgMgcoTermStateParm *tsp;
|
|
||||||
TknU8 *fmt;
|
|
||||||
CmSdpMedProtoFmts *format;
|
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
ctxtId = &inc_cmd->contextId;
|
ctxtId = &inc_cmd->contextId;
|
||||||
|
@ -546,175 +739,14 @@ switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand
|
||||||
/* Kapil - If there is an error - send response back to MG stack with MGT_MGCO_RSP_CODE_NO_TERM_CTXT error code*/
|
/* Kapil - If there is an error - send response back to MG stack with MGT_MGCO_RSP_CODE_NO_TERM_CTXT error code*/
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
|
|
||||||
|
/* TODO - dummy code will replace with proper choose_termination api */
|
||||||
|
term = malloc(sizeof(*term));
|
||||||
|
term->active_events = NULL;
|
||||||
|
|
||||||
|
ret = mg_prc_descriptors(mg_profile, inc_cmd, term);
|
||||||
|
|
||||||
/* Media Descriptor processing same as ADD command */
|
/********************************************************************/
|
||||||
|
|
||||||
/* TODO - Will see If we can have common media_descriptor processing API which we can use for both ADD/MODIFY */
|
|
||||||
|
|
||||||
for (descId = 0; descId < cmd->dl.num.val; descId++) {
|
|
||||||
switch (cmd->dl.descs[descId]->type.val) {
|
|
||||||
case MGT_MEDIADESC:
|
|
||||||
{
|
|
||||||
int mediaId;
|
|
||||||
for (mediaId = 0; mediaId < cmd->dl.descs[descId]->u.media.num.val; mediaId++) {
|
|
||||||
MgMgcoMediaPar *mediaPar = cmd->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");
|
|
||||||
/* Matt - check local descriptor processing */
|
|
||||||
local = &mediaPar->u.local;
|
|
||||||
sdp = local->sdp.info[0];
|
|
||||||
for (i = 0; i < sdp->mediaDescSet.numComp.val; i++) {
|
|
||||||
/* sdp formats */
|
|
||||||
for (j = 0; j <
|
|
||||||
sdp->mediaDescSet.mediaDesc[i]->field.par.numProtFmts.val; j++)
|
|
||||||
{
|
|
||||||
format = sdp->mediaDescSet.mediaDesc[i]->field.par.pflst[j];
|
|
||||||
/* Matt - format has field for T38 also */
|
|
||||||
if ((format->protType.pres != NOTPRSNT) &&
|
|
||||||
(format->protType.val == CM_SDP_MEDIA_PROTO_RTP)) {
|
|
||||||
|
|
||||||
/* protocol type RTP */
|
|
||||||
fmt_list = &format->u.rtp;
|
|
||||||
|
|
||||||
/* print format */
|
|
||||||
for(fmtCnt = 0; fmtCnt < fmt_list->num.val; fmtCnt++){
|
|
||||||
fmt = &fmt_list->fmts[i]->val;
|
|
||||||
if(fmt->pres == NOTPRSNT) continue;
|
|
||||||
printf("Format [%d]\n", fmt->val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MGT_MEDIAPAR_REMOTE:
|
|
||||||
{
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_REMOTE");
|
|
||||||
/* Matt - check remote descriptor processing */
|
|
||||||
remote = &mediaPar->u.remote;
|
|
||||||
sdp = remote->sdp.info[0];
|
|
||||||
/* for Matt - same like local descriptor */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case MGT_MEDIAPAR_LOCCTL:
|
|
||||||
{
|
|
||||||
/* Matt - check Local Control descriptor processing */
|
|
||||||
locCtl = &mediaPar->u.locCtl;
|
|
||||||
for (i = 0; i < locCtl->num.val; i++){
|
|
||||||
lclParm = locCtl->parms[i];
|
|
||||||
if (PRSNT_NODEF == lclParm->type.pres){
|
|
||||||
switch(lclParm->type.val)
|
|
||||||
{
|
|
||||||
case MGT_LCLCTL_MODE:
|
|
||||||
{
|
|
||||||
/* Mode Property */
|
|
||||||
printf("MGT_LCLCTL_MODE - Mode value [%d]\n", lclParm->u.mode.val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MGT_LCLCTL_RESVAL:
|
|
||||||
{
|
|
||||||
/* Reserve Value */
|
|
||||||
printf("MGT_LCLCTL_RESVAL: Reserve Value[%d] \n", lclParm->u.resVal.val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MGT_LCLCTL_RESGRP:
|
|
||||||
{
|
|
||||||
/* Reserve group */
|
|
||||||
printf("MGT_LCLCTL_RESGRP: Reserve Group[%d]\n", lclParm->u.resGrp.val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MGT_LCLCTL_PROPPARM:
|
|
||||||
{
|
|
||||||
/* Properties (of a termination) */
|
|
||||||
/* Matt - See how we can apply this to a termination */
|
|
||||||
printf("MGT_LCLCTL_PROPPARM: \n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
printf("Invalid local control descriptor type[%d]\n",lclParm->type.val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_LOCCTL");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MGT_MEDIAPAR_TERMST:
|
|
||||||
{
|
|
||||||
/* Matt - apply termination state descriptor */
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_TERMST");
|
|
||||||
tstate = &mediaPar->u.tstate;
|
|
||||||
for (i = 0; i < tstate->numComp.val; i++)
|
|
||||||
{
|
|
||||||
/* Matt to see how to apply below descriptors to a termination */
|
|
||||||
tsp = tstate->trmStPar[i];
|
|
||||||
if (PRSNT_NODEF == tsp->type.pres) {
|
|
||||||
switch(tsp->type.val)
|
|
||||||
{
|
|
||||||
case MGT_TERMST_PROPLST:
|
|
||||||
{
|
|
||||||
/* Matt to see how to apply properties to a termination */
|
|
||||||
/* Properties of a termination */
|
|
||||||
printf("MGT_TERMST_PROPLST:\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MGT_TERMST_EVTBUFCTL:
|
|
||||||
{
|
|
||||||
/* Event /buffer Control Properties */
|
|
||||||
printf(" MGT_TERMST_EVTBUFCTL: value[%d]\n", tsp->u.evtBufCtl.val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MGT_TERMST_SVCST:
|
|
||||||
{
|
|
||||||
/* Service State Properties */
|
|
||||||
printf(" MGT_TERMST_SVCST: value[%d]\n", tsp->u.svcState.val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
printf("Invalid termination state descriptor type[%d]\n",tsp->type.val);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Matt - to provide the response SDP structure which needs to fill in Modify command response */
|
/* Matt - to provide the response SDP structure which needs to fill in Modify command response */
|
||||||
|
|
||||||
|
@ -724,6 +756,55 @@ switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand
|
||||||
|
|
||||||
/* Kapil - to fill the response structure and call the response API to send Modify response */
|
/* Kapil - to fill the response structure and call the response API to send Modify response */
|
||||||
|
|
||||||
|
{ /* send response */
|
||||||
|
|
||||||
|
MgMgcoCommand rsp;
|
||||||
|
int ret = 0x00;
|
||||||
|
|
||||||
|
memset(&rsp,0, sizeof(rsp));
|
||||||
|
|
||||||
|
/*copy transaction-id*/
|
||||||
|
memcpy(&rsp.transId, &inc_cmd->transId,sizeof(MgMgcoTransId));
|
||||||
|
|
||||||
|
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
|
||||||
|
memcpy(&rsp.contextId, &inc_cmd->contextId,sizeof(MgMgcoContextId));
|
||||||
|
|
||||||
|
/*copy peer identifier */
|
||||||
|
memcpy(&rsp.peerId, &inc_cmd->peerId,sizeof(TknU32));
|
||||||
|
|
||||||
|
/*fill response structue */
|
||||||
|
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&rsp.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
rsp.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
|
||||||
|
rsp.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
|
||||||
|
rsp.u.mgCmdRsp[0]->type.val = MGT_MODIFY;
|
||||||
|
rsp.u.mgCmdRsp[0]->u.mod.pres.pres = PRSNT_NODEF;
|
||||||
|
rsp.u.mgCmdRsp[0]->u.mod.termIdLst.num.pres = PRSNT_NODEF;
|
||||||
|
rsp.u.mgCmdRsp[0]->u.mod.termIdLst.num.val = 1;
|
||||||
|
|
||||||
|
mgUtlAllocMgMgcoTermIdLst(&rsp.u.mgCmdRsp[0]->u.mod.termIdLst, &inc_cmd->u.mgCmdReq[0]->cmd.u.mod.termIdLst);
|
||||||
|
|
||||||
|
#ifdef GCP_VER_2_1
|
||||||
|
termId = rsp.u.mgCmdRsp[0]->u.mod.termIdLst.terms[0];
|
||||||
|
#else
|
||||||
|
termId = &(rsp.u.mgCmdRsp[0]->u.mod.termId);
|
||||||
|
#endif
|
||||||
|
/*mg_fill_mgco_termid(termId, (char*)"term1",&req->u.mgCmdRsp[0]->memCp);*/
|
||||||
|
|
||||||
|
/* We will always send one command at a time..*/
|
||||||
|
rsp.cmdStatus.pres = PRSNT_NODEF;
|
||||||
|
rsp.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
|
||||||
|
|
||||||
|
rsp.cmdType.pres = PRSNT_NODEF;
|
||||||
|
rsp.cmdType.val = CH_CMD_TYPE_RSP;
|
||||||
|
|
||||||
|
|
||||||
|
ret = sng_mgco_send_cmd(mg_profile->idx, &rsp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
error:
|
error:
|
||||||
|
@ -755,7 +836,7 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
|
||||||
int err_code;
|
int err_code;
|
||||||
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add;
|
MgMgcoAmmReq *cmd = &inc_cmd->u.mgCmdInd[0]->cmd.u.add;
|
||||||
U32 txn_id = inc_cmd->transId.val;
|
U32 txn_id = inc_cmd->transId.val;
|
||||||
mg_context_t* mg_ctxt;
|
mg_context_t* mg_ctxt = NULL;
|
||||||
uint8_t wild = 0x00;
|
uint8_t wild = 0x00;
|
||||||
|
|
||||||
wild = inc_cmd->u.mgCmdReq[0]->wild.pres;
|
wild = inc_cmd->u.mgCmdReq[0]->wild.pres;
|
||||||
|
@ -792,6 +873,8 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
/* TODO - see if we receive wild card SUB for ALL context */
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/* Matt - TODO - check if we have terminations in the context */
|
/* Matt - TODO - check if we have terminations in the context */
|
||||||
|
@ -800,15 +883,20 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Received context_id[%d]\n", ctxtId->val.val);
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Received context_id[%d]\n", ctxtId->val.val);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*find context based on received context-id */
|
/*find context based on received context-id */
|
||||||
mg_ctxt = megaco_get_context(mg_profile, ctxtId->val.val);
|
mg_ctxt = megaco_get_context(mg_profile, ctxtId->val.val);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Found Context[%p] for context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);
|
if(mg_ctxt){
|
||||||
|
|
||||||
/* TODO - remove terminations from context....as if now there is no termination associated with Context */
|
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Found Context[%p] for context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);
|
||||||
|
|
||||||
/* release context*/
|
/* TODO - remove terminations from context....as if now there is no termination associated with Context */
|
||||||
megaco_release_context(mg_ctxt);
|
|
||||||
|
/* release context*/
|
||||||
|
megaco_release_context(mg_ctxt);
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************************************************************/
|
/*************************************************************************************************************************/
|
||||||
/* resp code -- begin */
|
/* resp code -- begin */
|
||||||
|
|
|
@ -112,6 +112,15 @@ typedef enum {
|
||||||
cmMemcpy((U8 *)(_tkn)->val, (CONSTANT U8 *)(_val), (_len)); \
|
cmMemcpy((U8 *)(_tkn)->val, (CONSTANT U8 *)(_val), (_len)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MG_SET_TKNSTROSXL(_tkn, _len, _val, _mem)\
|
||||||
|
{\
|
||||||
|
(_tkn).pres = PRSNT_NODEF;\
|
||||||
|
(_tkn).len = (_len);\
|
||||||
|
cmGetMem((Ptr)_mem, (Size)((_len)*sizeof(U8)), (Ptr*)&((_tkn).val));\
|
||||||
|
cmMemcpy((U8*)((_tkn).val), (U8*)(_val), _len);\
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_status_t mg_prc_descriptors(megaco_profile_t* mg_profile, MgMgcoCommand *inc_cmd, mg_termination_t* term);
|
||||||
void handle_sng_log(uint8_t level, char *fmt, ...);
|
void handle_sng_log(uint8_t level, char *fmt, ...);
|
||||||
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* msg);
|
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* msg);
|
||||||
void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* msg);
|
void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* msg);
|
||||||
|
|
|
@ -438,6 +438,9 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
||||||
|
|
||||||
memset(&out_ctxt,0,sizeof(out_ctxt));
|
memset(&out_ctxt,0,sizeof(out_ctxt));
|
||||||
|
|
||||||
|
inc_context = &cmd->contextId;
|
||||||
|
memcpy(&out_ctxt, inc_context,sizeof(MgMgcoContextId));
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Received Command Type[%s] \n", __PRETTY_FUNCTION__, PRNT_MG_CMD_TYPE(cmd->cmdType.val));
|
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 */
|
/* validate Transaction Id */
|
||||||
|
@ -506,7 +509,6 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
||||||
|
|
||||||
|
|
||||||
/* Validate Context - if context is specified then check if its present with us */
|
/* Validate Context - if context is specified then check if its present with us */
|
||||||
inc_context = &cmd->contextId;
|
|
||||||
MG_ZERO(&ctxtId, sizeof(MgMgcoContextId));
|
MG_ZERO(&ctxtId, sizeof(MgMgcoContextId));
|
||||||
memcpy(&ctxtId, inc_context, sizeof(MgMgcoContextId));
|
memcpy(&ctxtId, inc_context, sizeof(MgMgcoContextId));
|
||||||
|
|
||||||
|
@ -535,7 +537,6 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
||||||
goto error1;
|
goto error1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&out_ctxt, inc_context,sizeof(MgMgcoContextId));
|
|
||||||
|
|
||||||
switch(cmd->cmdType.val)
|
switch(cmd->cmdType.val)
|
||||||
{
|
{
|
||||||
|
@ -557,7 +558,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
||||||
{
|
{
|
||||||
/*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod;*/
|
/*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod;*/
|
||||||
handle_mg_modify_cmd(mg_profile, cmd);
|
handle_mg_modify_cmd(mg_profile, cmd);
|
||||||
mg_send_modify_rsp(suId, cmd);
|
/*mg_send_modify_rsp(suId, cmd);*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MGT_MOVE:
|
case MGT_MOVE:
|
||||||
|
@ -619,9 +620,10 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "cmd->cmdStatus.val[%d]\n",cmd->cmdStatus.val);
|
||||||
/* END OF TXN received - means last command in txn to process.
|
/* END OF TXN received - means last command in txn to process.
|
||||||
* Send response to peer */
|
* Send response to peer */
|
||||||
if(CH_CMD_STATUS_END_OF_TXN == cmd->cmdStatus.val){
|
/*if(CH_CMD_STATUS_END_OF_TXN == cmd->cmdStatus.val)*/{
|
||||||
mg_send_end_of_axn(suId, &cmd->transId, &out_ctxt, &cmd->peerId);
|
mg_send_end_of_axn(suId, &cmd->transId, &out_ctxt, &cmd->peerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,6 +637,9 @@ error:
|
||||||
mg_build_mgco_err_request(&mgErr, txn_id, &ctxtId, err_code, &errTxt)) {
|
mg_build_mgco_err_request(&mgErr, txn_id, &ctxtId, err_code, &errTxt)) {
|
||||||
sng_mgco_send_err(suId, mgErr);
|
sng_mgco_send_err(suId, mgErr);
|
||||||
}
|
}
|
||||||
|
if(CH_CMD_STATUS_END_OF_TXN == cmd->cmdStatus.val){
|
||||||
|
mg_send_end_of_axn(suId, &cmd->transId, &out_ctxt, &cmd->peerId);
|
||||||
|
}
|
||||||
error1:
|
error1:
|
||||||
mg_free_cmd(cmd);
|
mg_free_cmd(cmd);
|
||||||
return;
|
return;
|
||||||
|
@ -654,7 +659,7 @@ void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* txn_sta_ind)
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__);
|
||||||
|
|
||||||
/*dump information*/
|
/*dump information*/
|
||||||
/*mgAccEvntPrntMgMgcoInd(txn_sta_ind, stdout);*/
|
mgAccEvntPrntMgMgcoInd(txn_sta_ind, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************************************************************/
|
/*****************************************************************************************************************************/
|
||||||
|
|
|
@ -42,7 +42,7 @@ typedef enum {
|
||||||
MEGACO_CODEC_ILBC,
|
MEGACO_CODEC_ILBC,
|
||||||
|
|
||||||
/* Nothing below this line */
|
/* Nothing below this line */
|
||||||
MEGACO_CODEC_INVALID = 0xFFFFFFFF
|
MEGACO_CODEC_INVALID = 0xFFFFFF
|
||||||
} megaco_codec_t;
|
} megaco_codec_t;
|
||||||
|
|
||||||
typedef struct mg_peer_profile_s{
|
typedef struct mg_peer_profile_s{
|
||||||
|
@ -90,6 +90,7 @@ typedef struct mg_termination_s {
|
||||||
const char *uuid; /*!< UUID of the associated FS channel, or NULL if it's not activated */
|
const char *uuid; /*!< UUID of the associated FS channel, or NULL if it's not activated */
|
||||||
mg_context_t *context; /*!< Context in which this termination is connected, or NULL */
|
mg_context_t *context; /*!< Context in which this termination is connected, or NULL */
|
||||||
megaco_profile_t *profile; /*!< Parent MG profile */
|
megaco_profile_t *profile; /*!< Parent MG profile */
|
||||||
|
MgMgcoReqEvtDesc *active_events; /* !< active megaco events */
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
|
Loading…
Reference in New Issue