code commit for multiple peer cli command
This commit is contained in:
parent
c18c32f800
commit
ca5b100d17
|
@ -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");
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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; 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));
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue