chlog freetdm: ss7 - adding initial support for RELAY

This commit is contained in:
Konrad Hammel 2011-02-15 11:45:17 -05:00
parent c0a2a225ba
commit 93bfa6d1e9
8 changed files with 246 additions and 68 deletions

View File

@ -967,12 +967,14 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,
/******************************************************************************/
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) {
@ -1001,11 +1003,11 @@ static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, i
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);
}
}

View File

@ -68,11 +68,14 @@ int ftmod_ss7_shutdown_isup(void);
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 ******************************************************************/
@ -712,6 +715,38 @@ int ftmod_ss7_shutdown_relay(void)
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)
{
@ -808,6 +843,38 @@ int ftmod_ss7_disable_grp_mtp2Link(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:

View File

@ -766,7 +766,18 @@ void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)
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;
/**************************************************************************/

View File

@ -365,6 +365,9 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
/* 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)) {
/**********************************************************************/
@ -926,33 +929,27 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
}
}
/* 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)) {
@ -1598,6 +1595,8 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
{
/*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)) {
@ -1625,6 +1624,26 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
}
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);

View File

@ -506,6 +506,27 @@ typedef enum {
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),
@ -626,12 +647,17 @@ int ftmod_ss7_shutdown_isup(void);
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);
@ -756,6 +782,7 @@ int find_ssf_type_in_map(const char *ssfType);
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);

View File

@ -61,23 +61,28 @@ ftdm_status_t handle_relay_connect(RyMngmt *sta)
/* 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();
}
@ -104,16 +109,20 @@ ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta)
/* 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;
@ -222,30 +231,26 @@ ftdm_status_t enable_all_ckts_for_relay(void)
/******************************************************************************/
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);
}
/* 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);
}
} /* 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;
/* move to the next circuit */
x++;
/**************************************************************************/
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
#endif
return FTDM_SUCCESS;
}
@ -253,23 +258,26 @@ ftdm_status_t reconfig_all_ckts_for_relay(void)
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 */

View File

@ -83,6 +83,7 @@ int find_ssf_type_in_map(const char *ssfType);
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);
@ -90,6 +91,9 @@ ftdm_status_t sngss7_add_var(sngss7_chan_data_t *ss7_info, const char* var, cons
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)
{
@ -1475,6 +1479,46 @@ void sngss7_set_sig_status(sngss7_chan_data_t *sngss7_info, ftdm_signaling_statu
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:

View File

@ -2668,7 +2668,7 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
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;