/******************************************************************************/
static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, int chan, int verbose)
{
- int x;
- int bit;
- sngss7_chan_data_t *ss7_info;
- ftdm_channel_t *ftdmchan;
- int lspan;
- int lchan;
+ sngss7_chan_data_t *ss7_info;
+ ftdm_channel_t *ftdmchan;
+ int x;
+ int bit;
+ int lspan;
+ int lchan;
+ const char *text;
+ int flag;
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
ss7_info->circuit->cic);
for (bit = 0; bit < 33; bit++) {
- stream->write_function(stream, "|");
if (ss7_info->ckt_flags & ( 0x1 << bit)) {
- stream->write_function(stream, "%2d=1", bit);
- } else {
- stream->write_function(stream, "%2d=0", bit);
+ stream->write_function(stream, "|");
+ flag = bit;
+ text = ftmod_ss7_ckt_flag2str(flag);
+ stream->write_function(stream, "%s",text);
}
}
int ftmod_ss7_shutdown_mtp3(void);
int ftmod_ss7_shutdown_mtp2(void);
int ftmod_ss7_shutdown_relay(void);
+int ftmod_ss7_disable_relay_channel(uint32_t chanId);
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
+
+int ftmod_ss7_block_isup_ckt(uint32_t cktId);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
return (sng_cntrl_relay(&pst, &cntrl));
}
+/******************************************************************************/
+int ftmod_ss7_disable_relay_channel(uint32_t chanId)
+{
+ RyMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTRY;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(RyMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTRY;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STGEN;
+
+
+ cntrl.hdr.elmId.elmntInst1 = chanId;
+
+ cntrl.t.cntrl.action = ADISIMM; /* Deactivate */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_relay(&pst, &cntrl));
+}
+
/******************************************************************************/
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId)
{
}
+/******************************************************************************/
+int ftmod_ss7_block_isup_ckt(uint32_t cktId)
+{
+ SiMngmt cntrl;
+ Pst pst;
+
+ /* initalize the post structure */
+ smPstInit(&pst);
+
+ /* insert the destination Entity */
+ pst.dstEnt = ENTSI;
+
+ /* initalize the control structure */
+ memset(&cntrl, 0x0, sizeof(SiMngmt));
+
+ /* initalize the control header */
+ smHdrInit(&cntrl.hdr);
+
+ cntrl.hdr.msgType = TCNTRL; /* this is a control request */
+ cntrl.hdr.entId.ent = ENTSI;
+ cntrl.hdr.entId.inst = S_INST;
+ cntrl.hdr.elmId.elmnt = STICIR;
+
+ cntrl.t.cntrl.s.siElmnt.elmntId.circuit = cktId;
+ cntrl.t.cntrl.s.siElmnt.elmntParam.cir.flag = LSI_CNTRL_CIR_FORCE;
+
+ cntrl.t.cntrl.action = ADISIMM; /* block via BLO */
+ cntrl.t.cntrl.subAction = SAELMNT; /* specificed element */
+
+ return (sng_cntrl_isup(&pst, &cntrl));
+}
+
/******************************************************************************/
/* For Emacs:
* Local Variables:
DECODE_LRY_REASON(sta->t.usta.s.ryErrUsta.reason));
/* process the event */
- handle_relay_disconnect_on_error(sta);
+ switch (sta->t.usta.s.ryErrUsta.reason) {
+ /**********************************************************************/
+ case (LRYRSNMGMTREQ):
+ /* do nothing since this is a shutdown */
+ break;
+ /**********************************************************************/
+ default:
+ /* handle the error */
+ handle_relay_disconnect_on_error(sta);
+ break;
+ /**********************************************************************/
+ } /* switch (sta->t.usta.s.ryErrUsta.reason) */
break;
/**************************************************************************/
/* check each channel on the span to see if there is an un-procressed SUS/RES flag */
check_for_res_sus_flag(ftdmspan);
+ /* check each channel on the span to see if it needs to be reconfigured */
+ check_for_reconfig_flag(ftdmspan);
+
/* Poll for events, e.g HW DTMF */
switch (ftdm_span_poll_event(ftdmspan, 0, NULL)) {
/**********************************************************************/
}
}
- /* if we're not coming from HANGUP_COMPLETE we need to check for resets
- * we can also check if we are in a PAUSED state (no point in sending message
- */
- if ((ftdmchan->last_state != FTDM_CHANNEL_STATE_HANGUP_COMPLETE) &&
- (!sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED))) {
- /* check if this is an outgoing RSC */
- if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) &&
- !(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) {
+ /* check if this is an outgoing RSC */
+ if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) &&
+ !(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) {
- /* send a reset request */
- ft_to_sngss7_rsc (ftdmchan);
- sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);
+ /* send a reset request */
+ ft_to_sngss7_rsc (ftdmchan);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);
- } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */
-
- /* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */
- if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
- !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &&
- (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {
+ } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */
- /* send out the grs */
- ft_to_sngss7_grs (ftdmchan);
- sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
+ /* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */
+ if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &&
+ !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &&
+ (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {
- }/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
- } /* if ( last_state != HANGUP && !PAUSED */
+ /* send out the grs */
+ ft_to_sngss7_grs (ftdmchan);
+ sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);
+
+ }/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */
/* if the sig_status is up...bring it down */
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
{
/*this function is called by the FT-core to unload the signaling module */
+ int x;
+
ftdm_log (FTDM_LOG_INFO, "Starting ftmod_sangoma_ss7 unload...\n");
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {
}
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) {
+ /* go through all the relays channels and configure it */
+ x = 1;
+ while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
+ /* check if this relay channel has been configured already */
+ if ((g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) {
+
+ /* send the specific configuration */
+ if (ftmod_ss7_disable_relay_channel(x)) {
+ SS7_CRITICAL("Relay Channel %d disable failed!\n", x);
+ return 1;
+ } else {
+ SS7_INFO("Relay Channel %d disable DONE!\n", x);
+ }
+
+ /* set the SNGSS7_CONFIGURED flag */
+ g_ftdm_sngss7_data.cfg.relay[x].flags &= !SNGSS7_CONFIGURED;
+ } /* if !SNGSS7_CONFIGURED */
+ x++;
+ } /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */
+
ftmod_ss7_shutdown_relay();
sng_isup_free_relay();
sngss7_clear_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY);
FLAG_RELAY_DOWN = (1 << 30)
} sng_ckt_flag_t;
+#define CKT_FLAGS_STRING \
+ "RX_RSC", \
+ "TX_RSC", \
+ "TX_RSC_REQ_SENT", \
+ "TX_RSC_RSP_RECIEVED", \
+ "RX_GRS", \
+ "RX_GRS_DONE", \
+ "RX_GRS_CMPLT", \
+ "GRS_BASE", \
+ "TX_GRS", \
+ "TX_GRS_REQ_SENT", \
+ "TX_GRS_RSP_RECIEVED", \
+ "REMOTE_REL", \
+ "LOCAL_REL", \
+ "GLARE", \
+ "INF_RESUME", \
+ "INF_PAUSED", \
+ "RELAY_DOWN", \
+ "CKT_RECONFIG"
+FTDM_STR2ENUM_P(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t)
+
/* ckt blocking flags */
typedef enum {
FLAG_CKT_UCIC_BLOCK = (1 << 0),
int ftmod_ss7_shutdown_mtp3(void);
int ftmod_ss7_shutdown_mtp2(void);
int ftmod_ss7_shutdown_relay(void);
+int ftmod_ss7_disable_relay_channel(uint32_t chanId);
int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);
int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);
+int ftmod_ss7_block_isup_ckt(uint32_t cktId);
+
+
+
/* in ftmod_sangoma_ss7_sta.c */
int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm);
int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm);
int find_cic_cntrl_in_map(const char *cntrlType);
ftdm_status_t check_status_of_all_isup_intf(void);
+ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan);
void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id);
void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status);
/* test if this is the first time the channel comes up */
if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) {
- SS7_DEBUG("Relay Channel %d initial connection UP\n", sng_relay->id);
+ SS7_INFO("Relay Channel %d initial connection UP\n", sng_relay->id);
/* mark the channel as being up */
sngss7_set_flag(sng_relay, SNGSS7_RELAY_INIT);
} else {
- SS7_DEBUG("Relay Channel %d connection UP\n", sng_relay->id);
+ SS7_INFO("Relay Channel %d connection UP\n", sng_relay->id);
/* react based on type of channel */
switch (sng_relay->type) {
/******************************************************************/
case (LRY_CT_TCP_CLIENT):
+ /* check the status of all isup intfs in case we weren't connected when
+ * the interface became active
+ */
+ check_status_of_all_isup_intf();
+
/* reconfigure all ISUP ckts, since the main system would have lost all configs */
if (reconfig_all_ckts_for_relay()) {
SS7_ERROR("Failed to reconfigure ISUP Ckts!\n");
-
/* we're done....this is very bad! */
- } else {
+ } else {
+ /* if the circuits reconfiged then bring then back up */
enable_all_ckts_for_relay();
}
/* check which procId is in error, if it is 1, disable the ckts */
if (sta->t.usta.s.ryErrUsta.errPid == 1 ) {
- disable_all_ckts_for_relay();
-
+ /* we've lost the server, bring down the mtp2 links */
disble_all_mtp2_sigs_for_relay();
+
+ /* we've lost the server, bring the sig status down on all ckts */
+ disable_all_ckts_for_relay();
}
/* check if the channel is a server, means we just lost a MGW */
if (g_ftdm_sngss7_data.cfg.relay[sta->t.usta.s.ryErrUsta.errPid].type == LRY_CT_TCP_SERVER) {
- block_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);
-
+ /* we've lost the client, bring down all mtp3 links for this procId */
disable_all_sigs_for_relay(sta->t.usta.s.ryErrUsta.errPid);
+
+ /* we've lost the client, bring down all the ckts for this procId */
+ block_all_ckts_for_relay(sta->t.usta.s.ryErrUsta.errPid);
}
return FTDM_SUCCESS;
/******************************************************************************/
ftdm_status_t reconfig_all_ckts_for_relay(void)
{
-#if 1
int x;
- int ret;
+ sngss7_chan_data_t *sngss7_info = NULL;
+ /* go through all the circuits on our ProcId */
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
+ /**************************************************************************/
if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
-
- ret = ftmod_ss7_isup_ckt_config(x);
- if (ret) {
- SS7_CRITICAL("ISUP CKT %d configuration FAILED (%d)!\n", x, ret);
- return 1;
- } else {
- SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
- }
-
- } /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
-
- /* set the SNGSS7_CONFIGURED flag */
- g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
-
+ /* grab the private data structure */
+ sngss7_info = g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
+
+ /* mark the circuit for re-configuration */
+ sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG);
+ }
+
+ /* move to the next circuit */
x++;
+ /**************************************************************************/
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
-#endif
+
return FTDM_SUCCESS;
}
ftdm_status_t block_all_ckts_for_relay(uint32_t procId)
{
int x;
-
- SS7_INFO("BLOcking all ckts on ProcID = %d\n", procId);
+ int ret;
/* we just lost connection to this procId, send out a block for all these circuits */
x = (procId * 1000) + 1;
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
/**************************************************************************/
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
- /* send out a BLO */
- sng_cc_sta_request (1,
- 0,
- 0,
- g_ftdm_sngss7_data.cfg.isupCkt[x].id,
- 0,
- SIT_STA_CIRBLOREQ,
- NULL);
+ /* send a block request via stack manager */
+ ret = ftmod_ss7_block_isup_ckt(g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ if (ret) {
+ SS7_INFO("Successfully BLOcked CIC:%d(ckt:%d) due to Relay failure\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ } else {
+ SS7_ERROR("Failed to BLOck CIC:%d(ckt:%d) due to Relay failure\n",
+ g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
+ g_ftdm_sngss7_data.cfg.isupCkt[x].id);
+ }
+
} /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */
/* move along */
int find_cic_cntrl_in_map(const char *cntrlType);
ftdm_status_t check_status_of_all_isup_intf(void);
+ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan);
void sngss7_send_signal(sngss7_chan_data_t *sngss7_info, ftdm_signal_event_t event_id);
void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_status_t status);
ftdm_status_t sngss7_add_raw_data(sngss7_chan_data_t *sngss7_info, uint8_t* data, ftdm_size_t data_len);
/******************************************************************************/
+FTDM_ENUM_NAMES(CKT_FLAGS_NAMES, CKT_FLAGS_STRING)
+FTDM_STR2ENUM(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t, CKT_FLAGS_NAMES, 31)
+
/* FUNCTIONS ******************************************************************/
uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
{
return;
}
+/******************************************************************************/
+ftdm_status_t check_for_reconfig_flag(ftdm_span_t *ftdmspan)
+{
+ ftdm_channel_t *ftdmchan = NULL;
+ sngss7_chan_data_t *sngss7_info = NULL;
+ int x;
+ int ret;
+
+ for (x = 1; x < (ftdmspan->chan_count + 1); x++) {
+ /**************************************************************************/
+ /* extract the channel structure and sngss7 channel data */
+ ftdmchan = ftdmspan->channels[x];
+
+ /* if the call data is NULL move on */
+ if (ftdmchan->call_data == NULL) {
+ SS7_WARN_CHAN(ftdmchan, "Reconfiguring channel that has not call_data!%s\n", " ");
+ continue;
+ }
+
+ /* grab the private data */
+ sngss7_info = ftdmchan->call_data;
+
+ /* check the reconfig flag */
+ if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG)) {
+ ret = ftmod_ss7_isup_ckt_config(sngss7_info->circuit->id);
+
+ if (ret) {
+ SS7_CRITICAL("ISUP CKT %d re-configuration FAILED!\n", x);
+ } else {
+ SS7_INFO("ISUP CKT %d re-configuration DONE!\n", x);
+ }
+
+ /* clear the re-config flag ... no matter what */
+ sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG);
+
+ } /* if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_RECONFIG)) */
+ } /* for (x = 1; x < (span->chan_count + 1); x++) */
+
+ return FTDM_SUCCESS;
+}
/******************************************************************************/
/* For Emacs:
* Local Variables:
if (sng_isup->tpause != 0) {
g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = sng_isup->tpause;
} else {
- g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = 150;
+ g_ftdm_sngss7_data.cfg.isupIntf[i].tpause = 3000;
}
if (sng_isup->tstaenq != 0) {
g_ftdm_sngss7_data.cfg.isupIntf[i].tstaenq = sng_isup->tstaenq;