reorgnazing code , adding below two files
* megaco_cli.c - contains CLI commands APIs * megaco_stack_alarms.c - contains Alarm indication APIs from Trillium MEGACO layer
This commit is contained in:
parent
acfbbc9e73
commit
ba051e1007
|
@ -7,6 +7,6 @@ ifeq ($(ARCH),x86_64)
|
|||
endif
|
||||
|
||||
BASE=../../../..
|
||||
LOCAL_OBJS=megaco.o megaco_stack.o megaco_xml.o
|
||||
LOCAL_OBJS=megaco.o megaco_stack.o megaco_xml.o megaco_cli.o megaco_stack_alarms.o
|
||||
LOCAL_LDFLAGS=-lsng_megaco
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
|
|
@ -0,0 +1,465 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Sangoma Technologies
|
||||
* Kapil Gupta <kgupta@sangoma.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* <Insert license here>
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
#include "mod_megaco.h"
|
||||
#include "megaco_stack.h"
|
||||
/******************************************************************************/
|
||||
|
||||
/* FUNCTION PROTOTYPES ********************************************************/
|
||||
switch_status_t megaco_profile_status(switch_stream_handle_t *stream, const char* profilename);
|
||||
switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, const char* profilename);
|
||||
void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stream)
|
||||
{
|
||||
int argc;
|
||||
char *argv[10];
|
||||
char *dup = NULL;
|
||||
|
||||
if (zstr(cmd)) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
dup = strdup(cmd);
|
||||
argc = switch_split(dup, ' ', argv);
|
||||
|
||||
if (argc < 1 || zstr(argv[0])) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
if (!strcmp(argv[0], "profile")) {
|
||||
if (zstr(argv[1]) || zstr(argv[2])) {
|
||||
goto usage;
|
||||
}
|
||||
/**********************************************************************************/
|
||||
if (!strcmp(argv[2], "start")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_release(profile);
|
||||
stream->write_function(stream, "-ERR Profile %s is already started\n", argv[2]);
|
||||
} else {
|
||||
megaco_profile_start(argv[1]);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
} else if (!strcmp(argv[2], "stop")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_release(profile);
|
||||
megaco_profile_destroy(&profile);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such profile\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
}else if(!strcmp(argv[2], "status")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_status(stream, profile->name);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such profile\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
}else if(!strcmp(argv[2], "xmlstatus")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_xmlstatus(stream, profile->name);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such profile\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
}else {
|
||||
/**********************************************************************************/
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
|
||||
goto done;
|
||||
|
||||
usage:
|
||||
stream->write_function(stream, "-ERR Usage: "MEGACO_FUNCTION_SYNTAX"\n");
|
||||
|
||||
done:
|
||||
switch_safe_free(dup);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, const char* profilename)
|
||||
{
|
||||
int idx = 0x00;
|
||||
int len = 0x00;
|
||||
MgMngmt cfm;
|
||||
char* xmlhdr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
|
||||
char prntBuf[3048];
|
||||
int i = 0x00;
|
||||
char *asciiAddr;
|
||||
CmInetIpAddr ip;
|
||||
megaco_profile_t* mg_cfg = NULL;
|
||||
mg_peer_profile_t* mg_peer = NULL;
|
||||
|
||||
switch_assert(profilename);
|
||||
|
||||
memset((U8 *)&cfm, 0, sizeof(cfm));
|
||||
memset((char *)&prntBuf, 0, sizeof(prntBuf));
|
||||
|
||||
mg_cfg = megaco_profile_locate(profilename);
|
||||
if(!mg_cfg){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG configuration found against profilename[%s]\n",profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
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],profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
idx = mg_cfg->idx;
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"%s\n",xmlhdr);
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_profile>\n");
|
||||
len = len + sprintf(&prntBuf[0] + len,"<name>%s</name>\n",mg_cfg->name);
|
||||
len = len + sprintf(&prntBuf[0] + len,"<profile>%s</profile>\n",profilename);
|
||||
/****************************************************************************************************************/
|
||||
/* 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);
|
||||
|
||||
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");
|
||||
|
||||
|
||||
/****************************************************************************************************************/
|
||||
/* Print MG SAP Information ***************************************************************************************/
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_sap>\n");
|
||||
|
||||
/* MG SAP Information */
|
||||
sng_mgco_mg_get_status(STSSAP, &cfm, mg_cfg, mg_peer);
|
||||
|
||||
len = len + sprintf(prntBuf+len, "<state> %s </state>\n", PRNT_SAP_STATE((int)(cfm.t.ssta.s.mgSSAPSta.state)));
|
||||
len = len + sprintf(prntBuf+len, "<num_of_peer> %u </num_of_peer>\n", (unsigned int)(cfm.t.ssta.s.mgSSAPSta.numAssocPeer));
|
||||
len = len + sprintf(prntBuf+len, "<num_of_listeners> %u </num_of_listeners>\n", (unsigned int)(cfm.t.ssta.s.mgSSAPSta.numServers));
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_sap_peers>\n");
|
||||
for (i = 0; i < cfm.t.ssta.s.mgSSAPSta.numAssocPeer; i++)
|
||||
{
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_sap_peer>\n");
|
||||
if(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.namePres.pres == PRSNT_NODEF)
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<domain_name> %s </domain_name>\n", (char *)(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.name));
|
||||
}
|
||||
switch(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.netAddr.type)
|
||||
{
|
||||
case CM_NETADDR_IPV4:
|
||||
{
|
||||
ip = ntohl(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.netAddr.u.ipv4NetAddr);
|
||||
cmInetNtoa(ip, &asciiAddr);
|
||||
len = len + sprintf(prntBuf+len, "<ipv4_address>%s</ipv4_address>\n",asciiAddr);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "<ip_address>invalid type </ip_address>\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef GCP_MGCO
|
||||
if (PRSNT_NODEF == cfm.t.ssta.s.mgSSAPSta.peerInfo[i].mid.pres)
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<peer_mid> %s </peer_mid>\n", (char *)(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].mid.val));
|
||||
}
|
||||
#endif /* GCP_MGCO */
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_sap_peer>\n");
|
||||
}
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_sap_peers>\n");
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_sap>\n");
|
||||
|
||||
/****************************************************************************************************************/
|
||||
/* Print MG Transport SAP Information ***************************************************************************************/
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_transport_sap>\n");
|
||||
/* MG Transport SAP Information */
|
||||
sng_mgco_mg_get_status(STTSAP, &cfm, mg_cfg, mg_peer);
|
||||
len = len + sprintf(&prntBuf[0] + len,"<state> %s </state>\n", PRNT_SAP_STATE(cfm.t.ssta.s.mgTSAPSta.state));
|
||||
len = len + sprintf(&prntBuf[0] + len,"<num_of_listeners> %u </num_of_listeners>\n", (unsigned int)(cfm.t.ssta.s.mgTSAPSta.numServers));
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_transport_sap>\n");
|
||||
|
||||
/****************************************************************************************************************/
|
||||
/* Print MG Transport Server Information ***************************************************************************************/
|
||||
|
||||
if(sng_mgco_mg_get_status(STSERVER, &cfm, mg_cfg, mg_peer)){
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_transport_server> no established server found </mg_transport_server>\n");
|
||||
}
|
||||
else {
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_transport_server>\n");
|
||||
len = len + sprintf(&prntBuf[0] + len,"<state> %s </state>\n", PRNT_SAP_STATE(cfm.t.ssta.s.mgTptSrvSta.state));
|
||||
len = len + sprintf(prntBuf+len, "<transport_address>");
|
||||
|
||||
switch (cfm.t.ssta.s.mgTptSrvSta.tptAddr.type)
|
||||
{
|
||||
case CM_TPTADDR_NOTPRSNT:
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "none");
|
||||
break;
|
||||
}
|
||||
case CM_TPTADDR_IPV4:
|
||||
{
|
||||
ip = ntohl(cfm.t.ssta.s.mgTptSrvSta.tptAddr.u.ipv4TptAddr.address);
|
||||
cmInetNtoa(ip, &asciiAddr);
|
||||
len = len + sprintf(prntBuf+len, "IPv4 IP address #%s, port %u",asciiAddr,
|
||||
(unsigned int)(cfm.t.ssta.s.mgTptSrvSta.tptAddr.u.ipv4TptAddr.port));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "unknown");
|
||||
break;
|
||||
}
|
||||
len = len + sprintf(prntBuf+len, "</transport_address>\n");
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_transport_server>\n");
|
||||
}
|
||||
|
||||
/****************************************************************************************************************/
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_profile>\n");
|
||||
|
||||
stream->write_function(stream, "\n%s\n",&prntBuf[0]);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************************************************/
|
||||
switch_status_t megaco_profile_status(switch_stream_handle_t *stream, const char* profilename)
|
||||
{
|
||||
int idx = 0x00;
|
||||
int len = 0x00;
|
||||
MgMngmt cfm;
|
||||
char prntBuf[1024];
|
||||
megaco_profile_t* mg_cfg = NULL;
|
||||
mg_peer_profile_t* mg_peer = NULL;
|
||||
|
||||
switch_assert(profilename);
|
||||
|
||||
memset((U8 *)&cfm, 0, sizeof(cfm));
|
||||
memset((char *)&prntBuf, 0, sizeof(prntBuf));
|
||||
|
||||
mg_cfg = megaco_profile_locate(profilename);
|
||||
if(!mg_cfg){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG configuration found against profilename[%s]\n",profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
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],profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
idx = mg_cfg->idx;
|
||||
|
||||
/*stream->write_function(stream, "Collecting MG Profile[%s] status... \n",profilename);*/
|
||||
|
||||
/* Fetch data from Trillium MEGACO Stack *
|
||||
* SystemId - Software version information *
|
||||
* SSAP - MG SAP Information *
|
||||
* TSAP - MG Transport SAP Information *
|
||||
* Peer - MG Peer Information *
|
||||
* TPT-Server - MG Transport Server information *
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/* get System ID */
|
||||
sng_mgco_mg_get_status(STSID, &cfm, idx);
|
||||
stream->write_function(stream, "***********************************************\n");
|
||||
stream->write_function(stream, "**** TRILLIUM MEGACO Software Information *****\n");
|
||||
stream->write_function(stream, "Version = %d \n", cfm.t.ssta.s.systemId.mVer);
|
||||
stream->write_function(stream, "Version Revision = %d \n", cfm.t.ssta.s.systemId.mRev);
|
||||
stream->write_function(stream, "Branch Version = %d \n", cfm.t.ssta.s.systemId.bVer);
|
||||
stream->write_function(stream, "Branch Revision = %d \n", cfm.t.ssta.s.systemId.bRev);
|
||||
stream->write_function(stream, "Part Number = %d \n", cfm.t.ssta.s.systemId.ptNmb);
|
||||
stream->write_function(stream, "***********************************************\n");
|
||||
#endif
|
||||
|
||||
/* MG Peer Information */
|
||||
sng_mgco_mg_get_status(STGCPENT, &cfm, mg_cfg, mg_peer);
|
||||
smmgPrntPeerSta(&cfm.t.ssta.s.mgPeerSta);
|
||||
|
||||
/* MG Peer Information */
|
||||
sng_mgco_mg_get_status(STSSAP, &cfm, mg_cfg, mg_peer);
|
||||
smmgPrntSsapSta(&cfm.t.ssta.s.mgSSAPSta);
|
||||
|
||||
/* MG Transport SAP Information */
|
||||
sng_mgco_mg_get_status(STTSAP, &cfm, mg_cfg, mg_peer);
|
||||
len = len + sprintf(prntBuf+len,"***********************************************\n");
|
||||
len = len + sprintf(prntBuf+len,"**********MG TRANSPORT SAP Information**********\n");
|
||||
len = len + sprintf(prntBuf+len,"TSAP status:\n");
|
||||
len = len + sprintf(prntBuf+len,"state = %d, number of listeners %u\n",
|
||||
(int)(cfm.t.ssta.s.mgTSAPSta.state),
|
||||
(unsigned int)(cfm.t.ssta.s.mgTSAPSta.numServers));
|
||||
len = len + sprintf(prntBuf+len,"***********************************************\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,"%s\n",prntBuf);
|
||||
|
||||
/* MG Transport Server Information */
|
||||
sng_mgco_mg_get_status(STSERVER, &cfm, mg_cfg, mg_peer);
|
||||
smmgPrntSrvSta(&cfm.t.ssta.s.mgTptSrvSta);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm)
|
||||
{
|
||||
int len = 0x00;
|
||||
int i = 0x00;
|
||||
char *asciiAddr;
|
||||
CmInetIpAddr ip;
|
||||
|
||||
if(PRSNT_NODEF == cfm->namePres.pres)
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<domain_name> %s </domain_name>\n", (char *)(cfm->name));
|
||||
}
|
||||
else
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<domain_name> Not Present </domain_name>\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Print all IP addresses in the IP addr table
|
||||
*/
|
||||
for(i=0; i<cfm->peerAddrTbl.count; i++)
|
||||
{
|
||||
switch (cfm->peerAddrTbl.netAddr[i].type)
|
||||
{
|
||||
case CM_NETADDR_IPV4:
|
||||
{
|
||||
ip = ntohl(cfm->peerAddrTbl.netAddr[i].u.ipv4NetAddr);
|
||||
cmInetNtoa(ip, &asciiAddr);
|
||||
len = len + sprintf(prntBuf+len, "<ipv4_address>%s</ipv4_address>\n",asciiAddr);
|
||||
break;
|
||||
}
|
||||
case CM_NETADDR_IPV6:
|
||||
{
|
||||
char ipv6_buf[128];
|
||||
int len1= 0;
|
||||
int j = 0;
|
||||
memset(&ipv6_buf[0], 0, sizeof(ipv6_buf));
|
||||
len1 = len1 + sprintf(ipv6_buf+len1, "IP V6 address : %2x", (unsigned int)
|
||||
(cfm->peerAddrTbl.netAddr[i].u.ipv6NetAddr[0]));
|
||||
|
||||
for (j = 1; j < CM_IPV6ADDR_SIZE; j++)
|
||||
{
|
||||
len1 = len1 + sprintf(ipv6_buf+len1, ":%2x", (unsigned int)
|
||||
(cfm->peerAddrTbl.netAddr[i].u.ipv6NetAddr[j]));
|
||||
}
|
||||
len1 = len1 + sprintf(ipv6_buf+len1, "\n");
|
||||
len = len + sprintf(prntBuf+len, "<ipv6_address>%s</ipv6_address>\n", ipv6_buf);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<ip_address> Invalid address type[%d]</ip_address>\n", cfm->peerAddrTbl.netAddr[i].type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* End of for */
|
||||
|
||||
len = len + sprintf(prntBuf+len,"<num_of_pending_out_txn> %lu </num_of_pending_out_txn>\n",(unsigned long)(cfm->numPendOgTxn));
|
||||
len = len + sprintf(prntBuf+len,"<num_of_pending_in_txn> %lu </num_of_pending_in_txn>\n",(unsigned long)(cfm->numPendIcTxn));
|
||||
len = len + sprintf(prntBuf+len,"<round_trip_estimate_time> %lu </round_trip_estimate_time>\n",(unsigned long)(cfm->rttEstimate));
|
||||
|
||||
switch(cfm->protocol)
|
||||
{
|
||||
case LMG_PROTOCOL_MGCP:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> MGCP </protocol_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_PROTOCOL_MGCO:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> MEGACO </protocol_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_PROTOCOL_NONE:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> MGCP/MEGACO </protocol_type>\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> invalid </protocol_type>\n");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(cfm->transportType)
|
||||
{
|
||||
case LMG_TPT_UDP:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>UDP</transport_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_TPT_TCP:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>TCP</transport_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_TPT_NONE:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>UDP/TCP</transport_type>\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>invalid</transport_type>\n");
|
||||
break;
|
||||
}
|
||||
#ifdef GCP_MGCO
|
||||
switch(cfm->encodingScheme)
|
||||
{
|
||||
case LMG_ENCODE_BIN:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>BINARY</encoding_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_ENCODE_TXT:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>TEXT</encoding_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_ENCODE_NONE:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>TEXT/BINARY</encoding_type>\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>invalid</encoding_type>\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(LMG_VER_PROF_MGCO_H248_1_0 == cfm->version){
|
||||
len = len + sprintf(prntBuf+len, "<version>1.0</version> \n");
|
||||
} else if(LMG_VER_PROF_MGCO_H248_2_0 == cfm->version){
|
||||
len = len + sprintf(prntBuf+len, "<version>2.0</version> \n");
|
||||
}else if(LMG_VER_PROF_MGCO_H248_3_0 == cfm->version){
|
||||
len = len + sprintf(prntBuf+len, "<version>3.0</version> \n");
|
||||
} else{
|
||||
len = len + sprintf(prntBuf+len, "<version>invalid</version> \n");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
/******************************************************************************/
|
||||
|
|
@ -37,7 +37,6 @@ int sng_mgco_mg_app_ssap_stop(int idx);
|
|||
|
||||
switch_status_t sng_mgco_stack_gen_cfg();
|
||||
|
||||
void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm);
|
||||
|
||||
sng_mg_transport_types_e mg_get_tpt_type(megaco_profile_t* mg_cfg);
|
||||
sng_mg_transport_types_e mg_get_tpt_type_from_str(char* tpt_type);
|
||||
|
@ -1179,482 +1178,6 @@ int sng_mgco_mg_shutdown()
|
|||
return (sng_cntrl_mg (&pst, &cntrl));
|
||||
}
|
||||
/******************************************************************************/
|
||||
void handle_mg_alarm(Pst *pst, MgMngmt *usta)
|
||||
{
|
||||
U16 ret;
|
||||
int len = 0x00;
|
||||
char prBuf[3048];
|
||||
|
||||
memset(&prBuf[0], 0, sizeof(prBuf));
|
||||
|
||||
len = len + sprintf(prBuf+len,"MG Status Indication: received with Category = %d, Event = %d, Cause = %d \n",
|
||||
usta->t.usta.alarm.category, usta->t.usta.alarm.event,
|
||||
usta->t.usta.alarm.cause);
|
||||
|
||||
len = len + sprintf(prBuf+len, "Category ( ");
|
||||
|
||||
switch (usta->t.usta.alarm.category)
|
||||
{
|
||||
case LCM_CATEGORY_PROTOCOL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "protocol related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_INTERFACE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "interface related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_INTERNAL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "internal ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_RESOURCE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "system resources related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_PSF_FTHA:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "fault tolerance / high availability PSF related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_LYR_SPECIFIC:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGCP related ");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown: %d", (int)(usta->t.usta.alarm.category));
|
||||
break;
|
||||
}
|
||||
}
|
||||
len = len + sprintf(prBuf+len, ") ");
|
||||
|
||||
len = len + sprintf(prBuf+len, " Event ( ");
|
||||
switch (usta->t.usta.alarm.event)
|
||||
{
|
||||
case LMG_EVENT_TSAP_RECVRY_SUCCESS:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "TSAP recovery success");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_TSAP_RECVRY_FAILED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "TSAP recovery failed");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_UI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "upper interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_LI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "lower interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_PI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "peer interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "general invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_INV_STATE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid internal state");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_INV_TMR_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid timer event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_MI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "management interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_BND_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "bind failure");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_NAK:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "destination nack");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_TIMEOUT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "timeout");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_BND_OK:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "bind ok");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_SMEM_ALLOC_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "static memory allocation failed");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_DMEM_ALLOC_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "dynamic mmemory allocation failed");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_LYR_SPECIFIC:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGCP specific");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown event %d", (int)(usta->t.usta.alarm.event));
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_BNDCFM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT bind confirm");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_CONCFM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT connect confirm");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_DISCIND:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT disconnect indication");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_UDATIND:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT unit data indication");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_BNDREQ:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT bind request");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_PEER_CFG_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "Peer Configuration Failed");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_UBNDREQ:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT unbind request");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_MGCPTXNREQ:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT MGCP transaction request");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_MGCPTXNIND:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT MGCP transaction indication");
|
||||
break;
|
||||
}
|
||||
|
||||
case LMG_EVENT_PEER_ENABLED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "gateway enabled");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_PEER_DISCOVERED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "gateway discovered , notified entity");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_PEER_REMOVED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "gateway removed");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_RES_CONG_ON:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "resource congestion ON");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_RES_CONG_OFF:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "resource congestion OFF");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_TPTSRV:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "transport service");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_SSAP_ENABLED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "SSAP enabled");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_NS_NOT_RESPONDING:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "name server not responding");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_TPT_FAILED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "transport failure");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
len = len + sprintf(prBuf+len, " ) ");
|
||||
|
||||
len = len + sprintf(prBuf+len, " cause ( ");
|
||||
switch (usta->t.usta.alarm.cause)
|
||||
{
|
||||
case LCM_CAUSE_UNKNOWN:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_OUT_OF_RANGE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "out of range");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_SAP:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "NULL/unknown sap");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_SPID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid service provider");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_SUID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid service user");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_NETWORK_MSG:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid network message");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_DECODE_ERR:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "message decoding problem");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_USER_INITIATED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "user initiated");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_MGMT_INITIATED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "management initiated");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_STATE: /* cause and event! */
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid state");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_TMR_EXPIRED: /* cause and event! */
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "timer expired");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_MSG_LENGTH:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid message length");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_PROT_NOT_ACTIVE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "protocol layer not active");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_PAR_VAL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid parameter value");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_NEG_CFM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "negative confirmation");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_MEM_ALLOC_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "memory allocation failure");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_HASH_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "hashing failure");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_LYR_SPECIFIC:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGCP specific");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown %d", (int)(usta->t.usta.alarm.cause));
|
||||
break;
|
||||
}
|
||||
case LMG_CAUSE_TPT_FAILURE: /* make up your mind - cause or event? */
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "transport failure");
|
||||
break;
|
||||
}
|
||||
case LMG_CAUSE_NS_NOT_RESPONDING:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "name server not responding");
|
||||
break;
|
||||
}
|
||||
}
|
||||
len = len + sprintf(prBuf+len, " ) ");
|
||||
|
||||
len = len + sprintf(prBuf+len, " Alarm parameters ( ");
|
||||
ret = smmgGetAlarmInfoField(&usta->t.usta);
|
||||
switch (ret)
|
||||
{
|
||||
case SMMG_UNKNOWNFIELD:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid ");
|
||||
|
||||
break;
|
||||
}
|
||||
case SMMG_PEERINFO:
|
||||
{
|
||||
/*
|
||||
* Invoke the new function for printing the MgPeerInfo &
|
||||
* delete all print code here
|
||||
*/
|
||||
smmgPrntPeerInfo(&(usta->t.usta.alarmInfo.u.peerInfo));
|
||||
break;
|
||||
}
|
||||
case SMMG_SAPID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "SAP ID %d\n", (int)(usta->t.usta.alarmInfo.u.sapId));
|
||||
break;
|
||||
}
|
||||
case SMMG_MEM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "memory region %d pool %d\n",
|
||||
(int)(usta->t.usta.alarmInfo.u.mem.region),
|
||||
(int)(usta->t.usta.alarmInfo.u.mem.pool));
|
||||
|
||||
break;
|
||||
}
|
||||
case SMMG_SRVSTA:
|
||||
{
|
||||
smmgPrntSrvSta(&usta->t.usta.alarmInfo.u.srvSta);
|
||||
break;
|
||||
}
|
||||
case SMMG_PEERSTA:
|
||||
{
|
||||
smmgPrntPeerSta(&usta->t.usta.alarmInfo.u.peerSta);
|
||||
break;
|
||||
}
|
||||
case SMMG_SSAPSTA:
|
||||
{
|
||||
smmgPrntSsapSta(&usta->t.usta.alarmInfo.u.ssapSta);
|
||||
break;
|
||||
}
|
||||
case SMMG_PARID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "parameter type: ");
|
||||
switch (usta->t.usta.alarmInfo.u.parId.parType)
|
||||
{
|
||||
case LMG_PAR_TPTADDR: len = len + sprintf(prBuf+len, "transport address"); break;
|
||||
case LMG_PAR_MBUF: len = len + sprintf(prBuf+len, "message buffer"); break;
|
||||
case LMG_PAR_CHOICE: len = len + sprintf(prBuf+len, "choice"); break;
|
||||
case LMG_PAR_SPID: len = len + sprintf(prBuf+len, "spId"); break;
|
||||
default: len = len + sprintf(prBuf+len, "unknown"); break;
|
||||
}
|
||||
|
||||
len = len + sprintf(prBuf+len, ", value %d\n",
|
||||
(int)(usta->t.usta.alarmInfo.u.parId.u.sapId));
|
||||
|
||||
break;
|
||||
}
|
||||
case SMMG_NOT_APPL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "not applicable\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*TODO*/
|
||||
}
|
||||
len = len + sprintf(prBuf+len, " ) ");
|
||||
len = len + sprintf(prBuf+len, " \n ");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s \n", prBuf);
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
void handle_tucl_alarm(Pst *pst, HiMngmt *sta)
|
||||
{
|
||||
/* To print the general information */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recieved a status indication from TUCL layer \n\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Category = %d , event = %d , cause = %d\n",
|
||||
sta->t.usta.alarm.category,
|
||||
sta->t.usta.alarm.event, sta->t.usta.alarm.cause);
|
||||
|
||||
switch(sta->t.usta.alarm.event)
|
||||
{
|
||||
case LCM_EVENT_INV_EVT:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," [HI_USTA]: LCM_EVENT_INV_EVT with type (%d)\n\n",
|
||||
sta->t.usta.info.type);
|
||||
break;
|
||||
}
|
||||
case LHI_EVENT_BNDREQ:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," [HI_USTA]: LHI_EVENT_BNDREQ with type (%d) spId (%d)\n\n",
|
||||
sta->t.usta.info.type, sta->t.usta.info.spId);
|
||||
break;
|
||||
}
|
||||
case LHI_EVENT_SERVOPENREQ:
|
||||
case LHI_EVENT_DATREQ:
|
||||
case LHI_EVENT_UDATREQ:
|
||||
case LHI_EVENT_CONREQ:
|
||||
case LHI_EVENT_DISCREQ:
|
||||
#if(defined(HI_TLS) && defined(HI_TCP_TLS))
|
||||
case LHI_EVENT_TLS_ESTREQ:
|
||||
#endif
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," [HI_USTA]: partype (%d) type(%d)\n\n",
|
||||
sta->t.usta.info.inf.parType, sta->t.usta.info.type);
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_DMEM_ALLOC_FAIL:
|
||||
case LCM_EVENT_SMEM_ALLOC_FAIL:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " [HI_USTA]: MEM_ALLOC_FAIL with region(%d) pool (%d) type(%d)\n\n",
|
||||
sta->t.usta.info.inf.mem.region, sta->t.usta.info.inf.mem.pool,
|
||||
sta->t.usta.info.type);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} /* handle_sng_tucl_alarm */
|
||||
/******************************************************************************/
|
||||
|
||||
int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg, mg_peer_profile_t* mg_peer)
|
||||
{
|
||||
Pst pst;
|
||||
|
@ -1722,368 +1245,7 @@ int sng_mgco_mg_get_status(int elemId, MgMngmt* cfm, megaco_profile_t* mg_cfg,
|
|||
|
||||
return (sng_sta_mg (&pst, &cntrl, cfm));
|
||||
}
|
||||
/******************************************************************************/
|
||||
switch_status_t megaco_profile_status(switch_stream_handle_t *stream, const char* profilename)
|
||||
{
|
||||
int idx = 0x00;
|
||||
int len = 0x00;
|
||||
MgMngmt cfm;
|
||||
char prntBuf[1024];
|
||||
megaco_profile_t* mg_cfg = NULL;
|
||||
mg_peer_profile_t* mg_peer = NULL;
|
||||
|
||||
switch_assert(profilename);
|
||||
|
||||
memset((U8 *)&cfm, 0, sizeof(cfm));
|
||||
memset((char *)&prntBuf, 0, sizeof(prntBuf));
|
||||
|
||||
mg_cfg = megaco_profile_locate(profilename);
|
||||
if(!mg_cfg){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG configuration found against profilename[%s]\n",profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
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],profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
idx = mg_cfg->idx;
|
||||
|
||||
/*stream->write_function(stream, "Collecting MG Profile[%s] status... \n",profilename);*/
|
||||
|
||||
/* Fetch data from Trillium MEGACO Stack *
|
||||
* SystemId - Software version information *
|
||||
* SSAP - MG SAP Information *
|
||||
* TSAP - MG Transport SAP Information *
|
||||
* Peer - MG Peer Information *
|
||||
* TPT-Server - MG Transport Server information *
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/* get System ID */
|
||||
sng_mgco_mg_get_status(STSID, &cfm, idx);
|
||||
stream->write_function(stream, "***********************************************\n");
|
||||
stream->write_function(stream, "**** TRILLIUM MEGACO Software Information *****\n");
|
||||
stream->write_function(stream, "Version = %d \n", cfm.t.ssta.s.systemId.mVer);
|
||||
stream->write_function(stream, "Version Revision = %d \n", cfm.t.ssta.s.systemId.mRev);
|
||||
stream->write_function(stream, "Branch Version = %d \n", cfm.t.ssta.s.systemId.bVer);
|
||||
stream->write_function(stream, "Branch Revision = %d \n", cfm.t.ssta.s.systemId.bRev);
|
||||
stream->write_function(stream, "Part Number = %d \n", cfm.t.ssta.s.systemId.ptNmb);
|
||||
stream->write_function(stream, "***********************************************\n");
|
||||
#endif
|
||||
|
||||
/* MG Peer Information */
|
||||
sng_mgco_mg_get_status(STGCPENT, &cfm, mg_cfg, mg_peer);
|
||||
smmgPrntPeerSta(&cfm.t.ssta.s.mgPeerSta);
|
||||
|
||||
/* MG Peer Information */
|
||||
sng_mgco_mg_get_status(STSSAP, &cfm, mg_cfg, mg_peer);
|
||||
smmgPrntSsapSta(&cfm.t.ssta.s.mgSSAPSta);
|
||||
|
||||
/* MG Transport SAP Information */
|
||||
sng_mgco_mg_get_status(STTSAP, &cfm, mg_cfg, mg_peer);
|
||||
len = len + sprintf(prntBuf+len,"***********************************************\n");
|
||||
len = len + sprintf(prntBuf+len,"**********MG TRANSPORT SAP Information**********\n");
|
||||
len = len + sprintf(prntBuf+len,"TSAP status:\n");
|
||||
len = len + sprintf(prntBuf+len,"state = %d, number of listeners %u\n",
|
||||
(int)(cfm.t.ssta.s.mgTSAPSta.state),
|
||||
(unsigned int)(cfm.t.ssta.s.mgTSAPSta.numServers));
|
||||
len = len + sprintf(prntBuf+len,"***********************************************\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,"%s\n",prntBuf);
|
||||
|
||||
/* MG Transport Server Information */
|
||||
sng_mgco_mg_get_status(STSERVER, &cfm, mg_cfg, mg_peer);
|
||||
smmgPrntSrvSta(&cfm.t.ssta.s.mgTptSrvSta);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
/******************************************************************************/
|
||||
switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, const char* profilename)
|
||||
{
|
||||
int idx = 0x00;
|
||||
int len = 0x00;
|
||||
MgMngmt cfm;
|
||||
char* xmlhdr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
|
||||
char prntBuf[3048];
|
||||
int i = 0x00;
|
||||
char *asciiAddr;
|
||||
CmInetIpAddr ip;
|
||||
megaco_profile_t* mg_cfg = NULL;
|
||||
mg_peer_profile_t* mg_peer = NULL;
|
||||
|
||||
switch_assert(profilename);
|
||||
|
||||
memset((U8 *)&cfm, 0, sizeof(cfm));
|
||||
memset((char *)&prntBuf, 0, sizeof(prntBuf));
|
||||
|
||||
mg_cfg = megaco_profile_locate(profilename);
|
||||
if(!mg_cfg){
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," No MG configuration found against profilename[%s]\n",profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
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],profilename);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
idx = mg_cfg->idx;
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"%s\n",xmlhdr);
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_profile>\n");
|
||||
len = len + sprintf(&prntBuf[0] + len,"<name>%s</name>\n",mg_cfg->name);
|
||||
len = len + sprintf(&prntBuf[0] + len,"<profile>%s</profile>\n",profilename);
|
||||
/****************************************************************************************************************/
|
||||
/* 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);
|
||||
|
||||
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");
|
||||
|
||||
|
||||
/****************************************************************************************************************/
|
||||
/* Print MG SAP Information ***************************************************************************************/
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_sap>\n");
|
||||
|
||||
/* MG SAP Information */
|
||||
sng_mgco_mg_get_status(STSSAP, &cfm, mg_cfg, mg_peer);
|
||||
|
||||
len = len + sprintf(prntBuf+len, "<state> %s </state>\n", PRNT_SAP_STATE((int)(cfm.t.ssta.s.mgSSAPSta.state)));
|
||||
len = len + sprintf(prntBuf+len, "<num_of_peer> %u </num_of_peer>\n", (unsigned int)(cfm.t.ssta.s.mgSSAPSta.numAssocPeer));
|
||||
len = len + sprintf(prntBuf+len, "<num_of_listeners> %u </num_of_listeners>\n", (unsigned int)(cfm.t.ssta.s.mgSSAPSta.numServers));
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_sap_peers>\n");
|
||||
for (i = 0; i < cfm.t.ssta.s.mgSSAPSta.numAssocPeer; i++)
|
||||
{
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_sap_peer>\n");
|
||||
if(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.namePres.pres == PRSNT_NODEF)
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<domain_name> %s </domain_name>\n", (char *)(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.name));
|
||||
}
|
||||
switch(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.netAddr.type)
|
||||
{
|
||||
case CM_NETADDR_IPV4:
|
||||
{
|
||||
ip = ntohl(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].dname.netAddr.u.ipv4NetAddr);
|
||||
cmInetNtoa(ip, &asciiAddr);
|
||||
len = len + sprintf(prntBuf+len, "<ipv4_address>%s</ipv4_address>\n",asciiAddr);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "<ip_address>invalid type </ip_address>\n");
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef GCP_MGCO
|
||||
if (PRSNT_NODEF == cfm.t.ssta.s.mgSSAPSta.peerInfo[i].mid.pres)
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<peer_mid> %s </peer_mid>\n", (char *)(cfm.t.ssta.s.mgSSAPSta.peerInfo[i].mid.val));
|
||||
}
|
||||
#endif /* GCP_MGCO */
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_sap_peer>\n");
|
||||
}
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_sap_peers>\n");
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_sap>\n");
|
||||
|
||||
/****************************************************************************************************************/
|
||||
/* Print MG Transport SAP Information ***************************************************************************************/
|
||||
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_transport_sap>\n");
|
||||
/* MG Transport SAP Information */
|
||||
sng_mgco_mg_get_status(STTSAP, &cfm, mg_cfg, mg_peer);
|
||||
len = len + sprintf(&prntBuf[0] + len,"<state> %s </state>\n", PRNT_SAP_STATE(cfm.t.ssta.s.mgTSAPSta.state));
|
||||
len = len + sprintf(&prntBuf[0] + len,"<num_of_listeners> %u </num_of_listeners>\n", (unsigned int)(cfm.t.ssta.s.mgTSAPSta.numServers));
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_transport_sap>\n");
|
||||
|
||||
/****************************************************************************************************************/
|
||||
/* Print MG Transport Server Information ***************************************************************************************/
|
||||
|
||||
if(sng_mgco_mg_get_status(STSERVER, &cfm, mg_cfg, mg_peer)){
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_transport_server> no established server found </mg_transport_server>\n");
|
||||
}
|
||||
else {
|
||||
len = len + sprintf(&prntBuf[0] + len,"<mg_transport_server>\n");
|
||||
len = len + sprintf(&prntBuf[0] + len,"<state> %s </state>\n", PRNT_SAP_STATE(cfm.t.ssta.s.mgTptSrvSta.state));
|
||||
len = len + sprintf(prntBuf+len, "<transport_address>");
|
||||
|
||||
switch (cfm.t.ssta.s.mgTptSrvSta.tptAddr.type)
|
||||
{
|
||||
case CM_TPTADDR_NOTPRSNT:
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "none");
|
||||
break;
|
||||
}
|
||||
case CM_TPTADDR_IPV4:
|
||||
{
|
||||
ip = ntohl(cfm.t.ssta.s.mgTptSrvSta.tptAddr.u.ipv4TptAddr.address);
|
||||
cmInetNtoa(ip, &asciiAddr);
|
||||
len = len + sprintf(prntBuf+len, "IPv4 IP address #%s, port %u",asciiAddr,
|
||||
(unsigned int)(cfm.t.ssta.s.mgTptSrvSta.tptAddr.u.ipv4TptAddr.port));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "unknown");
|
||||
break;
|
||||
}
|
||||
len = len + sprintf(prntBuf+len, "</transport_address>\n");
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_transport_server>\n");
|
||||
}
|
||||
|
||||
/****************************************************************************************************************/
|
||||
len = len + sprintf(&prntBuf[0] + len,"</mg_profile>\n");
|
||||
|
||||
stream->write_function(stream, "\n%s\n",&prntBuf[0]);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm)
|
||||
{
|
||||
int len = 0x00;
|
||||
int i = 0x00;
|
||||
char *asciiAddr;
|
||||
CmInetIpAddr ip;
|
||||
|
||||
if(PRSNT_NODEF == cfm->namePres.pres)
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<domain_name> %s </domain_name>\n", (char *)(cfm->name));
|
||||
}
|
||||
else
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<domain_name> Not Present </domain_name>\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Print all IP addresses in the IP addr table
|
||||
*/
|
||||
for(i=0; i<cfm->peerAddrTbl.count; i++)
|
||||
{
|
||||
switch (cfm->peerAddrTbl.netAddr[i].type)
|
||||
{
|
||||
case CM_NETADDR_IPV4:
|
||||
{
|
||||
ip = ntohl(cfm->peerAddrTbl.netAddr[i].u.ipv4NetAddr);
|
||||
cmInetNtoa(ip, &asciiAddr);
|
||||
len = len + sprintf(prntBuf+len, "<ipv4_address>%s</ipv4_address>\n",asciiAddr);
|
||||
break;
|
||||
}
|
||||
case CM_NETADDR_IPV6:
|
||||
{
|
||||
char ipv6_buf[128];
|
||||
int len1= 0;
|
||||
int j = 0;
|
||||
memset(&ipv6_buf[0], 0, sizeof(ipv6_buf));
|
||||
len1 = len1 + sprintf(ipv6_buf+len1, "IP V6 address : %2x", (unsigned int)
|
||||
(cfm->peerAddrTbl.netAddr[i].u.ipv6NetAddr[0]));
|
||||
|
||||
for (j = 1; j < CM_IPV6ADDR_SIZE; j++)
|
||||
{
|
||||
len1 = len1 + sprintf(ipv6_buf+len1, ":%2x", (unsigned int)
|
||||
(cfm->peerAddrTbl.netAddr[i].u.ipv6NetAddr[j]));
|
||||
}
|
||||
len1 = len1 + sprintf(ipv6_buf+len1, "\n");
|
||||
len = len + sprintf(prntBuf+len, "<ipv6_address>%s</ipv6_address>\n", ipv6_buf);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prntBuf+len, "<ip_address> Invalid address type[%d]</ip_address>\n", cfm->peerAddrTbl.netAddr[i].type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* End of for */
|
||||
|
||||
len = len + sprintf(prntBuf+len,"<num_of_pending_out_txn> %lu </num_of_pending_out_txn>\n",(unsigned long)(cfm->numPendOgTxn));
|
||||
len = len + sprintf(prntBuf+len,"<num_of_pending_in_txn> %lu </num_of_pending_in_txn>\n",(unsigned long)(cfm->numPendIcTxn));
|
||||
len = len + sprintf(prntBuf+len,"<round_trip_estimate_time> %lu </round_trip_estimate_time>\n",(unsigned long)(cfm->rttEstimate));
|
||||
|
||||
switch(cfm->protocol)
|
||||
{
|
||||
case LMG_PROTOCOL_MGCP:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> MGCP </protocol_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_PROTOCOL_MGCO:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> MEGACO </protocol_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_PROTOCOL_NONE:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> MGCP/MEGACO </protocol_type>\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len,"<protocol_type> invalid </protocol_type>\n");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(cfm->transportType)
|
||||
{
|
||||
case LMG_TPT_UDP:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>UDP</transport_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_TPT_TCP:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>TCP</transport_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_TPT_NONE:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>UDP/TCP</transport_type>\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "<transport_type>invalid</transport_type>\n");
|
||||
break;
|
||||
}
|
||||
#ifdef GCP_MGCO
|
||||
switch(cfm->encodingScheme)
|
||||
{
|
||||
case LMG_ENCODE_BIN:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>BINARY</encoding_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_ENCODE_TXT:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>TEXT</encoding_type>\n");
|
||||
break;
|
||||
|
||||
case LMG_ENCODE_NONE:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>TEXT/BINARY</encoding_type>\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
len = len + sprintf(prntBuf+len, "<encoding_type>invalid</encoding_type>\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(LMG_VER_PROF_MGCO_H248_1_0 == cfm->version){
|
||||
len = len + sprintf(prntBuf+len, "<version>1.0</version> \n");
|
||||
} else if(LMG_VER_PROF_MGCO_H248_2_0 == cfm->version){
|
||||
len = len + sprintf(prntBuf+len, "<version>2.0</version> \n");
|
||||
}else if(LMG_VER_PROF_MGCO_H248_3_0 == cfm->version){
|
||||
len = len + sprintf(prntBuf+len, "<version>3.0</version> \n");
|
||||
} else{
|
||||
len = len + sprintf(prntBuf+len, "<version>invalid</version> \n");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
sng_mg_transport_types_e mg_get_tpt_type(megaco_profile_t* mg_profile)
|
||||
{
|
||||
|
|
|
@ -8,36 +8,10 @@
|
|||
|
||||
#include "mod_megaco.h"
|
||||
|
||||
#ifndef _MEGACO_CFG_H_
|
||||
#define _MEGACO_CFG_H_
|
||||
#ifndef _MEGACO_STACK_H_
|
||||
#define _MEGACO_STACK_H_
|
||||
|
||||
#define MAX_MID_LEN 30
|
||||
#define MAX_DOMAIN_LEN 30
|
||||
#define MAX_NAME_LEN 25
|
||||
#define MAX_MG_PROFILES 5
|
||||
|
||||
#if 0
|
||||
typedef struct sng_mg_peer{
|
||||
char name[MAX_NAME_LEN]; /* Peer Name as defined in config file */
|
||||
uint16_t id; /* Peer ID as defined in config file */
|
||||
uint8_t ipaddr[MAX_DOMAIN_LEN]; /* Peer IP */
|
||||
uint16_t port; /*Peer Port */
|
||||
uint8_t mid[MAX_MID_LEN]; /* Peer H.248 MID */
|
||||
uint16_t encoding_type; /* Encoding TEXT/Binary */
|
||||
}sng_mg_peer_t;
|
||||
|
||||
typedef struct sng_mg_peers{
|
||||
uint16_t total_peer; /* Total number of MGC Peer */
|
||||
sng_mg_peer_t peers[MG_MAX_PEERS+1];
|
||||
}sng_mg_peers_t;
|
||||
|
||||
typedef struct sng_mg_transport_profile{
|
||||
char name[MAX_NAME_LEN]; /* Peer Name as defined in config file */
|
||||
uint32_t id; /* map to tsap id */
|
||||
uint16_t transport_type; /* transport type */
|
||||
}sng_mg_transport_profile_t;
|
||||
|
||||
#endif
|
||||
|
||||
typedef enum{
|
||||
SNG_MG_TPT_NONE,
|
||||
|
@ -70,36 +44,6 @@ typedef enum{
|
|||
"SNG_MG_ENCODING_NONE")
|
||||
|
||||
|
||||
#if 0
|
||||
/* each profile is corresponds to each MG Instance */
|
||||
typedef struct sng_mg_cfg{
|
||||
char name[MAX_NAME_LEN]; /* MG(Virtual MG) Name as defined in config file */
|
||||
uint32_t id; /* Id - map to MG SAP ID */
|
||||
uint8_t mid[MAX_MID_LEN]; /* MG H.248 MID */
|
||||
uint8_t my_domain[MAX_DOMAIN_LEN]; /* local domain name */
|
||||
uint8_t my_ipaddr[MAX_DOMAIN_LEN]; /* local domain name */
|
||||
uint32_t port; /* port */
|
||||
uint16_t protocol_version; /* Protocol supported version */
|
||||
uint16_t peer_id; /* MGC Peer ID */
|
||||
uint16_t transport_prof_id; /* Transport profile id ..this also will be the spId for MG SAP*/
|
||||
uint16_t protocol_type; /* MEGACO/MGCP */
|
||||
}sng_mg_cfg_t;
|
||||
|
||||
|
||||
typedef struct sng_mg_gbl_cfg{
|
||||
int num_of_mg_profiles;
|
||||
sng_mg_cfg_t mgCfg[MAX_MG_PROFILES + 1];
|
||||
sng_mg_transport_profile_t mgTptProf[MG_MAX_PEERS+1]; /* transport profile */
|
||||
sng_mg_peers_t mgPeer;
|
||||
}sng_mg_gbl_cfg_t;
|
||||
|
||||
|
||||
extern switch_status_t sng_parse_mg_peer_profile(switch_xml_t mg_peer_profile);
|
||||
extern switch_status_t sng_parse_mg_tpt_profile(switch_xml_t mg_tpt_profile);
|
||||
extern switch_status_t sng_parse_mg_profile(switch_xml_t mg_interface);
|
||||
#endif
|
||||
|
||||
|
||||
void handle_sng_log(uint8_t level, char *fmt, ...);
|
||||
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* msg);
|
||||
void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* msg);
|
||||
|
@ -115,30 +59,5 @@ switch_status_t sng_mgco_cfg(megaco_profile_t* profile);
|
|||
switch_status_t sng_mgco_init(sng_isup_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);
|
||||
switch_status_t megaco_profile_status(switch_stream_handle_t *stream, const char* profilename);
|
||||
switch_status_t megaco_profile_xmlstatus(switch_stream_handle_t *stream, const char* profilename);
|
||||
|
||||
/*****************************************************************************************************/
|
||||
|
||||
#if 0
|
||||
#define GET_MG_CFG_IDX(_profilename, _idx){\
|
||||
for(idx=0; idx < MAX_MG_PROFILES; idx++){\
|
||||
/* id zero is not acceptable */\
|
||||
if(megaco_globals.g_mg_cfg.mgCfg[idx].id){\
|
||||
if (strcmp(megaco_globals.g_mg_cfg.mgCfg[idx].name, profilename)) {\
|
||||
continue;\
|
||||
} else{\
|
||||
break;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
#define GET_TPT_ID(_id) megaco_globals.g_mg_cfg.mgTptProf[megaco_globals.g_mg_cfg.mgCfg[_id].transport_prof_id].id
|
||||
#define GET_MU_SAP_ID(_id) megaco_globals.g_mg_cfg.mgCfg[_id].id
|
||||
|
||||
#define GET_TPT_TYPE(_id) megaco_globals.g_mg_cfg.mgTptProf[megaco_globals.g_mg_cfg.mgCfg[_id].transport_prof_id].transport_type
|
||||
|
||||
#define GET_ENCODING_TYPE(_id) megaco_globals.g_mg_cfg.mgPeer.peers[megaco_globals.g_mg_cfg.mgCfg[_id].peer_id].encoding_type
|
||||
#endif
|
||||
|
||||
#endif /* _MEGACO_CFG_H_ */
|
||||
#endif /* _MEGACO_STACK_H_ */
|
||||
|
|
|
@ -0,0 +1,495 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Sangoma Technologies
|
||||
* Kapil Gupta <kgupta@sangoma.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* <Insert license here>
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
#include "mod_megaco.h"
|
||||
#include "megaco_stack.h"
|
||||
/******************************************************************************/
|
||||
|
||||
/* FUNCTION PROTOTYPES ********************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
void handle_mg_alarm(Pst *pst, MgMngmt *usta)
|
||||
{
|
||||
U16 ret;
|
||||
int len = 0x00;
|
||||
char prBuf[3048];
|
||||
|
||||
memset(&prBuf[0], 0, sizeof(prBuf));
|
||||
|
||||
len = len + sprintf(prBuf+len,"MG Status Indication: received with Category = %d, Event = %d, Cause = %d \n",
|
||||
usta->t.usta.alarm.category, usta->t.usta.alarm.event,
|
||||
usta->t.usta.alarm.cause);
|
||||
|
||||
len = len + sprintf(prBuf+len, "Category ( ");
|
||||
|
||||
switch (usta->t.usta.alarm.category)
|
||||
{
|
||||
case LCM_CATEGORY_PROTOCOL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "protocol related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_INTERFACE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "interface related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_INTERNAL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "internal ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_RESOURCE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "system resources related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_PSF_FTHA:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "fault tolerance / high availability PSF related ");
|
||||
break;
|
||||
}
|
||||
case LCM_CATEGORY_LYR_SPECIFIC:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGCP related ");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown: %d", (int)(usta->t.usta.alarm.category));
|
||||
break;
|
||||
}
|
||||
}
|
||||
len = len + sprintf(prBuf+len, ") ");
|
||||
|
||||
len = len + sprintf(prBuf+len, " Event ( ");
|
||||
switch (usta->t.usta.alarm.event)
|
||||
{
|
||||
case LMG_EVENT_TSAP_RECVRY_SUCCESS:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "TSAP recovery success");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_TSAP_RECVRY_FAILED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "TSAP recovery failed");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_UI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "upper interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_LI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "lower interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_PI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "peer interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "general invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_INV_STATE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid internal state");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_INV_TMR_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid timer event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_MI_INV_EVT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "management interface invalid event");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_BND_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "bind failure");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_NAK:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "destination nack");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_TIMEOUT:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "timeout");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_BND_OK:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "bind ok");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_SMEM_ALLOC_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "static memory allocation failed");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_DMEM_ALLOC_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "dynamic mmemory allocation failed");
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_LYR_SPECIFIC:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGCP specific");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown event %d", (int)(usta->t.usta.alarm.event));
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_BNDCFM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT bind confirm");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_CONCFM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT connect confirm");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_DISCIND:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT disconnect indication");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_HIT_UDATIND:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "HIT unit data indication");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_BNDREQ:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT bind request");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_PEER_CFG_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "Peer Configuration Failed");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_UBNDREQ:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT unbind request");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_MGCPTXNREQ:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT MGCP transaction request");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_MGT_MGCPTXNIND:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGT MGCP transaction indication");
|
||||
break;
|
||||
}
|
||||
|
||||
case LMG_EVENT_PEER_ENABLED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "gateway enabled");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_PEER_DISCOVERED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "gateway discovered , notified entity");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_PEER_REMOVED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "gateway removed");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_RES_CONG_ON:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "resource congestion ON");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_RES_CONG_OFF:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "resource congestion OFF");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_TPTSRV:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "transport service");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_SSAP_ENABLED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "SSAP enabled");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_NS_NOT_RESPONDING:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "name server not responding");
|
||||
break;
|
||||
}
|
||||
case LMG_EVENT_TPT_FAILED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "transport failure");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
len = len + sprintf(prBuf+len, " ) ");
|
||||
|
||||
len = len + sprintf(prBuf+len, " cause ( ");
|
||||
switch (usta->t.usta.alarm.cause)
|
||||
{
|
||||
case LCM_CAUSE_UNKNOWN:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_OUT_OF_RANGE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "out of range");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_SAP:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "NULL/unknown sap");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_SPID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid service provider");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_SUID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid service user");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_NETWORK_MSG:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid network message");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_DECODE_ERR:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "message decoding problem");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_USER_INITIATED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "user initiated");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_MGMT_INITIATED:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "management initiated");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_STATE: /* cause and event! */
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid state");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_TMR_EXPIRED: /* cause and event! */
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "timer expired");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_MSG_LENGTH:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid message length");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_PROT_NOT_ACTIVE:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "protocol layer not active");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_INV_PAR_VAL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid parameter value");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_NEG_CFM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "negative confirmation");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_MEM_ALLOC_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "memory allocation failure");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_HASH_FAIL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "hashing failure");
|
||||
break;
|
||||
}
|
||||
case LCM_CAUSE_LYR_SPECIFIC:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "MGCP specific");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "unknown %d", (int)(usta->t.usta.alarm.cause));
|
||||
break;
|
||||
}
|
||||
case LMG_CAUSE_TPT_FAILURE: /* make up your mind - cause or event? */
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "transport failure");
|
||||
break;
|
||||
}
|
||||
case LMG_CAUSE_NS_NOT_RESPONDING:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "name server not responding");
|
||||
break;
|
||||
}
|
||||
}
|
||||
len = len + sprintf(prBuf+len, " ) ");
|
||||
|
||||
len = len + sprintf(prBuf+len, " Alarm parameters ( ");
|
||||
ret = smmgGetAlarmInfoField(&usta->t.usta);
|
||||
switch (ret)
|
||||
{
|
||||
case SMMG_UNKNOWNFIELD:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "invalid ");
|
||||
|
||||
break;
|
||||
}
|
||||
case SMMG_PEERINFO:
|
||||
{
|
||||
/*
|
||||
* Invoke the new function for printing the MgPeerInfo &
|
||||
* delete all print code here
|
||||
*/
|
||||
smmgPrntPeerInfo(&(usta->t.usta.alarmInfo.u.peerInfo));
|
||||
break;
|
||||
}
|
||||
case SMMG_SAPID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "SAP ID %d\n", (int)(usta->t.usta.alarmInfo.u.sapId));
|
||||
break;
|
||||
}
|
||||
case SMMG_MEM:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "memory region %d pool %d\n",
|
||||
(int)(usta->t.usta.alarmInfo.u.mem.region),
|
||||
(int)(usta->t.usta.alarmInfo.u.mem.pool));
|
||||
|
||||
break;
|
||||
}
|
||||
case SMMG_SRVSTA:
|
||||
{
|
||||
smmgPrntSrvSta(&usta->t.usta.alarmInfo.u.srvSta);
|
||||
break;
|
||||
}
|
||||
case SMMG_PEERSTA:
|
||||
{
|
||||
smmgPrntPeerSta(&usta->t.usta.alarmInfo.u.peerSta);
|
||||
break;
|
||||
}
|
||||
case SMMG_SSAPSTA:
|
||||
{
|
||||
smmgPrntSsapSta(&usta->t.usta.alarmInfo.u.ssapSta);
|
||||
break;
|
||||
}
|
||||
case SMMG_PARID:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "parameter type: ");
|
||||
switch (usta->t.usta.alarmInfo.u.parId.parType)
|
||||
{
|
||||
case LMG_PAR_TPTADDR: len = len + sprintf(prBuf+len, "transport address"); break;
|
||||
case LMG_PAR_MBUF: len = len + sprintf(prBuf+len, "message buffer"); break;
|
||||
case LMG_PAR_CHOICE: len = len + sprintf(prBuf+len, "choice"); break;
|
||||
case LMG_PAR_SPID: len = len + sprintf(prBuf+len, "spId"); break;
|
||||
default: len = len + sprintf(prBuf+len, "unknown"); break;
|
||||
}
|
||||
|
||||
len = len + sprintf(prBuf+len, ", value %d\n",
|
||||
(int)(usta->t.usta.alarmInfo.u.parId.u.sapId));
|
||||
|
||||
break;
|
||||
}
|
||||
case SMMG_NOT_APPL:
|
||||
{
|
||||
len = len + sprintf(prBuf+len, "not applicable\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/*TODO*/
|
||||
}
|
||||
len = len + sprintf(prBuf+len, " ) ");
|
||||
len = len + sprintf(prBuf+len, " \n ");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s \n", prBuf);
|
||||
}
|
||||
|
||||
/*****************************************************************************************************************************/
|
||||
void handle_tucl_alarm(Pst *pst, HiMngmt *sta)
|
||||
{
|
||||
/* To print the general information */
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Recieved a status indication from TUCL layer \n\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Category = %d , event = %d , cause = %d\n",
|
||||
sta->t.usta.alarm.category,
|
||||
sta->t.usta.alarm.event, sta->t.usta.alarm.cause);
|
||||
|
||||
switch(sta->t.usta.alarm.event)
|
||||
{
|
||||
case LCM_EVENT_INV_EVT:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," [HI_USTA]: LCM_EVENT_INV_EVT with type (%d)\n\n",
|
||||
sta->t.usta.info.type);
|
||||
break;
|
||||
}
|
||||
case LHI_EVENT_BNDREQ:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," [HI_USTA]: LHI_EVENT_BNDREQ with type (%d) spId (%d)\n\n",
|
||||
sta->t.usta.info.type, sta->t.usta.info.spId);
|
||||
break;
|
||||
}
|
||||
case LHI_EVENT_SERVOPENREQ:
|
||||
case LHI_EVENT_DATREQ:
|
||||
case LHI_EVENT_UDATREQ:
|
||||
case LHI_EVENT_CONREQ:
|
||||
case LHI_EVENT_DISCREQ:
|
||||
#if(defined(HI_TLS) && defined(HI_TCP_TLS))
|
||||
case LHI_EVENT_TLS_ESTREQ:
|
||||
#endif
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," [HI_USTA]: partype (%d) type(%d)\n\n",
|
||||
sta->t.usta.info.inf.parType, sta->t.usta.info.type);
|
||||
break;
|
||||
}
|
||||
case LCM_EVENT_DMEM_ALLOC_FAIL:
|
||||
case LCM_EVENT_SMEM_ALLOC_FAIL:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " [HI_USTA]: MEM_ALLOC_FAIL with region(%d) pool (%d) type(%d)\n\n",
|
||||
sta->t.usta.info.inf.mem.region, sta->t.usta.info.inf.mem.pool,
|
||||
sta->t.usta.info.type);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} /* handle_sng_tucl_alarm */
|
||||
/******************************************************************************/
|
||||
|
|
@ -165,229 +165,3 @@ static switch_xml_config_item_t *get_instructions(megaco_profile_t *profile) {
|
|||
}
|
||||
|
||||
/****************************************************************************************************************************/
|
||||
|
||||
#if 0
|
||||
switch_status_t sng_parse_mg_profile(switch_xml_t mg_interface)
|
||||
{
|
||||
int i = 0x00;
|
||||
const char *prof_name = NULL;
|
||||
switch_xml_t param;
|
||||
|
||||
/*************************************************************************/
|
||||
prof_name = switch_xml_attr_soft(mg_interface, "name");
|
||||
|
||||
/*************************************************************************/
|
||||
for (param = switch_xml_child(mg_interface, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!var || !val) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/******************************************************************************************/
|
||||
if(!strcasecmp(var, "id")){
|
||||
i = atoi(val);
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].id = i;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_interface Id[%d] \n", i);
|
||||
/*******************************************************************************************/
|
||||
}else if(!strcasecmp(var, "protocol")){
|
||||
/********************************************************************************************/
|
||||
if(!strcasecmp(val,"MEGACO")) {
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].protocol_type = SNG_MG_MEGACO;
|
||||
}else if(!strcasecmp(val,"MGCP")){
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].protocol_type = SNG_MG_MGCP;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MGCP Protocol Not Yet Supported \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}else{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Protocol Value[%s] \n",val);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_interface protocol[%d] \n",
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].protocol_type);
|
||||
/********************************************************************************************/
|
||||
}else if(!strcasecmp(var, "version")){
|
||||
/********************************************************************************************/
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].protocol_version = atoi(val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_interface protocol version[%s] \n",val);
|
||||
if((megaco_globals.g_mg_cfg.mgCfg[i].protocol_version < 1)
|
||||
|| (megaco_globals.g_mg_cfg.mgCfg[i].protocol_version > 3))
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Protocol version[%s] , Supported values are [1/2/3] \n",val);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
/********************************************************************************************/
|
||||
}else if(!strcasecmp(var, "transportProfileId")){
|
||||
/********************************************************************************************/
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].transport_prof_id = atoi(val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_interface transport_prof_id[%d] \n",
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].transport_prof_id);
|
||||
/********************************************************************************************/
|
||||
}else if(!strcasecmp(var, "localIp")){
|
||||
/***********************************************************************i*********************/
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgCfg[i].my_ipaddr[0],val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_interface my_ipaddr[%s] \n",
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].my_ipaddr);
|
||||
/********************************************************************************************/
|
||||
}else if(!strcasecmp(var, "port")){
|
||||
/********************************************************************************************/
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].port = atoi(val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_interface my_port[%d] \n", megaco_globals.g_mg_cfg.mgCfg[i].port);
|
||||
/********************************************************************************************/
|
||||
}else if(!strcasecmp(var, "myDomainName")){
|
||||
/********************************************************************************************/
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgCfg[i].my_domain[0],val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_interface myDomainName[%s] \n", megaco_globals.g_mg_cfg.mgCfg[i].my_domain);
|
||||
/********************************************************************************************/
|
||||
}else if(!strcasecmp(var, "mid")){
|
||||
/********************************************************************************************/
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgCfg[i].mid[0],val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_interface mid[%s] \n", megaco_globals.g_mg_cfg.mgCfg[i].mid);
|
||||
/********************************************************************************************/
|
||||
}else if(!strcasecmp(var, "peerId")){
|
||||
/********************************************************************************************/
|
||||
megaco_globals.g_mg_cfg.mgCfg[i].peer_id = atoi(val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_interface peerId[%d] \n", megaco_globals.g_mg_cfg.mgCfg[i].peer_id);
|
||||
/********************************************************************************************/
|
||||
}else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Invalid var[%s] in mg_interface \n", var);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgCfg[i].name[0], prof_name);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************/
|
||||
|
||||
switch_status_t sng_parse_mg_tpt_profile(switch_xml_t mg_tpt_profile)
|
||||
{
|
||||
int i = 0x00;
|
||||
switch_xml_t param;
|
||||
const char *prof_name = NULL;
|
||||
|
||||
/*************************************************************************/
|
||||
prof_name = switch_xml_attr_soft(mg_tpt_profile, "name");
|
||||
|
||||
/*************************************************************************/
|
||||
for (param = switch_xml_child(mg_tpt_profile, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!var || !val) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/******************************************************************************************/
|
||||
if(!strcasecmp(var, "id")){
|
||||
/*******************************************************************************************/
|
||||
i = atoi(val);
|
||||
megaco_globals.g_mg_cfg.mgTptProf[i].id = i;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_tpt_profile Id[%d] \n", i);
|
||||
/*******************************************************************************************/
|
||||
}else if(!strcasecmp(var, "transportType")){
|
||||
/*******************************************************************************************/
|
||||
if(!strcasecmp(val,"UDP")) {
|
||||
megaco_globals.g_mg_cfg.mgTptProf[i].transport_type = SNG_MG_TPT_UDP;
|
||||
}else if(!strcasecmp(val,"TCP")){
|
||||
megaco_globals.g_mg_cfg.mgTptProf[i].transport_type = SNG_MG_TPT_TCP;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "TCP Transport for H.248 Protocol Not Yet Supported \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}else if(!strcasecmp(val,"STCP")){
|
||||
megaco_globals.g_mg_cfg.mgTptProf[i].transport_type = SNG_MG_TPT_SCTP;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STCP Transport for H.248 Protocol Not Yet Supported \n");
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}else{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Protocol Value[%s] \n",val);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_tpt_profile transport_type[%d] \n",
|
||||
megaco_globals.g_mg_cfg.mgTptProf[i].transport_type);
|
||||
/********************************************************************************************/
|
||||
}else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Invalid var[%s] in mg_transport \n", var);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgTptProf[i].name[0], prof_name);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_tpt_profile Name[%s] \n", &megaco_globals.g_mg_cfg.mgTptProf[i].name[0]);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
/***********************************************************************************************************/
|
||||
|
||||
switch_status_t sng_parse_mg_peer_profile(switch_xml_t mg_peer_profile)
|
||||
{
|
||||
int i = 0x00;
|
||||
switch_xml_t param;
|
||||
const char *prof_name = NULL;
|
||||
|
||||
/*************************************************************************/
|
||||
prof_name = switch_xml_attr_soft(mg_peer_profile, "name");
|
||||
|
||||
for (param = switch_xml_child(mg_peer_profile, "param"); param; param = param->next) {
|
||||
/***********************************************************************************************************/
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!var || !val) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/***********************************************************************************************************/
|
||||
if(!strcasecmp(var, "id")){
|
||||
/***********************************************************************************************************/
|
||||
i = atoi(val);
|
||||
megaco_globals.g_mg_cfg.mgPeer.peers[i].id = i;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " mg_peer_profile Id[%d] \n", i);
|
||||
/***********************************************************************************************************/
|
||||
}else if(!strcasecmp(var, "port")){
|
||||
/***********************************************************************************************************/
|
||||
megaco_globals.g_mg_cfg.mgPeer.peers[i].port = atoi(val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_peer_profile port[%d] \n", megaco_globals.g_mg_cfg.mgPeer.peers[i].port);
|
||||
/***********************************************************************************************************/
|
||||
}else if(!strcasecmp(var, "encodingScheme")){
|
||||
/***********************************************************************************************************/
|
||||
if(!strcasecmp(val, "TEXT")){
|
||||
megaco_globals.g_mg_cfg.mgPeer.peers[i].encoding_type = SNG_MG_ENCODING_TEXT;
|
||||
} else if(!strcasecmp(val, "BINARY")){
|
||||
megaco_globals.g_mg_cfg.mgPeer.peers[i].encoding_type = SNG_MG_ENCODING_BINARY;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Encoding Type[%s] \n",val);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_peer_profile encodingScheme[%d] \n", megaco_globals.g_mg_cfg.mgPeer.peers[i].encoding_type);
|
||||
/***********************************************************************************************************/
|
||||
}else if(!strcasecmp(var, "mid")){
|
||||
/***********************************************************************************************************/
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgPeer.peers[i].mid[0],val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_peer_profile mid[%s] \n", megaco_globals.g_mg_cfg.mgPeer.peers[i].mid);
|
||||
/***********************************************************************************************************/
|
||||
}else if(!strcasecmp(var, "ip")){
|
||||
/***********************************************************************************************************/
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgPeer.peers[i].ipaddr[0],val);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
|
||||
" mg_peer_profile ip[%s] \n", megaco_globals.g_mg_cfg.mgPeer.peers[i].ipaddr);
|
||||
/***********************************************************************************************************/
|
||||
}else{
|
||||
/***********************************************************************************************************/
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Invalid var[%s] in mg_peer \n", var);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy((char*)&megaco_globals.g_mg_cfg.mgPeer.peers[i].name[0], prof_name);
|
||||
|
||||
megaco_globals.g_mg_cfg.mgPeer.total_peer++;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
/***********************************************************************************************************/
|
||||
|
|
|
@ -16,84 +16,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_megaco_load);
|
|||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_megaco_shutdown);
|
||||
SWITCH_MODULE_DEFINITION(mod_megaco, mod_megaco_load, mod_megaco_shutdown, NULL);
|
||||
|
||||
#define MEGACO_FUNCTION_SYNTAX "profile [name] [start | stop] [status] [xmlstatus]"
|
||||
SWITCH_STANDARD_API(megaco_function)
|
||||
{
|
||||
int argc;
|
||||
char *argv[10];
|
||||
char *dup = NULL;
|
||||
|
||||
if (zstr(cmd)) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
dup = strdup(cmd);
|
||||
argc = switch_split(dup, ' ', argv);
|
||||
|
||||
if (argc < 1 || zstr(argv[0])) {
|
||||
goto usage;
|
||||
}
|
||||
|
||||
/**********************************************************************************/
|
||||
if (!strcmp(argv[0], "profile")) {
|
||||
if (zstr(argv[1]) || zstr(argv[2])) {
|
||||
goto usage;
|
||||
}
|
||||
/**********************************************************************************/
|
||||
if (!strcmp(argv[2], "start")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_release(profile);
|
||||
stream->write_function(stream, "-ERR Profile %s is already started\n", argv[2]);
|
||||
} else {
|
||||
megaco_profile_start(argv[1]);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
} else if (!strcmp(argv[2], "stop")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_release(profile);
|
||||
megaco_profile_destroy(&profile);
|
||||
stream->write_function(stream, "+OK\n");
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such profile\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
}else if(!strcmp(argv[2], "status")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_status(stream, profile->name);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such profile\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
}else if(!strcmp(argv[2], "xmlstatus")) {
|
||||
/**********************************************************************************/
|
||||
megaco_profile_t *profile = megaco_profile_locate(argv[1]);
|
||||
if (profile) {
|
||||
megaco_profile_xmlstatus(stream, profile->name);
|
||||
} else {
|
||||
stream->write_function(stream, "-ERR No such profile\n");
|
||||
}
|
||||
/**********************************************************************************/
|
||||
}else {
|
||||
/**********************************************************************************/
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
|
||||
goto done;
|
||||
|
||||
usage:
|
||||
stream->write_function(stream, "-ERR Usage: "MEGACO_FUNCTION_SYNTAX"\n");
|
||||
|
||||
done:
|
||||
switch_safe_free(dup);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
return mg_process_cli_cmd(cmd, stream);
|
||||
}
|
||||
|
||||
static switch_status_t console_complete_hashtable(switch_hash_t *hash, const char *line, const char *cursor, switch_console_callback_match_t **matches)
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#define MG_MAX_PEERS 5
|
||||
|
||||
#define MEGACO_FUNCTION_SYNTAX "profile [name] [start | stop] [status] [xmlstatus]"
|
||||
|
||||
struct megaco_globals {
|
||||
switch_memory_pool_t *pool;
|
||||
switch_hash_t *profile_hash;
|
||||
|
@ -68,6 +70,7 @@ 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_process_cli_cmd(const char *cmd, switch_stream_handle_t *stream);
|
||||
|
||||
|
||||
#endif /* MOD_MEGACO_H */
|
||||
|
|
Loading…
Reference in New Issue