Merge branch 'nsg-4.3' of ssh://git.sangoma.com/smg_freeswitch into nsg-4.3

Conflicts:
	build/modules.conf.in
This commit is contained in:
David Yat Sin 2012-06-26 21:27:03 -04:00
commit 8de2568c3e
14 changed files with 872 additions and 76 deletions

3
.gitignore vendored
View File

@ -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

View File

@ -11,4 +11,3 @@ endpoints/mod_sofia
xml_int/mod_xml_cdr
event_handlers/mod_event_socket
codecs/mod_sangoma_codec

View File

@ -60,7 +60,7 @@
<load module="mod_g723_1"/>
<load module="mod_g729"/>
<load module="mod_amr"/>
<load module="mod_ilbc"/>
<!-- <load module="mod_ilbc"/> -->
<load module="mod_speex"/>
<load module="mod_h26x"/>
<!--<load module="mod_siren"/>-->

View File

@ -80,7 +80,7 @@
<load module="mod_g723_1"/>
<load module="mod_g729"/>
<load module="mod_amr"/>
<load module="mod_ilbc"/>
<!-- <load module="mod_ilbc"/> -->
<load module="mod_speex"/>
<load module="mod_h26x"/>
<load module="mod_siren"/>

View File

@ -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");

View File

@ -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

View File

@ -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

View File

@ -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 = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
@ -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,"<mg_peer>\n");
len = len + sprintf(&prntBuf[0] + len,"<name>%s</name>\n",mg_cfg->peer_list[0]);
len = len + sprintf(&prntBuf[0] + len,"<mg_peers>\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, "<ipv4_address>%s</ipv4_address>\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, "<peer_state>%s</peer_state>\n",PRNT_MG_PEER_STATE(cfm.t.ssta.s.mgPeerSta.peerState));
len = len + sprintf(&prntBuf[0] + len,"<mg_peer>\n");
len = len + sprintf(&prntBuf[0] + len,"<name>%s</name>\n",mg_peer->name);
len = len + sprintf(&prntBuf[0] + len,"</mg_peer>\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, "<ipv4_address>%s</ipv4_address>\n",asciiAddr);
len = len + sprintf(prntBuf+len, "<peer_state>%s</peer_state>\n",PRNT_MG_PEER_STATE(cfm.t.ssta.s.mgPeerSta.peerState));
len = len + sprintf(&prntBuf[0] + len,"</mg_peer>\n");
}
len = len + sprintf(&prntBuf[0] + len,"</mg_peers>\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 = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
@ -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,"<mg_peers>\n");
len = len + sprintf(&prntBuf[0] + len,"<mg_peer name=%s>\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,"</mg_peer>\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,"<mg_peer name=%s>\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,"</mg_peer>\n");
}
len = len + sprintf(&prntBuf[0] + len,"</mg_peers>\n");

View File

@ -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;
@ -783,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;
@ -944,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;
@ -1001,7 +1004,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 +1048,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 +1066,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));
}
@ -1305,7 +1312,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");

View File

@ -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_ */

View File

@ -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);
@ -78,22 +79,24 @@ 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; idx<profile->total_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));
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);
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;
}
@ -132,10 +135,20 @@ 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;
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 +158,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;
@ -243,6 +256,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;
}

View File

