Adding megaco stack configuration code and "megaco.conf.xml"

This commit is contained in:
kapil 2012-05-16 18:36:26 +05:30
parent f3fe2232f3
commit 32c5100e62
7 changed files with 520 additions and 33 deletions

View File

@ -1,3 +1,4 @@
BASE=../../../.. BASE=../../../..
LOCAL_OBJS=megaco.o LOCAL_OBJS=megaco.o megaco_cfg.o
LOCAL_LDFLAGS=-lsng_megaco
include $(BASE)/build/modmake.rules include $(BASE)/build/modmake.rules

View File

@ -1,9 +1,46 @@
<configuration name="megaco.conf" description="Megaco Controllee"> <configuration name="megaco.conf" description="Megaco Controllee">
<profiles>
<profile name="default"> <!--Each instances of MG will have each mg profile -->
<settings> <sng_mg_interfaces>
<param name="foo" value="bar" /> <sng_mg_interface name="default">
</settings> <param name="id" value="1"/> <!-- /* equivalent to SSAP ID of MEGACO layer */-->
</profile> <param name="protocol" value="MEGACO"/> <!-- /* Protocol Type , Supported values are MEGACO/MGCP */ -->
</profiles> <param name="transportProfileId" value="1"/> <!-- /* Link to transport layer configuration -->
<param name="localIp" value="xxx-xxx-xx-xx"/> <!-- /* Local node IP */ -->
<param name="port" value="2944" /> <!-- /* Port */ -->
<param name="myDomainName" value="mg.sangoma.com" /> <!--/* Local domain name */ -->
<param name="mid" value="<lab.sangoma.com>" /> <!-- /* Message Identifier (MID) of MEGACO message */ -->
<param name="peerId" value="1" /> <!--/* MGC Peer Configuration profile ID */-->
<!--/*We can define multiple peer_ids depends on number of MGC per MG.
MGC Priority - peer order can defines the priority or we can priority attribute in peer_id element..Not needed now..we can think later
Primart/Secondary MGC - we can think later in future when we need this functionality..as of now not requied. */
-->
</sng_mg_interface>
</sng_mg_interfaces>
<!--/*transport profiles which can be TCP, UDP or SCTP */-->
<sng_transport_interfaces>
<!--/* for TUCL we dont need any layer specific config parameters */ -->
<sng_transport_interface name="TPT-1">
<param name="id" value="1" /> <!-- /* transport profile id */ -->
<param name="transportType" value="UDP"/> <!-- /* transport profile type values could be UDP/TCP/SCTP */ -->
</sng_transport_interface>
</sng_transport_interfaces>
<sng_mg_peer_interfaces> <!--/* Supported number of peers */ -->
<sng_mg_peer_interface name="MG_PEER1">
<param name="id" value="1"/> <!-- /* Peer profile ID */-->
<param name="ip" value="xxx-xxx-xx-xx"/> <!-- /* Peer node IP */ -->
<param name="port" value="2944"/> <!--/* peer port */ -->
<param name="encodingScheme" value="TEXT"/> <!--/* H.248 Encoding scheme TEXT/BINARY */ -->
<param name="mid" value="remote.mgc.com" /> <!-- /* Message Identifier (MID) of remote MGC MEGACO message */-->
</sng_mg_peer_interface>
</sng_mg_peer_interfaces>
</configuration> </configuration>

View File

