freetdm: fixing glare with different options

This commit is contained in:
James Zhang 2012-03-16 11:19:01 -04:00
parent b5f69db10f
commit 46ddfc0ebb
2 changed files with 46 additions and 126 deletions

View File

@ -316,12 +316,12 @@ handle_glare:
/* setup the hangup cause */ /* setup the hangup cause */
ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */ ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */
/* this is a remote hangup request */ /* move the state of the channel to Terminating to end the call
sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); in TERMINATING state, the release cause is set to REMOTE_REL
in any means. So we don't have to set the release reason here.
/* move the state of the channel to Terminating to end the call */ */
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
} /* if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) */ }
break; break;
/**************************************************************************/ /**************************************************************************/
default: /* should not have gotten an IAM while in this state */ default: /* should not have gotten an IAM while in this state */
@ -1282,6 +1282,7 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci
/* the glare flag is already up so it was caught ... do nothing */ /* the glare flag is already up so it was caught ... do nothing */
SS7_DEBUG_CHAN(ftdmchan, "Glare flag is already up...nothing to do!%s\n", " "); SS7_DEBUG_CHAN(ftdmchan, "Glare flag is already up...nothing to do!%s\n", " ");
} else { } else {
int bHangup = 0;
SS7_DEBUG_CHAN(ftdmchan, "Glare flag is not up yet...indicating glare from reattempt!%s\n", " "); SS7_DEBUG_CHAN(ftdmchan, "Glare flag is not up yet...indicating glare from reattempt!%s\n", " ");
/* glare, throw the flag */ /* glare, throw the flag */
sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE); sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE);
@ -1289,15 +1290,46 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci
/* clear any existing glare data from the channel */ /* clear any existing glare data from the channel */
memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t)); memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t));
if (g_ftdm_sngss7_data.cfg.glareResolution == SNGSS7_GLARE_DOWN) {
/* If I'm in DOWN mode, I will always hangup my call. */
bHangup = 1;
}
else if (g_ftdm_sngss7_data.cfg.glareResolution == SNGSS7_GLARE_PC) {
/* I'm in PointCode mode.
Case 1: My point code is higher than the other side.
If the CIC number is even, I'm trying to control.
If the CIC number is odd, I'll hangup my call and back off.
Case 2: My point code is lower than the other side.
If the CIC number is odd, I'm trying to control.
If the CIC number is even, I'll hangup my call and back off.
*/
if( g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc > g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc )
{
if ((sngss7_info->circuit->cic % 2) == 1 ) {
bHangup = 1;
}
} else {
if( (sngss7_info->circuit->cic % 2) == 0 ) {
bHangup = 1;
}
}
}
else {
/* If I'm in CONTROL mode, I will not hangup my call. */
bHangup = 0;
}
if (bHangup) {
/* setup the hangup cause */ /* setup the hangup cause */
ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */ ftdmchan->caller_data.hangup_cause = 34; /* Circuit Congrestion */
/* this is a remote hangup request */ /* move the state of the channel to Terminating to end the call
sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL); in TERMINATING state, the release cause is set to REMOTE_REL
in any means. So we don't have to set the release reason here.
/* move the state of the channel to Terminating to end the call */ */
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING); ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
} }
}
/* unlock the channel again before we exit */ /* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex); ftdm_mutex_unlock(ftdmchan->mutex);
@ -2455,63 +2487,6 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
x++; x++;
} }
#if 0
for (x = circuit; x < (circuit + range + 1); x++) {
/* confirm this is a voice channel */
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) continue;
/* grab the circuit in question */
if (extract_chan_data(x, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x);
break;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
#if 0
SS7_ERROR("KONRAD -> circuit=%d, byte=%d, bit=%d, status[byte]=%d, math=%d\n",
x,
byte,
bit,
status[byte],
(status[byte] & (1 << bit)));
#endif
if (status[byte] & (1 << bit)) {
switch (blockType) {
/**********************************************************************/
case 0: /* maintenance oriented */
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
break;
/**********************************************************************/
case 1: /* hardware failure oriented */
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
break;
/**********************************************************************/
case 2: /* reserved for national use */
break;
/**********************************************************************/
default:
break;
/**********************************************************************/
} /* switch (blockType) */
}
/* bring the sig status down */
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
/* update the bit and byte counter*/
bit ++;
if (bit == 8) {
byte++;
bit = 0;
}
} /* for (x = circuit; x < (circuit + range + 1); x++) */
#endif
/* get the ftdmchan and ss7_chan_data from the circuit */ /* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@ -2665,61 +2640,6 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
} }
x++; x++;
} }
#if 0
for (x = circuit; x < (circuit + range + 1); x++) {
if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE) continue;
/* grab the circuit in question */
if (extract_chan_data(x, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x);
break;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
if (status[byte] & (1 << bit)) {
switch (blockType) {
/**********************************************************************/
case 0: /* maintenance oriented */
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN);
break;
/**********************************************************************/
case 1: /* hardware failure oriented */
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);
break;
/**********************************************************************/
case 2: /* reserved for national use */
break;
/**********************************************************************/
default:
break;
/**********************************************************************/
} /* switch (blockType) */
} /* if (status[byte] & (1 << bit)) */
sigev.chan_id = ftdmchan->chan_id;
sigev.span_id = ftdmchan->span_id;
sigev.channel = ftdmchan;
/* bring the sig status down */
if (sngss7_channel_status_clear(sngss7_info)) {
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
}
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
/* update the bit and byte counter*/
bit ++;
if (bit == 8) {
byte++;
bit = 0;
}
} /* for (x = circuit; x < (circuit + range + 1); x++) */
#endif
/* get the ftdmchan and ss7_chan_data from the circuit */ /* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) { if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {

View File

@ -1471,14 +1471,14 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan)
SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", ""); SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", "");
/* all flags are down so we can bring up the sig status */ /* all flags are down so we can bring up the sig status */
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP); sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
} /* if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) */ }
} else { } else {
state_flag = 0; state_flag = 0;
SS7_DEBUG_CHAN(ftdmchan,"Down detected blocked flags go to SUSPEND %s\n", " "); SS7_DEBUG_CHAN(ftdmchan,"Down detected blocked flags go to SUSPEND %s\n", " ");
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED); ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
break; break;
} /* if !blocked */ }
} else { } else {
SS7_DEBUG_CHAN(ftdmchan,"Reset flags present (0x%X)\n", sngss7_info->ckt_flags); SS7_DEBUG_CHAN(ftdmchan,"Reset flags present (0x%X)\n", sngss7_info->ckt_flags);
@ -1486,7 +1486,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan)
state_flag = 0; state_flag = 0;
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART); ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
} }
} /* if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) */ }
/* check if t35 is active */ /* check if t35 is active */
if (sngss7_info->t35.hb_timer_id) { if (sngss7_info->t35.hb_timer_id) {