<h1>Project "FreeSWITCH Source" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: b8afa79b4446b80336285d1ce0bb4293cb9e04ed (commit)
       via: 2582d71689191909fd8a62b5f5693ebd1b4dc8d1 (commit)
       via: 3546654615f88058fb6769fe79e07162602fa4af (commit)
       via: 46215605f42bf534ab040e63b9bd84a6c34c3e05 (commit)
       via: 361178089943c14bb3f842d7ff5cd8950cbe2493 (commit)
       via: 1ee94c11c7b2fd46508eebb463ffd9a1cf9b19ce (commit)
       via: 6f9da9a070517ce30e9edec6a7d2536db0646c33 (commit)
       via: eeac03ef5028b565b28364752ef5a48307ca17d4 (commit)
       via: 8037b69f40413784631c59942b5d4fc856cff845 (commit)
       via: 67edc7c3215f6476452f3ff7ee82ba559c39656f (commit)
       via: 2adfc50af7958eea12c15e023bcf80b18a4c73f9 (commit)
       via: 0cbac4ad25ed3921262a7676397206f824aade32 (commit)
       via: 2401fec54b48d8dfb1ec5a2f33a092dac076c0f3 (commit)
       via: 330d741853f4f7c548b61dbcb717266a2bf24107 (commit)
       via: 93501b288b34a7d4f5287f7bc2b498a2321d73c5 (commit)
       via: df4a18dcba1ad6a3ac20f67982642e8fe0e35471 (commit)
       via: 0e841a5f14810514ee60562481c405d7fb560e72 (commit)
       via: a93623618b83fb08f2a0a728800f431856b29f92 (commit)
       via: 804fc61a6c28f85321614ab74ba3986e2cd7a771 (commit)
       via: 428ef9666734805fa7f97f8291c06252a4f1b798 (commit)
       via: f64b03bd8b25deb191fd456a1854b02fd73626fc (commit)
       via: 3830484155cfa3bd8ef09b88515e8afa6c251121 (commit)
       via: bcb2262fdc48b36bd2e6bfe45adcbaecd1d091ee (commit)
       via: f0a31e1bfff2d49d97bc0ee83627c426fa311bfc (commit)
       via: 526e6fe48cadc9418d64f2b639bad68d8883dcdd (commit)
       via: 8c12162a9d92ceac55c6305f2336efcf7157b923 (commit)
       via: bab7a2392f955facbb91d0f30512682e2b38773e (commit)
       via: 946ec62893014a5796d0d90b1fc62797d4102164 (commit)
       via: 1cc51046c5b5b61e86394b97996a2d7833244f90 (commit)
       via: 12c13e115b96e9e036bd65655c1f12a72a83510e (commit)
       via: cf83f9c381a6abb988efc41b8711271b4665b79e (commit)
       via: 080c5ae98167e590bebf698439c550bdb656925e (commit)
       via: 0806c3880104fff154802adb010713365ef6a0ed (commit)
       via: d4b5b07b2a76404ed8bf5adf8bc2bc9c0cbd9f04 (commit)
       via: 2b4f163826132cf55698008a22c065374320796a (commit)
       via: 7386b9f8f55e6b2648bcfb3f9dafaf62dccd772e (commit)
       via: 0d5fcf65a0fef932f32874da6f4bdddb69279c53 (commit)
       via: b3086c1d6b6f4900ec770e22878038ac565424d9 (commit)
       via: beb829053945926447ba0f970faf1a3326d83981 (commit)
       via: 41dc6f46db0140b171d5ae71bfe923e7605f0cff (commit)
       via: 944b99687ea3e6f14f6eeb1f6daa97a6905fbb1d (commit)
       via: 57b0710bacb7cc58dee4262fe0c915048e47b7bc (commit)
       via: 673678509f0f3ea0464ea45798c0cdbc4843946b (commit)
       via: ae4b2873b0e56090658953f503157166825b66bc (commit)
       via: 45ec088753031fc60b1b1abeb25536b7ac042374 (commit)
       via: 53aeb1c1a71e6546950721d9f79f4a6131eb3071 (commit)
       via: be370d45ebf5bc7fc329ef0b1abd48c2e38c8e9b (commit)
       via: 4371d3c804d890315ca623e2930286154d80a9a8 (commit)
       via: 7c3ee98d3375dcab851ed8f4eb4b3d6a991295b1 (commit)
       via: 1932b3fe3bc8de85098eaf9b810da9d3b027d865 (commit)
       via: a382990d9f23096d04812cea6d66f6c3f3994e89 (commit)
       via: becb94052ac619290e6825c4f985917134c6bce2 (commit)
       via: 231a7ffaa19886653705c217a73d8e25b705503c (commit)
       via: 0d276e7d7b7b52ac5510d139d8252fc10ad37298 (commit)
       via: 9a8eea27feb6f300d5adeb078cad82974681bca7 (commit)
       via: 189db0e7ad0f4ef29ffa703114ff1d94a20d0b8f (commit)
       via: 1842798e95eeeed61604455ebcd5001bdf35eeb1 (commit)
       via: 155571d841effd7411686952da0d679af34bc0ac (commit)
       via: e1c17cffe0bfbf7c50a02acc9384679ef283a96b (commit)
       via: f37390f0a7f1ca636d54c23d6873510fcf26e91e (commit)
       via: 1388ed811a2369b26778c4cce158691f285c45b4 (commit)
       via: 00bba5790b9deeb34c7c40c289ac66ff59c9b39b (commit)
      from: 1e09a4d2dafdd9a5ffa2ab606d2caebf52baf25f (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: cypromis
comments: 
Merge remote branch &#39;origin/master&#39;
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: use packet_len as the base length in tone generation

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #000080; font-weight: bold">index 1e282d1..bd4e896 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #800080; font-weight: bold">@@ -3588,7 +3588,7 @@ static FIO_READ_FUNCTION(ftdm_raw_read)</span>
 }
 
 /* This function takes care of automatically generating DTMF or FSK tones when needed */
<span style="color: #A00000">-static ftdm_status_t handle_tone_generation(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
<span style="color: #00A000">+static ftdm_status_t handle_tone_generation(ftdm_channel_t *ftdmchan)</span>
 {
         /*
          * datalen: size in bytes of the chunk of data the user requested to read (this function 
<span style="color: #800080; font-weight: bold">@@ -3650,9 +3650,7 @@ static ftdm_status_t handle_tone_generation(ftdm_channel_t *ftdmchan, ftdm_size_</span>
         /* if we picked a buffer, time to read from it and write the linear data to the device */
         if (buffer) {
                 uint8_t auxbuf[1024];
<span style="color: #A00000">-                /* we initialize dlen to datalen, which is the size in bytes the </span>
<span style="color: #A00000">-                 * user wants to read (typically chunks of 160 bytes, 20ms G.711) */</span>
<span style="color: #A00000">-                ftdm_size_t dlen = datalen;</span>
<span style="color: #00A000">+                ftdm_size_t dlen = ftdmchan-&gt;packet_len;</span>
                 ftdm_size_t len, br, max = sizeof(auxbuf);
                 
                 /* if the codec is not linear, then data is really twice as much cuz
<span style="color: #800080; font-weight: bold">@@ -3662,10 +3660,10 @@ static ftdm_status_t handle_tone_generation(ftdm_channel_t *ftdmchan, ftdm_size_</span>
                 }
 
                 /* we do not expect the user chunks to be bigger than auxbuf */
<span style="color: #A00000">-                ftdm_assert(dlen &lt;= sizeof(auxbuf), &quot;Unexpected size for user data chunk size\n&quot;);</span>
<span style="color: #00A000">+                ftdm_assert((dlen &lt;= sizeof(auxbuf)), &quot;Unexpected size for user data chunk size\n&quot;);</span>
 
                 /* dblen is the size in use for dtmf_buffer or fsk_buffer, and dlen is the size
<span style="color: #A00000">-                 * of the read chunks of the user, we pick the smaller one */</span>
<span style="color: #00A000">+                 * of the io chunks to write, we pick the smaller one */</span>
                 len = dblen &gt; dlen ? dlen : dblen;
 
                 /* we can&#39;t read more than the size of our auxiliary buffer */
<span style="color: #800080; font-weight: bold">@@ -3770,7 +3768,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data</span>
                         rdata[i] = ftdmchan-&gt;rxgain_table[rdata[i]];
                 }
         }
<span style="color: #A00000">-        handle_tone_generation(ftdmchan, *datalen);</span>
<span style="color: #00A000">+        handle_tone_generation(ftdmchan);</span>
 
         if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) &amp;&amp; ftdmchan-&gt;effective_codec != ftdmchan-&gt;native_codec) {
                 if (ftdmchan-&gt;native_codec == FTDM_CODEC_ULAW &amp;&amp; ftdmchan-&gt;effective_codec == FTDM_CODEC_SLIN) {
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
don&#39;t bow out on att_xfer bridge

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_loopback/mod_loopback.c b/src/mod/endpoints/mod_loopback/mod_loopback.c</span>
<span style="color: #000080; font-weight: bold">index be9b499..b098ede 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_loopback/mod_loopback.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_loopback/mod_loopback.c</span>
<span style="color: #800080; font-weight: bold">@@ -637,8 +637,13 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc</span>
                 tech_pvt-&gt;other_tech_pvt &amp;&amp;
                 switch_test_flag(tech_pvt, TFLAG_BRIDGE) &amp;&amp;
                 switch_test_flag(tech_pvt-&gt;other_tech_pvt, TFLAG_BRIDGE) &amp;&amp;
<span style="color: #00A000">+</span>
                 switch_channel_test_flag(tech_pvt-&gt;channel, CF_BRIDGED) &amp;&amp;
                 switch_channel_test_flag(tech_pvt-&gt;other_channel, CF_BRIDGED) &amp;&amp;
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                !switch_channel_test_flag(tech_pvt-&gt;channel, CF_INNER_BRIDGE) &amp;&amp;</span>
<span style="color: #00A000">+                !switch_channel_test_flag(tech_pvt-&gt;other_channel, CF_INNER_BRIDGE) &amp;&amp;</span>
<span style="color: #00A000">+</span>
                 switch_channel_test_flag(tech_pvt-&gt;channel, CF_ANSWERED) &amp;&amp;
                 switch_channel_test_flag(tech_pvt-&gt;other_channel, CF_ANSWERED) &amp;&amp; !--tech_pvt-&gt;bowout_frame_count &lt;= 0) {
                 const char *a_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
Merge remote branch &#39;fsorig/master&#39;
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
Merge branch &#39;master&#39; of git.sangoma.com:/smg_freeswitch
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
freetdm: ss7 - bug fix for SPC no longer being part sng_gen config

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #000080; font-weight: bold">index 20bcc3a..df0414a 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -352,22 +352,6 @@ int  ft_to_sngss7_cfg_all(void)</span>
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */
 
<span style="color: #A00000">-        if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) {</span>
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.mtpRoute[0].flags &amp; SNGSS7_CONFIGURED)) {</span>
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                        if (ftmod_ss7_mtp3_route_config(0)) {</span>
<span style="color: #A00000">-                                SS7_CRITICAL(&quot;MTP3 ROUTE 0 configuration FAILED!\n&quot;);</span>
<span style="color: #A00000">-                                return 1;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_INFO(&quot;MTP3 ROUTE 0 configuration DONE!\n&quot;);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.mtpRoute[0].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #A00000">-                } /* if !SNGSS7_CONFIGURED */</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
         x = 1;
         while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
                 /* check if this link has been configured already */
<span style="color: #800080; font-weight: bold">@@ -1161,10 +1145,10 @@ int ftmod_ss7_mtp3_route_config(int id)</span>
         cfg.t.cfg.s.snRout.swtchType                = k-&gt;linkType;                                /* switch type */
         cfg.t.cfg.s.snRout.upSwtch                        = k-&gt;switchType;                        /* user part switch type */
         cfg.t.cfg.s.snRout.cmbLnkSetId                = k-&gt;cmbLinkSetId;                        /* combined link set ID */
<span style="color: #A00000">-        if (k-&gt;id == 0) {</span>
<span style="color: #A00000">-                cfg.t.cfg.s.snRout.dir                                 = LSN_RTE_UP;                                /* direction */</span>
<span style="color: #00A000">+        if (k-&gt;dir == SNG_RTE_UP) {</span>
<span style="color: #00A000">+                cfg.t.cfg.s.snRout.dir                         = LSN_RTE_UP;                                /* direction */</span>
         } else {
<span style="color: #A00000">-                cfg.t.cfg.s.snRout.dir                                 = LSN_RTE_DN;                                /* direction */</span>
<span style="color: #00A000">+                cfg.t.cfg.s.snRout.dir                         = LSN_RTE_DN;                                /* direction */</span>
         }
         cfg.t.cfg.s.snRout.rteToAdjSp                = 0;                                                /* flag indicating this route to adjacent SP */ 
         cfg.t.cfg.s.snRout.ssf                                = k-&gt;ssf;                                        /* sub service field */
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #000080; font-weight: bold">index fe291fb..05c6351 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #800080; font-weight: bold">@@ -83,6 +83,11 @@ typedef enum {</span>
 } sng_ckt_type_t;
 
 typedef enum {
<span style="color: #00A000">+        SNG_RTE_UP        = 0,</span>
<span style="color: #00A000">+        SNG_RTE_DN</span>
<span style="color: #00A000">+} sng_route_direction_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef enum {</span>
         SNGSS7_LPA_FOR_COT                = (1 &lt;&lt; 0),        /* send LPA when COT arrives */
         SNGSS7_ACM_OBCI_BITA        = (1 &lt;&lt; 10)        /* in-band indication */
 } sng_intf_options_t;
<span style="color: #800080; font-weight: bold">@@ -236,6 +241,7 @@ typedef struct sng_route {</span>
         uint32_t                ssf;
         uint32_t                nwId;
         uint32_t                isSTP;
<span style="color: #00A000">+        uint32_t                dir;</span>
         uint32_t                t6;
         uint32_t                t8;
         uint32_t                t10;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #000080; font-weight: bold">index 46df990..1b24e34 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #800080; font-weight: bold">@@ -2383,6 +2383,7 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)</span>
         g_ftdm_sngss7_data.cfg.mtpRoute[i].nwId                        = mtp3_route-&gt;nwId;
         g_ftdm_sngss7_data.cfg.mtpRoute[i].lnkSets                = mtp3_route-&gt;lnkSets;
         g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf                        = mtp3_route-&gt;ssf;
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].dir                        = SNG_RTE_DN;</span>
         if (mtp3_route-&gt;t6 != 0) {
                 g_ftdm_sngss7_data.cfg.mtpRoute[i].t6                = mtp3_route-&gt;t6;
         } else {
<span style="color: #800080; font-weight: bold">@@ -2443,6 +2444,52 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = 1;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.mtpRoute[i].id != 0) {</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc == spc) {</span>
<span style="color: #00A000">+                        /* we have a match so break out of this loop */</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                /* move on to the next one */</span>
<span style="color: #00A000">+                i++;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i;</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;found new mtp3 self route\n&quot;);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i;</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;found existing mtp3 self route\n&quot;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        strncpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, &quot;self-route&quot;, MAX_NAME_LEN-1);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].id                        = i;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc                        = spc;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType                = linkType;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType        = switchType;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId        = i;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].isSTP                = 0;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf                        = ssf;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].dir                        = SNG_RTE_UP;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t6                        = 8;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t8                        = 12;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t10                        = 300;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t11                        = 300;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t15                        = 30;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t16                        = 20;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t18                        = 200;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t19                        = 690;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t21                        = 650; </span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].t25                        = 100;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return 0;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
 static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)
 {
         int i;
<span style="color: #800080; font-weight: bold">@@ -2755,45 +2802,6 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf)</span>
<span style="color: #A00000">-{</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc == 0){</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found new mtp3 self route\n&quot;);</span>
<span style="color: #A00000">-        } else if (g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc == spc) {</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found existing mtp3 self route\n&quot;);</span>
<span style="color: #A00000">-                return FTDM_SUCCESS;</span>
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                SS7_ERROR(&quot;found new mtp3 self route but it does not match the route already configured (dpc=%d:spc=%d)\n&quot;,</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc,</span>
<span style="color: #A00000">-                                        spc);</span>
<span style="color: #A00000">-                return FTDM_FAIL;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        strncpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[0].name, &quot;self-route&quot;, MAX_NAME_LEN-1);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].id                        = 0;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].dpc                        = spc;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].linkType                = linkType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].switchType        = switchType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].cmbLinkSetId        = 0;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].isSTP                = 0;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].ssf                        = ssf;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t6                        = 8;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t8                        = 12;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t10                        = 300;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t11                        = 300;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t15                        = 30;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t16                        = 20;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t18                        = 200;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t19                        = 690;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t21                        = 650; </span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[0].t25                        = 100;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        return 0;</span>
<span style="color: #A00000">-}</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-/******************************************************************************/</span>
 static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)
 {
         sng_timeslot_t                timeslot;
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
Merge branch &#39;master&#39; of git.freeswitch.org:freeswitch
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: add code to troubleshoot crash on tone generation

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #000080; font-weight: bold">index c9000de..1e282d1 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #800080; font-weight: bold">@@ -2743,10 +2743,9 @@ static ftdm_status_t ftdmchan_activate_dtmf_buffer(ftdm_channel_t *ftdmchan)</span>
         if (!ftdmchan-&gt;dtmf_buffer) {
                 if (ftdm_buffer_create(&amp;ftdmchan-&gt;dtmf_buffer, 1024, 3192, 0) != FTDM_SUCCESS) {
                         ftdm_log(FTDM_LOG_ERROR, &quot;Failed to allocate DTMF Buffer!\n&quot;);
<span style="color: #A00000">-                        snprintf(ftdmchan-&gt;last_error, sizeof(ftdmchan-&gt;last_error), &quot;buffer error&quot;);</span>
                         return FTDM_FAIL;
                 } else {
<span style="color: #A00000">-                        ftdm_log(FTDM_LOG_DEBUG, &quot;Created DTMF Buffer!\n&quot;);</span>
<span style="color: #00A000">+                        ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, &quot;Created DTMF buffer\n&quot;);</span>
                 }
         }
 
<span style="color: #800080; font-weight: bold">@@ -3588,8 +3587,17 @@ static FIO_READ_FUNCTION(ftdm_raw_read)</span>
         return status;
 }
 
<span style="color: #A00000">-static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
<span style="color: #00A000">+/* This function takes care of automatically generating DTMF or FSK tones when needed */</span>
<span style="color: #00A000">+static ftdm_status_t handle_tone_generation(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
 {
<span style="color: #00A000">+        /*</span>
<span style="color: #00A000">+         * datalen: size in bytes of the chunk of data the user requested to read (this function </span>
<span style="color: #00A000">+         *          is called from the ftdm_channel_read function)</span>
<span style="color: #00A000">+         * dblen: size currently in use in any of the tone generation buffers (data available in the buffer)</span>
<span style="color: #00A000">+         * gen_dtmf_buffer: buffer holding the raw ASCII digits that the user requested to generate</span>
<span style="color: #00A000">+         * dtmf_buffer: raw linear tone data generated by teletone to be written to the devices</span>
<span style="color: #00A000">+         * fsk_buffer: raw linear FSK modulated data for caller id</span>
<span style="color: #00A000">+         */</span>
         ftdm_buffer_t *buffer = NULL;
         ftdm_size_t dblen = 0;
         int wrote = 0;
<span style="color: #800080; font-weight: bold">@@ -3604,7 +3612,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
                 }
 
                 if (ftdm_buffer_read(ftdmchan-&gt;gen_dtmf_buffer, digits, dblen) &amp;&amp; !ftdm_strlen_zero_buf(digits)) {
<span style="color: #A00000">-                        ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, &quot;Generating DTMF [%s]\n&quot;, digits);        </span>
<span style="color: #00A000">+                        ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, &quot;Generating DTMF [%s]\n&quot;, digits);</span>
                 
                         cur = digits;
 
<span style="color: #800080; font-weight: bold">@@ -3618,7 +3626,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
                                         ftdm_buffer_write(ftdmchan-&gt;dtmf_buffer, ftdmchan-&gt;tone_session.buffer, wrote * 2);
                                         x++;
                                 } else {
<span style="color: #A00000">-                                        ftdm_log(FTDM_LOG_ERROR, &quot;%d:%d Problem Adding DTMF SEQ [%s]\n&quot;, ftdmchan-&gt;span_id, ftdmchan-&gt;chan_id, digits);</span>
<span style="color: #00A000">+                                        ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, &quot;Problem adding DTMF sequence [%s]\n&quot;, digits);</span>
                                         return FTDM_FAIL;
                                 }
                         }
<span style="color: #800080; font-weight: bold">@@ -3631,6 +3639,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
         
 
         if (!ftdmchan-&gt;buffer_delay || --ftdmchan-&gt;buffer_delay == 0) {
<span style="color: #00A000">+                /* time to pick a buffer, either the dtmf or fsk buffer */</span>
                 if (ftdmchan-&gt;dtmf_buffer &amp;&amp; (dblen = ftdm_buffer_inuse(ftdmchan-&gt;dtmf_buffer))) {
                         buffer = ftdmchan-&gt;dtmf_buffer;
                 } else if (ftdmchan-&gt;fsk_buffer &amp;&amp; (dblen = ftdm_buffer_inuse(ftdmchan-&gt;fsk_buffer))) {
<span style="color: #800080; font-weight: bold">@@ -3638,22 +3647,41 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
                 }
         }
 
<span style="color: #00A000">+        /* if we picked a buffer, time to read from it and write the linear data to the device */</span>
         if (buffer) {
<span style="color: #A00000">-                ftdm_size_t dlen = datalen;</span>
                 uint8_t auxbuf[1024];
<span style="color: #00A000">+                /* we initialize dlen to datalen, which is the size in bytes the </span>
<span style="color: #00A000">+                 * user wants to read (typically chunks of 160 bytes, 20ms G.711) */</span>
<span style="color: #00A000">+                ftdm_size_t dlen = datalen;</span>
                 ftdm_size_t len, br, max = sizeof(auxbuf);
                 
<span style="color: #00A000">+                /* if the codec is not linear, then data is really twice as much cuz</span>
<span style="color: #00A000">+                   tone generation is done in linear (we assume anything different than linear is G.711) */</span>
                 if (ftdmchan-&gt;native_codec != FTDM_CODEC_SLIN) {
                         dlen *= 2;
                 }
<span style="color: #A00000">-                </span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* we do not expect the user chunks to be bigger than auxbuf */</span>
<span style="color: #00A000">+                ftdm_assert(dlen &lt;= sizeof(auxbuf), &quot;Unexpected size for user data chunk size\n&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* dblen is the size in use for dtmf_buffer or fsk_buffer, and dlen is the size</span>
<span style="color: #00A000">+                 * of the read chunks of the user, we pick the smaller one */</span>
                 len = dblen &gt; dlen ? dlen : dblen;
 
<span style="color: #00A000">+                /* we can&#39;t read more than the size of our auxiliary buffer */</span>
<span style="color: #00A000">+                ftdm_assert((len &lt;= sizeof(auxbuf)), &quot;Unexpected size to read into auxbuf\n&quot;);</span>
<span style="color: #00A000">+</span>
                 br = ftdm_buffer_read(buffer, auxbuf, len);                
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* the amount read can&#39;t possibly be bigger than what we requested */</span>
<span style="color: #00A000">+                ftdm_assert((br &lt;= len), &quot;Unexpected size read from tone generation buffer\n&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* if we read less than the chunk size, we must fill in with silence the rest */</span>
                 if (br &lt; dlen) {
                         memset(auxbuf + br, 0, dlen - br);
                 }
 
<span style="color: #00A000">+                /* finally we convert to the native format for the channel if necessary */</span>
                 if (ftdmchan-&gt;native_codec != FTDM_CODEC_SLIN) {
                         if (ftdmchan-&gt;native_codec == FTDM_CODEC_ULAW) {
                                 fio_slin2ulaw(auxbuf, max, &amp;dlen);
<span style="color: #800080; font-weight: bold">@@ -3662,6 +3690,7 @@ static ftdm_status_t handle_dtmf(ftdm_channel_t *ftdmchan, ftdm_size_t datalen)</span>
                         }
                 }
                 
<span style="color: #00A000">+                /* write the tone to the channel */</span>
                 return ftdm_raw_write(ftdmchan, auxbuf, &amp;dlen);
         } 
 
<span style="color: #800080; font-weight: bold">@@ -3741,7 +3770,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data</span>
                         rdata[i] = ftdmchan-&gt;rxgain_table[rdata[i]];
                 }
         }
<span style="color: #A00000">-        handle_dtmf(ftdmchan, *datalen);</span>
<span style="color: #00A000">+        handle_tone_generation(ftdmchan, *datalen);</span>
 
         if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_TRANSCODE) &amp;&amp; ftdmchan-&gt;effective_codec != ftdmchan-&gt;native_codec) {
                 if (ftdmchan-&gt;native_codec == FTDM_CODEC_ULAW &amp;&amp; ftdmchan-&gt;effective_codec == FTDM_CODEC_SLIN) {
<span style="color: #800080; font-weight: bold">@@ -3938,7 +3967,8 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *dat</span>
         if (!ftdmchan-&gt;buffer_delay &amp;&amp; 
                 ((ftdmchan-&gt;dtmf_buffer &amp;&amp; ftdm_buffer_inuse(ftdmchan-&gt;dtmf_buffer)) ||
                  (ftdmchan-&gt;fsk_buffer &amp;&amp; ftdm_buffer_inuse(ftdmchan-&gt;fsk_buffer)))) {
<span style="color: #A00000">-                /* read size writing DTMF ATM */</span>
<span style="color: #00A000">+                /* generating some kind of tone at the moment (see handle_tone_generation), </span>
<span style="color: #00A000">+                 * we ignore user data ... */</span>
                 goto done;
         }
 
</pre></div>
<div class="highlight"><pre>committer: Christopher Rienzo
comments: 
FS-3043 break during mod_unimrcp can hang session

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #000080; font-weight: bold">index 734ef21..d5bac5f 100644</span>
<span style="color: #A00000">--- a/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #00A000">+++ b/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</span>
<span style="color: #800080; font-weight: bold">@@ -1363,7 +1363,7 @@ static switch_status_t speech_channel_stop(speech_channel_t *schannel)</span>
                 }
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;(%s) %s stopped\n&quot;, schannel-&gt;name, speech_channel_type_to_string(schannel-&gt;type));
         } else if (schannel-&gt;state == SPEECH_CHANNEL_DONE) {
<span style="color: #A00000">-                speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);</span>
<span style="color: #00A000">+                speech_channel_set_state_unlocked(schannel, SPEECH_CHANNEL_READY);</span>
         }
 
   done:
</pre></div>
<div class="highlight"><pre>committer: Marc Olivier Chouinard
comments: 
mod_conference: Added to the Auto OutCall support to specify the conf profile to be used using variable : conference_auto_outcall_profile

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c</span>
<span style="color: #000080; font-weight: bold">index 961a140..0aee352 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_conference/mod_conference.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_conference/mod_conference.c</span>
<span style="color: #800080; font-weight: bold">@@ -401,13 +401,14 @@ static switch_status_t conference_outcall(conference_obj_t *conference,</span>
                                                                                   char *bridgeto, uint32_t timeout, 
                                                                                   char *flags, 
                                                                                   char *cid_name, 
<span style="color: #A00000">-                                                                                  char *cid_num, </span>
<span style="color: #00A000">+                                                                                  char *cid_num,</span>
<span style="color: #00A000">+                                                                                  char *profile,</span>
                                                                                   switch_call_cause_t *cause,
                                                                                   switch_call_cause_t *cancel_cause);
 static switch_status_t conference_outcall_bg(conference_obj_t *conference,
                                                                                          char *conference_name,
                                                                                          switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
<span style="color: #A00000">-                                                                                         const char *cid_num, const char *call_uuid, switch_call_cause_t *cancel_cause);</span>
<span style="color: #00A000">+                                                                                         const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause);</span>
 SWITCH_STANDARD_APP(conference_function);
 static void launch_conference_thread(conference_obj_t *conference);
 static void launch_conference_video_thread(conference_obj_t *conference);
<span style="color: #800080; font-weight: bold">@@ -2410,6 +2411,7 @@ static void conference_loop_output(conference_member_t *member)</span>
                         const char *cid_num = switch_channel_get_variable(channel, &quot;conference_auto_outcall_caller_id_number&quot;);
                         const char *toval = switch_channel_get_variable(channel, &quot;conference_auto_outcall_timeout&quot;);
                         const char *flags = switch_channel_get_variable(channel, &quot;conference_auto_outcall_flags&quot;);
<span style="color: #00A000">+                        const char *profile = switch_channel_get_variable(channel, &quot;conference_auto_outcall_profile&quot;);</span>
                         const char *ann = switch_channel_get_variable(channel, &quot;conference_auto_outcall_announce&quot;);
                         const char *prefix = switch_channel_get_variable(channel, &quot;conference_auto_outcall_prefix&quot;);
                         int to = 60;
<span style="color: #800080; font-weight: bold">@@ -2441,7 +2443,7 @@ static void conference_loop_output(conference_member_t *member)</span>
                                         char *dial_str = switch_mprintf(&quot;%s%s&quot;, switch_str_nil(prefix), argv[x]);
                                         switch_assert(dial_str);
                                         conference_outcall_bg(member-&gt;conference, NULL, NULL, dial_str, to, switch_str_nil(flags), cid_name, cid_num, NULL, 
<span style="color: #A00000">-                                                                                  &amp;member-&gt;conference-&gt;cancel_cause);</span>
<span style="color: #00A000">+                                                                                  profile, &amp;member-&gt;conference-&gt;cancel_cause);</span>
                                         switch_safe_free(dial_str);
                                 }
                                 switch_safe_free(cpstr);
<span style="color: #800080; font-weight: bold">@@ -4264,9 +4266,9 @@ static switch_status_t conf_api_sub_dial(conference_obj_t *conference, switch_st</span>
         }
 
         if (conference) {
<span style="color: #A00000">-                conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], &amp;cause, NULL);</span>
<span style="color: #00A000">+                conference_outcall(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &amp;cause, NULL);</span>
         } else {
<span style="color: #A00000">-                conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], &amp;cause, NULL);</span>
<span style="color: #00A000">+                conference_outcall(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], NULL, &amp;cause, NULL);</span>
         }
         stream-&gt;write_function(stream, &quot;Call Requested: result: [%s]\n&quot;, switch_channel_cause2str(cause));
 
<span style="color: #800080; font-weight: bold">@@ -4289,9 +4291,9 @@ static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_</span>
         switch_uuid_format(uuid_str, &amp;uuid);
 
         if (conference) {
<span style="color: #A00000">-                conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL);</span>
<span style="color: #00A000">+                conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL);</span>
         } else {
<span style="color: #A00000">-                conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL);</span>
<span style="color: #00A000">+                conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str, NULL, NULL);</span>
         }
 
         stream-&gt;write_function(stream, &quot;OK Job-UUID: %s\n&quot;, uuid_str);
<span style="color: #800080; font-weight: bold">@@ -4807,7 +4809,8 @@ static switch_status_t conference_outcall(conference_obj_t *conference,</span>
                                                                                   switch_core_session_t *session,
                                                                                   char *bridgeto, uint32_t timeout, 
                                                                                   char *flags, char *cid_name, 
<span style="color: #A00000">-                                                                                  char *cid_num, </span>
<span style="color: #00A000">+                                                                                  char *cid_num,</span>
<span style="color: #00A000">+                                                                                  char *profile,</span>
                                                                                   switch_call_cause_t *cause,
                                                                                   switch_call_cause_t *cancel_cause)
 {
<span style="color: #800080; font-weight: bold">@@ -4817,6 +4820,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference,</span>
         switch_channel_t *caller_channel = NULL;
         char appdata[512];
         int rdlock = 0;
<span style="color: #00A000">+        switch_bool_t have_flags = SWITCH_FALSE;</span>
 
         *cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
<span style="color: #800080; font-weight: bold">@@ -4902,13 +4906,16 @@ static switch_status_t conference_outcall(conference_obj_t *conference,</span>
                         status = SWITCH_STATUS_MEMERR;
                         goto done;
                 }
<span style="color: #A00000">-                /* add them to the conference */</span>
<span style="color: #00A000">+</span>
                 if (flags &amp;&amp; strcasecmp(flags, &quot;none&quot;)) {
<span style="color: #A00000">-                        switch_snprintf(appdata, sizeof(appdata), &quot;%s+flags{%s}&quot;, conference_name, flags);</span>
<span style="color: #A00000">-                        switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);</span>
<span style="color: #00A000">+                        have_flags = SWITCH_TRUE;</span>
                 }
<span style="color: #00A000">+                /* add them to the conference */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                switch_snprintf(appdata, sizeof(appdata), &quot;%s%s%s%s%s%s&quot;, conference_name,</span>
<span style="color: #00A000">+                                profile?&quot;@&quot;:&quot;&quot;, profile?profile:&quot;&quot;,</span>
<span style="color: #00A000">+                                have_flags?&quot;+flags{&quot;:&quot;&quot;, have_flags?flags:&quot;&quot;, have_flags?&quot;}&quot;:&quot;&quot;);</span>
<span style="color: #00A000">+                switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);</span>
 
                 switch_channel_set_caller_extension(peer_channel, extension);
                 switch_channel_set_state(peer_channel, CS_EXECUTE);
<span style="color: #800080; font-weight: bold">@@ -4940,6 +4947,7 @@ struct bg_call {</span>
         char *cid_num;
         char *conference_name;
         char *uuid;
<span style="color: #00A000">+        char *profile;</span>
         switch_call_cause_t *cancel_cause;
         switch_memory_pool_t *pool;
 };
<span style="color: #800080; font-weight: bold">@@ -4953,7 +4961,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,</span>
                 switch_event_t *event;
 
                 conference_outcall(call-&gt;conference, call-&gt;conference_name,
<span style="color: #A00000">-                                                   call-&gt;session, call-&gt;bridgeto, call-&gt;timeout, call-&gt;flags, call-&gt;cid_name, call-&gt;cid_num, &amp;cause, call-&gt;cancel_cause);</span>
<span style="color: #00A000">+                                                   call-&gt;session, call-&gt;bridgeto, call-&gt;timeout, call-&gt;flags, call-&gt;cid_name, call-&gt;cid_num, call-&gt;profile, &amp;cause, call-&gt;cancel_cause);</span>
 
                 if (call-&gt;conference &amp;&amp; test_eflag(call-&gt;conference, EFLAG_BGDIAL_RESULT) &amp;&amp;
                         switch_event_create_subclass(&amp;event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
<span style="color: #800080; font-weight: bold">@@ -4969,6 +4977,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,</span>
                 switch_safe_free(call-&gt;cid_num);
                 switch_safe_free(call-&gt;conference_name);
                 switch_safe_free(call-&gt;uuid);
<span style="color: #00A000">+                switch_safe_free(call-&gt;profile);</span>
                 if (call-&gt;pool) {
                         switch_core_destroy_memory_pool(&amp;call-&gt;pool);
                 }
<span style="color: #800080; font-weight: bold">@@ -4981,7 +4990,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread,</span>
 static switch_status_t conference_outcall_bg(conference_obj_t *conference,
                                                                                          char *conference_name,
                                                                                          switch_core_session_t *session, char *bridgeto, uint32_t timeout, const char *flags, const char *cid_name,
<span style="color: #A00000">-                                                                                         const char *cid_num, const char *call_uuid, switch_call_cause_t *cancel_cause)</span>
<span style="color: #00A000">+                                                                                         const char *cid_num, const char *call_uuid, const char *profile, switch_call_cause_t *cancel_cause)</span>
 {
         struct bg_call *call = NULL;
         switch_thread_t *thread;
<span style="color: #800080; font-weight: bold">@@ -5025,6 +5034,10 @@ static switch_status_t conference_outcall_bg(conference_obj_t *conference,</span>
                 call-&gt;uuid = strdup(call_uuid);
         }
 
<span style="color: #00A000">+        if (profile) {</span>
<span style="color: #00A000">+                call-&gt;profile = strdup(profile);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         switch_threadattr_create(&amp;thd_attr, pool);
         switch_threadattr_detach_set(thd_attr, 1);
         switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
<span style="color: #800080; font-weight: bold">@@ -5750,7 +5763,7 @@ SWITCH_STANDARD_APP(conference_function)</span>
         /* if we&#39;re using &quot;bridge:&quot; make an outbound call and bridge it in */
         if (!zstr(bridgeto) &amp;&amp; strcasecmp(bridgeto, &quot;none&quot;)) {
                 switch_call_cause_t cause;
<span style="color: #A00000">-                if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, &amp;cause, NULL) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                if (conference_outcall(conference, NULL, session, bridgeto, 60, NULL, NULL, NULL, NULL, &amp;cause, NULL) != SWITCH_STATUS_SUCCESS) {</span>
                         goto done;
                 }
         } else {
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
take out default it seems to suck on 32 bit

<span style="color: #000080; font-weight: bold">diff --git a/conf/autoload_configs/switch.conf.xml b/conf/autoload_configs/switch.conf.xml</span>
<span style="color: #000080; font-weight: bold">index 32cb76f..44893b9 100644</span>
<span style="color: #A00000">--- a/conf/autoload_configs/switch.conf.xml</span>
<span style="color: #00A000">+++ b/conf/autoload_configs/switch.conf.xml</span>
<span style="color: #800080; font-weight: bold">@@ -25,7 +25,7 @@</span>
     &lt;param name=&quot;colorize-console&quot; value=&quot;true&quot;/&gt;
 
     &lt;!-- minimum idle CPU before refusing calls --&gt;
<span style="color: #A00000">-    &lt;param name=&quot;min-idle-cpu&quot; value=&quot;25&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;!--&lt;param name=&quot;min-idle-cpu&quot; value=&quot;25&quot;/&gt;--&gt;</span>
 
     &lt;!--
         Max number of sessions to allow at any given time.
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
Merge remote branch &#39;smgfs/master&#39;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
minor regression from 4ae8282e6c6df0e296113e9b4b4a1383e1af8ad7 (sofia_contact with no args from cli caused seg)

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #000080; font-weight: bold">index c683203..2a2ec63 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #800080; font-weight: bold">@@ -3458,7 +3458,7 @@ SWITCH_STANDARD_API(sofia_contact_function)</span>
 {
         char *data;
         char *user = NULL;
<span style="color: #A00000">-        char *domain = NULL;</span>
<span style="color: #00A000">+        char *domain = NULL, *dup_domain = NULL;</span>
         char *concat = NULL;
         char *profile_name = NULL;
         char *p;
<span style="color: #800080; font-weight: bold">@@ -3501,7 +3501,8 @@ SWITCH_STANDARD_API(sofia_contact_function)</span>
         }
 
         if (zstr(domain)) {
<span style="color: #A00000">-                domain = switch_core_get_variable_pdup(&quot;domain&quot;, switch_core_session_get_pool(session));</span>
<span style="color: #00A000">+                dup_domain = switch_core_get_variable_dup(&quot;domain&quot;);</span>
<span style="color: #00A000">+                domain = dup_domain;</span>
         }
 
         if (!user) goto end;
<span style="color: #800080; font-weight: bold">@@ -3567,6 +3568,7 @@ SWITCH_STANDARD_API(sofia_contact_function)</span>
         switch_safe_free(mystream.data);                                        
 
         switch_safe_free(data);
<span style="color: #00A000">+        switch_safe_free(dup_domain);</span>
 
         return SWITCH_STATUS_SUCCESS;
 }
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
reset signal_bond variable back to its original value on failed dial in att_xfer

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #000080; font-weight: bold">index f7bf86b..9a1258a 100755</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_dptools/mod_dptools.c</span>
<span style="color: #800080; font-weight: bold">@@ -1864,6 +1864,7 @@ SWITCH_STANDARD_APP(att_xfer_function)</span>
 
         if (switch_ivr_originate(session, &amp;peer_session, &amp;cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)
                 != SWITCH_STATUS_SUCCESS || !peer_session) {
<span style="color: #00A000">+                switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);</span>
                 goto end;
         }
 
<span style="color: #800080; font-weight: bold">@@ -1878,6 +1879,7 @@ SWITCH_STANDARD_APP(att_xfer_function)</span>
 
         if (zstr(bond) &amp;&amp; switch_channel_down(peer_channel)) {
                 switch_core_session_rwunlock(peer_session);
<span style="color: #00A000">+                switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond);</span>
                 goto end;
         }
 
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
Fixes to support QSIG over T1

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c</span>
<span style="color: #000080; font-weight: bold">index bd5b13b..9fe2819 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -84,6 +84,8 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span</span>
                                 signal_data-&gt;switchtype = SNGISDN_SWITCH_4ESS;
                         } else if (!strcasecmp(switch_name, &quot;dms100&quot;)) {
                                 signal_data-&gt;switchtype = SNGISDN_SWITCH_DMS100;
<span style="color: #00A000">+                        } else if (!strcasecmp(switch_name, &quot;qsig&quot;)) {</span>
<span style="color: #00A000">+                                signal_data-&gt;switchtype = SNGISDN_SWITCH_QSIG;</span>
                         } else {
                                 ftdm_log(FTDM_LOG_ERROR, &quot;%s:Unsupported switchtype %s for trunktype:%s\n&quot;, span-&gt;name, switch_name, ftdm_trunk_type2str(span-&gt;trunk_type));
                                 return FTDM_FAIL;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c</span>
<span style="color: #000080; font-weight: bold">index a52a624..1bd2753 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -667,25 +667,33 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span)</span>
         cfg.t.cfg.s.inDLSAP.maxBSrvCnt = 2;
         cfg.t.cfg.s.inDLSAP.maxDSrvCnt = 2;
 #endif /* ISDN_SRV */
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-        if (signal_data-&gt;signalling == SNGISDN_SIGNALING_NET) {</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.intType = NETWORK;</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.clrGlr = FALSE;                        /* in case of glare, do not clear local call */</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE;</span>
 
<span style="color: #A00000">-                if (signal_data-&gt;switchtype == SNGISDN_SWITCH_EUROISDN ||</span>
<span style="color: #A00000">-                        signal_data-&gt;switchtype == SNGISDN_SWITCH_INSNET) {</span>
<span style="color: #A00000">-                        cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        cfg.t.cfg.s.inDLSAP.rstOpt = TRUE;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.ackOpt = FALSE;</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.intType = USER;</span>
<span style="color: #00A000">+        if (signal_data-&gt;switchtype == SNGISDN_SWITCH_QSIG) {</span>
<span style="color: #00A000">+                cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;</span>
<span style="color: #00A000">+                cfg.t.cfg.s.inDLSAP.intType = SYM_USER;</span>
                 cfg.t.cfg.s.inDLSAP.clrGlr = TRUE;                        /* in case of glare, clear local call */
                 cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE;
                 cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                if (signal_data-&gt;signalling == SNGISDN_SIGNALING_NET) {</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.intType = NETWORK;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.clrGlr = FALSE;                        /* in case of glare, do not clear local call */</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        if (signal_data-&gt;switchtype == SNGISDN_SWITCH_EUROISDN ||</span>
<span style="color: #00A000">+                                signal_data-&gt;switchtype == SNGISDN_SWITCH_INSNET) {</span>
<span style="color: #00A000">+                                cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                cfg.t.cfg.s.inDLSAP.rstOpt = TRUE;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.ackOpt = FALSE;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.intType = USER;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.clrGlr = TRUE;                        /* in case of glare, clear local call */</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;</span>
<span style="color: #00A000">+                }</span>
         }
 
         /* Override the restart options if user selected that option */
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
Fixes to support QSIG over T1

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c</span>
<span style="color: #000080; font-weight: bold">index bd5b13b..9fe2819 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -84,6 +84,8 @@ static ftdm_status_t parse_switchtype(const char* switch_name, ftdm_span_t *span</span>
                                 signal_data-&gt;switchtype = SNGISDN_SWITCH_4ESS;
                         } else if (!strcasecmp(switch_name, &quot;dms100&quot;)) {
                                 signal_data-&gt;switchtype = SNGISDN_SWITCH_DMS100;
<span style="color: #00A000">+                        } else if (!strcasecmp(switch_name, &quot;qsig&quot;)) {</span>
<span style="color: #00A000">+                                signal_data-&gt;switchtype = SNGISDN_SWITCH_QSIG;</span>
                         } else {
                                 ftdm_log(FTDM_LOG_ERROR, &quot;%s:Unsupported switchtype %s for trunktype:%s\n&quot;, span-&gt;name, switch_name, ftdm_trunk_type2str(span-&gt;trunk_type));
                                 return FTDM_FAIL;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c</span>
<span style="color: #000080; font-weight: bold">index a52a624..1bd2753 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -667,25 +667,33 @@ ftdm_status_t sngisdn_stack_cfg_q931_dlsap(ftdm_span_t *span)</span>
         cfg.t.cfg.s.inDLSAP.maxBSrvCnt = 2;
         cfg.t.cfg.s.inDLSAP.maxDSrvCnt = 2;
 #endif /* ISDN_SRV */
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-        if (signal_data-&gt;signalling == SNGISDN_SIGNALING_NET) {</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.intType = NETWORK;</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.clrGlr = FALSE;                        /* in case of glare, do not clear local call */</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE;</span>
 
<span style="color: #A00000">-                if (signal_data-&gt;switchtype == SNGISDN_SWITCH_EUROISDN ||</span>
<span style="color: #A00000">-                        signal_data-&gt;switchtype == SNGISDN_SWITCH_INSNET) {</span>
<span style="color: #A00000">-                        cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        cfg.t.cfg.s.inDLSAP.rstOpt = TRUE;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.ackOpt = FALSE;</span>
<span style="color: #A00000">-                cfg.t.cfg.s.inDLSAP.intType = USER;</span>
<span style="color: #00A000">+        if (signal_data-&gt;switchtype == SNGISDN_SWITCH_QSIG) {</span>
<span style="color: #00A000">+                cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;</span>
<span style="color: #00A000">+                cfg.t.cfg.s.inDLSAP.intType = SYM_USER;</span>
                 cfg.t.cfg.s.inDLSAP.clrGlr = TRUE;                        /* in case of glare, clear local call */
                 cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE;
                 cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                if (signal_data-&gt;signalling == SNGISDN_SIGNALING_NET) {</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.ackOpt = TRUE;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.intType = NETWORK;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.clrGlr = FALSE;                        /* in case of glare, do not clear local call */</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.statEnqOpt = TRUE;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        if (signal_data-&gt;switchtype == SNGISDN_SWITCH_EUROISDN ||</span>
<span style="color: #00A000">+                                signal_data-&gt;switchtype == SNGISDN_SWITCH_INSNET) {</span>
<span style="color: #00A000">+                                cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                cfg.t.cfg.s.inDLSAP.rstOpt = TRUE;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.ackOpt = FALSE;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.intType = USER;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.clrGlr = TRUE;                        /* in case of glare, clear local call */</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.statEnqOpt = FALSE;</span>
<span style="color: #00A000">+                        cfg.t.cfg.s.inDLSAP.rstOpt = FALSE;</span>
<span style="color: #00A000">+                }</span>
         }
 
         /* Override the restart options if user selected that option */
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
FS-3040/FS-1742: use 1 sql query for message count in a way that is portable and doesn&#39;t segfault

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index 80b011e..894e49a 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -1011,6 +1011,11 @@ typedef struct msg_cnt_callback msg_cnt_callback_t;</span>
 static int message_count_callback(void *pArg, int argc, char **argv, char **columnNames)
 {
         msg_cnt_callback_t *cbt = (msg_cnt_callback_t *) pArg;
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (argc &lt; 3 || zstr(argv[0]) || zstr(argv[1]) || zstr(argv[2])) {</span>
<span style="color: #00A000">+                return -1;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         if (atoi(argv[0]) == 1) {        /* UnRead */
                 if (!strcasecmp(argv[1], &quot;A_URGENT&quot;)) {        /* Urgent */
                         cbt-&gt;total_new_urgent_messages = atoi(argv[2]);
<span style="color: #800080; font-weight: bold">@@ -1263,7 +1268,7 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 {
         char msg_count[80] = &quot;&quot;;
         msg_cnt_callback_t cbt = { 0 };
<span style="color: #A00000">-        char sql[256];</span>
<span style="color: #00A000">+        char *sql;</span>
         char *myid = NULL;
 
 
<span style="color: #800080; font-weight: bold">@@ -1277,11 +1282,20 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 
         myid = resolve_id(id_in, domain_name, &quot;message-count&quot;);
 
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql),</span>
<span style="color: #A00000">-                                        &quot;select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; group by read_epoch=0,read_flags;&quot;,</span>
<span style="color: #A00000">-                                        myid, domain_name, myfolder);</span>
<span style="color: #00A000">+        sql = switch_mprintf(</span>
<span style="color: #00A000">+                                                 &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where &quot;</span>
<span style="color: #00A000">+                                                 &quot;username=&#39;%q&#39; and domain=&#39;%q&#39; and in_folder=&#39;%q&#39; and read_epoch=0 &quot;</span>
<span style="color: #00A000">+                                                 &quot;group by read_flags &quot;</span>
<span style="color: #00A000">+                                                 &quot;union &quot;</span>
<span style="color: #00A000">+                                                 &quot;select 0, read_flags, count(read_epoch) from voicemail_msgs where &quot;</span>
<span style="color: #00A000">+                                                 &quot;username=&#39;%q&#39; and domain=&#39;%q&#39; and in_folder=&#39;%q&#39; and read_epoch&lt;&gt;0 &quot;</span>
<span style="color: #00A000">+                                                 &quot;group by read_flags;&quot;,</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                                 myid, domain_name, myfolder,</span>
<span style="color: #00A000">+                                                 myid, domain_name, myfolder);</span>
 
         vm_execute_sql_callback(profile, profile-&gt;mutex, sql, message_count_callback, &amp;cbt);
<span style="color: #00A000">+        free(sql);</span>
 
         *total_new_messages = cbt.total_new_messages + cbt.total_new_urgent_messages;
         *total_new_urgent_messages = cbt.total_new_urgent_messages;
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
3 regresions from this now, rolling it back

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index bea8214..80b011e 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -1277,13 +1277,9 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 
         myid = resolve_id(id_in, domain_name, &quot;message-count&quot;);
 
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql), &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where &quot;</span>
<span style="color: #A00000">-                                        &quot;username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; &quot;</span>
<span style="color: #A00000">-                                        &quot;and read_epoch=0 group by read_flags union select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; &quot;</span>
<span style="color: #A00000">-                                        &quot;and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;, </span>
<span style="color: #A00000">-                                        myid, domain_name, myfolder, myid, domain_name, myfolder);</span>
<span style="color: #A00000">-                                        </span>
<span style="color: #A00000">-                                   </span>
<span style="color: #00A000">+        switch_snprintf(sql, sizeof(sql),</span>
<span style="color: #00A000">+                                        &quot;select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; group by read_epoch=0,read_flags;&quot;,</span>
<span style="color: #00A000">+                                        myid, domain_name, myfolder);</span>
 
         vm_execute_sql_callback(profile, profile-&gt;mutex, sql, message_count_callback, &amp;cbt);
 
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
Merge branch &#39;master&#39; of git.sangoma.com:smg_freeswitch
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
freetdm: allow reception of FACILITY msg in any channel state when transparent facility is enabled

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c</span>
<span style="color: #000080; font-weight: bold">index 578677a..bcc7d93 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_hndl.c</span>
<span style="color: #800080; font-weight: bold">@@ -801,6 +801,23 @@ void sngisdn_process_fac_ind (sngisdn_event_data_t *sngisdn_event)</span>
 
         ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, &quot;Processing FACILITY IND (suId:%u suInstId:%u spInstId:%u)\n&quot;, suId, suInstId, spInstId);
 
<span style="color: #00A000">+        if (signal_data-&gt;facility_ie_decode == SNGISDN_OPT_FALSE) {</span>
<span style="color: #00A000">+                /* If Facility decoding is disabled, we do not care about current call state, just pass event up to user */</span>
<span style="color: #00A000">+                ftdm_sigmsg_t sigev;</span>
<span style="color: #00A000">+                if (facEvnt-&gt;facElmt.facStr.pres) {</span>
<span style="color: #00A000">+                        get_facility_ie_str(ftdmchan, &amp;facEvnt-&gt;facElmt.facStr.val[2], facEvnt-&gt;facElmt.facStr.len-2);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                memset(&amp;sigev, 0, sizeof(sigev));</span>
<span style="color: #00A000">+                sigev.chan_id = ftdmchan-&gt;chan_id;</span>
<span style="color: #00A000">+                sigev.span_id = ftdmchan-&gt;span_id;</span>
<span style="color: #00A000">+                sigev.channel = ftdmchan;</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                sigev.event_id = FTDM_SIGEVENT_FACILITY;</span>
<span style="color: #00A000">+                ftdm_span_send_signal(ftdmchan-&gt;span, &amp;sigev);</span>
<span style="color: #00A000">+                ISDN_FUNC_TRACE_EXIT(__FUNCTION__);</span>
<span style="color: #00A000">+                return;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         switch (ftdmchan-&gt;state) {
                 case FTDM_CHANNEL_STATE_GET_CALLERID:
                         /* Update the caller ID Name */
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
Merge remote branch &#39;fsorig/master&#39;
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: do not expect result_cb to be set to make the interface cleaner

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #000080; font-weight: bold">index 0f92f59..c9000de 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #800080; font-weight: bold">@@ -37,9 +37,6 @@</span>
  *
  */
 
<span style="color: #A00000">-#ifdef MOYTEST</span>
<span style="color: #A00000">-crap</span>
<span style="color: #A00000">-#endif</span>
 #define _GNU_SOURCE
 #include &quot;private/ftdm_core.h&quot;
 #include &lt;stdarg.h&gt;
<span style="color: #800080; font-weight: bold">@@ -2509,10 +2506,12 @@ FT_DECLARE(ftdm_status_t) _ftdm_call_place(const char *file, const char *func, i</span>
         }
 
         /* we have a locked channel and are not afraid of using it! */
<span style="color: #A00000">-        status = hunting-&gt;result_cb(fchan, caller_data);</span>
<span style="color: #A00000">-        if (status != FTDM_SUCCESS) {</span>
<span style="color: #A00000">-                status = FTDM_ECANCELED;</span>
<span style="color: #A00000">-                goto done;</span>
<span style="color: #00A000">+        if (hunting-&gt;result_cb) {</span>
<span style="color: #00A000">+                status = hunting-&gt;result_cb(fchan, caller_data);</span>
<span style="color: #00A000">+                if (status != FTDM_SUCCESS) {</span>
<span style="color: #00A000">+                        status = FTDM_ECANCELED;</span>
<span style="color: #00A000">+                        goto done;</span>
<span style="color: #00A000">+                }</span>
         }
 
         ftdm_channel_set_caller_data(fchan, caller_data);
</pre></div>
<div class="highlight"><pre>committer: Daniel Swarbrick
comments: 
major factor of pgsql field handling

<span style="color: #000080; font-weight: bold">diff --git a/conf/autoload_configs/cdr_pg_csv.conf.xml b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #000080; font-weight: bold">index 427bf2d..4fec817 100644</span>
<span style="color: #A00000">--- a/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #00A000">+++ b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #800080; font-weight: bold">@@ -16,10 +16,25 @@</span>
 
     &lt;!-- This is like the info app but after the call is hung up --&gt;
     &lt;!--&lt;param name=&quot;debug&quot; value=&quot;true&quot;/&gt;--&gt;
<span style="color: #A00000">-</span>
<span style="color: #A00000">-    &lt;param name=&quot;default-template&quot; value=&quot;example&quot;/&gt;</span>
   &lt;/settings&gt;
<span style="color: #A00000">-  &lt;templates&gt;</span>
<span style="color: #A00000">-    &lt;template name=&quot;example&quot;&gt;&quot;${local_ip_v4}&quot;,&quot;${caller_id_name}&quot;,&quot;${caller_id_number}&quot;,&quot;${destination_number}&quot;,&quot;${context}&quot;,&quot;${start_stamp}&quot;,&quot;${answer_stamp}&quot;,&quot;${end_stamp}&quot;,&quot;${duration}&quot;,&quot;${billsec}&quot;,&quot;${hangup_cause}&quot;,&quot;${uuid}&quot;,&quot;${bleg_uuid}&quot;,&quot;${accountcode}&quot;,&quot;${read_codec}&quot;,&quot;${write_codec}&quot;,&quot;${sip_hangup_disposition}&quot;,&quot;${ani}&quot;&lt;/template&gt;</span>
<span style="color: #A00000">-  &lt;/templates&gt;</span>
<span style="color: #00A000">+  &lt;schema&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;local_ip_v4&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;caller_id_name&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;caller_id_number&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;destination_number&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;context&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;start_stamp&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;answer_stamp&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;end_stamp&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;duration&quot; quote=&quot;false&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;billsec&quot; quote=&quot;false&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;hangup_cause&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;uuid&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;bleg_uuid&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;accountcode&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;read_codec&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;field var=&quot;write_codec&quot;/&gt;</span>
<span style="color: #00A000">+    &lt;!-- &lt;field var=&quot;sip_hangup_disposition&quot;/&gt; --&gt;</span>
<span style="color: #00A000">+    &lt;!-- &lt;field var=&quot;ani&quot;/&gt; --&gt;</span>
<span style="color: #00A000">+  &lt;/schema&gt;</span>
 &lt;/configuration&gt;
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #000080; font-weight: bold">index 1ec56bd..51194f4 100644</span>
<span style="color: #A00000">--- a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #00A000">+++ b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #800080; font-weight: bold">@@ -59,28 +59,34 @@ typedef struct {</span>
         switch_mutex_t *mutex;
 } cdr_fd_t;
 
<span style="color: #A00000">-const char *default_template =</span>
<span style="color: #A00000">-        &quot;\&quot;${local_ip_v4}\&quot;,\&quot;${caller_id_name}\&quot;,\&quot;${caller_id_number}\&quot;,\&quot;${destination_number}\&quot;,\&quot;${context}\&quot;,\&quot;${start_stamp}\&quot;,&quot;</span>
<span style="color: #A00000">-        &quot;\&quot;${answer_stamp}\&quot;,\&quot;${end_stamp}\&quot;,\&quot;${duration}\&quot;,\&quot;${billsec}\&quot;,\&quot;${hangup_cause}\&quot;,\&quot;${uuid}\&quot;,\&quot;${bleg_uuid}\&quot;,\&quot;${accountcode}\&quot;,&quot;</span>
<span style="color: #A00000">-        &quot;\&quot;${read_codec}\&quot;,\&quot;${write_codec}\&quot;&quot;;</span>
<span style="color: #00A000">+typedef struct {</span>
<span style="color: #00A000">+        char *col_name;</span>
<span style="color: #00A000">+        char *var_name;</span>
<span style="color: #00A000">+        switch_bool_t quote;</span>
<span style="color: #00A000">+        switch_bool_t not_null;</span>
<span style="color: #00A000">+} cdr_field_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct {</span>
<span style="color: #00A000">+        char *columns;</span>
<span style="color: #00A000">+        cdr_field_t fields[1];</span>
<span style="color: #00A000">+} db_schema_t;</span>
 
 static struct {
         switch_memory_pool_t *pool;
         switch_hash_t *fd_hash;
<span style="color: #A00000">-        switch_hash_t *template_hash;</span>
         int shutdown;
         char *db_info;
         char *db_table;
<span style="color: #00A000">+        db_schema_t *db_schema;</span>
         PGconn *db_connection;
<span style="color: #00A000">+        switch_mutex_t *db_mutex;</span>
         int db_online;
         cdr_leg_t legs;
         char *spool_dir;
         spool_format_t spool_format;
         int rotate;
         int debug;
<span style="color: #A00000">-        char *default_template;</span>
<span style="color: #A00000">-        switch_mutex_t *db_mutex;</span>
<span style="color: #A00000">-} globals = { 0 };</span>
<span style="color: #00A000">+} globals;</span>
 
 static switch_xml_config_enum_item_t config_opt_cdr_leg_enum[] = {
         {&quot;a&quot;, CDR_LEG_A},
<span style="color: #800080; font-weight: bold">@@ -110,7 +116,6 @@ static switch_xml_config_item_t config_settings[] = {</span>
         /* key, type, flags, ptr, default_value, data, syntax, helptext */
         SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;db-info&quot;, CONFIG_RELOADABLE, &amp;globals.db_info, &quot;dbname=cdr&quot;, NULL, NULL),
         SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;db-table&quot;, CONFIG_RELOADABLE, &amp;globals.db_table, &quot;cdr&quot;, NULL, NULL),
<span style="color: #A00000">-        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;default-template&quot;, CONFIG_RELOADABLE, &amp;globals.default_template, &quot;default&quot;, NULL, NULL),</span>
         SWITCH_CONFIG_ITEM(&quot;legs&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.legs, (void *) CDR_LEG_A, &amp;config_opt_cdr_leg_enum, &quot;a|b|ab&quot;, NULL),
         SWITCH_CONFIG_ITEM(&quot;spool-format&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.spool_format, (void *) SPOOL_FORMAT_CSV, &amp;config_opt_spool_format_enum, &quot;csv|sql&quot;, &quot;Disk spool format to use if SQL insert fails.&quot;),
         SWITCH_CONFIG_ITEM(&quot;rotate-on-hup&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &amp;globals.rotate, SWITCH_FALSE, NULL, NULL, NULL),
<span style="color: #800080; font-weight: bold">@@ -239,135 +244,13 @@ static void spool_cdr(const char *path, const char *log_line)</span>
         switch_safe_free(log_line_lf);
 }
 
<span style="color: #A00000">-static switch_status_t insert_cdr(const char * const template, const char * const cdr)</span>
<span style="color: #00A000">+static switch_status_t insert_cdr(const char *values)</span>
 {
<span style="color: #A00000">-        char *columns, *values;</span>
<span style="color: #A00000">-        char *p, *q;</span>
<span style="color: #A00000">-        unsigned vlen;</span>
<span style="color: #A00000">-        char *nullValues, *temp, *tp;</span>
<span style="color: #A00000">-        int nullCounter = 0, charCounter = 0;</span>
         char *sql = NULL, *path = NULL;
         PGresult *res;
 
<span style="color: #A00000">-        if (!template || !*template || !cdr || !*cdr) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, &quot;Bad parameter\n&quot;);</span>
<span style="color: #A00000">-                return SWITCH_STATUS_FALSE;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /* Build comma-separated list of field names by dropping $ { } ; chars */</span>
<span style="color: #A00000">-        switch_strdup(columns, template);</span>
<span style="color: #A00000">-        for (p = columns, q = columns; *p; ++p) {</span>
<span style="color: #A00000">-                switch (*p) {</span>
<span style="color: #A00000">-                        case &#39;$&#39;: case &#39;&quot;&#39;: case &#39;{&#39;: case &#39;}&#39;: case &#39;;&#39;:</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        default:</span>
<span style="color: #A00000">-                                *q++ = *p;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        *q = &#39;\0&#39;;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /*</span>
<span style="color: #A00000">-         * In the expanded vars, replace double quotes (&quot;) with single quotes (&#39;)</span>
<span style="color: #A00000">-         * for correct PostgreSQL syntax, and replace semi-colon with space to</span>
<span style="color: #A00000">-         * prevent SQL injection attacks</span>
<span style="color: #A00000">-         */</span>
<span style="color: #A00000">-        switch_strdup(values, cdr);</span>
<span style="color: #A00000">-        for (p = values; *p; ++p) {</span>
<span style="color: #A00000">-                switch(*p) {</span>
<span style="color: #A00000">-                        case &#39;&quot;&#39;:</span>
<span style="color: #A00000">-                                *p = &#39;\&#39;&#39;;</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case &#39;;&#39;:</span>
<span style="color: #A00000">-                                *p = &#39; &#39;;</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        vlen = p - values;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /*</span>
<span style="color: #A00000">-         * Patch for changing empty strings (&#39;&#39;) in the expanded variables to</span>
<span style="color: #A00000">-         * PostgreSQL null</span>
<span style="color: #A00000">-         */</span>
<span style="color: #A00000">-        for (p = values; *p; ++p) {</span>
<span style="color: #A00000">-                if (*p == &#39;,&#39;) {</span>
<span style="color: #A00000">-                        if (charCounter == 0) {</span>
<span style="color: #A00000">-                                nullCounter++;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                        charCounter = 0;</span>
<span style="color: #A00000">-                } else if (*p != &#39; &#39; &amp;&amp; *p != &#39;\&#39;&#39;) {</span>
<span style="color: #A00000">-                        charCounter++;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (charCounter == 0) {</span>
<span style="color: #A00000">-                nullCounter++;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        nullCounter *= 4;</span>
<span style="color: #A00000">-        vlen += nullCounter;</span>
<span style="color: #A00000">-        switch_zmalloc(nullValues, strlen(values) + nullCounter + 1);</span>
<span style="color: #A00000">-        charCounter = 0;</span>
<span style="color: #A00000">-        temp = nullValues;</span>
<span style="color: #A00000">-        tp = nullValues;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        for (p = values; *p; ++tp, ++p) {</span>
<span style="color: #A00000">-                if (*p == &#39;,&#39;) {</span>
<span style="color: #A00000">-                        if (charCounter == 0) {</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                *temp = &#39;n&#39;;</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                                *temp = &#39;u&#39;;</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                                *temp = &#39;l&#39;;</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                                *temp = &#39;l&#39;;</span>
<span style="color: #A00000">-                                temp++;</span>
<span style="color: #A00000">-                                while (temp != tp) {</span>
<span style="color: #A00000">-                                        *temp = &#39; &#39;;</span>
<span style="color: #A00000">-                                        temp++;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                        charCounter = 0;</span>
<span style="color: #A00000">-                        temp = tp;</span>
<span style="color: #A00000">-                } else if (*p != &#39; &#39; &amp;&amp; *p != &#39;\&#39;&#39;) {</span>
<span style="color: #A00000">-                        charCounter++;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                *tp = *p;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (charCounter == 0) {</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                *temp = &#39;n&#39;;</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                *temp = &#39;u&#39;;</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                *temp = &#39;l&#39;;</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                if (temp == tp) tp++;</span>
<span style="color: #A00000">-                *temp = &#39;l&#39;;</span>
<span style="color: #A00000">-                temp++;</span>
<span style="color: #A00000">-                while (temp != tp) {</span>
<span style="color: #A00000">-                        *temp = &#39; &#39;;</span>
<span style="color: #A00000">-                        temp++;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        charCounter = 0;</span>
<span style="color: #A00000">-        temp = tp;</span>
<span style="color: #A00000">-        *tp = 0;</span>
<span style="color: #A00000">-        tp = values;</span>
<span style="color: #A00000">-        values = nullValues;</span>
<span style="color: #A00000">-        switch_safe_free(tp);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        sql = switch_mprintf(&quot;INSERT INTO %s (%s) VALUES (%s);&quot;, globals.db_table, columns, values);</span>
<span style="color: #00A000">+        sql = switch_mprintf(&quot;INSERT INTO %s (%s) VALUES (%s);&quot;, globals.db_table, globals.db_schema-&gt;columns, values);</span>
         assert(sql);
<span style="color: #A00000">-        switch_safe_free(columns);</span>
<span style="color: #A00000">-        switch_safe_free(values);</span>
 
         if (globals.debug) {
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, &quot;Query: \&quot;%s\&quot;\n&quot;, sql);
<span style="color: #800080; font-weight: bold">@@ -415,7 +298,7 @@ static switch_status_t insert_cdr(const char * const template, const char * cons</span>
         } else {
                 path = switch_mprintf(&quot;%s%scdr-spool.csv&quot;, globals.spool_dir, SWITCH_PATH_SEPARATOR);
                 assert(path);
<span style="color: #A00000">-                spool_cdr(path, cdr);</span>
<span style="color: #00A000">+                spool_cdr(path, values);</span>
         }
 
         switch_safe_free(path);
<span style="color: #800080; font-weight: bold">@@ -428,8 +311,10 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)</span>
 {
         switch_channel_t *channel = switch_core_session_get_channel(session);
         switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #A00000">-        const char *template_str = NULL;</span>
<span style="color: #A00000">-        char *expanded_vars = NULL;</span>
<span style="color: #00A000">+        char *values = NULL, *tmp = NULL, *pq_var = NULL;</span>
<span style="color: #00A000">+        const char *var = NULL;</span>
<span style="color: #00A000">+        cdr_field_t *cdr_field = NULL;</span>
<span style="color: #00A000">+        switch_size_t len, offset;</span>
 
         if (globals.shutdown) {
                 return SWITCH_STATUS_SUCCESS;
<span style="color: #800080; font-weight: bold">@@ -465,24 +350,40 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)</span>
                 }
         }
 
<span style="color: #A00000">-        template_str = (const char *) switch_core_hash_find(globals.template_hash, globals.default_template);</span>
<span style="color: #00A000">+        switch_zmalloc(values, 1);</span>
<span style="color: #00A000">+        offset = 0;</span>
 
<span style="color: #A00000">-        if (!template_str) {</span>
<span style="color: #A00000">-                template_str = default_template;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        for (cdr_field = globals.db_schema-&gt;fields; cdr_field-&gt;var_name; cdr_field++) {</span>
<span style="color: #00A000">+                if ((var = switch_channel_get_variable(channel, cdr_field-&gt;var_name))) {</span>
<span style="color: #00A000">+                        /* Allocate sufficient buffer for PQescapeString */</span>
<span style="color: #00A000">+                        len = strlen(var);</span>
<span style="color: #00A000">+                        tmp = switch_core_session_alloc(session, len * 2 + 1);</span>
<span style="color: #00A000">+                        PQescapeString(tmp, var, len);</span>
<span style="color: #00A000">+                        var = tmp;</span>
<span style="color: #00A000">+                }</span>
 
<span style="color: #A00000">-        expanded_vars = switch_channel_expand_variables(channel, template_str);</span>
<span style="color: #00A000">+                if (cdr_field-&gt;quote) {</span>
<span style="color: #00A000">+                        if ((cdr_field-&gt;not_null == SWITCH_FALSE) &amp;&amp; zstr(var)) {</span>
<span style="color: #00A000">+                                pq_var = switch_mprintf(&quot;null,&quot;, var);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                pq_var = switch_mprintf(&quot;&#39;%s&#39;,&quot;, var);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        pq_var = switch_mprintf(&quot;%s,&quot;, var);</span>
<span style="color: #00A000">+                }</span>
 
<span style="color: #A00000">-        if (!expanded_vars) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error expanding CDR variables.\n&quot;);</span>
<span style="color: #A00000">-                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+                /* Resize values buffer to accomodate next var */</span>
<span style="color: #00A000">+                len = strlen(pq_var);</span>
<span style="color: #00A000">+                tmp = realloc(values, offset + len);</span>
<span style="color: #00A000">+                values = tmp;</span>
<span style="color: #00A000">+                memcpy(values + offset, pq_var, len);</span>
<span style="color: #00A000">+                switch_safe_free(pq_var);</span>
<span style="color: #00A000">+                offset += len;</span>
         }
<span style="color: #00A000">+        *(values + --offset) = &#39;\0&#39;;</span>
 
<span style="color: #A00000">-        insert_cdr(template_str, expanded_vars);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (expanded_vars != template_str) {</span>
<span style="color: #A00000">-                switch_safe_free(expanded_vars);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        insert_cdr(values);</span>
<span style="color: #00A000">+        switch_safe_free(values);</span>
 
         return status;
 }
<span style="color: #800080; font-weight: bold">@@ -532,9 +433,13 @@ static switch_state_handler_table_t state_handlers = {</span>
 
 static switch_status_t load_config(switch_memory_pool_t *pool)
 {
<span style="color: #A00000">-        char *cf = &quot;cdr_pg_csv.conf&quot;;</span>
<span style="color: #A00000">-        switch_xml_t cfg, xml, settings, param;</span>
         switch_status_t status = SWITCH_STATUS_SUCCESS;
<span style="color: #00A000">+        char *cf = &quot;cdr_pg_csv.conf&quot;, *ptr;</span>
<span style="color: #00A000">+        switch_xml_t cfg, xml, schema, field;</span>
<span style="color: #00A000">+        const char *attr;</span>
<span style="color: #00A000">+        int num_fields = 0;</span>
<span style="color: #00A000">+        switch_size_t len = 0;</span>
<span style="color: #00A000">+        cdr_field_t *cdr_field;</span>
 
         if (globals.db_online) {
                 PQfinish(globals.db_connection);
<span style="color: #800080; font-weight: bold">@@ -544,32 +449,69 @@ static switch_status_t load_config(switch_memory_pool_t *pool)</span>
 
         memset(&amp;globals, 0, sizeof(globals));
         switch_core_hash_init(&amp;globals.fd_hash, pool);
<span style="color: #A00000">-        switch_core_hash_init(&amp;globals.template_hash, pool);</span>
         switch_mutex_init(&amp;globals.db_mutex, SWITCH_MUTEX_NESTED, pool);
 
         globals.pool = pool;
 
<span style="color: #A00000">-        switch_core_hash_insert(globals.template_hash, &quot;default&quot;, default_template);</span>
<span style="color: #A00000">-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Adding default template.\n&quot;);</span>
<span style="color: #A00000">-        globals.legs = CDR_LEG_A;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (switch_xml_config_parse_module_settings(&quot;cdr_pg_csv.conf&quot;, SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+        if (switch_xml_config_parse_module_settings(cf, SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {</span>
                 return SWITCH_STATUS_FALSE;
         }
 
         if ((xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {
<span style="color: #A00000">-                if ((settings = switch_xml_child(cfg, &quot;templates&quot;))) {</span>
<span style="color: #A00000">-                        for (param = switch_xml_child(settings, &quot;template&quot;); param; param = param-&gt;next) {</span>
<span style="color: #A00000">-                                char *var = (char *) switch_xml_attr(param, &quot;name&quot;);</span>
<span style="color: #A00000">-                                if (var) {</span>
<span style="color: #A00000">-                                        char *tpl;</span>
<span style="color: #A00000">-                                        tpl = switch_core_strdup(pool, param-&gt;txt);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        switch_core_hash_insert(globals.template_hash, var, tpl);</span>
<span style="color: #A00000">-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Adding template %s.\n&quot;, var);</span>
<span style="color: #00A000">+                if ((schema = switch_xml_child(cfg, &quot;schema&quot;))) {</span>
<span style="color: #00A000">+                        /* Count fields in schema so we can calculate required buffer size */</span>
<span style="color: #00A000">+                        for (field = switch_xml_child(schema, &quot;field&quot;); field; field = field-&gt;next) {</span>
<span style="color: #00A000">+                                if (switch_xml_attr(field, &quot;var&quot;)) {</span>
<span style="color: #00A000">+                                        num_fields++;</span>
                                 }
                         }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        globals.db_schema = switch_core_alloc(pool, (num_fields + 1) * sizeof(cdr_field_t));</span>
<span style="color: #00A000">+                        cdr_field = globals.db_schema-&gt;fields;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        for (field = switch_xml_child(schema, &quot;field&quot;); field; field = field-&gt;next) {</span>
<span style="color: #00A000">+                                if ((attr = switch_xml_attr(field, &quot;var&quot;))) {</span>
<span style="color: #00A000">+                                        cdr_field-&gt;var_name = switch_core_strdup(pool, attr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* Assume SQL column name is the same as FreeSWITCH channel var name, unless specified otherwise */</span>
<span style="color: #00A000">+                                        if ((attr = switch_xml_attr(field, &quot;column&quot;))) {</span>
<span style="color: #00A000">+                                                cdr_field-&gt;col_name = switch_core_strdup(pool, attr);</span>
<span style="color: #00A000">+                                        } else {</span>
<span style="color: #00A000">+                                                cdr_field-&gt;col_name = switch_core_strdup(pool, cdr_field-&gt;var_name);</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* Assume all fields should be quoted (treated as strings), unless specified otherwise */</span>
<span style="color: #00A000">+                                        if ((attr = switch_xml_attr(field, &quot;quote&quot;)) &amp;&amp; !strncmp(attr, &quot;false&quot;, 5)) {</span>
<span style="color: #00A000">+                                                cdr_field-&gt;quote = SWITCH_FALSE;</span>
<span style="color: #00A000">+                                        } else {</span>
<span style="color: #00A000">+                                                cdr_field-&gt;quote = SWITCH_TRUE;</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* Assume all fields allow SQL nulls, unless specified otherwise */</span>
<span style="color: #00A000">+                                        if ((attr = switch_xml_attr(field, &quot;not-null&quot;)) &amp;&amp; !strncmp(attr, &quot;true&quot;, 4)) {</span>
<span style="color: #00A000">+                                                cdr_field-&gt;not_null = SWITCH_TRUE;</span>
<span style="color: #00A000">+                                        } else {</span>
<span style="color: #00A000">+                                                cdr_field-&gt;not_null = SWITCH_FALSE;</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        len += strlen(cdr_field-&gt;col_name) + 1;</span>
<span style="color: #00A000">+                                        cdr_field++;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        cdr_field-&gt;var_name = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        globals.db_schema-&gt;columns = switch_core_alloc(pool, len);</span>
<span style="color: #00A000">+                        ptr = globals.db_schema-&gt;columns;</span>
<span style="color: #00A000">+                        for (cdr_field = globals.db_schema-&gt;fields; cdr_field-&gt;col_name; cdr_field++) {</span>
<span style="color: #00A000">+                                len = strlen(cdr_field-&gt;col_name);</span>
<span style="color: #00A000">+                                memcpy(ptr, cdr_field-&gt;col_name, len);</span>
<span style="color: #00A000">+                                ptr += len;</span>
<span style="color: #00A000">+                                *ptr = &#39;,&#39;;</span>
<span style="color: #00A000">+                                ptr++;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        *--ptr = &#39;\0&#39;;</span>
                 }
<span style="color: #00A000">+</span>
                 switch_xml_free(xml);
         }
 
<span style="color: #800080; font-weight: bold">@@ -596,7 +538,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load)</span>
         switch_core_add_state_handler(&amp;state_handlers);
         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
<span style="color: #A00000">-</span>
         return status;
 }
 
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
default to 10

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #000080; font-weight: bold">index c78aac7..c683203 100644</span>
<span style="color: #A00000">--- a/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #00A000">+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c</span>
<span style="color: #800080; font-weight: bold">@@ -3708,7 +3708,7 @@ SWITCH_STANDARD_API(sofia_function)</span>
 
                                 if (argc &gt; 2) {
                                         if (strstr(argv[2], &quot;presence&quot;)) {
<span style="color: #A00000">-                                                mod_sofia_globals.debug_presence = 1;</span>
<span style="color: #00A000">+                                                mod_sofia_globals.debug_presence = 10;</span>
                                                 stream-&gt;write_function(stream, &quot;+OK Debugging presence\n&quot;);
                                         }
                                         
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
FS-3038

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c</span>
<span style="color: #000080; font-weight: bold">index 807770a..f34042a 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_commands/mod_commands.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_commands/mod_commands.c</span>
<span style="color: #800080; font-weight: bold">@@ -4439,19 +4439,23 @@ SWITCH_STANDARD_API(strftime_tz_api_function)</span>
 
                 if ((format = strchr(mycmd, &#39; &#39;))) {
                         *format++ = &#39;\0&#39;;
<span style="color: #A00000">-                }</span>
                 
<span style="color: #A00000">-                if ((p = strchr(format, &#39;|&#39;))) {</span>
<span style="color: #A00000">-                        *p++ = &#39;\0&#39;;</span>
<span style="color: #A00000">-                        when = atol(format);</span>
<span style="color: #A00000">-                        format = p;</span>
<span style="color: #00A000">+                        if (format &amp;&amp; (p = strchr(format, &#39;|&#39;))) {</span>
<span style="color: #00A000">+                                *p++ = &#39;\0&#39;;</span>
<span style="color: #00A000">+                                when = atol(format);</span>
<span style="color: #00A000">+                                format = p;</span>
<span style="color: #00A000">+                        }</span>
                 }
         }
 
<span style="color: #A00000">-        if (switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) {        /* The lookup of the zone may fail. */</span>
<span style="color: #00A000">+        if (zstr(format)) {</span>
<span style="color: #00A000">+                format = &quot;%Y-%m-%d&quot;;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        if (format &amp;&amp; switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) {        /* The lookup of the zone may fail. */</span>
                 stream-&gt;write_function(stream, &quot;%s&quot;, date);
         } else {
<span style="color: #A00000">-                stream-&gt;write_function(stream, &quot;-ERR Invalid Timezone\n&quot;);</span>
<span style="color: #00A000">+                stream-&gt;write_function(stream, &quot;-ERR Invalid Timezone/Format\n&quot;);</span>
         }
 
         switch_safe_free(mycmd);
</pre></div>
<div class="highlight"><pre>committer: Anthony Minessale
comments: 
FS-3040

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index f829e57..bea8214 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -1277,9 +1277,14 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 
         myid = resolve_id(id_in, domain_name, &quot;message-count&quot;);
 
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql), &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; &quot;</span>
<span style="color: #A00000">-                                                                          &quot;and read_epoch=0 group by read_flags union select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; &quot;</span>
<span style="color: #A00000">-                                                                          &quot;and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;, myid, domain_name, myfolder);</span>
<span style="color: #00A000">+        switch_snprintf(sql, sizeof(sql), &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where &quot;</span>
<span style="color: #00A000">+                                        &quot;username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; &quot;</span>
<span style="color: #00A000">+                                        &quot;and read_epoch=0 group by read_flags union select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; &quot;</span>
<span style="color: #00A000">+                                        &quot;and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;, </span>
<span style="color: #00A000">+                                        myid, domain_name, myfolder, myid, domain_name, myfolder);</span>
<span style="color: #00A000">+                                        </span>
<span style="color: #00A000">+                                   </span>
<span style="color: #00A000">+</span>
         vm_execute_sql_callback(profile, profile-&gt;mutex, sql, message_count_callback, &amp;cbt);
 
         *total_new_messages = cbt.total_new_messages + cbt.total_new_urgent_messages;
</pre></div>
<div class="highlight"><pre>committer: Daniel Swarbrick
comments: 
refactor config parsing

<span style="color: #000080; font-weight: bold">diff --git a/conf/autoload_configs/cdr_pg_csv.conf.xml b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #000080; font-weight: bold">index 2f2efa9..427bf2d 100644</span>
<span style="color: #A00000">--- a/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #00A000">+++ b/conf/autoload_configs/cdr_pg_csv.conf.xml</span>
<span style="color: #800080; font-weight: bold">@@ -1,19 +1,23 @@</span>
 &lt;configuration name=&quot;cdr_pg_csv.conf&quot; description=&quot;CDR PG CSV Format&quot;&gt;
   &lt;settings&gt;
<span style="color: #A00000">-    &lt;!-- Log a-leg (a), b-leg (b) or both (ab) --&gt;</span>
<span style="color: #A00000">-    &lt;param name=&quot;legs&quot; value=&quot;a&quot;/&gt;</span>
     &lt;!-- See parameters for PQconnectdb() at http://www.postgresql.org/docs/8.4/static/libpq-connect.html --&gt;
     &lt;param name=&quot;db-info&quot; value=&quot;host=localhost dbname=cdr connect_timeout=10&quot; /&gt;
     &lt;!-- CDR table name --&gt;
     &lt;!--&lt;param name=&quot;db-table&quot; value=&quot;cdr&quot;/&gt;--&gt;
<span style="color: #A00000">-    &lt;param name=&quot;default-template&quot; value=&quot;example&quot;/&gt;</span>
<span style="color: #A00000">-    &lt;!-- &#39;cdr-pg-csv&#39; will always be appended to log-base --&gt;</span>
<span style="color: #A00000">-    &lt;!--&lt;param name=&quot;log-base&quot; value=&quot;/var/log&quot;/&gt;--&gt;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+    &lt;!-- Log a-leg (a), b-leg (b) or both (ab) --&gt;</span>
<span style="color: #00A000">+    &lt;param name=&quot;legs&quot; value=&quot;a&quot;/&gt;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+    &lt;!-- Directory in which to spool failed SQL inserts --&gt;</span>
<span style="color: #00A000">+    &lt;!-- &lt;param name=&quot;spool-dir&quot; value=&quot;$${base_dir}/log/cdr-pg-csv&quot;/&gt; --&gt;</span>
     &lt;!-- Disk spool format if DB connection/insert fails - csv (default) or sql --&gt;
     &lt;param name=&quot;spool-format&quot; value=&quot;csv&quot;/&gt;
     &lt;param name=&quot;rotate-on-hup&quot; value=&quot;true&quot;/&gt;
<span style="color: #00A000">+</span>
     &lt;!-- This is like the info app but after the call is hung up --&gt;
     &lt;!--&lt;param name=&quot;debug&quot; value=&quot;true&quot;/&gt;--&gt;
<span style="color: #00A000">+</span>
<span style="color: #00A000">+    &lt;param name=&quot;default-template&quot; value=&quot;example&quot;/&gt;</span>
   &lt;/settings&gt;
   &lt;templates&gt;
     &lt;template name=&quot;example&quot;&gt;&quot;${local_ip_v4}&quot;,&quot;${caller_id_name}&quot;,&quot;${caller_id_number}&quot;,&quot;${destination_number}&quot;,&quot;${context}&quot;,&quot;${start_stamp}&quot;,&quot;${answer_stamp}&quot;,&quot;${end_stamp}&quot;,&quot;${duration}&quot;,&quot;${billsec}&quot;,&quot;${hangup_cause}&quot;,&quot;${uuid}&quot;,&quot;${bleg_uuid}&quot;,&quot;${accountcode}&quot;,&quot;${read_codec}&quot;,&quot;${write_codec}&quot;,&quot;${sip_hangup_disposition}&quot;,&quot;${ani}&quot;&lt;/template&gt;
<span style="color: #000080; font-weight: bold">diff --git a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #000080; font-weight: bold">index 5227161..1ec56bd 100644</span>
<span style="color: #A00000">--- a/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #00A000">+++ b/src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c</span>
<span style="color: #800080; font-weight: bold">@@ -37,18 +37,27 @@</span>
 #include &lt;switch.h&gt;
 #include &lt;libpq-fe.h&gt;
 
<span style="color: #00A000">+SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load);</span>
<span style="color: #00A000">+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_pg_csv_shutdown);</span>
<span style="color: #00A000">+SWITCH_MODULE_DEFINITION(mod_cdr_pg_csv, mod_cdr_pg_csv_load, mod_cdr_pg_csv_shutdown, NULL);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
 typedef enum {
         CDR_LEG_A = (1 &lt;&lt; 0),
         CDR_LEG_B = (1 &lt;&lt; 1)
 } cdr_leg_t;
 
<span style="color: #A00000">-struct cdr_fd {</span>
<span style="color: #00A000">+typedef enum {</span>
<span style="color: #00A000">+        SPOOL_FORMAT_CSV,</span>
<span style="color: #00A000">+        SPOOL_FORMAT_SQL</span>
<span style="color: #00A000">+} spool_format_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct {</span>
         int fd;
         char *path;
         int64_t bytes;
         switch_mutex_t *mutex;
<span style="color: #A00000">-};</span>
<span style="color: #A00000">-typedef struct cdr_fd cdr_fd_t;</span>
<span style="color: #00A000">+} cdr_fd_t;</span>
 
 const char *default_template =
         &quot;\&quot;${local_ip_v4}\&quot;,\&quot;${caller_id_name}\&quot;,\&quot;${caller_id_number}\&quot;,\&quot;${destination_number}\&quot;,\&quot;${context}\&quot;,\&quot;${start_stamp}\&quot;,&quot;
<span style="color: #800080; font-weight: bold">@@ -59,23 +68,59 @@ static struct {</span>
         switch_memory_pool_t *pool;
         switch_hash_t *fd_hash;
         switch_hash_t *template_hash;
<span style="color: #A00000">-        char *log_dir;</span>
<span style="color: #A00000">-        char *default_template;</span>
         int shutdown;
<span style="color: #A00000">-        int rotate;</span>
<span style="color: #A00000">-        int debug;</span>
<span style="color: #A00000">-        cdr_leg_t legs;</span>
         char *db_info;
         char *db_table;
<span style="color: #A00000">-        char *spool_format;</span>
         PGconn *db_connection;
         int db_online;
<span style="color: #00A000">+        cdr_leg_t legs;</span>
<span style="color: #00A000">+        char *spool_dir;</span>
<span style="color: #00A000">+        spool_format_t spool_format;</span>
<span style="color: #00A000">+        int rotate;</span>
<span style="color: #00A000">+        int debug;</span>
<span style="color: #00A000">+        char *default_template;</span>
         switch_mutex_t *db_mutex;
 } globals = { 0 };
 
<span style="color: #A00000">-SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load);</span>
<span style="color: #A00000">-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_pg_csv_shutdown);</span>
<span style="color: #A00000">-SWITCH_MODULE_DEFINITION(mod_cdr_pg_csv, mod_cdr_pg_csv_load, mod_cdr_pg_csv_shutdown, NULL);</span>
<span style="color: #00A000">+static switch_xml_config_enum_item_t config_opt_cdr_leg_enum[] = {</span>
<span style="color: #00A000">+        {&quot;a&quot;, CDR_LEG_A},</span>
<span style="color: #00A000">+        {&quot;b&quot;, CDR_LEG_B},</span>
<span style="color: #00A000">+        {&quot;ab&quot;, CDR_LEG_A | CDR_LEG_B},</span>
<span style="color: #00A000">+        {NULL, 0}</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_xml_config_enum_item_t config_opt_spool_format_enum[] = {</span>
<span style="color: #00A000">+        {&quot;csv&quot;, SPOOL_FORMAT_CSV},</span>
<span style="color: #00A000">+        {&quot;sql&quot;, SPOOL_FORMAT_SQL},</span>
<span style="color: #00A000">+        {NULL, 0}</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_status_t config_validate_spool_dir(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        if ((callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD)) {</span>
<span style="color: #00A000">+                if (zstr(newvalue)) {</span>
<span style="color: #00A000">+                        globals.spool_dir = switch_core_sprintf(globals.pool, &quot;%s%scdr-pg-csv&quot;, SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return SWITCH_STATUS_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static switch_xml_config_item_t config_settings[] = {</span>
<span style="color: #00A000">+        /* key, type, flags, ptr, default_value, data, syntax, helptext */</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;db-info&quot;, CONFIG_RELOADABLE, &amp;globals.db_info, &quot;dbname=cdr&quot;, NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;db-table&quot;, CONFIG_RELOADABLE, &amp;globals.db_table, &quot;cdr&quot;, NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_STRING_STRDUP(&quot;default-template&quot;, CONFIG_RELOADABLE, &amp;globals.default_template, &quot;default&quot;, NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM(&quot;legs&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.legs, (void *) CDR_LEG_A, &amp;config_opt_cdr_leg_enum, &quot;a|b|ab&quot;, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM(&quot;spool-format&quot;, SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &amp;globals.spool_format, (void *) SPOOL_FORMAT_CSV, &amp;config_opt_spool_format_enum, &quot;csv|sql&quot;, &quot;Disk spool format to use if SQL insert fails.&quot;),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM(&quot;rotate-on-hup&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &amp;globals.rotate, SWITCH_FALSE, NULL, NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM(&quot;debug&quot;, SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &amp;globals.debug, SWITCH_FALSE, NULL, NULL, NULL),</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* key, type, flags, ptr, defaultvalue, function, functiondata, syntax, helptext */</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_CALLBACK(&quot;spool-dir&quot;, SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &amp;globals.spool_dir, NULL, config_validate_spool_dir, NULL, NULL, NULL),</span>
<span style="color: #00A000">+        SWITCH_CONFIG_ITEM_END()</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
 
 static off_t fd_size(int fd)
 {
<span style="color: #800080; font-weight: bold">@@ -363,12 +408,12 @@ static switch_status_t insert_cdr(const char * const template, const char * cons</span>
         switch_mutex_unlock(globals.db_mutex);
 
         /* SQL INSERT failed for whatever reason. Spool the attempted query to disk */
<span style="color: #A00000">-        if (!strcasecmp(globals.spool_format, &quot;sql&quot;)) {</span>
<span style="color: #A00000">-                path = switch_mprintf(&quot;%s%scdr-spool.sql&quot;, globals.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #00A000">+        if (globals.spool_format == SPOOL_FORMAT_SQL) {</span>
<span style="color: #00A000">+                path = switch_mprintf(&quot;%s%scdr-spool.sql&quot;, globals.spool_dir, SWITCH_PATH_SEPARATOR);</span>
                 assert(path);
                 spool_cdr(path, sql);
         } else {
<span style="color: #A00000">-                path = switch_mprintf(&quot;%s%scdr-spool.csv&quot;, globals.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #00A000">+                path = switch_mprintf(&quot;%s%scdr-spool.csv&quot;, globals.spool_dir, SWITCH_PATH_SEPARATOR);</span>
                 assert(path);
                 spool_cdr(path, cdr);
         }
<span style="color: #800080; font-weight: bold">@@ -402,8 +447,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)</span>
                 }
         }
 
<span style="color: #A00000">-        if (switch_dir_make_recursive(globals.log_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating %s\n&quot;, globals.log_dir);</span>
<span style="color: #00A000">+        if (switch_dir_make_recursive(globals.spool_dir, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating %s\n&quot;, globals.spool_dir);</span>
                 return SWITCH_STATUS_FALSE;
         }
 
<span style="color: #800080; font-weight: bold">@@ -485,7 +530,6 @@ static switch_state_handler_table_t state_handlers = {</span>
 };
 
 
<span style="color: #A00000">-</span>
 static switch_status_t load_config(switch_memory_pool_t *pool)
 {
         char *cf = &quot;cdr_pg_csv.conf&quot;;
<span style="color: #800080; font-weight: bold">@@ -509,40 +553,11 @@ static switch_status_t load_config(switch_memory_pool_t *pool)</span>
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Adding default template.\n&quot;);
         globals.legs = CDR_LEG_A;
 
<span style="color: #A00000">-        if ((xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if ((settings = switch_xml_child(cfg, &quot;settings&quot;))) {</span>
<span style="color: #A00000">-                        for (param = switch_xml_child(settings, &quot;param&quot;); param; param = param-&gt;next) {</span>
<span style="color: #A00000">-                                char *var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);</span>
<span style="color: #A00000">-                                char *val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);</span>
<span style="color: #A00000">-                                if (!strcasecmp(var, &quot;debug&quot;)) {</span>
<span style="color: #A00000">-                                        globals.debug = switch_true(val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, &quot;legs&quot;)) {</span>
<span style="color: #A00000">-                                        globals.legs = 0;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        if (strchr(val, &#39;a&#39;)) {</span>
<span style="color: #A00000">-                                                globals.legs |= CDR_LEG_A;</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        if (strchr(val, &#39;b&#39;)) {</span>
<span style="color: #A00000">-                                                globals.legs |= CDR_LEG_B;</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, &quot;log-base&quot;)) {</span>
<span style="color: #A00000">-                                        globals.log_dir = switch_core_sprintf(pool, &quot;%s%scdr-pg-csv&quot;, val, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, &quot;rotate-on-hup&quot;)) {</span>
<span style="color: #A00000">-                                        globals.rotate = switch_true(val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, &quot;db-info&quot;)) {</span>
<span style="color: #A00000">-                                        globals.db_info = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, &quot;db-table&quot;) || !strcasecmp(var, &quot;g-table&quot;)) {</span>
<span style="color: #A00000">-                                        globals.db_table = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, &quot;default-template&quot;)) {</span>
<span style="color: #A00000">-                                        globals.default_template = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                } else if (!strcasecmp(var, &quot;spool-format&quot;)) {</span>
<span style="color: #A00000">-                                        globals.spool_format = switch_core_strdup(pool, val);</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+        if (switch_xml_config_parse_module_settings(&quot;cdr_pg_csv.conf&quot;, SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                return SWITCH_STATUS_FALSE;</span>
<span style="color: #00A000">+        }</span>
 
<span style="color: #00A000">+        if ((xml = switch_xml_open_cfg(cf, &amp;cfg, NULL))) {</span>
                 if ((settings = switch_xml_child(cfg, &quot;templates&quot;))) {
                         for (param = switch_xml_child(settings, &quot;template&quot;); param; param = param-&gt;next) {
                                 char *var = (char *) switch_xml_attr(param, &quot;name&quot;);
<span style="color: #800080; font-weight: bold">@@ -558,26 +573,6 @@ static switch_status_t load_config(switch_memory_pool_t *pool)</span>
                 switch_xml_free(xml);
         }
 
<span style="color: #A00000">-        if (!globals.log_dir) {</span>
<span style="color: #A00000">-                globals.log_dir = switch_core_sprintf(pool, &quot;%s%scdr-pg-csv&quot;, SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.db_info)) {</span>
<span style="color: #A00000">-                globals.db_info = switch_core_strdup(pool, &quot;dbname=cdr&quot;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.db_table)) {</span>
<span style="color: #A00000">-                globals.db_table = switch_core_strdup(pool, &quot;cdr&quot;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.default_template)) {</span>
<span style="color: #A00000">-                globals.default_template = switch_core_strdup(pool, &quot;default&quot;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if (zstr(globals.spool_format)) {</span>
<span style="color: #A00000">-                globals.spool_format = switch_core_strdup(pool, &quot;csv&quot;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
         return status;
 }
 
<span style="color: #800080; font-weight: bold">@@ -588,8 +583,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_pg_csv_load)</span>
 
         load_config(pool);
 
<span style="color: #A00000">-        if ((status = switch_dir_make_recursive(globals.log_dir, SWITCH_DEFAULT_DIR_PERMS, pool)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #A00000">-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating %s\n&quot;, globals.log_dir);</span>
<span style="color: #00A000">+        if ((status = switch_dir_make_recursive(globals.spool_dir, SWITCH_DEFAULT_DIR_PERMS, pool)) != SWITCH_STATUS_SUCCESS) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;Error creating %s\n&quot;, globals.spool_dir);</span>
                 return status;
         }
 
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
freemtdm: ss7 - SPC no long in sng_gen...new configuration file

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #000080; font-weight: bold">index 01d1013..20bcc3a 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -99,6 +99,7 @@ int  ft_to_sngss7_cfg_all(void)</span>
                         return 1;
                 } else {
                         SS7_INFO(&quot;Started Stack Manager!\n&quot;);
<span style="color: #00A000">+                        sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_SM);</span>
                 }
 
                 /* check if the configuration had a Relay Channel */
<span style="color: #800080; font-weight: bold">@@ -575,12 +576,10 @@ int ftmod_ss7_mtp3_gen_config(void)</span>
 
 
         cfg.t.cfg.s.snGen.typeSP                = LSN_TYPE_SP;                /* type of signalling postatic int */
<span style="color: #A00000">-        cfg.t.cfg.s.snGen.spCode1                = g_ftdm_sngss7_data.cfg.spc;        /* our DPC for CCITT version */</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snGen.spCode1                = 0;                                /* our DPC for CCITT version */</span>
 #if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || SS7_CHINA || defined(TDS_ROLL_UPGRADE_SUPPORT))
<span style="color: #A00000">-        cfg.t.cfg.s.snGen.spCode2                = g_ftdm_sngss7_data.cfg.spc;        /* our DPC for ANSI or CHINA version */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snGen.spCode2                = 0;                                /* our DPC for ANSI or CHINA version */</span>
 #endif
<span style="color: #A00000">-</span>
         cfg.t.cfg.s.snGen.ssfValid                = TRUE;                                /* ssf validation required */
         cfg.t.cfg.s.snGen.nmbDLSap                = MAX_SN_LINKS;                /* number of MTP Data Link SAPs */
         cfg.t.cfg.s.snGen.nmbNSap                = MAX_SN_ROUTES;        /* number of Upper Layer Saps */
<span style="color: #000080; font-weight: bold">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</span>
<span style="color: #000080; font-weight: bold">index ad52827..2f2e502 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #800080; font-weight: bold">@@ -1598,7 +1598,9 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)</span>
                 sngss7_clear_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_RY);
         }
 
<span style="color: #A00000">-        sng_isup_free_sm();</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_SM)) {</span>
<span style="color: #00A000">+                sng_isup_free_sm();</span>
<span style="color: #00A000">+        }</span>
 
         sng_isup_free_gen();
 
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #000080; font-weight: bold">index dc6428d..46df990 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #800080; font-weight: bold">@@ -464,11 +464,6 @@ static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen)</span>
                         SS7_DEBUG(&quot;Found license file = %s\n&quot;, g_ftdm_sngss7_data.cfg.license);
                         SS7_DEBUG(&quot;Found signature file = %s\n&quot;, g_ftdm_sngss7_data.cfg.signature);        
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;spc&quot;)) {</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.spc = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;Found SPC = %d\n&quot;, g_ftdm_sngss7_data.cfg.spc);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
                 } else {
                 /**********************************************************************/
                         SS7_ERROR(&quot;Found an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
freetdm: ss7 - only unload layers when they are loaded freetdm: ss7 - configuration updated to allow a route to use multiple linksets...new configuration file

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #000080; font-weight: bold">index 15fc1ef..01d1013 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -74,6 +74,7 @@ int ftmod_ss7_relay_chan_config(int id);</span>
 int  ft_to_sngss7_cfg_all(void)
 {
         int x = 0;
<span style="color: #00A000">+        int ret = 0;</span>
 
         /* check if we have done gen_config already */
         if (!(g_ftdm_sngss7_data.gen_config)) {
<span style="color: #800080; font-weight: bold">@@ -289,15 +290,17 @@ int  ft_to_sngss7_cfg_all(void)</span>
                 /* check if this link has been configured already */
                 if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags &amp; SNGSS7_CONFIGURED)) {
 
<span style="color: #A00000">-                        if (ftmod_ss7_mtp3_nsap_config(x)) {</span>
<span style="color: #A00000">-                                SS7_CRITICAL(&quot;MTP3 NSAP %d configuration FAILED!\n&quot;, x);</span>
<span style="color: #00A000">+                        ret = ftmod_ss7_mtp3_nsap_config(x);</span>
<span style="color: #00A000">+                        if (ret) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;MTP3 NSAP %d configuration FAILED!(%s)\n&quot;, x, DECODE_LCM_REASON(ret));</span>
                                 return 1;
                         } else {
                                 SS7_INFO(&quot;MTP3 NSAP %d configuration DONE!\n&quot;, x);
                         }
 
<span style="color: #A00000">-                        if (ftmod_ss7_isup_nsap_config(x)) {</span>
<span style="color: #A00000">-                                SS7_CRITICAL(&quot;ISUP NSAP %d configuration FAILED!\n&quot;, x);</span>
<span style="color: #00A000">+                        ret = ftmod_ss7_isup_nsap_config(x);</span>
<span style="color: #00A000">+                        if (ret) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;ISUP NSAP %d configuration FAILED!(%s)\n&quot;, x, DECODE_LCM_REASON(ret));</span>
                                 return 1;
                         } else {
                                 SS7_INFO(&quot;ISUP NSAP %d configuration DONE!\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -580,7 +583,7 @@ int ftmod_ss7_mtp3_gen_config(void)</span>
 
         cfg.t.cfg.s.snGen.ssfValid                = TRUE;                                /* ssf validation required */
         cfg.t.cfg.s.snGen.nmbDLSap                = MAX_SN_LINKS;                /* number of MTP Data Link SAPs */
<span style="color: #A00000">-        cfg.t.cfg.s.snGen.nmbNSap                = MAX_SN_VARIANTS;        /* number of Upper Layer Saps */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snGen.nmbNSap                = MAX_SN_ROUTES;        /* number of Upper Layer Saps */</span>
         cfg.t.cfg.s.snGen.nmbRouts                = MAX_SN_ROUTES;        /* maximum number of routing entries */
         cfg.t.cfg.s.snGen.nmbLnkSets        = MAX_SN_LINKSETS;        /* number of link sets */
         cfg.t.cfg.s.snGen.nmbRteInst        = MAX_SN_ROUTES*16;        /* number of simultaneous Rte instances */
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c</span>
<span style="color: #000080; font-weight: bold">index 4ab4359..0298429 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c</span>
<span style="color: #800080; font-weight: bold">@@ -1131,45 +1131,56 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,</span>
                                         ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
                                         ftdmchan = ss7_info-&gt;ftdmchan;
 
<span style="color: #A00000">-                                        /* grab the signaling_status */</span>
<span style="color: #A00000">-                                        ftdm_channel_get_sig_status(ftdmchan, &amp;sigstatus);</span>
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                                        stream-&gt;write_function(stream, &quot;span=%2d|chan=%2d|cic=%4d|sig_status=%4s|state=%s|&quot;,</span>
<span style="color: #A00000">-                                                                                                        ckt-&gt;span,</span>
<span style="color: #A00000">-                                                                                                        ckt-&gt;chan,</span>
<span style="color: #A00000">-                                                                                                        ckt-&gt;cic,</span>
<span style="color: #A00000">-                                                                                                        ftdm_signaling_status2str(sigstatus),</span>
<span style="color: #A00000">-                                                                                                        ftdm_channel_state2str(ftdmchan-&gt;state));</span>
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                                        if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_mn=Y|&quot;);</span>
<span style="color: #A00000">-                                        }else {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_mn=N|&quot;);</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                                        if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;r_mn=Y|&quot;);</span>
<span style="color: #A00000">-                                        }else {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;r_mn=N|&quot;);</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                                        if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_hw=Y|&quot;);</span>
<span style="color: #A00000">-                                        }else {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_hw=N|&quot;);</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #00A000">+                                        if (ftdmchan == NULL) {</span>
<span style="color: #00A000">+                                                /* this should never happen!!! */</span>
<span style="color: #00A000">+                                                stream-&gt;write_function(stream, &quot;span=%2d|chan=%2d|cic=%4d|FTDMCHAN DOES NOT EXISTS&quot;,</span>
<span style="color: #00A000">+                                                                                                                ckt-&gt;span,</span>
<span style="color: #00A000">+                                                                                                                ckt-&gt;chan,</span>
<span style="color: #00A000">+                                                                                                                ckt-&gt;cic);</span>
<span style="color: #00A000">+                                                </span>
<span style="color: #00A000">+                                        } else {</span>
<span style="color: #00A000">+                                                /* grab the signaling_status */</span>
<span style="color: #00A000">+                                                ftdm_channel_get_sig_status(ftdmchan, &amp;sigstatus);</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                                                stream-&gt;write_function(stream, &quot;span=%2d|chan=%2d|cic=%4d|sig_status=%4s|state=%s|&quot;,</span>
<span style="color: #00A000">+                                                                                                                ckt-&gt;span,</span>
<span style="color: #00A000">+                                                                                                                ckt-&gt;chan,</span>
<span style="color: #00A000">+                                                                                                                ckt-&gt;cic,</span>
<span style="color: #00A000">+                                                                                                                ftdm_signaling_status2str(sigstatus),</span>
<span style="color: #00A000">+                                                                                                                ftdm_channel_state2str(ftdmchan-&gt;state));</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                                                if ((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || </span>
<span style="color: #00A000">+                                                        (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;l_mn=Y|&quot;);</span>
<span style="color: #00A000">+                                                }else {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;l_mn=N|&quot;);</span>
<span style="color: #00A000">+                                                }</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                                                if ((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || </span>
<span style="color: #00A000">+                                                        (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;r_mn=Y|&quot;);</span>
<span style="color: #00A000">+                                                }else {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;r_mn=N|&quot;);</span>
<span style="color: #00A000">+                                                }</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                                                if (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;l_hw=Y|&quot;);</span>
<span style="color: #00A000">+                                                }else {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;l_hw=N|&quot;);</span>
<span style="color: #00A000">+                                                }</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                                                if (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;r_hw=Y|&quot;);</span>
<span style="color: #00A000">+                                                }else {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;r_hw=N|&quot;);</span>
<span style="color: #00A000">+                                                }</span>
         
<span style="color: #A00000">-                                        if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;r_hw=Y|&quot;);</span>
<span style="color: #A00000">-                                        }else {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;r_hw=N|&quot;);</span>
<span style="color: #00A000">+                                                if (sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;relay=Y|&quot;);</span>
<span style="color: #00A000">+                                                }else {</span>
<span style="color: #00A000">+                                                        stream-&gt;write_function(stream, &quot;relay=N|&quot;);</span>
<span style="color: #00A000">+                                                }</span>
                                         }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        if(sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;relay=Y|&quot;);</span>
<span style="color: #A00000">-                                        }else {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;relay=N|&quot;);</span>
<span style="color: #A00000">-                                        }                </span>
         
                                         stream-&gt;write_function(stream, &quot;flags=0x%X&quot;,ss7_info-&gt;ckt_flags);
         
<span style="color: #000080; font-weight: bold">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</span>
<span style="color: #000080; font-weight: bold">index adee000..ad52827 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #800080; font-weight: bold">@@ -1570,26 +1570,33 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)</span>
 
         if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {
                 sng_isup_free_cc();
<span style="color: #00A000">+                sngss7_clear_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_CC);</span>
         }
 
         if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {
                 ftmod_ss7_shutdown_isup();
                 sng_isup_free_isup();
<span style="color: #00A000">+                sngss7_clear_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP);</span>
         }
 
         if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) {
                 ftmod_ss7_shutdown_mtp3();
                 sng_isup_free_mtp3();
<span style="color: #00A000">+                sngss7_clear_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP3);</span>
         }
 
         if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) {
                 ftmod_ss7_shutdown_mtp2();
                 sng_isup_free_mtp2();
                 sng_isup_free_mtp1();
<span style="color: #00A000">+                sngss7_clear_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP2);</span>
         }
 
<span style="color: #A00000">-        ftmod_ss7_shutdown_relay();</span>
<span style="color: #A00000">-        sng_isup_free_relay();</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_RY)) {</span>
<span style="color: #00A000">+                ftmod_ss7_shutdown_relay();</span>
<span style="color: #00A000">+                sng_isup_free_relay();</span>
<span style="color: #00A000">+                sngss7_clear_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_RY);</span>
<span style="color: #00A000">+        }</span>
 
         sng_isup_free_sm();
 
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #000080; font-weight: bold">index 5272aa8..fe291fb 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #800080; font-weight: bold">@@ -219,13 +219,18 @@ typedef struct sng_link_set {</span>
         uint32_t                links[16];
 } sng_link_set_t;
 
<span style="color: #00A000">+typedef struct sng_link_set_list {</span>
<span style="color: #00A000">+        uint32_t                                        lsId;</span>
<span style="color: #00A000">+        struct sng_link_set_list        *next;</span>
<span style="color: #00A000">+} sng_link_set_list_t;</span>
<span style="color: #00A000">+</span>
 typedef struct sng_route {
         char                        name[MAX_NAME_LEN];
         uint32_t                flags;
         uint32_t                id;
         uint32_t                dpc;
         uint32_t                cmbLinkSetId;
<span style="color: #A00000">-        uint32_t                linkSetId;</span>
<span style="color: #00A000">+        struct sng_link_set_list        lnkSets;</span>
         uint32_t                linkType;
         uint32_t                switchType;
         uint32_t                ssf;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #000080; font-weight: bold">index d2fa973..dc6428d 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #800080; font-weight: bold">@@ -1268,9 +1268,9 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)</span>
         ftdm_conf_parameter_t        *parm = mtp_route-&gt;parameters;
         int                                                 num_parms = mtp_route-&gt;n_parameters;
         int                                                 i;
<span style="color: #00A000">+        sng_link_set_list_t                *lnkSet;</span>
 
         ftdm_conf_node_t                *linkset;
<span style="color: #A00000">-        int                                                ls_id;</span>
         int                                                numLinks;
 
         /* initalize the mtpRoute structure */
<span style="color: #800080; font-weight: bold">@@ -1383,42 +1383,50 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)</span>
         }
 
         /* fill in the rest of the values in the mtpRoute struct  */
<span style="color: #A00000">-        mtpRoute.nwId = mtpRoute.id;</span>
<span style="color: #00A000">+        mtpRoute.nwId = 0;</span>
         mtpRoute.cmbLinkSetId = mtpRoute.id;
 
         /* parse in the list of linksets this route is reachable by */
         linkset = mtp_route-&gt;child-&gt;child;
 
<span style="color: #00A000">+        /* initalize the link-list of linkSet Ids */</span>
<span style="color: #00A000">+        lnkSet = &amp;mtpRoute.lnkSets;</span>
<span style="color: #00A000">+</span>
         while (linkset != NULL) {
         /**************************************************************************/
                 /* extract the linkset Id */
<span style="color: #A00000">-                ls_id = atoi(linkset-&gt;parameters-&gt;val);</span>
<span style="color: #00A000">+                lnkSet-&gt;lsId = atoi(linkset-&gt;parameters-&gt;val);</span>
 
<span style="color: #A00000">-                if (g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].id != 0) {</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;Found mtpRoute linkset id = %d that is valid\n&quot;,ls_id);</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].id != 0) {</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found mtpRoute linkset id = %d that is valid\n&quot;,lnkSet-&gt;lsId);</span>
                 } else {
<span style="color: #A00000">-                        SS7_ERROR(&quot;Found mtpRoute linkset id = %d that is invalid\n&quot;,ls_id);</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found mtpRoute linkset id = %d that is invalid\n&quot;,lnkSet-&gt;lsId);</span>
                         goto move_along;
                 }
 
                 /* pull up the linktype, switchtype, and SSF from the linkset */
<span style="color: #A00000">-                mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].linkType;</span>
<span style="color: #A00000">-                mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].switchType;</span>
<span style="color: #A00000">-                mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].ssf;</span>
<span style="color: #00A000">+                mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].linkType;</span>
<span style="color: #00A000">+                mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].switchType;</span>
<span style="color: #00A000">+                mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].ssf;</span>
                 
                 /* extract the number of cmbLinkSetId aleady on this linkset */
<span style="color: #A00000">-                numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks;</span>
<span style="color: #00A000">+                numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].numLinks;</span>
                 
                 /* add this routes cmbLinkSetId to the list */
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].links[numLinks] = mtpRoute.cmbLinkSetId;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].links[numLinks] = mtpRoute.cmbLinkSetId;</span>
 
                 /* increment the number of cmbLinkSets on this linkset */
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks++;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].numLinks++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* update the linked list */</span>
<span style="color: #00A000">+                lnkSet-&gt;next = ftdm_malloc(sizeof(sng_link_set_list_t));</span>
<span style="color: #00A000">+                lnkSet = lnkSet-&gt;next;</span>
<span style="color: #00A000">+                lnkSet-&gt;lsId = 0;</span>
<span style="color: #00A000">+                lnkSet-&gt;next = NULL;</span>
 
 move_along:
                 /* move to the next linkset element */
                 linkset = linkset-&gt;next;
<span style="color: #A00000">-</span>
         /**************************************************************************/
         } /* while (linkset != null) */
 
<span style="color: #800080; font-weight: bold">@@ -1465,6 +1473,7 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)</span>
 {
         sng_isup_inf_t                        sng_isup;
         sng_isap_t                                sng_isap;
<span style="color: #00A000">+        sng_link_set_list_t                *lnkSet;</span>
         ftdm_conf_parameter_t        *parm = isup_interface-&gt;parameters;
         int                                                num_parms = isup_interface-&gt;n_parameters;
         int                                                i;
<span style="color: #800080; font-weight: bold">@@ -1500,7 +1509,6 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)</span>
                 } else if (!strcasecmp(parm-&gt;var, &quot;spc&quot;)) {
                 /**********************************************************************/
                         sng_isup.spc = atoi(parm-&gt;val);
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.spc = sng_isup.spc;</span>
                         SS7_DEBUG(&quot;Found an isup SPC = %d\n&quot;, sng_isup.spc);
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtprouteId&quot;)) {
<span style="color: #800080; font-weight: bold">@@ -1747,17 +1755,14 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)</span>
         sngss7_set_flag(&amp;sng_isup, SNGSS7_PAUSED);
 
         /* trickle down the SPC to all sub entities */
<span style="color: #A00000">-        int        linkSetId;</span>
<span style="color: #00A000">+        lnkSet = &amp;g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].lnkSets;</span>
 
<span style="color: #A00000">-        linkSetId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].linkSetId;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[lnkSet-&gt;lsId].spc = sng_isup.spc;</span>
<span style="color: #00A000">+        lnkSet = lnkSet-&gt;next;</span>
 
<span style="color: #A00000">-        i = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {</span>
<span style="color: #A00000">-                if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == linkSetId) {</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.mtp3Link[i].spc = g_ftdm_sngss7_data.cfg.spc;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                i++;</span>
<span style="color: #00A000">+        while (lnkSet-&gt;next != NULL) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[lnkSet-&gt;lsId].spc = sng_isup.spc;</span>
<span style="color: #00A000">+                lnkSet = lnkSet-&gt;next;</span>
         }
 
         /* pull values from the lower levels */
<span style="color: #800080; font-weight: bold">@@ -2342,7 +2347,10 @@ static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)</span>
 /******************************************************************************/
 static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
 {
<span style="color: #A00000">-        int i = mtp3_route-&gt;id;</span>
<span style="color: #00A000">+        sng_link_set_list_t        *lnkSet = NULL;</span>
<span style="color: #00A000">+        int                                 i = mtp3_route-&gt;id;</span>
<span style="color: #00A000">+        int                                        tmp = 0;</span>
<span style="color: #00A000">+</span>
 
         /* check if this id value has been used already */
         if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
<span style="color: #800080; font-weight: bold">@@ -2355,10 +2363,19 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)</span>
         }
 
         /* fill in the cmbLinkSet in the linkset structure */
<span style="color: #A00000">-        int tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route-&gt;linkSetId].numLinks;</span>
<span style="color: #00A000">+        lnkSet = &amp;mtp3_route-&gt;lnkSets;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].numLinks;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].links[tmp] = mtp3_route-&gt;cmbLinkSetId;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].numLinks++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (lnkSet-&gt;next != NULL) {</span>
<span style="color: #00A000">+                tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].numLinks;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].links[tmp] = mtp3_route-&gt;cmbLinkSetId;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[lnkSet-&gt;lsId].numLinks++;</span>
 
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route-&gt;linkSetId].links[tmp] = mtp3_route-&gt;cmbLinkSetId;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route-&gt;linkSetId].numLinks++;</span>
<span style="color: #00A000">+                lnkSet = lnkSet-&gt;next;</span>
<span style="color: #00A000">+        }</span>
 
         strcpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, (char *)mtp3_route-&gt;name);
 
<span style="color: #800080; font-weight: bold">@@ -2369,7 +2386,7 @@ static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)</span>
         g_ftdm_sngss7_data.cfg.mtpRoute[i].cmbLinkSetId        = mtp3_route-&gt;cmbLinkSetId;
         g_ftdm_sngss7_data.cfg.mtpRoute[i].isSTP                = mtp3_route-&gt;isSTP;
         g_ftdm_sngss7_data.cfg.mtpRoute[i].nwId                        = mtp3_route-&gt;nwId;
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpRoute[i].linkSetId        = mtp3_route-&gt;linkSetId;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpRoute[i].lnkSets                = mtp3_route-&gt;lnkSets;</span>
         g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf                        = mtp3_route-&gt;ssf;
         if (mtp3_route-&gt;t6 != 0) {
                 g_ftdm_sngss7_data.cfg.mtpRoute[i].t6                = mtp3_route-&gt;t6;
<span style="color: #800080; font-weight: bold">@@ -2439,8 +2456,7 @@ static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)</span>
         i = 1;
         while (g_ftdm_sngss7_data.cfg.nsap[i].id != 0) {
                 if ((g_ftdm_sngss7_data.cfg.nsap[i].linkType == mtp3_route-&gt;linkType) &amp;&amp;
<span style="color: #A00000">-                        (g_ftdm_sngss7_data.cfg.nsap[i].switchType == mtp3_route-&gt;switchType) &amp;&amp;</span>
<span style="color: #A00000">-                        (g_ftdm_sngss7_data.cfg.nsap[i].ssf == mtp3_route-&gt;ssf)) {</span>
<span style="color: #00A000">+                        (g_ftdm_sngss7_data.cfg.nsap[i].switchType == mtp3_route-&gt;switchType)) {</span>
 
                         /* we have a match so break out of this loop */
                         break;
<span style="color: #800080; font-weight: bold">@@ -2789,6 +2805,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)</span>
         sngss7_chan_data_t        *ss7_info = NULL;
         int                                        x;
         int                                        count = 1;
<span style="color: #00A000">+        int                                        flag;</span>
 
         while (ccSpan-&gt;ch_map[0] != &#39;\0&#39;) {
         /**************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -2799,13 +2816,45 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)</span>
                         return FTDM_FAIL;
                 }
 
<span style="color: #A00000">-                /* find the spot in master array for this circuit */</span>
<span style="color: #A00000">-                x = (ccSpan-&gt;procId * 1000) + count;</span>
<span style="color: #00A000">+                /* find a spot for this circuit in the global structure */</span>
<span style="color: #00A000">+                x = (ccSpan-&gt;procId * 1000);</span>
<span style="color: #00A000">+                flag = 0;</span>
<span style="color: #00A000">+                while (flag == 0) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        /* check the id value ( 0 = new, 0 &gt; circuit can be existing) */</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) {</span>
<span style="color: #00A000">+                                /* we&#39;re at the end of the list of circuitsl aka this is new */</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a new circuit %d, ccSpanId=%d, chan=%d\n&quot;,</span>
<span style="color: #00A000">+                                                        x, </span>
<span style="color: #00A000">+                                                        ccSpan-&gt;id, </span>
<span style="color: #00A000">+                                                        count);</span>
 
<span style="color: #A00000">-                /* check if this circuit has already been filled in */</span>
<span style="color: #A00000">-                if (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #A00000">-                        SS7_DEVEL_DEBUG(&quot;Filling in circuit that already exists...%d\n&quot;, x);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                                /* throw the flag to end the loop */</span>
<span style="color: #00A000">+                                flag = 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                /* check the ccspan.id and chan to see if the circuit already exists */</span>
<span style="color: #00A000">+                                if ((g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId == ccSpan-&gt;id) &amp;&amp;</span>
<span style="color: #00A000">+                                        (g_ftdm_sngss7_data.cfg.isupCkt[x].chan == count)) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* we are processing a circuit that already exists */</span>
<span style="color: #00A000">+                                        SS7_DEBUG(&quot;Found an existing circuit %d, ccSpanId=%d, chan%d\n&quot;,</span>
<span style="color: #00A000">+                                                                x, </span>
<span style="color: #00A000">+                                                                ccSpan-&gt;id, </span>
<span style="color: #00A000">+                                                                count);</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                                        /* throw the flag to end the loop */</span>
<span style="color: #00A000">+                                        flag = 1;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        /* not supporting reconfig at this time */</span>
<span style="color: #00A000">+                                        SS7_DEBUG(&quot;Not supporting ckt reconfig at this time!\n&quot;);</span>
<span style="color: #00A000">+                                        goto move_along;</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        /* this is not the droid you are looking for */</span>
<span style="color: #00A000">+                                        x++;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } /* while (flag == 0) */</span>
 
                 /* prepare the global info sturcture */
                 ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));
<span style="color: #800080; font-weight: bold">@@ -2901,6 +2950,7 @@ static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)</span>
                                         g_ftdm_sngss7_data.cfg.isupCkt[x].cic,
                                         g_ftdm_sngss7_data.cfg.isupCkt[x].id);
 
<span style="color: #00A000">+move_along:</span>
                 /* increment the span channel count */
                 count++;
 
</pre></div>
<div class="highlight"><pre>committer: cypromis
comments: 
more formatting mistakes *sigh*

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index 1684127..f829e57 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -1277,9 +1277,9 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 
         myid = resolve_id(id_in, domain_name, &quot;message-count&quot;);
 
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql), &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch=0 group by read_flags union </span>
<span style="color: #A00000">-        select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;,        myid, domain_name, myfolder);</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        switch_snprintf(sql, sizeof(sql), &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; &quot;</span>
<span style="color: #00A000">+                                                                          &quot;and read_epoch=0 group by read_flags union select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; &quot;</span>
<span style="color: #00A000">+                                                                          &quot;and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;, myid, domain_name, myfolder);</span>
         vm_execute_sql_callback(profile, profile-&gt;mutex, sql, message_count_callback, &amp;cbt);
 
         *total_new_messages = cbt.total_new_messages + cbt.total_new_urgent_messages;
</pre></div>
<div class="highlight"><pre>committer: cypromis
comments: 
seems whitespaces are unpopular on some linux/gcc combinations

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index f868c3a..1684127 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -1277,11 +1277,8 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
 
         myid = resolve_id(id_in, domain_name, &quot;message-count&quot;);
 
<span style="color: #A00000">-        switch_snprintf(sql, sizeof(sql),</span>
<span style="color: #A00000">-                                        &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch=0 group by read_flags </span>
<span style="color: #A00000">-                                        union </span>
<span style="color: #A00000">-                                        select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;,        </span>
<span style="color: #A00000">-                                        myid, domain_name, myfolder);</span>
<span style="color: #00A000">+        switch_snprintf(sql, sizeof(sql), &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch=0 group by read_flags union </span>
<span style="color: #00A000">+        select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;,        myid, domain_name, myfolder);</span>
 
         vm_execute_sql_callback(profile, profile-&gt;mutex, sql, message_count_callback, &amp;cbt);
 
</pre></div>
<div class="highlight"><pre>committer: cypromis
comments: 
FS-1742 - Make Voicemail use 1 SQL query instead of 4 to get the message count use in MWI - Now also working on your more favourite and less favourite databases

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #000080; font-weight: bold">index 80b011e..f868c3a 100644</span>
<span style="color: #A00000">--- a/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #00A000">+++ b/src/mod/applications/mod_voicemail/mod_voicemail.c</span>
<span style="color: #800080; font-weight: bold">@@ -1278,7 +1278,9 @@ static void message_count(vm_profile_t *profile, const char *id_in, const char *</span>
         myid = resolve_id(id_in, domain_name, &quot;message-count&quot;);
 
         switch_snprintf(sql, sizeof(sql),
<span style="color: #A00000">-                                        &quot;select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; group by read_epoch=0,read_flags;&quot;,</span>
<span style="color: #00A000">+                                        &quot;select 1, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch=0 group by read_flags </span>
<span style="color: #00A000">+                                        union </span>
<span style="color: #00A000">+                                        select 0, read_flags, count(read_epoch) from voicemail_msgs where username=&#39;%s&#39; and domain=&#39;%s&#39; and in_folder=&#39;%s&#39; and read_epoch&lt;&gt;0 group by read_flags;&quot;,        </span>
                                         myid, domain_name, myfolder);
 
         vm_execute_sql_callback(profile, profile-&gt;mutex, sql, message_count_callback, &amp;cbt);
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
reswig mod_lua for freeswitch.email

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp</span>
<span style="color: #000080; font-weight: bold">index 1d84a39..559d403 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp</span>
<span style="color: #800080; font-weight: bold">@@ -1582,6 +1582,55 @@ fail:</span>
 }
 
 
<span style="color: #00A000">+static int _wrap_email(lua_State* L) {</span>
<span style="color: #00A000">+  int SWIG_arg = -1;</span>
<span style="color: #00A000">+  char *arg1 = (char *) 0 ;</span>
<span style="color: #00A000">+  char *arg2 = (char *) 0 ;</span>
<span style="color: #00A000">+  char *arg3 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg4 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg5 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg6 = (char *) NULL ;</span>
<span style="color: #00A000">+  char *arg7 = (char *) NULL ;</span>
<span style="color: #00A000">+  bool result;</span>
<span style="color: #00A000">+  </span>
<span style="color: #00A000">+  SWIG_check_num_args(&quot;email&quot;,2,7)</span>
<span style="color: #00A000">+  if(!lua_isstring(L,1)) SWIG_fail_arg(&quot;email&quot;,1,&quot;char *&quot;);</span>
<span style="color: #00A000">+  if(!lua_isstring(L,2)) SWIG_fail_arg(&quot;email&quot;,2,&quot;char *&quot;);</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=3 &amp;&amp; !lua_isstring(L,3)) SWIG_fail_arg(&quot;email&quot;,3,&quot;char *&quot;);</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=4 &amp;&amp; !lua_isstring(L,4)) SWIG_fail_arg(&quot;email&quot;,4,&quot;char *&quot;);</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=5 &amp;&amp; !lua_isstring(L,5)) SWIG_fail_arg(&quot;email&quot;,5,&quot;char *&quot;);</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=6 &amp;&amp; !lua_isstring(L,6)) SWIG_fail_arg(&quot;email&quot;,6,&quot;char *&quot;);</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=7 &amp;&amp; !lua_isstring(L,7)) SWIG_fail_arg(&quot;email&quot;,7,&quot;char *&quot;);</span>
<span style="color: #00A000">+  arg1 = (char *)lua_tostring(L, 1);</span>
<span style="color: #00A000">+  arg2 = (char *)lua_tostring(L, 2);</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=3){</span>
<span style="color: #00A000">+    arg3 = (char *)lua_tostring(L, 3);</span>
<span style="color: #00A000">+  }</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=4){</span>
<span style="color: #00A000">+    arg4 = (char *)lua_tostring(L, 4);</span>
<span style="color: #00A000">+  }</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=5){</span>
<span style="color: #00A000">+    arg5 = (char *)lua_tostring(L, 5);</span>
<span style="color: #00A000">+  }</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=6){</span>
<span style="color: #00A000">+    arg6 = (char *)lua_tostring(L, 6);</span>
<span style="color: #00A000">+  }</span>
<span style="color: #00A000">+  if(lua_gettop(L)&gt;=7){</span>
<span style="color: #00A000">+    arg7 = (char *)lua_tostring(L, 7);</span>
<span style="color: #00A000">+  }</span>
<span style="color: #00A000">+  result = (bool)email(arg1,arg2,arg3,arg4,arg5,arg6,arg7);</span>
<span style="color: #00A000">+  SWIG_arg=0;</span>
<span style="color: #00A000">+  lua_pushboolean(L,(int)(result==true)); SWIG_arg++;</span>
<span style="color: #00A000">+  return SWIG_arg;</span>
<span style="color: #00A000">+  </span>
<span style="color: #00A000">+  if(0) SWIG_fail;</span>
<span style="color: #00A000">+  </span>
<span style="color: #00A000">+fail:</span>
<span style="color: #00A000">+  lua_error(L);</span>
<span style="color: #00A000">+  return SWIG_arg;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
 static int _wrap_new_IVRMenu(lua_State* L) {
   int SWIG_arg = -1;
   IVRMenu *arg1 = (IVRMenu *) 0 ;
<span style="color: #800080; font-weight: bold">@@ -7525,6 +7574,7 @@ static swig_lua_class _wrap_class_LUA_Dbh = { &quot;Dbh&quot;, &amp;SWIGTYPE_p_LUA__Dbh,_wrap_</span>
 static const struct luaL_reg swig_commands[] = {
     { &quot;consoleLog&quot;, _wrap_consoleLog},
     { &quot;consoleCleanLog&quot;, _wrap_consoleCleanLog},
<span style="color: #00A000">+    { &quot;email&quot;, _wrap_email},</span>
     { &quot;console_log&quot;, _wrap_console_log},
     { &quot;console_clean_log&quot;, _wrap_console_clean_log},
     { &quot;msleep&quot;, _wrap_msleep},
</pre></div>
<div class="highlight"><pre>committer: Mathieu Rene
comments: 
Add libjpeg-dev to apt prereqs

<span style="color: #000080; font-weight: bold">diff --git a/support-d/prereq.sh b/support-d/prereq.sh</span>
<span style="color: #000080; font-weight: bold">index 4e214cf..8bc454d 100755</span>
<span style="color: #A00000">--- a/support-d/prereq.sh</span>
<span style="color: #00A000">+++ b/support-d/prereq.sh</span>
<span style="color: #800080; font-weight: bold">@@ -2,7 +2,7 @@ UNAME=`uname`</span>
 
 
 NEEDED_PACKAGES_YUM=&#39;automake autoconf libtool screen gdb gcc-c++ compat-gcc-32 compat-gcc-32-c++ subversion ncurses-devel unixODBC-devel make wget&#39;
<span style="color: #A00000">-NEEDED_PACAKGES_APT=&#39;automake autoconf libtool screen gdb libncurses5-dev unixodbc-dev subversion emacs22-nox gcc g++ make&#39;</span>
<span style="color: #00A000">+NEEDED_PACAKGES_APT=&#39;automake autoconf libtool screen gdb libncurses5-dev unixodbc-dev subversion emacs22-nox gcc g++ make libjpeg-dev&#39;</span>
 NEEDED_PACKAGES_PKG_ADD=&#39;&#39;
 
 
</pre></div>
<div class="highlight"><pre>committer: Mathieu Rene
comments: 
Add session.ringReady() to check for CF_RING_READY

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</span>
<span style="color: #000080; font-weight: bold">index 1d6ee8d..a818c1d 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</span>
<span style="color: #800080; font-weight: bold">@@ -2126,6 +2126,15 @@ static JSBool session_media_ready(JSContext * cx, JSObject * obj, uintN argc, js</span>
 }
 
 
<span style="color: #00A000">+static JSBool session_ring_ready(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        struct js_session *jss = JS_GetPrivate(cx, obj);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        *rval = BOOLEAN_TO_JSVAL((jss &amp;&amp; jss-&gt;session &amp;&amp; switch_channel_test_flag(switch_core_session_get_channel(jss-&gt;session), CF_RING_READY)) ? JS_TRUE : JS_FALSE);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return JS_TRUE;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
 static JSBool session_answered(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
 {
         struct js_session *jss = JS_GetPrivate(cx, obj);
<span style="color: #800080; font-weight: bold">@@ -2673,6 +2682,7 @@ static JSFunctionSpec session_methods[] = {</span>
         {&quot;ready&quot;, session_ready, 0},
         {&quot;answered&quot;, session_answered, 0},
         {&quot;mediaReady&quot;, session_media_ready, 0},
<span style="color: #00A000">+        {&quot;ringReady&quot;, session_ring_ready, 0},</span>
         {&quot;waitForAnswer&quot;, session_wait_for_answer, 0},
         {&quot;waitForMedia&quot;, session_wait_for_media, 0},
         {&quot;getEvent&quot;, session_get_event, 0},
</pre></div>
<div class="highlight"><pre>committer: Mathieu Rene
comments: 
xml_config: change min/max enforcements to &gt;= instead of &gt;

<span style="color: #000080; font-weight: bold">diff --git a/src/switch_xml_config.c b/src/switch_xml_config.c</span>
<span style="color: #000080; font-weight: bold">index b6b37bd..5ade057 100644</span>
<span style="color: #A00000">--- a/src/switch_xml_config.c</span>
<span style="color: #00A000">+++ b/src/switch_xml_config.c</span>
<span style="color: #800080; font-weight: bold">@@ -177,7 +177,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_event(switch_event_t *ev</span>
 
                                         if (int_options) {
                                                 /* Enforce validation options */
<span style="color: #A00000">-                                                if ((int_options-&gt;enforce_min &amp;&amp; !(intval &gt; int_options-&gt;min)) || (int_options-&gt;enforce_max &amp;&amp; !(intval &lt; int_options-&gt;max))) {</span>
<span style="color: #00A000">+                                                if ((int_options-&gt;enforce_min &amp;&amp; !(intval &gt;= int_options-&gt;min)) || (int_options-&gt;enforce_max &amp;&amp; !(intval &lt;= int_options-&gt;max))) {</span>
                                                         /* Validation failed, set default */
                                                         intval = (int) (intptr_t) item-&gt;defaultvalue;
                                                         /* Then complain */
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
chlog: freetdm: isdn: fix for 4ESS call clearing procedures

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c</span>
<span style="color: #000080; font-weight: bold">index 97984fb..5702b72 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c</span>
<span style="color: #800080; font-weight: bold">@@ -801,12 +801,14 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm</span>
                                                 sngisdn_snd_release(ftdmchan, 0);
                                                 break;
                                         case FTDM_CHANNEL_STATE_PROCEED:
<span style="color: #A00000">-                                                if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) &amp;&amp;</span>
<span style="color: #A00000">-                                                        ((sngisdn_span_data_t*)(ftdmchan-&gt;span-&gt;signal_data))-&gt;switchtype == SNGISDN_SWITCH_5ESS) {</span>
<span style="color: #00A000">+                                                if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND)) {</span>
<span style="color: #00A000">+                                                        if (((sngisdn_span_data_t*)(ftdmchan-&gt;span-&gt;signal_data))-&gt;switchtype == SNGISDN_SWITCH_4ESS ||</span>
<span style="color: #00A000">+                                                            ((sngisdn_span_data_t*)(ftdmchan-&gt;span-&gt;signal_data))-&gt;switchtype == SNGISDN_SWITCH_5ESS) {</span>
                                                         
<span style="color: #A00000">-                                                        /* When using 5ESS, if the user wants to clear an inbound call, the correct procedure is to send a PROGRESS with in-band info available, and play tones. Then send a DISCONNECT. If we reached this point, it means user did not try to play-tones, so send a RELEASE because remote side does not expect DISCONNECT in state 3 */</span>
<span style="color: #A00000">-                                                        sngisdn_snd_release(ftdmchan, 0);</span>
<span style="color: #A00000">-                                                        break;</span>
<span style="color: #00A000">+                                                                /* When using 5ESS, if the user wants to clear an inbound call, the correct procedure is to send a PROGRESS with in-band info available, and play tones. Then send a DISCONNECT. If we reached this point, it means user did not try to play-tones, so send a RELEASE because remote side does not expect DISCONNECT in state 3 */</span>
<span style="color: #00A000">+                                                                sngisdn_snd_release(ftdmchan, 0);</span>
<span style="color: #00A000">+                                                                break;</span>
<span style="color: #00A000">+                                                        }</span>
                                                 }
                                                 /* fall-through */
                                         default:
</pre></div>
<div class="highlight"><pre>committer: Arnaldo Pereira
comments: 
Merge branch &#39;master&#39; of git://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
Merge branch &#39;master&#39; of git.sangoma.com:smg_freeswitch
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
freetdm: Fix for typo in print

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #000080; font-weight: bold">index 92cf9e5..563a203 100755</span>
<span style="color: #A00000">--- a/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #800080; font-weight: bold">@@ -1570,8 +1570,8 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session</span>
                 switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-ANI2&quot;, &quot;%s&quot;, channel_caller_data-&gt;aniII);
                 
                 switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-DNIS&quot;, &quot;%s&quot;, channel_caller_data-&gt;dnis.digits);
<span style="color: #A00000">-                switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-DNIS-TON&quot;, &quot;%s&quot;, channel_caller_data-&gt;dnis.type);</span>
<span style="color: #A00000">-                switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-DNIS-Plan&quot;, &quot;%s&quot;, channel_caller_data-&gt;dnis.plan);</span>
<span style="color: #00A000">+                switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-DNIS-TON&quot;, &quot;%d&quot;, channel_caller_data-&gt;dnis.type);</span>
<span style="color: #00A000">+                switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-DNIS-Plan&quot;, &quot;%d&quot;, channel_caller_data-&gt;dnis.plan);</span>
 
                 switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-RDNIS&quot;, &quot;%s&quot;, channel_caller_data-&gt;rdnis.digits);
                 switch_channel_set_variable_printf(channel, &quot;sip_h_X-FreeTDM-RDNIS-TON&quot;, &quot;%d&quot;, channel_caller_data-&gt;rdnis.type);
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
chlog: freetdm: isdn: fix for 5ESS call clearing procedures

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c</span>
<span style="color: #000080; font-weight: bold">index df528ae..97984fb 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c</span>
<span style="color: #800080; font-weight: bold">@@ -683,8 +683,8 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm</span>
                                 if (!sngisdn_test_flag(sngisdn_info, FLAG_SENT_PROCEED)) {
                                         /* By default, we do not send a progress indicator in the proceed */
                                         ftdm_sngisdn_progind_t prog_ind = {SNGISDN_PROGIND_LOC_USER, SNGISDN_PROGIND_DESCR_INVALID};
<span style="color: #A00000">-                                        </span>
                                         sngisdn_set_flag(sngisdn_info, FLAG_SENT_PROCEED);
<span style="color: #00A000">+                                        </span>
                                         sngisdn_snd_proceed(ftdmchan, prog_ind);
                                 }
                         }
<span style="color: #800080; font-weight: bold">@@ -800,6 +800,15 @@ static ftdm_status_t ftdm_sangoma_isdn_process_state_change(ftdm_channel_t *ftdm</span>
                                                 /* If we never received a PROCEED/ALERT/PROGRESS/CONNECT on an outgoing call, we need to send release instead of disconnect */
                                                 sngisdn_snd_release(ftdmchan, 0);
                                                 break;
<span style="color: #00A000">+                                        case FTDM_CHANNEL_STATE_PROCEED:</span>
<span style="color: #00A000">+                                                if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_OUTBOUND) &amp;&amp;</span>
<span style="color: #00A000">+                                                        ((sngisdn_span_data_t*)(ftdmchan-&gt;span-&gt;signal_data))-&gt;switchtype == SNGISDN_SWITCH_5ESS) {</span>
<span style="color: #00A000">+                                                        </span>
<span style="color: #00A000">+                                                        /* When using 5ESS, if the user wants to clear an inbound call, the correct procedure is to send a PROGRESS with in-band info available, and play tones. Then send a DISCONNECT. If we reached this point, it means user did not try to play-tones, so send a RELEASE because remote side does not expect DISCONNECT in state 3 */</span>
<span style="color: #00A000">+                                                        sngisdn_snd_release(ftdmchan, 0);</span>
<span style="color: #00A000">+                                                        break;</span>
<span style="color: #00A000">+                                                }</span>
<span style="color: #00A000">+                                                /* fall-through */</span>
                                         default:
                                                 sngisdn_snd_disconnect(ftdmchan);
                                                 break;
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
test

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #000080; font-weight: bold">index 529a30f..0f92f59 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #800080; font-weight: bold">@@ -37,6 +37,9 @@</span>
  *
  */
 
<span style="color: #00A000">+#ifdef MOYTEST</span>
<span style="color: #00A000">+crap</span>
<span style="color: #00A000">+#endif</span>
 #define _GNU_SOURCE
 #include &quot;private/ftdm_core.h&quot;
 #include &lt;stdarg.h&gt;
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
freetdm: ss7 - bug fix: fix for bug introduced by merge of RELAY work

<span style="color: #000080; font-weight: bold">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</span>
<span style="color: #000080; font-weight: bold">index c971179..adee000 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #800080; font-weight: bold">@@ -495,8 +495,6 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
         /**************************************************************************/
         case FTDM_CHANNEL_STATE_COLLECT:        /* IAM received but wating on digits */
 
<span style="color: #A00000">-                isup_intf = &amp;g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId];</span>
<span style="color: #A00000">-</span>
                 if (ftdmchan-&gt;last_state == FTDM_CHANNEL_STATE_SUSPENDED) {
                         SS7_DEBUG(&quot;re-entering state from processing block/unblock request ... do nothing\n&quot;);
                         break;
<span style="color: #800080; font-weight: bold">@@ -516,8 +514,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         /*now go to the RING state */
                         ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RING);
                         
<span style="color: #A00000">-                } else if (i &gt;= isup_intf-&gt;min_digits) {</span>
<span style="color: #A00000">-                        SS7_DEBUG_CHAN(ftdmchan, &quot;Received %d digits (min digits = %d)\n&quot;, i, isup_intf-&gt;min_digits);</span>
<span style="color: #00A000">+                } else if (i &gt;= sngss7_info-&gt;circuit-&gt;min_digits) {</span>
<span style="color: #00A000">+                        SS7_DEBUG_CHAN(ftdmchan, &quot;Received %d digits (min digits = %d)\n&quot;, i, sngss7_info-&gt;circuit-&gt;min_digits);</span>
 
                         /*now go to the RING state */
                         ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RING);
<span style="color: #800080; font-weight: bold">@@ -527,7 +525,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         if (ftdmchan-&gt;last_state != FTDM_CHANNEL_STATE_IDLE) {
                                 SS7_INFO_CHAN(ftdmchan,&quot;Received %d out of %d so far: %s...starting T35\n&quot;,
                                                                                 i,
<span style="color: #A00000">-                                                                                isup_intf-&gt;min_digits,</span>
<span style="color: #00A000">+                                                                                sngss7_info-&gt;circuit-&gt;min_digits,</span>
                                                                                 ftdmchan-&gt;caller_data.dnis.digits);
                 
                                 /* start ISUP t35 */
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #000080; font-weight: bold">index 93f2678..d2fa973 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #800080; font-weight: bold">@@ -1509,11 +1509,6 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)</span>
 
                         SS7_DEBUG(&quot;Found an isup mptRouteId = %d\n&quot;, sng_isup.mtpRouteId);
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;min_digits&quot;)) {</span>
<span style="color: #A00000">-                        sng_isup.min_digits = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound min_digits = %d\n&quot;, sng_isup.min_digits);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
                 } else if (!strcasecmp(parm-&gt;var, &quot;ssf&quot;)) {
                 /**********************************************************************/
                         ret = find_ssf_type_in_map(parm-&gt;val);
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
chlog: freetdm: ss7 - update for new licensing, will not work with old licenses                         contact Sangoma (techdesk@sangoma.com) to obtain a new license

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #000080; font-weight: bold">index 42b95a1..15fc1ef 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -80,8 +80,7 @@ int  ft_to_sngss7_cfg_all(void)</span>
 
                 /* start of by checking if the license and sig file are valid */
                 if (sng_validate_license(g_ftdm_sngss7_data.cfg.license,
<span style="color: #A00000">-                                                                 g_ftdm_sngss7_data.cfg.signature,</span>
<span style="color: #A00000">-                                                                 g_ftdm_sngss7_data.cfg.spc)) {</span>
<span style="color: #00A000">+                                                                 g_ftdm_sngss7_data.cfg.signature)) {</span>
 
                         SS7_CRITICAL(&quot;License verification failed..ending!\n&quot;);
                         return 1;
<span style="color: #000080; font-weight: bold">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</span>
<span style="color: #000080; font-weight: bold">index 1dfcab4..f4143fc 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c</span>
<span style="color: #800080; font-weight: bold">@@ -79,8 +79,8 @@ void handle_sng_log(uint8_t level, char *fmt,...)</span>
                 ftdm_log(FTDM_LOG_INFO, &quot;sng_ss7-&gt;%s&quot;, data);
                 break;
         /**************************************************************************/
<span style="color: #A00000">-        case SNG_LOGLEVEL_STATS:</span>
<span style="color: #A00000">-                ftdm_log(FTDM_LOG_INFO, &quot;sng_ss7-&gt;%s&quot;, data);</span>
<span style="color: #00A000">+        case SNG_LOGLEVEL_NOTICE:</span>
<span style="color: #00A000">+                ftdm_log(FTDM_LOG_NOTICE, &quot;sng_ss7-&gt;%s&quot;, data);</span>
                 break;
         /**************************************************************************/
         case SNG_LOGLEVEL_ERROR:
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
chlog: freetdm: ss7 - bug fix: a route now supports multiple linksets

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #000080; font-weight: bold">index d972cd7..92cf9e5 100755</span>
<span style="color: #A00000">--- a/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #800080; font-weight: bold">@@ -2462,7 +2462,7 @@ static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confn</span>
         }
 
         /* add mtp routes */
<span style="color: #A00000">-        if (add_config_list_nodes(isup, rootnode, &quot;mtp_routes&quot;, &quot;mtp_route&quot;, NULL, NULL)) {</span>
<span style="color: #00A000">+        if (add_config_list_nodes(isup, rootnode, &quot;mtp_routes&quot;, &quot;mtp_route&quot;, &quot;linksets&quot;, &quot;linkset&quot;)) {</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process mtp_routes for sng_isup config %s\n&quot;, confname);
                 ftdm_conf_node_destroy(rootnode);
                 return NULL;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #000080; font-weight: bold">index 277951c..93f2678 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #800080; font-weight: bold">@@ -1269,6 +1269,10 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)</span>
         int                                                 num_parms = mtp_route-&gt;n_parameters;
         int                                                 i;
 
<span style="color: #00A000">+        ftdm_conf_node_t                *linkset;</span>
<span style="color: #00A000">+        int                                                ls_id;</span>
<span style="color: #00A000">+        int                                                numLinks;</span>
<span style="color: #00A000">+</span>
         /* initalize the mtpRoute structure */
         memset(&amp;mtpRoute, 0x0, sizeof(mtpRoute));
 
<span style="color: #800080; font-weight: bold">@@ -1299,11 +1303,6 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)</span>
                         mtpRoute.dpc = atoi(parm-&gt;val);
                         SS7_DEBUG(&quot;Found an mtpRoute dpc = %d\n&quot;, mtpRoute.dpc);
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;linksetId&quot;)) {</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                        mtpRoute.linkSetId = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;Found an mtpRoute linkset = %s\n&quot;, parm-&gt;val);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
                 } else if (!strcasecmp(parm-&gt;var, &quot;isSTP&quot;)) {
                 /**********************************************************************/
                         if (!strcasecmp(parm-&gt;val, &quot;no&quot;)) {
<span style="color: #800080; font-weight: bold">@@ -1383,15 +1382,47 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)</span>
                 parm = parm + 1;
         }
 
<span style="color: #A00000">-        /* pull up the linktype, switchtype, and SSF from the linkset */</span>
<span style="color: #A00000">-        mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].linkType;</span>
<span style="color: #A00000">-        mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].switchType;</span>
<span style="color: #A00000">-        mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].ssf;</span>
<span style="color: #A00000">-</span>
         /* fill in the rest of the values in the mtpRoute struct  */
         mtpRoute.nwId = mtpRoute.id;
         mtpRoute.cmbLinkSetId = mtpRoute.id;
 
<span style="color: #00A000">+        /* parse in the list of linksets this route is reachable by */</span>
<span style="color: #00A000">+        linkset = mtp_route-&gt;child-&gt;child;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (linkset != NULL) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+                /* extract the linkset Id */</span>
<span style="color: #00A000">+                ls_id = atoi(linkset-&gt;parameters-&gt;val);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].id != 0) {</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found mtpRoute linkset id = %d that is valid\n&quot;,ls_id);</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found mtpRoute linkset id = %d that is invalid\n&quot;,ls_id);</span>
<span style="color: #00A000">+                        goto move_along;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* pull up the linktype, switchtype, and SSF from the linkset */</span>
<span style="color: #00A000">+                mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].linkType;</span>
<span style="color: #00A000">+                mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].switchType;</span>
<span style="color: #00A000">+                mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].ssf;</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                /* extract the number of cmbLinkSetId aleady on this linkset */</span>
<span style="color: #00A000">+                numLinks = g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks;</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                /* add this routes cmbLinkSetId to the list */</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].links[numLinks] = mtpRoute.cmbLinkSetId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* increment the number of cmbLinkSets on this linkset */</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[ls_id].numLinks++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+move_along:</span>
<span style="color: #00A000">+                /* move to the next linkset element */</span>
<span style="color: #00A000">+                linkset = linkset-&gt;next;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* while (linkset != null) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
         ftmod_ss7_fill_in_mtp3_route(&amp;mtpRoute);
 
         ftmod_ss7_fill_in_nsap(&amp;mtpRoute);
</pre></div>
<div class="highlight"><pre>committer: Konrad Hammel
comments: 
chlog: freetdm: ss7 - added support for RELAY

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/Makefile.am b/libs/freetdm/Makefile.am</span>
<span style="color: #000080; font-weight: bold">index 96f1c9a..b3353f3 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/Makefile.am</span>
<span style="color: #00A000">+++ b/libs/freetdm/Makefile.am</span>
<span style="color: #800080; font-weight: bold">@@ -240,7 +240,8 @@ ftmod_sangoma_ss7_la_SOURCES = \</span>
         $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c \
         $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c \
         $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sts.c \
<span style="color: #A00000">-        $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c</span>
<span style="color: #00A000">+        $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c \</span>
<span style="color: #00A000">+        $(SRC)/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c</span>
 
 ftmod_sangoma_ss7_la_CFLAGS  = $(AM_CFLAGS) $(FTDM_CFLAGS) -D_GNU_SOURCE
 ftmod_sangoma_ss7_la_LDFLAGS = -shared -module -avoid-version -lsng_ss7
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/configure.ac b/libs/freetdm/configure.ac</span>
<span style="color: #000080; font-weight: bold">index a070e99..1f4fc9c 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/configure.ac</span>
<span style="color: #00A000">+++ b/libs/freetdm/configure.ac</span>
<span style="color: #800080; font-weight: bold">@@ -267,7 +267,7 @@ fi</span>
 #
 HAVE_SNG_SS7=&quot;no&quot;
 AC_MSG_RESULT([${as_nl}&lt;&lt;&gt;&gt; Sangoma SS7 stack])
<span style="color: #A00000">-AC_CHECK_LIB([sng_ss7], [sng_isup_init], [HAVE_SNG_SS7=&quot;yes&quot;])</span>
<span style="color: #00A000">+AC_CHECK_LIB([sng_ss7], [sng_isup_init_gen], [HAVE_SNG_SS7=&quot;yes&quot;])</span>
 AC_MSG_RESULT([checking whether to build ftmod_sangoma_ss7... ${HAVE_SNG_SS7}])
 AM_CONDITIONAL([HAVE_SNG_SS7], [test &quot;${HAVE_SNG_SS7}&quot; = &quot;yes&quot;])
 
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #000080; font-weight: bold">index 970cb5b..d972cd7 100755</span>
<span style="color: #A00000">--- a/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/mod_freetdm/mod_freetdm.c</span>
<span style="color: #800080; font-weight: bold">@@ -2360,8 +2360,9 @@ static int add_config_list_nodes(switch_xml_t swnode, ftdm_conf_node_t *rootnode</span>
 
 static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confname)
 {
<span style="color: #A00000">-        switch_xml_t signode, ss7configs, isup;</span>
<span style="color: #A00000">-        ftdm_conf_node_t *rootnode;</span>
<span style="color: #00A000">+        switch_xml_t signode, ss7configs, isup, gen, param;</span>
<span style="color: #00A000">+        ftdm_conf_node_t *rootnode, *list;</span>
<span style="color: #00A000">+        char *var, *val;</span>
 
         /* try to find the conf in the hash first */
         rootnode = switch_core_hash_find(globals.ss7_configs, confname);
<span style="color: #800080; font-weight: bold">@@ -2405,8 +2406,56 @@ static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confn</span>
                 return NULL;
         }
 
<span style="color: #00A000">+        /* add sng_gen */</span>
<span style="color: #00A000">+        gen = switch_xml_child(isup, &quot;sng_gen&quot;);</span>
<span style="color: #00A000">+        if (gen == NULL) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process sng_gen for sng_isup config %s\n&quot;, confname);</span>
<span style="color: #00A000">+                ftdm_conf_node_destroy(rootnode);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ((FTDM_SUCCESS != ftdm_conf_node_create(&quot;sng_gen&quot;, &amp;list, rootnode))) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to create %s node for %s\n&quot;, &quot;sng_gen&quot;, confname);</span>
<span style="color: #00A000">+                ftdm_conf_node_destroy(rootnode);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        for (param = switch_xml_child(gen, &quot;param&quot;); param; param = param-&gt;next) {</span>
<span style="color: #00A000">+                var = (char *) switch_xml_attr_soft(param, &quot;name&quot;);</span>
<span style="color: #00A000">+                val = (char *) switch_xml_attr_soft(param, &quot;value&quot;);</span>
<span style="color: #00A000">+                ftdm_conf_node_add_param(list, var, val);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* add relay channels */</span>
<span style="color: #00A000">+        if (add_config_list_nodes(isup, rootnode, &quot;sng_relay&quot;, &quot;relay_channel&quot;, NULL, NULL)) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process sng_relay for sng_isup config %s\n&quot;, confname);</span>
<span style="color: #00A000">+                ftdm_conf_node_destroy(rootnode);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* add mtp1 links */</span>
<span style="color: #00A000">+        if (add_config_list_nodes(isup, rootnode, &quot;mtp1_links&quot;, &quot;mtp1_link&quot;, NULL, NULL)) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process mtp1_links for sng_isup config %s\n&quot;, confname);</span>
<span style="color: #00A000">+                ftdm_conf_node_destroy(rootnode);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* add mtp2 links */</span>
<span style="color: #00A000">+        if (add_config_list_nodes(isup, rootnode, &quot;mtp2_links&quot;, &quot;mtp2_link&quot;, NULL, NULL)) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process mtp2_links for sng_isup config %s\n&quot;, confname);</span>
<span style="color: #00A000">+                ftdm_conf_node_destroy(rootnode);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* add mtp3 links */</span>
<span style="color: #00A000">+        if (add_config_list_nodes(isup, rootnode, &quot;mtp3_links&quot;, &quot;mtp3_link&quot;, NULL, NULL)) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process mtp3_links for sng_isup config %s\n&quot;, confname);</span>
<span style="color: #00A000">+                ftdm_conf_node_destroy(rootnode);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         /* add mtp linksets */
<span style="color: #A00000">-        if (add_config_list_nodes(isup, rootnode, &quot;mtp_linksets&quot;, &quot;mtp_linkset&quot;, &quot;mtp_links&quot;, &quot;mtp_link&quot;)) {</span>
<span style="color: #00A000">+        if (add_config_list_nodes(isup, rootnode, &quot;mtp_linksets&quot;, &quot;mtp_linkset&quot;, NULL, NULL)) {</span>
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process mtp_linksets for sng_isup config %s\n&quot;, confname);
                 ftdm_conf_node_destroy(rootnode);
                 return NULL;
<span style="color: #800080; font-weight: bold">@@ -2426,6 +2475,13 @@ static ftdm_conf_node_t *get_ss7_config_node(switch_xml_t cfg, const char *confn</span>
                 return NULL;
         }
 
<span style="color: #00A000">+        /* add cc spans */</span>
<span style="color: #00A000">+        if (add_config_list_nodes(isup, rootnode, &quot;cc_spans&quot;, &quot;cc_span&quot;, NULL, NULL)) {</span>
<span style="color: #00A000">+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, &quot;failed to process cc_spans for sng_isup config %s\n&quot;, confname);</span>
<span style="color: #00A000">+                ftdm_conf_node_destroy(rootnode);</span>
<span style="color: #00A000">+                return NULL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         switch_core_hash_insert(globals.ss7_configs, confname, rootnode);
 
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Added SS7 node configuration %s\n&quot;, confname);
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #000080; font-weight: bold">index e7378bf..42b95a1 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c</span>
<span style="color: #800080; font-weight: bold">@@ -44,6 +44,7 @@</span>
 /* PROTOTYPES *****************************************************************/
 int ft_to_sngss7_cfg_all(void);
 
<span style="color: #00A000">+int ftmod_ss7_relay_gen_config(void);</span>
 int ftmod_ss7_mtp1_gen_config(void);
 int ftmod_ss7_mtp2_gen_config(void);
 int ftmod_ss7_mtp3_gen_config(void);
<span style="color: #800080; font-weight: bold">@@ -65,6 +66,8 @@ int ftmod_ss7_isup_ckt_config(int id);</span>
 int ftmod_ss7_isup_isap_config(int id);
 
 int ftmod_ss7_cc_isap_config(int id);
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int ftmod_ss7_relay_chan_config(int id);</span>
 /******************************************************************************/
 
 /* FUNCTIONS ******************************************************************/
<span style="color: #800080; font-weight: bold">@@ -75,6 +78,7 @@ int  ft_to_sngss7_cfg_all(void)</span>
         /* check if we have done gen_config already */
         if (!(g_ftdm_sngss7_data.gen_config)) {
 
<span style="color: #00A000">+                /* start of by checking if the license and sig file are valid */</span>
                 if (sng_validate_license(g_ftdm_sngss7_data.cfg.license,
                                                                  g_ftdm_sngss7_data.cfg.signature,
                                                                  g_ftdm_sngss7_data.cfg.spc)) {
<span style="color: #800080; font-weight: bold">@@ -83,50 +87,148 @@ int  ft_to_sngss7_cfg_all(void)</span>
                         return 1;
                 }
 
<span style="color: #A00000">-                if (ftmod_ss7_mtp1_gen_config()) {</span>
<span style="color: #A00000">-                        SS7_CRITICAL(&quot;MTP1 General configuration FAILED!\n&quot;);</span>
<span style="color: #A00000">-                        return 1;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        SS7_INFO(&quot;MTP1 General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                /* if the procId is not 0 then we are using relay mode */</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.procId != 0) {</span>
<span style="color: #00A000">+                        /* set the desired procID value */</span>
<span style="color: #00A000">+                        sng_set_procId((uint16_t)g_ftdm_sngss7_data.cfg.procId);</span>
                 }
 
<span style="color: #A00000">-                if (ftmod_ss7_mtp2_gen_config()) {</span>
<span style="color: #A00000">-                        SS7_CRITICAL(&quot;MTP2 General configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                /* start up the stack manager */</span>
<span style="color: #00A000">+                if (sng_isup_init_sm()) {</span>
<span style="color: #00A000">+                        SS7_CRITICAL(&quot;Failed to start Stack Manager\n&quot;);</span>
                         return 1;
                 } else {
<span style="color: #A00000">-                        SS7_INFO(&quot;MTP2 General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                        SS7_INFO(&quot;Started Stack Manager!\n&quot;);</span>
                 }
 
<span style="color: #A00000">-                if (ftmod_ss7_mtp3_gen_config()) {</span>
<span style="color: #A00000">-                        SS7_CRITICAL(&quot;MTP3 General configuration FAILED!\n&quot;);</span>
<span style="color: #A00000">-                        return 1;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        SS7_INFO(&quot;MTP3 General configuration DONE\n&quot;);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                /* check if the configuration had a Relay Channel */</span>
<span style="color: #00A000">+                if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_RY)) { </span>
<span style="color: #00A000">+                        /* start up the relay task */</span>
<span style="color: #00A000">+                        if (sng_isup_init_relay()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Failed to start Relay\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Started Relay!\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
 
<span style="color: #A00000">-                if (ftmod_ss7_isup_gen_config()) {</span>
<span style="color: #A00000">-                        SS7_CRITICAL(&quot;ISUP General configuration FAILED!\n&quot;);</span>
<span style="color: #A00000">-                        return 1;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        SS7_INFO(&quot;ISUP General configuration DONE\n&quot;);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                        /* run general configuration on the relay task */</span>
<span style="color: #00A000">+                        if (ftmod_ss7_relay_gen_config()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Relay General configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Relay General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
 
<span style="color: #A00000">-                if (ftmod_ss7_cc_gen_config()) {</span>
<span style="color: #A00000">-                        SS7_CRITICAL(&quot;CC General configuration FAILED!\n&quot;);</span>
<span style="color: #A00000">-                        return 1;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        SS7_INFO(&quot;CC General configuration DONE\n&quot;);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                } /* if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_RY)) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {</span>
<span style="color: #00A000">+                        if (sng_isup_init_cc()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Failed to start Call-Control\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Started Call-Control!\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        if (ftmod_ss7_cc_gen_config()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;CC General configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;CC General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        if (ftmod_ss7_cc_isap_config(1)) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;CC ISAP configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;CC ISAP configuration DONE!\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } /* if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_CC)) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {</span>
<span style="color: #00A000">+                        if (sng_isup_init_isup()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Failed to start ISUP\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Started ISUP!\n&quot;);</span>
<span style="color: #00A000">+                        }        </span>
<span style="color: #00A000">+                        if (ftmod_ss7_isup_gen_config()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;ISUP General configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;ISUP General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } /* if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) {</span>
<span style="color: #00A000">+                        if (sng_isup_init_mtp3()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Failed to start MTP3\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Started MTP3!\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        if (ftmod_ss7_mtp3_gen_config()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;MTP3 General configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;MTP3 General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } /* if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) {</span>
<span style="color: #00A000">+                        if (sng_isup_init_mtp2()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Failed to start MTP2\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Started MTP2!\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        if (sng_isup_init_mtp1()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Failed to start MTP2\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Started MTP1!\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        if (ftmod_ss7_mtp1_gen_config()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;MTP1 General configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;MTP1 General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        if (ftmod_ss7_mtp2_gen_config()) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;MTP2 General configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;MTP2 General configuration DONE\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } /* if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) */</span>
 
                 /* update the global gen_config so we don&#39;t do it again */
                 g_ftdm_sngss7_data.gen_config = 1;
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        } /* if (!(g_ftdm_sngss7_data.gen_config)) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* go through all the relays channels and configure it */</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) {</span>
<span style="color: #00A000">+                /* check if this relay channel has been configured already */</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.relay[x].flags &amp; SNGSS7_CONFIGURED)) {</span>
 
<span style="color: #00A000">+                        /* send the specific configuration */</span>
<span style="color: #00A000">+                        if (ftmod_ss7_relay_chan_config(x)) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;Relay Channel %d configuration FAILED!\n&quot;, x);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;Relay Channel %d configuration DONE!\n&quot;, x);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.relay[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_CONFIGURED */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */</span>
 
         x = 1;
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #00A000">+        while (x &lt; (MAX_MTP_LINKS + 1)) {</span>
                 /* check if this link has been configured already */
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.mtpLink[x].flags &amp; CONFIGURED)) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags &amp; SNGSS7_CONFIGURED) &amp;&amp;</span>
<span style="color: #00A000">+                          (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0)) {</span>
 
                         /* configure mtp1 */
                         if (ftmod_ss7_mtp1_psap_config(x)) {
<span style="color: #800080; font-weight: bold">@@ -136,6 +238,18 @@ int  ft_to_sngss7_cfg_all(void)</span>
                                 SS7_INFO(&quot;MTP1 PSAP %d configuration DONE!\n&quot;, x);
                         }
 
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtp1Link[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        while (x &lt; (MAX_MTP_LINKS + 1)) {</span>
<span style="color: #00A000">+                /* check if this link has been configured already */</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags &amp; SNGSS7_CONFIGURED) &amp;&amp;</span>
<span style="color: #00A000">+                         (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0)) {</span>
<span style="color: #00A000">+</span>
                         /* configure mtp2 */
                         if (ftmod_ss7_mtp2_dlsap_config(x)) {
                                 SS7_CRITICAL(&quot;MTP2 DLSAP %d configuration FAILED!\n&quot;,x);
<span style="color: #800080; font-weight: bold">@@ -144,6 +258,18 @@ int  ft_to_sngss7_cfg_all(void)</span>
                                 SS7_INFO(&quot;MTP2 DLSAP %d configuration DONE!\n&quot;, x);
                         }
 
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtp2Link[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        while (x &lt; (MAX_MTP_LINKS + 1)) {</span>
<span style="color: #00A000">+                /* check if this link has been configured already */</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags &amp; SNGSS7_CONFIGURED) &amp;&amp;</span>
<span style="color: #00A000">+                         (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0)) {</span>
<span style="color: #00A000">+</span>
                         /* configure mtp3 */
                         if (ftmod_ss7_mtp3_dlsap_config(x)) {
                                 SS7_CRITICAL(&quot;MTP3 DLSAP %d configuration FAILED!\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -152,17 +278,17 @@ int  ft_to_sngss7_cfg_all(void)</span>
                                 SS7_INFO(&quot;MTP3 DLSAP %d configuration DONE!\n&quot;, x);
                         }
 
<span style="color: #A00000">-                        /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.mtpLink[x].flags |= CONFIGURED;</span>
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtp3Link[x].flags |= SNGSS7_CONFIGURED;</span>
                 }
                 
                 x++;
<span style="color: #A00000">-        } /* while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) */</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) */</span>
 
         x = 1;
         while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
                 /* check if this link has been configured already */
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags &amp; CONFIGURED)) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags &amp; SNGSS7_CONFIGURED)) {</span>
 
                         if (ftmod_ss7_mtp3_nsap_config(x)) {
                                 SS7_CRITICAL(&quot;MTP3 NSAP %d configuration FAILED!\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -178,9 +304,9 @@ int  ft_to_sngss7_cfg_all(void)</span>
                                 SS7_INFO(&quot;ISUP NSAP %d configuration DONE!\n&quot;, x);
                         }
 
<span style="color: #A00000">-                        /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.nsap[x].flags |= CONFIGURED;</span>
<span style="color: #A00000">-                } /* if !CONFIGURED */</span>
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_CONFIGURED */</span>
                 
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
<span style="color: #800080; font-weight: bold">@@ -188,7 +314,7 @@ int  ft_to_sngss7_cfg_all(void)</span>
         x = 1;
         while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
                 /* check if this link has been configured already */
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags &amp; CONFIGURED)) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags &amp; SNGSS7_CONFIGURED)) {</span>
 
                         if (ftmod_ss7_mtp3_linkset_config(x)) {
                                 SS7_CRITICAL(&quot;MTP3 LINKSET %d configuration FAILED!\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -197,9 +323,9 @@ int  ft_to_sngss7_cfg_all(void)</span>
                                 SS7_INFO(&quot;MTP3 LINKSET %d configuration DONE!\n&quot;, x);
                         }
 
<span style="color: #A00000">-                        /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= CONFIGURED;</span>
<span style="color: #A00000">-                } /* if !CONFIGURED */</span>
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_CONFIGURED */</span>
                 
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
<span style="color: #800080; font-weight: bold">@@ -207,7 +333,7 @@ int  ft_to_sngss7_cfg_all(void)</span>
         x = 1;
         while ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0)) {
                 /* check if this link has been configured already */
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags &amp; CONFIGURED)) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags &amp; SNGSS7_CONFIGURED)) {</span>
 
                         if (ftmod_ss7_mtp3_route_config(x)) {
                                 SS7_CRITICAL(&quot;MTP3 ROUTE %d configuration FAILED!\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -216,31 +342,33 @@ int  ft_to_sngss7_cfg_all(void)</span>
                                 SS7_INFO(&quot;MTP3 ROUTE %d configuration DONE!\n&quot;,x);
                         }
 
<span style="color: #A00000">-                        /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.mtpRoute[x].flags |= CONFIGURED;</span>
<span style="color: #A00000">-                } /* if !CONFIGURED */</span>
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtpRoute[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_CONFIGURED */</span>
                 
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */
 
<span style="color: #A00000">-        if (!(g_ftdm_sngss7_data.cfg.mtpRoute[0].flags &amp; CONFIGURED)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (ftmod_ss7_mtp3_route_config(0)) {</span>
<span style="color: #A00000">-                        SS7_CRITICAL(&quot;MTP3 ROUTE 0 configuration FAILED!\n&quot;);</span>
<span style="color: #A00000">-                        return 1;</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        SS7_INFO(&quot;MTP3 ROUTE 0 configuration DONE!\n&quot;);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpRoute[0].flags |= CONFIGURED;</span>
<span style="color: #A00000">-        } /* if !CONFIGURED */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.mtpRoute[0].flags &amp; SNGSS7_CONFIGURED)) {</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                        if (ftmod_ss7_mtp3_route_config(0)) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;MTP3 ROUTE 0 configuration FAILED!\n&quot;);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;MTP3 ROUTE 0 configuration DONE!\n&quot;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtpRoute[0].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_CONFIGURED */</span>
<span style="color: #00A000">+        }</span>
 
 
         x = 1;
         while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
                 /* check if this link has been configured already */
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.isap[x].flags &amp; CONFIGURED)) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.isap[x].flags &amp; SNGSS7_CONFIGURED)) {</span>
                         
                         if (ftmod_ss7_isup_isap_config(x)) {
                                 SS7_CRITICAL(&quot;ISUP ISAP %d configuration FAILED!\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -249,57 +377,51 @@ int  ft_to_sngss7_cfg_all(void)</span>
                                 SS7_INFO(&quot;ISUP ISAP %d configuration DONE!\n&quot;, x);
                         }
 
<span style="color: #A00000">-                        if (ftmod_ss7_cc_isap_config(x)) {</span>
<span style="color: #A00000">-                                SS7_CRITICAL(&quot;CC ISAP %d configuration FAILED!\n&quot;, x);</span>
<span style="color: #A00000">-                                return 1;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_INFO(&quot;CC ISAP %d configuration DONE!\n&quot;, x);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.isap[x].flags |= CONFIGURED;</span>
<span style="color: #A00000">-                } /* if !CONFIGURED */</span>
<span style="color: #00A000">+                        /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_CONFIGURED */</span>
                 
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
 
<span style="color: #A00000">-        x = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {</span>
<span style="color: #A00000">-                /* check if this link has been configured already */</span>
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags &amp; CONFIGURED)) {</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {</span>
<span style="color: #00A000">+                x = 1;</span>
<span style="color: #00A000">+                while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {</span>
<span style="color: #00A000">+                        /* check if this link has been configured already */</span>
<span style="color: #00A000">+                        if (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags &amp; SNGSS7_CONFIGURED)) {</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                                if (ftmod_ss7_isup_intf_config(x)) {</span>
<span style="color: #00A000">+                                        SS7_CRITICAL(&quot;ISUP INTF %d configuration FAILED!\n&quot;, x);</span>
<span style="color: #00A000">+                                        return 1;</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        SS7_INFO(&quot;ISUP INTF %d configuration DONE!\n&quot;, x);</span>
<span style="color: #00A000">+                                        /* set the interface to paused */</span>
<span style="color: #00A000">+                                        sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg.isupIntf[x], SNGSS7_PAUSED);</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                                /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                                g_ftdm_sngss7_data.cfg.isupIntf[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                        } /* if !SNGSS7_CONFIGURED */</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                        x++;</span>
<span style="color: #00A000">+                } /* while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) */</span>
<span style="color: #00A000">+        } /* if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #00A000">+                if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {</span>
 
<span style="color: #A00000">-                        if (ftmod_ss7_isup_intf_config(x)) {</span>
<span style="color: #A00000">-                                SS7_CRITICAL(&quot;ISUP INTF %d configuration FAILED!\n&quot;, x);</span>
<span style="color: #00A000">+                        if (ftmod_ss7_isup_ckt_config(x)) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;ISUP CKT %d configuration FAILED!\n&quot;, x);</span>
                                 return 1;
                         } else {
<span style="color: #A00000">-                                SS7_INFO(&quot;ISUP INTF %d configuration DONE!\n&quot;, x);</span>
<span style="color: #A00000">-                                /* set the interface to paused */</span>
<span style="color: #A00000">-                                sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg.isupIntf[x], SNGSS7_PAUSED);</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;ISUP CKT %d configuration DONE!\n&quot;, x);</span>
                         }
 
<span style="color: #A00000">-                        /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.isupIntf[x].flags |= CONFIGURED;</span>
<span style="color: #A00000">-                } /* if !CONFIGURED */</span>
<span style="color: #A00000">-                </span>
<span style="color: #A00000">-                x++;</span>
<span style="color: #A00000">-        } /* while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) */</span>
<span style="color: #00A000">+                } /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */</span>
 
<span style="color: #A00000">-        x = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #A00000">-                /* check if this link has been configured already */</span>
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.isupCkt[x].flags &amp; CONFIGURED)) {</span>
<span style="color: #A00000">-                        if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == 0) {</span>
<span style="color: #A00000">-                                if (ftmod_ss7_isup_ckt_config(x)) {</span>
<span style="color: #A00000">-                                        SS7_CRITICAL(&quot;ISUP CKT %d configuration FAILED!\n&quot;, x);</span>
<span style="color: #A00000">-                                        return 1;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        SS7_INFO(&quot;ISUP CKT %d configuration DONE!\n&quot;, x);</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* set the CONFIGURED flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= CONFIGURED;</span>
<span style="color: #A00000">-                } /* if !CONFIGURED */</span>
<span style="color: #00A000">+                /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;</span>
                 
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
<span style="color: #800080; font-weight: bold">@@ -308,6 +430,44 @@ int  ft_to_sngss7_cfg_all(void)</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+int ftmod_ss7_relay_gen_config(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        RyMngmt        cfg;        /*configuration structure*/</span>
<span style="color: #00A000">+        Pst                pst;        /*post structure*/</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTRY;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* clear the configuration structure */</span>
<span style="color: #00A000">+        memset(&amp;cfg, 0x0, sizeof(RyMngmt));</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* fill in some general sections of the header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cfg.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* fill in the post structure */</span>
<span style="color: #00A000">+        smPstInit( &amp;cfg.t.cfg.s.ryGenCfg.lmPst );</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /*fill in the specific fields of the header */</span>
<span style="color: #00A000">+        cfg.hdr.msgType                                                = TCFG;</span>
<span style="color: #00A000">+        cfg.hdr.entId.ent                                         = ENTRY;</span>
<span style="color: #00A000">+        cfg.hdr.entId.inst                                        = S_INST;</span>
<span style="color: #00A000">+        cfg.hdr.elmId.elmnt                                 = STGEN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryGenCfg.lmPst.srcEnt        = ENTRY;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryGenCfg.lmPst.dstEnt        = ENTSM;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryGenCfg.nmbChan                = 10;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryGenCfg.tmrRes                        = RY_PERIOD;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryGenCfg.usta                        = 1;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return(sng_cfg_relay(&amp;pst, &amp;cfg));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
 int ftmod_ss7_mtp1_gen_config(void)
 {
         L1Mngmt        cfg;        /*configuration structure*/
<span style="color: #800080; font-weight: bold">@@ -575,7 +735,7 @@ int ftmod_ss7_mtp1_psap_config(int id)</span>
 {
         L1Mngmt                        cfg;
         Pst                                pst;
<span style="color: #A00000">-        sng_mtp_link_t        *k = &amp;g_ftdm_sngss7_data.cfg.mtpLink[id];</span>
<span style="color: #00A000">+        sng_mtp1_link_t        *k = &amp;g_ftdm_sngss7_data.cfg.mtp1Link[id];</span>
         
         /* initalize the post structure */
         smPstInit(&amp;pst);
<span style="color: #800080; font-weight: bold">@@ -597,8 +757,8 @@ int ftmod_ss7_mtp1_psap_config(int id)</span>
         
         cfg.hdr.elmId.elmntInst1        = k-&gt;id;
         
<span style="color: #A00000">-        cfg.t.cfg.s.l1PSAP.span                = k-&gt;mtp1.span;</span>
<span style="color: #A00000">-        cfg.t.cfg.s.l1PSAP.chan                = k-&gt;mtp1.chan;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.l1PSAP.span                = k-&gt;span;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.l1PSAP.chan                = k-&gt;chan;</span>
         cfg.t.cfg.s.l1PSAP.spId                = k-&gt;id;
 
         return(sng_cfg_mtp1(&amp;pst, &amp;cfg));
<span style="color: #800080; font-weight: bold">@@ -609,7 +769,7 @@ int ftmod_ss7_mtp2_dlsap_config(int id)</span>
 {
         SdMngmt        cfg;
         Pst                pst;
<span style="color: #A00000">-        sng_mtp_link_t        *k = &amp;g_ftdm_sngss7_data.cfg.mtpLink[id];</span>
<span style="color: #00A000">+        sng_mtp2_link_t        *k = &amp;g_ftdm_sngss7_data.cfg.mtp2Link[id];</span>
 
         /* initalize the post structure */
         smPstInit( &amp;pst);
<span style="color: #800080; font-weight: bold">@@ -633,10 +793,15 @@ int ftmod_ss7_mtp2_dlsap_config(int id)</span>
 
         cfg.t.cfg.s.sdDLSAP.mem.region                = S_REG;                                        /* memory region */
         cfg.t.cfg.s.sdDLSAP.mem.pool                = S_POOL;                                        /* memory pool */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.swtch                        = k-&gt;mtp2.linkType;                        /* protocol type */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.swtch                        = k-&gt;linkType;                        /* protocol type */</span>
         cfg.t.cfg.s.sdDLSAP.priorDl                        = PRIOR0;                                        /* priority for data link layer */
         cfg.t.cfg.s.sdDLSAP.routeDl                        = RTESPEC;                                        /* route for data link layer */
         cfg.t.cfg.s.sdDLSAP.selectorDl                = 0;                                                /* upper interface selector */
<span style="color: #00A000">+        if (k-&gt;mtp1ProcId &gt; 0) {</span>
<span style="color: #00A000">+                cfg.t.cfg.s.sdDLSAP.dstProcId        = k-&gt;mtp1ProcId;                /* the procid of MAC/L1/MTP1 */</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                cfg.t.cfg.s.sdDLSAP.dstProcId        = SFndProcId();                                /* the procid of MAC/L1/MTP1 */</span>
<span style="color: #00A000">+        }</span>
         cfg.t.cfg.s.sdDLSAP.dstProcId                = SFndProcId();                                /* the procid of MAC/L1/MTP1 */
         cfg.t.cfg.s.sdDLSAP.entMac                        = ENTL1;                                        /* entity for MAC */
         cfg.t.cfg.s.sdDLSAP.instMac                        = S_INST;                                        /* instance for MAC */
<span style="color: #800080; font-weight: bold">@@ -646,22 +811,22 @@ int ftmod_ss7_mtp2_dlsap_config(int id)</span>
         cfg.t.cfg.s.sdDLSAP.memMac.region        = S_REG;                                        /* memory region and pool id for MAC */
         cfg.t.cfg.s.sdDLSAP.memMac.pool                = S_POOL;
         cfg.t.cfg.s.sdDLSAP.maxOutsFrms                = MAX_SD_OUTSTANDING;                /* maximum outstanding frames */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.errType                        = k-&gt;mtp2.errorType;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.errType                        = k-&gt;errorType;</span>
         cfg.t.cfg.s.sdDLSAP.t1.enb                        = TRUE;                                                /* timer 1 - Alignment Ready Timer */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.t1.val                        = k-&gt;mtp2.t1;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.t1.val                        = k-&gt;t1;</span>
         cfg.t.cfg.s.sdDLSAP.t2.enb                        = TRUE;                                                /* timer 2 - Not Aligned Timer */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.t2.val                        = k-&gt;mtp2.t2;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.t2.val                        = k-&gt;t2;</span>
         cfg.t.cfg.s.sdDLSAP.t3.enb                        = TRUE;                                                /* timer 3 - Aligned Timer */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.t3.val                        = k-&gt;mtp2.t3;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.t3.val                        = k-&gt;t3;</span>
         cfg.t.cfg.s.sdDLSAP.t5.enb                        = TRUE;                                                /* timer 5 - Sending SIB timer */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.t5.val                        = k-&gt;mtp2.t5;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.t5.val                        = k-&gt;t5;</span>
         cfg.t.cfg.s.sdDLSAP.t6.enb                        = TRUE;                                                /* timer 6 - Remote Congestion Timer */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.t6.val                        = k-&gt;mtp2.t6;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.t6.val                        = k-&gt;t6;</span>
         cfg.t.cfg.s.sdDLSAP.t7.enb                        = TRUE;                                                /* timer 7 - Excessive delay of acknowledgement timer */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.t7.val                        = k-&gt;mtp2.t7;</span>
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.provEmrgcy                = k-&gt;mtp2.t4e;                                /* emergency proving period */</span>
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.provNormal                = k-&gt;mtp2.t4n;                                /* normal proving period */</span>
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.lssuLen                        = k-&gt;mtp2.lssuLength;                        /* one or two byte LSSU length */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.t7.val                        = k-&gt;t7;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.provEmrgcy                = k-&gt;t4e;                                /* emergency proving period */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.provNormal                = k-&gt;t4n;                                /* normal proving period */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.lssuLen                        = k-&gt;lssuLength;                        /* one or two byte LSSU length */</span>
         cfg.t.cfg.s.sdDLSAP.maxFrmLen                = MAX_SD_FRAME_LEN;                        /* max frame length for MSU */
         cfg.t.cfg.s.sdDLSAP.congDisc                = FALSE;                                        /* congestion discard TRUE or FALSE */
         cfg.t.cfg.s.sdDLSAP.sdT                                = MAX_SD_SUERM;                                /* SUERM error rate threshold */
<span style="color: #800080; font-weight: bold">@@ -670,7 +835,7 @@ int ftmod_ss7_mtp2_dlsap_config(int id)</span>
         cfg.t.cfg.s.sdDLSAP.sdN1                        = MAX_SD_MSU_RETRANS;                /* maximum number of MSUs for retransmission */
         cfg.t.cfg.s.sdDLSAP.sdN2                        = MAX_SD_OCTETS_RETRANS;        /* maximum number of MSU octets for retrans */
         cfg.t.cfg.s.sdDLSAP.sdCp                        = MAX_SD_ALIGN_ATTEMPTS;        /* maximum number of alignment attempts */
<span style="color: #A00000">-        cfg.t.cfg.s.sdDLSAP.spIdSE                        = k-&gt;mtp2.mtp1Id;                                /* service provider id */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.sdDLSAP.spIdSE                        = k-&gt;mtp1Id;                                /* service provider id */</span>
         cfg.t.cfg.s.sdDLSAP.sdtFlcStartTr        = 256;                                                /* SDT interface flow control start thresh */
         cfg.t.cfg.s.sdDLSAP.sdtFlcEndTr                = 512;                                                /* SDT interface flow control end thresh */
 
<span style="color: #800080; font-weight: bold">@@ -707,7 +872,6 @@ int ftmod_ss7_mtp2_dlsap_config(int id)</span>
 #endif /*RUG*/
 
         return(sng_cfg_mtp2(&amp;pst, &amp;cfg));
<span style="color: #A00000">-        return 0;</span>
 }
 
 /******************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -715,7 +879,7 @@ int ftmod_ss7_mtp3_dlsap_config(int id)</span>
 {
         Pst                                pst;
         SnMngmt                        cfg;
<span style="color: #A00000">-        sng_mtp_link_t        *k = &amp;g_ftdm_sngss7_data.cfg.mtpLink[id];</span>
<span style="color: #00A000">+        sng_mtp3_link_t        *k = &amp;g_ftdm_sngss7_data.cfg.mtp3Link[id];</span>
 
 
         /* initalize the post structure */
<span style="color: #800080; font-weight: bold">@@ -738,14 +902,14 @@ int ftmod_ss7_mtp3_dlsap_config(int id)</span>
 
         cfg.hdr.elmId.elmntInst1                         = k-&gt;id;
 
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.lnkSetId                = k-&gt;mtp3.linkSetId;        /* link set ID */</span>
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.opc                                = k-&gt;mtp3.spc;                        /* Originating Postatic int Code */</span>
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.adjDpc                        = k-&gt;mtp3.apc;                        /* Adlacent Destination Postatic int Code */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.lnkSetId                = k-&gt;linkSetId;                        /* link set ID */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.opc                                = k-&gt;spc;                                /* Originating Postatic int Code */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.adjDpc                        = k-&gt;apc;                                /* Adlacent Destination Postatic int Code */</span>
         cfg.t.cfg.s.snDLSAP.lnkPrior                = 0;                                        /* link priority within the link set */
         cfg.t.cfg.s.snDLSAP.msgSize                        = MAX_SN_MSG_SIZE;                /* message length */
         cfg.t.cfg.s.snDLSAP.msgPrior                = 0;                                        /* management message priority */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.lnkType                        = k-&gt;mtp3.linkType;                /* link type ANSI, ITU, BICI or CHINA */</span>
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.upSwtch                        = k-&gt;mtp3.switchType;        /* user part switch type */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.lnkType                        = k-&gt;linkType;                        /* link type ANSI, ITU, BICI or CHINA */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.upSwtch                        = k-&gt;switchType;                /* user part switch type */</span>
         cfg.t.cfg.s.snDLSAP.maxSLTtry                = MAX_SLTM_RETRIES;                /* maximun times to retry SLTM */
         cfg.t.cfg.s.snDLSAP.p0QLen                        = 32;                                        /* size of the priority 0 Q */
         cfg.t.cfg.s.snDLSAP.p1QLen                        = 32;                                        /* size of the priority 1 Q */
<span style="color: #800080; font-weight: bold">@@ -756,7 +920,7 @@ int ftmod_ss7_mtp3_dlsap_config(int id)</span>
         cfg.t.cfg.s.snDLSAP.maxCredit                = MAX_SN_CREDIT;                /* max credit */
 #endif /* SDT2 */
         cfg.t.cfg.s.snDLSAP.lnkId                        = 0;                                        /* signalling link allocation procedure identity */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.lnkTstSLC                = k-&gt;mtp3.slc;                        /* link selection code for link test */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.lnkTstSLC                = k-&gt;slc;                                /* link selection code for link test */</span>
         cfg.t.cfg.s.snDLSAP.tstLen                        = 6;                                        /* link test pattern length */
         cfg.t.cfg.s.snDLSAP.tst[0]                        = &#39;K&#39;;                                        /* link test pattern */
         cfg.t.cfg.s.snDLSAP.tst[1]                        = &#39;O&#39;;                                        /* link test pattern */
<span style="color: #800080; font-weight: bold">@@ -764,8 +928,8 @@ int ftmod_ss7_mtp3_dlsap_config(int id)</span>
         cfg.t.cfg.s.snDLSAP.tst[3]                        = &#39;R&#39;;                                        /* link test pattern */
         cfg.t.cfg.s.snDLSAP.tst[4]                        = &#39;A&#39;;                                        /* link test pattern */
         cfg.t.cfg.s.snDLSAP.tst[5]                        = &#39;D&#39;;                                        /* link test pattern */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.ssf                                = k-&gt;mtp3.ssf;                        /* sub service field */ </span>
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.dstProcId                = SFndProcId();                        /* destination processor id */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.ssf                                = k-&gt;ssf;                                /* sub service field */ </span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.dstProcId                = k-&gt;mtp2ProcId;                /* destination processor id */</span>
         cfg.t.cfg.s.snDLSAP.dstEnt                        = ENTSD;                                /* entity */
         cfg.t.cfg.s.snDLSAP.dstInst                        = S_INST;                                /* instance */
         cfg.t.cfg.s.snDLSAP.prior                        = PRIOR0;                                /* priority */
<span style="color: #800080; font-weight: bold">@@ -773,9 +937,9 @@ int ftmod_ss7_mtp3_dlsap_config(int id)</span>
         cfg.t.cfg.s.snDLSAP.selector                = 0;                                        /* lower layer selector */
         cfg.t.cfg.s.snDLSAP.mem.region                = S_REG;                                /* memory region id */
         cfg.t.cfg.s.snDLSAP.mem.pool                = S_POOL;                                /* memory pool id */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.spId                        = k-&gt;mtp3.mtp2Id                /* service provider id */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.spId                        = k-&gt;mtp2Id;                        /* service provider id */</span>
 
<span style="color: #A00000">-        switch (k-&gt;mtp3.linkType) {</span>
<span style="color: #00A000">+        switch (k-&gt;linkType) {</span>
         /**************************************************************************/
         case (LSN_SW_ANS):
         case (LSN_SW_ANS96):
<span style="color: #800080; font-weight: bold">@@ -793,9 +957,9 @@ int ftmod_ss7_mtp3_dlsap_config(int id)</span>
                 cfg.t.cfg.s.snDLSAP.dpcLen                = DPC14;                                /* dpc length 14 bits */
                 break;
         /**************************************************************************/
<span style="color: #A00000">-        } /* switch (k-&gt;mtp3.linkType) */</span>
<span style="color: #00A000">+        } /* switch (k-&gt;linkType) */</span>
 
<span style="color: #A00000">-        switch (k-&gt;mtp3.linkType) {</span>
<span style="color: #00A000">+        switch (k-&gt;linkType) {</span>
         /**************************************************************************/
         case (LSN_SW_ANS):
         case (LSN_SW_ANS96):
<span style="color: #800080; font-weight: bold">@@ -811,51 +975,51 @@ int ftmod_ss7_mtp3_dlsap_config(int id)</span>
                 cfg.t.cfg.s.snDLSAP.flushContFlag        = FALSE;                        /* flush continue handling */
                 break;
         /**************************************************************************/
<span style="color: #A00000">-        } /* switch (k-&gt;mtp3.linkType) */</span>
<span style="color: #00A000">+        } /* switch (k-&gt;linkType) */</span>
 
         cfg.t.cfg.s.snDLSAP.tmr.t1.enb                = TRUE;                                        /* t1 - delay to avoid missequencing on changeover */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t1.val                = k-&gt;mtp3.t1;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t1.val                = k-&gt;t1;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t2.enb                = TRUE;                                        /* t2 - waiting for changeover ack */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t2.val                = k-&gt;mtp3.t2;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t2.val                = k-&gt;t2;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t3.enb                = TRUE;                                        /* t3 - delay to avoid missequencing on changeback */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t3.val                = k-&gt;mtp3.t3;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t3.val                = k-&gt;t3;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t4.enb                = TRUE;                                        /* t4 - waiting for first changeback ack */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t4.val                = k-&gt;mtp3.t4;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t4.val                = k-&gt;t4;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t5.enb                = TRUE;                                        /* t5 - waiting for second changeback ack */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t5.val                = k-&gt;mtp3.t5;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t5.val                = k-&gt;t5;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t7.enb                = TRUE;                                        /* t7 - waiting for link connection ack */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t7.val                = k-&gt;mtp3.t7;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t7.val                = k-&gt;t7;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t12.enb                = TRUE;                                        /* t12 - waiting for uninhibit ack */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t12.val                = k-&gt;mtp3.t12;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t12.val                = k-&gt;t12;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t13.enb                = TRUE;                                        /* t13 - waiting for forced uninhibit */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t13.val                = k-&gt;mtp3.t13;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t13.val                = k-&gt;t13;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t14.enb                = TRUE;                                        /* t14 - waiting for inhibition ack */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t14.val                = k-&gt;mtp3.t14;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t14.val                = k-&gt;t14;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t17.enb                = TRUE;                                        /* t17 - delay to avoid oscillation of initial alignment failure */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t17.val                = k-&gt;mtp3.t17;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t17.val                = k-&gt;t17;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t22.enb                = TRUE;                                        /* t22 - local inhibit test timer */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t22.val                = k-&gt;mtp3.t22;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t22.val                = k-&gt;t22;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t23.enb                = TRUE;                                        /* t23 - remote inhibit test timer */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t23.val                = k-&gt;mtp3.t23;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t23.val                = k-&gt;t23;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t24.enb                = TRUE;                                        /* t24 - stabilizing timer */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t24.val                = k-&gt;mtp3.t24;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t24.val                = k-&gt;t24;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t31.enb                = TRUE;                                        /* t31 - BSN requested timer */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t31.val                = k-&gt;mtp3.t31;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t31.val                = k-&gt;t31;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t32.enb                = TRUE;                                        /* t32 - SLT timer */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t32.val                = k-&gt;mtp3.t32;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t32.val                = k-&gt;t32;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t33.enb                = TRUE;                                        /* t33 - connecting timer */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t33.val                = k-&gt;mtp3.t33;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t33.val                = k-&gt;t33;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t34.enb                = TRUE;                                        /* t34 - periodic signalling link test timer */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t34.val                = k-&gt;mtp3.t34;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t34.val                = k-&gt;t34;</span>
 #if (SS7_ANS92 || SS7_ANS88 || SS7_ANS96 || defined(TDS_ROLL_UPGRADE_SUPPORT))
         cfg.t.cfg.s.snDLSAP.tmr.t35.enb                = TRUE;                                        /* t35 - false link congestion timer, same as t31 of ANSI&#39;96*/
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t35.val                = k-&gt;mtp3.t35;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t35.val                = k-&gt;t35;</span>
         cfg.t.cfg.s.snDLSAP.tmr.t36.enb                = TRUE;                                        /* t36 - false link congestion timer, same as t33 of ANSI&#39;96*/
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t36.val                = k-&gt;mtp3.t36;        </span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t36.val                = k-&gt;t36;        </span>
         cfg.t.cfg.s.snDLSAP.tmr.t37.enb                = TRUE;                                        /* t37 - false link congestion timer, same as t34 of ANSI&#39;96*/
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.t37.val                = k-&gt;mtp3.t37;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.t37.val                = k-&gt;t37;</span>
         cfg.t.cfg.s.snDLSAP.tmr.tCraft.enb        = TRUE;                                        /* link referral craft timer - T19 in ANSI */
<span style="color: #A00000">-        cfg.t.cfg.s.snDLSAP.tmr.tCraft.val        = k-&gt;mtp3.tcraft;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.snDLSAP.tmr.tCraft.val        = k-&gt;tcraft;</span>
 #endif
 #ifdef SDT2
         cfg.t.cfg.s.snDLSAP.tmr.tFlc.enb        = TRUE;                                        /* flow control timer */
<span style="color: #800080; font-weight: bold">@@ -1217,6 +1381,11 @@ int ftmod_ss7_isup_ckt_config(int id)</span>
         /* insert the destination Entity */
         pst.dstEnt = ENTSI;
 
<span style="color: #00A000">+        /* check the for the correct ProcId and make sure it goes to the right system */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.procId != 1) {</span>
<span style="color: #00A000">+                pst.dstProcId = 1;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         /*clear the configuration structure*/
         memset(&amp;cfg, 0x0, sizeof(SiMngmt));
 
<span style="color: #800080; font-weight: bold">@@ -1417,11 +1586,11 @@ int ftmod_ss7_isup_isap_config(int id)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_cc_isap_config(int id)</span>
<span style="color: #00A000">+int ftmod_ss7_cc_isap_config(int dstProcId)</span>
 {
         CcMngmt         cfg;
         Pst                 pst;
<span style="color: #A00000">-        sng_isap_t        *k = &amp;g_ftdm_sngss7_data.cfg.isap[id];</span>
<span style="color: #00A000">+</span>
 
         /* initalize the post structure */
         smPstInit(&amp;pst);
<span style="color: #800080; font-weight: bold">@@ -1441,11 +1610,11 @@ int ftmod_ss7_cc_isap_config(int id)</span>
         cfg.hdr.entId.inst                                        = S_INST;
         cfg.hdr.elmId.elmnt                                        = STISAP;
 
<span style="color: #A00000">-        cfg.hdr.elmId.elmntInst1                         = k-&gt;id;</span>
<span style="color: #00A000">+        cfg.hdr.elmId.elmntInst1                         = 1;</span>
 
<span style="color: #A00000">-        cfg.t.cfg.s.ccISAP.suId                                 = k-&gt;suId;</span>
<span style="color: #A00000">-        cfg.t.cfg.s.ccISAP.spId                                 = k-&gt;spId;</span>
<span style="color: #A00000">-        cfg.t.cfg.s.ccISAP.pst.dstProcId        = SFndProcId();</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ccISAP.suId                                 = 1;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ccISAP.spId                                 = 1;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ccISAP.pst.dstProcId        = dstProcId;</span>
         cfg.t.cfg.s.ccISAP.pst.dstEnt                = ENTSI;
         cfg.t.cfg.s.ccISAP.pst.dstInst                = S_INST;
         cfg.t.cfg.s.ccISAP.pst.srcProcId        = SFndProcId();
<span style="color: #800080; font-weight: bold">@@ -1461,6 +1630,70 @@ int ftmod_ss7_cc_isap_config(int id)</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+int ftmod_ss7_relay_chan_config(int id)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        RyMngmt        cfg;        /*configuration structure*/</span>
<span style="color: #00A000">+        Pst                pst;        /*post structure*/</span>
<span style="color: #00A000">+        sng_relay_t                *k = &amp;g_ftdm_sngss7_data.cfg.relay[id];</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTRY;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* clear the configuration structure */</span>
<span style="color: #00A000">+        memset(&amp;cfg, 0x0, sizeof(RyMngmt));</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* fill in some general sections of the header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cfg.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /*fill in the specific fields of the header */</span>
<span style="color: #00A000">+        cfg.hdr.msgType                                                        = TCFG;</span>
<span style="color: #00A000">+        cfg.hdr.entId.ent                                                 = ENTRY;</span>
<span style="color: #00A000">+        cfg.hdr.entId.inst                                                = S_INST;</span>
<span style="color: #00A000">+        cfg.hdr.elmId.elmnt                                         = STCHCFG;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cfg.hdr.elmId.elmntInst1                                 = k-&gt;id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.id                                = k-&gt;id;                                        /* channel id */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.type                                = k-&gt;type;                                        /* channel type */</span>
<span style="color: #00A000">+/*        cfg.t.cfg.s.ryChanCfg.msInd                                =;*/                                                /* master/slave indicator */</span>
<span style="color: #00A000">+        if (k-&gt;type == LRY_CT_TCP_LISTEN) {</span>
<span style="color: #00A000">+                cfg.t.cfg.s.ryChanCfg.low                        = 0;                                                /* low proc id for channel */</span>
<span style="color: #00A000">+                cfg.t.cfg.s.ryChanCfg.high                        = 0;                                                /* high proc id for channel */</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                cfg.t.cfg.s.ryChanCfg.low                        = k-&gt;procId;                                /* low proc id for channel */</span>
<span style="color: #00A000">+                cfg.t.cfg.s.ryChanCfg.high                        = k-&gt;procId;                                /* high proc id for channel */</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.nmbScanQ                        = MAX_RELAY_NMBSCAN;                /* number of times to scan the queue */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.flags                                = LRY_FLG_INTR;                                /* flags */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.congThrsh                        = MAX_RELAY_CONGTHRSH;                /* congestion threshold */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.dropThrsh                        = 0;                                                /* drop threshold */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.contThrsh                        = MAX_RELAY_CONGTHRSH + 1;        /* continue threshold */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.kaTxTmr.enb                = 1;                                                /* keep alive transmit timer config */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.kaTxTmr.val                = RY_TX_KP_ALIVE_TMR;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.kaRxTmr.enb                = 1;                                                /* keep alive receive timer config */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.kaRxTmr.val                = RY_RX_KP_ALIVE_TMR;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.btTmr.enb                        = 1;                                                /* boot timer */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.btTmr.val                        = RY_BT_TMR;</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.region                        = S_REG;                                        /* Relay region */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.pool                                = S_POOL;                                        /* Relay pool */</span>
<span style="color: #00A000">+#if (RY_ENBUDPSOCK || RY_ENBTCPSOCK) </span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.listenPortNo                = k-&gt;port;                                        /* Listen Port of Rx Relay Channel*/</span>
<span style="color: #00A000">+        strncpy(cfg.t.cfg.s.ryChanCfg.transmittoHostName, k-&gt;hostname, (size_t)RY_REMHOSTNAME_SIZE);</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.transmittoPortNo        = k-&gt;port;                                        /* TransmitTo PortId for Tx Relay Channel */</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.targetProcId                = k-&gt;procId;                                /* procId of the node present in the other end of this channel                     */</span>
<span style="color: #00A000">+# ifdef LRY1</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.sockParam                        =;   /* Socket Parameters */</span>
<span style="color: #00A000">+# endif /* LRY1 */</span>
<span style="color: #00A000">+# ifdef LRYV2</span>
<span style="color: #00A000">+        cfg.t.cfg.s.ryChanCfg.selfHostName[RY_REMHOSTNAME_SIZE];</span>
<span style="color: #00A000">+# endif /* LRY2 */</span>
<span style="color: #00A000">+#endif /* RY_ENBUDPSOCK || RY_ENBTCPSOCK */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return(sng_cfg_relay(&amp;pst, &amp;cfg));</span>
<span style="color: #00A000">+}</span>
 
 /******************************************************************************/
 /* For Emacs:
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c</span>
<span style="color: #000080; font-weight: bold">index dc2d24f..4ab4359 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c</span>
<span style="color: #800080; font-weight: bold">@@ -46,6 +46,8 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha</span>
 
 static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream);
 
<span style="color: #00A000">+static ftdm_status_t handle_show_procId(ftdm_stream_handle_t *stream);</span>
<span style="color: #00A000">+</span>
 static ftdm_status_t handle_set_function_trace(ftdm_stream_handle_t *stream, int on, int level);
 static ftdm_status_t handle_set_message_trace(ftdm_stream_handle_t *stream, int on, int level);
 static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name);
<span style="color: #800080; font-weight: bold">@@ -67,6 +69,8 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c</span>
 static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose);
 static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int chan, int range, int verbose);
 
<span style="color: #00A000">+static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name);</span>
<span style="color: #00A000">+static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name);</span>
 static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *name);
 static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *name);
 
<span style="color: #800080; font-weight: bold">@@ -76,9 +80,12 @@ static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, cha</span>
 static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name);
 static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name);
 
<span style="color: #A00000">-static ftdm_status_t handle_status_link(ftdm_stream_handle_t *stream, char *name);</span>
<span style="color: #00A000">+static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *name);</span>
<span style="color: #00A000">+static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *name);</span>
 static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *name);
 
<span style="color: #00A000">+static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *name);</span>
<span style="color: #00A000">+</span>
 static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan);
 static ftdm_status_t check_arg_count(int args, int min);
 /******************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -111,18 +118,29 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha</span>
 
                 if (!strcasecmp(argv[c], &quot;status&quot;)) {
                 /**********************************************************************/
<span style="color: #00A000">+                        if (check_arg_count(argc, 3)) goto handle_cli_error_argc;</span>
                         c++;
 
<span style="color: #A00000">-                        if (!strcasecmp(argv[c], &quot;link&quot;)) {</span>
<span style="color: #00A000">+                        if (!strcasecmp(argv[c], &quot;mtp3&quot;)) {</span>
<span style="color: #00A000">+                        /******************************************************************/</span>
<span style="color: #00A000">+                                c++;</span>
<span style="color: #00A000">+                                handle_status_mtp3link(stream, argv[c]);</span>
<span style="color: #00A000">+                        /******************************************************************/</span>
<span style="color: #00A000">+                        } else if (!strcasecmp(argv[c], &quot;mtp2&quot;)) {</span>
                         /******************************************************************/
                                 c++;
<span style="color: #A00000">-                                handle_status_link(stream, argv[c]);</span>
<span style="color: #00A000">+                                handle_status_mtp2link(stream, argv[c]);</span>
                         /******************************************************************/
                         } else if (!strcasecmp(argv[c], &quot;linkset&quot;)) {
                         /******************************************************************/
                                 c++;
                                 handle_status_linkset(stream, argv[c]);
                         /******************************************************************/
<span style="color: #00A000">+                        } else if (!strcasecmp(argv[c], &quot;relay&quot;)) {</span>
<span style="color: #00A000">+                        /******************************************************************/</span>
<span style="color: #00A000">+                                c++;</span>
<span style="color: #00A000">+                                handle_status_relay(stream, argv[c]);</span>
<span style="color: #00A000">+                        /******************************************************************/</span>
                         } else if (!strcasecmp(argv[c], &quot;span&quot;)) {
                         /******************************************************************/
                                 if (check_arg_count(argc, 6)) goto handle_cli_error_argc;
<span style="color: #800080; font-weight: bold">@@ -256,6 +274,10 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha</span>
                                                                                         sts.rx_frm, sts.rx_err, sts.rx_fisu, sts.rx_lssu, sts.rx_msu);
 */
                 /**********************************************************************/
<span style="color: #00A000">+                } else if (!strcasecmp(argv[c], &quot;procid&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        handle_show_procId(stream);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
                 } else {
                 /**********************************************************************/
                         stream-&gt;write_function(stream, &quot;Unknown \&quot;show\&quot; command\n&quot;);
<span style="color: #800080; font-weight: bold">@@ -534,6 +556,44 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha</span>
                 /**********************************************************************/
                 }
         /**************************************************************************/
<span style="color: #00A000">+        } else if (!strcasecmp(argv[c], &quot;bind&quot;)) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+                if (check_arg_count(argc, 2)) goto handle_cli_error_argc;</span>
<span style="color: #00A000">+                c++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (!strcasecmp(argv[c], &quot;link&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (check_arg_count(argc, 3)) goto handle_cli_error_argc;</span>
<span style="color: #00A000">+                        c++;</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                        handle_bind_link(stream, argv[c]);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        stream-&gt;write_function(stream, &quot;Unknown \&quot;bind\&quot; command\n&quot;);</span>
<span style="color: #00A000">+                        goto handle_cli_error;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } else if (!strcasecmp(argv[c], &quot;unbind&quot;)) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+                if (check_arg_count(argc, 2)) goto handle_cli_error_argc;</span>
<span style="color: #00A000">+                c++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (!strcasecmp(argv[c], &quot;link&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (check_arg_count(argc, 3)) goto handle_cli_error_argc;</span>
<span style="color: #00A000">+                        c++;</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                        handle_unbind_link(stream, argv[c]);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        stream-&gt;write_function(stream, &quot;Unknown \&quot;bind\&quot; command\n&quot;);</span>
<span style="color: #00A000">+                        goto handle_cli_error;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
         } else if (!strcasecmp(argv[c], &quot;activate&quot;)) {
         /**************************************************************************/
                 if (check_arg_count(argc, 2)) goto handle_cli_error_argc;
<span style="color: #800080; font-weight: bold">@@ -650,6 +710,16 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream)</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+static ftdm_status_t handle_show_procId(ftdm_stream_handle_t *stream)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int        procId = sng_get_procId();</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;Local ProcId = %d\n&quot;, procId);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
 static ftdm_status_t handle_set_function_trace(ftdm_stream_handle_t *stream, int on, int level)
 {
         stream-&gt;write_function(stream, &quot;ftmod_sangoma_ss7 Function Trace was %s, level = %d\n&quot;,
<span style="color: #800080; font-weight: bold">@@ -693,7 +763,7 @@ static ftdm_status_t handle_show_free(ftdm_stream_handle_t *stream, int span, in</span>
         int                                 lspan;
         int                                 lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         free = 0;
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
<span style="color: #800080; font-weight: bold">@@ -756,7 +826,7 @@ static ftdm_status_t handle_show_inuse(ftdm_stream_handle_t *stream, int span, i</span>
         int                                 lspan;
         int                                 lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         in_use = 0;
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
<span style="color: #800080; font-weight: bold">@@ -826,7 +896,7 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,</span>
         int                                 lspan;
         int                                 lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         in_reset = 0;
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
<span style="color: #800080; font-weight: bold">@@ -848,10 +918,10 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,</span>
                         }
 
                         if ((ftdmchan-&gt;physical_span_id == lspan) &amp;&amp; (ftdmchan-&gt;physical_chan_id == lchan)) {
<span style="color: #A00000">-                                if ((sngss7_test_flag(ss7_info, FLAG_RESET_RX)) ||</span>
<span style="color: #A00000">-                                        (sngss7_test_flag(ss7_info, FLAG_RESET_TX)) ||</span>
<span style="color: #A00000">-                                        (sngss7_test_flag(ss7_info, FLAG_GRP_RESET_RX)) ||</span>
<span style="color: #A00000">-                                        (sngss7_test_flag(ss7_info, FLAG_GRP_RESET_TX))) {</span>
<span style="color: #00A000">+                                if ((sngss7_test_ckt_flag(ss7_info, FLAG_RESET_RX)) ||</span>
<span style="color: #00A000">+                                        (sngss7_test_ckt_flag(ss7_info, FLAG_RESET_TX)) ||</span>
<span style="color: #00A000">+                                        (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_RESET_RX)) ||</span>
<span style="color: #00A000">+                                        (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_RESET_TX))) {</span>
                                         
                                         if (verbose) {
                                                 stream-&gt;write_function(stream, &quot;span=%2d|chan=%2d|cic=%4d|in_reset=Y\n&quot;,
<span style="color: #800080; font-weight: bold">@@ -862,7 +932,7 @@ static ftdm_status_t handle_show_inreset(ftdm_stream_handle_t *stream, int span,</span>
                 
                                         /*increment the count of circuits in reset */
                                         in_reset++;
<span style="color: #A00000">-                                } /* if ((sngss7_test_flag(ss7_info, FLAG_RESET_RX) ... */</span>
<span style="color: #00A000">+                                } /* if ((sngss7_test_ckt_flag(ss7_info, FLAG_RESET_RX) ... */</span>
                         } /* if ( span and chan) */
                 } /* if ( cic != 0) */
 
<span style="color: #800080; font-weight: bold">@@ -885,7 +955,7 @@ static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, i</span>
         int                                 lspan;
         int                                 lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
                         ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
<span style="color: #800080; font-weight: bold">@@ -913,7 +983,7 @@ static ftdm_status_t handle_show_flags(ftdm_stream_handle_t *stream, int span, i</span>
         
                                 for (bit = 0; bit &lt; 33; bit++) {
                                         stream-&gt;write_function(stream, &quot;|&quot;);
<span style="color: #A00000">-                                        if (ss7_info-&gt;flags &amp; ( 0x1 &lt;&lt; bit)) {</span>
<span style="color: #00A000">+                                        if (ss7_info-&gt;ckt_flags &amp; ( 0x1 &lt;&lt; bit)) {</span>
                                                 stream-&gt;write_function(stream, &quot;%2d=1&quot;, bit);
                                         } else {
                                                 stream-&gt;write_function(stream, &quot;%2d=0&quot;, bit);
<span style="color: #800080; font-weight: bold">@@ -941,7 +1011,7 @@ static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span,</span>
         int                                 lspan;
         int                                 lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
                         ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
<span style="color: #800080; font-weight: bold">@@ -967,37 +1037,37 @@ static ftdm_status_t handle_show_blocks(ftdm_stream_handle_t *stream, int span,</span>
                                                         ftdmchan-&gt;physical_chan_id,
                                                         ss7_info-&gt;circuit-&gt;cic);
 
<span style="color: #A00000">-                                if((sngss7_test_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
<span style="color: #00A000">+                                if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
                                         stream-&gt;write_function(stream, &quot;l_mn=Y|&quot;);
                                 }else {
                                         stream-&gt;write_function(stream, &quot;l_mn=N|&quot;);
                                 }
 
<span style="color: #A00000">-                                if((sngss7_test_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
<span style="color: #00A000">+                                if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
                                         stream-&gt;write_function(stream, &quot;r_mn=Y|&quot;);
                                 }else {
                                         stream-&gt;write_function(stream, &quot;r_mn=N|&quot;);
                                 }
 
<span style="color: #A00000">-                                if(sngss7_test_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {</span>
<span style="color: #00A000">+                                if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {</span>
                                         stream-&gt;write_function(stream, &quot;l_hw=Y|&quot;);
                                 }else {
                                         stream-&gt;write_function(stream, &quot;l_hw=N|&quot;);
                                 }
 
<span style="color: #A00000">-                                if(sngss7_test_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {</span>
<span style="color: #00A000">+                                if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {</span>
                                         stream-&gt;write_function(stream, &quot;r_hw=Y|&quot;);
                                 }else {
                                         stream-&gt;write_function(stream, &quot;r_hw=N|&quot;);
                                 }
 
<span style="color: #A00000">-                                if(sngss7_test_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX)) {</span>
<span style="color: #00A000">+                                if(sngss7_test_ckt_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX)) {</span>
                                         stream-&gt;write_function(stream, &quot;l_mngmt=Y|&quot;);
                                 }else {
                                         stream-&gt;write_function(stream, &quot;l_mngmt=N|&quot;);
                                 }
 
<span style="color: #A00000">-                                if(sngss7_test_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {</span>
<span style="color: #00A000">+                                if(sngss7_test_ckt_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {</span>
                                         stream-&gt;write_function(stream, &quot;l_ucic=Y|&quot;);
                                 }else {
                                         stream-&gt;write_function(stream, &quot;l_ucic=N|&quot;);
<span style="color: #800080; font-weight: bold">@@ -1026,7 +1096,7 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,</span>
         ftdm_signaling_status_t                sigstatus = FTDM_SIG_STATE_DOWN;
         sng_isup_ckt_t                                *ckt;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                         /* extract the circuit to make it easier to work with */
                         ckt = &amp;g_ftdm_sngss7_data.cfg.isupCkt[x];
<span style="color: #800080; font-weight: bold">@@ -1071,43 +1141,37 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,</span>
                                                                                                         ftdm_signaling_status2str(sigstatus),
                                                                                                         ftdm_channel_state2str(ftdmchan-&gt;state));
         
<span style="color: #A00000">-                                        if((sngss7_test_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
<span style="color: #00A000">+                                        if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
                                                 stream-&gt;write_function(stream, &quot;l_mn=Y|&quot;);
                                         }else {
                                                 stream-&gt;write_function(stream, &quot;l_mn=N|&quot;);
                                         }
         
<span style="color: #A00000">-                                        if((sngss7_test_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
<span style="color: #00A000">+                                        if((sngss7_test_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_RX)) || (sngss7_test_ckt_flag(ss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
                                                 stream-&gt;write_function(stream, &quot;r_mn=Y|&quot;);
                                         }else {
                                                 stream-&gt;write_function(stream, &quot;r_mn=N|&quot;);
                                         }
         
<span style="color: #A00000">-                                        if(sngss7_test_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {</span>
<span style="color: #00A000">+                                        if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_TX)) {</span>
                                                 stream-&gt;write_function(stream, &quot;l_hw=Y|&quot;);
                                         }else {
                                                 stream-&gt;write_function(stream, &quot;l_hw=N|&quot;);
                                         }
         
<span style="color: #A00000">-                                        if(sngss7_test_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {</span>
<span style="color: #00A000">+                                        if(sngss7_test_ckt_flag(ss7_info, FLAG_GRP_HW_BLOCK_RX)) {</span>
                                                 stream-&gt;write_function(stream, &quot;r_hw=Y|&quot;);
                                         }else {
                                                 stream-&gt;write_function(stream, &quot;r_hw=N|&quot;);
                                         }
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                                        if(sngss7_test_flag(ss7_info, FLAG_CKT_LC_BLOCK_RX)) {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_mngmt=Y|&quot;);</span>
<span style="color: #A00000">-                                        }else {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_mngmt=N|&quot;);</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                                        if(sngss7_test_flag(ss7_info, FLAG_CKT_UCIC_BLOCK)) {</span>
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_ucic=Y|&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                        if(sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) {</span>
<span style="color: #00A000">+                                                stream-&gt;write_function(stream, &quot;relay=Y|&quot;);</span>
                                         }else {
<span style="color: #A00000">-                                                stream-&gt;write_function(stream, &quot;l_ucic=N|&quot;);</span>
<span style="color: #A00000">-                                        }                                </span>
<span style="color: #00A000">+                                                stream-&gt;write_function(stream, &quot;relay=N|&quot;);</span>
<span style="color: #00A000">+                                        }                </span>
         
<span style="color: #A00000">-                                        stream-&gt;write_function(stream, &quot;flags=0x%X&quot;,ss7_info-&gt;flags);</span>
<span style="color: #00A000">+                                        stream-&gt;write_function(stream, &quot;flags=0x%X&quot;,ss7_info-&gt;ckt_flags);</span>
         
                                         stream-&gt;write_function(stream, &quot;\n&quot;);
                                 } /* if ( hole, sig, voice) */
<span style="color: #800080; font-weight: bold">@@ -1127,7 +1191,7 @@ static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int c</span>
         int                                 lspan;
         int                                 lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
                         ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
<span style="color: #800080; font-weight: bold">@@ -1162,7 +1226,7 @@ static ftdm_status_t handle_tx_blo(ftdm_stream_handle_t *stream, int span, int c</span>
                                         continue;
                                 } else {
                                         /* throw the ckt block flag */
<span style="color: #A00000">-                                        sngss7_set_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);</span>
<span style="color: #00A000">+                                        sngss7_set_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);</span>
 
                                         /* set the channel to suspended state */
                                         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1193,7 +1257,7 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c</span>
         int                                 lspan;
         int                                 lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
                         ss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
<span style="color: #800080; font-weight: bold">@@ -1228,10 +1292,10 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c</span>
                                         continue;
                                 } else {
                                         /* throw the ckt block flag */
<span style="color: #A00000">-                                        sngss7_set_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX);</span>
<span style="color: #00A000">+                                        sngss7_set_ckt_flag(ss7_info, FLAG_CKT_MN_UNBLK_TX);</span>
 
                                         /* clear the block flag */
<span style="color: #A00000">-                                        sngss7_clear_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);</span>
<span style="color: #00A000">+                                        sngss7_clear_ckt_flag(ss7_info, FLAG_CKT_MN_BLOCK_TX);</span>
 
                                         /* set the channel to suspended state */
                                         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1254,18 +1318,18 @@ static ftdm_status_t handle_tx_ubl(ftdm_stream_handle_t *stream, int span, int c</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-static ftdm_status_t handle_status_link(ftdm_stream_handle_t *stream, char *name)</span>
<span style="color: #00A000">+static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *name)</span>
 {
         int                 x = 0;
         SnMngmt                sta;
         
         /* find the link request by it&#39;s name */
         x = 1;
<span style="color: #A00000">-        while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
 
                         /* send the status request */
<span style="color: #A00000">-                        if (ftmod_ss7_mtplink_sta(x, &amp;sta)) {</span>
<span style="color: #00A000">+                        if (ftmod_ss7_mtp3link_sta(x, &amp;sta)) {</span>
                                 stream-&gt;write_function(stream, &quot;Failed to read link=%s status\n&quot;, name);
                                 return FTDM_FAIL;
                         }
<span style="color: #800080; font-weight: bold">@@ -1273,9 +1337,9 @@ static ftdm_status_t handle_status_link(ftdm_stream_handle_t *stream, char *name</span>
                         /* print the results */
                         stream-&gt;write_function(stream, &quot;%s|span=%d|chan=%d|sap=%d|state=%s|l_blk=%s|r_blk=%s|l_inhbt=%s|r_inhbt=%s\n&quot;,
                                                 name,
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.mtpLink[x].mtp1.span,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.mtpLink[x].mtp1.chan,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.mtpLink[x].id,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.mtp1Link[x].span,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.mtp1Link[x].chan,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.mtp3Link[x].id,</span>
                                                 DECODE_LSN_LINK_STATUS(sta.t.ssta.s.snDLSAP.state),
                                                 (sta.t.ssta.s.snDLSAP.locBlkd) ? &quot;Y&quot;:&quot;N&quot;,
                                                 (sta.t.ssta.s.snDLSAP.remBlkd) ? &quot;Y&quot;:&quot;N&quot;,
<span style="color: #800080; font-weight: bold">@@ -1296,6 +1360,50 @@ success:</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *name)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int                 x = 0;</span>
<span style="color: #00A000">+        SdMngmt                sta;</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        /* find the link request by it&#39;s name */</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* send the status request */</span>
<span style="color: #00A000">+                        if (ftmod_ss7_mtp2link_sta(x, &amp;sta)) {</span>
<span style="color: #00A000">+                                stream-&gt;write_function(stream, &quot;Failed to read link=%s status\n&quot;, name);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* print the results */</span>
<span style="color: #00A000">+                        stream-&gt;write_function(stream, &quot;%s|span=%d|chan=%d|sap=%d|state=%s|outsFrm=%d|drpdFrm=%d|lclStatus=%s|rmtStatus=%s|fsn=%d|bsn=%d\n&quot;,</span>
<span style="color: #00A000">+                                                name,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.mtp1Link[x].span,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.mtp1Link[x].chan,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.mtp2Link[x].id,</span>
<span style="color: #00A000">+                                                DECODE_LSD_LINK_STATUS(sta.t.ssta.s.sdDLSAP.hlSt),</span>
<span style="color: #00A000">+                                                sta.t.ssta.s.sdDLSAP.psOutsFrm,</span>
<span style="color: #00A000">+                                                sta.t.ssta.s.sdDLSAP.cntMaDrop,</span>
<span style="color: #00A000">+                                                (sta.t.ssta.s.sdDLSAP.lclBsy) ? &quot;Y&quot;:&quot;N&quot;,</span>
<span style="color: #00A000">+                                                (sta.t.ssta.s.sdDLSAP.remBsy) ? &quot;Y&quot;:&quot;N&quot;,</span>
<span style="color: #00A000">+                                                sta.t.ssta.s.sdDLSAP.fsn,</span>
<span style="color: #00A000">+                                                sta.t.ssta.s.sdDLSAP.bsn);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        goto success;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                /* move to the next link */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        } /* while (id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;Failed to find link=\&quot;%s\&quot;\n&quot;, name);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+success:</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
 static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *name)
 {
         int                 x = 0;
<span style="color: #800080; font-weight: bold">@@ -1338,17 +1446,17 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name</span>
 
         /* find the link request by it&#39;s name */
         x = 1;
<span style="color: #A00000">-        while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
 
                         /* send the inhibit request */
<span style="color: #A00000">-                        if (ftmod_ss7_inhibit_mtplink(x)) {</span>
<span style="color: #00A000">+                        if (ftmod_ss7_inhibit_mtp3link(x)) {</span>
                                 stream-&gt;write_function(stream, &quot;Failed to inhibit link=%s\n&quot;, name);
                                 return FTDM_FAIL;
                         }
 
                         /* print the new status of the link */
<span style="color: #A00000">-                        handle_status_link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
 
                         goto success;
                 }
<span style="color: #800080; font-weight: bold">@@ -1370,17 +1478,17 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na</span>
 
         /* find the link request by it&#39;s name */
         x = 1;
<span style="color: #A00000">-        while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
 
                         /* send the uninhibit request */
<span style="color: #A00000">-                        if (ftmod_ss7_uninhibit_mtplink(x)) {</span>
<span style="color: #00A000">+                        if (ftmod_ss7_uninhibit_mtp3link(x)) {</span>
                                 stream-&gt;write_function(stream, &quot;Failed to uninhibit link=%s\n&quot;, name);
                                 return FTDM_FAIL;
                         }
 
                         /* print the new status of the link */
<span style="color: #A00000">-                        handle_status_link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
 
                         goto success;
                 }
<span style="color: #800080; font-weight: bold">@@ -1404,7 +1512,7 @@ static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int c</span>
         int                                         lspan;
         int                                         lchan;
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
                         sngss7_info = (sngss7_chan_data_t *)g_ftdm_sngss7_data.cfg.isupCkt[x].obj;
<span style="color: #800080; font-weight: bold">@@ -1429,7 +1537,7 @@ static ftdm_status_t handle_tx_rsc(ftdm_stream_handle_t *stream, int span, int c</span>
                                 ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
                                 /* throw the reset flag */
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_RESET_TX);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);</span>
 
                                 switch (ftdmchan-&gt;state) {
                                 /**************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -1476,7 +1584,7 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c</span>
                 return FTDM_SUCCESS;
         }
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
 
<span style="color: #800080; font-weight: bold">@@ -1500,9 +1608,9 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c</span>
                                         continue;
                                 } else {
                                         /* throw the grp reset flag */
<span style="color: #A00000">-                                        sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
<span style="color: #00A000">+                                        sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
                                         if (ftdmchan-&gt;physical_chan_id == chan) {
<span style="color: #A00000">-                                                sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_BASE);</span>
<span style="color: #00A000">+                                                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE);</span>
                                                 sngss7_span-&gt;tx_grs.circuit = sngss7_info-&gt;circuit-&gt;id;
                                                 sngss7_span-&gt;tx_grs.range = range-1;
                                         }
<span style="color: #800080; font-weight: bold">@@ -1523,7 +1631,7 @@ static ftdm_status_t handle_tx_grs(ftdm_stream_handle_t *stream, int span, int c</span>
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x]id != 0) */
         
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
 
<span style="color: #800080; font-weight: bold">@@ -1565,7 +1673,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c</span>
                 return FTDM_SUCCESS;
         }
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
 
<span style="color: #800080; font-weight: bold">@@ -1582,7 +1690,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c</span>
                                 ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
                                 /* throw the grp maint. block flag */
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);</span>
 
                                 /* bring the sig status down */
                                 sigev.chan_id = ftdmchan-&gt;chan_id;
<span style="color: #800080; font-weight: bold">@@ -1622,7 +1730,7 @@ static ftdm_status_t handle_tx_cgb(ftdm_stream_handle_t *stream, int span, int c</span>
         /* send the circuit group block */
         ft_to_sngss7_cgb(main_chan);
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
 
<span style="color: #800080; font-weight: bold">@@ -1665,7 +1773,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c</span>
                 return FTDM_SUCCESS;
         }
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
 
<span style="color: #800080; font-weight: bold">@@ -1682,7 +1790,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c</span>
                                 ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
                                 /* throw the grp maint. block flag */
<span style="color: #A00000">-                                sngss7_clear_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);</span>
<span style="color: #00A000">+                                sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX);</span>
 
                                 /* bring the sig status up */
                                 sigev.chan_id = ftdmchan-&gt;chan_id;
<span style="color: #800080; font-weight: bold">@@ -1722,7 +1830,7 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c</span>
         /* send the circuit group block */
         ft_to_sngss7_cgu(main_chan);
 
<span style="color: #A00000">-        x=1;</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
                 if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {
 
<span style="color: #800080; font-weight: bold">@@ -1746,23 +1854,85 @@ static ftdm_status_t handle_tx_cgu(ftdm_stream_handle_t *stream, int span, int c</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int                x = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* find the link request by it&#39;s name */</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* send the uninhibit request */</span>
<span style="color: #00A000">+                        if (ftmod_ss7_bind_mtp3link(g_ftdm_sngss7_data.cfg.mtp3Link[x].mtp2Id)) {</span>
<span style="color: #00A000">+                                stream-&gt;write_function(stream, &quot;Failed to bind link=%s\n&quot;, name);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* print the new status of the link */</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        goto success;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+ </span>
<span style="color: #00A000">+                /* move to the next link */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        } /* while (id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;Could not find link=%s\n&quot;, name);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+success:</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int                x = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* find the link request by it&#39;s name */</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* send the uninhibit request */</span>
<span style="color: #00A000">+                        if (ftmod_ss7_unbind_mtp3link(g_ftdm_sngss7_data.cfg.mtp3Link[x].mtp2Id)) {</span>
<span style="color: #00A000">+                                stream-&gt;write_function(stream, &quot;Failed to bind link=%s\n&quot;, name);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* print the new status of the link */</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        goto success;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+ </span>
<span style="color: #00A000">+                /* move to the next link */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        } /* while (id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        stream-&gt;write_function(stream, &quot;Could not find link=%s\n&quot;, name);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+success:</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
 static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *name)
 {
         int                x = 0;
 
         /* find the link request by it&#39;s name */
         x = 1;
<span style="color: #A00000">-        while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
 
                         /* send the uninhibit request */
<span style="color: #A00000">-                        if (ftmod_ss7_activate_mtplink(x)) {</span>
<span style="color: #00A000">+                        if (ftmod_ss7_activate_mtp3link(x)) {</span>
                                 stream-&gt;write_function(stream, &quot;Failed to activate link=%s\n&quot;, name);
                                 return FTDM_FAIL;
                         }
 
                         /* print the new status of the link */
<span style="color: #A00000">-                        handle_status_link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
                         goto success;
                 }
  
<span style="color: #800080; font-weight: bold">@@ -1783,17 +1953,17 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *</span>
 
         /* find the link request by it&#39;s name */
         x = 1;
<span style="color: #A00000">-        while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
 
                         /* send the deactivate request */
<span style="color: #A00000">-                        if (ftmod_ss7_deactivate2_mtplink(x)) {</span>
<span style="color: #00A000">+                        if (ftmod_ss7_deactivate2_mtp3link(x)) {</span>
                                 stream-&gt;write_function(stream, &quot;Failed to deactivate link=%s\n&quot;, name);
                                 return FTDM_FAIL;
                         }
 
                         /* print the new status of the link */
<span style="color: #A00000">-                        handle_status_link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
                         goto success;
                 }
  
<span style="color: #800080; font-weight: bold">@@ -1877,17 +2047,17 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name)</span>
 
         /* find the link request by it&#39;s name */
         x = 1;
<span style="color: #A00000">-        while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
 
                         /* send the uninhibit request */
<span style="color: #A00000">-                        if (ftmod_ss7_lpo_mtplink(x)) {</span>
<span style="color: #00A000">+                        if (ftmod_ss7_lpo_mtp3link(x)) {</span>
                                 stream-&gt;write_function(stream, &quot;Failed set LPO link=%s\n&quot;, name);
                                 return FTDM_FAIL;
                         }
 
                         /* print the new status of the link */
<span style="color: #A00000">-                        handle_status_link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
                         goto success;
                 }
  
<span style="color: #800080; font-weight: bold">@@ -1908,17 +2078,17 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name)</span>
 
         /* find the link request by it&#39;s name */
         x = 1;
<span style="color: #A00000">-        while(g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLink[x].name, name)) {</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {</span>
 
                         /* send the uninhibit request */
<span style="color: #A00000">-                        if (ftmod_ss7_lpr_mtplink(x)) {</span>
<span style="color: #00A000">+                        if (ftmod_ss7_lpr_mtp3link(x)) {</span>
                                 stream-&gt;write_function(stream, &quot;Failed set LPR link=%s\n&quot;, name);
                                 return FTDM_FAIL;
                         }
 
                         /* print the new status of the link */
<span style="color: #A00000">-                        handle_status_link(stream, &amp;name[0]);</span>
<span style="color: #00A000">+                        handle_status_mtp3link(stream, &amp;name[0]);</span>
                         goto success;
                 }
  
<span style="color: #800080; font-weight: bold">@@ -1933,6 +2103,47 @@ success:</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *name)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        RyMngmt        sta;</span>
<span style="color: #00A000">+        int                x = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        memset(&amp;sta, 0x0, sizeof(sta));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* find the channel request by it&#39;s name */</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        while(g_ftdm_sngss7_data.cfg.relay[x].id != 0) {</span>
<span style="color: #00A000">+                if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[x].id, &amp;sta)) {</span>
<span style="color: #00A000">+                                stream-&gt;write_function(stream, &quot;Failed to read relay =%s status\n&quot;, name);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* print the results */</span>
<span style="color: #00A000">+                        stream-&gt;write_function(stream, &quot;%s|sap=%d|type=%d|port=%d|hostname=%s|procId=%d|status=%s\n&quot;,</span>
<span style="color: #00A000">+                                                name,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.relay[x].id,        </span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.relay[x].type,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.relay[x].port,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.relay[x].hostname,</span>
<span style="color: #00A000">+                                                g_ftdm_sngss7_data.cfg.relay[x].procId,</span>
<span style="color: #00A000">+                                                DECODE_LRY_CHAN_STATUS(sta.t.ssta.rySta.cStatus));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        goto success;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                /* move to the next link */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        } /* g_ftdm_sngss7_data.cfg.relay[x].id */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+success:</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
 static ftdm_status_t extract_span_chan(char *argv[10], int pos, int *span, int *chan)
 {
 
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c</span>
<span style="color: #000080; font-weight: bold">index 87733dd..c1b18e5 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c</span>
<span style="color: #800080; font-weight: bold">@@ -48,19 +48,31 @@ static int ftmod_ss7_enable_isap(int suId);</span>
 static int ftmod_ss7_enable_nsap(int suId);
 static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId);
 
<span style="color: #A00000">-int ftmod_ss7_inhibit_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_uninhibit_mtplink(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_inhibit_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_uninhibit_mtp3link(uint32_t id);</span>
 
<span style="color: #A00000">-int ftmod_ss7_activate_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_deactivate_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_deactivate2_mtplink(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_bind_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_unbind_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_activate_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_deactivate_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_deactivate2_mtp3link(uint32_t id);</span>
 
 int ftmod_ss7_activate_mtplinkSet(uint32_t id);
 int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
 int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
 
<span style="color: #A00000">-int ftmod_ss7_lpo_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_lpr_mtplink(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_lpo_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_lpr_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_isup(void);</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_mtp3(void);</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_mtp2(void);</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_relay(void);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);</span>
<span style="color: #00A000">+int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);</span>
 /******************************************************************************/
 
 /* FUNCTIONS ******************************************************************/
<span style="color: #800080; font-weight: bold">@@ -71,7 +83,7 @@ int ft_to_sngss7_activate_all(void)</span>
         x = 1;
         while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
                 /* check if this link has already been actived */
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.isap[x].flags &amp; ACTIVE)) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.isap[x].flags &amp; SNGSS7_ACTIVE)) {</span>
 
                         if (ftmod_ss7_enable_isap(x)) {        
                                 SS7_CRITICAL(&quot;ISAP %d Enable: NOT OK\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -80,9 +92,9 @@ int ft_to_sngss7_activate_all(void)</span>
                                 SS7_INFO(&quot;ISAP %d Enable: OK\n&quot;, x);
                         }
 
<span style="color: #A00000">-                        /* set the ACTIVE flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.isap[x].flags |= ACTIVE;</span>
<span style="color: #A00000">-                } /* if !ACTIVE */</span>
<span style="color: #00A000">+                        /* set the SNGSS7_ACTIVE flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isap[x].flags |= SNGSS7_ACTIVE;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_ACTIVE */</span>
                 
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
<span style="color: #800080; font-weight: bold">@@ -90,7 +102,7 @@ int ft_to_sngss7_activate_all(void)</span>
         x = 1;
         while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
                 /* check if this link has already been actived */
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags &amp; ACTIVE)) {</span>
<span style="color: #00A000">+                if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags &amp; SNGSS7_ACTIVE)) {</span>
 
                         if (ftmod_ss7_enable_nsap(x)) {        
                                 SS7_CRITICAL(&quot;NSAP %d Enable: NOT OK\n&quot;, x);
<span style="color: #800080; font-weight: bold">@@ -99,31 +111,33 @@ int ft_to_sngss7_activate_all(void)</span>
                                 SS7_INFO(&quot;NSAP %d Enable: OK\n&quot;, x);
                         }
 
<span style="color: #A00000">-                        /* set the ACTIVE flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.nsap[x].flags |= ACTIVE;</span>
<span style="color: #A00000">-                } /* if !ACTIVE */</span>
<span style="color: #00A000">+                        /* set the SNGSS7_ACTIVE flag */</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.nsap[x].flags |= SNGSS7_ACTIVE;</span>
<span style="color: #00A000">+                } /* if !SNGSS7_ACTIVE */</span>
                 
                 x++;
         } /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
 
<span style="color: #A00000">-        x = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {</span>
<span style="color: #A00000">-                /* check if this link has already been actived */</span>
<span style="color: #A00000">-                if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags &amp; ACTIVE)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        if (ftmod_ss7_enable_mtpLinkSet(x)) {        </span>
<span style="color: #A00000">-                                SS7_CRITICAL(&quot;LinkSet \&quot;%s\&quot; Enable: NOT OK\n&quot;, g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);</span>
<span style="color: #A00000">-                                return 1;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_INFO(&quot;LinkSet \&quot;%s\&quot; Enable: OK\n&quot;, g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* set the ACTIVE flag */</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= ACTIVE;</span>
<span style="color: #A00000">-                } /* if !ACTIVE */</span>
<span style="color: #A00000">-                </span>
<span style="color: #A00000">-                x++;</span>
<span style="color: #A00000">-        } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) {</span>
<span style="color: #00A000">+                x = 1;</span>
<span style="color: #00A000">+                while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {</span>
<span style="color: #00A000">+                        /* check if this link has already been actived */</span>
<span style="color: #00A000">+                        if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags &amp; SNGSS7_ACTIVE)) {</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                                if (ftmod_ss7_enable_mtpLinkSet(x)) {        </span>
<span style="color: #00A000">+                                        SS7_CRITICAL(&quot;LinkSet \&quot;%s\&quot; Enable: NOT OK\n&quot;, g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);</span>
<span style="color: #00A000">+                                        return 1;</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        SS7_INFO(&quot;LinkSet \&quot;%s\&quot; Enable: OK\n&quot;, g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                                /* set the SNGSS7_ACTIVE flag */</span>
<span style="color: #00A000">+                                g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= SNGSS7_ACTIVE;</span>
<span style="color: #00A000">+                        } /* if !SNGSS7_ACTIVE */</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                        x++;</span>
<span style="color: #00A000">+                } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */</span>
<span style="color: #00A000">+        }</span>
 
         return 0;
 }
<span style="color: #800080; font-weight: bold">@@ -223,7 +237,7 @@ static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_inhibit_mtplink(uint32_t id)</span>
<span style="color: #00A000">+int ftmod_ss7_inhibit_mtp3link(uint32_t id)</span>
 {
         SnMngmt cntrl;
         Pst pst;
<span style="color: #800080; font-weight: bold">@@ -253,7 +267,7 @@ int ftmod_ss7_inhibit_mtplink(uint32_t id)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_uninhibit_mtplink(uint32_t id)</span>
<span style="color: #00A000">+int ftmod_ss7_uninhibit_mtp3link(uint32_t id)</span>
 {
         SnMngmt cntrl;
         Pst pst;
<span style="color: #800080; font-weight: bold">@@ -283,7 +297,67 @@ int ftmod_ss7_uninhibit_mtplink(uint32_t id)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_activate_mtplink(uint32_t id)</span>
<span style="color: #00A000">+int ftmod_ss7_bind_mtp3link(uint32_t id)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SnMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(SnMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSN;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STDLSAP;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = ABND;                /* Activate */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAELMNT;        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_mtp3(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_unbind_mtp3link(uint32_t id)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SnMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(SnMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSN;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STDLSAP;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = AUBND_DIS;                /* unbind and disable */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAELMNT;                        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_mtp3(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_activate_mtp3link(uint32_t id)</span>
 {
         SnMngmt cntrl;
         Pst pst;
<span style="color: #800080; font-weight: bold">@@ -304,7 +378,7 @@ int ftmod_ss7_activate_mtplink(uint32_t id)</span>
         cntrl.hdr.entId.ent                        = ENTSN;
         cntrl.hdr.entId.inst                = S_INST;
         cntrl.hdr.elmId.elmnt                = STDLSAP;
<span style="color: #A00000">-        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtpLink[id].id;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
 
         cntrl.t.cntrl.action                = AENA;                /* Activate */
         cntrl.t.cntrl.subAction                = SAELMNT;        /* specificed element */
<span style="color: #800080; font-weight: bold">@@ -313,7 +387,7 @@ int ftmod_ss7_activate_mtplink(uint32_t id)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_deactivate_mtplink(uint32_t id)</span>
<span style="color: #00A000">+int ftmod_ss7_deactivate_mtp3link(uint32_t id)</span>
 {
         SnMngmt cntrl;
         Pst pst;
<span style="color: #800080; font-weight: bold">@@ -334,7 +408,7 @@ int ftmod_ss7_deactivate_mtplink(uint32_t id)</span>
         cntrl.hdr.entId.ent                        = ENTSN;
         cntrl.hdr.entId.inst                = S_INST;
         cntrl.hdr.elmId.elmnt                = STDLSAP;
<span style="color: #A00000">-        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtpLink[id].id;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
 
         cntrl.t.cntrl.action                = ADISIMM;        /* Deactivate */
         cntrl.t.cntrl.subAction                = SAELMNT;        /* specificed element */
<span style="color: #800080; font-weight: bold">@@ -343,7 +417,7 @@ int ftmod_ss7_deactivate_mtplink(uint32_t id)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_deactivate2_mtplink(uint32_t id)</span>
<span style="color: #00A000">+int ftmod_ss7_deactivate2_mtp3link(uint32_t id)</span>
 {
         SnMngmt cntrl;
         Pst pst;
<span style="color: #800080; font-weight: bold">@@ -364,7 +438,7 @@ int ftmod_ss7_deactivate2_mtplink(uint32_t id)</span>
         cntrl.hdr.entId.ent                        = ENTSN;
         cntrl.hdr.entId.inst                = S_INST;
         cntrl.hdr.elmId.elmnt                = STDLSAP;
<span style="color: #A00000">-        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtpLink[id].id;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
 
         cntrl.t.cntrl.action                = ADISIMM_L2;        /* Deactivate...layer 2 only */
         cntrl.t.cntrl.subAction                = SAELMNT;                /* specificed element */
<span style="color: #800080; font-weight: bold">@@ -463,7 +537,7 @@ int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_lpo_mtplink(uint32_t id)</span>
<span style="color: #00A000">+int ftmod_ss7_lpo_mtp3link(uint32_t id)</span>
 {
         SnMngmt cntrl;
         Pst pst;
<span style="color: #800080; font-weight: bold">@@ -484,7 +558,7 @@ int ftmod_ss7_lpo_mtplink(uint32_t id)</span>
         cntrl.hdr.entId.ent                        = ENTSN;
         cntrl.hdr.entId.inst                = S_INST;
         cntrl.hdr.elmId.elmnt                = STDLSAP;
<span style="color: #A00000">-        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtpLink[id].id;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
 
         cntrl.t.cntrl.action                = ACTION_LPO;        /* Activate */
         cntrl.t.cntrl.subAction                = SAELMNT;                        /* specificed element */
<span style="color: #800080; font-weight: bold">@@ -493,7 +567,7 @@ int ftmod_ss7_lpo_mtplink(uint32_t id)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-int ftmod_ss7_lpr_mtplink(uint32_t id)</span>
<span style="color: #00A000">+int ftmod_ss7_lpr_mtp3link(uint32_t id)</span>
 {
         SnMngmt cntrl;
         Pst pst;
<span style="color: #800080; font-weight: bold">@@ -514,7 +588,7 @@ int ftmod_ss7_lpr_mtplink(uint32_t id)</span>
         cntrl.hdr.entId.ent                        = ENTSN;
         cntrl.hdr.entId.inst                = S_INST;
         cntrl.hdr.elmId.elmnt                = STDLSAP;
<span style="color: #A00000">-        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtpLink[id].id;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
 
         cntrl.t.cntrl.action                = ACTION_LPR;        /* Activate */
         cntrl.t.cntrl.subAction                = SAELMNT;                        /* specificed element */
<span style="color: #800080; font-weight: bold">@@ -523,6 +597,216 @@ int ftmod_ss7_lpr_mtplink(uint32_t id)</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+int ftmod_ss7_shutdown_isup(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SiMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSI;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(SiMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;           /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSI;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STGEN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = ASHUTDOWN;        /* shutdown */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAELMNT;                /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_isup(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_mtp3(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SnMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(SnMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSN;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STGEN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = ASHUTDOWN;        /* Activate */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAELMNT;                        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_mtp3(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_mtp2(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SdMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSD;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(SdMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSD;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STGEN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = ASHUTDOWN;        /* Activate */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAELMNT;                        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_mtp2(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_relay(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        RyMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTRY;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(RyMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTRY;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STGEN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = ASHUTDOWN;        /* Activate */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAELMNT;                        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_relay(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SnMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(SnMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;                        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSN;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STGRDLSAP;                /* group DLSAP */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.ctlType.groupKey.dstProcId = procId;        /* all SAPS to this ProcId */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = AUBND_DIS;                /* disable and unbind */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAGR_DSTPROCID;                        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_mtp3(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SnMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSN;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(SnMngmt));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;                        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSN;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STGRDLSAP;                /* group DLSAP */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.ctlType.groupKey.dstProcId = procId;        /* all SAPS to this ProcId */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = ABND_ENA;                        /* bind and enable */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAGR_DSTPROCID;                        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_mtp3(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SdMngmt cntrl;</span>
<span style="color: #00A000">+        Pst pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSD;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control structure */</span>
<span style="color: #00A000">+        memset(&amp;cntrl, 0x0, sizeof(cntrl));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the control header */</span>
<span style="color: #00A000">+        smHdrInit(&amp;cntrl.hdr);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.hdr.msgType                        = TCNTRL;                        /* this is a control request */</span>
<span style="color: #00A000">+        cntrl.hdr.entId.ent                        = ENTSD;</span>
<span style="color: #00A000">+        cntrl.hdr.entId.inst                = S_INST;</span>
<span style="color: #00A000">+        cntrl.hdr.elmId.elmnt                = STGRNSAP;                        /* group NSAP */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.par.dstProcId = procId;                        /* all SAPS to this ProcId */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        cntrl.t.cntrl.action                = AUBND_DIS;                /* disable and unbind */</span>
<span style="color: #00A000">+        cntrl.t.cntrl.subAction                = SAGR_DSTPROCID;                        /* specificed element */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return (sng_cntrl_mtp2(&amp;pst, &amp;cntrl));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+}</span>
 
 /******************************************************************************/
 /* For Emacs:
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c</span>
<span style="color: #000080; font-weight: bold">index dcfb7f7..3a6fca7 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c</span>
<span style="color: #800080; font-weight: bold">@@ -99,21 +99,21 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
         /* lock the channel */
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) {</span>
                 SS7_INFO_CHAN(ftdmchan,&quot;[CIC:%d]Rx IAM (glare)\n&quot;, sngss7_info-&gt;circuit-&gt;cic);
         } else {
                 SS7_INFO_CHAN(ftdmchan,&quot;[CIC:%d]Rx IAM\n&quot;, sngss7_info-&gt;circuit-&gt;cic);
         }
 
         /* check if the circuit has a remote block */
<span style="color: #A00000">-        if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||</span>
<span style="color: #A00000">-                (sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||</span>
<span style="color: #A00000">-                (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
<span style="color: #00A000">+        if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||</span>
<span style="color: #00A000">+                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||</span>
<span style="color: #00A000">+                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
 
                 /* as per Q.764, 2.8.2.3 xiv ... remove the block from this channel */
<span style="color: #A00000">-                sngss7_clear_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);</span>
<span style="color: #A00000">-                sngss7_clear_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);</span>
<span style="color: #A00000">-                sngss7_clear_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);</span>
<span style="color: #00A000">+                sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);</span>
<span style="color: #00A000">+                sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);</span>
<span style="color: #00A000">+                sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);</span>
 
                 /* KONRAD FIX ME : check in case there is a ckt and grp block */
         }
<span style="color: #800080; font-weight: bold">@@ -134,7 +134,7 @@ ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
                                                 ftdmchan-&gt;physical_chan_id);
 
                          /* set the flag to indicate this hangup is started from the local side */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_LOCAL_REL);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL);</span>
 
                         ftdmchan-&gt;caller_data.hangup_cause = 41;
 
<span style="color: #800080; font-weight: bold">@@ -253,26 +253,26 @@ handle_glare:</span>
                 sngss7_info-&gt;glare.circuit = circuit;
                 memcpy(&amp;sngss7_info-&gt;glare.iam, siConEvnt, sizeof(*siConEvnt));
 
<span style="color: #A00000">-                if (!(sngss7_test_flag(sngss7_info, FLAG_GLARE))) {</span>
<span style="color: #00A000">+                if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) {</span>
                         /* glare, throw the flag */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_GLARE);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE);</span>
                 
                         /* setup the hangup cause */
                         ftdmchan-&gt;caller_data.hangup_cause = 34;        /* Circuit Congrestion */
                 
                         /* this is a remote hangup request */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);</span>
                 
                         /* move the state of the channel to Terminating to end the call */
                         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
<span style="color: #A00000">-                } /* if (!(sngss7_test_flag(sngss7_info, FLAG_GLARE))) */</span>
<span style="color: #00A000">+                } /* if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) */</span>
                 break;
         /**************************************************************************/
         default:        /* should not have gotten an IAM while in this state */
                 SS7_ERROR_CHAN(ftdmchan, &quot;Got IAM on channel in invalid state(%s)...reset!\n&quot;, ftdm_channel_state2str (ftdmchan-&gt;state));
 
                 /* reset the cic */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_RESET_TX);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);</span>
 
                 /* move the state of the channel to RESTART to force a reset */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
<span style="color: #800080; font-weight: bold">@@ -341,7 +341,7 @@ ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
                                                                         ftdm_channel_state2str (ftdmchan-&gt;state));
 
                         /* reset the cic */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_RESET_TX);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);</span>
 
                         /* go to RESTART */
                         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
<span style="color: #800080; font-weight: bold">@@ -545,7 +545,7 @@ ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
                 SS7_INFO_CHAN(ftdmchan,&quot;[CIC:%d]Rx ANM/CON\n&quot;, sngss7_info-&gt;circuit-&gt;cic);
 
                 /* throw the TX reset flag */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
 
                 /* go to RESTART */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
<span style="color: #800080; font-weight: bold">@@ -597,7 +597,7 @@ ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
                 }
 
                 /* this is a remote hangup request */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);</span>
 ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
                 /* move the state of the channel to CANCEL to end the call */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
<span style="color: #800080; font-weight: bold">@@ -618,7 +618,7 @@ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);</span>
                 }
 
                 /* this is a remote hangup request */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);</span>
 
                 /* move the state of the channel to TERMINATING to end the call */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
<span style="color: #800080; font-weight: bold">@@ -631,7 +631,7 @@ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);</span>
                 ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);
 
                 /* since we need to acknowledge the hang up set the flag for remote release */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);</span>
 
                 /* go to hangup complete to send the RLC */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_HANGUP_COMPLETE);
<span style="color: #800080; font-weight: bold">@@ -645,7 +645,7 @@ ftdm_channel_command(ftdmchan, FTDM_COMMAND_DISABLE_LOOP, NULL);</span>
         default:
 
                 /* throw the reset flag */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_RESET_RX);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX);</span>
 
                 /* set the state to RESTART */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
<span style="color: #800080; font-weight: bold">@@ -1134,13 +1134,13 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci</span>
         /* lock the channel */
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) {</span>
                 /* the glare flag is already up so it was caught ... do nothing */
                 SS7_DEBUG_CHAN(ftdmchan, &quot;Glare flag is already up...nothing to do!%s\n&quot;, &quot; &quot;);
         } else {
                 SS7_DEBUG_CHAN(ftdmchan, &quot;Glare flag is not up yet...indicating glare from reattempt!%s\n&quot;, &quot; &quot;);
                 /* glare, throw the flag */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_GLARE);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_GLARE);</span>
 
                 /* clear any existing glare data from the channel */
                 memset(&amp;sngss7_info-&gt;glare, 0x0, sizeof(sngss7_glare_data_t));
<span style="color: #800080; font-weight: bold">@@ -1149,7 +1149,7 @@ ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t ci</span>
                 ftdmchan-&gt;caller_data.hangup_cause = 34;        /* Circuit Congrestion */
 
                 /* this is a remote hangup request */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_REMOTE_REL);</span>
 
                 /* move the state of the channel to Terminating to end the call */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_TERMINATING);
<span style="color: #800080; font-weight: bold">@@ -1179,7 +1179,7 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui</span>
         sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg.isupIntf[infId], SNGSS7_PAUSED);
         
         /* go through all the circuits now and find any other circuits on this infId */
<span style="color: #A00000">-        i = 1;</span>
<span style="color: #00A000">+        i = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) {
                 
                 /* check that the infId matches and that this is not a siglink */
<span style="color: #800080; font-weight: bold">@@ -1200,7 +1200,7 @@ ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circui</span>
                         if (ftdm_test_flag(ftdmchan-&gt;span, FTDM_SPAN_IN_THREAD)) {
                                 SS7_DEBUG_CHAN(ftdmchan, &quot;Rx PAUSE%s\n&quot;, &quot;&quot;);
                                 /* set the pause flag on the channel */
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
                         }
         
                         /* unlock the channel again before we exit */
<span style="color: #800080; font-weight: bold">@@ -1234,7 +1234,7 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu</span>
         sngss7_clear_flag(&amp;g_ftdm_sngss7_data.cfg.isupIntf[infId], SNGSS7_PAUSED);
 
         /* go through all the circuits now and find any other circuits on this infId */
<span style="color: #A00000">-        i = 1;</span>
<span style="color: #00A000">+        i = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
         while (g_ftdm_sngss7_data.cfg.isupCkt[i].id != 0) {
 
                 /* check that the infId matches and that this is not a siglink */
<span style="color: #800080; font-weight: bold">@@ -1252,14 +1252,14 @@ ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circu</span>
                         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
                         /* only resume if we are paused */
<span style="color: #A00000">-                        if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) {</span>
<span style="color: #00A000">+                        if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) {</span>
                                 SS7_DEBUG_CHAN(ftdmchan, &quot;Rx RESUME%s\n&quot;, &quot;&quot;);
 
                                 /* set the resume flag on the channel */
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_INFID_RESUME);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);</span>
 
                                 /* clear the paused flag */
<span style="color: #A00000">-                                sngss7_clear_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
<span style="color: #00A000">+                                sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
                         }
                         
                         /* unlock the channel again before we exit */
<span style="color: #800080; font-weight: bold">@@ -1421,12 +1421,12 @@ ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
         /* check if the circuit is already blocked or not */
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {</span>
                 SS7_WARN(&quot;Received BLO on circuit that is already blocked!\n&quot;);
         }
 
         /* throw the ckt block flag */
<span style="color: #A00000">-        sngss7_set_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);</span>
<span style="color: #00A000">+        sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);</span>
 
         /* set the channel to suspended state */
         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1484,15 +1484,15 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
         /* check if the channel is blocked */
<span style="color: #A00000">-        if (!(sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX))) {</span>
<span style="color: #00A000">+        if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX))) {</span>
                 SS7_WARN(&quot;Received UBL on circuit that is not blocked!\n&quot;);
         }
 
         /* throw the unblock flag */
<span style="color: #A00000">-        sngss7_set_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX);</span>
<span style="color: #00A000">+        sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX);</span>
 
         /* clear the block flag */
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);</span>
 
         /* set the channel to suspended state */
         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1550,7 +1550,7 @@ ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
         /* throw the reset flag */
<span style="color: #A00000">-        sngss7_set_flag(sngss7_info, FLAG_RESET_RX);</span>
<span style="color: #00A000">+        sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX);</span>
 
         switch (ftdmchan-&gt;state) {
         /**************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -1595,7 +1595,7 @@ ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_</span>
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
         /* throw the reset flag */
<span style="color: #A00000">-        sngss7_set_flag(sngss7_info, FLAG_RESET_RX);</span>
<span style="color: #00A000">+        sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_RX);</span>
 
         switch (ftdmchan-&gt;state) {
         /**************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -1643,9 +1643,9 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
         /**********************************************************************/
         case FTDM_CHANNEL_STATE_RESTART:
                 
<span style="color: #A00000">-                if ( sngss7_test_flag(sngss7_info, FLAG_RESET_TX) ) {</span>
<span style="color: #00A000">+                if ( sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX) ) {</span>
                         /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_RESET_TX_RSP);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP);</span>
 
                         /* go to DOWN */
                         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
<span style="color: #800080; font-weight: bold">@@ -1667,7 +1667,7 @@ ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
         case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
                 
                 /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_RESET_TX_RSP);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP);</span>
 
                 /* go to DOWN */
                 /*ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);*/
<span style="color: #800080; font-weight: bold">@@ -1795,12 +1795,12 @@ ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t ci</span>
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
         /* check if the circuit is already blocked or not */
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {</span>
                 SS7_WARN(&quot;Received local BLO on circuit that is already blocked!\n&quot;);
         }
 
         /* throw the ckt block flag */
<span style="color: #A00000">-        sngss7_set_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);</span>
<span style="color: #00A000">+        sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX);</span>
 
         /* set the channel to suspended state */
         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1831,12 +1831,12 @@ ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t ci</span>
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
         /* check if the circuit is already blocked or not */
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {</span>
                 SS7_WARN(&quot;Received local UBL on circuit that is already unblocked!\n&quot;);
         }
 
         /* throw the ckt block flag */
<span style="color: #A00000">-        sngss7_set_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX);</span>
<span style="color: #00A000">+        sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX);</span>
 
         /* set the channel to suspended state */
         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1878,7 +1878,7 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit</span>
         ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
         /* throw the ckt block flag */
<span style="color: #A00000">-        sngss7_set_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
<span style="color: #00A000">+        sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
 
         /* set the channel to suspended state */
         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1982,11 +1982,11 @@ ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
                         switch (blockType) {
                         /**********************************************************************/
                         case 0:        /* maintenance oriented */
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);</span>
                                 break;
                         /**********************************************************************/
                         case 1: /* hardware failure oriented */
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);</span>
                                 break;
                         /**********************************************************************/
                         case 2: /* reserved for national use */
<span style="color: #800080; font-weight: bold">@@ -2113,11 +2113,11 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ</span>
                         switch (blockType) {
                         /**********************************************************************/
                         case 0:        /* maintenance oriented */
<span style="color: #A00000">-                                sngss7_clear_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);</span>
<span style="color: #00A000">+                                sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX);</span>
                                 break;
                         /**********************************************************************/
                         case 1: /* hardware failure oriented */
<span style="color: #A00000">-                                sngss7_clear_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);</span>
<span style="color: #00A000">+                                sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX);</span>
                                 break;
                         /**********************************************************************/
                         case 2: /* reserved for national use */
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c</span>
<span style="color: #000080; font-weight: bold">index 72bd1c3..76984b9 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c</span>
<span style="color: #800080; font-weight: bold">@@ -409,13 +409,80 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint</span>
         sngss7_chan_data_t        *sngss7_info = NULL;
         ftdm_channel_t                *ftdmchan = NULL;
         sngss7_event_data_t        *sngss7_event = NULL;
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /* get the ftdmchan and ss7_chan_data from the circuit */</span>
<span style="color: #A00000">-        if (extract_chan_data(circuit, &amp;sngss7_info, &amp;ftdmchan)) {</span>
<span style="color: #A00000">-                SS7_ERROR(&quot;Failed to extract channel data for circuit = %d!\n&quot;, circuit);</span>
<span style="color: #A00000">-                SS7_FUNC_TRACE_EXIT(__FUNCTION__);</span>
<span style="color: #A00000">-                return;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        uint32_t                        intfId;</span>
<span style="color: #00A000">+        int                                 x;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check if the eventType is a pause/resume */</span>
<span style="color: #00A000">+        switch (evntType) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        case (SIT_STA_PAUSEIND):</span>
<span style="color: #00A000">+        case (SIT_STA_RESUMEIND):</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* the circuit for this type of event may not exist on the local system</span>
<span style="color: #00A000">+                 * so first check if the circuit is local</span>
<span style="color: #00A000">+                 */</span>
<span style="color: #00A000">+                if ((circuit &gt;= (g_ftdm_sngss7_data.cfg.procId * 1000)) &amp;&amp;</span>
<span style="color: #00A000">+                        (circuit &lt; ((g_ftdm_sngss7_data.cfg.procId +1) * 1000))) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* the circuit is on the local system, handle normally */</span>
<span style="color: #00A000">+                        goto sta_ind_local;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* the circuit is not local, so find a local circuit with the same intfId</span>
<span style="color: #00A000">+                 * by finding the orginial circuit in our array first, finding the intfId </span>
<span style="color: #00A000">+                 * from there, then go through the local circuits to see if we find a </span>
<span style="color: #00A000">+                 * match and use that circuit instead</span>
<span style="color: #00A000">+                 */</span>
<span style="color: #00A000">+                intfId = g_ftdm_sngss7_data.cfg.isupCkt[circuit].infId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
<span style="color: #00A000">+                while ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) &amp;&amp;</span>
<span style="color: #00A000">+                           (g_ftdm_sngss7_data.cfg.isupCkt[x].id &lt; ((g_ftdm_sngss7_data.cfg.procId +1) * 1000))) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        /* confirm this is a voice channel and not a gap/sig (no ftdmchan there) */</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.isupCkt[x].type != VOICE) goto move_along;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* compare the intfIds */</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) {</span>
<span style="color: #00A000">+                                /* we have a match, setup the pointers to the correct values */</span>
<span style="color: #00A000">+                                circuit = x;</span>
<span style="color: #00A000">+                                </span>
<span style="color: #00A000">+                                if (extract_chan_data(circuit, &amp;sngss7_info, &amp;ftdmchan)) {</span>
<span style="color: #00A000">+                                        SS7_ERROR(&quot;Failed to extract channel data for circuit = %d!\n&quot;, circuit);</span>
<span style="color: #00A000">+                                        SS7_FUNC_TRACE_EXIT(__FUNCTION__);</span>
<span style="color: #00A000">+                                        return;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                /* bounce out of the loop */</span>
<span style="color: #00A000">+                                break;</span>
<span style="color: #00A000">+                        } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].intfId == intfId) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+move_along:</span>
<span style="color: #00A000">+                        /* move along ... nothing to see here */</span>
<span style="color: #00A000">+                        x++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* check if we found any circuits that are on the intfId, drop the message</span>
<span style="color: #00A000">+                 * if none are found</span>
<span style="color: #00A000">+                 */</span>
<span style="color: #00A000">+                if (ftdmchan == NULL) goto sta_ind_end;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        default:</span>
<span style="color: #00A000">+sta_ind_local:</span>
<span style="color: #00A000">+                /* get the ftdmchan and ss7_chan_data from the circuit */</span>
<span style="color: #00A000">+                if (extract_chan_data(circuit, &amp;sngss7_info, &amp;ftdmchan)) {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Failed to extract channel data for circuit = %d!\n&quot;, circuit);</span>
<span style="color: #00A000">+                        SS7_FUNC_TRACE_EXIT(__FUNCTION__);</span>
<span style="color: #00A000">+                        return;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* switch (evntType) */</span>
 
         /* initalize the sngss7_event */
         sngss7_event = ftdm_malloc(sizeof(*sngss7_event));
<span style="color: #800080; font-weight: bold">@@ -440,6 +507,7 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint</span>
         /* enqueue this event */
         ftdm_queue_enqueue(((sngss7_span_data_t*)sngss7_info-&gt;ftdmchan-&gt;span-&gt;signal_data)-&gt;event_queue, sngss7_event);
 
<span style="color: #00A000">+sta_ind_end:</span>
         SS7_FUNC_TRACE_EXIT(__FUNCTION__);
 }
 
<span style="color: #000080; font-weight: bold">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</span>
<span style="color: #000080; font-weight: bold">index 3f507d6..1dfcab4 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c</span>
<span style="color: #800080; font-weight: bold">@@ -48,6 +48,8 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);</span>
 void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta);
 void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta);
 void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta);
<span style="color: #00A000">+void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta);</span>
<span style="color: #00A000">+</span>
 /******************************************************************************/
 
 /* FUNCTIONS ******************************************************************/
<span style="color: #800080; font-weight: bold">@@ -132,17 +134,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)</span>
 
                         /* find the name for the sap in question */
                         x = 1;
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                                if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
<span style="color: #00A000">+                        while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {</span>
<span style="color: #00A000">+                                if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
                                         break;
                                 }
                                 x++;
                         }
 
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {</span>
                                 sprintf(buf, &quot;[SAPID:%d]&quot;, sta-&gt;t.usta.evntParm[0]);
                         } else {
<span style="color: #A00000">-                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtpLink[x].name);</span>
<span style="color: #00A000">+                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtp2Link[x].name);</span>
                         }
                                         
 
<span style="color: #800080; font-weight: bold">@@ -173,17 +175,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)</span>
                         
                         /* find the name for the sap in question */
                         x = 1;
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                                if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
<span style="color: #00A000">+                        while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {</span>
<span style="color: #00A000">+                                if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
                                         break;
                                 }
                                 x++;
                         }
 
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {</span>
                                 sprintf(buf, &quot;[SAPID:%d]&quot;, sta-&gt;t.usta.evntParm[0]);
                         } else {
<span style="color: #A00000">-                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtpLink[x].name);</span>
<span style="color: #00A000">+                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtp2Link[x].name);</span>
                         }
 
                         ftdm_log(FTDM_LOG_ERROR,&quot;[MTP2]%s %s : %s\n&quot;,
<span style="color: #800080; font-weight: bold">@@ -196,17 +198,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)</span>
                         
                         /* find the name for the sap in question */
                         x = 1;
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                                if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
<span style="color: #00A000">+                        while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {</span>
<span style="color: #00A000">+                                if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
                                         break;
                                 }
                                 x++;
                         }
 
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {</span>
                                 sprintf(buf, &quot;[SAPID:%d]&quot;, sta-&gt;t.usta.evntParm[0]);
                         } else {
<span style="color: #A00000">-                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtpLink[x].name);</span>
<span style="color: #00A000">+                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtp2Link[x].name);</span>
                         }
 
                         ftdm_log(FTDM_LOG_ERROR,&quot;[MTP2]%s %s : %s\n&quot;,
<span style="color: #800080; font-weight: bold">@@ -220,17 +222,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)</span>
 
                         /* find the name for the sap in question */
                         x = 1;
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                                if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
<span style="color: #00A000">+                        while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {</span>
<span style="color: #00A000">+                                if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
                                         break;
                                 }
                                 x++;
                         }
 
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {</span>
                                 sprintf(buf, &quot;[SAPID:%d]&quot;, sta-&gt;t.usta.evntParm[0]);
                         } else {
<span style="color: #A00000">-                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtpLink[x].name);</span>
<span style="color: #00A000">+                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtp2Link[x].name);</span>
                         }
 
                         ftdm_log(FTDM_LOG_ERROR,&quot;[MTP2]%s %s : RTB Queue Len(%d)|Oldest BSN(%d)|Tx Queue Len(%d)|Outstanding Frames(%d)\n&quot;,
<span style="color: #800080; font-weight: bold">@@ -246,17 +248,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)</span>
 
                         /* find the name for the sap in question */
                         x = 1;
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                                if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
<span style="color: #00A000">+                        while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {</span>
<span style="color: #00A000">+                                if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
                                         break;
                                 }
                                 x++;
                         }
 
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {</span>
                                 sprintf(buf, &quot;[SAPID:%d]&quot;, sta-&gt;t.usta.evntParm[0]);
                         } else {
<span style="color: #A00000">-                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtpLink[x].name);</span>
<span style="color: #00A000">+                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtp2Link[x].name);</span>
                         }
 
                         ftdm_log(FTDM_LOG_ERROR,&quot;[MTP2]%s %s : RTB Queue Len(%d)\n&quot;,
<span style="color: #800080; font-weight: bold">@@ -269,17 +271,17 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)</span>
 
                         /* find the name for the sap in question */
                         x = 1;
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                                if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
<span style="color: #00A000">+                        while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {</span>
<span style="color: #00A000">+                                if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta-&gt;t.usta.evntParm[0]) {</span>
                                         break;
                                 }
                                 x++;
                         }
 
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {</span>
                                 sprintf(buf, &quot;[SAPID:%d]&quot;, sta-&gt;t.usta.evntParm[0]);
                         } else {
<span style="color: #A00000">-                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtpLink[x].name);</span>
<span style="color: #00A000">+                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtp2Link[x].name);</span>
                         }
 
                         ftdm_log(FTDM_LOG_ERROR,&quot;[MTP2]%s %s : %d\n&quot;,
<span style="color: #800080; font-weight: bold">@@ -290,9 +292,11 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)</span>
                 /**********************************************************************/
                 case (LCM_EVENT_UI_INV_EVT):
                 case (LCM_EVENT_LI_INV_EVT):
<span style="color: #A00000">-                        ftdm_log(FTDM_LOG_ERROR,&quot;[MTP2] %s : %s : Primitive (%d)\n&quot;,</span>
<span style="color: #00A000">+                        ftdm_log(FTDM_LOG_ERROR,&quot;[MTP2] %s(%d) : %s(%d) : Primitive (%d)\n&quot;,</span>
                                                                                 DECODE_LSD_EVENT(sta-&gt;t.usta.alarm.event),
<span style="color: #00A000">+                                                                                sta-&gt;t.usta.alarm.event,</span>
                                                                                 DECODE_LCM_CAUSE(sta-&gt;t.usta.alarm.cause),
<span style="color: #00A000">+                                                                                sta-&gt;t.usta.alarm.cause,</span>
                                                                                 sta-&gt;t.usta.evntParm[0]);
                         break;
                 /**********************************************************************/
<span style="color: #800080; font-weight: bold">@@ -362,22 +366,23 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)</span>
 
                         /* find the name for the sap in question */
                         x = 1;
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLink[x].id != 0) {</span>
<span style="color: #A00000">-                                if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == sta-&gt;hdr.elmId.elmntInst1) {</span>
<span style="color: #00A000">+                        while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {</span>
<span style="color: #00A000">+                                if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == sta-&gt;hdr.elmId.elmntInst1) {</span>
                                         break;
                                 }
                                 x++;
                         }
 
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.mtpLink[x].id == 0) {</span>
<span style="color: #00A000">+                        if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == 0) {</span>
                                 sprintf(buf, &quot;[SAPID:%d]&quot;, sta-&gt;hdr.elmId.elmntInst1);
                         } else {
<span style="color: #A00000">-                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtpLink[x].name);</span>
<span style="color: #00A000">+                                sprintf(buf, &quot;[%s]&quot;, g_ftdm_sngss7_data.cfg.mtp3Link[x].name);</span>
                         }
 
                 switch (sta-&gt;t.usta.alarm.event) {
                 /**********************************************************************/
                 case (LSN_EVENT_INV_OPC_OTHER_END):
<span style="color: #00A000">+                        </span>
                         ftdm_log(FTDM_LOG_ERROR,&quot;[MTP3]%s %s : %s : OPC(0x%X%X%X%X)\n&quot;,
                                                                                 buf,
                                                                                 DECODE_LSN_EVENT(sta-&gt;t.usta.alarm.event),
<span style="color: #800080; font-weight: bold">@@ -460,7 +465,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)</span>
                         break;
                 /**********************************************************************/
                 default:
<span style="color: #A00000">-                        ftdm_log(FTDM_LOG_ERROR,&quot;[MTP3][DPC:0x%d%d%d%d] %s : %s\n&quot;,</span>
<span style="color: #00A000">+                        ftdm_log(FTDM_LOG_ERROR,&quot;[MTP3][DPC:0x%X%X%X%X] %s : %s\n&quot;,</span>
                                                                                 sta-&gt;t.usta.evntParm[0],
                                                                                 sta-&gt;t.usta.evntParm[1],
                                                                                 sta-&gt;t.usta.evntParm[2],
<span style="color: #800080; font-weight: bold">@@ -744,7 +749,63 @@ void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta)</span>
 
         return;
 }   /* handle_cc_alarm */
<span style="color: #00A000">+</span>
 /******************************************************************************/
<span style="color: #00A000">+void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        switch (sta-&gt;hdr.elmId.elmnt) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        case (LRY_USTA_ERR): /* ERROR */</span>
<span style="color: #00A000">+                ftdm_log(FTDM_LOG_ERROR,&quot;[RELAY] Error: tx procId %d: err procId %d: channel %d: seq %s: reason %s\n&quot;,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryErrUsta.sendPid,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryErrUsta.errPid,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryErrUsta.id,</span>
<span style="color: #00A000">+                                                                                                DECODE_LRY_SEQ(sta-&gt;t.usta.s.ryErrUsta.sequence),</span>
<span style="color: #00A000">+                                                                                                DECODE_LRY_REASON(sta-&gt;t.usta.s.ryErrUsta.reason));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* process the event */</span>
<span style="color: #00A000">+                handle_relay_disconnect_on_error(sta);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        case (LRY_USTA_CNG): /* Congestion */</span>
<span style="color: #00A000">+                ftdm_log(FTDM_LOG_ERROR,&quot;[RELAY] Congestion: tx procId %d: rem procId %d: channel %d: %s\n&quot;,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryCongUsta.sendPid,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryCongUsta.remPid,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryCongUsta.id,</span>
<span style="color: #00A000">+                                                                                                DECODE_LRY_CONG_FLAGS(sta-&gt;t.usta.s.ryCongUsta.flags));</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        case (LRY_USTA_UP): /* channel up */</span>
<span style="color: #00A000">+                ftdm_log(FTDM_LOG_ERROR,&quot;[RELAY] Channel UP: tx procId %d: channel %d\n&quot;,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryUpUsta.sendPid,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryUpUsta.id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* process the event */</span>
<span style="color: #00A000">+                handle_relay_connect(sta);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        case (LRY_USTA_DN): /* channel down */</span>
<span style="color: #00A000">+                ftdm_log(FTDM_LOG_ERROR,&quot;[RELAY] Channel DOWN: tx procId %d: channel %d\n&quot;,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryUpUsta.sendPid,</span>
<span style="color: #00A000">+                                                                                                sta-&gt;t.usta.s.ryUpUsta.id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* process the event */</span>
<span style="color: #00A000">+                handle_relay_disconnect_on_down(sta);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        default:</span>
<span style="color: #00A000">+                ftdm_log(FTDM_LOG_ERROR,&quot;Unknown Relay Alram\n&quot;);</span>
<span style="color: #00A000">+                break;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* switch (sta-&gt;hdr.elmId.elmnt) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return;</span>
<span style="color: #00A000">+}</span>
 
 /******************************************************************************/
 /* For Emacs:
<span style="color: #000080; font-weight: bold">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</span>
<span style="color: #000080; font-weight: bold">index 9016771..c971179 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c</span>
<span style="color: #800080; font-weight: bold">@@ -543,7 +543,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                                         ftdmchan-&gt;caller_data.hangup_cause = 41;
                 
                                         /* set the flag to indicate this hangup is started from the local side */
<span style="color: #A00000">-                                        sngss7_set_flag (sngss7_info, FLAG_LOCAL_REL);</span>
<span style="color: #00A000">+                                        sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL);</span>
                 
                                         /* end the call */
                                         ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_CANCEL);
<span style="color: #800080; font-weight: bold">@@ -673,7 +673,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                 }
 
                 /* set the flag to indicate this hangup is started from the remote side */
<span style="color: #A00000">-                sngss7_set_flag (sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag (sngss7_info, FLAG_REMOTE_REL);</span>
 
                 /*this state is set when the line is hanging up */
                 sigev.event_id = FTDM_SIGEVENT_STOP;
<span style="color: #800080; font-weight: bold">@@ -689,15 +689,15 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                 }
 
                 /* check for remote hangup flag */
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_REMOTE_REL)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) {</span>
                         /* remote release ...do nothing here */
                         SS7_DEBUG_CHAN(ftdmchan,&quot;Hanging up remotely requested call!%s\n&quot;, &quot;&quot;);
<span style="color: #A00000">-                } else if (sngss7_test_flag (sngss7_info, FLAG_GLARE)) {</span>
<span style="color: #00A000">+                } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_GLARE)) {</span>
                         /* release due to glare */
                         SS7_DEBUG_CHAN(ftdmchan,&quot;Hanging up requested call do to glare%s\n&quot;, &quot;&quot;);
                 } else         {
                         /* set the flag to indicate this hangup is started from the local side */
<span style="color: #A00000">-                        sngss7_set_flag (sngss7_info, FLAG_LOCAL_REL);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag (sngss7_info, FLAG_LOCAL_REL);</span>
 
                         /*this state is set when FS is hanging up...so tell the stack */
                         ft_to_sngss7_rel (ftdmchan);
<span style="color: #800080; font-weight: bold">@@ -718,16 +718,16 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         break;
                 }
 
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_REMOTE_REL)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_REMOTE_REL)) {</span>
                         /* check if this hangup is from a tx RSC */
<span style="color: #A00000">-                        if (sngss7_test_flag (sngss7_info, FLAG_RESET_TX)) {</span>
<span style="color: #00A000">+                        if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) {</span>
                                 /* go to RESTART State until RSCa is received */
                                 ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_RESTART);
                         } else {
                                 /* if the hangup is from a rx RSC, rx GRS, or glare don&#39;t sent RLC */
<span style="color: #A00000">-                                if (!(sngss7_test_flag(sngss7_info, FLAG_RESET_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_GLARE))) {</span>
<span style="color: #00A000">+                                if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE))) {</span>
 
                                         /* send out the release complete */
                                         ft_to_sngss7_rlc (ftdmchan);
<span style="color: #800080; font-weight: bold">@@ -738,17 +738,17 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         }
 
                         SS7_DEBUG_CHAN(ftdmchan,&quot;Completing remotely requested hangup!%s\n&quot;, &quot;&quot;);
<span style="color: #A00000">-                } else if (sngss7_test_flag (sngss7_info, FLAG_LOCAL_REL)) {</span>
<span style="color: #00A000">+                } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_LOCAL_REL)) {</span>
 
                         /* if this hang up is do to a rx RESET we need to sit here till the RSP arrives */
<span style="color: #A00000">-                        if (sngss7_test_flag (sngss7_info, FLAG_RESET_TX_RSP)) {</span>
<span style="color: #00A000">+                        if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX_RSP)) {</span>
                                 /* go to the down state as we have already received RSC-RLC */
                                 ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DOWN);
                         }
 
                         /* if it&#39;s a local release the user sends us to down */
                         SS7_DEBUG_CHAN(ftdmchan,&quot;Completing locally requested hangup!%s\n&quot;, &quot;&quot;);
<span style="color: #A00000">-                } else if (sngss7_test_flag (sngss7_info, FLAG_GLARE)) {</span>
<span style="color: #00A000">+                } else if (sngss7_test_ckt_flag (sngss7_info, FLAG_GLARE)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan,&quot;Completing requested hangup due to glare!%s\n&quot;, &quot;&quot;);
 
                         ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DOWN);
<span style="color: #800080; font-weight: bold">@@ -767,18 +767,18 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                 }
 
                 /* check if there is a reset response that needs to be sent */
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) {</span>
                         /* send a RSC-RLC */
                         ft_to_sngss7_rsca (ftdmchan);
 
                         /* clear the reset flag  */
                         clear_rx_rsc_flags(sngss7_info);
<span style="color: #A00000">-                } /* if (sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) */</span>
<span style="color: #00A000">+                } /* if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) */</span>
 
                 /* check if there was a GRS that needs a GRA */
<span style="color: #A00000">-                if ((sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                        (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) &amp;&amp;</span>
<span style="color: #A00000">-                        (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT))) {</span>
<span style="color: #00A000">+                if ((sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                        (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) &amp;&amp;</span>
<span style="color: #00A000">+                        (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT))) {</span>
 
                         /* check if this is the base circuit and send out the GRA
                          * we insure that this is the last circuit to have the state change queued
<span style="color: #800080; font-weight: bold">@@ -794,40 +794,40 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
 
                         /* clear the grp reset flag */
                         clear_rx_grs_flags(sngss7_info);
<span style="color: #A00000">-                }/*  if ( sngss7_test_flag ( sngss7_info, FLAG_GRP_RESET_RX ) ) */</span>
<span style="color: #00A000">+                }/*  if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_RX ) ) */</span>
 
                 /* check if we got the reset response */
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX_RSP)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP)) {</span>
                         /* clear the reset flag  */
                         clear_tx_rsc_flags(sngss7_info);
<span style="color: #A00000">-                } /* if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX_RSP)) */</span>
<span style="color: #00A000">+                } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP)) */</span>
 
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {</span>
                         /* clear the reset flag  */
                         clear_tx_grs_flags(sngss7_info);
                         
                         /* clean out the spans GRA structure */
                         clear_rx_gra_data(sngss7_info);
<span style="color: #A00000">-                } /* if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) */</span>
<span style="color: #00A000">+                } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) */</span>
 
                 /* check if we came from reset (aka we just processed a reset) */
                 if ((ftdmchan-&gt;last_state == FTDM_CHANNEL_STATE_RESTART) || 
                         (ftdmchan-&gt;last_state == FTDM_CHANNEL_STATE_SUSPENDED)) {
 
                         /* check if reset flags are up indicating there is more processing to do yet */
<span style="color: #A00000">-                        if (!(sngss7_test_flag (sngss7_info, FLAG_RESET_TX)) &amp;&amp;</span>
<span style="color: #A00000">-                                !(sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                                !(sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX)) &amp;&amp;</span>
<span style="color: #A00000">-                                !(sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX))) {</span>
<span style="color: #00A000">+                        if (!(sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) &amp;&amp;</span>
<span style="color: #00A000">+                                !(sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                                !(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &amp;&amp;</span>
<span style="color: #00A000">+                                !(sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX))) {</span>
 
                                 /* now check if there is an active block */
<span style="color: #A00000">-                                if (!(sngss7_test_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #A00000">-                                        !(sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
<span style="color: #00A000">+                                if (!(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) &amp;&amp;</span>
<span style="color: #00A000">+                                        !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
                                 
                                         /* check if the sig status is down, and bring it up if it isn&#39;t */
                                         if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) {
<span style="color: #800080; font-weight: bold">@@ -839,7 +839,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                                         } /* if (!ftdm_test_flag (ftdmchan, FTDM_CHANNEL_SIG_UP)) */
                                 } /* if !blocked */
                         } else {
<span style="color: #A00000">-                                SS7_DEBUG_CHAN(ftdmchan,&quot;Reset flags present (0x%X)\n&quot;, sngss7_info-&gt;flags);</span>
<span style="color: #00A000">+                                SS7_DEBUG_CHAN(ftdmchan,&quot;Reset flags present (0x%X)\n&quot;, sngss7_info-&gt;ckt_flags);</span>
                         
                                 /* there is still another reset pending so go back to reset*/
                                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_RESTART);
<span style="color: #800080; font-weight: bold">@@ -858,8 +858,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                 sngss7_info-&gt;spId = 0;
 
                 /* clear any call related flags */
<span style="color: #A00000">-                sngss7_clear_flag (sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #A00000">-                sngss7_clear_flag (sngss7_info, FLAG_LOCAL_REL);</span>
<span style="color: #00A000">+                sngss7_clear_ckt_flag (sngss7_info, FLAG_REMOTE_REL);</span>
<span style="color: #00A000">+                sngss7_clear_ckt_flag (sngss7_info, FLAG_LOCAL_REL);</span>
 
 
                 if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) {
<span style="color: #800080; font-weight: bold">@@ -869,10 +869,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                 } /* if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) */
 
                 /* check if there is a glared call that needs to be processed */
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) {</span>
                         
                         /* clear the glare flag */
<span style="color: #A00000">-                        sngss7_clear_flag (sngss7_info, FLAG_GLARE);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag (sngss7_info, FLAG_GLARE);</span>
 
                         /* check if we have an IAM stored...if we don&#39;t have one just exit */
                         if (sngss7_info-&gt;glare.circuit != 0) {
<span style="color: #800080; font-weight: bold">@@ -885,23 +885,23 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                                 /* clear the glare info */
                                 memset(&amp;sngss7_info-&gt;glare, 0x0, sizeof(sngss7_glare_data_t));
                         } /* if (sngss7_info-&gt;glare.circuit != 0) */
<span style="color: #A00000">-                } /* if (sngss7_test_flag(sngss7_info, FLAG_GLARE)) */</span>
<span style="color: #00A000">+                } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_GLARE)) */</span>
 
                 break;
         /**************************************************************************/
         case FTDM_CHANNEL_STATE_RESTART:        /* CICs needs a Reset */
 
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK)) {</span>
<span style="color: #A00000">-                        if ((sngss7_test_flag(sngss7_info, FLAG_RESET_RX)) ||</span>
<span style="color: #A00000">-                                (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX))) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK)) {</span>
<span style="color: #00A000">+                        if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_RX)) ||</span>
<span style="color: #00A000">+                                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX))) {</span>
 
                                 SS7_DEBUG_CHAN(ftdmchan,&quot;Incoming Reset request on CIC in UCIC block, removing UCIC block%s\n&quot;, &quot;&quot;);
 
                                 /* set the unblk flag */
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);</span>
 
                                 /* clear the block flag */
<span style="color: #A00000">-                                sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
<span style="color: #00A000">+                                sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
 
                                 /* process the flag */
                                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -915,28 +915,28 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                  * we can also check if we are in a PAUSED state (no point in sending message
                  */
                 if ((ftdmchan-&gt;last_state != FTDM_CHANNEL_STATE_HANGUP_COMPLETE) &amp;&amp;
<span style="color: #A00000">-                        (!sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED))) {</span>
<span style="color: #00A000">+                        (!sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED))) {</span>
 
                         /* check if this is an outgoing RSC */
<span style="color: #A00000">-                        if ((sngss7_test_flag(sngss7_info, FLAG_RESET_TX)) &amp;&amp;</span>
<span style="color: #A00000">-                                !(sngss7_test_flag(sngss7_info, FLAG_RESET_SENT))) {</span>
<span style="color: #00A000">+                        if ((sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) &amp;&amp;</span>
<span style="color: #00A000">+                                !(sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_SENT))) {</span>
 
                                 /* send a reset request */
                                 ft_to_sngss7_rsc (ftdmchan);
<span style="color: #A00000">-                                sngss7_set_flag(sngss7_info, FLAG_RESET_SENT);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_SENT);</span>
 
<span style="color: #A00000">-                        } /* if (sngss7_test_flag(sngss7_info, FLAG_RESET_TX)) */</span>
<span style="color: #00A000">+                        } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_RESET_TX)) */</span>
         
                         /* check if this is the first channel of a GRS (this flag is thrown when requesting reset) */
<span style="color: #A00000">-                        if ( (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX)) &amp;&amp;</span>
<span style="color: #A00000">-                                !(sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &amp;&amp;</span>
<span style="color: #A00000">-                                (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {</span>
<span style="color: #00A000">+                        if ( (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) &amp;&amp;</span>
<span style="color: #00A000">+                                !(sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT)) &amp;&amp;</span>
<span style="color: #00A000">+                                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE))) {</span>
 
                                         /* send out the grs */
                                         ft_to_sngss7_grs (ftdmchan);
<span style="color: #A00000">-                                        sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_SENT);</span>
<span style="color: #00A000">+                                        sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);</span>
 
<span style="color: #A00000">-                        }/* if ( sngss7_test_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */</span>
<span style="color: #00A000">+                        }/* if ( sngss7_test_ckt_flag ( sngss7_info, FLAG_GRP_RESET_TX ) ) */</span>
                 } /* if ( last_state != HANGUP &amp;&amp; !PAUSED */
         
                 /* if the sig_status is up...bring it down */
<span style="color: #800080; font-weight: bold">@@ -946,10 +946,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         ftdm_span_send_signal (ftdmchan-&gt;span, &amp;sigev);
                 }
 
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX)) {</span>
                         /* set the grp reset done flag so we know we have finished this reset */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);</span>
<span style="color: #A00000">-                } /* if (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX)) */</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);</span>
<span style="color: #00A000">+                } /* if (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX)) */</span>
 
 
                 if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_INUSE)) {
<span style="color: #800080; font-weight: bold">@@ -987,17 +987,17 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         } /* switch (ftdmchan-&gt;last_state) */
                 } else {
                         /* check if this an incoming RSC or we have a response already */
<span style="color: #A00000">-                        if (sngss7_test_flag (sngss7_info, FLAG_RESET_RX) ||</span>
<span style="color: #A00000">-                                sngss7_test_flag (sngss7_info, FLAG_RESET_TX_RSP) ||</span>
<span style="color: #A00000">-                                sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX_RSP) ||</span>
<span style="color: #A00000">-                                sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX_CMPLT)) {</span>
<span style="color: #00A000">+                        if (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX) ||</span>
<span style="color: #00A000">+                                sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX_RSP) ||</span>
<span style="color: #00A000">+                                sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX_RSP) ||</span>
<span style="color: #00A000">+                                sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX_CMPLT)) {</span>
         
<span style="color: #A00000">-                                SS7_DEBUG_CHAN(ftdmchan, &quot;Reset processed moving to DOWN (0x%X)\n&quot;, sngss7_info-&gt;flags);</span>
<span style="color: #00A000">+                                SS7_DEBUG_CHAN(ftdmchan, &quot;Reset processed moving to DOWN (0x%X)\n&quot;, sngss7_info-&gt;ckt_flags);</span>
         
                                 /* go to a down state to clear the channel and send the response */
                                 ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_DOWN);
                         } else {
<span style="color: #A00000">-                                SS7_DEBUG_CHAN(ftdmchan, &quot;Waiting on Reset Rsp/Grp Reset to move to DOWN (0x%X)\n&quot;, sngss7_info-&gt;flags);</span>
<span style="color: #00A000">+                                SS7_DEBUG_CHAN(ftdmchan, &quot;Waiting on Reset Rsp/Grp Reset to move to DOWN (0x%X)\n&quot;, sngss7_info-&gt;ckt_flags);</span>
                         }
                 }
 
<span style="color: #800080; font-weight: bold">@@ -1005,20 +1005,20 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
         /**************************************************************************/
         case FTDM_CHANNEL_STATE_SUSPENDED:        /* circuit has been blocked */
 
<span style="color: #A00000">-                  SS7_DEBUG_CHAN(ftdmchan,&quot;Current flags: 0x%X\n&quot;, sngss7_info-&gt;flags);</span>
<span style="color: #00A000">+                  SS7_DEBUG_CHAN(ftdmchan,&quot;Current flags: 0x%X\n&quot;, sngss7_info-&gt;ckt_flags);</span>
 
                 /**********************************************************************/
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing RESUME%s\n&quot;, &quot;&quot;);
 
                         /* clear the RESUME flag */
<span style="color: #A00000">-                        sngss7_clear_flag(sngss7_info, FLAG_INFID_RESUME);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);</span>
 
                         /* if there are any resets present */
<span style="color: #A00000">-                        if ((sngss7_test_flag (sngss7_info, FLAG_RESET_TX)) ||</span>
<span style="color: #A00000">-                                (sngss7_test_flag (sngss7_info, FLAG_RESET_RX)) ||</span>
<span style="color: #A00000">-                                (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_TX)) ||</span>
<span style="color: #A00000">-                                (sngss7_test_flag (sngss7_info, FLAG_GRP_RESET_RX))) {</span>
<span style="color: #00A000">+                        if ((sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_TX)) ||</span>
<span style="color: #00A000">+                                (sngss7_test_ckt_flag (sngss7_info, FLAG_RESET_RX)) ||</span>
<span style="color: #00A000">+                                (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_TX)) ||</span>
<span style="color: #00A000">+                                (sngss7_test_ckt_flag (sngss7_info, FLAG_GRP_RESET_RX))) {</span>
 
                                 /* go back to the reset state */
                                 goto suspend_goto_restart;
<span style="color: #800080; font-weight: bold">@@ -1034,7 +1034,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         goto suspend_goto_last;
                 } /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */
 
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing PAUSE%s\n&quot;, &quot;&quot;);
 
                         /* bring the sig status down */
<span style="color: #800080; font-weight: bold">@@ -1044,9 +1044,9 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
 
                         /* go back to the last state */
                         goto suspend_goto_last;
<span style="color: #A00000">-                } /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) { */</span>
<span style="color: #00A000">+                } /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { */</span>
                 /**********************************************************************/
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_MN_BLOCK_RX flag %s\n&quot;, &quot;&quot;);
 
                         /* bring the sig status down */
<span style="color: #800080; font-weight: bold">@@ -1061,11 +1061,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         goto suspend_goto_last;
                 }
 
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_MN_UNBLK_RX flag %s\n&quot;, &quot;&quot;);
 
                         /* clear the unblock flag */
<span style="color: #A00000">-                        sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);</span>
 
                         /* bring the sig status up */
                         sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
<span style="color: #800080; font-weight: bold">@@ -1080,7 +1080,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                 }
 
                 /**********************************************************************/
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_BLOCK_TX)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_MN_BLOCK_TX flag %s\n&quot;, &quot;&quot;);
 
                         /* bring the sig status down */
<span style="color: #800080; font-weight: bold">@@ -1095,11 +1095,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         goto suspend_goto_last;
                 }
 
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)){</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)){</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_MN_UNBLK_TX flag %s\n&quot;, &quot;&quot;);
 
                         /* clear the unblock flag */
<span style="color: #A00000">-                        sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX);</span>
 
                         /* bring the sig status up */
                         sigev.event_id = FTDM_SIGEVENT_SIGSTATUS_CHANGED;
<span style="color: #800080; font-weight: bold">@@ -1114,7 +1114,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                 }
 
                 /**********************************************************************/
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_LC_BLOCK_RX)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_LC_BLOCK_RX flag %s\n&quot;, &quot;&quot;);
 
                         /* send a BLA */
<span style="color: #800080; font-weight: bold">@@ -1124,11 +1124,11 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         goto suspend_goto_last;
                 }
 
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_LC_UNBLK_RX flag %s\n&quot;, &quot;&quot;);
                         
                         /* clear the unblock flag */
<span style="color: #A00000">-                        sngss7_clear_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX);</span>
 
                         /* send a uba */
                         /*ft_to_sngss7_uba(ftdmchan);*/
<span style="color: #800080; font-weight: bold">@@ -1137,7 +1137,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         goto suspend_goto_last;
                 }
                 /**********************************************************************/
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_UCIC_BLOCK flag %s\n&quot;, &quot;&quot;);
 
                         /* bring the channel signaling status to down */
<span style="color: #800080; font-weight: bold">@@ -1157,17 +1157,17 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)</span>
                         goto suspend_goto_last;
                 }
 
<span style="color: #A00000">-                if (sngss7_test_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {</span>
                         SS7_DEBUG_CHAN(ftdmchan, &quot;Processing CKT_UCIC_UNBLK flag %s\n&quot;, &quot;&quot;);;
 
                         /* remove the UCIC block flag */
<span style="color: #A00000">-                        sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
 
                         /* remove the UCIC unblock flag */
<span style="color: #A00000">-                        sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);</span>
 
                         /* throw the channel into reset to sync states */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_RESET_TX);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);</span>
 
                         /* bring the channel into restart again */
                         goto suspend_goto_restart;
<span style="color: #800080; font-weight: bold">@@ -1232,9 +1232,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)</span>
         }
 
         /* check if there is a remote block */
<span style="color: #A00000">-        if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||</span>
<span style="color: #A00000">-                (sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||</span>
<span style="color: #A00000">-                (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
<span style="color: #00A000">+        if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||</span>
<span style="color: #00A000">+                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_RX)) ||</span>
<span style="color: #00A000">+                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
 
                 /* the channel is blocked...can&#39;t send any calls here */
                 SS7_ERROR_CHAN(ftdmchan, &quot;Requested channel is remotely blocked, re-hunt channel!%s\n&quot;, &quot; &quot;);
<span style="color: #800080; font-weight: bold">@@ -1242,9 +1242,9 @@ static FIO_CHANNEL_OUTGOING_CALL_FUNCTION(ftdm_sangoma_ss7_outgoing_call)</span>
         }
 
         /* check if there is a local block */
<span style="color: #A00000">-        if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||</span>
<span style="color: #A00000">-                (sngss7_test_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) ||</span>
<span style="color: #A00000">-                (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
<span style="color: #00A000">+        if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||</span>
<span style="color: #00A000">+                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_HW_BLOCK_TX)) ||</span>
<span style="color: #00A000">+                (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_TX))) {</span>
 
                 /* KONRAD FIX ME : we should check if this is a TEST call and allow it */
 
<span style="color: #800080; font-weight: bold">@@ -1339,6 +1339,25 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)</span>
 
         SS7_INFO (&quot;Starting span %s:%u.\n&quot;, span-&gt;name, span-&gt;span_id);
 
<span style="color: #00A000">+        /* clear the monitor thread stop flag */</span>
<span style="color: #00A000">+        ftdm_clear_flag (span, FTDM_SPAN_STOP_THREAD);</span>
<span style="color: #00A000">+        ftdm_clear_flag (span, FTDM_SPAN_IN_THREAD);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* activate all the configured ss7 links */</span>
<span style="color: #00A000">+        if (ft_to_sngss7_activate_all()) {</span>
<span style="color: #00A000">+                SS7_CRITICAL (&quot;Failed to activate LibSngSS7!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /*start the span monitor thread */</span>
<span style="color: #00A000">+        if (ftdm_thread_create_detached (ftdm_sangoma_ss7_run, span) != FTDM_SUCCESS) {</span>
<span style="color: #00A000">+                SS7_CRITICAL (&quot;Failed to start Span Monitor Thread!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm the state of all isup interfaces*/</span>
<span style="color: #00A000">+        check_status_of_all_isup_intf();</span>
<span style="color: #00A000">+</span>
         /* throw the channels in pause */
         for (x = 1; x &lt; (span-&gt;chan_count + 1); x++) {
                 /* extract the channel structure and sngss7 channel data */
<span style="color: #800080; font-weight: bold">@@ -1348,23 +1367,24 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)</span>
                 sngss7_span = ftdmchan-&gt;span-&gt;signal_data;
                 sngss7_intf = &amp;g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId];
 
<span style="color: #A00000">-</span>
                 /* lock the channel */
                 ftdm_mutex_lock(ftdmchan-&gt;mutex);
 
                 /* check if the interface is paused or resumed */
                 if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
<span style="color: #00A000">+                        SS7_DEBUG_CHAN(ftdmchan, &quot;ISUP intf %d is PAUSED\n&quot;, sngss7_intf-&gt;id);</span>
                         /* throw the pause flag */
<span style="color: #A00000">-                        sngss7_clear_flag(sngss7_info, FLAG_INFID_RESUME);</span>
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
                 } else {
<span style="color: #A00000">-                        /* throw the pause flag */</span>
<span style="color: #A00000">-                        sngss7_clear_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_INFID_RESUME);</span>
<span style="color: #00A000">+                        SS7_DEBUG_CHAN(ftdmchan, &quot;ISUP intf %d is RESUMED\n&quot;, sngss7_intf-&gt;id);</span>
<span style="color: #00A000">+                        /* throw the resume flag */</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);</span>
                 }
 #if 0
                 /* throw the grp reset flag */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
                 if (x == 1) {
                         sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_BASE);
                         sngss7_span-&gt;tx_grs.circuit = sngss7_info-&gt;circuit-&gt;id;
<span style="color: #800080; font-weight: bold">@@ -1372,7 +1392,7 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)</span>
                 }
 #else
                 /* throw the channel into reset */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_RESET_TX);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_RESET_TX);</span>
 #endif
                 /* throw the channel to suspend */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -1381,22 +1401,6 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)</span>
                 ftdm_mutex_unlock(ftdmchan-&gt;mutex);
         }
 
<span style="color: #A00000">-        /* clear the monitor thread stop flag */</span>
<span style="color: #A00000">-        ftdm_clear_flag (span, FTDM_SPAN_STOP_THREAD);</span>
<span style="color: #A00000">-        ftdm_clear_flag (span, FTDM_SPAN_IN_THREAD);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /* activate all the configured ss7 links */</span>
<span style="color: #A00000">-        if (ft_to_sngss7_activate_all()) {</span>
<span style="color: #A00000">-                SS7_CRITICAL (&quot;Failed to activate LibSngSS7!\n&quot;);</span>
<span style="color: #A00000">-                return FTDM_FAIL;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /*start the span monitor thread */</span>
<span style="color: #A00000">-        if (ftdm_thread_create_detached (ftdm_sangoma_ss7_run, span) != FTDM_SUCCESS) {</span>
<span style="color: #A00000">-                SS7_CRITICAL (&quot;Failed to start Span Monitor Thread!\n&quot;);</span>
<span style="color: #A00000">-                return FTDM_FAIL;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
         SS7_DEBUG (&quot;Finished starting span %s:%u.\n&quot;, span-&gt;name, span-&gt;span_id);
 
         return FTDM_SUCCESS;
<span style="color: #800080; font-weight: bold">@@ -1537,7 +1541,6 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init)</span>
         sng_event.cc.sng_umsg_ind = sngss7_umsg_ind;
         sng_event.cc.sng_susp_ind = sngss7_susp_ind;
         sng_event.cc.sng_resm_ind = sngss7_resm_ind;
<span style="color: #A00000">-        sng_event.cc.sng_ssp_sta_cfm = sngss7_ssp_sta_cfm;</span>
 
         sng_event.sm.sng_log = handle_sng_log;
         sng_event.sm.sng_mtp1_alarm = handle_sng_mtp1_alarm;
<span style="color: #800080; font-weight: bold">@@ -1545,9 +1548,10 @@ static FIO_SIG_LOAD_FUNCTION(ftdm_sangoma_ss7_init)</span>
         sng_event.sm.sng_mtp3_alarm = handle_sng_mtp3_alarm;
         sng_event.sm.sng_isup_alarm = handle_sng_isup_alarm;
         sng_event.sm.sng_cc_alarm = handle_sng_cc_alarm;
<span style="color: #00A000">+        sng_event.sm.sng_relay_alarm = handle_sng_relay_alarm;</span>
 
         /* initalize sng_ss7 library */
<span style="color: #A00000">-        sng_isup_init (&amp;sng_event);</span>
<span style="color: #00A000">+        sng_isup_init_gen(&amp;sng_event);</span>
 
         /* print the version of the library being used */
         sng_isup_version(&amp;major, &amp;minor, &amp;build);
<span style="color: #800080; font-weight: bold">@@ -1566,7 +1570,32 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)</span>
 
         ftdm_log (FTDM_LOG_INFO, &quot;Starting ftmod_sangoma_ss7 unload...\n&quot;);
 
<span style="color: #A00000">-        sng_isup_free();</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_CC)) {</span>
<span style="color: #00A000">+                sng_isup_free_cc();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {</span>
<span style="color: #00A000">+                ftmod_ss7_shutdown_isup();</span>
<span style="color: #00A000">+                sng_isup_free_isup();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP3)) {</span>
<span style="color: #00A000">+                ftmod_ss7_shutdown_mtp3();</span>
<span style="color: #00A000">+                sng_isup_free_mtp3();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) {</span>
<span style="color: #00A000">+                ftmod_ss7_shutdown_mtp2();</span>
<span style="color: #00A000">+                sng_isup_free_mtp2();</span>
<span style="color: #00A000">+                sng_isup_free_mtp1();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        ftmod_ss7_shutdown_relay();</span>
<span style="color: #00A000">+        sng_isup_free_relay();</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        sng_isup_free_sm();</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        sng_isup_free_gen();</span>
 
         ftdm_log (FTDM_LOG_INFO, &quot;Finished ftmod_sangoma_ss7 unload!\n&quot;);
         return FTDM_SUCCESS;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #000080; font-weight: bold">index f28547f..5272aa8 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h</span>
<span style="color: #800080; font-weight: bold">@@ -83,12 +83,6 @@ typedef enum {</span>
 } sng_ckt_type_t;
 
 typedef enum {
<span style="color: #A00000">-        CONFIGURED                = (1 &lt;&lt; 0),</span>
<span style="color: #A00000">-        ACTIVE                        = (1 &lt;&lt; 1),</span>
<span style="color: #A00000">-        SNGSS7_PAUSED        = (1 &lt;&lt; 7)</span>
<span style="color: #A00000">-} sng_flag_t;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-typedef enum {</span>
         SNGSS7_LPA_FOR_COT                = (1 &lt;&lt; 0),        /* send LPA when COT arrives */
         SNGSS7_ACM_OBCI_BITA        = (1 &lt;&lt; 10)        /* in-band indication */
 } sng_intf_options_t;
<span style="color: #800080; font-weight: bold">@@ -98,84 +92,124 @@ typedef enum {</span>
         SNG_CALLING                        = 2
 } sng_addr_type_t;
 
<span style="color: #A00000">-typedef struct sng_mtp_link {</span>
<span style="color: #A00000">-        char                        name[MAX_NAME_LEN];</span>
<span style="color: #A00000">-        uint32_t                id;</span>
<span style="color: #A00000">-        uint32_t                flags;</span>
<span style="color: #A00000">-        struct {</span>
<span style="color: #A00000">-                uint32_t        span;</span>
<span style="color: #A00000">-                uint32_t        chan;</span>
<span style="color: #A00000">-        } mtp1;</span>
<span style="color: #A00000">-        struct {</span>
<span style="color: #A00000">-                uint32_t        lssuLength;</span>
<span style="color: #A00000">-                uint32_t        errorType;</span>
<span style="color: #A00000">-                uint32_t        linkType;</span>
<span style="color: #A00000">-                uint32_t        mtp1Id;</span>
<span style="color: #A00000">-                uint32_t        t1;</span>
<span style="color: #A00000">-                uint32_t        t2;</span>
<span style="color: #A00000">-                uint32_t        t3;</span>
<span style="color: #A00000">-                uint32_t        t4n;</span>
<span style="color: #A00000">-                uint32_t        t4e;</span>
<span style="color: #A00000">-                uint32_t        t5;</span>
<span style="color: #A00000">-                uint32_t        t6;</span>
<span style="color: #A00000">-                uint32_t        t7;</span>
<span style="color: #A00000">-        } mtp2;</span>
<span style="color: #A00000">-        struct {</span>
<span style="color: #A00000">-                uint32_t        priority;</span>
<span style="color: #A00000">-                uint32_t        linkType;</span>
<span style="color: #A00000">-                uint32_t        switchType;</span>
<span style="color: #A00000">-                uint32_t        apc;</span>
<span style="color: #A00000">-                uint32_t        spc;</span>
<span style="color: #A00000">-                uint32_t        ssf;</span>
<span style="color: #A00000">-                uint32_t        slc;</span>
<span style="color: #A00000">-                uint32_t        linkSetId;</span>
<span style="color: #A00000">-                uint32_t        mtp2Id;</span>
<span style="color: #A00000">-                uint32_t        t1;</span>
<span style="color: #A00000">-                uint32_t        t2;</span>
<span style="color: #A00000">-                uint32_t        t3;</span>
<span style="color: #A00000">-                uint32_t        t4;</span>
<span style="color: #A00000">-                uint32_t        t5;</span>
<span style="color: #A00000">-                uint32_t        t6;</span>
<span style="color: #A00000">-                uint32_t        t7;</span>
<span style="color: #A00000">-                uint32_t        t8;</span>
<span style="color: #A00000">-                uint32_t        t9;</span>
<span style="color: #A00000">-                uint32_t        t10;</span>
<span style="color: #A00000">-                uint32_t        t11;</span>
<span style="color: #A00000">-                uint32_t        t12;</span>
<span style="color: #A00000">-                uint32_t        t13;</span>
<span style="color: #A00000">-                uint32_t        t14;</span>
<span style="color: #A00000">-                uint32_t        t15;</span>
<span style="color: #A00000">-                uint32_t        t16;</span>
<span style="color: #A00000">-                uint32_t        t17;</span>
<span style="color: #A00000">-                uint32_t        t18;</span>
<span style="color: #A00000">-                uint32_t        t19;</span>
<span style="color: #A00000">-                uint32_t        t20;</span>
<span style="color: #A00000">-                uint32_t        t21;</span>
<span style="color: #A00000">-                uint32_t        t22;</span>
<span style="color: #A00000">-                uint32_t        t23;</span>
<span style="color: #A00000">-                uint32_t        t24;</span>
<span style="color: #A00000">-                uint32_t        t25;</span>
<span style="color: #A00000">-                uint32_t        t27;</span>
<span style="color: #A00000">-                uint32_t        t28;</span>
<span style="color: #A00000">-                uint32_t        t29;</span>
<span style="color: #A00000">-                uint32_t        t30;</span>
<span style="color: #A00000">-                uint32_t        t31;</span>
<span style="color: #A00000">-                uint32_t        t32;</span>
<span style="color: #A00000">-                uint32_t        t33;</span>
<span style="color: #A00000">-                uint32_t        t34;</span>
<span style="color: #A00000">-                uint32_t        t35;</span>
<span style="color: #A00000">-                uint32_t        t36;</span>
<span style="color: #A00000">-                uint32_t        t37;</span>
<span style="color: #A00000">-                uint32_t        tcraft;</span>
<span style="color: #A00000">-                uint32_t        tflc;</span>
<span style="color: #A00000">-                uint32_t        tbnd;</span>
<span style="color: #A00000">-        } mtp3;</span>
<span style="color: #A00000">-} sng_mtp_link_t;</span>
<span style="color: #00A000">+typedef struct sng_mtp2_error_type {</span>
<span style="color: #00A000">+        int        init;</span>
<span style="color: #00A000">+        char sng_type[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t tril_type;</span>
<span style="color: #00A000">+} sng_mtp2_error_type_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_link_type {</span>
<span style="color: #00A000">+        int init;</span>
<span style="color: #00A000">+        char sng_type[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t tril_mtp2_type;</span>
<span style="color: #00A000">+        uint32_t tril_mtp3_type;</span>
<span style="color: #00A000">+} sng_link_type_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_switch_type {</span>
<span style="color: #00A000">+        int init;</span>
<span style="color: #00A000">+        char sng_type[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t tril_mtp3_type;</span>
<span style="color: #00A000">+        uint32_t tril_isup_type;</span>
<span style="color: #00A000">+} sng_switch_type_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_ssf_type {</span>
<span style="color: #00A000">+        int init;</span>
<span style="color: #00A000">+        char sng_type[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t tril_type;</span>
<span style="color: #00A000">+} sng_ssf_type_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_cic_cntrl_type {</span>
<span style="color: #00A000">+        int init;</span>
<span style="color: #00A000">+        char sng_type[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t tril_type;</span>
<span style="color: #00A000">+} sng_cic_cntrl_type_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_mtp1_link {</span>
<span style="color: #00A000">+        char                name[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t        flags;</span>
<span style="color: #00A000">+        uint32_t        id;</span>
<span style="color: #00A000">+        uint32_t        span;</span>
<span style="color: #00A000">+        uint32_t        chan;</span>
<span style="color: #00A000">+} sng_mtp1_link_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_mtp2_link {</span>
<span style="color: #00A000">+        char                name[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t        flags;</span>
<span style="color: #00A000">+        uint32_t        id;</span>
<span style="color: #00A000">+        uint32_t        lssuLength;</span>
<span style="color: #00A000">+        uint32_t        errorType;</span>
<span style="color: #00A000">+        uint32_t        linkType;</span>
<span style="color: #00A000">+        uint32_t        mtp1Id;</span>
<span style="color: #00A000">+        uint32_t        mtp1ProcId;</span>
<span style="color: #00A000">+        uint32_t        t1;</span>
<span style="color: #00A000">+        uint32_t        t2;</span>
<span style="color: #00A000">+        uint32_t        t3;</span>
<span style="color: #00A000">+        uint32_t        t4n;</span>
<span style="color: #00A000">+        uint32_t        t4e;</span>
<span style="color: #00A000">+        uint32_t        t5;</span>
<span style="color: #00A000">+        uint32_t        t6;</span>
<span style="color: #00A000">+        uint32_t        t7;</span>
<span style="color: #00A000">+} sng_mtp2_link_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_mtp3_link {</span>
<span style="color: #00A000">+        char                name[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t        flags;</span>
<span style="color: #00A000">+        uint32_t        id;</span>
<span style="color: #00A000">+        uint32_t        priority;</span>
<span style="color: #00A000">+        uint32_t        linkType;</span>
<span style="color: #00A000">+        uint32_t        switchType;</span>
<span style="color: #00A000">+        uint32_t        apc;</span>
<span style="color: #00A000">+        uint32_t        spc;</span>
<span style="color: #00A000">+        uint32_t        ssf;</span>
<span style="color: #00A000">+        uint32_t        slc;</span>
<span style="color: #00A000">+        uint32_t        linkSetId;</span>
<span style="color: #00A000">+        uint32_t        mtp2Id;</span>
<span style="color: #00A000">+        uint32_t        mtp2ProcId;</span>
<span style="color: #00A000">+        uint32_t        t1;</span>
<span style="color: #00A000">+        uint32_t        t2;</span>
<span style="color: #00A000">+        uint32_t        t3;</span>
<span style="color: #00A000">+        uint32_t        t4;</span>
<span style="color: #00A000">+        uint32_t        t5;</span>
<span style="color: #00A000">+        uint32_t        t6;</span>
<span style="color: #00A000">+        uint32_t        t7;</span>
<span style="color: #00A000">+        uint32_t        t8;</span>
<span style="color: #00A000">+        uint32_t        t9;</span>
<span style="color: #00A000">+        uint32_t        t10;</span>
<span style="color: #00A000">+        uint32_t        t11;</span>
<span style="color: #00A000">+        uint32_t        t12;</span>
<span style="color: #00A000">+        uint32_t        t13;</span>
<span style="color: #00A000">+        uint32_t        t14;</span>
<span style="color: #00A000">+        uint32_t        t15;</span>
<span style="color: #00A000">+        uint32_t        t16;</span>
<span style="color: #00A000">+        uint32_t        t17;</span>
<span style="color: #00A000">+        uint32_t        t18;</span>
<span style="color: #00A000">+        uint32_t        t19;</span>
<span style="color: #00A000">+        uint32_t        t20;</span>
<span style="color: #00A000">+        uint32_t        t21;</span>
<span style="color: #00A000">+        uint32_t        t22;</span>
<span style="color: #00A000">+        uint32_t        t23;</span>
<span style="color: #00A000">+        uint32_t        t24;</span>
<span style="color: #00A000">+        uint32_t        t25;</span>
<span style="color: #00A000">+        uint32_t        t27;</span>
<span style="color: #00A000">+        uint32_t        t28;</span>
<span style="color: #00A000">+        uint32_t        t29;</span>
<span style="color: #00A000">+        uint32_t        t30;</span>
<span style="color: #00A000">+        uint32_t        t31;</span>
<span style="color: #00A000">+        uint32_t        t32;</span>
<span style="color: #00A000">+        uint32_t        t33;</span>
<span style="color: #00A000">+        uint32_t        t34;</span>
<span style="color: #00A000">+        uint32_t        t35;</span>
<span style="color: #00A000">+        uint32_t        t36;</span>
<span style="color: #00A000">+        uint32_t        t37;</span>
<span style="color: #00A000">+        uint32_t        tcraft;</span>
<span style="color: #00A000">+        uint32_t        tflc;</span>
<span style="color: #00A000">+        uint32_t        tbnd;</span>
<span style="color: #00A000">+} sng_mtp3_link_t;</span>
 
 typedef struct sng_link_set {
<span style="color: #A00000">-        uint32_t                id;</span>
         char                        name[MAX_NAME_LEN];
         uint32_t                flags;
<span style="color: #00A000">+        uint32_t                id;</span>
         uint32_t                apc;
         uint32_t                linkType;
         uint32_t                switchType;
<span style="color: #800080; font-weight: bold">@@ -186,9 +220,9 @@ typedef struct sng_link_set {</span>
 } sng_link_set_t;
 
 typedef struct sng_route {
<span style="color: #A00000">-        uint32_t                id;</span>
         char                        name[MAX_NAME_LEN];
         uint32_t                flags;
<span style="color: #00A000">+        uint32_t                id;</span>
         uint32_t                dpc;
         uint32_t                cmbLinkSetId;
         uint32_t                linkSetId;
<span style="color: #800080; font-weight: bold">@@ -211,10 +245,10 @@ typedef struct sng_route {</span>
 } sng_route_t;
 
 typedef struct sng_isup_intf {
<span style="color: #A00000">-        uint32_t                id;</span>
         char                        name[MAX_NAME_LEN];
         uint32_t                options;
         uint32_t                flags;
<span style="color: #00A000">+        uint32_t                id;</span>
         uint32_t                spc;
         uint32_t                dpc;
         uint32_t                switchType;
<span style="color: #800080; font-weight: bold">@@ -222,9 +256,6 @@ typedef struct sng_isup_intf {</span>
         uint32_t                mtpRouteId;
         uint32_t                ssf;
         uint32_t                isap;
<span style="color: #A00000">-        uint32_t                clg_nadi;</span>
<span style="color: #A00000">-        uint32_t                cld_nadi;</span>
<span style="color: #A00000">-        uint32_t                min_digits;</span>
         uint16_t                t4;
         uint32_t                t10;
         uint32_t                t11;
<span style="color: #800080; font-weight: bold">@@ -241,7 +272,6 @@ typedef struct sng_isup_intf {</span>
         uint32_t                t29;
         uint32_t                t30;
         uint32_t                t32;
<span style="color: #A00000">-        uint32_t                t35;</span>
         uint32_t                t37;
         uint32_t                t38;
         uint32_t                t39;
<span style="color: #800080; font-weight: bold">@@ -251,15 +281,23 @@ typedef struct sng_isup_intf {</span>
 } sng_isup_inf_t;
 
 typedef struct sng_isup_ckt {
<span style="color: #A00000">-        uint32_t                id;</span>
<span style="color: #00A000">+        uint32_t                options;</span>
         uint32_t                flags;
<span style="color: #00A000">+        uint32_t                ckt_flags;</span>
<span style="color: #00A000">+        uint32_t                procId;</span>
<span style="color: #00A000">+        uint32_t                id;</span>
<span style="color: #00A000">+        uint32_t                ccSpanId;</span>
         uint32_t                span;
         uint32_t                chan;
         uint32_t                type;        /* VOICE/SIG/HOLE */
         uint32_t                cic;
         uint32_t                infId;
<span style="color: #A00000">-        uint32_t                ssf;</span>
         uint32_t                typeCntrl;
<span style="color: #00A000">+        uint32_t                ssf;</span>
<span style="color: #00A000">+        uint32_t                switchType;</span>
<span style="color: #00A000">+        uint32_t                clg_nadi;</span>
<span style="color: #00A000">+        uint32_t                cld_nadi;</span>
<span style="color: #00A000">+        uint32_t                min_digits;</span>
         void                        *obj;
         uint16_t                t3;
         uint16_t                t12;
<span style="color: #800080; font-weight: bold">@@ -268,12 +306,13 @@ typedef struct sng_isup_ckt {</span>
         uint16_t                t15;
         uint16_t                t16;
         uint16_t                t17;
<span style="color: #00A000">+        uint32_t                t35;</span>
         uint16_t                tval;
 } sng_isup_ckt_t;
 
 typedef struct sng_nsap {
<span style="color: #A00000">-        uint32_t                id;</span>
         uint32_t                flags;
<span style="color: #00A000">+        uint32_t                id;</span>
         uint32_t                suId;
         uint32_t                spId;
         uint32_t                nwId;
<span style="color: #800080; font-weight: bold">@@ -311,15 +350,30 @@ typedef struct sng_isap {</span>
         uint32_t                tfnlrelrsp;
 } sng_isap_t;
 
<span style="color: #00A000">+typedef struct sng_relay {</span>
<span style="color: #00A000">+        uint32_t                id;</span>
<span style="color: #00A000">+        char                        name[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t                flags;</span>
<span style="color: #00A000">+        uint32_t                type;</span>
<span style="color: #00A000">+        uint32_t                port;</span>
<span style="color: #00A000">+        char                        hostname[RY_REMHOSTNAME_SIZE];</span>
<span style="color: #00A000">+        uint32_t                procId;</span>
<span style="color: #00A000">+} sng_relay_t;</span>
<span style="color: #00A000">+</span>
 typedef struct sng_ss7_cfg {
         uint32_t                        spc;
<span style="color: #00A000">+        uint32_t                        procId;</span>
         char                                license[MAX_PATH];
         char                                signature[MAX_PATH];
<span style="color: #A00000">-        sng_mtp_link_t                mtpLink[MAX_MTP_LINKS+1];</span>
<span style="color: #00A000">+        uint32_t                        flags;</span>
<span style="color: #00A000">+        sng_relay_t                        relay[MAX_RELAY_CHANNELS+1];</span>
<span style="color: #00A000">+        sng_mtp1_link_t                mtp1Link[MAX_MTP_LINKS+1];</span>
<span style="color: #00A000">+        sng_mtp2_link_t                mtp2Link[MAX_MTP_LINKS+1];</span>
<span style="color: #00A000">+        sng_mtp3_link_t                mtp3Link[MAX_MTP_LINKS+1];</span>
         sng_link_set_t                mtpLinkSet[MAX_MTP_LINKSETS+1];
         sng_route_t                        mtpRoute[MAX_MTP_ROUTES+1];
         sng_isup_inf_t                isupIntf[MAX_ISUP_INFS+1];
<span style="color: #A00000">-        sng_isup_ckt_t                isupCkt[MAX_ISUP_CKTS+1];</span>
<span style="color: #00A000">+        sng_isup_ckt_t                isupCkt[10000];         /* KONRAD - only need 2000 ( and 0-1000 aren&#39;t used) since other servers are registerd else where */</span>
         sng_nsap_t                        nsap[MAX_NSAPS+1];
         sng_isap_t                        isap[MAX_ISAPS+1];        
 }sng_ss7_cfg_t;
<span style="color: #800080; font-weight: bold">@@ -365,7 +419,7 @@ typedef struct sngss7_chan_data {</span>
         uint32_t                                spInstId;
         uint32_t                                spId;
         uint8_t                                        globalFlg;
<span style="color: #A00000">-        uint32_t                                flags;</span>
<span style="color: #00A000">+        uint32_t                                ckt_flags;</span>
         sngss7_glare_data_t                glare;
         sngss7_timer_data_t                t35;
 }sngss7_chan_data_t;
<span style="color: #800080; font-weight: bold">@@ -407,8 +461,6 @@ typedef struct sngss7_event_data</span>
 } sngss7_event_data_t;
 
 
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
 typedef enum {
         FLAG_RESET_RX                        = (1 &lt;&lt; 0),
         FLAG_RESET_TX                        = (1 &lt;&lt; 1),
<span style="color: #800080; font-weight: bold">@@ -439,15 +491,39 @@ typedef enum {</span>
         FLAG_GRP_MN_BLOCK_RX        = (1 &lt;&lt; 26),
         FLAG_GRP_MN_BLOCK_TX        = (1 &lt;&lt; 27),
         FLAG_GRP_HW_UNBLK_TX        = (1 &lt;&lt; 28),
<span style="color: #A00000">-        FLAG_GRP_MN_UNBLK_TX        = (1 &lt;&lt; 29)</span>
<span style="color: #A00000">-} flag_t;</span>
<span style="color: #00A000">+        FLAG_GRP_MN_UNBLK_TX        = (1 &lt;&lt; 29),</span>
<span style="color: #00A000">+        FLAG_RELAY_DOWN                        = (1 &lt;&lt; 30)</span>
<span style="color: #00A000">+} sng_ckt_flag_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* valid for every cfg array except circuits */</span>
<span style="color: #00A000">+typedef enum {</span>
<span style="color: #00A000">+        SNGSS7_CONFIGURED                = (1 &lt;&lt; 0),</span>
<span style="color: #00A000">+        SNGSS7_ACTIVE                        = (1 &lt;&lt; 1),</span>
<span style="color: #00A000">+        SNGSS7_RELAY_INIT                = (1 &lt;&lt; 3),</span>
<span style="color: #00A000">+        SNGSS7_PAUSED                        = (1 &lt;&lt; 7) /* for isup interfaces */</span>
<span style="color: #00A000">+} sng_cfg_flag_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef enum {</span>
<span style="color: #00A000">+        SNGSS7_SM                = (1 &lt;&lt; 0),</span>
<span style="color: #00A000">+        SNGSS7_RY                = (1 &lt;&lt; 1),</span>
<span style="color: #00A000">+        SNGSS7_MTP1                = (1 &lt;&lt; 2),</span>
<span style="color: #00A000">+        SNGSS7_MTP2                = (1 &lt;&lt; 3),</span>
<span style="color: #00A000">+        SNGSS7_MTP3                = (1 &lt;&lt; 4),</span>
<span style="color: #00A000">+        SNGSS7_ISUP                = (1 &lt;&lt; 5),</span>
<span style="color: #00A000">+        SNGSS7_CC                = (1 &lt;&lt; 6)</span>
<span style="color: #00A000">+} sng_task_flag_t;</span>
 /******************************************************************************/
 
 /* GLOBALS ********************************************************************/
<span style="color: #A00000">-extern ftdm_sngss7_data_t   g_ftdm_sngss7_data;</span>
<span style="color: #A00000">-extern uint32_t                         sngss7_id;</span>
<span style="color: #A00000">-extern ftdm_sched_t                 *sngss7_sched;</span>
<span style="color: #A00000">-extern int                                cmbLinkSetId;</span>
<span style="color: #00A000">+extern ftdm_sngss7_data_t                g_ftdm_sngss7_data;</span>
<span style="color: #00A000">+extern sng_ssf_type_t                        sng_ssf_type_map[];</span>
<span style="color: #00A000">+extern sng_switch_type_t                sng_switch_type_map[];</span>
<span style="color: #00A000">+extern sng_link_type_t                        sng_link_type_map[];</span>
<span style="color: #00A000">+extern sng_mtp2_error_type_t        sng_mtp2_error_type_map[];</span>
<span style="color: #00A000">+extern sng_cic_cntrl_type_t         sng_cic_cntrl_type_map[];</span>
<span style="color: #00A000">+extern uint32_t                                        sngss7_id;</span>
<span style="color: #00A000">+extern ftdm_sched_t                                *sngss7_sched;</span>
<span style="color: #00A000">+extern int                                                cmbLinkSetId;</span>
 /******************************************************************************/
 
 /* PROTOTYPES *****************************************************************/
<span style="color: #800080; font-weight: bold">@@ -461,6 +537,12 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);</span>
 void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta);
 void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta);
 void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta);
<span style="color: #00A000">+void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* in ftmod_sangoma_ss7_relay.c */</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_connect(RyMngmt *sta);</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_disconnect_on_down(RyMngmt *sta);</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta);</span>
 
 /* in ftmod_sangoma_ss7_cfg.c */
 int ft_to_sngss7_cfg_all(void);
<span style="color: #800080; font-weight: bold">@@ -484,20 +566,36 @@ int ftmod_ss7_cc_isap_config(int id);</span>
 /* in ftmod_sangoma_ss7_cntrl.c */
 int  ft_to_sngss7_activate_all(void);
 
<span style="color: #A00000">-int ftmod_ss7_inhibit_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_uninhibit_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_activate_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_deactivate_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_deactivate2_mtplink(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_inhibit_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_uninhibit_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_bind_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_unbind_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_activate_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_deactivate_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_deactivate2_mtp3link(uint32_t id);</span>
 int ftmod_ss7_activate_mtplinkSet(uint32_t id);
 int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
 int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
<span style="color: #A00000">-int ftmod_ss7_lpo_mtplink(uint32_t id);</span>
<span style="color: #A00000">-int ftmod_ss7_lpr_mtplink(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_lpo_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+int ftmod_ss7_lpr_mtp3link(uint32_t id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_isup(void);</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_mtp3(void);</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_mtp2(void);</span>
<span style="color: #00A000">+int ftmod_ss7_shutdown_relay(void);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int ftmod_ss7_disable_grp_mtp3Link(uint32_t procId);</span>
<span style="color: #00A000">+int ftmod_ss7_enable_grp_mtp3Link(uint32_t procId);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int ftmod_ss7_disable_grp_mtp2Link(uint32_t procId);</span>
 
 /* in ftmod_sangoma_ss7_sta.c */
<span style="color: #A00000">-int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm);</span>
<span style="color: #00A000">+int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm);</span>
<span style="color: #00A000">+int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm);</span>
<span style="color: #00A000">+int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm);</span>
 int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm);
<span style="color: #00A000">+int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status);</span>
<span style="color: #00A000">+int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm);</span>
 
 
 /* in ftmod_sangoma_ss7_out.c */
<span style="color: #800080; font-weight: bold">@@ -607,6 +705,14 @@ ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info);</span>
 ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type);
 ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type);
 
<span style="color: #00A000">+int find_mtp2_error_type_in_map(const char *err_type);</span>
<span style="color: #00A000">+int find_link_type_in_map(const char *linkType);</span>
<span style="color: #00A000">+int find_switch_type_in_map(const char *switchType);</span>
<span style="color: #00A000">+int find_ssf_type_in_map(const char *ssfType);</span>
<span style="color: #00A000">+int find_cic_cntrl_in_map(const char *cntrlType);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+ftdm_status_t check_status_of_all_isup_intf(void);</span>
<span style="color: #00A000">+</span>
 /* in ftmod_sangoma_ss7_timers.c */
 void handle_isup_t35(void *userdata);
 /******************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -739,6 +845,10 @@ void handle_isup_t35(void *userdata);</span>
 #define sngss7_clear_flag(obj, flag) ((obj)-&gt;flags &amp;= ~(flag))
 #define sngss7_set_flag(obj, flag)   ((obj)-&gt;flags |= (flag))
 
<span style="color: #00A000">+#define sngss7_test_ckt_flag(obj, flag)  ((obj)-&gt;ckt_flags &amp; flag)</span>
<span style="color: #00A000">+#define sngss7_clear_ckt_flag(obj, flag) ((obj)-&gt;ckt_flags &amp;= ~(flag))</span>
<span style="color: #00A000">+#define sngss7_set_ckt_flag(obj, flag)   ((obj)-&gt;ckt_flags |= (flag))</span>
<span style="color: #00A000">+</span>
 #define sngss7_test_options(obj, option) ((obj)-&gt;options &amp; option)
 #define sngss7_clear_options(obj, option) ((obj)-&gt;options &amp;= ~(option))
 #define sngss7_set_options(obj, option)   ((obj)-&gt;options |= (option))
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c</span>
<span style="color: #000080; font-weight: bold">index ec8d7df..06b0b21 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c</span>
<span style="color: #800080; font-weight: bold">@@ -125,9 +125,9 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)</span>
         iam.txMedReq.trMedReq.pres                         = PRSNT_NODEF;
         iam.txMedReq.trMedReq.val                         = ftdmchan-&gt;caller_data.bearer_capability;
 
<span style="color: #A00000">-        if ((g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId].switchType == LSI_SW_ANS88) ||</span>
<span style="color: #A00000">-                (g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId].switchType == LSI_SW_ANS92) ||</span>
<span style="color: #A00000">-                (g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId].switchType == LSI_SW_ANS95)) {</span>
<span style="color: #00A000">+        if ((g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info-&gt;circuit-&gt;id].switchType == LSI_SW_ANS88) ||</span>
<span style="color: #00A000">+                (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info-&gt;circuit-&gt;id].switchType == LSI_SW_ANS92) ||</span>
<span style="color: #00A000">+                (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info-&gt;circuit-&gt;id].switchType == LSI_SW_ANS95)) {</span>
 
                 /* include only if we&#39;re running ANSI */
                 iam.fwdCallInd.transCallNInd.pres   = PRSNT_NODEF;
<span style="color: #800080; font-weight: bold">@@ -178,7 +178,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)</span>
                 iam.usrServInfoA.rateMultiplier.pres        = PRSNT_NODEF;
                 iam.usrServInfoA.rateMultiplier.val                = 0x1;                                /* 1x rate multipler */
         } /* if ANSI */
<span style="color: #A00000">-        </span>
<span style="color: #00A000">+</span>
         /* copy down the called number information */
         copy_cdPtyNum_to_sngss7 (&amp;ftdmchan-&gt;caller_data, &amp;iam.cdPtyNum);
         
<span style="color: #800080; font-weight: bold">@@ -192,7 +192,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)</span>
                 SS7_DEBUG_CHAN(ftdmchan,&quot;Found user supplied Calling NADI value \&quot;%s\&quot;\n&quot;, clg_nadi);
                 iam.cgPtyNum.natAddrInd.val        = atoi(clg_nadi);
         } else {
<span style="color: #A00000">-                iam.cgPtyNum.natAddrInd.val        = g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId].clg_nadi;</span>
<span style="color: #00A000">+                iam.cgPtyNum.natAddrInd.val        = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info-&gt;circuit-&gt;id].clg_nadi;</span>
                 SS7_DEBUG_CHAN(ftdmchan,&quot;No user supplied NADI value found for CLG, using \&quot;%d\&quot;\n&quot;, iam.cgPtyNum.natAddrInd.val);
         }
 
<span style="color: #800080; font-weight: bold">@@ -201,7 +201,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)</span>
                 SS7_DEBUG_CHAN(ftdmchan,&quot;Found user supplied Called NADI value \&quot;%s\&quot;\n&quot;, cld_nadi);
                 iam.cdPtyNum.natAddrInd.val        = atoi(cld_nadi);
         } else {
<span style="color: #A00000">-                iam.cdPtyNum.natAddrInd.val        = g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId].cld_nadi;</span>
<span style="color: #00A000">+                iam.cdPtyNum.natAddrInd.val        = g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info-&gt;circuit-&gt;id].cld_nadi;</span>
                 SS7_DEBUG_CHAN(ftdmchan,&quot;No user supplied NADI value found for CLD, using \&quot;%d\&quot;\n&quot;, iam.cdPtyNum.natAddrInd.val);
         }
 
<span style="color: #800080; font-weight: bold">@@ -310,7 +310,6 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)</span>
         SS7_FUNC_TRACE_ENTER (__FUNCTION__);
         
         sngss7_chan_data_t        *sngss7_info = ftdmchan-&gt;call_data;
<span style="color: #A00000">-        sng_isup_inf_t                *isup_intf =  &amp;g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info-&gt;circuit-&gt;infId];</span>
         SiCnStEvnt acm;
         
         memset (&amp;acm, 0x0, sizeof (acm));
<span style="color: #800080; font-weight: bold">@@ -360,8 +359,8 @@ void ft_to_sngss7_acm (ftdm_channel_t * ftdmchan)</span>
         acm.bckCallInd.sccpMethInd.val                = SCCPMTH_NOIND;
 
         /* fill in any optional parameters */
<span style="color: #A00000">-        if (sngss7_test_options(isup_intf, SNGSS7_ACM_OBCI_BITA)) {</span>
<span style="color: #A00000">-                SS7_DEBUG_CHAN(ftdmchan, &quot;Found ACM_OBCI_BITA flag:0x%X\n&quot;, isup_intf-&gt;options);</span>
<span style="color: #00A000">+        if (sngss7_test_options(&amp;g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info-&gt;circuit-&gt;id], SNGSS7_ACM_OBCI_BITA)) {</span>
<span style="color: #00A000">+                SS7_DEBUG_CHAN(ftdmchan, &quot;Found ACM_OBCI_BITA flag:0x%X\n&quot;, g_ftdm_sngss7_data.cfg.isupCkt[sngss7_info-&gt;circuit-&gt;id].options);</span>
                 acm.optBckCalInd.eh.pres                                = PRSNT_NODEF;
                 acm.optBckCalInd.inbndInfoInd.pres                = PRSNT_NODEF;
                 acm.optBckCalInd.inbndInfoInd.val                = 0x1;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..05ea69e</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,318 @@</span>
<span style="color: #00A000">+/*</span>
<span style="color: #00A000">+ * Copyright (c) 2009|Konrad Hammel &lt;konrad@sangoma.com&gt;</span>
<span style="color: #00A000">+ * All rights reserved.</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * Redistribution and use in source and binary forms|with or without</span>
<span style="color: #00A000">+ * modification|are permitted provided that the following conditions</span>
<span style="color: #00A000">+ * are met:</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * * Redistributions of source code must retain the above copyright</span>
<span style="color: #00A000">+ * notice|this list of conditions and the following disclaimer.</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * * Redistributions in binary form must reproduce the above copyright</span>
<span style="color: #00A000">+ * notice|this list of conditions and the following disclaimer in the</span>
<span style="color: #00A000">+ * documentation and/or other materials provided with the distribution.</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * * Neither the name of the original author; nor the names of any contributors</span>
<span style="color: #00A000">+ * may be used to endorse or promote products derived from this software</span>
<span style="color: #00A000">+ * without specific prior written permission.</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ *</span>
<span style="color: #00A000">+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<span style="color: #00A000">+ * &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES|INCLUDING|BUT NOT</span>
<span style="color: #00A000">+ * LIMITED TO|THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
<span style="color: #00A000">+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER</span>
<span style="color: #00A000">+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT|INDIRECT|INCIDENTAL|SPECIAL,</span>
<span style="color: #00A000">+ * EXEMPLARY|OR CONSEQUENTIAL DAMAGES (INCLUDING|BUT NOT LIMITED TO,</span>
<span style="color: #00A000">+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE|DATA|OR</span>
<span style="color: #00A000">+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF</span>
<span style="color: #00A000">+ * LIABILITY|WHETHER IN CONTRACT|STRICT LIABILITY|OR TORT (INCLUDING</span>
<span style="color: #00A000">+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<span style="color: #00A000">+ * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<span style="color: #00A000">+ */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* INCLUDE ********************************************************************/</span>
<span style="color: #00A000">+#include &quot;ftmod_sangoma_ss7_main.h&quot;</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* DEFINES ********************************************************************/</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* GLOBALS ********************************************************************/</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* PROTOTYPES *****************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_connect(RyMngmt *sta);</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_disconnect(RyMngmt *sta);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static ftdm_status_t enable_all_ckts_for_relay(void);</span>
<span style="color: #00A000">+static ftdm_status_t reconfig_all_ckts_for_relay(void);</span>
<span style="color: #00A000">+static ftdm_status_t disable_all_ckts_for_relay(void);</span>
<span style="color: #00A000">+static ftdm_status_t block_all_ckts_for_relay(uint32_t procId);</span>
<span style="color: #00A000">+static ftdm_status_t disable_all_sigs_for_relay(uint32_t procId);</span>
<span style="color: #00A000">+static ftdm_status_t disble_all_mtp2_sigs_for_relay(void);</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/* FUNCTIONS ******************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_connect(RyMngmt *sta)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sng_relay_t        *sng_relay = &amp;g_ftdm_sngss7_data.cfg.relay[sta-&gt;t.usta.s.ryUpUsta.id];</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* test if this is the first time the channel comes up */</span>
<span style="color: #00A000">+        if (!sngss7_test_flag(sng_relay, SNGSS7_RELAY_INIT)) {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Relay Channel %d initial connection UP\n&quot;, sng_relay-&gt;id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* mark the channel as being up */</span>
<span style="color: #00A000">+                sngss7_set_flag(sng_relay, SNGSS7_RELAY_INIT);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Relay Channel %d connection UP\n&quot;, sng_relay-&gt;id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* react based on type of channel */</span>
<span style="color: #00A000">+                switch (sng_relay-&gt;type) {</span>
<span style="color: #00A000">+                /******************************************************************/</span>
<span style="color: #00A000">+                case (LRY_CT_TCP_CLIENT):</span>
<span style="color: #00A000">+                        /* reconfigure all ISUP ckts, since the main system would have lost all configs */</span>
<span style="color: #00A000">+                        if (reconfig_all_ckts_for_relay()) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Failed to reconfigure ISUP Ckts!\n&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                /* we&#39;re done....this is very bad! */</span>
<span style="color: #00A000">+                        } else {                                </span>
<span style="color: #00A000">+                                enable_all_ckts_for_relay();</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /******************************************************************/</span>
<span style="color: #00A000">+                case (LRY_CT_TCP_SERVER):</span>
<span style="color: #00A000">+                        /*unblock_all_ckts_for_relay(sta-&gt;t.usta.s.ryErrUsta.errPid);*/</span>
<span style="color: #00A000">+                        ftmod_ss7_enable_grp_mtp3Link(sta-&gt;t.usta.s.ryUpUsta.id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /******************************************************************/</span>
<span style="color: #00A000">+                default:</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /******************************************************************/</span>
<span style="color: #00A000">+                } /* switch (g_ftdm_sngss7_data.cfg.relay[sta-&gt;t.usta.s.ryUpUsta.id].type) */</span>
<span style="color: #00A000">+        } /* intial up? */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_disconnect_on_error(RyMngmt *sta)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check which procId is in error, if it is 1, disable the ckts */</span>
<span style="color: #00A000">+        if (sta-&gt;t.usta.s.ryErrUsta.errPid == 1 ) {</span>
<span style="color: #00A000">+                disable_all_ckts_for_relay();</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                disble_all_mtp2_sigs_for_relay();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check if the channel is a server, means we just lost a MGW */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.relay[sta-&gt;t.usta.s.ryErrUsta.errPid].type == LRY_CT_TCP_SERVER) {</span>
<span style="color: #00A000">+                block_all_ckts_for_relay(sta-&gt;t.usta.s.ryErrUsta.errPid);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                disable_all_sigs_for_relay(sta-&gt;t.usta.s.ryErrUsta.errPid);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t handle_relay_disconnect_on_down(RyMngmt *sta)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check if the channel is a server, means we just lost a MGW */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.relay[sta-&gt;t.usta.s.ryUpUsta.id].type == LRY_CT_TCP_SERVER) {</span>
<span style="color: #00A000">+                block_all_ckts_for_relay(sta-&gt;t.usta.s.ryUpUsta.id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                disable_all_sigs_for_relay(sta-&gt;t.usta.s.ryUpUsta.id);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t disable_all_ckts_for_relay(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sngss7_chan_data_t        *sngss7_info = NULL;</span>
<span style="color: #00A000">+        ftdm_channel_t                *ftdmchan = NULL;</span>
<span style="color: #00A000">+        int                                        x;        </span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        SS7_INFO(&quot;Disabling all ckts becuase of Relay loss\n&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #00A000">+        /**********************************************************************/</span>
<span style="color: #00A000">+                /* make sure this is voice channel */</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                        /* get the ftdmchan and ss7_chan_data from the circuit */</span>
<span style="color: #00A000">+                        if (extract_chan_data(g_ftdm_sngss7_data.cfg.isupCkt[x].id, &amp;sngss7_info, &amp;ftdmchan)) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Failed to extract channel data for circuit = %d!\n&quot;, g_ftdm_sngss7_data.cfg.isupCkt[x].id);</span>
<span style="color: #00A000">+                                x++;</span>
<span style="color: #00A000">+                                continue;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* throw the relay_down flag */</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_RELAY_DOWN);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* throw the channel infId status flags to PAUSED ... they will be executed next process cycle */</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag(sngss7_info, FLAG_INFID_RESUME);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
<span style="color: #00A000">+                } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move along */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        /**********************************************************************/</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t enable_all_ckts_for_relay(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sngss7_chan_data_t        *sngss7_info = NULL;</span>
<span style="color: #00A000">+        sng_isup_inf_t                *sngIntf = NULL;</span>
<span style="color: #00A000">+        ftdm_channel_t                *ftdmchan = NULL;</span>
<span style="color: #00A000">+        int                                        x;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        SS7_INFO(&quot;Enabling all ckts becuase of Relay connection\n&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #00A000">+        /**********************************************************************/</span>
<span style="color: #00A000">+                /* make sure this is voice channel */</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                        /* get the ftdmchan and ss7_chan_data from the circuit */</span>
<span style="color: #00A000">+                        if (extract_chan_data(g_ftdm_sngss7_data.cfg.isupCkt[x].id, &amp;sngss7_info, &amp;ftdmchan)) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Failed to extract channel data for circuit = %d!\n&quot;, g_ftdm_sngss7_data.cfg.isupCkt[x].id);</span>
<span style="color: #00A000">+                                x++;</span>
<span style="color: #00A000">+                                continue;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* bring the relay_down flag down */</span>
<span style="color: #00A000">+                        sngss7_clear_ckt_flag(sngss7_info, FLAG_RELAY_DOWN);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        sngIntf = &amp;g_ftdm_sngss7_data.cfg.isupIntf[g_ftdm_sngss7_data.cfg.isupCkt[x].infId];</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* check if the interface is paused or resumed */</span>
<span style="color: #00A000">+                        if (sngss7_test_flag(sngIntf, SNGSS7_PAUSED)) {</span>
<span style="color: #00A000">+                                /* don&#39;t bring the channel resume flag up...the interface is down */</span>
<span style="color: #00A000">+                                SS7_DEBUG_CHAN(ftdmchan, &quot;ISUP interface (%d) set to paused, not resuming channel\n&quot;, sngIntf-&gt;id);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_DEBUG_CHAN(ftdmchan, &quot;ISUP interface (%d) set to resume, resuming channel\n&quot;, sngIntf-&gt;id);</span>
<span style="color: #00A000">+                                /* throw the channel infId status flags to PAUSED ... they will be executed next process cycle */</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_RESUME);</span>
<span style="color: #00A000">+                                sngss7_set_ckt_flag(sngss7_info, FLAG_INFID_PAUSED);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move along */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        /**********************************************************************/</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t reconfig_all_ckts_for_relay(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+#if 1</span>
<span style="color: #00A000">+        int x;</span>
<span style="color: #00A000">+        int ret;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #00A000">+                if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+                        ret = ftmod_ss7_isup_ckt_config(x);</span>
<span style="color: #00A000">+                        if (ret) {</span>
<span style="color: #00A000">+                                SS7_CRITICAL(&quot;ISUP CKT %d configuration FAILED (%d)!\n&quot;, x, ret);</span>
<span style="color: #00A000">+                                return 1;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_INFO(&quot;ISUP CKT %d configuration DONE!\n&quot;, x);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                } /* if ( g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* set the SNGSS7_CONFIGURED flag */</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #00A000">+#endif</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t block_all_ckts_for_relay(uint32_t procId)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int x;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        SS7_INFO(&quot;BLOcking all ckts on ProcID = %d\n&quot;, procId);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* we just lost connection to this procId, send out a block for all these circuits */</span>
<span style="color: #00A000">+        x = (procId * 1000) + 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) {</span>
<span style="color: #00A000">+                        /* send out a BLO */</span>
<span style="color: #00A000">+                        sng_cc_sta_request (1,</span>
<span style="color: #00A000">+                                                                0,</span>
<span style="color: #00A000">+                                                                0,</span>
<span style="color: #00A000">+                                                                g_ftdm_sngss7_data.cfg.isupCkt[x].id,</span>
<span style="color: #00A000">+                                                                0, </span>
<span style="color: #00A000">+                                                                SIT_STA_CIRBLOREQ, </span>
<span style="color: #00A000">+                                                                NULL);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].type == VOICE) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move along */</span>
<span style="color: #00A000">+                x++;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t disable_all_sigs_for_relay(uint32_t procId)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SS7_INFO(&quot;Disalbing all sig links on ProcID = %d\n&quot;, procId);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        ftmod_ss7_disable_grp_mtp3Link(procId);</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t disble_all_mtp2_sigs_for_relay(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        /* check if there is a local mtp2 link*/</span>
<span style="color: #00A000">+        if (sngss7_test_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP2)) {</span>
<span style="color: #00A000">+                SS7_INFO(&quot;Disalbing all mtp2 sig links on local system\n&quot;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                ftmod_ss7_disable_grp_mtp2Link(1);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+/* For Emacs:</span>
<span style="color: #00A000">+ * Local Variables:</span>
<span style="color: #00A000">+ * mode:c</span>
<span style="color: #00A000">+ * indent-tabs-mode:t</span>
<span style="color: #00A000">+ * tab-width:4</span>
<span style="color: #00A000">+ * c-basic-offset:4</span>
<span style="color: #00A000">+ * End:</span>
<span style="color: #00A000">+ * For VIM:</span>
<span style="color: #00A000">+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:</span>
<span style="color: #00A000">+ */</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c</span>
<span style="color: #000080; font-weight: bold">index 1235238..2f507a2 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c</span>
<span style="color: #800080; font-weight: bold">@@ -42,12 +42,43 @@</span>
 /******************************************************************************/
 
 /* PROTOTYPES *****************************************************************/
<span style="color: #A00000">-int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm);</span>
<span style="color: #00A000">+int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm);</span>
<span style="color: #00A000">+int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm);</span>
<span style="color: #00A000">+int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm);</span>
 int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm);
<span style="color: #00A000">+int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status);</span>
<span style="color: #00A000">+int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm);</span>
 /******************************************************************************/
 
 /* FUNCTIONS ******************************************************************/
<span style="color: #A00000">-int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm)</span>
<span style="color: #00A000">+int ftmod_ss7_mtp1link_sta(uint32_t id, L1Mngmt *cfm)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return 1;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_mtp2link_sta(uint32_t id, SdMngmt *cfm)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SdMngmt        sta;</span>
<span style="color: #00A000">+        Pst                pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        memset(&amp;sta, 0x0, sizeof(sta));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSD;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        sta.hdr.elmId.elmnt                 = STDLSAP;</span>
<span style="color: #00A000">+        sta.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp2Link[id].id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return(sng_sta_mtp2(&amp;pst, &amp;sta, cfm));</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_mtp3link_sta(uint32_t id, SnMngmt *cfm)</span>
 {
         SnMngmt        sta;
         Pst                pst;
<span style="color: #800080; font-weight: bold">@@ -60,8 +91,13 @@ int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm)</span>
         /* insert the destination Entity */
         pst.dstEnt = ENTSN;
 
<span style="color: #00A000">+        /* check the for the correct ProcId and make sure it goes to the right system */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.procId != 1) {</span>
<span style="color: #00A000">+                pst.dstProcId = 1;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         sta.hdr.elmId.elmnt                 = STDLSAP;
<span style="color: #A00000">-        sta.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtpLink[id].id;</span>
<span style="color: #00A000">+        sta.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtp3Link[id].id;</span>
 
         return(sng_sta_mtp3(&amp;pst, &amp;sta, cfm));
 }
<span style="color: #800080; font-weight: bold">@@ -80,13 +116,77 @@ int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm)</span>
         /* insert the destination Entity */
         pst.dstEnt = ENTSN;
 
<span style="color: #00A000">+        /* check the for the correct ProcId and make sure it goes to the right system */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.procId != 1) {</span>
<span style="color: #00A000">+                pst.dstProcId = 1;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         sta.hdr.elmId.elmnt                 = STLNKSET;
         sta.hdr.elmId.elmntInst1        = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
         sta.hdr.elmId.elmntInst2        = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].links[0];
 
         return(sng_sta_mtp3(&amp;pst, &amp;sta, cfm));
 }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int ftmod_ss7_isup_intf_sta(uint32_t id, uint8_t *status)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        SiMngmt        sta;</span>
<span style="color: #00A000">+        SiMngmt cfm;</span>
<span style="color: #00A000">+        Pst                pst;</span>
<span style="color: #00A000">+        int                ret;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        memset(&amp;sta, 0x0, sizeof(sta));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTSI;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check the for the correct ProcId and make sure it goes to the right system */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.procId != 1) {</span>
<span style="color: #00A000">+                pst.dstProcId = 1;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* request the status of an inftId */</span>
<span style="color: #00A000">+        sta.hdr.entId.ent                        = ENTSI;</span>
<span style="color: #00A000">+        sta.hdr.entId.inst                        = S_INST;</span>
<span style="color: #00A000">+        sta.hdr.msgType                                = TSSTA;</span>
<span style="color: #00A000">+        sta.hdr.elmId.elmnt                 = SI_STINTF;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        sta.t.ssta.elmntId.intfId = id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        ret = sng_sta_isup(&amp;pst, &amp;sta, &amp;cfm);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        *status = cfm.t.ssta.cfm.s.intf.state;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return(ret);</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
 /******************************************************************************/
<span style="color: #00A000">+int ftmod_ss7_relay_status(uint32_t id, RyMngmt *cfm)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        RyMngmt        sta;</span>
<span style="color: #00A000">+        Pst                pst;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        memset(&amp;sta, 0x0, sizeof(sta));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the post structure */</span>
<span style="color: #00A000">+        smPstInit(&amp;pst);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* insert the destination Entity */</span>
<span style="color: #00A000">+        pst.dstEnt = ENTRY;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        sta.hdr.entId.ent                        = ENTRY;</span>
<span style="color: #00A000">+        sta.hdr.entId.inst                        = S_INST;</span>
<span style="color: #00A000">+        sta.hdr.msgType                                = TSSTA;</span>
<span style="color: #00A000">+        sta.hdr.elmId.elmnt                 = STCHSTA;</span>
<span style="color: #00A000">+        sta.hdr.elmId.elmntInst1        = id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return(sng_sta_relay(&amp;pst, &amp;sta, cfm));</span>
<span style="color: #00A000">+}</span>
 
 /******************************************************************************/
 /* For Emacs:
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c</span>
<span style="color: #000080; font-weight: bold">index 23617c9..683caf2 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c</span>
<span style="color: #800080; font-weight: bold">@@ -75,6 +75,14 @@ ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info);</span>
 
 ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type);
 ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type);
<span style="color: #00A000">+</span>
<span style="color: #00A000">+int find_mtp2_error_type_in_map(const char *err_type);</span>
<span style="color: #00A000">+int find_link_type_in_map(const char *linkType);</span>
<span style="color: #00A000">+int find_switch_type_in_map(const char *switchType);</span>
<span style="color: #00A000">+int find_ssf_type_in_map(const char *ssfType);</span>
<span style="color: #00A000">+int find_cic_cntrl_in_map(const char *cntrlType);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+ftdm_status_t check_status_of_all_isup_intf(void);</span>
 /******************************************************************************/
 
 /* FUNCTIONS ******************************************************************/
<span style="color: #800080; font-weight: bold">@@ -432,7 +440,7 @@ int check_cics_in_range(sngss7_chan_data_t *sngss7_info)</span>
                         }
 
                         /* check if the channel still has the reset flag done is up */
<span style="color: #A00000">-                        if (!sngss7_test_flag(tmp_sngss7_info, FLAG_GRP_RESET_RX_DN)) {</span>
<span style="color: #00A000">+                        if (!sngss7_test_ckt_flag(tmp_sngss7_info, FLAG_GRP_RESET_RX_DN)) {</span>
                                 SS7_DEBUG_CHAN(tmp_ftdmchan, &quot;[CIC:%d] Still processing reset...\n&quot;, tmp_sngss7_info-&gt;circuit-&gt;cic);
                                 return 0;
                         }
<span style="color: #800080; font-weight: bold">@@ -475,19 +483,19 @@ ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_in</span>
 int check_for_reset(sngss7_chan_data_t *sngss7_info)
 {
 
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info,FLAG_RESET_RX)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info,FLAG_RESET_RX)) {</span>
                 return 1;
         }
         
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info,FLAG_RESET_TX)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info,FLAG_RESET_TX)) {</span>
                 return 1;
         }
         
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info,FLAG_GRP_RESET_RX)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info,FLAG_GRP_RESET_RX)) {</span>
                 return 1;
         }
         
<span style="color: #A00000">-        if (sngss7_test_flag(sngss7_info,FLAG_GRP_RESET_TX)) {</span>
<span style="color: #00A000">+        if (sngss7_test_ckt_flag(sngss7_info,FLAG_GRP_RESET_TX)) {</span>
                 return 1;
         }
 
<span style="color: #800080; font-weight: bold">@@ -498,11 +506,13 @@ int check_for_reset(sngss7_chan_data_t *sngss7_info)</span>
 /******************************************************************************/
 unsigned long get_unique_id(void)
 {
<span style="color: #00A000">+        int        procId = sng_get_procId(); </span>
 
<span style="color: #A00000">-        if (sngss7_id &lt; 420000000) {</span>
<span style="color: #00A000">+        /* id values are between (procId * 1,000,000) and ((procId + 1) * 1,000,000) */ </span>
<span style="color: #00A000">+        if (sngss7_id &lt; ((procId + 1) * 1000000) ) {</span>
                 sngss7_id++;
         } else {
<span style="color: #A00000">-                sngss7_id = 1;</span>
<span style="color: #00A000">+                sngss7_id = procId * 1000000;</span>
         }
 
         return(sngss7_id);
<span style="color: #800080; font-weight: bold">@@ -525,7 +535,7 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)</span>
                 }
 
                 /* check if the GRP_RESET_RX flag is already up */
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX)) {</span>
                         /* we have already processed this channel...move along */
                         continue;
                 }
<span style="color: #800080; font-weight: bold">@@ -543,7 +553,7 @@ ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan)</span>
                                 (g_ftdm_sngss7_data.cfg.isupCkt[sngss7_span-&gt;rx_grs.circuit].cic + sngss7_span-&gt;rx_grs.range));
 
                 /* flag the channel as having received a reset */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_RX);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX);</span>
 
                 switch (ftdmchan-&gt;state) {
                 /**************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -598,10 +608,10 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)</span>
                 /* check if there is a state change pending on the channel */
                 if (!ftdm_test_flag(ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
                         /* check the state to the GRP_RESET_RX_DN flag */
<span style="color: #A00000">-                        if (!sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) {</span>
<span style="color: #00A000">+                        if (!sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) {</span>
                                 /* this channel is still resetting...do nothing */
                                         goto GRS_UNLOCK_ALL;
<span style="color: #A00000">-                        } /* if (!sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) */</span>
<span style="color: #00A000">+                        } /* if (!sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN)) */</span>
                 } else {
                         /* state change pending */
                         goto GRS_UNLOCK_ALL;
<span style="color: #800080; font-weight: bold">@@ -625,16 +635,16 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)</span>
                 }
 
                 /* throw the GRP reset flag complete flag */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);</span>
 
                 /* move the channel to the down state */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
 
                 /* update the status map if the ckt is in blocked state */
<span style="color: #A00000">-                if ((sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||</span>
<span style="color: #A00000">-                        (sngss7_test_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||</span>
<span style="color: #A00000">-                        (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) ||</span>
<span style="color: #A00000">-                        (sngss7_test_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
<span style="color: #00A000">+                if ((sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX)) ||</span>
<span style="color: #00A000">+                        (sngss7_test_ckt_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX)) ||</span>
<span style="color: #00A000">+                        (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX)) ||</span>
<span style="color: #00A000">+                        (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_MN_BLOCK_RX))) {</span>
                 
                         sngss7_span-&gt;rx_grs.status[byte] = (sngss7_span-&gt;rx_grs.status[byte] | (1 &lt;&lt; bit));
                 } /* if blocked */
<span style="color: #800080; font-weight: bold">@@ -679,7 +689,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)</span>
                 }
 
                 /* check if the channel is already procoessing the GRA */
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) {</span>
                         /* move along */
                         continue;
                 }
<span style="color: #800080; font-weight: bold">@@ -701,7 +711,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)</span>
                 case FTDM_CHANNEL_STATE_RESTART:
                         
                         /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);</span>
 
                         /* go to DOWN */
                         ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_DOWN);
<span style="color: #800080; font-weight: bold">@@ -720,7 +730,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)</span>
                 case FTDM_CHANNEL_STATE_HANGUP_COMPLETE:
                         
                         /* throw the FLAG_RESET_TX_RSP to indicate we have acknowledgement from the remote side */
<span style="color: #A00000">-                        sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);</span>
<span style="color: #00A000">+                        sngss7_set_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);</span>
 
                         break;
                 /**********************************************************************/
<span style="color: #800080; font-weight: bold">@@ -775,7 +785,7 @@ ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)</span>
                 sigev.channel = ftdmchan;
 
                 /* if we have the PAUSED flag and the sig status is still UP */
<span style="color: #A00000">-                if ((sngss7_test_flag(sngss7_info, FLAG_INFID_PAUSED)) &amp;&amp;</span>
<span style="color: #00A000">+                if ((sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) &amp;&amp;</span>
                         (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP))) {
 
                         /* clear up any pending state changes */
<span style="color: #800080; font-weight: bold">@@ -790,7 +800,7 @@ ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)</span>
 
                 /* if the RESUME flag is up go to SUSPENDED to process the flag */
                 /* after doing this the flag will be cleared */
<span style="color: #A00000">-                if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) {</span>
<span style="color: #00A000">+                if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_RESUME)) {</span>
 
                         /* clear up any pending state changes */
                         while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
<span style="color: #800080; font-weight: bold">@@ -839,7 +849,7 @@ ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan)</span>
                 }
 
                 /* throw the ckt block flag */
<span style="color: #A00000">-                sngss7_set_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
<span style="color: #00A000">+                sngss7_set_ckt_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);</span>
 
                 /* set the channel to suspended state */
                 ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
<span style="color: #800080; font-weight: bold">@@ -858,9 +868,9 @@ ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan)</span>
 ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info)
 {
         /* clear all the flags related to an incoming GRS */
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_RX);</span>
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);</span>
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_DN);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_RX_CMPLT);</span>
 
         return FTDM_SUCCESS;
 }
<span style="color: #800080; font-weight: bold">@@ -892,10 +902,10 @@ ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info)</span>
 ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info)
 {
         /* clear all the flags related to an outgoing GRS */
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_BASE);</span>
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_SENT);</span>
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_BASE);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_SENT);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP);</span>
 
         return FTDM_SUCCESS;
 }
<span style="color: #800080; font-weight: bold">@@ -918,7 +928,7 @@ ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info)</span>
 ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info)
 {
         /* clear all the flags related to an incoming RSC */
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_RESET_RX);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_RX);</span>
 
         return FTDM_SUCCESS;
 }
<span style="color: #800080; font-weight: bold">@@ -927,9 +937,9 @@ ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info)</span>
 ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info)
 {
         /* clear all the flags related to an outgoing RSC */
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_RESET_TX);</span>
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_RESET_SENT);</span>
<span style="color: #A00000">-        sngss7_clear_flag(sngss7_info, FLAG_RESET_TX_RSP);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_TX);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_SENT);</span>
<span style="color: #00A000">+        sngss7_clear_ckt_flag(sngss7_info, FLAG_RESET_TX_RSP);</span>
 
         return FTDM_SUCCESS;
 }
<span style="color: #800080; font-weight: bold">@@ -1148,6 +1158,197 @@ ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int typ</span>
 }
 
 /******************************************************************************/
<span style="color: #00A000">+int find_mtp2_error_type_in_map(const char *err_type)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (sng_mtp2_error_type_map[i].init == 1) {</span>
<span style="color: #00A000">+                /* check if string matches the sng_type name */ </span>
<span style="color: #00A000">+                if (!strcasecmp(err_type, sng_mtp2_error_type_map[i].sng_type)) {</span>
<span style="color: #00A000">+                        /* we&#39;ve found a match break from the loop */</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        /* move on to the next on */</span>
<span style="color: #00A000">+                        i++;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        } /* while (sng_mtp2_error_type_map[i].init == 1) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check how we exited the loop */</span>
<span style="color: #00A000">+        if (sng_mtp2_error_type_map[i].init == 0) {</span>
<span style="color: #00A000">+                return -1;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                return i;</span>
<span style="color: #00A000">+        } /* if (sng_mtp2_error_type_map[i].init == 0) */</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int find_link_type_in_map(const char *linkType)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (sng_link_type_map[i].init == 1) {</span>
<span style="color: #00A000">+                /* check if string matches the sng_type name */ </span>
<span style="color: #00A000">+                if (!strcasecmp(linkType, sng_link_type_map[i].sng_type)) {</span>
<span style="color: #00A000">+                        /* we&#39;ve found a match break from the loop */</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        /* move on to the next on */</span>
<span style="color: #00A000">+                        i++;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        } /* while (sng_link_type_map[i].init == 1) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check how we exited the loop */</span>
<span style="color: #00A000">+        if (sng_link_type_map[i].init == 0) {</span>
<span style="color: #00A000">+                return -1;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                return i;</span>
<span style="color: #00A000">+        } /* if (sng_link_type_map[i].init == 0) */</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int find_switch_type_in_map(const char *switchType)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (sng_switch_type_map[i].init == 1) {</span>
<span style="color: #00A000">+                /* check if string matches the sng_type name */ </span>
<span style="color: #00A000">+                if (!strcasecmp(switchType, sng_switch_type_map[i].sng_type)) {</span>
<span style="color: #00A000">+                        /* we&#39;ve found a match break from the loop */</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        /* move on to the next on */</span>
<span style="color: #00A000">+                        i++;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        } /* while (sng_switch_type_map[i].init == 1) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check how we exited the loop */</span>
<span style="color: #00A000">+        if (sng_switch_type_map[i].init == 0) {</span>
<span style="color: #00A000">+                return -1;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                return i;</span>
<span style="color: #00A000">+        } /* if (sng_switch_type_map[i].init == 0) */</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int find_ssf_type_in_map(const char *ssfType)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (sng_ssf_type_map[i].init == 1) {</span>
<span style="color: #00A000">+                /* check if string matches the sng_type name */ </span>
<span style="color: #00A000">+                if (!strcasecmp(ssfType, sng_ssf_type_map[i].sng_type)) {</span>
<span style="color: #00A000">+                        /* we&#39;ve found a match break from the loop */</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        /* move on to the next on */</span>
<span style="color: #00A000">+                        i++;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        } /* while (sng_ssf_type_map[i].init == 1) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check how we exited the loop */</span>
<span style="color: #00A000">+        if (sng_ssf_type_map[i].init == 0) {</span>
<span style="color: #00A000">+                return -1;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                return i;</span>
<span style="color: #00A000">+        } /* if (sng_ssf_type_map[i].init == 0) */</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+int find_cic_cntrl_in_map(const char *cntrlType)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (sng_cic_cntrl_type_map[i].init == 1) {</span>
<span style="color: #00A000">+                /* check if string matches the sng_type name */ </span>
<span style="color: #00A000">+                if (!strcasecmp(cntrlType, sng_cic_cntrl_type_map[i].sng_type)) {</span>
<span style="color: #00A000">+                        /* we&#39;ve found a match break from the loop */</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        /* move on to the next on */</span>
<span style="color: #00A000">+                        i++;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        } /* while (sng_cic_cntrl_type_map[i].init == 1) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check how we exited the loop */</span>
<span style="color: #00A000">+        if (sng_cic_cntrl_type_map[i].init == 0) {</span>
<span style="color: #00A000">+                return -1;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                return i;</span>
<span style="color: #00A000">+        } /* if (sng_cic_cntrl_type_map[i].init == 0) */</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+ftdm_status_t check_status_of_all_isup_intf(void)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sng_isup_inf_t                *sngss7_intf = NULL;</span>
<span style="color: #00A000">+        uint8_t                                status = 0xff;</span>
<span style="color: #00A000">+        int                                        x;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* go through all the isupIntfs and ask the stack to give their current state */</span>
<span style="color: #00A000">+        x = 1;</span>
<span style="color: #00A000">+        for (x = 1; x &lt; (MAX_ISUP_INFS + 1); x++) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.isupIntf[x].id == 0) continue;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                sngss7_intf = &amp;g_ftdm_sngss7_data.cfg.isupIntf[x];</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (ftmod_ss7_isup_intf_sta(sngss7_intf-&gt;id, &amp;status)) {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Failed to get status of ISUP intf %d\n&quot;, sngss7_intf-&gt;id);</span>
<span style="color: #00A000">+                        continue;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                switch (status){</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                case (SI_INTF_AVAIL):</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;State of ISUP intf %d = AVAIL\n&quot;, sngss7_intf-&gt;id); </span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* check the current state for interface that we know */</span>
<span style="color: #00A000">+                        if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {</span>
<span style="color: #00A000">+                                /* we thing the intf is paused...put into resume */ </span>
<span style="color: #00A000">+                                sngss7_clear_flag(sngss7_intf, SNGSS7_PAUSED);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                /* nothing to since we already know that interface is active */</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                case (SI_INTF_UNAVAIL):</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;State of ISUP intf %d = UNAVAIL\n&quot;, sngss7_intf-&gt;id); </span>
<span style="color: #00A000">+                        /* check the current state for interface that we know */</span>
<span style="color: #00A000">+                        if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {</span>
<span style="color: #00A000">+                                /* nothing to since we already know that interface is active */ </span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                /* put the interface into pause */</span>
<span style="color: #00A000">+                                sngss7_set_flag(sngss7_intf, SNGSS7_PAUSED);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                case (SI_INTF_CONG1):</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;State of ISUP intf %d = Congestion 1\n&quot;, sngss7_intf-&gt;id);</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                case (SI_INTF_CONG2):</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;State of ISUP intf %d = Congestion 2\n&quot;, sngss7_intf-&gt;id);</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                case (SI_INTF_CONG3):</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;State of ISUP intf %d = Congestion 3\n&quot;, sngss7_intf-&gt;id);</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                default:</span>
<span style="color: #00A000">+                        /* should do something here to handle the possiblity of an unknown case */</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Unknown ISUP intf Status code (%d) for Intf = %d\n&quot;, status, sngss7_intf-&gt;id);</span>
<span style="color: #00A000">+                        break;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } /* switch (status) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* for (x = 1; x &lt; MAX_ISUP_INFS + 1); i++) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
 /* For Emacs:
  * Local Variables:
  * mode:c
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c</span>
<span style="color: #000080; font-weight: bold">index 75b32d6..c2d493f 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c</span>
<span style="color: #800080; font-weight: bold">@@ -61,7 +61,7 @@ void handle_isup_t35(void *userdata)</span>
     SS7_ERROR(&quot;[Call-Control] Timer 35 expired on CIC = %d\n&quot;, sngss7_info-&gt;circuit-&gt;cic);
 
     /* set the flag to indicate this hangup is started from the local side */
<span style="color: #A00000">-    sngss7_set_flag(sngss7_info, FLAG_LOCAL_REL);</span>
<span style="color: #00A000">+    sngss7_set_ckt_flag(sngss7_info, FLAG_LOCAL_REL);</span>
 
     /* hang up on timer expiry */
     ftdmchan-&gt;caller_data.hangup_cause = 28;
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #000080; font-weight: bold">index d4fd1ca..277951c 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c</span>
<span style="color: #800080; font-weight: bold">@@ -39,6 +39,60 @@</span>
 /******************************************************************************/
 
 /* GLOBALS ********************************************************************/
<span style="color: #00A000">+sng_ssf_type_t sng_ssf_type_map[] =</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        { 1, &quot;nat&quot;   , SSF_NAT   },</span>
<span style="color: #00A000">+        { 1, &quot;int&quot;   , SSF_INTL  },</span>
<span style="color: #00A000">+        { 1, &quot;spare&quot; , SSF_SPARE },</span>
<span style="color: #00A000">+        { 1, &quot;res&quot;   , SSF_RES   },</span>
<span style="color: #00A000">+        { 0, &quot;&quot;, 0 },</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+sng_switch_type_t sng_switch_type_map[] =</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        { 1, &quot;itu88&quot;  , LSI_SW_ITU     , LSI_SW_ITU     },</span>
<span style="color: #00A000">+        { 1, &quot;itu92&quot;  , LSI_SW_ITU     , LSI_SW_ITU     },</span>
<span style="color: #00A000">+        { 1, &quot;itu97&quot;  , LSI_SW_ITU97   , LSI_SW_ITU97   },</span>
<span style="color: #00A000">+        { 1, &quot;itu00&quot;  , LSI_SW_ITU2000 , LSI_SW_ITU2000 },</span>
<span style="color: #00A000">+        { 1, &quot;ansi88&quot; , LSI_SW_ANS88   , LSI_SW_ANS88   },</span>
<span style="color: #00A000">+        { 1, &quot;ansi92&quot; , LSI_SW_ANS92   , LSI_SW_ANS92   },</span>
<span style="color: #00A000">+        { 1, &quot;ansi95&quot; , LSI_SW_ANS92   , LSI_SW_ANS92   },</span>
<span style="color: #00A000">+        { 1, &quot;etsiv2&quot; , LSI_SW_ETSI    , LSI_SW_ETSI    },</span>
<span style="color: #00A000">+        { 1, &quot;etsiv3&quot; , LSI_SW_ETSIV3  , LSI_SW_ETSIV3  },</span>
<span style="color: #00A000">+        { 1, &quot;india&quot;  , LSI_SW_INDIA   , LSI_SW_INDIA   },</span>
<span style="color: #00A000">+        { 1, &quot;uk&quot;     , LSI_SW_UK      , LSI_SW_UK      },</span>
<span style="color: #00A000">+        { 1, &quot;russia&quot; , LSI_SW_RUSSIA  , LSI_SW_RUSSIA  },</span>
<span style="color: #00A000">+        { 0, &quot;&quot;, 0, 0 },</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+sng_link_type_t sng_link_type_map[] =</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        { 1, &quot;itu88&quot;  , LSD_SW_ITU88 , LSN_SW_ITU   },</span>
<span style="color: #00A000">+        { 1, &quot;itu92&quot;  , LSD_SW_ITU92 , LSN_SW_ITU   },</span>
<span style="color: #00A000">+        { 1, &quot;etsi&quot;   , LSD_SW_ITU92 , LSN_SW_ITU   },</span>
<span style="color: #00A000">+        { 1, &quot;ansi88&quot; , LSD_SW_ANSI88, LSN_SW_ANS   },</span>
<span style="color: #00A000">+        { 1, &quot;ansi92&quot; , LSD_SW_ANSI92, LSN_SW_ANS   },</span>
<span style="color: #00A000">+        { 1, &quot;ansi96&quot; , LSD_SW_ANSI92, LSN_SW_ANS96 },</span>
<span style="color: #00A000">+        { 0, &quot;&quot;, 0, 0 },</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+sng_mtp2_error_type_t sng_mtp2_error_type_map[] =</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        { 1, &quot;basic&quot;, SD_ERR_NRM },</span>
<span style="color: #00A000">+        { 1, &quot;pcr&quot;  , SD_ERR_CYC },</span>
<span style="color: #00A000">+        { 0, &quot;&quot;, 0 },</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+sng_cic_cntrl_type_t sng_cic_cntrl_type_map[] =</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        { 1, &quot;bothway&quot;     , BOTHWAY     },</span>
<span style="color: #00A000">+        { 1, &quot;incoming&quot;    , INCOMING    },</span>
<span style="color: #00A000">+        { 1, &quot;outgoing&quot;    , OUTGOING    },</span>
<span style="color: #00A000">+        { 1, &quot;controlling&quot; , CONTROLLING },</span>
<span style="color: #00A000">+        { 1, &quot;controlled&quot;  , CONTROLLED  },</span>
<span style="color: #00A000">+        { 0, &quot;&quot;, 0 },</span>
<span style="color: #00A000">+};</span>
<span style="color: #00A000">+</span>
 typedef struct sng_timeslot
 {
         int         channel;
<span style="color: #800080; font-weight: bold">@@ -47,13 +101,28 @@ typedef struct sng_timeslot</span>
         int         hole;
 }sng_timeslot_t;
 
<span style="color: #A00000">-typedef struct sng_isupCkt</span>
<span style="color: #00A000">+typedef struct sng_span</span>
 {
<span style="color: #00A000">+        char                        name[MAX_NAME_LEN];</span>
         ftdm_span_t                *span;
<span style="color: #00A000">+        uint32_t                ccSpanId;</span>
<span style="color: #00A000">+} sng_span_t;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+typedef struct sng_ccSpan</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        char                        name[MAX_NAME_LEN];</span>
<span style="color: #00A000">+        uint32_t                options;</span>
<span style="color: #00A000">+        uint32_t                id;</span>
<span style="color: #00A000">+        uint32_t                procId;</span>
<span style="color: #00A000">+        uint32_t                isupInf;</span>
         uint32_t                cicbase;
<span style="color: #A00000">-        uint32_t                typeCntrl;</span>
         char                        ch_map[MAX_CIC_MAP_LENGTH];
<span style="color: #A00000">-        uint32_t                isupInf;</span>
<span style="color: #00A000">+        uint32_t                typeCntrl;</span>
<span style="color: #00A000">+        uint32_t                switchType;</span>
<span style="color: #00A000">+        uint32_t                ssf;</span>
<span style="color: #00A000">+        uint32_t                clg_nadi;</span>
<span style="color: #00A000">+        uint32_t                cld_nadi;</span>
<span style="color: #00A000">+        uint32_t                min_digits;</span>
         uint32_t                t3;
         uint32_t                t12;
         uint32_t                t13;
<span style="color: #800080; font-weight: bold">@@ -61,8 +130,9 @@ typedef struct sng_isupCkt</span>
         uint32_t                t15;
         uint32_t                t16;
         uint32_t                t17;
<span style="color: #00A000">+        uint32_t                t35;</span>
         uint32_t                tval;
<span style="color: #A00000">-} sng_isupCkt_t;</span>
<span style="color: #00A000">+} sng_ccSpan_t;</span>
 
 int cmbLinkSetId;
 /******************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -72,9 +142,22 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa</span>
 
 static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup);
 
<span style="color: #00A000">+static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_sng_relay(ftdm_conf_node_t *sng_relay);</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_relay_channel(ftdm_conf_node_t *relay_chan);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp1_links(ftdm_conf_node_t *mtp1_links);</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp1_link(ftdm_conf_node_t *mtp1_link);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp2_links(ftdm_conf_node_t *mtp2_links);</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp2_link(ftdm_conf_node_t *mtp2_link);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp3_links(ftdm_conf_node_t *mtp3_links);</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp3_link(ftdm_conf_node_t *mtp3_link);</span>
<span style="color: #00A000">+</span>
 static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets);
 static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset);
<span style="color: #A00000">-static int ftmod_ss7_parse_mtp_link(ftdm_conf_node_t *mtp_link, sng_mtp_link_t *mtpLink);</span>
 
 static int ftmod_ss7_parse_mtp_routes(ftdm_conf_node_t *mtp_routes);
 static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route);
<span style="color: #800080; font-weight: bold">@@ -82,19 +165,22 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route);</span>
 static int ftmod_ss7_parse_isup_interfaces(ftdm_conf_node_t *isup_interfaces);
 static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface);
 
<span style="color: #A00000">-static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink);</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_cc_spans(ftdm_conf_node_t *cc_spans);</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span);</span>
 
<span style="color: #00A000">+static int ftmod_ss7_fill_in_relay_channel(sng_relay_t *relay_channel);</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_mtp1_link(sng_mtp1_link_t *mtp1Link);</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_mtp2_link(sng_mtp2_link_t *mtp1Link);</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_mtp3_link(sng_mtp3_link_t *mtp1Link);</span>
 static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet);
<span style="color: #A00000">-</span>
 static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route);
 static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route);
<span style="color: #A00000">-</span>
 static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup);
 static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap);
<span style="color: #A00000">-</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan);</span>
 static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, int ssf);
<span style="color: #00A000">+static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan);</span>
 
<span style="color: #A00000">-static int ftmod_ss7_fill_in_circuits(sng_isupCkt_t *isupCkt);</span>
 static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot);
 
 /******************************************************************************/
<span style="color: #800080; font-weight: bold">@@ -103,18 +189,17 @@ static int ftmod_ss7_next_timeslot(char *ch_map, sng_timeslot_t *timeslot);</span>
 int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span)
 {
         int                                        i = 0;
<span style="color: #A00000">-        int                                        x = 0;</span>
         const char                        *var = NULL;
         const char                        *val = NULL;
         ftdm_conf_node_t        *ptr = NULL;
         sng_route_t                        self_route;
<span style="color: #A00000">-        sng_isupCkt_t                isupCkt;</span>
<span style="color: #00A000">+        sng_span_t                        sngSpan;</span>
 
         /* clean out the isup ckt */
<span style="color: #A00000">-        memset(&amp;isupCkt, 0x0, sizeof(sng_isupCkt_t));</span>
<span style="color: #00A000">+        memset(&amp;sngSpan, 0x0, sizeof(sngSpan));</span>
 
         /* clean out the self route */
<span style="color: #A00000">-        memset(&amp;self_route, 0x0, sizeof(sng_route_t));</span>
<span style="color: #00A000">+        memset(&amp;self_route, 0x0, sizeof(self_route));</span>
 
         var = ftdm_parameters[i].var;
         val = ftdm_parameters[i].val;
<span style="color: #800080; font-weight: bold">@@ -136,92 +221,23 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa</span>
 
         i++;
         while (ftdm_parameters[i].var != NULL) {
<span style="color: #00A000">+        /**************************************************************************/</span>
 
                 var = ftdm_parameters[i].var;
                 val = ftdm_parameters[i].val;
 
<span style="color: #A00000">-                if (!strcasecmp(var, &quot;ch_map&quot;)) {</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                        strncpy(isupCkt.ch_map, val, MAX_CIC_MAP_LENGTH-1);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound channel map \&quot;%s\&quot;\n&quot;, isupCkt.ch_map);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;typeCntrl&quot;)) {</span>
<span style="color: #A00000">-                        if (!strcasecmp(val, &quot;bothway&quot;)) {</span>
<span style="color: #A00000">-                                isupCkt.typeCntrl = BOTHWAY;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound control type \&quot;bothway\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(val, &quot;incoming&quot;)) {</span>
<span style="color: #A00000">-                                isupCkt.typeCntrl = INCOMING;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound control type \&quot;incoming\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(val, &quot;outgoing&quot;)) {</span>
<span style="color: #A00000">-                                isupCkt.typeCntrl = OUTGOING;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound control type \&quot;outgoing\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(val, &quot;controlled&quot;)) {</span>
<span style="color: #A00000">-                                isupCkt.typeCntrl = CONTROLLED;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound control type \&quot;controlled\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(val, &quot;controlling&quot;)) {</span>
<span style="color: #A00000">-                                isupCkt.typeCntrl = CONTROLLING;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound control type \&quot;controlling\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;Found invalid circuit control type \&quot;%s\&quot;!&quot;, val);</span>
<span style="color: #A00000">-                                goto ftmod_ss7_parse_xml_error;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;cicbase&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.cicbase = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound cicbase = %d\n&quot;, isupCkt.cicbase);</span>
<span style="color: #00A000">+                if (!strcasecmp(var, &quot;dialplan&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;dialplan&quot;)) {</span>
                         /* do i give a shit about this??? */
                 /**********************************************************************/
                 } else if (!strcasecmp(var, &quot;context&quot;)) {
<span style="color: #A00000">-                        /* do i give a shit about this??? */</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup_interface&quot;)) {</span>
<span style="color: #A00000">-                        /* go through all the existing interfaces and see if we find a match */</span>
<span style="color: #A00000">-                        x = 1;</span>
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {</span>
<span style="color: #A00000">-                                if (!strcasecmp(g_ftdm_sngss7_data.cfg.isupIntf[x].name, val)) {</span>
<span style="color: #A00000">-                                        /* we have a match so break out of this loop */</span>
<span style="color: #A00000">-                                        break;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                /* move on to the next one */</span>
<span style="color: #A00000">-                                x++;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        isupCkt.isupInf = x;</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup_interface = %s\n&quot;,g_ftdm_sngss7_data.cfg.isupIntf[x].name);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.t3&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.t3 = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t3 = \&quot;%d\&quot;\n&quot;, isupCkt.t3);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.t12&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.t12 = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t12 = \&quot;%d\&quot;\n&quot;, isupCkt.t12);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.t13&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.t13 = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t13 = \&quot;%d\&quot;\n&quot;, isupCkt.t13);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.t14&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.t14 = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t14 = \&quot;%d\&quot;\n&quot;, isupCkt.t14);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.t15&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.t15 = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t15 = \&quot;%d\&quot;\n&quot;, isupCkt.t15);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.t16&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.t16 = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t16 = \&quot;%d\&quot;\n&quot;, isupCkt.t16);</span>
<span style="color: #00A000">+                        /* do i give a shit about this??? */</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.t17&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.t17 = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t17 = \&quot;%d\&quot;\n&quot;, isupCkt.t17);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(var, &quot;ccSpanId&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(var, &quot;isup.tval&quot;)) {</span>
<span style="color: #A00000">-                        isupCkt.tval = atoi(val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tval = \&quot;%d\&quot;\n&quot;, isupCkt.tval);</span>
<span style="color: #00A000">+                        sngSpan.ccSpanId = atoi(val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an ccSpanId  = %d\n&quot;,sngSpan.ccSpanId);</span>
                 /**********************************************************************/
                 } else {
                         SS7_ERROR(&quot;Unknown parameter found =\&quot;%s\&quot;...ignoring it!\n&quot;, var);
<span style="color: #800080; font-weight: bold">@@ -231,24 +247,11 @@ int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *spa</span>
                 i++;
         } /* while (ftdm_parameters[i].var != NULL) */
 
<span style="color: #A00000">-        /* setup the self mtp3 route */</span>
<span style="color: #A00000">-        i = g_ftdm_sngss7_data.cfg.isupIntf[x].mtpRouteId;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        if(ftmod_ss7_fill_in_self_route(g_ftdm_sngss7_data.cfg.isupIntf[x].spc,</span>
<span style="color: #A00000">-                                                                        g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType,</span>
<span style="color: #A00000">-                                                                        g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType,</span>
<span style="color: #A00000">-                                                                        g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                SS7_ERROR(&quot;Failed to fill in self route structure!\n&quot;);</span>
<span style="color: #A00000">-                goto ftmod_ss7_parse_xml_error;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
         /* fill the pointer to span into isupCkt */
<span style="color: #A00000">-        isupCkt.span = span;</span>
<span style="color: #00A000">+        sngSpan.span = span;</span>
 
         /* setup the circuits structure */
<span style="color: #A00000">-        if(ftmod_ss7_fill_in_circuits(&amp;isupCkt)) {</span>
<span style="color: #00A000">+        if(ftmod_ss7_fill_in_circuits(&amp;sngSpan)) {</span>
                 SS7_ERROR(&quot;Failed to fill in circuits structure!\n&quot;);
                 goto ftmod_ss7_parse_xml_error;
         }
<span style="color: #800080; font-weight: bold">@@ -262,9 +265,15 @@ ftmod_ss7_parse_xml_error:</span>
 /******************************************************************************/
 static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup)
 {
<span style="color: #00A000">+        ftdm_conf_node_t        *gen_config = NULL;</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *relay_channels = NULL;</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *mtp1_links = NULL;</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *mtp2_links = NULL;</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *mtp3_links = NULL;</span>
         ftdm_conf_node_t        *mtp_linksets = NULL;
         ftdm_conf_node_t        *mtp_routes = NULL;
         ftdm_conf_node_t        *isup_interfaces = NULL;
<span style="color: #00A000">+        ftdm_conf_node_t        *cc_spans = NULL;</span>
         ftdm_conf_node_t        *tmp_node = NULL;
 
         /* confirm that we are looking at sng_isup */
<span style="color: #800080; font-weight: bold">@@ -275,51 +284,145 @@ static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup)</span>
                 SS7_DEBUG(&quot;Parsing \&quot;sng_isup\&quot;...\n&quot;);
         }
 
<span style="color: #A00000">-        /* extract the 3 main sections of the sng_isup block */</span>
<span style="color: #00A000">+        /* extract the main sections of the sng_isup block */</span>
         tmp_node = sng_isup-&gt;child;
<span style="color: #A00000">-        while (tmp_node != NULL) {</span>
 
<span style="color: #A00000">-                if (!strcasecmp(tmp_node-&gt;name, &quot;mtp_linksets&quot;)) {</span>
<span style="color: #00A000">+        while (tmp_node != NULL) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+                /* check the type of structure */</span>
<span style="color: #00A000">+                 if (!strcasecmp(tmp_node-&gt;name, &quot;sng_gen&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (gen_config == NULL) {</span>
<span style="color: #00A000">+                                gen_config = tmp_node;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;sng_gen\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;sng_gen\&quot; section\n!&quot;);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(tmp_node-&gt;name, &quot;sng_relay&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (relay_channels == NULL) {</span>
<span style="color: #00A000">+                                relay_channels = tmp_node;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;sng_relay\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;sng_relay\&quot; section\n!&quot;);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                }else if (!strcasecmp(tmp_node-&gt;name, &quot;mtp1_links&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (mtp1_links == NULL) {</span>
<span style="color: #00A000">+                                mtp1_links = tmp_node;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;mtp1_links\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;mtp1_links\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(tmp_node-&gt;name, &quot;mtp2_links&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (mtp2_links == NULL) {</span>
<span style="color: #00A000">+                                mtp2_links = tmp_node;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;mtp2_links\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;mtp2_links\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(tmp_node-&gt;name, &quot;mtp3_links&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (mtp3_links == NULL) {</span>
<span style="color: #00A000">+                                mtp3_links = tmp_node;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;mtp3_links\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;mtp3_links\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(tmp_node-&gt;name, &quot;mtp_linksets&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
                         if (mtp_linksets == NULL) {
                                 mtp_linksets = tmp_node;
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound a \&quot;mtp_linksets section!\n&quot;);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;mtp_linksets\&quot; section!\n&quot;);</span>
                         } else {
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound a second \&quot;mtp_linksets\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;mtp_linksets\&quot; section!\n&quot;);</span>
                                 return FTDM_FAIL;
                         }
<span style="color: #00A000">+                /**********************************************************************/</span>
                 } else if (!strcasecmp(tmp_node-&gt;name, &quot;mtp_routes&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         if (mtp_routes == NULL) {
                                 mtp_routes = tmp_node;
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound a \&quot;mtp_routes\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;mtp_routes\&quot; section!\n&quot;);</span>
                         } else {
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound a second \&quot;mtp_routes\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;mtp_routes\&quot; section!\n&quot;);</span>
                                 return FTDM_FAIL;
                         }
<span style="color: #00A000">+                /**********************************************************************/</span>
                 } else if (!strcasecmp(tmp_node-&gt;name, &quot;isup_interfaces&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         if (isup_interfaces == NULL) {
                                 isup_interfaces = tmp_node;
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound a \&quot;isup_interfaces\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;isup_interfaces\&quot; section!\n&quot;);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;isup_interfaces\&quot; section\n!&quot;);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(tmp_node-&gt;name, &quot;cc_spans&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (cc_spans == NULL) {</span>
<span style="color: #00A000">+                                cc_spans = tmp_node;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a \&quot;cc_spans\&quot; section!\n&quot;);</span>
                         } else {
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound a second \&quot;isup_interfaces\&quot; section\n!&quot;);</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found a second \&quot;cc_spans\&quot; section\n!&quot;);</span>
                                 return FTDM_FAIL;
                         }
<span style="color: #00A000">+                /**********************************************************************/</span>
                 } else {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         SS7_ERROR(&quot;\tFound an unknown section \&quot;%s\&quot;!\n&quot;, tmp_node-&gt;name);
                         return FTDM_FAIL;
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } </span>
 
                 /* go to the next sibling */
                 tmp_node = tmp_node-&gt;next;
<span style="color: #A00000">-</span>
         } /* while (tmp_node != NULL) */
 
         /* now try to parse the sections */
<span style="color: #00A000">+        if (ftmod_ss7_parse_sng_gen(gen_config)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Failed to parse \&quot;gen_config\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (ftmod_ss7_parse_sng_relay(relay_channels)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Failed to parse \&quot;relay_channels\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (ftmod_ss7_parse_mtp1_links(mtp1_links)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Failed to parse \&quot;mtp1_links\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (ftmod_ss7_parse_mtp2_links(mtp2_links)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Failed to parse \&quot;mtp2_links\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (ftmod_ss7_parse_mtp3_links(mtp3_links)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Failed to parse \&quot;mtp3_links\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         if (ftmod_ss7_parse_mtp_linksets(mtp_linksets)) {
                 SS7_ERROR(&quot;Failed to parse \&quot;mtp_linksets\&quot;!\n&quot;);
                 return FTDM_FAIL;
         }
 
<span style="color: #A00000">-        if (ftmod_ss7_parse_mtp_routes(mtp_routes)) {</span>
<span style="color: #00A000">+        if (ftmod_ss7_parse_mtp_routes(mtp_routes)) {        </span>
                 SS7_ERROR(&quot;Failed to parse \&quot;mtp_routes\&quot;!\n&quot;);
                 return FTDM_FAIL;
         }
<span style="color: #800080; font-weight: bold">@@ -329,35 +432,190 @@ static int ftmod_ss7_parse_sng_isup(ftdm_conf_node_t *sng_isup)</span>
                 return FTDM_FAIL;
         }
 
<span style="color: #00A000">+        if (ftmod_ss7_parse_cc_spans(cc_spans)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Failed to parse \&quot;cc_spans\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         return FTDM_SUCCESS;
 }
 
 /******************************************************************************/
<span style="color: #A00000">-static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets)</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_sng_gen(ftdm_conf_node_t *sng_gen)</span>
 {
<span style="color: #A00000">-        ftdm_conf_node_t        *mtp_linkset = NULL;</span>
<span style="color: #00A000">+        ftdm_conf_parameter_t        *parm = sng_gen-&gt;parameters;</span>
<span style="color: #00A000">+        int                                                num_parms = sng_gen-&gt;n_parameters;</span>
<span style="color: #00A000">+        int                                                i = 0;</span>
 
<span style="color: #A00000">-        /* confirm that we are looking at mtp_linksets */</span>
<span style="color: #A00000">-        if (strcasecmp(mtp_linksets-&gt;name, &quot;mtp_linksets&quot;)) {</span>
<span style="color: #A00000">-                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp_linksets\&quot;!\n&quot;,mtp_linksets-&gt;name);</span>
<span style="color: #00A000">+        /* extract all the information from the parameters */</span>
<span style="color: #00A000">+        for (i = 0; i &lt; num_parms; i++) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (!strcasecmp(parm-&gt;var, &quot;procId&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.procId = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found a procId = %d\n&quot;, g_ftdm_sngss7_data.cfg.procId);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;license&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy(g_ftdm_sngss7_data.cfg.license, parm-&gt;val);</span>
<span style="color: #00A000">+                        strcpy(g_ftdm_sngss7_data.cfg.signature, parm-&gt;val);</span>
<span style="color: #00A000">+                        strcat(g_ftdm_sngss7_data.cfg.signature, &quot;.sig&quot;);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found license file = %s\n&quot;, g_ftdm_sngss7_data.cfg.license);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found signature file = %s\n&quot;, g_ftdm_sngss7_data.cfg.signature);        </span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;spc&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.spc = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found SPC = %d\n&quot;, g_ftdm_sngss7_data.cfg.spc);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move to the next parmeter */</span>
<span style="color: #00A000">+                parm = parm + 1;</span>
<span style="color: #00A000">+        } /* for (i = 0; i &lt; num_parms; i++) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_sng_relay(ftdm_conf_node_t *sng_relay)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *relay_chan = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at sng_relay */</span>
<span style="color: #00A000">+        if (strcasecmp(sng_relay-&gt;name, &quot;sng_relay&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;sng_relay\&quot;!\n&quot;,sng_relay-&gt;name);</span>
                 return FTDM_FAIL;
         }  else {
<span style="color: #A00000">-                SS7_DEBUG(&quot;Parsing \&quot;mtp_linksets\&quot;...\n&quot;);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;sng_relay\&quot;...\n&quot;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        relay_chan = sng_relay-&gt;child;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (relay_chan != NULL) {</span>
<span style="color: #00A000">+                while (relay_chan != NULL) {</span>
<span style="color: #00A000">+                        /* try to the parse relay_channel */</span>
<span style="color: #00A000">+                        if (ftmod_ss7_parse_relay_channel(relay_chan)) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Failed to parse \&quot;relay_channels\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* move on to the next linkset */</span>
<span style="color: #00A000">+                        relay_chan = relay_chan-&gt;next;</span>
<span style="color: #00A000">+                } /* while (relay_chan != NULL) */</span>
<span style="color: #00A000">+        } /* if (relay_chan != NULL) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_relay_channel(ftdm_conf_node_t *relay_chan)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sng_relay_t                                tmp_chan;</span>
<span style="color: #00A000">+        ftdm_conf_parameter_t        *parm = relay_chan-&gt;parameters;</span>
<span style="color: #00A000">+        int                                                num_parms = relay_chan-&gt;n_parameters;</span>
<span style="color: #00A000">+        int                                                i = 0;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at relay_channel */</span>
<span style="color: #00A000">+        if (strcasecmp(relay_chan-&gt;name, &quot;relay_channel&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;relay_channel\&quot;!\n&quot;,relay_chan-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;relay_channel\&quot;...\n&quot;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the tmp_chan structure */</span>
<span style="color: #00A000">+        memset(&amp;tmp_chan, 0x0, sizeof(tmp_chan));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* extract all the information from the parameters */</span>
<span style="color: #00A000">+        for (i = 0; i &lt; num_parms; i++) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy((char *)tmp_chan.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an relay_channel named = %s\n&quot;, tmp_chan.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;type&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        if (!strcasecmp(parm-&gt;val, &quot;listen&quot;)) {</span>
<span style="color: #00A000">+                                tmp_chan.type = LRY_CT_TCP_LISTEN;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a type = LISTEN\n&quot;);</span>
<span style="color: #00A000">+                        } else if (!strcasecmp(parm-&gt;val, &quot;server&quot;)) {</span>
<span style="color: #00A000">+                                tmp_chan.type = LRY_CT_TCP_SERVER;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a type = SERVER\n&quot;);</span>
<span style="color: #00A000">+                        } else if (!strcasecmp(parm-&gt;val, &quot;client&quot;)) {</span>
<span style="color: #00A000">+                                tmp_chan.type = LRY_CT_TCP_CLIENT;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found a type = CLIENT\n&quot;);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid \&quot;type\&quot; = %s\n&quot;, parm-&gt;var);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;hostname&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy((char *)tmp_chan.hostname, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found a hostname = %s\n&quot;, tmp_chan.hostname);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;port&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        tmp_chan.port = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found a port = %d\n&quot;, tmp_chan.port);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;procId&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        tmp_chan.procId = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found a procId = %d\n&quot;, tmp_chan.procId);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move to the next parmeter */</span>
<span style="color: #00A000">+                parm = parm + 1;</span>
<span style="color: #00A000">+        } /* for (i = 0; i &lt; num_parms; i++) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* store the channel in the global structure */</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_relay_channel(&amp;tmp_chan);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp1_links(ftdm_conf_node_t *mtp1_links)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *mtp1_link = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at mtp1_links */</span>
<span style="color: #00A000">+        if (strcasecmp(mtp1_links-&gt;name, &quot;mtp1_links&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp1_links\&quot;!\n&quot;,mtp1_links-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }  else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp1_links\&quot;...\n&quot;);</span>
         }
 
         /* extract the mtp_links */
<span style="color: #A00000">-        mtp_linkset = mtp_linksets-&gt;child;</span>
<span style="color: #00A000">+        mtp1_link = mtp1_links-&gt;child;</span>
 
<span style="color: #A00000">-        /* run through all of the mtp_linksets found  */</span>
<span style="color: #A00000">-        while (mtp_linkset != NULL) {</span>
<span style="color: #A00000">-                /* try to the parse mtp_linkset */</span>
<span style="color: #A00000">-                if (ftmod_ss7_parse_mtp_linkset(mtp_linkset)) {</span>
<span style="color: #A00000">-                        SS7_ERROR(&quot;Failed to parse \&quot;mtp_linkset\&quot;!\n&quot;);</span>
<span style="color: #00A000">+        /* run through all of the links found  */</span>
<span style="color: #00A000">+        while (mtp1_link != NULL) {</span>
<span style="color: #00A000">+                /* try to the parse mtp_link */</span>
<span style="color: #00A000">+                if (ftmod_ss7_parse_mtp1_link(mtp1_link)) {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Failed to parse \&quot;mtp1_link\&quot;!\n&quot;);</span>
                         return FTDM_FAIL;
                 }
 
<span style="color: #A00000">-                /* move on to the next linkset */</span>
<span style="color: #A00000">-                mtp_linkset = mtp_linkset-&gt;next;</span>
<span style="color: #00A000">+                /* move on to the next link */</span>
<span style="color: #00A000">+                mtp1_link = mtp1_link-&gt;next;</span>
 
         } /* while (mtp_linkset != NULL) */
 
<span style="color: #800080; font-weight: bold">@@ -365,413 +623,611 @@ static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets)</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp1_link(ftdm_conf_node_t *mtp1_link)</span>
 {
<span style="color: #A00000">-        ftdm_conf_parameter_t        *parm = mtp_linkset-&gt;parameters;</span>
<span style="color: #A00000">-        int                                                num_parms = mtp_linkset-&gt;n_parameters;</span>
<span style="color: #A00000">-        ftdm_conf_node_t                *mtp_link = NULL;</span>
<span style="color: #A00000">-        sng_mtp_link_t                        mtpLink[MAX_MTP_LINKS+1];</span>
<span style="color: #A00000">-        sng_link_set_t                        mtpLinkSet;</span>
<span style="color: #A00000">-        int                                                count;</span>
<span style="color: #A00000">-        int                                                i;</span>
<span style="color: #00A000">+        sng_mtp1_link_t                         mtp1Link;</span>
<span style="color: #00A000">+        ftdm_conf_parameter_t        *parm = mtp1_link-&gt;parameters;</span>
<span style="color: #00A000">+        int                                                 num_parms = mtp1_link-&gt;n_parameters;</span>
<span style="color: #00A000">+        int                                                 i;</span>
 
<span style="color: #A00000">-        /* initialize the mtp_link structures */</span>
<span style="color: #A00000">-        for (i = 0; i &lt; (MAX_MTP_LINKS  + 1); i++) {</span>
<span style="color: #A00000">-                memset(&amp;mtpLink[i], 0x0, sizeof(mtpLink[i]));</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        memset(&amp;mtpLinkSet, 0x0, sizeof(mtpLinkSet));</span>
<span style="color: #00A000">+        /* initalize the mtp1Link structure */</span>
<span style="color: #00A000">+        memset(&amp;mtp1Link, 0x0, sizeof(mtp1Link));</span>
 
<span style="color: #A00000">-        /* confirm that we are looking at mtp_linkset */</span>
<span style="color: #A00000">-        if (strcasecmp(mtp_linkset-&gt;name, &quot;mtp_linkset&quot;)) {</span>
<span style="color: #A00000">-                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp_linkset\&quot;!\n&quot;,mtp_linkset-&gt;name);</span>
<span style="color: #00A000">+        /* confirm that we are looking at an mtp_link */</span>
<span style="color: #00A000">+        if (strcasecmp(mtp1_link-&gt;name, &quot;mtp1_link&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp1_link\&quot;!\n&quot;,mtp1_link-&gt;name);</span>
                 return FTDM_FAIL;
         } else {
<span style="color: #A00000">-                SS7_DEBUG(&quot;Parsing \&quot;mtp_linkset\&quot;...\n&quot;);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp1_link\&quot;...\n&quot;);</span>
         }
 
<span style="color: #A00000">-        /* extract all the information from the parameters */</span>
         for (i = 0; i &lt; num_parms; i++) {
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
                 if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {
<span style="color: #A00000">-                        strncpy((char *)mtpLinkSet.name, parm-&gt;val, MAX_NAME_LEN-1);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound an \&quot;mtp_linkset\&quot; named = %s\n&quot;, mtpLinkSet.name);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;apc&quot;)) {</span>
<span style="color: #A00000">-                        mtpLinkSet.apc = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtpLinkSet-&gt;apc = %d\n&quot;, mtpLinkSet.apc);</span>
<span style="color: #00A000">+                        strcpy((char *)mtp1Link.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp1_link named = %s\n&quot;, mtp1Link.name);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;minActive&quot;)) {</span>
<span style="color: #A00000">-                        mtpLinkSet.minActive = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtpLinkSet-&gt;minActive = %d\n&quot;, mtpLinkSet.minActive);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp1Link.id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp1_link id = %d\n&quot;, mtp1Link.id);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;span&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp1Link.span = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp1_link span = %d\n&quot;, mtp1Link.span);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;chan&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp1Link.chan = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp1_link chan = %d\n&quot;, mtp1Link.chan);</span>
                 /**********************************************************************/
                 } else {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         SS7_ERROR(&quot;\tFound an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);
                         return FTDM_FAIL;
<span style="color: #00A000">+                /**********************************************************************/</span>
                 }
 
                 /* move to the next parmeter */
                 parm = parm + 1;
 
<span style="color: #00A000">+        /**************************************************************************/</span>
         } /* for (i = 0; i &lt; num_parms; i++) */
 
<span style="color: #A00000">-        /* grab the first mtp-link (which sits below the mtp_links section) */</span>
<span style="color: #A00000">-        mtp_link = mtp_linkset-&gt;child-&gt;child;</span>
<span style="color: #00A000">+        /* store the link in global structure */</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_mtp1_link(&amp;mtp1Link);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp2_links(ftdm_conf_node_t *mtp2_links)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *mtp2_link = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at mtp2_links */</span>
<span style="color: #00A000">+        if (strcasecmp(mtp2_links-&gt;name, &quot;mtp2_links&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp2_links\&quot;!\n&quot;,mtp2_links-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }  else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp2_links\&quot;...\n&quot;);</span>
<span style="color: #00A000">+        }</span>
 
<span style="color: #A00000">-        /* initalize the link counter */</span>
<span style="color: #A00000">-        count = 0;</span>
<span style="color: #00A000">+        /* extract the mtp_links */</span>
<span style="color: #00A000">+        mtp2_link = mtp2_links-&gt;child;</span>
 
<span style="color: #A00000">-        /* run through all of the mtp_links found  */</span>
<span style="color: #A00000">-        while (mtp_link != NULL) {</span>
<span style="color: #00A000">+        /* run through all of the links found  */</span>
<span style="color: #00A000">+        while (mtp2_link != NULL) {</span>
                 /* try to the parse mtp_linkset */
<span style="color: #A00000">-                if (ftmod_ss7_parse_mtp_link(mtp_link, &amp;mtpLink[count] )) {</span>
<span style="color: #A00000">-                        SS7_ERROR(&quot;Failed to parse \&quot;mtp_link\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                if (ftmod_ss7_parse_mtp2_link(mtp2_link)) {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Failed to parse \&quot;mtp2_link\&quot;!\n&quot;);</span>
                         return FTDM_FAIL;
                 }
 
<span style="color: #A00000">-                /* incremenet the link counter */</span>
<span style="color: #A00000">-                count++;</span>
<span style="color: #A00000">-</span>
                 /* move on to the next link */
<span style="color: #A00000">-                mtp_link = mtp_link-&gt;next;</span>
<span style="color: #00A000">+                mtp2_link = mtp2_link-&gt;next;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        } /* while (mtp_linkset != NULL) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
 
<span style="color: #A00000">-        } /* while (mtp_link != NULL) */</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp2_link(ftdm_conf_node_t *mtp2_link)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sng_mtp2_link_t                         mtp2Link;</span>
<span style="color: #00A000">+        ftdm_conf_parameter_t        *parm = mtp2_link-&gt;parameters;</span>
<span style="color: #00A000">+        int                                                 num_parms = mtp2_link-&gt;n_parameters;</span>
<span style="color: #00A000">+        int                                                 i;</span>
<span style="color: #00A000">+        int                                                ret;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the mtp1Link structure */</span>
<span style="color: #00A000">+        memset(&amp;mtp2Link, 0x0, sizeof(mtp2Link));</span>
 
<span style="color: #A00000">-        /* confirm we have the right number of links */</span>
<span style="color: #A00000">-        if (count &lt; 1 || count &gt; 15 ) {</span>
<span style="color: #A00000">-                SS7_ERROR(&quot;Invalid number of mtp_links found (%d)\n&quot;, count);</span>
<span style="color: #00A000">+        /* confirm that we are looking at an mtp2_link */</span>
<span style="color: #00A000">+        if (strcasecmp(mtp2_link-&gt;name, &quot;mtp2_link&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp2_link\&quot;!\n&quot;,mtp2_link-&gt;name);</span>
                 return FTDM_FAIL;
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp2_link\&quot;...\n&quot;);</span>
         }
 
<span style="color: #A00000">-        /* now we need to see if this linkset exists already or not and grab an Id */</span>
<span style="color: #A00000">-        i = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.mtpLinkSet[i].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp((const char *)g_ftdm_sngss7_data.cfg.mtpLinkSet[i].name, (const char *)mtpLinkSet.name)) {</span>
<span style="color: #A00000">-                        /* we&#39;ve found the linkset...so it has already been configured */</span>
<span style="color: #A00000">-                        break;</span>
<span style="color: #00A000">+        for (i = 0; i &lt; num_parms; i++) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy((char *)mtp2Link.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2_link named = %s\n&quot;, mtp2Link.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2_link id = %d\n&quot;, mtp2Link.id);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;mtp1Id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.mtp1Id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2_link mtp1Id = %d\n&quot;, mtp2Link.mtp1Id);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;errorType&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_mtp2_error_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid mtp2_link errorType = %s\n&quot;, parm-&gt;var);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                mtp2Link.errorType = sng_mtp2_error_type_map[ret].tril_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an mtp2_link errorType = %s\n&quot;, sng_mtp2_error_type_map[ret].sng_type);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;lssuLength&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.lssuLength = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2_link lssuLength = %d\n&quot;, mtp2Link.lssuLength);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;linkType&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_link_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid mtp2_link linkType = %s\n&quot;, parm-&gt;var);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                mtp2Link.linkType = sng_link_type_map[ret].tril_mtp2_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an mtp2_link linkType = %s\n&quot;, sng_link_type_map[ret].sng_type);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t1&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t1 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t1 = \&quot;%d\&quot;\n&quot;,mtp2Link.t1);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t2&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t2 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t2 = \&quot;%d\&quot;\n&quot;,mtp2Link.t2);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t3&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t3 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t3 = \&quot;%d\&quot;\n&quot;,mtp2Link.t3);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t4n&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t4n = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t4n = \&quot;%d\&quot;\n&quot;,mtp2Link.t4n);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t4e&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t4e = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t4e = \&quot;%d\&quot;\n&quot;,mtp2Link.t4e);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t5&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t5 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t5 = \&quot;%d\&quot;\n&quot;,mtp2Link.t5);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t6&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t6 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t6 = \&quot;%d\&quot;\n&quot;,mtp2Link.t6);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t7&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp2Link.t7 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp2 t7 = \&quot;%d\&quot;\n&quot;,mtp2Link.t7);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
                 }
<span style="color: #A00000">-                i++;</span>
<span style="color: #A00000">-                /* add in error check to make sure we don&#39;t go out-of-bounds */</span>
<span style="color: #A00000">-        }</span>
 
<span style="color: #A00000">-        /* if the id value is 0 that means we didn&#39;t find the linkset */</span>
<span style="color: #A00000">-        if (g_ftdm_sngss7_data.cfg.mtpLinkSet[i].id  == 0) {</span>
<span style="color: #A00000">-                mtpLinkSet.id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found new mtpLinkSet, id is = %d\n&quot;, mtpLinkSet.id);</span>
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                mtpLinkSet.id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found existing mtpLinkSet, id is = %d\n&quot;, mtpLinkSet.id);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+                /* move to the next parmeter */</span>
<span style="color: #00A000">+                parm = parm + 1;</span>
 
<span style="color: #A00000">-        /* we now have all the information to fill in the Libsng_ss7 structures */</span>
<span style="color: #A00000">-        i = 0;</span>
<span style="color: #A00000">-        count = 0;</span>
<span style="color: #A00000">-        while (mtpLink[i].mtp1.span != 0 ){</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* for (i = 0; i &lt; num_parms; i++) */</span>
 
<span style="color: #A00000">-                /* have to grab a couple of values from the linkset */</span>
<span style="color: #A00000">-                mtpLink[i].mtp3.apc                        = mtpLinkSet.apc;</span>
<span style="color: #A00000">-                mtpLink[i].mtp3.linkSetId        = mtpLinkSet.id;</span>
<span style="color: #00A000">+        /* store the link in global structure */</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_mtp2_link(&amp;mtp2Link);</span>
 
<span style="color: #A00000">-                ftmod_ss7_fill_in_mtpLink(&amp;mtpLink[i]);</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
 
<span style="color: #A00000">-                /* increment the links counter */</span>
<span style="color: #A00000">-                count++;</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp3_links(ftdm_conf_node_t *mtp3_links)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *mtp3_link = NULL;</span>
 
<span style="color: #A00000">-                /* increment the index value */</span>
<span style="color: #A00000">-                i++;</span>
<span style="color: #00A000">+        /* confirm that we are looking at mtp3_links */</span>
<span style="color: #00A000">+        if (strcasecmp(mtp3_links-&gt;name, &quot;mtp3_links&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp3_links\&quot;!\n&quot;,mtp3_links-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }  else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp3_links\&quot;...\n&quot;);</span>
         }
 
<span style="color: #A00000">-        mtpLinkSet.linkType                = mtpLink[0].mtp3.linkType;</span>
<span style="color: #A00000">-        mtpLinkSet.switchType        = mtpLink[0].mtp3.switchType;</span>
<span style="color: #A00000">-        mtpLinkSet.ssf                        = mtpLink[0].mtp3.ssf;</span>
<span style="color: #00A000">+        /* extract the mtp_links */</span>
<span style="color: #00A000">+        mtp3_link = mtp3_links-&gt;child;</span>
 
<span style="color: #A00000">-        ftmod_ss7_fill_in_mtpLinkSet(&amp;mtpLinkSet);</span>
<span style="color: #00A000">+        /* run through all of the links found  */</span>
<span style="color: #00A000">+        while (mtp3_link != NULL) {</span>
<span style="color: #00A000">+                /* try to the parse mtp_linkset */</span>
<span style="color: #00A000">+                if (ftmod_ss7_parse_mtp3_link(mtp3_link)) {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Failed to parse \&quot;mtp3_link\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move on to the next link */</span>
<span style="color: #00A000">+                mtp3_link = mtp3_link-&gt;next;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        } /* while (mtp_linkset != NULL) */</span>
 
         return FTDM_SUCCESS;
 }
 
 /******************************************************************************/
<span style="color: #A00000">-static int ftmod_ss7_parse_mtp_link(ftdm_conf_node_t *mtp_link, sng_mtp_link_t *mtpLink)</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp3_link(ftdm_conf_node_t *mtp3_link)</span>
 {
<span style="color: #A00000">-        ftdm_conf_parameter_t        *parm = mtp_link-&gt;parameters;</span>
<span style="color: #A00000">-        int                                                 num_parms = mtp_link-&gt;n_parameters;</span>
<span style="color: #00A000">+        sng_mtp3_link_t                         mtp3Link;</span>
<span style="color: #00A000">+        ftdm_conf_parameter_t        *parm = mtp3_link-&gt;parameters;</span>
<span style="color: #00A000">+        int                                                 num_parms = mtp3_link-&gt;n_parameters;</span>
         int                                                 i;
<span style="color: #A00000">-        </span>
<span style="color: #00A000">+        int                                                ret;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the mtp3Link structure */</span>
<span style="color: #00A000">+        memset(&amp;mtp3Link, 0x0, sizeof(mtp3Link));</span>
<span style="color: #00A000">+</span>
         /* confirm that we are looking at an mtp_link */
<span style="color: #A00000">-        if (strcasecmp(mtp_link-&gt;name, &quot;mtp_link&quot;)) {</span>
<span style="color: #A00000">-                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp_link\&quot;!\n&quot;,mtp_link-&gt;name);</span>
<span style="color: #00A000">+        if (strcasecmp(mtp3_link-&gt;name, &quot;mtp3_link&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp3_link\&quot;!\n&quot;,mtp3_link-&gt;name);</span>
                 return FTDM_FAIL;
         } else {
<span style="color: #A00000">-                SS7_DEBUG(&quot;Parsing \&quot;mtp_link\&quot;...\n&quot;);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp3_link\&quot;...\n&quot;);</span>
         }
<span style="color: #A00000">-        </span>
<span style="color: #00A000">+</span>
         for (i = 0; i &lt; num_parms; i++) {
<span style="color: #A00000">-                /* try to match the parameter to what we expect */</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
                 if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {
<span style="color: #A00000">-                        strncpy((char *)mtpLink-&gt;name, parm-&gt;val, MAX_NAME_LEN-1);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound an \&quot;mtp_link\&quot; named = %s\n&quot;, mtpLink-&gt;name);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;span&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp1.span = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtpLink-&gt;span = %d\n&quot;, mtpLink-&gt;mtp1.span);</span>
<span style="color: #00A000">+                        strcpy((char *)mtp3Link.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3_link named = %s\n&quot;, mtp3Link.name);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;chan&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp1.chan = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtpLink-&gt;chan = %d\n&quot;, mtpLink-&gt;mtp1.chan);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;id&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;errorType&quot;)) {</span>
<span style="color: #A00000">-                        if (!strcasecmp(parm-&gt;val, &quot;basic&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.errorType = SD_ERR_NRM;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;pcr&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.errorType = SD_ERR_CYC;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid \&quot;errorType\&quot; = %s\n&quot;, parm-&gt;var);</span>
<span style="color: #A00000">-                                return FTDM_FAIL;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtpLink-&gt;errorType=%s\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                        mtp3Link.id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3_link id = %d\n&quot;, mtp3Link.id);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;lssuLength&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.lssuLength = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        if ((mtpLink-&gt;mtp2.lssuLength != 1) &amp;&amp; (mtpLink-&gt;mtp2.lssuLength != 2)) {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid \&quot;lssuLength\&quot; = %d\n&quot;, mtpLink-&gt;mtp2.lssuLength);</span>
<span style="color: #A00000">-                                return FTDM_FAIL;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;lssuLength=%d\n&quot;, mtpLink-&gt;mtp2.lssuLength);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2Id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.mtp2Id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3_link mtp2Id = %d\n&quot;, mtp3Link.mtp2Id);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2ProcId&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.mtp2ProcId = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3_link mtp2ProcId = %d\n&quot;, mtp3Link.mtp2ProcId);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;priority&quot;)) {
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.priority = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        if ((mtpLink-&gt;mtp3.priority == 0) || (mtpLink-&gt;mtp3.priority == 1) || </span>
<span style="color: #A00000">-                                (mtpLink-&gt;mtp3.priority == 2) || (mtpLink-&gt;mtp3.priority == 3)) {</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;priority = %d\n&quot;,mtpLink-&gt;mtp3.priority);</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid \&quot;priority\&quot;=%d\n&quot;,mtpLink-&gt;mtp3.priority);</span>
<span style="color: #A00000">-                                return FTDM_FAIL;</span>
<span style="color: #A00000">-                        } </span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.priority = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 Link priority = %d\n&quot;,mtp3Link.priority); </span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;linkType&quot;)) {
<span style="color: #A00000">-                        if (!strcasecmp(parm-&gt;val, &quot;itu92&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.linkType = LSD_SW_ITU92;</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.linkType = LSN_SW_ITU;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;linkType = \&quot;ITU92\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;itu88&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.linkType = LSD_SW_ITU88;</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.linkType = LSN_SW_ITU;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;linkType = \&quot;ITU88\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ansi96&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.linkType = LSD_SW_ANSI92;</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.linkType = LSN_SW_ANS96;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;linkType = \&quot;ANSI96\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ansi92&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.linkType = LSD_SW_ANSI92;</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.linkType = LSN_SW_ANS;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;linkType = \&quot;ANSI92\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ansi88&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.linkType = LSD_SW_ANSI88;</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.linkType = LSN_SW_ANS;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;linkType = \&quot;ANSI88\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;etsi&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp2.linkType = LSD_SW_ITU92;</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.linkType = LSN_SW_ITU;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;linkType = \&quot;ETSI\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid linktype of \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_link_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid mtp3_link linkType = %s\n&quot;, parm-&gt;var);</span>
                                 return FTDM_FAIL;
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                mtp3Link.linkType = sng_link_type_map[ret].tril_mtp3_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an mtp3_link linkType = %s\n&quot;, sng_link_type_map[ret].sng_type);</span>
                         }
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;switchType&quot;)) {
<span style="color: #A00000">-                        if (!strcasecmp(parm-&gt;val, &quot;itu97&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ITU97;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ITU97\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;itu88&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ITU;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ITU88\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;itu92&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ITU;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ITU92\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;itu00&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ITU2000;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ITU00\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ETSIV2&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ETSI;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ETSIV2\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ETSIV3&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ETSIV3;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ETSIV3\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;UK&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_UK;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;UK\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;RUSSIA&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_RUSSIA;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;RUSSIA\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;INDIA&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_INDIA;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;INDIA\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ansi88&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ANS88;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ANSI88\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ansi92&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ANS92;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ANSI92\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;ansi95&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.switchType = LSI_SW_ANS95;</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpLink-&gt;switchType = \&quot;ANSI95\&quot;\n&quot;);</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid linktype of \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_switch_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid mtp3_link switchType = %s\n&quot;, parm-&gt;var);</span>
                                 return FTDM_FAIL;
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                mtp3Link.switchType = sng_switch_type_map[ret].tril_mtp3_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an mtp3_link switchType = %s\n&quot;, sng_switch_type_map[ret].sng_type);</span>
                         }
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;ssf&quot;)) {
<span style="color: #A00000">-                        if (!strcasecmp(parm-&gt;val, &quot;nat&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.ssf = SSF_NAT;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;int&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.ssf = SSF_INTL;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;spare&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.ssf = SSF_SPARE;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;res&quot;)) {</span>
<span style="color: #A00000">-                                mtpLink-&gt;mtp3.ssf = SSF_RES;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid ssf of \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_ssf_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid mtp3_link ssf = %s\n&quot;, parm-&gt;var);</span>
                                 return FTDM_FAIL;
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                mtp3Link.ssf = sng_ssf_type_map[ret].tril_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an mtp3_link ssf = %s\n&quot;, sng_ssf_type_map[ret].sng_type);</span>
                         }
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;slc&quot;)) {
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.slc = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtpLink-&gt;slc = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.slc);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t1&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t1 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t1 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t1);</span>
<span style="color: #00A000">+                        mtp3Link.slc = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 Link slc = %d\n&quot;,mtp3Link.slc);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;linkset&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.linkSetId = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 Link linkset = %d\n&quot;,mtp3Link.linkSetId);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t1&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.t1 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t1 = %d\n&quot;,mtp3Link.t1);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t2&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.t2 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t2 = %d\n&quot;,mtp3Link.t2);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t3&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.t3 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t3 = %d\n&quot;,mtp3Link.t3);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t4&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.t4 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t4 = %d\n&quot;,mtp3Link.t4);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t5&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.t5 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t5 = %d\n&quot;,mtp3Link.t5);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t2&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t2 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t2 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t2);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t7&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t3&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t3 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t3 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t3);</span>
<span style="color: #00A000">+                        mtp3Link.t7 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t7 = %d\n&quot;,mtp3Link.t7);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t4n&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t4n = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t4n = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t4n);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t12&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t4e&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t4e = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t4e = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t4e);</span>
<span style="color: #00A000">+                        mtp3Link.t12 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t12 = %d\n&quot;,mtp3Link.t12);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t5&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t5 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t5 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t5);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t13&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t6&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t6 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t6 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t6);</span>
<span style="color: #00A000">+                        mtp3Link.t13 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t13 = %d\n&quot;,mtp3Link.t13);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp2.t7&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp2.t7 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp2 t7 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp2.t7);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t14&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t1&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t1 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t1 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t1);</span>
<span style="color: #00A000">+                        mtp3Link.t14 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t14 = %d\n&quot;,mtp3Link.t14);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t2&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t2 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t2 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t2);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t17&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t3&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t3 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t3 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t3);</span>
<span style="color: #00A000">+                        mtp3Link.t17 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t17 = %d\n&quot;,mtp3Link.t17);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t4&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t4 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t4 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t4);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t22&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t5&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t5 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t5 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t5);</span>
<span style="color: #00A000">+                        mtp3Link.t22 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t22 = %d\n&quot;,mtp3Link.t22);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t7&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t7 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t7 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t7);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t23&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t12&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t12 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t12 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t12);</span>
<span style="color: #00A000">+                        mtp3Link.t23 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t23 = %d\n&quot;,mtp3Link.t23);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t13&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t13 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t13 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t13);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t24&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t14&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t14 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t14 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t14);</span>
<span style="color: #00A000">+                        mtp3Link.t24 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t24 = %d\n&quot;,mtp3Link.t24);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t17&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t17 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t17 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t17);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t31&quot;)) {</span>
<span style="color: #00A000">+                        mtp3Link.t31 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t31 = %d\n&quot;,mtp3Link.t31);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t22&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t22 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t22 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t22);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t32&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t23&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t23 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t23 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t23);</span>
<span style="color: #00A000">+                        mtp3Link.t32 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t32 = %d\n&quot;,mtp3Link.t32);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t24&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t24 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t24 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t24);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t33&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t31&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t31 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t31 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t31);</span>
<span style="color: #00A000">+                        mtp3Link.t33 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t33 = %d\n&quot;,mtp3Link.t33);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t32&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t32 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t32 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t32);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t34&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t33&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t33 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t33 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t33);</span>
<span style="color: #00A000">+                        mtp3Link.t34 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t34 = %d\n&quot;,mtp3Link.t34);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t34&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t34 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t34 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t34);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t35&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t35&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t35 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t35 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t35);</span>
<span style="color: #00A000">+                        mtp3Link.t35 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t35 = %d\n&quot;,mtp3Link.t35);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t36&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t36 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t36 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t36);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t36&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t37&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.t37 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t37 = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.t37);</span>
<span style="color: #00A000">+                        mtp3Link.t36 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t36 = %d\n&quot;,mtp3Link.t36);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.tcraft&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.tcraft = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 tcraft = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.tcraft);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;t37&quot;)) {</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.tflc&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.tflc = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 tflc = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.tflc);</span>
<span style="color: #00A000">+                        mtp3Link.t37 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t37 = %d\n&quot;,mtp3Link.t37);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.tbnd&quot;)) {</span>
<span style="color: #A00000">-                        mtpLink-&gt;mtp3.tbnd = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 tbnd = \&quot;%d\&quot;\n&quot;,mtpLink-&gt;mtp3.tbnd);</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;tcraft&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.tcraft = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 tcraft = %d\n&quot;,mtp3Link.tcraft);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;tflc&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.tflc = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 tflc = %d\n&quot;,mtp3Link.tflc);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;tbnd&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtp3Link.tbnd = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 tbnd = %d\n&quot;,mtp3Link.tbnd);</span>
                 /**********************************************************************/
                 } else {
<span style="color: #A00000">-                        SS7_ERROR(&quot;\tFound an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter %s!\n&quot;, parm-&gt;val);</span>
                         return FTDM_FAIL;
<span style="color: #00A000">+                /**********************************************************************/</span>
                 }
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-                /* move to the next parameter */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move to the next parmeter */</span>
                 parm = parm + 1;
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* for (i = 0; i &lt; num_parms; i++) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* store the link in global structure */</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_mtp3_link(&amp;mtp3Link);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* move the linktype, switchtype and ssf to the linkset */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType == 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType = mtp3Link.linkType;</span>
<span style="color: #00A000">+        } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType != mtp3Link.linkType) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Trying to add an MTP3 Link to a Linkset with a different linkType: mtp3.id=%d, mtp3.name=%s, mtp3.linktype=%d, linkset.id=%d, linkset.linktype=%d\n&quot;,</span>
<span style="color: #00A000">+                                        mtp3Link.id, mtp3Link.name, mtp3Link.linkType,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].linkType);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                /* should print that all is ok...*/</span>
         }
<span style="color: #A00000">-        </span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType == 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType = mtp3Link.switchType;</span>
<span style="color: #00A000">+        } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType != mtp3Link.switchType) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Trying to add an MTP3 Link to a Linkset with a different switchType: mtp3.id=%d, mtp3.name=%s, mtp3.switchtype=%d, linkset.id=%d, linkset.switchtype=%d\n&quot;,</span>
<span style="color: #00A000">+                                        mtp3Link.id, mtp3Link.name, mtp3Link.switchType,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].switchType);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                /* should print that all is ok...*/</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf == 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf = mtp3Link.ssf;</span>
<span style="color: #00A000">+        } else if (g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf != mtp3Link.ssf) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Trying to add an MTP3 Link to a Linkset with a different ssf: mtp3.id=%d, mtp3.name=%s, mtp3.ssf=%d, linkset.id=%d, linkset.ssf=%d\n&quot;,</span>
<span style="color: #00A000">+                                        mtp3Link.id, mtp3Link.name, mtp3Link.ssf,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].id, g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3Link.linkSetId].ssf);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                /* should print that all is ok...*/</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp_linksets(ftdm_conf_node_t *mtp_linksets)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *mtp_linkset = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at mtp_linksets */</span>
<span style="color: #00A000">+        if (strcasecmp(mtp_linksets-&gt;name, &quot;mtp_linksets&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp_linksets\&quot;!\n&quot;,mtp_linksets-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        }  else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp_linksets\&quot;...\n&quot;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* extract the mtp_links */</span>
<span style="color: #00A000">+        mtp_linkset = mtp_linksets-&gt;child;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* run through all of the mtp_linksets found  */</span>
<span style="color: #00A000">+        while (mtp_linkset != NULL) {</span>
<span style="color: #00A000">+                /* try to the parse mtp_linkset */</span>
<span style="color: #00A000">+                if (ftmod_ss7_parse_mtp_linkset(mtp_linkset)) {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Failed to parse \&quot;mtp_linkset\&quot;!\n&quot;);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move on to the next linkset */</span>
<span style="color: #00A000">+                mtp_linkset = mtp_linkset-&gt;next;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        } /* while (mtp_linkset != NULL) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sng_link_set_t                         mtpLinkSet;</span>
<span style="color: #00A000">+        ftdm_conf_parameter_t        *parm = mtp_linkset-&gt;parameters;</span>
<span style="color: #00A000">+        int                                                 num_parms = mtp_linkset-&gt;n_parameters;</span>
<span style="color: #00A000">+        int                                                 i;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the mtpLinkSet structure */</span>
<span style="color: #00A000">+        memset(&amp;mtpLinkSet, 0x0, sizeof(mtpLinkSet));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at mtp_linkset */</span>
<span style="color: #00A000">+        if (strcasecmp(mtp_linkset-&gt;name, &quot;mtp_linkset&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;mtp_linkset\&quot;!\n&quot;,mtp_linkset-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;mtp_linkset\&quot;...\n&quot;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* extract all the information from the parameters */</span>
<span style="color: #00A000">+        for (i = 0; i &lt; num_parms; i++) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy((char *)mtpLinkSet.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtpLinkSet named = %s\n&quot;, mtpLinkSet.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtpLinkSet.id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found mtpLinkSet id = %d\n&quot;, mtpLinkSet.id);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;apc&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtpLinkSet.apc = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found mtpLinkSet apc = %d\n&quot;, mtpLinkSet.apc);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;minActive&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtpLinkSet.minActive = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found mtpLinkSet minActive = %d\n&quot;, mtpLinkSet.minActive);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move to the next parmeter */</span>
<span style="color: #00A000">+                parm = parm + 1;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* for (i = 0; i &lt; num_parms; i++) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_mtpLinkSet(&amp;mtpLinkSet);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* go through all the mtp3 links and fill in the apc */</span>
<span style="color: #00A000">+        i = 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == mtpLinkSet.id) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtpLinkSet.apc;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                i++;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         return FTDM_SUCCESS;
 }
 
<span style="color: #800080; font-weight: bold">@@ -813,6 +1269,7 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)</span>
         int                                                 num_parms = mtp_route-&gt;n_parameters;
         int                                                 i;
 
<span style="color: #00A000">+        /* initalize the mtpRoute structure */</span>
         memset(&amp;mtpRoute, 0x0, sizeof(mtpRoute));
 
         /* confirm that we are looking at an mtp_link */
<span style="color: #800080; font-weight: bold">@@ -824,119 +1281,120 @@ static int ftmod_ss7_parse_mtp_route(ftdm_conf_node_t *mtp_route)</span>
         }
 
         for (i = 0; i &lt; num_parms; i++) {
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
                 /* try to match the parameter to what we expect */
<span style="color: #A00000">-                /**********************************************************************/</span>
                 if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {
<span style="color: #A00000">-                        strncpy((char *)mtpRoute.name, parm-&gt;val, MAX_NAME_LEN-1);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound an \&quot;mtp_route\&quot; named = %s\n&quot;, mtpRoute.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy((char *)mtpRoute.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtpRoute named = %s\n&quot;, mtpRoute.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtpRoute.id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtpRoute id = %d\n&quot;, mtpRoute.id);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;dpc&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.dpc = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtpRoute-&gt;dpc = %d\n&quot;, mtpRoute.dpc);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp_linkset&quot;)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* find the linkset by it&#39;s name */</span>
<span style="color: #A00000">-                        int x = 1;</span>
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {</span>
<span style="color: #A00000">-                                /* check if the name matches */</span>
<span style="color: #A00000">-                                if (!strcasecmp((char *)g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, parm-&gt;val)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        /* now, harvest the required infomormation from the global structure */</span>
<span style="color: #A00000">-                                        mtpRoute.linkType                = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].linkType;</span>
<span style="color: #A00000">-                                        mtpRoute.switchType                = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].switchType;</span>
<span style="color: #A00000">-                                        mtpRoute.ssf                        = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].ssf;</span>
<span style="color: #A00000">-                                        mtpRoute.linkSetId                = g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id;</span>
<span style="color: #A00000">-                                        cmbLinkSetId++;</span>
<span style="color: #A00000">-                                        mtpRoute.cmbLinkSetId        = cmbLinkSetId;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        /* update the linkset with the new cmbLinkSet value */</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.mtpLinkSet[x].numLinks++;</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.mtpLinkSet[x].links[g_ftdm_sngss7_data.cfg.mtpLinkSet[x].numLinks-1] = mtpRoute.cmbLinkSetId;</span>
<span style="color: #A00000">-                                        break;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                x++;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* check why we exited the wile loop ... and react accordingly */</span>
<span style="color: #A00000">-                        if (mtpRoute.cmbLinkSetId == 0) {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFailed to find the linkset = \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #A00000">-                                return FTDM_FAIL;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtp3_route-&gt;linkset = %s\n&quot;, parm-&gt;val);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtpRoute dpc = %d\n&quot;, mtpRoute.dpc);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;linksetId&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        mtpRoute.linkSetId = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtpRoute linkset = %s\n&quot;, parm-&gt;val);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isSTP&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         if (!strcasecmp(parm-&gt;val, &quot;no&quot;)) {
                                 mtpRoute.isSTP = 0;
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpRoute-&gt;isSTP = no\n&quot;);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an mtpRoute isSTP = no\n&quot;);</span>
                         } else if (!strcasecmp(parm-&gt;val, &quot;yes&quot;)) {
                                 mtpRoute.isSTP = 1;
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound mtpRoute-&gt;isSTP = yes\n&quot;);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an mtpRoute isSTP = yes\n&quot;);</span>
                         } else {
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid parameter for isSTP \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid parameter for isSTP %s!\n&quot;, parm-&gt;val);</span>
                            return FTDM_FAIL;
                         }
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t6&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t6 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t6 = \&quot;%d\&quot;\n&quot;,mtpRoute.t6);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t6 = %d\n&quot;,mtpRoute.t6);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t8&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t8 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t8 = \&quot;%d\&quot;\n&quot;,mtpRoute.t8);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t8 = %d\n&quot;,mtpRoute.t8);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t10&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t10 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t10 = \&quot;%d\&quot;\n&quot;,mtpRoute.t10);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t10 = %d\n&quot;,mtpRoute.t10);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t11&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t11 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t11 = \&quot;%d\&quot;\n&quot;,mtpRoute.t11);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t11 = %d\n&quot;,mtpRoute.t11);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t15&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t15 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t15 = \&quot;%d\&quot;\n&quot;,mtpRoute.t15);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t15 = %d\n&quot;,mtpRoute.t15);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t16&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t16 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t16 = \&quot;%d\&quot;\n&quot;,mtpRoute.t16);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t16 = %d\n&quot;,mtpRoute.t16);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t18&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t18 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t18 = \&quot;%d\&quot;\n&quot;,mtpRoute.t18);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t18 = %d\n&quot;,mtpRoute.t18);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t19&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t19 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t19 = \&quot;%d\&quot;\n&quot;,mtpRoute.t19);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t19 = %d\n&quot;,mtpRoute.t19);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t21&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t21 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t21 = \&quot;%d\&quot;\n&quot;,mtpRoute.t21);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t21 = %d\n&quot;,mtpRoute.t21);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t25&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t25 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t25 = \&quot;%d\&quot;\n&quot;,mtpRoute.t25);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t25 = %d\n&quot;,mtpRoute.t25);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;mtp3.t26&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         mtpRoute.t26 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound mtp3 t26 = \&quot;%d\&quot;\n&quot;,mtpRoute.t26);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an mtp3 t26 = %d\n&quot;,mtpRoute.t26);</span>
                 /**********************************************************************/
                 } else {
<span style="color: #A00000">-                        SS7_ERROR(&quot;\tFound an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
                         return FTDM_FAIL;
<span style="color: #A00000">-</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
                 }
 
                 /* move to the next parameter */
                 parm = parm + 1;
         }
 
<span style="color: #A00000">-        ftmod_ss7_fill_in_nsap(&amp;mtpRoute);</span>
<span style="color: #00A000">+        /* pull up the linktype, switchtype, and SSF from the linkset */</span>
<span style="color: #00A000">+        mtpRoute.linkType = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].linkType;</span>
<span style="color: #00A000">+        mtpRoute.switchType = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].switchType;</span>
<span style="color: #00A000">+        mtpRoute.ssf = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtpRoute.linkSetId].ssf;</span>
 
<span style="color: #A00000">-        ftmod_ss7_fill_in_mtp3_route(&amp;mtpRoute);</span>
<span style="color: #00A000">+        /* fill in the rest of the values in the mtpRoute struct  */</span>
<span style="color: #00A000">+        mtpRoute.nwId = mtpRoute.id;</span>
<span style="color: #00A000">+        mtpRoute.cmbLinkSetId = mtpRoute.id;</span>
 
<span style="color: #00A000">+        ftmod_ss7_fill_in_mtp3_route(&amp;mtpRoute);</span>
 
<span style="color: #00A000">+        ftmod_ss7_fill_in_nsap(&amp;mtpRoute);</span>
 
         return FTDM_SUCCESS;
 }
<span style="color: #800080; font-weight: bold">@@ -979,10 +1437,9 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)</span>
         ftdm_conf_parameter_t        *parm = isup_interface-&gt;parameters;
         int                                                num_parms = isup_interface-&gt;n_parameters;
         int                                                i;
<span style="color: #A00000">-        int                                                linkSetId;</span>
<span style="color: #A00000">-        int                                                flag_cld_nadi = 0;</span>
<span style="color: #A00000">-        int                                                flag_clg_nadi = 0;</span>
<span style="color: #00A000">+        int                                                ret;</span>
 
<span style="color: #00A000">+        /* initalize the isup intf and isap structure */</span>
         memset(&amp;sng_isup, 0x0, sizeof(sng_isup));
         memset(&amp;sng_isap, 0x0, sizeof(sng_isap));
 
<span style="color: #800080; font-weight: bold">@@ -996,56 +1453,30 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)</span>
 
 
         for (i = 0; i &lt; num_parms; i++) {
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
                 /* try to match the parameter to what we expect */
<span style="color: #A00000">-                /**********************************************************************/</span>
                 if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {
<span style="color: #A00000">-                        strncpy((char *)sng_isup.name, parm-&gt;val, MAX_NAME_LEN-1);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound an \&quot;isup_interface\&quot; named = %s\n&quot;, sng_isup.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy((char *)sng_isup.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an isup_interface named = %s\n&quot;, sng_isup.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_isup.id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an isup id = %d\n&quot;, sng_isup.id);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;spc&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.spc = atoi(parm-&gt;val);
                         g_ftdm_sngss7_data.cfg.spc = sng_isup.spc;
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound SPC = %d\n&quot;, sng_isup.spc);</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;mtp_route&quot;)) {</span>
<span style="color: #A00000">-                        /* find the route by it&#39;s name */</span>
<span style="color: #A00000">-                        int x = 1;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* check if the name matches */</span>
<span style="color: #A00000">-                                if (!strcasecmp((char *)g_ftdm_sngss7_data.cfg.mtpRoute[x].name, parm-&gt;val)) {</span>
<span style="color: #A00000">-                                        /* now, harvest the required information from the global structure */</span>
<span style="color: #A00000">-                                        sng_isup.mtpRouteId                = g_ftdm_sngss7_data.cfg.mtpRoute[x].id;</span>
<span style="color: #A00000">-                                        sng_isup.dpc                        = g_ftdm_sngss7_data.cfg.mtpRoute[x].dpc;</span>
<span style="color: #A00000">-                                        sng_isup.switchType                 = g_ftdm_sngss7_data.cfg.mtpRoute[x].switchType;</span>
<span style="color: #A00000">-                                        sng_isap.switchType                = g_ftdm_sngss7_data.cfg.mtpRoute[x].switchType;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        /* find the NSAP corresponding to this switchType and SSF */</span>
<span style="color: #A00000">-                                        int z = 1;</span>
<span style="color: #A00000">-                                        while (g_ftdm_sngss7_data.cfg.nsap[z].id != 0) {</span>
<span style="color: #A00000">-                                                if ((g_ftdm_sngss7_data.cfg.nsap[z].linkType == g_ftdm_sngss7_data.cfg.mtpRoute[x].linkType) &amp;&amp;</span>
<span style="color: #A00000">-                                                        (g_ftdm_sngss7_data.cfg.nsap[z].switchType == g_ftdm_sngss7_data.cfg.mtpRoute[x].switchType) &amp;&amp;</span>
<span style="color: #A00000">-                                                        (g_ftdm_sngss7_data.cfg.nsap[z].ssf == g_ftdm_sngss7_data.cfg.mtpRoute[x].ssf)) {</span>
<span style="color: #A00000">-                                                                sng_isup.nwId         = g_ftdm_sngss7_data.cfg.nsap[z].nwId;</span>
<span style="color: #A00000">-                                                        /* we have a match so break out of this loop */</span>
<span style="color: #A00000">-                                                        break;</span>
<span style="color: #A00000">-                                                }</span>
<span style="color: #A00000">-                                                /* move on to the next one */</span>
<span style="color: #A00000">-                                                z++;</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                        break;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                x++;</span>
<span style="color: #A00000">-                        } /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* check why we exited the while loop ... and react accordingly */</span>
<span style="color: #A00000">-                        if (sng_isup.mtpRouteId == 0) {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFailed to find the MTP3 Route = \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #A00000">-                                return FTDM_FAIL;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound MTP3 Route = %s\n&quot;, parm-&gt;val);</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an isup SPC = %d\n&quot;, sng_isup.spc);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;mtprouteId&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_isup.mtpRouteId=atoi(parm-&gt;val);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an isup mptRouteId = %d\n&quot;, sng_isup.mtpRouteId);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;min_digits&quot;)) {
                         sng_isup.min_digits = atoi(parm-&gt;val);
<span style="color: #800080; font-weight: bold">@@ -1053,300 +1484,544 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)</span>
                         SS7_DEBUG(&quot;\tFound min_digits = %d\n&quot;, sng_isup.min_digits);
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;ssf&quot;)) {
<span style="color: #A00000">-                        if (!strcasecmp(parm-&gt;val, &quot;nat&quot;)) {</span>
<span style="color: #A00000">-                                sng_isup.ssf = SSF_NAT;</span>
<span style="color: #A00000">-                                sng_isap.ssf = SSF_NAT;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;int&quot;)) {</span>
<span style="color: #A00000">-                                sng_isup.ssf = SSF_INTL;</span>
<span style="color: #A00000">-                                sng_isap.ssf = SSF_INTL;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;spare&quot;)) {</span>
<span style="color: #A00000">-                                sng_isup.ssf = SSF_SPARE;</span>
<span style="color: #A00000">-                                sng_isap.ssf = SSF_SPARE;</span>
<span style="color: #A00000">-                        } else if (!strcasecmp(parm-&gt;val, &quot;res&quot;)) {</span>
<span style="color: #A00000">-                                sng_isup.ssf = SSF_RES;</span>
<span style="color: #A00000">-                                sng_isap.ssf = SSF_RES;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;\tFound an invalid ssf of \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_ssf_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid isup ssf = %s\n&quot;, parm-&gt;var);</span>
                                 return FTDM_FAIL;
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                sng_isup.ssf = sng_ssf_type_map[ret].tril_type;</span>
<span style="color: #00A000">+                                sng_isap.ssf = sng_ssf_type_map[ret].tril_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an isup ssf = %s\n&quot;, sng_ssf_type_map[ret].sng_type);</span>
                         }
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;license&quot;)) {</span>
<span style="color: #A00000">-                /**********************************************************************/</span>
<span style="color: #A00000">-                        strncpy(g_ftdm_sngss7_data.cfg.license, parm-&gt;val, MAX_PATH-1);</span>
<span style="color: #A00000">-                        strncpy(g_ftdm_sngss7_data.cfg.signature, parm-&gt;val, MAX_PATH-1);</span>
<span style="color: #A00000">-                        strcat(g_ftdm_sngss7_data.cfg.signature, &quot;.sig&quot;);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound license file = %s\n&quot;, g_ftdm_sngss7_data.cfg.license);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound signature file = %s\n&quot;, g_ftdm_sngss7_data.cfg.signature);        </span>
<span style="color: #A00000">-                /**********************************************************************/</span>
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t1&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t1 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t1 = \&quot;%d\&quot;\n&quot;,sng_isap.t1);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t1 = %d\n&quot;,sng_isap.t1);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t2&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t2 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t2 = \&quot;%d\&quot;\n&quot;,sng_isap.t2);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t2 = %d\n&quot;,sng_isap.t2);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t4&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t4 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t4 = \&quot;%d\&quot;\n&quot;,sng_isup.t4);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t4 = %d\n&quot;,sng_isup.t4);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t5&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t5 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t5 = \&quot;%d\&quot;\n&quot;,sng_isap.t5);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t5 = %d\n&quot;,sng_isap.t5);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t6&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t6 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t6 = \&quot;%d\&quot;\n&quot;,sng_isap.t6);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t6 = %d\n&quot;,sng_isap.t6);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t7&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t7 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t7 = \&quot;%d\&quot;\n&quot;,sng_isap.t7);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t7 = %d\n&quot;,sng_isap.t7);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t8&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t8 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t8 = \&quot;%d\&quot;\n&quot;,sng_isap.t8);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t8 = %d\n&quot;,sng_isap.t8);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t9&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t9 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t9 = \&quot;%d\&quot;\n&quot;,sng_isap.t9);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t9 = %d\n&quot;,sng_isap.t9);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t10&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t10 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t10 = \&quot;%d\&quot;\n&quot;,sng_isup.t10);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t10 = %d\n&quot;,sng_isup.t10);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t11&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t11 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t11 = \&quot;%d\&quot;\n&quot;,sng_isup.t11);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t11 = %d\n&quot;,sng_isup.t11);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t18&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t18 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t18 = \&quot;%d\&quot;\n&quot;,sng_isup.t18);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t18 = %d\n&quot;,sng_isup.t18);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t19&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t19 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t19 = \&quot;%d\&quot;\n&quot;,sng_isup.t19);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t19 = %d\n&quot;,sng_isup.t19);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t20&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t20 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t20 = \&quot;%d\&quot;\n&quot;,sng_isup.t20);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t20 = %d\n&quot;,sng_isup.t20);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t21&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t21 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t21 = \&quot;%d\&quot;\n&quot;,sng_isup.t21);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t21 = %d\n&quot;,sng_isup.t21);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t22&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t22 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t22 = \&quot;%d\&quot;\n&quot;,sng_isup.t22);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t22 = %d\n&quot;,sng_isup.t22);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t23&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t23 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t23 = \&quot;%d\&quot;\n&quot;,sng_isup.t23);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t23 = %d\n&quot;,sng_isup.t23);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t24&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t24 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t24 = \&quot;%d\&quot;\n&quot;,sng_isup.t24);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t24 = %d\n&quot;,sng_isup.t24);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t25&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t25 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t25 = \&quot;%d\&quot;\n&quot;,sng_isup.t25);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t25 = %d\n&quot;,sng_isup.t25);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t26&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t26 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t26 = \&quot;%d\&quot;\n&quot;,sng_isup.t26);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t26 = %d\n&quot;,sng_isup.t26);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t28&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t28 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t28 = \&quot;%d\&quot;\n&quot;,sng_isup.t28);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t28 = %d\n&quot;,sng_isup.t28);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t29&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t29 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t29 = \&quot;%d\&quot;\n&quot;,sng_isup.t29);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t29 = %d\n&quot;,sng_isup.t29);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t30&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t30 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t30 = \&quot;%d\&quot;\n&quot;,sng_isup.t30);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t30 = %d\n&quot;,sng_isup.t30);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t31&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t31 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t31 = \&quot;%d\&quot;\n&quot;,sng_isap.t31);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t31 = %d\n&quot;,sng_isap.t31);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t32&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t32 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t32 = \&quot;%d\&quot;\n&quot;,sng_isup.t32);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t32 = %d\n&quot;,sng_isup.t32);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t33&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t33 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t33 = \&quot;%d\&quot;\n&quot;,sng_isap.t33);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t33 = %d\n&quot;,sng_isap.t33);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t34&quot;)) {
<span style="color: #A00000">-                        sng_isap.t34 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t34 = \&quot;%d\&quot;\n&quot;,sng_isap.t34);</span>
                 /**********************************************************************/
<span style="color: #A00000">-                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t35&quot;)) {</span>
<span style="color: #A00000">-                        sng_isup.t35 = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t35 = \&quot;%d\&quot;\n&quot;,sng_isup.t35);</span>
<span style="color: #00A000">+                        sng_isap.t34 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t34 = %d\n&quot;,sng_isap.t34);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t36&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.t36 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t36 = \&quot;%d\&quot;\n&quot;,sng_isap.t36);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t36 = %d\n&quot;,sng_isap.t36);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t37&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t37 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t37 = \&quot;%d\&quot;\n&quot;,sng_isup.t37);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t37 = %d\n&quot;,sng_isup.t37);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t38&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t38 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t38 = \&quot;%d\&quot;\n&quot;,sng_isup.t38);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t38 = %d\n&quot;,sng_isup.t38);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.t39&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.t39 = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup t39 = \&quot;%d\&quot;\n&quot;,sng_isup.t39);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t39 = %d\n&quot;,sng_isup.t39);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tccr&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tccr = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tccr = \&quot;%d\&quot;\n&quot;,sng_isap.tccr);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tccr = %d\n&quot;,sng_isap.tccr);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tccrt&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tccrt = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tccrt = \&quot;%d\&quot;\n&quot;,sng_isap.tccrt);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tccrt = %d\n&quot;,sng_isap.tccrt);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tex&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tex = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tex = \&quot;%d\&quot;\n&quot;,sng_isap.tex);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tex = %d\n&quot;,sng_isap.tex);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tect&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tect = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tect = \&quot;%d\&quot;\n&quot;,sng_isap.tect);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tect = %d\n&quot;,sng_isap.tect);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tcrm&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tcrm = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tcrm = \&quot;%d\&quot;\n&quot;,sng_isap.tcrm);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tcrm = %d\n&quot;,sng_isap.tcrm);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tcra&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tcra = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tcra = \&quot;%d\&quot;\n&quot;,sng_isap.tcra);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tcra = %d\n&quot;,sng_isap.tcra);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tfgr&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.tfgr = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tfgr = \&quot;%d\&quot;\n&quot;,sng_isup.tfgr);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tfgr = %d\n&quot;,sng_isup.tfgr);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.trelrsp&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.trelrsp = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup trelrsp = \&quot;%d\&quot;\n&quot;,sng_isap.trelrsp);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup trelrsp = %d\n&quot;,sng_isap.trelrsp);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tfnlrelrsp&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tfnlrelrsp = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tfnlrelrsp = \&quot;%d\&quot;\n&quot;,sng_isap.tfnlrelrsp);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tfnlrelrsp = %d\n&quot;,sng_isap.tfnlrelrsp);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tfnlrelrsp&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isap.tfnlrelrsp = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tfnlrelrsp = \&quot;%d\&quot;\n&quot;,sng_isap.tfnlrelrsp);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tfnlrelrsp = %d\n&quot;,sng_isap.tfnlrelrsp);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tpause&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.tpause = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tpause = \&quot;%d\&quot;\n&quot;,sng_isup.tpause);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tpause = %d\n&quot;,sng_isup.tpause);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;isup.tstaenq&quot;)) {
<span style="color: #00A000">+                /**********************************************************************/</span>
                         sng_isup.tstaenq = atoi(parm-&gt;val);
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound isup tstaenq = \&quot;%d\&quot;\n&quot;,sng_isup.tstaenq);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tstaenq = %d\n&quot;,sng_isup.tstaenq);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter %s!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* move to the next parameter */</span>
<span style="color: #00A000">+                parm = parm + 1;</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* for (i = 0; i &lt; num_parms; i++) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* default the interface to paused state */</span>
<span style="color: #00A000">+        sngss7_set_flag(&amp;sng_isup, SNGSS7_PAUSED);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* trickle down the SPC to all sub entities */</span>
<span style="color: #00A000">+        int        linkSetId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        linkSetId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].linkSetId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        i = 1;</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == linkSetId) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.mtp3Link[i].spc = g_ftdm_sngss7_data.cfg.spc;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                i++;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* pull values from the lower levels */</span>
<span style="color: #00A000">+        sng_isup.dpc = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].dpc;</span>
<span style="color: #00A000">+        sng_isup.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].switchType;</span>
<span style="color: #00A000">+        sng_isup.nwId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].nwId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        sng_isap.switchType = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].switchType;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_isap(&amp;sng_isap);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        sng_isup.isap = sng_isap.id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_isup_interface(&amp;sng_isup);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* setup the self mtp3 route */</span>
<span style="color: #00A000">+        i = sng_isup.mtpRouteId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if(ftmod_ss7_fill_in_self_route(sng_isup.spc,</span>
<span style="color: #00A000">+                                                                        g_ftdm_sngss7_data.cfg.mtpRoute[i].linkType,</span>
<span style="color: #00A000">+                                                                        g_ftdm_sngss7_data.cfg.mtpRoute[i].switchType,</span>
<span style="color: #00A000">+                                                                        g_ftdm_sngss7_data.cfg.mtpRoute[i].ssf)) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;Failed to fill in self route structure!\n&quot;);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_cc_spans(ftdm_conf_node_t *cc_spans)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        ftdm_conf_node_t        *cc_span = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at cc_spans */</span>
<span style="color: #00A000">+        if (strcasecmp(cc_spans-&gt;name, &quot;cc_spans&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;cc_spans\&quot;!\n&quot;,cc_spans-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;cc_spans\&quot;...\n&quot;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* extract the cc_spans */</span>
<span style="color: #00A000">+        cc_span = cc_spans-&gt;child;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        while (cc_span != NULL) {</span>
<span style="color: #00A000">+                /* parse the found cc_span */</span>
<span style="color: #00A000">+                if (ftmod_ss7_parse_cc_span(cc_span)) {</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Failed to parse \&quot;cc_span\&quot;\n&quot;);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* go to the next cc_span */</span>
<span style="color: #00A000">+                cc_span = cc_span-&gt;next;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        sng_ccSpan_t                        sng_ccSpan;</span>
<span style="color: #00A000">+        ftdm_conf_parameter_t        *parm = cc_span-&gt;parameters;</span>
<span style="color: #00A000">+        int                                                num_parms = cc_span-&gt;n_parameters;</span>
<span style="color: #00A000">+        int                                                flag_clg_nadi = 0;</span>
<span style="color: #00A000">+        int                                                flag_cld_nadi = 0;</span>
<span style="color: #00A000">+        int                                                i;</span>
<span style="color: #00A000">+        int                                                ret;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* initalize the ccSpan structure */</span>
<span style="color: #00A000">+        memset(&amp;sng_ccSpan, 0x0, sizeof(sng_ccSpan));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* confirm that we are looking at an mtp_link */</span>
<span style="color: #00A000">+        if (strcasecmp(cc_span-&gt;name, &quot;cc_span&quot;)) {</span>
<span style="color: #00A000">+                SS7_ERROR(&quot;We&#39;re looking at \&quot;%s\&quot;...but we&#39;re supposed to be looking at \&quot;cc_span\&quot;!\n&quot;,cc_span-&gt;name);</span>
<span style="color: #00A000">+                return FTDM_FAIL;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Parsing \&quot;cc_span\&quot;...\n&quot;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        for (i = 0; i &lt; num_parms; i++) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* try to match the parameter to what we expect */</span>
<span style="color: #00A000">+                if (!strcasecmp(parm-&gt;var, &quot;name&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy((char *)sng_ccSpan.name, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an ccSpan named = %s\n&quot;, sng_ccSpan.name);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;id&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.id = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an ccSpan id = %d\n&quot;, sng_ccSpan.id);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;procid&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.procId = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an ccSpan procId = %d\n&quot;, sng_ccSpan.procId);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;ch_map&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        strcpy(sng_ccSpan.ch_map, parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found channel map %s\n&quot;, sng_ccSpan.ch_map);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;typeCntrl&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_cic_cntrl_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid ccSpan typeCntrl = %s\n&quot;, parm-&gt;var);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                sng_ccSpan.typeCntrl = sng_cic_cntrl_type_map[ret].tril_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an ccSpan typeCntrl = %s\n&quot;, sng_cic_cntrl_type_map[ret].sng_type);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;ssf&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_ssf_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid ccSpan ssf = %s\n&quot;, parm-&gt;var);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                sng_ccSpan.ssf = sng_ssf_type_map[ret].tril_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an ccSpan ssf = %s\n&quot;, sng_ssf_type_map[ret].sng_type);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;switchType&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        ret = find_switch_type_in_map(parm-&gt;val);</span>
<span style="color: #00A000">+                        if (ret == -1) {</span>
<span style="color: #00A000">+                                SS7_ERROR(&quot;Found an invalid ccSpan switchType = %s\n&quot;, parm-&gt;var);</span>
<span style="color: #00A000">+                                return FTDM_FAIL;</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                sng_ccSpan.switchType = sng_switch_type_map[ret].tril_isup_type;</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found an ccSpan switchType = %s\n&quot;, sng_switch_type_map[ret].sng_type);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;cicbase&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.cicbase = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found a cicbase = %d\n&quot;, sng_ccSpan.cicbase);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup_interface&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.isupInf = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found an isup_interface = %d\n&quot;,sng_ccSpan.isupInf);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;min_digits&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.min_digits = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found a min_digits = %d\n&quot;,sng_ccSpan.min_digits);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;clg_nadi&quot;)) {
                 /**********************************************************************/
                         /* throw the flag so that we know we got this optional parameter */
                         flag_clg_nadi = 1;
<span style="color: #A00000">-                        sng_isup.clg_nadi = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound default CLG_NADI value = %d\n&quot;, sng_isup.clg_nadi);</span>
<span style="color: #00A000">+                        sng_ccSpan.clg_nadi = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found default CLG_NADI parm-&gt;value = %d\n&quot;, sng_ccSpan.clg_nadi);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;cld_nadi&quot;)) {
                 /**********************************************************************/
                         /* throw the flag so that we know we got this optional parameter */
                         flag_cld_nadi = 1;
<span style="color: #A00000">-                        sng_isup.cld_nadi = atoi(parm-&gt;val);</span>
<span style="color: #A00000">-                        SS7_DEBUG(&quot;\tFound default CLD_NADI value = %d\n&quot;, sng_isup.cld_nadi);</span>
<span style="color: #00A000">+                        sng_ccSpan.cld_nadi = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found default CLD_NADI parm-&gt;value = %d\n&quot;, sng_ccSpan.cld_nadi);</span>
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;obci_bita&quot;)) {
                 /**********************************************************************/
                         if (*parm-&gt;val == &#39;1&#39;) {
<span style="color: #A00000">-                                sngss7_set_options(&amp;sng_isup, SNGSS7_ACM_OBCI_BITA);</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound Optional Backwards Indicator: Bit A (early media) enable option\n&quot;);</span>
<span style="color: #00A000">+                                sngss7_set_options(&amp;sng_ccSpan, SNGSS7_ACM_OBCI_BITA);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found Optional Backwards Indicator: Bit A (early media) enable option\n&quot;);</span>
                         } else if (*parm-&gt;val == &#39;0&#39;) {
<span style="color: #A00000">-                                sngss7_clear_options(&amp;sng_isup, SNGSS7_ACM_OBCI_BITA);</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound Optional Backwards Indicator: Bit A (early media) disable option\n&quot;);</span>
<span style="color: #00A000">+                                sngss7_clear_options(&amp;sng_ccSpan, SNGSS7_ACM_OBCI_BITA);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found Optional Backwards Indicator: Bit A (early media) disable option\n&quot;);</span>
                         } else {
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tInvalid value for \&quot;obci_bita\&quot; option\n&quot;);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Invalid parm-&gt;value for obci_bita option\n&quot;);</span>
                         }
                 /**********************************************************************/
                 } else if (!strcasecmp(parm-&gt;var, &quot;lpa_on_cot&quot;)) {
                 /**********************************************************************/
                         if (*parm-&gt;val == &#39;1&#39;) {
<span style="color: #A00000">-                                sngss7_set_options(&amp;sng_isup, SNGSS7_LPA_FOR_COT);</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound Tx LPA on COT enable option\n&quot;);</span>
<span style="color: #00A000">+                                sngss7_set_options(&amp;sng_ccSpan, SNGSS7_LPA_FOR_COT);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found Tx LPA on COT enable option\n&quot;);</span>
                         } else if (*parm-&gt;val == &#39;0&#39;) {
<span style="color: #A00000">-                                sngss7_clear_options(&amp;sng_isup, SNGSS7_LPA_FOR_COT);</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tFound Tx LPA on COT disable option\n&quot;);</span>
<span style="color: #00A000">+                                sngss7_clear_options(&amp;sng_ccSpan, SNGSS7_LPA_FOR_COT);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Found Tx LPA on COT disable option\n&quot;);</span>
                         } else {
<span style="color: #A00000">-                                SS7_DEBUG(&quot;\tInvalid value for \&quot;lpa_on_cot\&quot; option\n&quot;);</span>
<span style="color: #00A000">+                                SS7_DEBUG(&quot;Invalid parm-&gt;value for lpa_on_cot option\n&quot;);</span>
                         }
                 /**********************************************************************/
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t3&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t3 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t3 = %d\n&quot;, sng_ccSpan.t3);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t12&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t12 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t12 = %d\n&quot;, sng_ccSpan.t12);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t13&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t13 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t13 = %d\n&quot;, sng_ccSpan.t13);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t14&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t14 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t14 = %d\n&quot;, sng_ccSpan.t14);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t15&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t15 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t15 = %d\n&quot;, sng_ccSpan.t15);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t16&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t16 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t16 = %d\n&quot;, sng_ccSpan.t16);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t17&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t17 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t17 = %d\n&quot;, sng_ccSpan.t17);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.t35&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.t35 = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup t35 = %d\n&quot;,sng_ccSpan.t35);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } else if (!strcasecmp(parm-&gt;var, &quot;isup.tval&quot;)) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        sng_ccSpan.tval = atoi(parm-&gt;val);</span>
<span style="color: #00A000">+                        SS7_DEBUG(&quot;Found isup tval = %d\n&quot;, sng_ccSpan.tval);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
                 } else {
<span style="color: #A00000">-                        SS7_ERROR(&quot;\tFound an invalid parameter \&quot;%s\&quot;!\n&quot;, parm-&gt;val);</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        SS7_ERROR(&quot;Found an invalid parameter %s!\n&quot;, parm-&gt;var);</span>
                         return FTDM_FAIL;
<span style="color: #A00000">-</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
                 }
 
                 /* move to the next parameter */
                 parm = parm + 1;
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* for (i = 0; i &lt; num_parms; i++) */</span>
 
         /* check if the user filled in a nadi value by looking at flag */
         if (!flag_cld_nadi) {
                 /* default the nadi value to national */
<span style="color: #A00000">-                sng_isup.cld_nadi = 0x03;</span>
<span style="color: #00A000">+                sng_ccSpan.cld_nadi = 0x03;</span>
         }
 
         if (!flag_clg_nadi) {
                 /* default the nadi value to national */
<span style="color: #A00000">-                sng_isup.clg_nadi = 0x03;</span>
<span style="color: #00A000">+                sng_ccSpan.clg_nadi = 0x03;</span>
         }
 
<span style="color: #A00000">-        /* check if the user requested min_digits value */</span>
<span style="color: #A00000">-        if (sng_isup.min_digits == 0) {</span>
<span style="color: #A00000">-                /* default to 7 */</span>
<span style="color: #A00000">-                sng_isup.min_digits = 7;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-                </span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /* trickle down the SPC to all sub entities */</span>
<span style="color: #A00000">-        linkSetId = g_ftdm_sngss7_data.cfg.mtpRoute[sng_isup.mtpRouteId].linkSetId;</span>
<span style="color: #00A000">+        /* add this span to our global listing */</span>
<span style="color: #00A000">+        ftmod_ss7_fill_in_ccSpan(&amp;sng_ccSpan);</span>
 
<span style="color: #A00000">-        i = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.mtpLink[i].id != 0) {</span>
<span style="color: #A00000">-                if (g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.linkSetId == linkSetId) {</span>
<span style="color: #A00000">-                        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.spc = g_ftdm_sngss7_data.cfg.spc;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+        /* make sure the isup interface structure has something in it */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].id == 0) {</span>
<span style="color: #00A000">+                /* fill in the id, so that we know it exists */</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].id = sng_ccSpan.isupInf;</span>
 
<span style="color: #A00000">-                i++;</span>
<span style="color: #00A000">+                /* default the status to PAUSED */</span>
<span style="color: #00A000">+                sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf], SNGSS7_PAUSED);</span>
         }
 
<span style="color: #A00000">-        ftmod_ss7_fill_in_isap(&amp;sng_isap);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        sng_isup.isap = sng_isap.id;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        ftmod_ss7_fill_in_isup_interface(&amp;sng_isup);</span>
<span style="color: #A00000">-</span>
         return FTDM_SUCCESS;
 }
 
 /******************************************************************************/
<span style="color: #A00000">-static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink)</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_relay_channel(sng_relay_t *relay_channel)</span>
 {
         int i;
 
<span style="color: #A00000">-        /* go through all the existing links and see if we find a match */</span>
<span style="color: #00A000">+        /* go through all the existing channels and see if we find a match */</span>
         i = 1;
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.mtpLink[i].id != 0) {</span>
<span style="color: #A00000">-                if ((g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.span == mtpLink-&gt;mtp1.span) &amp;&amp;</span>
<span style="color: #A00000">-                        (g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.chan == mtpLink-&gt;mtp1.chan)) {</span>
<span style="color: #00A000">+        while (g_ftdm_sngss7_data.cfg.relay[i].id != 0) {</span>
<span style="color: #00A000">+                if ((g_ftdm_sngss7_data.cfg.relay[i].type == relay_channel-&gt;type) &amp;&amp;</span>
<span style="color: #00A000">+                        (g_ftdm_sngss7_data.cfg.relay[i].port == relay_channel-&gt;port) &amp;&amp;</span>
<span style="color: #00A000">+                        (g_ftdm_sngss7_data.cfg.relay[i].procId == relay_channel-&gt;procId) &amp;&amp;</span>
<span style="color: #00A000">+                        (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[i].hostname, relay_channel-&gt;hostname))) {</span>
 
                         /* we have a match so break out of this loop */
                         break;
<span style="color: #800080; font-weight: bold">@@ -1355,179 +2030,273 @@ static int ftmod_ss7_fill_in_mtpLink(sng_mtp_link_t *mtpLink)</span>
                 i++;
         }
 
<span style="color: #A00000">-        /* if the id value is 0 that means we didn&#39;t find the link */</span>
<span style="color: #A00000">-        if (g_ftdm_sngss7_data.cfg.mtpLink[i].id  == 0) {</span>
<span style="color: #A00000">-                mtpLink-&gt;id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found new mtpLink on span=%d, chan=%d, id = %d\n&quot;, </span>
<span style="color: #A00000">-                                        mtpLink-&gt;mtp1.span, </span>
<span style="color: #A00000">-                                        mtpLink-&gt;mtp1.chan, </span>
<span style="color: #A00000">-                                        mtpLink-&gt;id);</span>
<span style="color: #00A000">+                /* if the id value is 0 that means we didn&#39;t find the relay channel */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.relay[i].id  == 0) {</span>
<span style="color: #00A000">+                relay_channel-&gt;id = i;</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;found new relay channel on type:%d, hostname:%s, port:%d, procId:%d, id = %d\n&quot;,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;type,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;hostname,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;port,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;procId, </span>
<span style="color: #00A000">+                                        relay_channel-&gt;id);</span>
<span style="color: #00A000">+                sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_RY);</span>
         } else {
<span style="color: #A00000">-                mtpLink-&gt;id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found existing mtpLink on span=%d, chan=%d, id = %d\n&quot;, </span>
<span style="color: #A00000">-                                        mtpLink-&gt;mtp1.span, </span>
<span style="color: #A00000">-                                        mtpLink-&gt;mtp1.chan, </span>
<span style="color: #A00000">-                                        mtpLink-&gt;id);</span>
<span style="color: #00A000">+                relay_channel-&gt;id = i;</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;found existing relay channel on type:%d, hostname:%s, port:%d, procId:%d, id = %d\n&quot;,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;type,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;hostname,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;port,</span>
<span style="color: #00A000">+                                        relay_channel-&gt;procId, </span>
<span style="color: #00A000">+                                        relay_channel-&gt;id);</span>
         }
 
<span style="color: #A00000">-        /* fill in the information */</span>
<span style="color: #A00000">-        strncpy((char *)g_ftdm_sngss7_data.cfg.mtpLink[i].name, (char *)mtpLink-&gt;name, MAX_NAME_LEN-1);</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.relay[i].id                = relay_channel-&gt;id;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.relay[i].type        = relay_channel-&gt;type;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.relay[i].port        = relay_channel-&gt;port;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.relay[i].procId        = relay_channel-&gt;procId;</span>
<span style="color: #00A000">+        strcpy(g_ftdm_sngss7_data.cfg.relay[i].hostname, relay_channel-&gt;hostname);</span>
<span style="color: #00A000">+        strcpy(g_ftdm_sngss7_data.cfg.relay[i].name, relay_channel-&gt;name);</span>
 
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].id                                = mtpLink-&gt;id;</span>
<span style="color: #00A000">+        /* if this is THE listen channel grab the procId and use it */</span>
<span style="color: #00A000">+        if (relay_channel-&gt;type == LRY_CT_TCP_LISTEN) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.procId = relay_channel-&gt;procId;</span>
<span style="color: #00A000">+        }</span>
 
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.span                 = mtpLink-&gt;mtp1.span;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp1.chan                 = mtpLink-&gt;mtp1.chan;</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
 
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.linkType                = mtpLink-&gt;mtp2.linkType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.errorType        = mtpLink-&gt;mtp2.errorType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.lssuLength        = mtpLink-&gt;mtp2.lssuLength;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.mtp1Id                = mtpLink-&gt;id;</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_mtp1_link(sng_mtp1_link_t *mtp1Link)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = mtp1Link-&gt;id;</span>
 
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.priority                = mtpLink-&gt;mtp3.priority;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.linkType                = mtpLink-&gt;mtp3.linkType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.switchType        = mtpLink-&gt;mtp3.switchType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.apc                        = mtpLink-&gt;mtp3.apc;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.spc                        = g_ftdm_sngss7_data.cfg.spc;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.ssf                        = mtpLink-&gt;mtp3.ssf;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.slc                        = mtpLink-&gt;mtp3.slc;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.linkSetId        = mtpLink-&gt;mtp3.linkSetId;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.mtp2Id                = mtpLink-&gt;id;</span>
<span style="color: #00A000">+        /* check if this id value has been used already */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtp1Link[i].id == 0) {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found new MTP1 Link: id=%d, name=%s\n&quot;, mtp1Link-&gt;id, mtp1Link-&gt;name);</span>
<span style="color: #00A000">+                sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP1);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found an existing MTP1 Link: id=%d, name=%s (old name=%s)\n&quot;, </span>
<span style="color: #00A000">+                                        mtp1Link-&gt;id, </span>
<span style="color: #00A000">+                                        mtp1Link-&gt;name,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.mtp1Link[i].name);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* copy over the values */</span>
<span style="color: #00A000">+        strcpy((char *)g_ftdm_sngss7_data.cfg.mtp1Link[i].name, (char *)mtp1Link-&gt;name);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp1Link[i].id                = mtp1Link-&gt;id;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp1Link[i].span                = mtp1Link-&gt;span;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp1Link[i].chan                = mtp1Link-&gt;chan;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_mtp2_link(sng_mtp2_link_t *mtp2Link)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = mtp2Link-&gt;id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check if this id value has been used already */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtp2Link[i].id == 0) {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found new MTP2 Link: id=%d, name=%s\n&quot;, mtp2Link-&gt;id, mtp2Link-&gt;name);</span>
<span style="color: #00A000">+                sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP2);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found an existing MTP2 Link: id=%d, name=%s (old name=%s)\n&quot;, </span>
<span style="color: #00A000">+                                        mtp2Link-&gt;id, </span>
<span style="color: #00A000">+                                        mtp2Link-&gt;name,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.mtp2Link[i].name);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* copy over the values */</span>
<span style="color: #00A000">+        strcpy((char *)g_ftdm_sngss7_data.cfg.mtp2Link[i].name, (char *)mtp2Link-&gt;name);</span>
 
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t1 != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t1                = mtpLink-&gt;mtp2.t1;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp2Link[i].id                        = mtp2Link-&gt;id;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp2Link[i].lssuLength        = mtp2Link-&gt;lssuLength;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp2Link[i].errorType        = mtp2Link-&gt;errorType;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp2Link[i].linkType                = mtp2Link-&gt;linkType;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp2Link[i].mtp1Id                = mtp2Link-&gt;mtp1Id;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp2Link[i].mtp1ProcId        = mtp2Link-&gt;mtp1ProcId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t1 != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t1                = mtp2Link-&gt;t1;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t1                = 500;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t1                = 500;</span>
         }
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t2 != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t2                = mtpLink-&gt;mtp2.t2;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t2 != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t2                = mtp2Link-&gt;t2;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t2                = 250;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t2                = 250;</span>
         }
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t3 != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t3                = mtpLink-&gt;mtp2.t3;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t3 != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t3                = mtp2Link-&gt;t3;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t3                = 20;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t3                = 20;</span>
         }
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t4n != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4n                = mtpLink-&gt;mtp2.t4n;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t4n != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t4n                = mtp2Link-&gt;t4n;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4n                = 80;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t4n                = 80;</span>
         }
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t4e != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4e                = mtpLink-&gt;mtp2.t4e;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t4e != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t4e                = mtp2Link-&gt;t4e;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t4e                = 5;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t4e                = 5;</span>
         }
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t5 != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t5                = mtpLink-&gt;mtp2.t5;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t5 != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t5                = mtp2Link-&gt;t5;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t5                = 1;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t5                = 1;</span>
         }
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t6 != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t6                = mtpLink-&gt;mtp2.t6;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t6 != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t6                = mtp2Link-&gt;t6;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t6                = 60;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t6                = 60;</span>
         }
<span style="color: #A00000">-        if ( mtpLink-&gt;mtp2.t7 != 0 ) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t7                = mtpLink-&gt;mtp2.t7;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if ( mtp2Link-&gt;t7 != 0 ) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t7                = mtp2Link-&gt;t7;</span>
         }else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp2.t7                = 40;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp2Link[i].t7                = 40;</span>
         }
 
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t1 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t1                = mtpLink-&gt;mtp3.t1;</span>
<span style="color: #A00000">-        } else { </span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t1                = 8;</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_mtp3_link(sng_mtp3_link_t *mtp3Link)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        int i = mtp3Link-&gt;id;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* check if this id value has been used already */</span>
<span style="color: #00A000">+        if (g_ftdm_sngss7_data.cfg.mtp3Link[i].id == 0) {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found new MTP3 Link: id=%d, name=%s\n&quot;, mtp3Link-&gt;id, mtp3Link-&gt;name);</span>
<span style="color: #00A000">+                sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_MTP3);</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found an existing MTP3 Link: id=%d, name=%s (old name=%s)\n&quot;, </span>
<span style="color: #00A000">+                                        mtp3Link-&gt;id, </span>
<span style="color: #00A000">+                                        mtp3Link-&gt;name,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.mtp3Link[i].name);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* copy over the values */</span>
<span style="color: #00A000">+        strcpy((char *)g_ftdm_sngss7_data.cfg.mtp3Link[i].name, (char *)mtp3Link-&gt;name);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].id                        = mtp3Link-&gt;id;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].priority                = mtp3Link-&gt;priority;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].linkType                = mtp3Link-&gt;linkType;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].switchType        = mtp3Link-&gt;switchType;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].apc                        = mtp3Link-&gt;apc;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].spc                        = mtp3Link-&gt;spc;        /* unknown at this time */</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].ssf                        = mtp3Link-&gt;ssf;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].slc                        = mtp3Link-&gt;slc;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId        = mtp3Link-&gt;linkSetId;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].mtp2Id                = mtp3Link-&gt;mtp2Id;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtp3Link[i].mtp2ProcId        = mtp3Link-&gt;mtp2ProcId;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t1 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t1                = mtp3Link-&gt;t1;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t1                = 8;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t2 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t2                = mtp3Link-&gt;t2;</span>
<span style="color: #00A000">+        } else {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t2                = 14;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t2 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t2                = mtpLink-&gt;mtp3.t2;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t3 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t3                = mtp3Link-&gt;t3;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t2                = 14;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t3                = 8;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t3 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t3                = mtpLink-&gt;mtp3.t3;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t4 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t4                = mtp3Link-&gt;t4;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t3                = 8;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t4                = 8;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t4 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t4                = mtpLink-&gt;mtp3.t4;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t5 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t5                = mtp3Link-&gt;t5;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t4                = 8;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t5                = 8;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t5 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t5                = mtpLink-&gt;mtp3.t5;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t7 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t7                = mtp3Link-&gt;t7;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t5                = 8;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t7                = 15;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t7 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t7                = mtpLink-&gt;mtp3.t7;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t12 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t12                = mtp3Link-&gt;t12;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t7                = 15;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t12                = 15;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t12 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t12                = mtpLink-&gt;mtp3.t12;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t13 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t13                = mtp3Link-&gt;t13;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t12                = 15;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t13                = 15;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t13 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t13                = mtpLink-&gt;mtp3.t13;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t14 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t14                = mtp3Link-&gt;t14;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t13                = 15;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t14                = 30;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t14 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t14                = mtpLink-&gt;mtp3.t14;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t17 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t17                = mtp3Link-&gt;t17;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t14                = 30;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t17                = 15;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t17 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t17                = mtpLink-&gt;mtp3.t17;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t22 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t22                = mtp3Link-&gt;t22;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t17                = 15;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t22                = 1800;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t22 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t22                = mtpLink-&gt;mtp3.t22;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t23 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t23                = mtp3Link-&gt;t23;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t22                = 1800;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t23                = 1800;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t23 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t23                = mtpLink-&gt;mtp3.t23;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t24 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t24                = mtp3Link-&gt;t24;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t23                = 1800;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t24                = 5;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t24 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t24                = mtpLink-&gt;mtp3.t24;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t31 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t31                = mtp3Link-&gt;t31;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t24                = 5;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t31                = 50;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t31 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t31                = mtpLink-&gt;mtp3.t31;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t32 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t32                = mtp3Link-&gt;t32;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t31                = 50;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t32                = 120;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t32 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t32                = mtpLink-&gt;mtp3.t32;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t33 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t33                = mtp3Link-&gt;t33;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t32                = 120;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t33                = 3000;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t33 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t33                = mtpLink-&gt;mtp3.t33;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;t34 != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t34                = mtp3Link-&gt;t34;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t33                = 3000;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].t34                = 600;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.t34 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t34                = mtpLink-&gt;mtp3.t34;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;tbnd != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].tbnd                = mtp3Link-&gt;tbnd;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.t34                = 600;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].tbnd                = 30000;</span>
         }
<span style="color: #A00000">-        if (mtpLink-&gt;mtp3.tflc != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.tflc                = mtpLink-&gt;mtp3.tflc;</span>
<span style="color: #00A000">+        if (mtp3Link-&gt;tflc != 0) {</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].tflc                = mtp3Link-&gt;tflc;</span>
         } else {
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.mtpLink[i].mtp3.tflc                = 300;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.mtp3Link[i].tflc                = 300;</span>
         }
<span style="color: #A00000">-        return (mtpLink-&gt;id);</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
 }
 
<span style="color: #A00000">-</span>
 /******************************************************************************/
 static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)
 {
<span style="color: #800080; font-weight: bold">@@ -1537,9 +2306,6 @@ static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)</span>
 
         g_ftdm_sngss7_data.cfg.mtpLinkSet[i].id                        = mtpLinkSet-&gt;id;
         g_ftdm_sngss7_data.cfg.mtpLinkSet[i].apc                = mtpLinkSet-&gt;apc;
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLinkSet[i].linkType        = mtpLinkSet-&gt;linkType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLinkSet[i].switchType        = mtpLinkSet-&gt;switchType;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.mtpLinkSet[i].ssf                = mtpLinkSet-&gt;ssf;</span>
 
         /* these values are filled in as we find routes and start allocating cmbLinkSetIds */
         g_ftdm_sngss7_data.cfg.mtpLinkSet[i].minActive        = mtpLinkSet-&gt;minActive;
<span style="color: #800080; font-weight: bold">@@ -1550,28 +2316,25 @@ static int ftmod_ss7_fill_in_mtpLinkSet(sng_link_set_t *mtpLinkSet)</span>
 /******************************************************************************/
 static int ftmod_ss7_fill_in_mtp3_route(sng_route_t *mtp3_route)
 {
<span style="color: #A00000">-        int i;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /* go through all the existing routes and see if we find a match */</span>
<span style="color: #A00000">-        i = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.mtpRoute[i].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpRoute[i].name, mtp3_route-&gt;name)) {</span>
<span style="color: #A00000">-                        /* we have a match so break out of this loop */</span>
<span style="color: #A00000">-                        break;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                /* move on to the next one */</span>
<span style="color: #A00000">-                i++;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        int i = mtp3_route-&gt;id;</span>
 
<span style="color: #00A000">+        /* check if this id value has been used already */</span>
         if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
<span style="color: #A00000">-                mtp3_route-&gt;id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found new mtp3_route, id is = %d\n&quot;, mtp3_route-&gt;id);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found new MTP3 Link: id=%d, name=%s\n&quot;, mtp3_route-&gt;id, mtp3_route-&gt;name);</span>
         } else {
<span style="color: #A00000">-                mtp3_route-&gt;id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found existing mtp3_route, id is = %d\n&quot;, mtp3_route-&gt;id);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found an existing MTP3 Link: id=%d, name=%s (old name=%s)\n&quot;, </span>
<span style="color: #00A000">+                                        mtp3_route-&gt;id, </span>
<span style="color: #00A000">+                                        mtp3_route-&gt;name,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.mtpRoute[i].name);</span>
         }
 
<span style="color: #A00000">-        strncpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, (char *)mtp3_route-&gt;name, MAX_NAME_LEN-1);</span>
<span style="color: #00A000">+        /* fill in the cmbLinkSet in the linkset structure */</span>
<span style="color: #00A000">+        int tmp = g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route-&gt;linkSetId].numLinks;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route-&gt;linkSetId].links[tmp] = mtp3_route-&gt;cmbLinkSetId;</span>
<span style="color: #00A000">+        g_ftdm_sngss7_data.cfg.mtpLinkSet[mtp3_route-&gt;linkSetId].numLinks++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        strcpy((char *)g_ftdm_sngss7_data.cfg.mtpRoute[i].name, (char *)mtp3_route-&gt;name);</span>
 
         g_ftdm_sngss7_data.cfg.mtpRoute[i].id                        = mtp3_route-&gt;id;
         g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc                        = mtp3_route-&gt;dpc;
<span style="color: #800080; font-weight: bold">@@ -1662,11 +2425,9 @@ static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)</span>
 
         if (g_ftdm_sngss7_data.cfg.nsap[i].id == 0) {
                 g_ftdm_sngss7_data.cfg.nsap[i].id = i;
<span style="color: #A00000">-                 mtp3_route-&gt;nwId = i;</span>
                 SS7_DEBUG(&quot;found new mtp3_isup interface, id is = %d\n&quot;, g_ftdm_sngss7_data.cfg.nsap[i].id);
         } else {
                 g_ftdm_sngss7_data.cfg.nsap[i].id = i;
<span style="color: #A00000">-                 mtp3_route-&gt;nwId = i;</span>
                 SS7_DEBUG(&quot;found existing mtp3_isup interface, id is = %d\n&quot;, g_ftdm_sngss7_data.cfg.nsap[i].id);
         }
         
<span style="color: #800080; font-weight: bold">@@ -1683,26 +2444,17 @@ static int ftmod_ss7_fill_in_nsap(sng_route_t *mtp3_route)</span>
 /******************************************************************************/
 static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)
 {
<span style="color: #A00000">-        int i;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        /* go through all the existing interfaces and see if we find a match */</span>
<span style="color: #A00000">-        i = 1;</span>
<span style="color: #A00000">-        while (g_ftdm_sngss7_data.cfg.isupIntf[i].id != 0) {</span>
<span style="color: #A00000">-                if (!strcasecmp(g_ftdm_sngss7_data.cfg.isupIntf[i].name, sng_isup-&gt;name)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* we have a match so break out of this loop */</span>
<span style="color: #A00000">-                        break;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                /* move on to the next one */</span>
<span style="color: #A00000">-                i++;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        int i = sng_isup-&gt;id;</span>
 
<span style="color: #00A000">+        /* check if this id value has been used already */</span>
         if (g_ftdm_sngss7_data.cfg.isupIntf[i].id == 0) {
<span style="color: #A00000">-                sng_isup-&gt;id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found new isup interface, id is = %d\n&quot;, sng_isup-&gt;id);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found new ISUP Interface: id=%d, name=%s\n&quot;, sng_isup-&gt;id, sng_isup-&gt;name);</span>
<span style="color: #00A000">+                sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_ISUP);</span>
         } else {
<span style="color: #A00000">-                sng_isup-&gt;id = i;</span>
<span style="color: #A00000">-                SS7_DEBUG(&quot;found existing isup interface, id is = %d\n&quot;, sng_isup-&gt;id);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;Found an existing ISUP Interface: id=%d, name=%s (old name=%s)\n&quot;, </span>
<span style="color: #00A000">+                                        sng_isup-&gt;id, </span>
<span style="color: #00A000">+                                        sng_isup-&gt;name,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.isupIntf[i].name);</span>
         }
 
         strncpy((char *)g_ftdm_sngss7_data.cfg.isupIntf[i].name, (char *)sng_isup-&gt;name, MAX_NAME_LEN-1);
<span style="color: #800080; font-weight: bold">@@ -1715,9 +2467,6 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)</span>
         g_ftdm_sngss7_data.cfg.isupIntf[i].switchType        = sng_isup-&gt;switchType;
         g_ftdm_sngss7_data.cfg.isupIntf[i].ssf                        = sng_isup-&gt;ssf;
         g_ftdm_sngss7_data.cfg.isupIntf[i].isap                        = sng_isup-&gt;isap;
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.isupIntf[i].cld_nadi                = sng_isup-&gt;cld_nadi;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.isupIntf[i].clg_nadi                = sng_isup-&gt;clg_nadi;</span>
<span style="color: #A00000">-        g_ftdm_sngss7_data.cfg.isupIntf[i].min_digits        = sng_isup-&gt;min_digits;</span>
         g_ftdm_sngss7_data.cfg.isupIntf[i].options                = sng_isup-&gt;options;
         if (sng_isup-&gt;t4 != 0) {
                 g_ftdm_sngss7_data.cfg.isupIntf[i].t4                = sng_isup-&gt;t4;
<span style="color: #800080; font-weight: bold">@@ -1799,11 +2548,6 @@ static int ftmod_ss7_fill_in_isup_interface(sng_isup_inf_t *sng_isup)</span>
         } else {
                 g_ftdm_sngss7_data.cfg.isupIntf[i].t32                = 30;
         }
<span style="color: #A00000">-        if (sng_isup-&gt;t35 != 0) {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.isupIntf[i].t35                = sng_isup-&gt;t35;</span>
<span style="color: #A00000">-        } else {</span>
<span style="color: #A00000">-                g_ftdm_sngss7_data.cfg.isupIntf[i].t35                = 170;</span>
<span style="color: #A00000">-        }</span>
         if (sng_isup-&gt;t37 != 0) {
                 g_ftdm_sngss7_data.cfg.isupIntf[i].t37                = sng_isup-&gt;t37;
         } else {
<span style="color: #800080; font-weight: bold">@@ -1857,10 +2601,10 @@ static int ftmod_ss7_fill_in_isap(sng_isap_t *sng_isap)</span>
 
         if (g_ftdm_sngss7_data.cfg.isap[i].id == 0) {
                 sng_isap-&gt;id = i;
<span style="color: #A00000">-                SS7_DEBUG(&quot;found new isup to cc interface, id is = %d\n&quot;, g_ftdm_sngss7_data.cfg.isap[i].id);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;found new isup to cc interface, id is = %d\n&quot;, sng_isap-&gt;id);</span>
         } else {
                 sng_isap-&gt;id = i;
<span style="color: #A00000">-                SS7_DEBUG(&quot;found existing isup to cc interface, id is = %d\n&quot;, g_ftdm_sngss7_data.cfg.isap[i].id);</span>
<span style="color: #00A000">+                SS7_DEBUG(&quot;found existing isup to cc interface, id is = %d\n&quot;, sng_isap-&gt;id);</span>
         }
 
         g_ftdm_sngss7_data.cfg.isap[i].id                         = sng_isap-&gt;id;
<span style="color: #800080; font-weight: bold">@@ -2013,226 +2757,213 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i</span>
 }
 
 /******************************************************************************/
<span style="color: #A00000">-static int ftmod_ss7_fill_in_circuits(sng_isupCkt_t *isupCkt)</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_ccSpan(sng_ccSpan_t *ccSpan)</span>
 {
<span style="color: #A00000">-        sngss7_chan_data_t        *ss7_info = NULL;</span>
<span style="color: #A00000">-        ftdm_channel_t                *ftdmchan = NULL;</span>
         sng_timeslot_t                timeslot;
<span style="color: #A00000">-        int                                        count;</span>
<span style="color: #A00000">-        int                                        i;</span>
<span style="color: #00A000">+        sngss7_chan_data_t        *ss7_info = NULL;</span>
         int                                        x;
<span style="color: #00A000">+        int                                        count = 1;</span>
 
<span style="color: #A00000">-        count = 1;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        while (isupCkt-&gt;ch_map[0] != &#39;\0&#39;) {</span>
<span style="color: #00A000">+        while (ccSpan-&gt;ch_map[0] != &#39;\0&#39;) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
 
<span style="color: #A00000">-                 /* pull out the next timeslot */</span>
<span style="color: #A00000">-                if (ftmod_ss7_next_timeslot(isupCkt-&gt;ch_map, &amp;timeslot)) {</span>
<span style="color: #00A000">+                /* pull out the next timeslot */</span>
<span style="color: #00A000">+                if (ftmod_ss7_next_timeslot(ccSpan-&gt;ch_map, &amp;timeslot)) {</span>
                         SS7_ERROR(&quot;Failed to parse the channel map!\n&quot;);
                         return FTDM_FAIL;
                 }
 
<span style="color: #A00000">-                if ((timeslot.siglink) || (timeslot.gap)) {</span>
<span style="color: #A00000">-                        /* try to find the channel in the circuits structure*/</span>
<span style="color: #A00000">-                        x = 1;</span>
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #A00000">-                                if ((g_ftdm_sngss7_data.cfg.isupCkt[x].chan == count) &amp;&amp;</span>
<span style="color: #A00000">-                                        (g_ftdm_sngss7_data.cfg.isupCkt[x].span == isupCkt-&gt;span-&gt;channels[1]-&gt;physical_span_id)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        SS7_DEVEL_DEBUG(&quot;Circuit for span=%d, chan=%d is already exists...id=%d\n&quot;,</span>
<span style="color: #A00000">-                                                                isupCkt-&gt;span-&gt;channels[1]-&gt;physical_span_id,</span>
<span style="color: #A00000">-                                                                count,</span>
<span style="color: #A00000">-                                                                x);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        /* we have a match so this circuit already exists in the structure */</span>
<span style="color: #A00000">-                                        break;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                /* move to the next circuit */</span>
<span style="color: #A00000">-                                x++;</span>
<span style="color: #A00000">-                        } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* check why we exited the while loop */</span>
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) {</span>
<span style="color: #A00000">-                                SS7_DEVEL_DEBUG(&quot;Circuit for span=%d, chan=%d is new...id=%d\n&quot;,</span>
<span style="color: #A00000">-                                isupCkt-&gt;span-&gt;channels[1]-&gt;physical_span_id,</span>
<span style="color: #A00000">-                                count,</span>
<span style="color: #A00000">-                                x);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* prepare the global info sturcture */</span>
<span style="color: #A00000">-                                ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));</span>
<span style="color: #A00000">-                                ss7_info-&gt;ftdmchan = NULL;</span>
<span style="color: #A00000">-                                ss7_info-&gt;circuit = &amp;g_ftdm_sngss7_data.cfg.isupCkt[x];</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* circuit is new so fill in the needed information */</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].id                          = x;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].span                        = isupCkt-&gt;span-&gt;channels[1]-&gt;physical_span_id;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].chan                        = count;</span>
<span style="color: #A00000">-                                if (timeslot.siglink) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].type                = SIG;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].type                = HOLE;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                if (timeslot.channel) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].cic                = isupCkt-&gt;cicbase;</span>
<span style="color: #A00000">-                                        isupCkt-&gt;cicbase++;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].cic                = 0;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].infId                           = isupCkt-&gt;isupInf;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl           = isupCkt-&gt;typeCntrl;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].ssf                        = g_ftdm_sngss7_data.cfg.isupIntf[isupCkt-&gt;isupInf].ssf;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].obj                        = ss7_info;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        } /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* increment the span channel count */</span>
<span style="color: #A00000">-                        count++;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                } else { /* if ((timeslot.siglink) || (timeslot.gap)) */</span>
<span style="color: #A00000">-                        /* find the ftdm the channel structure for this channel*/</span>
<span style="color: #A00000">-                        i = 1;</span>
<span style="color: #A00000">-                        while (isupCkt-&gt;span-&gt;channels[i] != NULL) {</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;span-&gt;channels[i]-&gt;physical_chan_id == timeslot.channel) {</span>
<span style="color: #A00000">-                                        break;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                i++;</span>
<span style="color: #A00000">-                        } /* while (span-&gt;channels[i] != NULL) */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        if (isupCkt-&gt;span-&gt;channels[i] == NULL) {</span>
<span style="color: #A00000">-                                /* we weren&#39;t able to find the channel in the ftdm channels */</span>
<span style="color: #A00000">-                                SS7_ERROR(&quot;Unable to find the requested channel %d in the FreeTDM channels!\n&quot;, timeslot.channel);</span>
<span style="color: #A00000">-                                return FTDM_FAIL;</span>
<span style="color: #A00000">-                        } else {</span>
<span style="color: #A00000">-                                ftdmchan = isupCkt-&gt;span-&gt;channels[i];</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #00A000">+                /* find the spot in master array for this circuit */</span>
<span style="color: #00A000">+                x = (ccSpan-&gt;procId * 1000) + count;</span>
 
<span style="color: #A00000">-                        /* try to find a match for the physical span and chan */</span>
<span style="color: #A00000">-                        x = 1;</span>
<span style="color: #A00000">-                        while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #A00000">-                                if ((g_ftdm_sngss7_data.cfg.isupCkt[x].chan == ftdmchan-&gt;physical_chan_id) &amp;&amp; </span>
<span style="color: #A00000">-                                        (g_ftdm_sngss7_data.cfg.isupCkt[x].span == ftdmchan-&gt;physical_span_id)) {</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                        /* we have a match so this circuit already exists in the structure */</span>
<span style="color: #A00000">-                                        break;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                /* move to the next circuit */</span>
<span style="color: #A00000">-                                x++;</span>
<span style="color: #A00000">-                        } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* check why we exited the while loop */</span>
<span style="color: #A00000">-                        if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) {</span>
<span style="color: #A00000">-                                SS7_DEVEL_DEBUG(&quot;Circuit for span=%d, chan=%d is new...id=%d\n&quot;,</span>
<span style="color: #A00000">-                                ftdmchan-&gt;physical_span_id,</span>
<span style="color: #A00000">-                                ftdmchan-&gt;physical_chan_id,</span>
<span style="color: #A00000">-                                x);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* prepare the global info sturcture */</span>
<span style="color: #A00000">-                                ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));</span>
<span style="color: #A00000">-                                ss7_info-&gt;ftdmchan = ftdmchan;</span>
<span style="color: #A00000">-                                ss7_info-&gt;circuit = &amp;g_ftdm_sngss7_data.cfg.isupCkt[x];</span>
<span style="color: #A00000">-                                ftdmchan-&gt;call_data = ss7_info;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* prepare the timer structures */</span>
<span style="color: #A00000">-                                ss7_info-&gt;t35.sched                        = ((sngss7_span_data_t *)isupCkt-&gt;span-&gt;signal_data)-&gt;sched;</span>
<span style="color: #A00000">-                                ss7_info-&gt;t35.counter                = 1;</span>
<span style="color: #A00000">-                                ss7_info-&gt;t35.beat                        = g_ftdm_sngss7_data.cfg.isupIntf[isupCkt-&gt;isupInf].t35*100; /* beat is in ms, t35 is in 100ms */</span>
<span style="color: #A00000">-                                ss7_info-&gt;t35.callback                = handle_isup_t35;</span>
<span style="color: #A00000">-                                ss7_info-&gt;t35.sngss7_info        = ss7_info;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* circuit is new so fill in the needed information */</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].id                = x;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].span                = ftdmchan-&gt;physical_span_id;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].chan                = ftdmchan-&gt;physical_chan_id;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].type                = VOICE;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].cic                = isupCkt-&gt;cicbase;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].infId                = isupCkt-&gt;isupInf;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl        = isupCkt-&gt;typeCntrl;</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;t3 == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t3        = 1200;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t3        = isupCkt-&gt;t3;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;t12 == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t12        = 300;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t12        = isupCkt-&gt;t12;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;t13 == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t13        = 3000;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t13        = isupCkt-&gt;t13;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;t14 == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t14        = 300;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t14        = isupCkt-&gt;t14;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;t15 == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t15        = 3000;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t15        = isupCkt-&gt;t15;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;t16 == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t16        = 300;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t16        = isupCkt-&gt;t16;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;t17 == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t17        = 3000;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].t17        = isupCkt-&gt;t17;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if (isupCkt-&gt;tval == 0) {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].tval        = 10;</span>
<span style="color: #A00000">-                                } else {</span>
<span style="color: #A00000">-                                        g_ftdm_sngss7_data.cfg.isupCkt[x].tval        = isupCkt-&gt;tval;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].obj                = ss7_info;</span>
<span style="color: #A00000">-                                g_ftdm_sngss7_data.cfg.isupCkt[x].ssf                = g_ftdm_sngss7_data.cfg.isupIntf[isupCkt-&gt;isupInf].ssf;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* increment the cicbase */</span>
<span style="color: #A00000">-                                isupCkt-&gt;cicbase++;</span>
<span style="color: #A00000">-                        } else { /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) */</span>
<span style="color: #A00000">-                                SS7_DEBUG(&quot;Circuit for span=%d, chan=%d is new...id=%d\n&quot;,</span>
<span style="color: #A00000">-                                                                        ftdmchan-&gt;physical_span_id,</span>
<span style="color: #A00000">-                                                                        ftdmchan-&gt;physical_chan_id,</span>
<span style="color: #A00000">-                                                                        x);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* for now make sure ss7_info is set to null */</span>
<span style="color: #A00000">-                                ss7_info = NULL;</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                                /* KONRAD FIX ME -&gt; confirm that it is the same circuit */</span>
<span style="color: #A00000">-                        }  /* if (g_ftdm_sngss7_data.cfg.isupCkt[x].id == 0) */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                        /* increment the span channel count */</span>
<span style="color: #A00000">-                        count++;</span>
<span style="color: #A00000">-                } /* if ((timeslot.siglink) || (timeslot.gap)) */</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                if (ss7_info == NULL) {</span>
<span style="color: #A00000">-                        SS7_ERROR(&quot;KONRAD -&gt; circuit was not configured !\n&quot;);</span>
<span style="color: #A00000">-                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                /* check if this circuit has already been filled in */</span>
<span style="color: #00A000">+                if (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #00A000">+                        SS7_DEVEL_DEBUG(&quot;Filling in circuit that already exists...%d\n&quot;, x);</span>
                 }
 
<span style="color: #A00000">-                if (ss7_info-&gt;ftdmchan == NULL) {</span>
<span style="color: #A00000">-                        SS7_INFO(&quot;Added span = %d, chan = %d, cic = %d, FTDM chan = %d, ISUP cirId = %d\n&quot;,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].span,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].chan,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].cic,</span>
<span style="color: #A00000">-                                                0,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].id);</span>
<span style="color: #00A000">+                /* prepare the global info sturcture */</span>
<span style="color: #00A000">+                ss7_info = ftdm_calloc(1, sizeof(sngss7_chan_data_t));</span>
<span style="color: #00A000">+                ss7_info-&gt;ftdmchan = NULL;</span>
<span style="color: #00A000">+                ss7_info-&gt;circuit = &amp;g_ftdm_sngss7_data.cfg.isupCkt[x];</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].obj                        = ss7_info;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* fill in the rest of the global structure */</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].procId                  = ccSpan-&gt;procId;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].id                          = x;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId                = ccSpan-&gt;id;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].span                        = 0;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].chan                        = count;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (timeslot.siglink) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].type                = SIG;</span>
<span style="color: #00A000">+                } else if (timeslot.gap) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].type                = HOLE;</span>
                 } else {
<span style="color: #A00000">-                        SS7_INFO(&quot;Added span = %d, chan = %d, cic = %d, FTDM chan = %d, ISUP cirId = %d\n&quot;,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].span,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].chan,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].cic,</span>
<span style="color: #A00000">-                                                ss7_info-&gt;ftdmchan-&gt;chan_id,</span>
<span style="color: #A00000">-                                                g_ftdm_sngss7_data.cfg.isupCkt[x].id);</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].type                = VOICE;</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                        /* throw the flag to indicate that we need to start call control */</span>
<span style="color: #00A000">+                        sngss7_set_flag(&amp;g_ftdm_sngss7_data.cfg, SNGSS7_CC);</span>
                 }
 
<span style="color: #A00000">-        } /* while (ch_map[0] != &#39;\0&#39;) */</span>
<span style="color: #00A000">+                if (timeslot.channel) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].cic                = ccSpan-&gt;cicbase;</span>
<span style="color: #00A000">+                        ccSpan-&gt;cicbase++;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].cic                = 0;</span>
<span style="color: #00A000">+                }</span>
 
<span style="color: #A00000">-        return 0;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].infId                           = ccSpan-&gt;isupInf;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].typeCntrl           = ccSpan-&gt;typeCntrl;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].ssf                        = ccSpan-&gt;ssf;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].cld_nadi                = ccSpan-&gt;cld_nadi;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].clg_nadi                = ccSpan-&gt;clg_nadi;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].options                = ccSpan-&gt;options;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].switchType        = ccSpan-&gt;switchType;</span>
<span style="color: #00A000">+                g_ftdm_sngss7_data.cfg.isupCkt[x].min_digits        = ccSpan-&gt;min_digits;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t3 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t3                        = 1200;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t3                        = ccSpan-&gt;t3;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t12 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t12                = 300;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t12                = ccSpan-&gt;t12;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t13 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t13                = 3000;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t13                = ccSpan-&gt;t13;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t14 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t14                = 300;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t14                = ccSpan-&gt;t14;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t15 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t15                = 3000;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t15                = ccSpan-&gt;t15;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t16 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t16                = 300;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t16                = ccSpan-&gt;t16;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t17 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t17                = 3000;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t17                = ccSpan-&gt;t17;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;t35 == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t17                = 170;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].t17                = ccSpan-&gt;t35;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (ccSpan-&gt;tval == 0) {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].tval                = 10;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        g_ftdm_sngss7_data.cfg.isupCkt[x].tval                = ccSpan-&gt;tval;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                SS7_INFO(&quot;Added procId=%d, spanId = %d, chan = %d, cic = %d, ISUP cirId = %d\n&quot;,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.isupCkt[x].procId,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.isupCkt[x].ccSpanId,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.isupCkt[x].chan,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.isupCkt[x].cic,</span>
<span style="color: #00A000">+                                        g_ftdm_sngss7_data.cfg.isupCkt[x].id);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* increment the span channel count */</span>
<span style="color: #00A000">+                count++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* while (ccSpan-&gt;ch_map[0] != &#39;\0&#39;) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/******************************************************************************/</span>
<span style="color: #00A000">+static int ftmod_ss7_fill_in_circuits(sng_span_t *sngSpan)</span>
<span style="color: #00A000">+{</span>
<span style="color: #00A000">+        ftdm_channel_t                *ftdmchan = NULL;</span>
<span style="color: #00A000">+        ftdm_span_t                        *ftdmspan = sngSpan-&gt;span;</span>
<span style="color: #00A000">+        sng_isup_ckt_t                *isupCkt = NULL;</span>
<span style="color: #00A000">+        sngss7_chan_data_t        *ss7_info = NULL;</span>
<span style="color: #00A000">+        int                                        flag;</span>
<span style="color: #00A000">+        int                                        i;</span>
<span style="color: #00A000">+        int                                        x;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* go through all the channels on ftdm span */</span>
<span style="color: #00A000">+        for (i = 1; i &lt; (ftdmspan-&gt;chan_count+1); i++) {</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+                </span>
<span style="color: #00A000">+                /* extract the ftdmchan pointer */</span>
<span style="color: #00A000">+                ftdmchan = ftdmspan-&gt;channels[i];</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* find the equivalent channel in the global structure */</span>
<span style="color: #00A000">+                x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;</span>
<span style="color: #00A000">+                flag = 0;</span>
<span style="color: #00A000">+                while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                        /* pull out the circuit to make it easier to work with */</span>
<span style="color: #00A000">+                        isupCkt = &amp;g_ftdm_sngss7_data.cfg.isupCkt[x];</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* if the ccSpanId&#39;s match fill in the span value...this is for sigs</span>
<span style="color: #00A000">+                         * because they will never have a channel that matches since they </span>
<span style="color: #00A000">+                         * have a ftdmchan at this time */</span>
<span style="color: #00A000">+                        if (sngSpan-&gt;ccSpanId == isupCkt-&gt;ccSpanId) {</span>
<span style="color: #00A000">+                                isupCkt-&gt;span = ftdmchan-&gt;physical_span_id;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* check if the ccSpanId matches and the physical channel # match */</span>
<span style="color: #00A000">+                        if ((sngSpan-&gt;ccSpanId == isupCkt-&gt;ccSpanId) &amp;&amp;</span>
<span style="color: #00A000">+                                (ftdmchan-&gt;physical_chan_id == isupCkt-&gt;chan)) {</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                /* we&#39;ve found the channel in the ckt structure...raise the flag */</span>
<span style="color: #00A000">+                                flag = 1;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                                /* now get out of the loop */</span>
<span style="color: #00A000">+                                break;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* move to the next ckt */</span>
<span style="color: #00A000">+                        x++;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        /* check if we are outside of the range of possible indexes */</span>
<span style="color: #00A000">+                        if (x == ((g_ftdm_sngss7_data.cfg.procId + 1) * 1000)) {</span>
<span style="color: #00A000">+                                break;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                /**********************************************************************/</span>
<span style="color: #00A000">+                } /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* check we found the ckt or not */</span>
<span style="color: #00A000">+                if (!flag) {</span>
<span style="color: #00A000">+                        SS7_ERROR_CHAN(ftdmchan, &quot;Failed to find this channel in the global ckts!%s\n&quot;,&quot;&quot;);</span>
<span style="color: #00A000">+                        return FTDM_FAIL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* fill in the rest of the global sngss7_chan_data_t structure */</span>
<span style="color: #00A000">+                ss7_info = (sngss7_chan_data_t *)isupCkt-&gt;obj;</span>
<span style="color: #00A000">+                ss7_info-&gt;ftdmchan = ftdmchan;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* attach the sngss7_chan_data_t to the freetdm channel structure */</span>
<span style="color: #00A000">+                ftdmchan-&gt;call_data = ss7_info;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                /* prepare the timer structures */</span>
<span style="color: #00A000">+                ss7_info-&gt;t35.sched                        = ((sngss7_span_data_t *)(ftdmspan-&gt;signal_data))-&gt;sched;</span>
<span style="color: #00A000">+                ss7_info-&gt;t35.counter                = 1;</span>
<span style="color: #00A000">+                ss7_info-&gt;t35.beat                        = (isupCkt-&gt;t35) * 100; /* beat is in ms, t35 is in 100ms */</span>
<span style="color: #00A000">+                ss7_info-&gt;t35.callback                = handle_isup_t35;</span>
<span style="color: #00A000">+                ss7_info-&gt;t35.sngss7_info        = ss7_info;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /**************************************************************************/</span>
<span style="color: #00A000">+        } /* for (i == 1; i &lt; ftdmspan-&gt;chan_count; i++) */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        return FTDM_SUCCESS;</span>
 }
 
 /******************************************************************************/
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: David Yat Sin
comments: 
Merge branch &#39;master&#39; of git://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
Merge branch &#39;master&#39; of ssh://git.freeswitch.org/freeswitch
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: add WIN32_LEAN_AND_MEAN fix

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/cyginstall.sh b/libs/freetdm/cyginstall.sh</span>
old mode 100644
new mode 100755
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h</span>
<span style="color: #000080; font-weight: bold">index 7cf0934..ba16c7c 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/include/private/ftdm_core.h</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/include/private/ftdm_core.h</span>
<span style="color: #800080; font-weight: bold">@@ -94,7 +94,10 @@</span>
                            !strcasecmp(expr, &quot;active&quot;) ||        \
                            atoi(expr))) ? 1 : 0
 
<span style="color: #A00000">-</span>
<span style="color: #00A000">+#ifdef WIN32_LEAN_AND_MEAN</span>
<span style="color: #00A000">+#include &lt;winsock2.h&gt;</span>
<span style="color: #00A000">+#include &lt;mmsystem.h&gt;</span>
<span style="color: #00A000">+#endif</span>
 
 #include &lt;time.h&gt;
 #ifndef __WINDOWS__
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: ftmod_r2 - check for io dump file errors on open

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c</span>
<span style="color: #000080; font-weight: bold">index 0217a51..d86fb43 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c</span>
<span style="color: #800080; font-weight: bold">@@ -729,16 +729,24 @@ static void dump_mf(openr2_chan_t *r2chan)</span>
                 snprintf(dfile, sizeof(dfile), logname ? &quot;%s.s%dc%d.input.alaw&quot; : &quot;%s/s%dc%d.input.alaw&quot;, 
                                 logname ? logname : r2data-&gt;logdir, ftdmchan-&gt;span_id, ftdmchan-&gt;chan_id);
                 f = fopen(dfile, &quot;wb&quot;);
<span style="color: #A00000">-                ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, &quot;Dumping IO input in file %s\n&quot;, dfile);</span>
<span style="color: #A00000">-                ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, f);</span>
<span style="color: #A00000">-                fclose(f);</span>
<span style="color: #00A000">+                if (f) {</span>
<span style="color: #00A000">+                        ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, &quot;Dumping IO input in file %s\n&quot;, dfile);</span>
<span style="color: #00A000">+                        ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_INPUT, f);</span>
<span style="color: #00A000">+                        fclose(f);</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, &quot;Could not dump IO input in file %s, error: %s&quot;, dfile, strerror(errno));</span>
<span style="color: #00A000">+                }</span>
 
                 snprintf(dfile, sizeof(dfile), logname ? &quot;%s.s%dc%d.output.alaw&quot; : &quot;%s/s%dc%d.output.alaw&quot;, 
                                 logname ? logname : r2data-&gt;logdir, ftdmchan-&gt;span_id, ftdmchan-&gt;chan_id);
                 f = fopen(dfile, &quot;wb&quot;);
<span style="color: #A00000">-                ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, &quot;Dumping IO output in file %s\n&quot;, dfile);</span>
<span style="color: #A00000">-                ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_OUTPUT, f);</span>
<span style="color: #A00000">-                fclose(f);</span>
<span style="color: #00A000">+                if (f) {</span>
<span style="color: #00A000">+                        ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, &quot;Dumping IO output in file %s\n&quot;, dfile);</span>
<span style="color: #00A000">+                        ftdm_channel_command(ftdmchan, FTDM_COMMAND_DUMP_OUTPUT, f);</span>
<span style="color: #00A000">+                        fclose(f);</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        ftdm_log_chan(ftdmchan, FTDM_LOG_ERROR, &quot;Could not dump IO output in file %s, error: %s&quot;, dfile, strerror(errno));</span>
<span style="color: #00A000">+                }</span>
         }
 }
 
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: fix ftdm error mapping to unix-style errors

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/include/ftdm_declare.h b/libs/freetdm/src/include/ftdm_declare.h</span>
<span style="color: #000080; font-weight: bold">index 88a7693..b443f2d 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/include/ftdm_declare.h</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/include/ftdm_declare.h</span>
<span style="color: #800080; font-weight: bold">@@ -178,18 +178,20 @@ typedef int ftdm_socket_t;</span>
 /*! \brief FreeTDM APIs possible return codes */
 typedef enum {
         FTDM_SUCCESS, /*!&lt; Success */
<span style="color: #A00000">-        FTDM_FAIL, /*!&lt; Failure, generic error return code, use ftdm_channel_get_last_error or ftdm_span_get_last_error for details */</span>
<span style="color: #A00000">-        FTDM_MEMERR, /*!&lt; Memory error, most likely allocation failure */</span>
<span style="color: #00A000">+        FTDM_FAIL, /*!&lt; Failure, generic error return code when no more specific return code can be used */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        FTDM_MEMERR, /*!&lt; Allocation failure */</span>
<span style="color: #00A000">+        FTDM_ENOMEM = FTDM_MEMERR,</span>
<span style="color: #00A000">+</span>
         FTDM_TIMEOUT, /*!&lt; Operation timed out (ie: polling on a device)*/
<span style="color: #00A000">+        FTDM_ETIMEDOUT = FTDM_TIMEOUT,</span>
<span style="color: #00A000">+</span>
         FTDM_NOTIMPL, /*!&lt; Operation not implemented */
<span style="color: #00A000">+        FTDM_ENOSYS = FTDM_NOTIMPL, /*!&lt; The function is not implemented */</span>
<span style="color: #00A000">+</span>
         FTDM_BREAK, /*!&lt; Request the caller to perform a break (context-dependant, ie: stop getting DNIS/ANI) */
 
         /*!&lt; Any new return codes should try to mimc unix style error codes, no need to reinvent */
<span style="color: #A00000">-        /* Remapping some of the codes that were before */</span>
<span style="color: #A00000">-        FTDM_ENOMEM = FTDM_MEMERR, /*!&lt; Memory error */</span>
<span style="color: #A00000">-        FTDM_ETIMEDOUT = FTDM_TIMEOUT, /*!&lt; Operation timedout */</span>
<span style="color: #A00000">-        FTDM_ENOSYS = FTDM_NOTIMPL, /*!&lt; The function is not implemented */</span>
<span style="color: #A00000">-</span>
         FTDM_EINVAL, /*!&lt; Invalid argument */
         FTDM_ECANCELED, /*!&lt; Operation cancelled */
         FTDM_EBUSY, /*!&lt; Device busy */
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: use the problem freetdm define to set wp alarms

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c</span>
<span style="color: #000080; font-weight: bold">index 3b384cd..b3d1fe6 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c</span>
<span style="color: #800080; font-weight: bold">@@ -1242,7 +1242,7 @@ static FIO_GET_ALARMS_FUNCTION(wanpipe_get_alarms)</span>
                         /* there is a bug in wanpipe where alarms were not properly set when they should be
                          * on at application startup, until that is fixed we check the link status here too */
                         ftdm_channel_command(ftdmchan, FTDM_COMMAND_GET_LINK_STATUS, &amp;sangoma_status);
<span style="color: #A00000">-                        ftdmchan-&gt;alarm_flags = sangoma_status == FTDM_HW_LINK_DISCONNECTED ? 1 : 0;</span>
<span style="color: #00A000">+                        ftdmchan-&gt;alarm_flags = sangoma_status == FTDM_HW_LINK_DISCONNECTED ? FTDM_ALARM_RED : FTDM_ALARM_NONE;</span>
                         ftdm_log_chan(ftdmchan, FTDM_LOG_DEBUG, &quot;Link status is %d\n&quot;, sangoma_status);
                 }
         }
<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h</span>
<span style="color: #000080; font-weight: bold">index aed4054..588dc31 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/include/freetdm.h</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/include/freetdm.h</span>
<span style="color: #800080; font-weight: bold">@@ -838,11 +838,11 @@ typedef enum {</span>
 /*! \brief FreeTDM supported hardware alarms. */
 typedef enum {
         FTDM_ALARM_NONE    = 0,
<span style="color: #A00000">-        FTDM_ALARM_RED     = (1 &lt;&lt; 1),</span>
<span style="color: #A00000">-        FTDM_ALARM_YELLOW  = (1 &lt;&lt; 2),</span>
<span style="color: #A00000">-        FTDM_ALARM_RAI     = (1 &lt;&lt; 3),</span>
<span style="color: #A00000">-        FTDM_ALARM_BLUE    = (1 &lt;&lt; 4),</span>
<span style="color: #A00000">-        FTDM_ALARM_AIS     = (1 &lt;&lt; 5),</span>
<span style="color: #00A000">+        FTDM_ALARM_RED     = (1 &lt;&lt; 0),</span>
<span style="color: #00A000">+        FTDM_ALARM_YELLOW  = (1 &lt;&lt; 1),</span>
<span style="color: #00A000">+        FTDM_ALARM_RAI     = (1 &lt;&lt; 2),</span>
<span style="color: #00A000">+        FTDM_ALARM_BLUE    = (1 &lt;&lt; 3),</span>
<span style="color: #00A000">+        FTDM_ALARM_AIS     = (1 &lt;&lt; 4),</span>
         FTDM_ALARM_GENERAL = (1 &lt;&lt; 30)
 } ftdm_alarm_flag_t;
 
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
enter

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_lua/mod_lua_extra.c b/src/mod/languages/mod_lua/mod_lua_extra.c</span>
<span style="color: #000080; font-weight: bold">index 38776f9..821cc60 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_lua/mod_lua_extra.c</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_lua/mod_lua_extra.c</span>
<span style="color: #800080; font-weight: bold">@@ -1,6 +1,8 @@</span>
 using namespace LUA;
 
<span style="color: #A00000">-SWITCH_BEGIN_EXTERN_C void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me)</span>
<span style="color: #00A000">+SWITCH_BEGIN_EXTERN_C</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me)</span>
 {
         Event *result = new Event(event);
         SWIG_NewPointerObj(L, result, SWIGTYPE_p_Event, destroy_me);
</pre></div>
<div class="highlight"><pre>committer: Leon de Rooij
comments: 
enter

<span style="color: #000080; font-weight: bold">diff --git a/src/mod/languages/mod_lua/mod_lua_extra.h b/src/mod/languages/mod_lua/mod_lua_extra.h</span>
<span style="color: #000080; font-weight: bold">index b96adc3..3fca994 100644</span>
<span style="color: #A00000">--- a/src/mod/languages/mod_lua/mod_lua_extra.h</span>
<span style="color: #00A000">+++ b/src/mod/languages/mod_lua/mod_lua_extra.h</span>
<span style="color: #800080; font-weight: bold">@@ -1,6 +1,8 @@</span>
 #ifndef MOD_LUA_EXTRA
 #define MOD_LUA_EXTRA
<span style="color: #A00000">-SWITCH_BEGIN_EXTERN_C void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me);</span>
<span style="color: #00A000">+SWITCH_BEGIN_EXTERN_C</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me);</span>
 void mod_lua_conjure_stream(lua_State * L, switch_stream_handle_t *stream, const char *name, int destroy_me);
 void mod_lua_conjure_session(lua_State * L, switch_core_session_t *session, const char *name, int destroy_me);
 
</pre></div>
<div class="highlight"><pre>committer: Moises Silva
comments: 
freetdm: do not enable ec on SIGEVENT_START

<span style="color: #000080; font-weight: bold">diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #000080; font-weight: bold">index b5f9fab..529a30f 100644</span>
<span style="color: #A00000">--- a/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #00A000">+++ b/libs/freetdm/src/ftdm_io.c</span>
<span style="color: #800080; font-weight: bold">@@ -5533,7 +5533,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_send_signal(ftdm_span_t *span, ftdm_sigmsg_t</span>
                         }
                         ftdm_set_flag(sigmsg-&gt;channel, FTDM_CHANNEL_CALL_STARTED);
                         ftdm_call_set_call_id(sigmsg-&gt;channel, &amp;sigmsg-&gt;channel-&gt;caller_data);
<span style="color: #A00000">-                        ftdm_set_echocancel_call_begin(sigmsg-&gt;channel);</span>
                         if (sigmsg-&gt;channel-&gt;dtmfdbg.requested) {
                                 ftdm_channel_command(sigmsg-&gt;channel, FTDM_COMMAND_ENABLE_DEBUG_DTMF, NULL);
                         }
</pre></div>
========================================================================<pre>

Summary of changes:
 conf/autoload_configs/cdr_pg_csv.conf.xml          |   35 +-
 conf/autoload_configs/switch.conf.xml              |    2 +-
 libs/freetdm/Makefile.am                           |    3 +-
 libs/freetdm/configure.ac                          |    2 +-
 libs/freetdm/mod_freetdm/mod_freetdm.c             |   68 +-
 libs/freetdm/src/ftdm_io.c                         |   57 +-
 libs/freetdm/src/ftmod/ftmod_r2/ftmod_r2.c         |   20 +-
 .../ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c  |   13 +-
 .../ftmod_sangoma_isdn/ftmod_sangoma_isdn_cfg.c    |    2 +
 .../ftmod_sangoma_isdn_stack_cfg.c                 |   38 +-
 .../ftmod_sangoma_isdn_stack_hndl.c                |   17 +
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cfg.c      |  562 +++--
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cli.c      |  448 +++-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c    |  374 +++-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_handle.c   |   94 +-
 .../ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_in.c |   82 +-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_logger.c   |  125 +-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.c     |  286 ++-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h     |  335 ++-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c      |   17 +-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c    |  318 +++
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_sta.c      |  106 +-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_support.c  |  267 ++-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_timers.c   |    2 +-
 .../ftmod_sangoma_ss7/ftmod_sangoma_ss7_xml.c      | 2878 +++++++++++++-------
 .../src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c        |    2 +-
 libs/freetdm/src/include/freetdm.h                 |   10 +-
 libs/freetdm/src/include/ftdm_declare.h            |   16 +-
 libs/freetdm/src/include/private/ftdm_core.h       |    5 +-
 src/mod/applications/mod_commands/mod_commands.c   |   18 +-
 .../applications/mod_conference/mod_conference.c   |   45 +-
 src/mod/applications/mod_dptools/mod_dptools.c     |    2 +
 src/mod/applications/mod_voicemail/mod_voicemail.c |   22 +-
 src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c          |    2 +-
 src/mod/endpoints/mod_loopback/mod_loopback.c      |    5 +
 src/mod/endpoints/mod_sofia/mod_sofia.c            |    8 +-
 .../event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c |  396 ++--
 src/mod/languages/mod_lua/mod_lua_extra.c          |    4 +-
 src/mod/languages/mod_lua/mod_lua_extra.h          |    4 +-
 src/mod/languages/mod_lua/mod_lua_wrap.cpp         |   50 +
 .../languages/mod_spidermonkey/mod_spidermonkey.c  |   10 +
 src/switch_xml_config.c                            |    2 +-
 support-d/prereq.sh                                |    2 +-
 43 files changed, 4694 insertions(+), 2060 deletions(-)
 mode change 100644 => 100755 libs/freetdm/cyginstall.sh
 create mode 100644 libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_relay.c
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH Source</p>