]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
freetdm: synchronizing fixes in releases.3.5 version
authorJames Zhang <jzhang@sangoma.com>
Fri, 16 Mar 2012 15:40:21 +0000 (11:40 -0400)
committerJames Zhang <jzhang@sangoma.com>
Fri, 16 Mar 2012 15:40:21 +0000 (11:40 -0400)
         - glare
         - cgb/cgu range bug
         - inhibit/uninhibit

libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h
libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c

index 60b44cec1eb92b12146232f4c871cb6654b167c6..3f1a03f4d86299ed5cf5d60b41c84dc3855f7ddf 100644 (file)
@@ -784,16 +784,24 @@ static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream)
        stream->write_function(stream, "ftdm ss7 set ftrace X Y\n");
        stream->write_function(stream, "ftdm ss7 set mtrace X Y\n");
        stream->write_function(stream, "\n");
-       stream->write_function(stream, "ftmod_sangoma_ss7 information:\n");
-       stream->write_function(stream, "ftdm ss7 show status mtp3 X\n");
+    
+       stream->write_function(stream, "ftmod_sangoma_ss7 signaling information:\n");
+       stream->write_function(stream, "ftdm ss7 show \n");
        stream->write_function(stream, "ftdm ss7 show status mtp2 X\n");
+       stream->write_function(stream, "ftdm ss7 show status mtp3 X\n");
+       stream->write_function(stream, "ftdm ss7 show status linkset X\n");
+       stream->write_function(stream, "\n");
+    
+       stream->write_function(stream, "ftmod_sangoma_ss7 circuit information:\n");
+       stream->write_function(stream, "ftdm ss7 show span all\n");
+       stream->write_function(stream, "ftdm ss7 show span X\n");
        stream->write_function(stream, "ftdm ss7 show status span X chan Y\n");
        stream->write_function(stream, "ftdm ss7 show free span X chan Y\n");
        stream->write_function(stream, "ftdm ss7 show blocks span X chan Y\n");
-
        stream->write_function(stream, "ftdm ss7 show inuse span X chan Y\n");
        stream->write_function(stream, "ftdm ss7 show inreset span X chan Y\n");
        stream->write_function(stream, "\n");
+    
        stream->write_function(stream, "ftmod_sangoma_ss7 circuit control:\n");
        stream->write_function(stream, "ftdm ss7 blo span X chan Y\n");
        stream->write_function(stream, "ftdm ss7 ubl span X chan Y\n");
@@ -802,9 +810,12 @@ static ftdm_status_t handle_print_usage(ftdm_stream_handle_t *stream)
        stream->write_function(stream, "ftdm ss7 cgb span X chan Y range Z\n");
        stream->write_function(stream, "ftdm ss7 cgu span X chan Y range Z\n");
        stream->write_function(stream, "\n");
+    
        stream->write_function(stream, "ftmod_sangoma_ss7 link control:\n");
+       /*
        stream->write_function(stream, "ftdm ss7 inhibit link X\n");
        stream->write_function(stream, "ftdm ss7 uninhibit link X\n");
+       */
        stream->write_function(stream, "ftdm ss7 activate link X\n");
        stream->write_function(stream, "ftdm ss7 deactivate link X\n");
        stream->write_function(stream, "ftdm ss7 activate linkset X\n");
index f080352d4a8c53de999ed605823f9b8588549c61..d9816dfa0e4e502e9bde62bed449211d5c8d0d67 100644 (file)
@@ -33,6 +33,7 @@
  * Contributors: 
  *
  * Ricardo BarroetaveƱa <rbarroetavena@anura.com.ar>
+ * James Zhang <jzhang@sangoma.com>
  *
  */
 
@@ -199,7 +200,6 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
                        } else {
                                SS7_INFO_CHAN(ftdmchan,"No Called party (DNIS) information in IAM!%s\n", " ");
                        }
-
                        copy_ocn_from_sngss7(ftdmchan, &siConEvnt->origCdNum);
                        copy_redirgNum_from_sngss7(ftdmchan, &siConEvnt->redirgNum);
                        copy_redirgInfo_from_sngss7(ftdmchan, &siConEvnt->redirInfo);
@@ -316,13 +316,13 @@ handle_glare:
                
                        /* setup the hangup cause */
                        ftdmchan->caller_data.hangup_cause = 34;        /* Circuit Congrestion */
-               
-                       /* this is a remote hangup request */
-                       sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);
-               
-                       /* move the state of the channel to Terminating to end the call */
+                       
+                       /* move the state of the channel to Terminating to end the call 
+                            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.
+                       */
                        ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
