提交 ba051e10 authored 作者: kapil's avatar kapil

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
上级 acfbbc9e
......@@ -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
差异被折叠。
......@@ -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_ */
......@@ -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 */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论