From f1f78a86537bad866a6eb70bdee20fa1a52acb9e Mon Sep 17 00:00:00 2001 From: kapil Date: Wed, 30 May 2012 20:20:58 +0530 Subject: [PATCH] adding m2ua stack free code while unloading freetdm module --- .../ftmod_sangoma_ss7_logger.c | 5 + .../ftmod_sangoma_ss7_m2ua.c | 137 ++++++++++++++++++ .../ftmod_sangoma_ss7_m2ua.h | 1 + .../ftmod_sangoma_ss7_main.c | 4 + 4 files changed, 147 insertions(+) diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c index 5a6cc31907..922200629f 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c @@ -870,6 +870,11 @@ void handle_sng_m2ua_alarm(Pst *pst, MwMgmt *sta) /* To print the event specific information */ switch(sta->t.usta.alarm.event) { + case LMW_EVENT_ENDPOPEN_OK: + { + ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ENDPOPEN_OK: \n"); + break; + } case LMW_EVENT_ESTABLISH_OK: { ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ESTABLISH_OK Event raised on peerId[%d]\n",sta->t.usta.s.peerId); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c index f7836ed629..39e9bba658 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.c @@ -64,10 +64,114 @@ static int ftmod_nif_m2ua_dlsap_bind(int id); static int ftmod_nif_mtp2_dlsap_bind(int id); static int ftmod_m2ua_enable_debug(void); static int ftmod_tucl_enable_debug(void); +static int ftmod_sctp_enable_debug(void); + +static int ftmod_ss7_sctp_shutdown(void); +static int ftmod_ss7_m2ua_shutdown(void); +static int ftmod_ss7_tucl_shutdown(void); ftdm_status_t sng_m2ua_init(void); ftdm_status_t sng_m2ua_cfg(void); +/******************************************************************************/ +void ftmod_ss7_m2ua_free() +{ + ftmod_ss7_m2ua_shutdown(); + ftmod_ss7_sctp_shutdown(); + ftmod_ss7_tucl_shutdown(); + + sng_isup_free_m2ua(); + sng_isup_free_sctp(); + sng_isup_free_tucl(); +} +/******************************************************************************/ +static int ftmod_ss7_tucl_shutdown() +{ + Pst pst; + HiMngmt cntrl; + + memset((U8 *)&pst, 0, sizeof(Pst)); + memset((U8 *)&cntrl, 0, sizeof(HiMngmt)); + + smPstInit(&pst); + + pst.dstEnt = ENTHI; + + /* prepare header */ + cntrl.hdr.msgType = TCNTRL; /* message type */ + cntrl.hdr.entId.ent = ENTHI; /* entity */ + cntrl.hdr.entId.inst = 0; /* instance */ + cntrl.hdr.elmId.elmnt = STGEN; /* General */ + + cntrl.hdr.response.selector = 0; + cntrl.hdr.response.prior = PRIOR0; + cntrl.hdr.response.route = RTESPEC; + cntrl.hdr.response.mem.region = S_REG; + cntrl.hdr.response.mem.pool = S_POOL; + + cntrl.t.cntrl.action = ASHUTDOWN; + + return (sng_cntrl_tucl (&pst, &cntrl)); +} +/******************************************************************************/ +static int ftmod_ss7_m2ua_shutdown() +{ + Pst pst; + MwMgmt cntrl; + + memset((U8 *)&pst, 0, sizeof(Pst)); + memset((U8 *)&cntrl, 0, sizeof(MwMgmt)); + + smPstInit(&pst); + + pst.dstEnt = ENTMW; + + /* prepare header */ + cntrl.hdr.msgType = TCNTRL; /* message type */ + cntrl.hdr.entId.ent = ENTMW; /* entity */ + cntrl.hdr.entId.inst = 0; /* instance */ + cntrl.hdr.elmId.elmnt = STMWGEN; /* General */ + + cntrl.hdr.response.selector = 0; + cntrl.hdr.response.prior = PRIOR0; + cntrl.hdr.response.route = RTESPEC; + cntrl.hdr.response.mem.region = S_REG; + cntrl.hdr.response.mem.pool = S_POOL; + + cntrl.t.cntrl.action = ASHUTDOWN; + + return (sng_cntrl_m2ua (&pst, &cntrl)); +} +/***********************************************************************************************************************/ +static int ftmod_ss7_sctp_shutdown() +{ + Pst pst; + SbMgmt cntrl; + + memset((U8 *)&pst, 0, sizeof(Pst)); + memset((U8 *)&cntrl, 0, sizeof(SbMgmt)); + + smPstInit(&pst); + + pst.dstEnt = ENTSB; + + /* prepare header */ + cntrl.hdr.msgType = TCNTRL; /* message type */ + cntrl.hdr.entId.ent = ENTSB; /* entity */ + cntrl.hdr.entId.inst = 0; /* instance */ + cntrl.hdr.elmId.elmnt = STSBGEN; /* General */ + + cntrl.hdr.response.selector = 0; + cntrl.hdr.response.prior = PRIOR0; + cntrl.hdr.response.route = RTESPEC; + cntrl.hdr.response.mem.region = S_REG; + cntrl.hdr.response.mem.pool = S_POOL; + + cntrl.t.cntrl.action = ASHUTDOWN; + + return (sng_cntrl_sctp (&pst, &cntrl)); +} + /******************************************************************************/ ftdm_status_t ftmod_ss7_m2ua_cfg(void) @@ -1036,6 +1140,7 @@ int ftmod_ss7_m2ua_start(void){ /***********************************************************************************************************************/ /* Enable DEBUGs*/ + ftmod_sctp_enable_debug(); ftmod_m2ua_enable_debug(); ftmod_tucl_enable_debug(); @@ -1275,6 +1380,38 @@ static int ftmod_nif_mtp2_dlsap_bind(int id) } /***********************************************************************************************************************/ +static int ftmod_sctp_enable_debug() +{ + Pst pst; + SbMgmt cntrl; + + memset((U8 *)&pst, 0, sizeof(Pst)); + memset((U8 *)&cntrl, 0, sizeof(SbMgmt)); + + smPstInit(&pst); + + pst.dstEnt = ENTSB; + + /* prepare header */ + cntrl.hdr.msgType = TCNTRL; /* message type */ + cntrl.hdr.entId.ent = ENTSB; /* entity */ + cntrl.hdr.entId.inst = 0; /* instance */ + cntrl.hdr.elmId.elmnt = STSBGEN; /* General */ + + cntrl.hdr.response.selector = 0; + cntrl.hdr.response.prior = PRIOR0; + cntrl.hdr.response.route = RTESPEC; + cntrl.hdr.response.mem.region = S_REG; + cntrl.hdr.response.mem.pool = S_POOL; + + cntrl.t.cntrl.action = AENA; + cntrl.t.cntrl.subAction = SADBG; + cntrl.t.cntrl.dbgMask = 0xFFFF; + + return (sng_cntrl_sctp (&pst, &cntrl)); +} +/***********************************************************************************************************************/ + static int ftmod_m2ua_enable_debug() { Pst pst; diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h index 9eb727ea02..a988b9c8db 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_m2ua.h @@ -118,6 +118,7 @@ int ftmod_ss7_parse_sctp_links(ftdm_conf_node_t *node); uint32_t iptoul(const char *ip); int ftmod_ss7_m2ua_start(void); +void ftmod_ss7_m2ua_free(void); ftdm_status_t ftmod_ss7_m2ua_cfg(void); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c index dbb1c1974c..90202d3989 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c @@ -2687,6 +2687,10 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload) sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY_STARTED); } + if(SNG_SS7_OPR_MODE_ISUP != g_ftdm_operating_mode){ + ftmod_ss7_m2ua_free(); + } + if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_SM_STARTED)) { sng_isup_free_sm();