-               } /* if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) */
+               }
                break;
        /**************************************************************************/
        default:        /* should not have gotten an IAM while in this state */
@@ -1283,6 +1283,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 */
                SS7_DEBUG_CHAN(ftdmchan, "Glare flag is already up...nothing to do!%s\n", " ");
        } else {
+               int bHangup = 0;
                SS7_DEBUG_CHAN(ftdmchan, "Glare flag is not up yet...indicating glare from reattempt!%s\n", " ");
                /* glare, throw the flag */
                sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE);
@@ -1290,14 +1291,45 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci
                /* clear any existing glare data from the channel */
                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 */
                ftdmchan->caller_data.hangup_cause = 34;        /* Circuit Congrestion */
 
-               /* this is a remote hangup request */
-               sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);
-
-               /* move the state of the channel to Terminating to end the call */
-               ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
+                       /* move the state of the channel to Terminating to end the call 
+                            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.
+                       */
+                       ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
+               }
        }
 
        /* unlock the channel again before we exit */
@@ -2340,7 +2372,8 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        int                                     blockType = 0;
        int                                     byte = 0;
        int                                     bit = 0;
-       int                             x;
+       int                                     x;
+       int                                     loop_range=0;
 
        ftdm_running_return(FTDM_FAIL);
 
@@ -2407,61 +2440,54 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        }
 
        /* loop over the cics starting from circuit until range+1 */
-       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) */
+       loop_range = circuit + range + 1;
+       x = circuit;
+       while( x < loop_range ) {
+               if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE)  {
+                       loop_range++;
                }
+               else {
+                       if (extract_chan_data(x, &sngss7_info, &ftdmchan)) {
+                               SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x);
+                       } else {
+                               ftdm_mutex_lock(ftdmchan->mutex);
+                               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;
+                                       /**********************************************************************/
+                                       }
+                               }
 
-               /* bring the sig status down */
-               sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
+                               /* 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);
+                               /* 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;
+                               /* update the bit and byte counter*/
+                               bit ++;
+                               if (bit == 8) {
+                                       byte++;
+                                       bit = 0;
+                               }
+                       }
                }
+               x++;
+       }
 
-       } /* for (x = circuit; x < (circuit + range + 1); x++) */
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -2488,7 +2514,8 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        int                                     blockType = 0;
        int                                     byte = 0;
        int                                     bit = 0;
-       int                             x;
+       int                                     x;
+       int                                     loop_range=0;
        ftdm_sigmsg_t           sigev;
        
        ftdm_running_return(FTDM_FAIL);
@@ -2558,59 +2585,62 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
        }
 
        /* loop over the cics starting from circuit until range+1 */
-       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;
+       loop_range = circuit + range + 1;
+       x = circuit;
+       while( x < loop_range ) {
+               if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != SNG_CKT_VOICE)  {
+                       loop_range++;
                }
+               else {
+                       if (extract_chan_data(x, &sngss7_info, &ftdmchan)) {
+                               SS7_ERROR("Failed to extract channel data for circuit = %d!\n", x);
+                       }
+                       else {
+                               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);
+                               }
+                       
+                               ftdm_mutex_unlock(ftdmchan->mutex);
 
-       } /* for (x = circuit; x < (circuit + range + 1); x++) */
+                               /* update the bit and byte counter*/
+                               bit ++;
+                               if (bit == 8) {
+                                       byte++;
+                                       bit = 0;
+                               }
+                       }
+               }
+               x++;
+       }
 
        /* get the ftdmchan and ss7_chan_data from the circuit */
        if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
index ecd83a14d46db577a5b74840791d3bae34026294..fe129c0f733307460bacca7df2044a606e1b6af3 100644 (file)
@@ -35,6 +35,7 @@
  *
  * Moises Silva <moy@sangoma.com>
  * David Yat Sin <dyatsin@sangoma.com>
+ * James Zhang <jzhang@sangoma.com>
  *
  */
 
@@ -1474,14 +1475,14 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan)
                                                SS7_DEBUG_CHAN(ftdmchan,"All reset flags cleared %s\n", "");
                                                /* all flags are down so we can bring up the sig status */
                                                sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_UP);
-                                       } /* if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) */
+                                       }
                                } else {
                                        state_flag = 0;
                                        SS7_DEBUG_CHAN(ftdmchan,"Down detected blocked flags go to SUSPEND %s\n", " ");
                                        ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
                                        break;
                        
-                               }       /* if !blocked */
+                               }
                        } else {
                                SS7_DEBUG_CHAN(ftdmchan,"Reset flags present (0x%X)\n", sngss7_info->ckt_flags);
                        
@@ -1489,7 +1490,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan)
                                state_flag = 0;
                                ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
                        }