@ -9,12 +9,23 @@
#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_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);
/**************************************************************************************************************/
SWITCH_STANDARD_API(megaco_function)
{
@ -97,6 +108,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;
@ -118,7 +155,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;
};
@ -130,23 +167,330 @@ void handle_sng_log(uint8_t level, char *fmt, ...)
va_end(ptr);
}
static void mgco_print_sdp(CmSdpInfoSet *sdp)
{
int i;
if (sdp->numComp.pres == NOTPRSNT) {
return;
}
for (i = 0; i < sdp->numComp.val; i++) {
CmSdpInfo *s = sdp->info[i];
int mediaId;
if (s->conn.addrType.pres && s->conn.addrType.val == CM_SDP_ADDR_TYPE_IPV4 &&
s->conn.netType.type.val == CM_SDP_NET_TYPE_IN &&
s->conn.u.ip4.addrType.val == CM_SDP_IPV4_IP_UNI) {
if (s->conn.u.ip4.addrType.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Address: %d.%d.%d.%d\n",
s->conn.u.ip4.u.uniIp.b[0].val,
s->conn.u.ip4.u.uniIp.b[1].val,
s->conn.u.ip4.u.uniIp.b[2].val,
s->conn.u.ip4.u.uniIp.b[3].val);
}
if (s->attrSet.numComp.pres) {
for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) {
/*CmSdpAttr *a = s->attrSet.attr[mediaId];*/
}
}
if (s->mediaDescSet.numComp.pres) {
for (mediaId = 0; mediaId < s->mediaDescSet.numComp.val; mediaId++) {
CmSdpMediaDesc *desc = s->mediaDescSet.mediaDesc[mediaId];
if (desc->field.mediaType.val == CM_SDP_MEDIA_AUDIO &&
desc->field.id.type.val == CM_SDP_VCID_PORT &&
desc->field.id.u.port.type.val == CM_SDP_PORT_INT &&
desc->field.id.u.port.u.portInt.port.type.val == CM_SDP_SPEC) {
int port = desc->field.id.u.port.u.portInt.port.val.val;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Port: %d\n", port);
}
}
}
}
}
}
/*****************************************************************************************************************************/
void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
{
size_t txnIter;
switch_memory_pool_t *pool;
switch_core_new_memory_pool(&pool);
/*TODO*/
if(msg->body.type.val == MGT_TXN)
{
/* Loop over transaction list */
for(txnIter=0;txnIter<msg->body.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;axnIter<txnReq->al.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 *term_id = NULLP;*/
/* The reply we'll send */
MgMgcoCommand mgCmd;
memset(&mgCmd, 0, sizeof(mgCmd));
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;
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;
}
}
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:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MGT_TXNREPLY\n");
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;
}
}
}
switch_core_destroy_memory_pool(&pool);
}
/*****************************************************************************************************************************/
void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
{
/*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);
mg_send_add_rsp(suId, cmd);
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;
}
/*****************************************************************************************************************************/
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*/
}
/*****************************************************************************************************************************/
@ -154,22 +498,417 @@ 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__);
/*dump information*/
/*mgAccEvntPrntMgMgcoInd(txn_sta_ind, stdout);*/
}
/*****************************************************************************************************************************/
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__);
}
/*****************************************************************************************************************************/
/*
*
* Fun: mg_get_term_id_list
*
* Desc: Utility function to get MgMgcoTermIdLst structure
* from MgMgcoCommand structure.
* GCP_VER_2_1 - we will have term id list instead of single term id
*
* Ret: If success, return pointer to MgMgcoTermIdLst.
* If failure, return Null.
*
* Notes: None
*
*/
MgMgcoTermIdLst *mg_get_term_id_list(MgMgcoCommand *cmd)
{
uint8_t cmd_type = MGT_NONE;
uint8_t api_type = CM_CMD_TYPE_NONE;
MgMgcoTermIdLst * term_id = NULL;
/*-- mgCmdInd type represents the data structure for both
* incoming and outgoing requests, hence we can get the
* command type from there itself --*/
cmd_type = cmd->u.mgCmdInd[0]->cmd.type.val;
/*-- Find apiType --*/
api_type = cmd->cmdType.val;
switch (api_type)
{
case CH_CMD_TYPE_REQ:
case CH_CMD_TYPE_IND:
/* Based on Command Type, get to the TermId structure */
switch (cmd_type)
{
case MGT_ADD:
if (cmd->u.mgCmdInd[0]->cmd.u.add.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.add.termIdLst;
break;
case MGT_MOVE:
if (cmd->u.mgCmdInd[0]->cmd.u.move.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.move.termIdLst;
break;
case MGT_MODIFY:
if (cmd->u.mgCmdInd[0]->cmd.u.mod.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.mod.termIdLst;
break;
case MGT_SUB:
if (cmd->u.mgCmdInd[0]->cmd.u.sub.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.sub.termIdLst;
break;
case MGT_AUDITCAP:
if (cmd->u.mgCmdInd[0]->cmd.u.acap.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.acap.termIdLst;
break;
case MGT_AUDITVAL:
if (cmd->u.mgCmdInd[0]->cmd.u.aval.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.aval.termIdLst;
break;
case MGT_NTFY:
if (cmd->u.mgCmdInd[0]->cmd.u.ntfy.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.ntfy.termIdLst;
break;
case MGT_SVCCHG:
if (cmd->u.mgCmdInd[0]->cmd.u.svc.pres.pres)
term_id = &cmd->u.mgCmdInd[0]->cmd.u.svc.termIdLst;
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported Command[%s]\n", __PRETTY_FUNCTION__, PRNT_MG_CMD(cmd_type));
break;
}
break;
case CH_CMD_TYPE_RSP:
case CH_CMD_TYPE_CFM:
cmd_type = cmd->u.mgCmdRsp[0]->type.val;
switch (cmd_type)
{
case MGT_ADD:
if (cmd->u.mgCmdRsp[0]->u.add.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.add.termIdLst;
break;
case MGT_MOVE:
if (cmd->u.mgCmdRsp[0]->u.move.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.move.termIdLst;
break;
case MGT_MODIFY:
if (cmd->u.mgCmdRsp[0]->u.mod.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.mod.termIdLst;
break;
case MGT_SUB:
if (cmd->u.mgCmdRsp[0]->u.sub.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.sub.termIdLst;
break;
case MGT_SVCCHG:
if (cmd->u.mgCmdRsp[0]->u.svc.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.svc.termIdLst;
break;
case MGT_AUDITVAL:
if (cmd->u.mgCmdRsp[0]->u.aval.u.other.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.aval.u.other.termIdLst;
break;
case MGT_AUDITCAP:
if (cmd->u.mgCmdRsp[0]->u.acap.u.other.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.acap.u.other.termIdLst;
break;
case MGT_NTFY:
if (cmd->u.mgCmdRsp[0]->u.ntfy.pres.pres)
term_id = &cmd->u.mgCmdRsp[0]->u.ntfy.termIdLst;
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported Command[%s]\n", __PRETTY_FUNCTION__, PRNT_MG_CMD(cmd_type));
} /* switch command type for reply */
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s: failed, Unsupported api_type[%s]!\n", __PRETTY_FUNCTION__, PRNT_MG_CMD_TYPE(api_type));
break;
} /* switch -api_type */
return (term_id);
}
/*****************************************************************************************************************************/
switch_status_t handle_mg_add_cmd(MgMgcoAmmReq *addReq)
{
int descId;
for (descId = 0; descId < addReq->dl.num.val; descId++) {
switch (addReq->dl.descs[descId]->type.val) {
case MGT_MEDIADESC:
{
int mediaId;
for (mediaId = 0; mediaId < addReq->dl.descs[descId]->u.media.num.val; mediaId++) {
MgMgcoMediaPar *mediaPar = addReq->dl.descs[descId]->u.media.parms[mediaId];
switch (mediaPar->type.val) {
case MGT_MEDIAPAR_LOCAL:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_LOCAL");
break;
}
case MGT_MEDIAPAR_REMOTE:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_REMOTE");
break;
}
case MGT_MEDIAPAR_LOCCTL:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_LOCCTL");
break;
}
case MGT_MEDIAPAR_TERMST:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MGT_MEDIAPAR_TERMST");
break;
}
case MGT_MEDIAPAR_STRPAR:
{
MgMgcoStreamDesc *mgStream = &mediaPar->u.stream;
if (mgStream->sl.remote.pres.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got remote stream media description:\n");
mgco_print_sdp(&mgStream->sl.remote.sdp);
}
if (mgStream->sl.local.pres.pres) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Got local stream media description:\n");
mgco_print_sdp(&mgStream->sl.local.sdp);
}
break;
}
}
}
}
case MGT_MODEMDESC:
case MGT_MUXDESC:
case MGT_REQEVTDESC:
case MGT_EVBUFDESC:
case MGT_SIGNALSDESC:
case MGT_DIGMAPDESC:
case MGT_AUDITDESC:
case MGT_STATSDESC:
break;
}
}
return SWITCH_STATUS_SUCCESS;
}
/*****************************************************************************************************************************/
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req)
{
MgMgcoCommand cmd;
int ret = 0x00;
MgMgcoTermId *termId;
MgMgcoCtxt ctxt;
memset(&cmd,0, sizeof(cmd));
/*copy transaction-id*/
memcpy(&cmd.transId, &req->transId,sizeof(MgMgcoTransId));
/*copy context-id*/ /*TODO - in case of $ context should be generated by app, we should not simply copy incoming structure */
memcpy(&cmd.contextId, &req->contextId,sizeof(MgMgcoContextId));
/*copy peer identifier */
memcpy(&cmd.peerId, &req->peerId,sizeof(TknU32));
/*fill response structue */
if(SWITCH_STATUS_FALSE == (ret = mg_stack_alloc_mem((Ptr*)&cmd.u.mgCmdRsp[0],sizeof(MgMgcoCmdReply)))){
return ret;
}
cmd.u.mgCmdRsp[0]->pres.pres = PRSNT_NODEF;
cmd.u.mgCmdRsp[0]->type.pres = PRSNT_NODEF;
cmd.u.mgCmdRsp[0]->type.val = MGT_ADD;
cmd.u.mgCmdRsp[0]->u.add.pres.pres = PRSNT_NODEF;
cmd.u.mgCmdRsp[0]->u.add.termIdLst.num.pres = PRSNT_NODEF;
cmd.u.mgCmdRsp[0]->u.add.termIdLst.num.val = 1;
mgUtlAllocMgMgcoTermIdLst(&cmd.u.mgCmdRsp[0]->u.add.termIdLst, &req->u.mgCmdReq[0]->cmd.u.add.termIdLst);
#ifdef GCP_VER_2_1
termId = cmd.u.mgCmdRsp[0]->u.add.termIdLst.terms[0];
#else
termId = &(cmd.u.mgCmdRsp[0]->u.add.termId);
#endif
mg_fill_mgco_termid(termId, (CONSTANT U8*)"term1",&req->u.mgCmdRsp[0]->memCp);
/* We will always send one command at a time..*/
cmd.cmdStatus.pres = PRSNT_NODEF;
cmd.cmdStatus.val = CH_CMD_STATUS_END_OF_CMD;
cmd.cmdType.pres = PRSNT_NODEF;
cmd.cmdType.val = CH_CMD_TYPE_RSP;
ret = sng_mgco_send_cmd(suId, &cmd);
memcpy(&ctxt.transId,&req->transId,sizeof(MgMgcoTransId));
memcpy(&ctxt.cntxtId, &req->contextId,sizeof(MgMgcoContextId));
memcpy(&ctxt.peerId, &req->peerId,sizeof(TknU32));
ctxt.cmdStatus.pres = PRSNT_NODEF;
ctxt.cmdStatus.val = CH_CMD_STATUS_END_OF_AXN;
ret = sng_mgco_send_axn_req(suId, &ctxt);
return ret;
}
/*****************************************************************************************************************************/
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize )
{
Mem sMem;
sMem.region = 0;
sMem.pool = 0;
if ( _memSize <= 0 )
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_alloc_mem: invalid size\n");
return SWITCH_STATUS_FALSE;
}
if ( ROK != cmAllocEvnt( _memSize, MG_MAXBLKSIZE, &sMem, _memPtr ) )
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_alloc_mem: cmAllocEvnt return failure for _memSize=%d\n",_memSize);
return SWITCH_STATUS_FALSE;
}
// Note: memset done inside stack api
return SWITCH_STATUS_SUCCESS;
}
switch_status_t mg_stack_get_mem(MgMgcoMsg* msg, Ptr* _memPtr, Size _memSize )
{
if ( _memSize <= 0 )
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid size\n");
return SWITCH_STATUS_FALSE;
}
if ( !msg )
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid message\n");
return SWITCH_STATUS_FALSE;
}
if ( cmGetMem( (Ptr)msg, _memSize, (Ptr*)_memPtr ) != ROK )
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed alloc_mg_stack_mem: get memory failed _memSize=%d\n", _memSize );
return SWITCH_STATUS_FALSE;
}
// Note: memset done inside stack api
return SWITCH_STATUS_SUCCESS;
}
switch_status_t mg_stack_free_mem(MgMgcoMsg* msg)
{
if ( !msg )
{
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, " Failed mg_stack_get_mem: invalid message\n");
return SWITCH_STATUS_FALSE;
}
cmFreeMem( (Ptr)msg );
return SWITCH_STATUS_SUCCESS;
}
#define MG_ACC_GETMEM(_ptr,_len,_memCp,_ret) \
{ \
ret = cmGetMem((_memCp), (_len), (Ptr *)&(_ptr)); \
if( ret == ROK) \
cmMemset((U8 *)(_ptr), (U8)0, (PTR)(_len)); \
}
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, CONSTANT U8 *str, CmMemListCp *memCp)
{
#ifdef GCP_ASN
Size size;
#endif
S16 ret = ROK;
termId->name.pres.pres = PRSNT_NODEF;
/* mg011.105: Bug fixes */
termId->name.lcl.pres = PRSNT_NODEF;
termId->name.lcl.len = cmStrlen((CONSTANT U8*)str);
MG_ACC_GETMEM((termId->name.lcl.val), termId->name.lcl.len, memCp, ret);
if( ret != ROK)
RETVALUE(ret);
cmMemcpy((U8*)(termId->name.lcl.val), (CONSTANT U8*)str,termId->name.lcl.len);
#ifdef GCP_ASN
/* Remove comment to fill other term ID
termId->wildcard.num.pres = NOTPRSNT; */
/* Remove comment to fill wilcard term ID */
termId->wildcard.num.pres = PRSNT_NODEF;
termId->wildcard.num.val = 1;
size = ((sizeof(MgMgcoWildcardField*)));
MG_ACC_GETMEM((termId->wildcard.wildcard),size,memCp, ret);
if( ret != ROK)
RETVALUE(ret);
MG_ACC_GETMEM( ((termId->wildcard.wildcard)[0]),sizeof(MgMgcoWildcardField),
memCp, ret);
if( ret != ROK)
RETVALUE(ret);
termId->wildcard.wildcard[0]->pres = PRSNT_NODEF;
termId->wildcard.wildcard[0]->len = 1;
termId->wildcard.wildcard[0]->val[0] = 0x55;
#endif /* GCP_ASN */
RETVALUE(ROK);
}
/*****************************************************************************************************************************/
/* For Emacs:

View File

@ -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);

View File

@ -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