From 743e91569e5ef10abc92198ed473d9ac561abb5f Mon Sep 17 00:00:00 2001 From: kapil Date: Tue, 19 Jun 2012 17:00:39 +0530 Subject: [PATCH] adding enable/disable MEGACO stack looging CLI command --- .../mod_media_gateway/media_gateway_cli.c | 25 +++++++++++++++- .../mod_media_gateway/media_gateway_stack.c | 30 +++++++++++++++++-- .../mod_media_gateway/media_gateway_stack.h | 2 ++ .../mod_media_gateway/mod_media_gateway.c | 2 ++ .../mod_media_gateway/mod_media_gateway.h | 2 ++ 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c index db50feaa57..720032673c 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cli.c @@ -99,12 +99,35 @@ switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stre /**********************************************************************************/ goto usage; } +/**********************************************************************************/ + }else if (!strcmp(argv[0], "logging")) { +/**********************************************************************************/ + if (zstr(argv[1])) { + goto usage; + } + /******************************************************************/ + if(!strcasecmp(argv[1], "enable")){ + mg_enable_logging(); + /******************************************************************/ + }else if(!strcasecmp(argv[1], "disable")){ + /******************************************************************/ + mg_disable_logging(); + /******************************************************************/ + } else { + /******************************************************************/ + goto usage; + } +/**********************************************************************************/ + }else { +/**********************************************************************************/ + goto usage; } +/**********************************************************************************/ goto done; usage: - stream->write_function(stream, "-ERR Usage: "MEGACO_FUNCTION_SYNTAX"\n"); + stream->write_function(stream, "-ERR Usage: \n""\t"MEGACO_CLI_SYNTAX" \n \t"MEGACO_FUNCTION_SYNTAX"\n \t" MEGACO_LOGGING_CLI_SYNTAX "\n"); done: switch_safe_free(dup); diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c index abe46a5837..d4717501ce 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.c @@ -19,7 +19,6 @@ int mgco_mu_gen_config(void); int mgco_tucl_gen_config(void); int mgco_mu_ssap_config(int idx); int mgco_mg_tsap_config(megaco_profile_t* profile); -int mgco_mg_enble_debug(void); int mgco_mg_ssap_config(megaco_profile_t* profile); int mgco_mg_peer_config(megaco_profile_t* profile); int mgco_mg_tpt_server_config(megaco_profile_t* profile); @@ -571,7 +570,7 @@ int mgco_mg_ssap_cntrl(int idx) } /******************************************************************************/ -int mgco_mg_enble_debug() +int mg_enable_logging() { MgMngmt mgMngmt; Pst pst; /* Post for layer manager */ @@ -597,6 +596,33 @@ int mgco_mg_enble_debug() return(sng_cntrl_mg(&pst, &mgMngmt)); } +/******************************************************************************/ +int mg_disable_logging() +{ + MgMngmt mgMngmt; + Pst pst; /* Post for layer manager */ + MgCntrl* cntrl; + + memset(&mgMngmt, 0, sizeof(mgMngmt)); + cntrl = &mgMngmt.t.cntrl; + + /* initalize the post structure */ + smPstInit(&pst); + + /* insert the destination Entity */ + pst.dstEnt = ENTMG; + mgMngmt.hdr.msgType = TCFG; + mgMngmt.hdr.entId.ent = ENTHI; + mgMngmt.hdr.entId.inst = S_INST; + mgMngmt.hdr.elmId.elmnt = STGEN; + + cntrl->action = ADISIMM; + cntrl->subAction = SADBG; + cntrl->s.dbg.genDbgMask = 0xfffffdff; + + return(sng_cntrl_mg(&pst, &mgMngmt)); +} + /******************************************************************************/ int mgco_tucl_gen_config(void) { diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h index ac5b911f9b..9bbe90b7df 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_stack.h @@ -53,6 +53,8 @@ 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); +int mg_enable_logging(void); +int mg_disable_logging(void); switch_status_t sng_mgco_cfg(megaco_profile_t* profile); diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c index 58a8794fad..322dbd4221 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.c @@ -73,6 +73,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load) switch_console_set_complete("add megaco profile ::megaco::list_profiles status"); switch_console_set_complete("add megaco profile ::megaco::list_profiles xmlstatus"); switch_console_set_complete("add megaco profile ::megaco::list_profiles peerxmlstatus"); + switch_console_set_complete("add megaco logging ::megaco::list_profiles enable"); + switch_console_set_complete("add megaco logging ::megaco::list_profiles disable"); switch_console_add_complete_func("::megaco::list_profiles", list_profiles); diff --git a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h index c55bb6744f..2e0db8cb62 100644 --- a/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h +++ b/src/mod/endpoints/mod_media_gateway/mod_media_gateway.h @@ -15,6 +15,8 @@ #define MG_MAX_PEERS 5 +#define MEGACO_CLI_SYNTAX "profile|logging" +#define MEGACO_LOGGING_CLI_SYNTAX "logging [enable|disable]" #define MEGACO_FUNCTION_SYNTAX "profile [name] [start | stop] [status] [xmlstatus] [peerxmlstatus]" struct megaco_globals {