-               } /* if ((ftdmchan->last_state == FTDM_CHANNEL_STATE_RESTART) */
+               }
 
                /* check if t35 is active */
                if (sngss7_info->t35.hb_timer_id) {
@@ -1532,20 +1533,47 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan)
 
                /* check if there is a glared call that needs to be processed */
                if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) {
-                       
-                       /* clear the glare flag */
                        sngss7_clear_ckt_flag (sngss7_info, FLAG_GLARE);
 
-                       /* check if we have an IAM stored...if we don't have one just exit */
                        if (sngss7_info->glare.circuit != 0) {
-                               /* send the saved call back in to us */
-                               handle_con_ind (0, 
-                                                               sngss7_info->glare.spInstId, 
-                                                               sngss7_info->glare.circuit, 
-                                                               &sngss7_info->glare.iam);
-
+                               int bHandle=0;
+                               switch (g_ftdm_sngss7_data.cfg.glareResolution) {
+                                       case SNGSS7_GLARE_DOWN:
+                                               SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Giving control to the other side, handling copied IAM from glare. \n", sngss7_info->circuit->cic);
+                                               bHandle = 1;
+                                               break;
+
+                                       case SNGSS7_GLARE_PC:
+                                               SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Trying to handle IAM copied from glare. \n", sngss7_info->circuit->cic);
+                                               SS7_INFO_CHAN(ftdmchan,"[CIC:%d]My PC = %d, incoming PC = %d. \n", sngss7_info->circuit->cic,
+                                                                               g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].spc, 
+                                                                               g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId].dpc );
+                                               
+                                               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 ) {
+                                                               bHandle = 1;
+                                                       }
+                                               } else {
+                                                       if( (sngss7_info->circuit->cic % 2) == 0 ) {
+                                                               bHandle = 1;
+                                                       }
+                                               }
+                                       
+                                               break;
+                                       default:                /* if configured as SNGSS7_GLARE_CONTROL, always abandon incoming glared IAM. */
+                                               bHandle = 0;
+                                               break;
+                               }
+                               
+                               if (!bHandle) {
+                                       SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Handling glare IAM. \n", sngss7_info->circuit->cic);
+                                       handle_con_ind (0, sngss7_info->glare.spInstId, sngss7_info->glare.circuit, &sngss7_info->glare.iam);                           
+                               }
+                               
                                /* clear the glare info */
                                memset(&sngss7_info->glare, 0x0, sizeof(sngss7_glare_data_t));
+                               state_flag = 0;
                        }
                }
 
index 86cdc73bc9996696c1787e4927cd98c24dd8faf9..63d4ded203e18e43d65f29d4424975acde60d698 100644 (file)
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Contributors: 
+ *
+ * James Zhang <jzhang@sangoma.com>
+ *
  */
 /******************************************************************************/
 #ifndef __FTMOD_SNG_SS7_H__
@@ -195,6 +201,21 @@ typedef struct sng_mtp2_link {
        uint32_t        t7;
 } sng_mtp2_link_t;
 
+/* defining glare handling methods: 
+       SNGSS7_GLARE_PC: 
+               higher PointCode controls even number CIC
+               lower PointCode controls odd number CIC
+       SNGSS7_GLARE_DOWN:
+               always give control to the other side
+       SNGSS7_GLARE_CONTROL:
+               always trying to control
+*/
+typedef enum {
+       SNGSS7_GLARE_PC = 0,
+       SNGSS7_GLARE_DOWN,
+       SNGSS7_GLARE_CONTROL
+} sng_glare_resolution;
+
 typedef struct sng_mtp3_link {
        char            name[MAX_NAME_LEN];
        uint32_t        flags;
@@ -444,6 +465,7 @@ typedef struct sng_ss7_cfg {
        sng_isup_ckt_t          isupCkt[10000];         /* KONRAD - only need 2000 ( and 0-1000 aren't used) since other servers are registerd else where */
        sng_nsap_t                      nsap[MAX_NSAPS+1];
        sng_isap_t                      isap[MAX_ISAPS+1];      
+       sng_glare_resolution    glareResolution;
 } sng_ss7_cfg_t;
 
 typedef struct ftdm_sngss7_data {
@@ -871,7 +893,6 @@ ftdm_status_t copy_redirgInfo_to_sngss7(ftdm_channel_t *ftdmchan, SiRedirInfo *r
 ftdm_status_t copy_ocn_to_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum);
 ftdm_status_t copy_ocn_from_sngss7(ftdm_channel_t *ftdmchan, SiOrigCdNum *origCdNum);
 
-
 ftdm_status_t copy_locPtyNum_to_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum);
 ftdm_status_t copy_locPtyNum_from_sngss7(ftdm_channel_t *ftdmchan, SiCgPtyNum *locPtyNum);
 ftdm_status_t copy_genNmb_to_sngss7(ftdm_channel_t *ftdmchan, SiGenNum *genNmb);
index 24293ef0ee48130c943f9c41ffd1688b614b188b..ad47f0cbb4f0dafc4c081cbbd0b4fce798e35fe9 100644 (file)
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * Contributors: 
+ *
+ * James Zhang <jzhang@sangoma.com>
+ *
  */
 
 /* INCLUDE ********************************************************************/
@@ -191,6 +197,7 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i
 static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan);
 
 static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot);