@ -29,34 +29,73 @@ void megaco_profile_release(megaco_profile_t *profile)
static switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload) static switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
{ {
switch_xml_t cfg, xml, x_profiles, x_profile, x_settings; switch_xml_t cfg, xml, mg_interfaces, mg_interface, tpt_interfaces, tpt_interface, peer_interfaces, peer_interface;
switch_status_t status = SWITCH_STATUS_FALSE; switch_status_t status = SWITCH_STATUS_FALSE;
switch_event_t *event = NULL; switch_event_t *event = NULL;
int count;
const char *file = "megaco.conf"; const char *file = "megaco.conf";
const char* mg_profile_tpt_id = NULL;
const char* mg_profile_peer_id = NULL;
if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) { if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file);
goto done; goto done;
} }
if (!(x_profiles = switch_xml_child(cfg, "profiles"))) { if (!(mg_interfaces = switch_xml_child(cfg, "sng_mg_interfaces"))) {
goto done; goto done;
} }
for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { /* iterate through MG Interface list to build all MG profiles */
const char *name = switch_xml_attr_soft(x_profile, "name"); for (mg_interface = switch_xml_child(mg_interfaces, "sng_mg_interface"); mg_interface; mg_interface = mg_interface->next) {
const char *name = switch_xml_attr_soft(mg_interface, "name");
if (strcmp(name, profile->name)) { if (strcmp(name, profile->name)) {
continue; continue;
} }
if (!(x_settings = switch_xml_child(x_profile, "settings"))) { /* parse MG profile */
if(SWITCH_STATUS_FALSE == sng_parse_mg_profile(mg_interface)) {
goto done; goto done;
} }
count = switch_event_import_xml(switch_xml_child(x_settings, "param"), "name", "value", &event);
// status = switch_xml_config_parse_event(event, count, reload, instructions);
/* TODO: Kapil: Initialize stack configuration */ mg_profile_tpt_id = switch_xml_attr_soft(mg_interface, "id");
/* Now get required transport profile against mg_profile_tpt_id*/
if (!(tpt_interfaces = switch_xml_child(cfg, "sng_transport_interfaces"))) {
goto done;
}
for (tpt_interface = switch_xml_child(tpt_interfaces, "sng_transport_interface"); tpt_interface; tpt_interface = tpt_interface->next) {
const char *id = switch_xml_attr_soft(tpt_interface, "id");
if (strcmp(id, mg_profile_tpt_id)) {
continue;
}
/* parse MG transport profile */
if(SWITCH_STATUS_FALSE == sng_parse_mg_tpt_profile(tpt_interface)) {
goto done;
}
}
/* as of now supporting only one peer */
mg_profile_peer_id = switch_xml_attr_soft(mg_interface, "peerId");
/* Now get required peer profile against mg_profile_peer_id*/
if (!(peer_interfaces = switch_xml_child(cfg, "sng_mg_peer_interfaces"))) {
goto done;
}
for (peer_interface = switch_xml_child(peer_interfaces, "sng_mg_peer_interface"); peer_interface; peer_interface = peer_interface->next) {
const char *id = switch_xml_attr_soft(peer_interface, "id");
if (strcmp(id, mg_profile_peer_id)) {
continue;
}
/* parse MG Peer profile */
if(SWITCH_STATUS_FALSE == sng_parse_mg_peer_profile(peer_interface)) {
goto done;
}
}
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
} }
@ -87,7 +126,6 @@ switch_status_t megaco_profile_start(const char *profilename)
switch_thread_rwlock_create(&profile->rwlock, pool); switch_thread_rwlock_create(&profile->rwlock, pool);
/* TODO: Kapil: Insert stack per-interface startup code here */
if (config_profile(profile, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) { if (config_profile(profile, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error configuring profile %s\n", profile->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error configuring profile %s\n", profile->name);
goto fail; goto fail;
@ -125,7 +163,6 @@ switch_status_t megaco_profile_destroy(megaco_profile_t **profile)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 2012, Sangoma Technologies
* Kapil Gupta <kgupta@sangoma.com>
* All rights reserved.
*
* <Insert license here>
*/
#include "sng_megaco/sng_ss7.h"
#ifndef _MEGACO_CFG_H_
#define _MEGACO_CFG_H_
#define MAX_MID_LEN 30
#define MAX_DOMAIN_LEN 30
#define MAX_NAME_LEN 25
#define MAX_MG_PROFILES 5
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;
typedef enum{
SNG_MG_TPT_NONE,
SNG_MG_TPT_UDP,
SNG_MG_TPT_TCP,
SNG_MG_TPT_SCTP,
SNG_MG_TPT_MTP3
}sng_mg_transport_types_e;
typedef enum{
SNG_MG_NONE,
SNG_MG_MGCP,
SNG_MG_MEGACO,
}sng_mg_protocol_types_e;
typedef enum{
SNG_MG_ENCODING_NONE,
SNG_MG_ENCODING_TEXT,
SNG_MG_ENCODING_BINARY,
}sng_mg_encoding_types_e;
/* 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 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{
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);
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);
void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* msg);
void handle_mgco_cntrl_cfm(Pst *pst, SuId suId, MgMgtCntrl* cntrl, Reason reason);
void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg);
void handle_mgco_audit_cfm(Pst *pst, SuId suId, MgMgtAudit* audit, Reason reason);
void handle_mg_alarm(Pst *pst, MgMngmt *sta);
void handle_tucl_alarm(Pst *pst, HiMngmt *sta);
#endif /* _MEGACO_CFG_H_ */

View File

@ -0,0 +1,219 @@
/*
* Copyright (c) 2012, Sangoma Technologies
* Kapil Gupta <kgupta@sangoma.com>
* All rights reserved.
*
* <Insert license here>
*/
#include "mod_megaco.h"
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, "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;
}
}
return SWITCH_STATUS_SUCCESS;
}
/***********************************************************************************************************/

View File

