From 79702bc0d2aa1fe4086c6108633181bf2d9a0a68 Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Wed, 20 Jun 2012 21:34:04 -0400 Subject: [PATCH 01/11] start implementing command handlers --- .gitignore | 3 + libs/freetdm/mod_freetdm/tdm.c | 2 +- src/include/switch_apr.h | 3 +- .../mod_media_gateway/media_gateway_stack.c | 3 +- .../mod_media_gateway/media_gateway_xml.c | 1 + .../mod_media_gateway/mod_media_gateway.c | 189 ++++++++++++++++++ 6 files changed, 197 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 55e1e9856b..3c0fd7cf40 100644 --- a/.gitignore +++ b/.gitignore @@ -199,3 +199,6 @@ src/mod/formats/mod_shout/*/*/mod_shout.log /src/mod/languages/mod_managed/x64/Release_CLR/FREESWITCH.MANAGED.DLL.metagen /src/mod/languages/mod_managed/x64/Release_CLR/RSAENH.DLL.bi /src/mod/languages/mod_managed/x64/Release_CLR/TZRES.DLL.bi + +src/include/switch_apr.h +.gitignore \ No newline at end of file diff --git a/libs/freetdm/mod_freetdm/tdm.c b/libs/freetdm/mod_freetdm/tdm.c index 935411867b..61a145ed3b 100644 --- a/libs/freetdm/mod_freetdm/tdm.c +++ b/libs/freetdm/mod_freetdm/tdm.c @@ -109,7 +109,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi ftdm_codec_t codec; uint32_t interval; - ctdm_private_t *tech_pvt; + ctdm_private_t *tech_pvt = NULL; if (zstr(szchanid) || zstr(szspanid)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Both "kSPAN_ID" and "kCHAN_ID" have to be set.\n"); diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index 0c8673570f..e125eb9390 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -773,7 +773,8 @@ typedef gid_t switch_gid_t; typedef ino_t switch_ino_t; typedef dev_t switch_dev_t; #endif - typedef off64_t switch_off_t; + +typedef off_t switch_off_t; /** * Structure for referencing file information diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index ebc7b869f6..51935b9c8d 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -256,8 +256,7 @@ switch_status_t sng_mgco_start(megaco_profile_t* profile ) else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mgco_mg_tsap_enable_cntrl SUCCESS \n"); } - - mgco_mg_enble_debug(); + //mgco_mg_enable_debug(); return SWITCH_STATUS_SUCCESS; } diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index ba5c20aabb..d43a0e96ce 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -243,6 +243,7 @@ static switch_status_t modify_mid(char* mid) sprintf(mid,"[%s]",dup); }else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid input MID string[%s]\n",mid); + free(dup); return SWITCH_STATUS_FALSE; } diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 30de4f86fc..b249e98896 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -130,11 +130,200 @@ void handle_sng_log(uint8_t level, char *fmt, ...) va_end(ptr); } +static void mgco_print_sdp(CmSdpInfoSet *sdp) +{ + int i; + +// XXX check if we can use that for debug: +// cmUnpkCmSdpInfoSet(<#CmSdpInfoSet *param#>, <#Ptr ptr#>, <#CmIntfVer intfVer#>, <#Buffer *mBuf#>); + + + 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) { + size_t txnIter; + /*TODO*/ + if(msg->body.type.val == MGT_TXN) + { + /* Loop over transaction list */ + for(txnIter=0;txnIterbody.u.tl.num.val;txnIter++) + { + switch(msg->body.u.tl.txns[txnIter]->type.val) { + case MGT_TXNREQ: + { + MgMgcoTxnReq* txnReq; + MgMgcoTransId transId; /* XXX */ + int axnIter; + txnReq = &(msg->body.u.tl.txns[txnIter]->u.req); + + /* Loop over action list */ + for (axnIter=0;axnIteral.num.val;axnIter++) { + MgMgcoActionReq *actnReq; + MgMgcoContextId ctxId; + int cmdIter; + + actnReq = txnReq->al.actns[axnIter]; + ctxId = actnReq->cxtId; /* XXX */ + + if (actnReq->pres.pres == NOTPRSNT) { + continue; + } + + /* Loop over command list */ + for (cmdIter=0; cmdIter < (actnReq->cl.num.val); cmdIter++) { + MgMgcoCommandReq *cmdReq = actnReq->cl.cmds[cmdIter]; + MgMgcoTermId *termId = NULLP; + + switch (cmdReq->cmd.type.val) { + case MGT_ADD: + { + MgMgcoAmmReq *addReq = &cmdReq->cmd.u.add; + MgMgcoTermId termId = addReq->termId; + 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, "Textual SDP %s\n", mediaPar->u.local.sdpStr.pres ? "present" : "absent"); + break; + } + case MGT_MEDIAPAR_REMOTE: + { + break; + } + + case MGT_MEDIAPAR_LOCCTL: + { + break; + } + case MGT_MEDIAPAR_TERMST: + break; + case MGT_MEDIAPAR_STRPAR: + { + MgMgcoStreamDesc *mgStream = &mediaPar->u.stream; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Textual SDP %s\n", mgStream->sl.remote.sdpStr.pres ? "present" : "absent"); + + 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; + } + } + break; + } + case MGT_MODIFY: + { + MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod; + break; + } + case MGT_MOVE: + { + MgMgcoAmmReq *addReq = &cmdReq->cmd.u.move; + break; + + } + case MGT_SUB: + { + MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub; + } + case MGT_SVCCHG: + case MGT_NTFY: + case MGT_AUDITCAP: + case MGT_AUDITVAL: + break; + } + + } + } + + break; + } + case MGT_TXNREPLY: + { + break; + } + default: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received unknown command %d in transaction\n", msg->body.u.tl.txns[txnIter]->type.val); + break; + } + } + } } /*****************************************************************************************************************************/ From ca5b100d17072c95a269d4d2d533dc1f2d6d1b07 Mon Sep 17 00:00:00 2001 From: kapil Date: Thu, 21 Jun 2012 11:36:20 +0530 Subject: [PATCH 02/11] code commit for multiple peer cli command --- .../mod_media_gateway/media_gateway_cli.c | 73 +++++++++++-------- .../mod_media_gateway/media_gateway_stack.c | 59 ++++++++------- .../mod_media_gateway/media_gateway_xml.c | 10 ++- .../mod_media_gateway/mod_media_gateway.c | 2 +- src/mod/endpoints/mod_sofia/rtp.c | 2 +- 5 files changed, 80 insertions(+), 66 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c index 720032673c..e21fc9d3af 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c @@ -138,6 +138,7 @@ done: switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg) { int idx = 0x00; + int peerIdx = 0x00; int len = 0x00; MgMngmt cfm; char* xmlhdr = ""; @@ -152,33 +153,37 @@ switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, me memset((U8 *)&cfm, 0, sizeof(cfm)); memset((char *)&prntBuf, 0, sizeof(prntBuf)); - mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[0]); - - if(!mg_peer){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[0],mg_cfg->name); - return SWITCH_STATUS_FALSE; - } - - idx = mg_cfg->idx; len = len + sprintf(&prntBuf[0] + len,"%s\n",xmlhdr); - len = len + sprintf(&prntBuf[0] + len,"\n"); - len = len + sprintf(&prntBuf[0] + len,"%s\n",mg_cfg->peer_list[0]); + len = len + sprintf(&prntBuf[0] + len,"\n"); - /* TODO - as of now supporting only one peer .. need to add logic to iterate through all the peers associated with this profile..*/ + for(peerIdx =0; peerIdx < mg_cfg->total_peers; peerIdx++){ - /* send request to MEGACO Trillium stack to get peer information*/ - sng_mgco_mg_get_status(STGCPENT, &cfm, mg_cfg, mg_peer); + mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[peerIdx]); - ip = ntohl(cfm.t.ssta.s.mgPeerSta.peerAddrTbl.netAddr[i].u.ipv4NetAddr); - cmInetNtoa(ip, &asciiAddr); - len = len + sprintf(prntBuf+len, "%s\n",asciiAddr); + if(!mg_peer){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[peerIdx],mg_cfg->name); + return SWITCH_STATUS_FALSE; + } - len = len + sprintf(prntBuf+len, "%s\n",PRNT_MG_PEER_STATE(cfm.t.ssta.s.mgPeerSta.peerState)); + len = len + sprintf(&prntBuf[0] + len,"\n"); + len = len + sprintf(&prntBuf[0] + len,"%s\n",mg_peer->name); - len = len + sprintf(&prntBuf[0] + len,"\n"); + /* send request to MEGACO Trillium stack to get peer information*/ + sng_mgco_mg_get_status(STGCPENT, &cfm, mg_cfg, mg_peer); + + ip = ntohl(cfm.t.ssta.s.mgPeerSta.peerAddrTbl.netAddr[i].u.ipv4NetAddr); + cmInetNtoa(ip, &asciiAddr); + len = len + sprintf(prntBuf+len, "%s\n",asciiAddr); + + len = len + sprintf(prntBuf+len, "%s\n",PRNT_MG_PEER_STATE(cfm.t.ssta.s.mgPeerSta.peerState)); + + len = len + sprintf(&prntBuf[0] + len,"\n"); + } + + len = len + sprintf(&prntBuf[0] + len,"\n"); stream->write_function(stream, "\n%s\n",&prntBuf[0]); @@ -190,6 +195,7 @@ switch_status_t megaco_profile_peer_xmlstatus(switch_stream_handle_t *stream, me switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_profile_t* mg_cfg) { int idx = 0x00; + int peerIdx = 0x00; int len = 0x00; MgMngmt cfm; char* xmlhdr = ""; @@ -204,13 +210,7 @@ switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_ memset((U8 *)&cfm, 0, sizeof(cfm)); memset((char *)&prntBuf, 0, sizeof(prntBuf)); - mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[0]); - - if(!mg_peer){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[0],mg_cfg->name); - return SWITCH_STATUS_FALSE; - } - + idx = mg_cfg->idx; @@ -221,17 +221,26 @@ switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, megaco_ /****************************************************************************************************************/ /* Print Peer Information ***************************************************************************************/ - /* TODO - as of now supporting only one peer .. need to add logic to iterate through all the peers associated with this profile..*/ - len = len + sprintf(&prntBuf[0] + len,"\n"); - len = len + sprintf(&prntBuf[0] + len,"\n",mg_peer->name); - /* send request to MEGACO Trillium stack to get peer information*/ - sng_mgco_mg_get_status(STGCPENT, &cfm, mg_cfg, mg_peer); + for(peerIdx =0; peerIdx < mg_cfg->total_peers; peerIdx++){ - get_peer_xml_buffer(&prntBuf[0] + len, &cfm.t.ssta.s.mgPeerSta); + mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[peerIdx]); - len = len + sprintf(&prntBuf[0] + len,"\n"); + if(!mg_peer){ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG peer configuration found for peername[%s] against profilename[%s]\n",mg_cfg->peer_list[peerIdx],mg_cfg->name); + return SWITCH_STATUS_FALSE; + } + + len = len + sprintf(&prntBuf[0] + len,"\n",mg_peer->name); + + /* send request to MEGACO Trillium stack to get peer information*/ + sng_mgco_mg_get_status(STGCPENT, &cfm, mg_cfg, mg_peer); + + get_peer_xml_buffer(&prntBuf[0] + len, &cfm.t.ssta.s.mgPeerSta); + + len = len + sprintf(&prntBuf[0] + len,"\n"); + } len = len + sprintf(&prntBuf[0] + len,"\n"); diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index 591bb5f13d..d6fe2c5614 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -183,7 +183,6 @@ switch_status_t sng_mgco_cfg(megaco_profile_t* profile) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," mgco_mu_ssap_config SUCCESS \n"); } - if(mgco_mg_tsap_config(profile)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," mgco_mg_tsap_config FAILED \n"); return SWITCH_STATUS_FALSE; @@ -1001,7 +1000,7 @@ int mgco_mg_tsap_config(megaco_profile_t* profile) /* FILL TSAP config */ cfg->tSAPId = profile->idx; cfg->spId = profile->idx; - cfg->provType = mg_get_tpt_type(profile); + cfg->provType = LMG_PROV_TYPE_TUCL; /* FILL TUCL Information */ cfg->memId.region = S_REG; @@ -1045,7 +1044,7 @@ int mgco_mg_peer_config(megaco_profile_t* mg_cfg) Pst pst; /* Post for layer manager */ U32 peerIdx = 0; CmInetIpAddr ipAddr = 0; - mg_peer_profile_t* mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[0]); + mg_peer_profile_t* mg_peer = NULL; memset(&mgMngmt, 0, sizeof(mgMngmt)); cfg = &(mgMngmt.t.cfg.c.mgGcpEntCfg); @@ -1063,39 +1062,43 @@ int mgco_mg_peer_config(megaco_profile_t* mg_cfg) mgMngmt.hdr.elmId.elmnt = STGCPENT; cfg->numPeer = mg_cfg->total_peers; - cfg->peerCfg[peerIdx].sSAPId = mg_cfg->idx; /* SSAP ID */; - cfg->peerCfg[peerIdx].port = atoi(mg_peer->port); - cfg->peerCfg[peerIdx].tsapId = mg_cfg->idx; + for(peerIdx =0; peerIdx < mg_cfg->total_peers; peerIdx++){ - cfg->peerCfg[peerIdx].mtuSize = MG_MAX_MTU_SIZE; + mg_peer = megaco_peer_profile_locate(mg_cfg->peer_list[peerIdx]); + cfg->peerCfg[peerIdx].sSAPId = mg_cfg->idx; /* SSAP ID */; + cfg->peerCfg[peerIdx].port = atoi(mg_peer->port); + cfg->peerCfg[peerIdx].tsapId = mg_cfg->idx; - cfg->peerCfg[peerIdx].peerAddrTbl.count = 1; - cfg->peerCfg[peerIdx].peerAddrTbl.netAddr[0].type = - CM_NETADDR_IPV4; + cfg->peerCfg[peerIdx].mtuSize = MG_MAX_MTU_SIZE; - if(ROK == cmInetAddr((S8*)&mg_peer->ipaddr[0],&ipAddr)) - { - cfg->peerCfg[peerIdx].peerAddrTbl.netAddr[0].u.ipv4NetAddr = ntohl(ipAddr); - } - else - { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "cmInetAddr failed \n"); - cfg->peerCfg[peerIdx].peerAddrTbl.count = 0; - } + cfg->peerCfg[peerIdx].peerAddrTbl.count = 1; + cfg->peerCfg[peerIdx].peerAddrTbl.netAddr[0].type = + CM_NETADDR_IPV4; + + if(ROK == cmInetAddr((S8*)&mg_peer->ipaddr[0],&ipAddr)) + { + cfg->peerCfg[peerIdx].peerAddrTbl.netAddr[0].u.ipv4NetAddr = ntohl(ipAddr); + } + else + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "cmInetAddr failed \n"); + cfg->peerCfg[peerIdx].peerAddrTbl.count = 0; + } #ifdef GCP_MG - cfg->peerCfg[peerIdx].transportType = mg_get_tpt_type_from_str(mg_peer->transport_type); - cfg->peerCfg[peerIdx].encodingScheme = mg_get_enc_type_from_str(mg_peer->encoding_type); - cfg->peerCfg[peerIdx].mgcPriority = 0; - cfg->peerCfg[peerIdx].useAHScheme = FALSE; - cfg->peerCfg[peerIdx].mid.pres = PRSNT_NODEF; - cfg->peerCfg[peerIdx].mid.len = strlen((char*)mg_peer->mid); - cmMemcpy((U8 *)cfg->peerCfg[peerIdx].mid.val, - (CONSTANT U8*)(char*)mg_peer->mid, - cfg->peerCfg[peerIdx].mid.len); + cfg->peerCfg[peerIdx].transportType = mg_get_tpt_type_from_str(mg_peer->transport_type); + cfg->peerCfg[peerIdx].encodingScheme = mg_get_enc_type_from_str(mg_peer->encoding_type); + cfg->peerCfg[peerIdx].mgcPriority = peerIdx; + cfg->peerCfg[peerIdx].useAHScheme = FALSE; + cfg->peerCfg[peerIdx].mid.pres = PRSNT_NODEF; + cfg->peerCfg[peerIdx].mid.len = strlen((char*)mg_peer->mid); + cmMemcpy((U8 *)cfg->peerCfg[peerIdx].mid.val, + (CONSTANT U8*)(char*)mg_peer->mid, + cfg->peerCfg[peerIdx].mid.len); #endif /* GCP_MG */ + } return(sng_cfg_mg(&pst, &mgMngmt)); } diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index ba5c20aabb..f174361f03 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -78,11 +78,12 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) goto done; } - count = 0x00; - event = NULL; for (mg_peer = switch_xml_child(mg_peers, "mg_peer"); mg_peer; mg_peer = mg_peer->next) { const char *name = switch_xml_attr_soft(mg_peer, "name"); for(idx=0; idxtotal_peers; idx++){ + count = 0x00; + event = NULL; + peer_profile = NULL; if (!strcmp(name, profile->peer_list[idx])) { /* peer profile */ peer_profile = switch_core_alloc(profile->pool, sizeof(*peer_profile)); @@ -93,7 +94,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) count = switch_event_import_xml(switch_xml_child(mg_peer, "param"), "name", "value", &event); if(SWITCH_STATUS_FALSE == (status = switch_xml_config_parse_event(event, count, reload, instructions1))){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Peer XML Parsing failed \n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Peer XML Parsing failed \n"); goto done; } @@ -136,6 +137,7 @@ switch_status_t mg_config_cleanup(megaco_profile_t* profile) static switch_xml_config_item_t *get_peer_instructions(mg_peer_profile_t *profile) { switch_xml_config_item_t *dup; + switch_xml_config_item_t instructions[] = { /* parameter name type reloadable pointer default value options structure */ SWITCH_CONFIG_ITEM("ip", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->ipaddr, "", &switch_config_string_strdup, "", "Peer IP"), @@ -145,7 +147,7 @@ static switch_xml_config_item_t *get_peer_instructions(mg_peer_profile_t *profil SWITCH_CONFIG_ITEM("message-identifier", SWITCH_CONFIG_STRING, 0, &profile->mid, "", &switch_config_string_strdup, "", "peer message identifier "), SWITCH_CONFIG_ITEM_END() }; - + dup = malloc(sizeof(instructions)); memcpy(dup, instructions, sizeof(instructions)); return dup; diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 30de4f86fc..ea6e9fe53b 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -118,7 +118,7 @@ void handle_sng_log(uint8_t level, char *fmt, ...) case SNG_LOGLEVEL_DEBUG: log_level = SWITCH_LOG_DEBUG; break; case SNG_LOGLEVEL_INFO: log_level = SWITCH_LOG_INFO; break; case SNG_LOGLEVEL_WARN: log_level = SWITCH_LOG_WARNING; break; - case SNG_LOGLEVEL_ERROR: log_level = SWITCH_LOG_DEBUG; break; + case SNG_LOGLEVEL_ERROR: log_level = SWITCH_LOG_ERROR; break; case SNG_LOGLEVEL_CRIT: log_level = SWITCH_LOG_CRIT; break; default: log_level = SWITCH_LOG_DEBUG; break; }; diff --git a/src/mod/endpoints/mod_sofia/rtp.c b/src/mod/endpoints/mod_sofia/rtp.c index 23a94b9261..4a8107f859 100644 --- a/src/mod/endpoints/mod_sofia/rtp.c +++ b/src/mod/endpoints/mod_sofia/rtp.c @@ -502,7 +502,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi char name[128]; const char *dname = "PCMU"; uint32_t interval = 20; - crtp_private_t *tech_pvt; + crtp_private_t *tech_pvt = NULL; #if 0 const char *r_sdp = switch_event_get_header(var_event, kRSDP); #endif From 3693867388d241078a113ef1c37cdb9f95a23896 Mon Sep 17 00:00:00 2001 From: kapil Date: Thu, 21 Jun 2012 19:22:14 +0530 Subject: [PATCH 03/11] adding TCP transport support --- src/mod/endpoints/mod_media_gateway/media_gateway_stack.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index d6fe2c5614..55fd3ee9b0 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -782,6 +782,8 @@ int mgco_mg_gen_config(void) cfg->noEDInst = 1; #endif /* CM_ABNF_MT_LIB */ + cfg->entType = LMG_ENT_GW; + #ifdef GCP_CH cfg->numBinsPeerCmdHl = 20; cfg->numBinsTransReqHl = 50; From 97d89de3fc5011168f7a5eb903316fb6d1221bed Mon Sep 17 00:00:00 2001 From: kapil Date: Thu, 21 Jun 2012 19:23:22 +0530 Subject: [PATCH 04/11] MEGACO over TCP support --- src/mod/endpoints/mod_media_gateway/media_gateway_stack.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index 55fd3ee9b0..0cec5a829e 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -1310,7 +1310,6 @@ sng_mg_transport_types_e mg_get_tpt_type_from_str(char* tpt_type) if(!strcasecmp(tpt_type, "UDP")){ return SNG_MG_TPT_UDP; }else if(!strcasecmp(tpt_type,"TCP")){ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "TCP Transport for H.248 Protocol Not Yet Supported \n"); return SNG_MG_TPT_TCP; }else if(!strcasecmp(tpt_type,"STCP")){ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STCP Transport for H.248 Protocol Not Yet Supported \n"); From c5c7b09007bcbd767e507f86bc2cb69081936ed6 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 22 Jun 2012 11:35:00 -0400 Subject: [PATCH 05/11] Rolling back to find out what's breaking build --- conf/insideout/autoload_configs/modules.conf.xml | 2 +- conf/vanilla/autoload_configs/modules.conf.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/insideout/autoload_configs/modules.conf.xml b/conf/insideout/autoload_configs/modules.conf.xml index 8793a003ba..9970d7724d 100644 --- a/conf/insideout/autoload_configs/modules.conf.xml +++ b/conf/insideout/autoload_configs/modules.conf.xml @@ -60,7 +60,7 @@ - + diff --git a/conf/vanilla/autoload_configs/modules.conf.xml b/conf/vanilla/autoload_configs/modules.conf.xml index 50353ac849..cb45a1598c 100644 --- a/conf/vanilla/autoload_configs/modules.conf.xml +++ b/conf/vanilla/autoload_configs/modules.conf.xml @@ -80,7 +80,7 @@ - + From adca0985a4274d7d67643d9549581f1743d13db9 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Fri, 22 Jun 2012 13:20:04 -0400 Subject: [PATCH 06/11] Rolling back to find out what's breaking build --- build/modules.conf.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/modules.conf.in b/build/modules.conf.in index 2bdedc6237..e17118c6f6 100644 --- a/build/modules.conf.in +++ b/build/modules.conf.in @@ -8,10 +8,10 @@ applications/mod_spandsp #applications/mod_rad_auth dialplans/mod_dialplan_xml endpoints/mod_sofia -endpoints/mod_media_gateway +#endpoints/mod_media_gateway ../../libs/freetdm/mod_freetdm xml_int/mod_xml_cdr event_handlers/mod_event_socket codecs/mod_sangoma_codec -event_handlers/mod_radius_cdr +#event_handlers/mod_radius_cdr From fd634d6bc9ce57fdbf2c469b7dde6e8b6b21cd3f Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Fri, 22 Jun 2012 19:10:08 -0400 Subject: [PATCH 07/11] still figuring out lib --- .../mod_media_gateway/mod_media_gateway.c | 66 ++++++++++++++++--- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 4a3c32c9fe..1423df9cda 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -134,9 +134,6 @@ static void mgco_print_sdp(CmSdpInfoSet *sdp) { int i; -// XXX check if we can use that for debug: -// cmUnpkCmSdpInfoSet(<#CmSdpInfoSet *param#>, <#Ptr ptr#>, <#CmIntfVer intfVer#>, <#Buffer *mBuf#>); - if (sdp->numComp.pres == NOTPRSNT) { return; @@ -161,6 +158,7 @@ static void mgco_print_sdp(CmSdpInfoSet *sdp) for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) { CmSdpAttr *a = s->attrSet.attr[mediaId]; + } } @@ -177,12 +175,9 @@ static void mgco_print_sdp(CmSdpInfoSet *sdp) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Port: %d\n", port); } - } } - } - } } @@ -191,6 +186,9 @@ static void mgco_print_sdp(CmSdpInfoSet *sdp) void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) { size_t txnIter; + switch_memory_pool_t *pool; + + switch_core_new_memory_pool(&pool); /*TODO*/ if(msg->body.type.val == MGT_TXN) @@ -198,6 +196,7 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) /* Loop over transaction list */ for(txnIter=0;txnIterbody.u.tl.num.val;txnIter++) { + switch(msg->body.u.tl.txns[txnIter]->type.val) { case MGT_TXNREQ: { @@ -223,12 +222,44 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) for (cmdIter=0; cmdIter < (actnReq->cl.num.val); cmdIter++) { MgMgcoCommandReq *cmdReq = actnReq->cl.cmds[cmdIter]; MgMgcoTermId *termId = NULLP; + /* The reply we'll send */ + MgMgcoCommand mgCmd = {0}; + mgCmd.peerId = msg->lcl.id; + mgCmd.transId = transId; + mgCmd.u.mgCmdInd[0] = cmdReq; + + + /* XXX Handle choose context before this */ + + mgCmd.contextId = ctxId; + mgCmd.transId = transId; + + mgCmd.cmdStatus.pres = PRSNT_NODEF; + + if(cmdIter == (actnReq->cl.num.val -1)) + { + mgCmd.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN; + if(axnIter == (txnReq->al.num.val-1)) + { + mgCmd.cmdStatus.val= CH_CMD_STATUS_END_OF_TXN; + } + } + else + { + mgCmd.cmdStatus.val = CH_CMD_STATUS_PENDING; + } + + /* XXX handle props */ + mgCmd.cmdType.pres = PRSNT_NODEF; + mgCmd.cmdType.val = CH_CMD_TYPE_REQ; + mgCmd.u.mgCmdReq[0] = cmdReq; + sng_mgco_send_cmd(suId, &mgCmd); + switch (cmdReq->cmd.type.val) { case MGT_ADD: { MgMgcoAmmReq *addReq = &cmdReq->cmd.u.add; - MgMgcoTermId termId = addReq->termId; int descId; for (descId = 0; descId < addReq->dl.num.val; descId++) { switch (addReq->dl.descs[descId]->type.val) { @@ -240,24 +271,28 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) switch (mediaPar->type.val) { case MGT_MEDIAPAR_LOCAL: { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Textual SDP %s\n", mediaPar->u.local.sdpStr.pres ? "present" : "absent"); + 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; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Textual SDP %s\n", mgStream->sl.remote.sdpStr.pres ? "present" : "absent"); if (mgStream->sl.remote.pres.pres) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got remote stream media description:\n"); @@ -269,6 +304,7 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) mgco_print_sdp(&mgStream->sl.local.sdp); } + break; } } @@ -285,6 +321,9 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) break; } } + + + break; } case MGT_MODIFY: @@ -316,6 +355,7 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) } case MGT_TXNREPLY: { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MGT_TXNREPLY\n"); break; } default: @@ -324,18 +364,21 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) } } } + + switch_core_destroy_memory_pool(&pool); } /*****************************************************************************************************************************/ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); /*TODO*/ } /*****************************************************************************************************************************/ void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* sta) { - /*TODO*/ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); /*TODO*/ } /*****************************************************************************************************************************/ @@ -343,18 +386,21 @@ void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* sta) void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* txn_sta_ind) { /*TODO*/ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); } /*****************************************************************************************************************************/ void handle_mgco_cntrl_cfm(Pst *pst, SuId suId, MgMgtCntrl* cntrl, Reason reason) { /*TODO*/ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); } /*****************************************************************************************************************************/ void handle_mgco_audit_cfm(Pst *pst, SuId suId, MgMgtAudit* audit, Reason reason) { /*TODO*/ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); } /*****************************************************************************************************************************/ From e3eed73ecbe2687598983579bee78b2c202f327c Mon Sep 17 00:00:00 2001 From: kapil Date: Mon, 25 Jun 2012 12:12:04 +0530 Subject: [PATCH 08/11] adding mg and peer profile cleanup code during shutdown and removing "unused variables" warnings --- .../mod_media_gateway/media_gateway.c | 15 +++++++ .../mod_media_gateway/media_gateway_xml.c | 9 +++++ .../mod_media_gateway/mod_media_gateway.c | 39 ++++++++++++++++--- .../mod_media_gateway/mod_media_gateway.h | 2 + 4 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway.c b/src/mod/endpoints/mod_media_gateway/media_gateway.c index 98d433179e..3cd5856bd2 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway.c @@ -107,6 +107,21 @@ switch_status_t megaco_profile_destroy(megaco_profile_t **profile) return SWITCH_STATUS_SUCCESS; } +switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile) +{ + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stopping peer profile: %s\n", (*profile)->name); + + switch_core_hash_delete_wrlock(megaco_globals.peer_profile_hash, (*profile)->name, megaco_globals.peer_profile_rwlock); + + mg_peer_config_cleanup(*profile); + + switch_core_destroy_memory_pool(&(*profile)->pool); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stopped peer profile: %s\n", (*profile)->name); + + return SWITCH_STATUS_SUCCESS; +} + /* For Emacs: * Local Variables: * mode:c diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index 9e6b7fc1ad..c48032e30c 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -133,6 +133,15 @@ switch_status_t mg_config_cleanup(megaco_profile_t* profile) return SWITCH_STATUS_SUCCESS; } +/****************************************************************************************************************************/ +switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile) +{ + switch_xml_config_item_t *instructions = (profile ? get_peer_instructions(profile) : NULL); + switch_xml_config_cleanup(instructions); + + return SWITCH_STATUS_SUCCESS; +} + /****************************************************************************************************************************/ static switch_xml_config_item_t *get_peer_instructions(mg_peer_profile_t *profile) { switch_xml_config_item_t *dup; diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 1423df9cda..b056d91bba 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -97,6 +97,32 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_media_gateway_shutdown) { + void *val = NULL; + const void *key = NULL; + switch_ssize_t keylen; + switch_hash_index_t *hi = NULL; + megaco_profile_t* profile = NULL; + mg_peer_profile_t* peer_profile = NULL; + + /* destroy all the mg profiles */ + while ((hi = switch_hash_first(NULL, megaco_globals.profile_hash))) { + switch_hash_this(hi, &key, &keylen, &val); + profile = (megaco_profile_t *) val; + megaco_profile_destroy(&profile); + profile = NULL; + } + + hi = NULL; + key = NULL; + val = NULL; + /* destroy all the mg peer profiles */ + while ((hi = switch_hash_first(NULL, megaco_globals.peer_profile_hash))) { + switch_hash_this(hi, &key, &keylen, &val); + peer_profile = (mg_peer_profile_t *) val; + megaco_peer_profile_destroy(&peer_profile); + peer_profile = NULL; + } + sng_mgco_stack_shutdown(); return SWITCH_STATUS_SUCCESS; @@ -156,7 +182,7 @@ static void mgco_print_sdp(CmSdpInfoSet *sdp) } if (s->attrSet.numComp.pres) { for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) { - CmSdpAttr *a = s->attrSet.attr[mediaId]; + /*CmSdpAttr *a = s->attrSet.attr[mediaId];*/ } @@ -221,9 +247,10 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) /* Loop over command list */ for (cmdIter=0; cmdIter < (actnReq->cl.num.val); cmdIter++) { MgMgcoCommandReq *cmdReq = actnReq->cl.cmds[cmdIter]; - MgMgcoTermId *termId = NULLP; + /*MgMgcoTermId *termId = NULLP;*/ /* The reply we'll send */ - MgMgcoCommand mgCmd = {0}; + MgMgcoCommand mgCmd; + memset(&mgCmd, 0, sizeof(mgCmd)); mgCmd.peerId = msg->lcl.id; mgCmd.transId = transId; mgCmd.u.mgCmdInd[0] = cmdReq; @@ -328,18 +355,18 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) } case MGT_MODIFY: { - MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod; + /*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod;*/ break; } case MGT_MOVE: { - MgMgcoAmmReq *addReq = &cmdReq->cmd.u.move; + /*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.move;*/ break; } case MGT_SUB: { - MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub; + /*MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub;*/ } case MGT_SVCCHG: case MGT_NTFY: diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h index d4c6e43077..8aa0dae0d3 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h @@ -84,6 +84,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload); switch_status_t sng_mgco_start(megaco_profile_t* profile); switch_status_t sng_mgco_stop(megaco_profile_t* profile); switch_status_t mg_config_cleanup(megaco_profile_t* profile); +switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile); +switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile); switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stream); From b6737e31a30afe9901f327b7b29120281c0e2754 Mon Sep 17 00:00:00 2001 From: kapil Date: Mon, 25 Jun 2012 20:07:51 +0530 Subject: [PATCH 09/11] adding command handler to handle command indication from megaco stack --- .../mod_media_gateway/media_gateway_stack.c | 2 + .../mod_media_gateway/media_gateway_stack.h | 8 + .../mod_media_gateway/media_gateway_xml.c | 6 +- .../mod_media_gateway/mod_media_gateway.c | 296 +++++++++++++++++- 4 files changed, 307 insertions(+), 5 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index 0cec5a829e..8a300ff97e 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -945,6 +945,8 @@ int mgco_mg_ssap_config(megaco_profile_t* profile) return SWITCH_STATUS_FALSE; } + pCfg->chEnabled = 0x01; + pCfg->userInfo.pres.pres = PRSNT_NODEF; pCfg->userInfo.id.pres = NOTPRSNT; pCfg->userInfo.mid.pres = PRSNT_NODEF; diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h index 9bbe90b7df..6c2cbc7abd 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -62,4 +62,12 @@ 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); +/****************************************************************************************************************/ +/* MG Stack defines */ + +/* Free Commands inside MG CH command */ +#define mg_free_cmd(_cmd) mgFreeEventMem(_cmd) + +/****************************************************************************************************************/ + #endif /* _MEGACO_STACK_H_ */ diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c index c48032e30c..f1259ed544 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_xml.c @@ -27,6 +27,7 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) char *var, *val; mg_peer_profile_t* peer_profile = NULL; switch_xml_config_item_t *instructions1 = NULL; + switch_memory_pool_t *pool; if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file); @@ -86,8 +87,9 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) peer_profile = NULL; if (!strcmp(name, profile->peer_list[idx])) { /* peer profile */ - peer_profile = switch_core_alloc(profile->pool, sizeof(*peer_profile)); - peer_profile->pool = profile->pool; + switch_core_new_memory_pool(&pool); + peer_profile = switch_core_alloc(pool, sizeof(*peer_profile)); + peer_profile->pool = pool; peer_profile->name = switch_core_strdup(peer_profile->pool, name); switch_thread_rwlock_create(&peer_profile->rwlock, peer_profile->pool); instructions1 = (peer_profile ? get_peer_instructions(peer_profile) : NULL); diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index b056d91bba..56d40ec41d 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -9,12 +9,18 @@ #include "mod_media_gateway.h" #include "media_gateway_stack.h" + +/**************************************************************************************************************/ struct megaco_globals megaco_globals; 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_STANDARD_API(megaco_function) { @@ -247,7 +253,7 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) /* Loop over command list */ for (cmdIter=0; cmdIter < (actnReq->cl.num.val); cmdIter++) { MgMgcoCommandReq *cmdReq = actnReq->cl.cmds[cmdIter]; - /*MgMgcoTermId *termId = NULLP;*/ + /*MgMgcoTermId *term_id = NULLP;*/ /* The reply we'll send */ MgMgcoCommand mgCmd; memset(&mgCmd, 0, sizeof(mgCmd)); @@ -398,8 +404,81 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg) /*****************************************************************************************************************************/ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); - /*TODO*/ + uint32_t txn_id = 0x00; + + 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) + txn_id = cmd->transId.val; + else + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Transaction Id not present, rejecting\n", __PRETTY_FUNCTION__); + /*TODO - can invoke "MgUiMgtMgcoErrReq" to report error to MEGACO stack */ + /* deallocate the msg */ + mg_free_cmd(cmd); + return ; + } + + mgAccEvntPrntMgMgcoCommand(cmd, stdout); + + switch(cmd->cmdType.val) + { + case CH_CMD_TYPE_IND: + { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: Received Command indication for command[%s]\n", + __PRETTY_FUNCTION__,PRNT_MG_CMD(cmd->u.mgCmdInd[0]->cmd.type.val)); + + switch(cmd->u.mgCmdInd[0]->cmd.type.val) + { + case MGT_ADD: + { + handle_mg_add_cmd(&cmd->u.mgCmdInd[0]->cmd.u.add); + break; + } + + case MGT_MODIFY: + { + /*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod;*/ + break; + } + case MGT_MOVE: + { + /*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.move;*/ + break; + + } + case MGT_SUB: + { + /*MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub;*/ + } + case MGT_SVCCHG: + case MGT_NTFY: + case MGT_AUDITCAP: + case MGT_AUDITVAL: + break; + } + + break; + } + case CH_CMD_TYPE_REQ: + { + break; + } + case CH_CMD_TYPE_RSP: + { + break; + } + case CH_CMD_TYPE_CFM: + { + break; + } + default: + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid command type[%d]\n",cmd->cmdType.val); + return; + } + + return; } /*****************************************************************************************************************************/ @@ -430,7 +509,218 @@ void handle_mgco_audit_cfm(Pst *pst, SuId suId, MgMgtAudit* audit, Reason reason switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); } + /*****************************************************************************************************************************/ +/* +* +* 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; +} /*****************************************************************************************************************************/ From e777de3eefc161e32709534ae63454a8f20d0c5f Mon Sep 17 00:00:00 2001 From: kapil Date: Tue, 26 Jun 2012 13:05:23 +0530 Subject: [PATCH 10/11] adding mg stack add command code and sendign dummy rsp of add --- .../mod_media_gateway/mod_media_gateway.c | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 56d40ec41d..d24fa93008 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -19,6 +19,11 @@ 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); /**************************************************************************************************************/ @@ -434,6 +439,7 @@ void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd) case MGT_ADD: { handle_mg_add_cmd(&cmd->u.mgCmdInd[0]->cmd.u.add); + mg_send_add_rsp(suId, cmd); break; } @@ -493,6 +499,9 @@ void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* txn_sta_ind) { /*TODO*/ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s\n", __PRETTY_FUNCTION__); + + /*dump information*/ + /*mgAccEvntPrntMgMgcoInd(txn_sta_ind, stdout);*/ } /*****************************************************************************************************************************/ @@ -719,9 +728,180 @@ switch_status_t handle_mg_add_cmd(MgMgcoAmmReq *addReq) } } + return SWITCH_STATUS_SUCCESS; } + +/*****************************************************************************************************************************/ +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; +} + +/*****************************************************************************************************************************/ +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); +} + + /*****************************************************************************************************************************/ /* For Emacs: From c82c11b02a3dc54e1a68ed29bd3c5024dc4dd603 Mon Sep 17 00:00:00 2001 From: kapil Date: Tue, 26 Jun 2012 17:45:01 +0530 Subject: [PATCH 11/11] adding code to send add response --- src/mod/endpoints/mod_media_gateway/mod_media_gateway.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index d24fa93008..bca39abb30 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -739,6 +739,7 @@ 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)); @@ -784,6 +785,12 @@ switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req) 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; }