+static void ftmod_ss7_set_glare_resolution (const char *method);
 
 /******************************************************************************/
 
@@ -239,11 +246,11 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa
 
                if (!strcasecmp(var, "dialplan")) {
                /**********************************************************************/
-                       /* do i give a shit about this??? */
+                       /* don't care for now */
                /**********************************************************************/
                } else if (!strcasecmp(var, "context")) {
                /**********************************************************************/
-                       /* do i give a shit about this??? */
+                       /* don't care for now */
                /**********************************************************************/
                } else if (!strcasecmp(var, "ccSpanId")) {
                /**********************************************************************/
@@ -451,6 +458,26 @@ static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup)
        return FTDM_SUCCESS;
 }
 
+static void ftmod_ss7_set_glare_resolution (const char *method)
+{
+       sng_glare_resolution iMethod=SNGSS7_GLARE_PC;
+       if (!method || (strlen (method) <=0) ) {
+               SS7_ERROR( "Wrong glare resolution parameter, using default. \n" );
+       } else {
+               if (!strcasecmp( method, "PointCode")) {
+                       iMethod = SNGSS7_GLARE_PC;
+               } else if (!strcasecmp( method, "Down")) {
+                       iMethod = SNGSS7_GLARE_DOWN;
+               } else if (!strcasecmp( method, "Control")) {
+                       iMethod = SNGSS7_GLARE_CONTROL;
+               } else {
+                       SS7_ERROR( "Wrong glare resolution parameter, using default. \n" );
+                       iMethod = SNGSS7_GLARE_DOWN;                    
+               }
+       }
+       g_ftdm_sngss7_data.cfg.glareResolution = iMethod;
+}
+
 /******************************************************************************/
 static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen)
 {
@@ -463,28 +490,27 @@ static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen)
 
        /* extract all the information from the parameters */
        for (i = 0; i < num_parms; i++) {
-       /**************************************************************************/
-
                if (!strcasecmp(parm->var, "procId")) {
-               /**********************************************************************/
                        g_ftdm_sngss7_data.cfg.procId = atoi(parm->val);
                        SS7_DEBUG("Found a procId = %d\n", g_ftdm_sngss7_data.cfg.procId);
-               /**********************************************************************/
-               } else if (!strcasecmp(parm->var, "license")) {
-               /**********************************************************************/
+               } 
+               else if (!strcasecmp(parm->var, "license")) {
                        ftdm_set_string(g_ftdm_sngss7_data.cfg.license, parm->val);
                        snprintf(g_ftdm_sngss7_data.cfg.signature, sizeof(g_ftdm_sngss7_data.cfg.signature), "%s.sig", parm->val);
                        SS7_DEBUG("Found license file = %s\n", g_ftdm_sngss7_data.cfg.license);
                        SS7_DEBUG("Found signature file = %s\n", g_ftdm_sngss7_data.cfg.signature);     
-               /**********************************************************************/
-               else if (!strcasecmp(parm->var, "transparent_iam_max_size")) {
+               } 
+               else if (!strcasecmp(parm->var, "transparent_iam_max_size")) {
                        g_ftdm_sngss7_data.cfg.transparent_iam_max_size = atoi(parm->val);
                        SS7_DEBUG("Found a transparent_iam max size = %d\n", g_ftdm_sngss7_data.cfg.transparent_iam_max_size);
-               } else {
-               /**********************************************************************/
+               } 
+               else if (!strcasecmp(parm->var, "glare-reso")) {
+                       ftmod_ss7_set_glare_resolution (parm->val);
+                       SS7_DEBUG("Found glare resolution configuration = %d  %s\n", g_ftdm_sngss7_data.cfg.glareResolution, parm->val );
+               }
+               else {
                        SS7_ERROR("Found an invalid parameter \"%s\"!\n", parm->val);
                        return FTDM_FAIL;
-               /**********************************************************************/
                }
 
                /* move to the next parmeter */