@ -9,6 +9,7 @@
#include "mod_megaco.h" #include "mod_megaco.h"
struct megaco_globals megaco_globals; struct megaco_globals megaco_globals;
static sng_isup_event_interface_t sng_event;
SWITCH_MODULE_LOAD_FUNCTION(mod_megaco_load); SWITCH_MODULE_LOAD_FUNCTION(mod_megaco_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_megaco_shutdown); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_megaco_shutdown);
@ -116,8 +117,24 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_megaco_load)
switch_console_set_complete("add megaco profile ::megaco::list_profiles stop"); switch_console_set_complete("add megaco profile ::megaco::list_profiles stop");
switch_console_add_complete_func("::megaco::list_profiles", list_profiles); switch_console_add_complete_func("::megaco::list_profiles", list_profiles);
/* TODO: Kapil: Insert stack global startup code here */
/* Initialize MEGACO Stack */
sng_event.mg.sng_mgco_txn_ind = handle_mgco_txn_ind;
sng_event.mg.sng_mgco_cmd_ind = handle_mgco_cmd_ind;
sng_event.mg.sng_mgco_txn_sta_ind = handle_mgco_txn_sta_ind;
sng_event.mg.sng_mgco_sta_ind = handle_mgco_sta_ind;
sng_event.mg.sng_mgco_cntrl_cfm = handle_mgco_cntrl_cfm;
sng_event.mg.sng_mgco_audit_cfm = handle_mgco_audit_cfm;
/* Alarm CB */
sng_event.sm.sng_mg_alarm = handle_mg_alarm;
sng_event.sm.sng_tucl_alarm = handle_tucl_alarm;
/* Log */
sng_event.sm.sng_log = handle_sng_log;
/* initalize sng_mg library */
sng_isup_init_gen(&sng_event);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -128,6 +145,85 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_megaco_shutdown)
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/*****************************************************************************************************************************/
void handle_sng_log(uint8_t level, char *fmt, ...)
{
int log_level;
char print_buf[1024];
va_list ptr;
memset(&print_buf[0],0,sizeof(1024));
va_start(ptr, fmt);
switch(level)
{
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_ERROR; break;
case SNG_LOGLEVEL_CRIT: log_level = SWITCH_LOG_CRIT; break;
default: log_level = SWITCH_LOG_DEBUG; break;
};
vsprintf(&print_buf[0], fmt, ptr);
switch_log_printf(SWITCH_CHANNEL_LOG, log_level, " MOD_MEGACO: %s \n", &print_buf[0]);
va_end(ptr);
}
/*****************************************************************************************************************************/
void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
{
/*TODO*/
}
/*****************************************************************************************************************************/
void handle_mgco_cmd_ind(Pst *pst, SuId suId, MgMgcoCommand* cmd)
{
/*TODO*/
}
/*****************************************************************************************************************************/
void handle_mgco_sta_ind(Pst *pst, SuId suId, MgMgtSta* sta)
{
/*TODO*/
}
/*****************************************************************************************************************************/
void handle_mgco_txn_sta_ind(Pst *pst, SuId suId, MgMgcoInd* txn_sta_ind)
{
/*TODO*/
}
/*****************************************************************************************************************************/
void handle_mgco_cntrl_cfm(Pst *pst, SuId suId, MgMgtCntrl* cntrl, Reason reason)
{
/*TODO*/
}
/*****************************************************************************************************************************/
void handle_mgco_audit_cfm(Pst *pst, SuId suId, MgMgtAudit* audit, Reason reason)
{
/*TODO*/
}
/*****************************************************************************************************************************/
void handle_mg_alarm(Pst *pst, MgMngmt *sta)
{
/*TODO*/
}
/*****************************************************************************************************************************/
void handle_tucl_alarm(Pst *pst, HiMngmt *sta)
{
/*TODO*/
}
/*****************************************************************************************************************************/
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:

View File

@ -11,12 +11,13 @@
#define MOD_MEGACO_H #define MOD_MEGACO_H
#include <switch.h> #include <switch.h>
#include "megaco_cfg.h"
struct megaco_globals { struct megaco_globals {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_hash_t *profile_hash; switch_hash_t *profile_hash;
switch_thread_rwlock_t *profile_rwlock; switch_thread_rwlock_t *profile_rwlock;
/* TODO: Kapil: add global variables here */ sng_mg_gbl_cfg_t g_mg_cfg;
}; };
extern struct megaco_globals megaco_globals; /* < defined in mod_megaco.c */ extern struct megaco_globals megaco_globals; /* < defined in mod_megaco.c */
@ -29,8 +30,6 @@ typedef struct megaco_profile_s {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_thread_rwlock_t *rwlock; /* < Reference counting rwlock */ switch_thread_rwlock_t *rwlock; /* < Reference counting rwlock */
megaco_profile_flags_t flags; megaco_profile_flags_t flags;
/* TODO: Kapil: Insert interface-specific stack elements here */
} megaco_profile_t; } megaco_profile_t;