]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
wanpipe update
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 7 Feb 2007 23:43:04 +0000 (23:43 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 7 Feb 2007 23:43:04 +0000 (23:43 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4156 d0543943-73ff-0310-b7d9-9358b9ac24b2

conf/wanpipe.conf.xml
src/mod/endpoints/mod_wanpipe/mod_wanpipe.c

index d7dd17e308f08c7ebea80d8d853a60db29bcbf58..07c302f983b6ff9ce34551543057ce58961f1c62 100644 (file)
@@ -1,17 +1,17 @@
 <configuration name="wanpipe.conf" description="Sangoma Wanpipe Endpoint">
   <settings>
-    <param name="debug" value="1"/>
+    <param name="debug" value="0"/>
     <param name="dialplan" value="XML"/>
     <param name="mtu" value="320"/>
     <param name="dtmf-on" value="800"/>
     <param name="dtmf-off" value="100"/>
     <param name="supress-dtmf-tone" value="yes"/>
   </settings>
-  <span>
-    <param name="span" value="1"/>
+  <!-- may be any single digit or a range of digits separated by a '-' e.g "1-4" -->
+  <span id="1">
     <param name="node" value="cpe"/>
-    <!-- <param name="switch" value="ni2"/> -->
-    <param name="switch" value="dms100"/>
+    <param name="switch" value="ni2"/>
+    <!--<param name="switch" value="dms100"/>-->
     <!-- <param name="switch" value="lucent5e"/> -->
     <!-- <param name="switch" value="att4ess"/> -->
     <!-- <param name="switch" value="euroisdn"/> -->
index ff64b6ce546d095944037a898dcd4713b31c9a3f..261d4f59581822fc0ecb537d3b945d4117f07f58 100644 (file)
@@ -1414,7 +1414,7 @@ static void pri_thread_launch(struct sangoma_pri *spri)
 static switch_status_t config_wanpipe(int reload)
 {
        char *cf = "wanpipe.conf";
-       int current_span = 0;
+       int current_span = 0, min_span = 0, max_span = 0;
        switch_xml_t cfg, xml, settings, param, span;
 
        globals.mtu = DEFAULT_MTU;
@@ -1450,31 +1450,52 @@ static switch_status_t config_wanpipe(int reload)
 
        
        for (span = switch_xml_child(cfg, "span"); span; span = span->next) {
-               for (param = switch_xml_child(span, "param"); param; param = param->next) {
-                       char *var = (char *) switch_xml_attr_soft(param, "name");
-                       char *val = (char *) switch_xml_attr_soft(param, "value");
+               char *id = switch_xml_attr(span, "id");
+               int32_t i = 0;
 
-                       if (!strcmp(var, "span")) {
-                               current_span = atoi(val);
-                               if (current_span <= 0 || current_span > MAX_SPANS) {
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid SPAN!\n");
-                                       current_span = 0;
-                                       continue;
-                               }
-                               if (!SPANS[current_span]) {
-                                       if (!(SPANS[current_span] = switch_core_alloc(module_pool, sizeof(*SPANS[current_span])))) {
-                                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "MEMORY ERROR\n");
-                                               break;;
-                                       }
-                                       SPANS[current_span]->span = current_span;
-                               }
-                               
+               current_span = 0;
+               
+               if (id) {
+                       char *p;
+                       
+                       min_span = atoi(id);
+                       if ((p = strchr(id, '-'))) {
+                               p++;
+                               max_span = atoi(p);
                        } else {
-                               if (!current_span) {
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid option %s when no span defined.\n", var);
-                                       continue;
+                               max_span = min_span;
+                       }
+                       if (min_span < 1 || max_span < min_span) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Span Config! [%s]\n", id);
+                               continue;
+                       }
+               } else {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing SPAN ID!\n");
+                       continue;
+               }
+               
+               for (i = min_span; i <= max_span; i++) {
+                       current_span = i;
+                       
+                       if (current_span <= 0 || current_span > MAX_SPANS) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid SPAN %d!\n", current_span);
+                               current_span = 0;
+                               continue;
+                       }
+                       
+                       if (!SPANS[current_span]) {
+                               if (!(SPANS[current_span] = switch_core_alloc(module_pool, sizeof(*SPANS[current_span])))) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "MEMORY ERROR\n");
+                                       break;
                                }
-                               
+                               SPANS[current_span]->span = current_span;
+                       }
+                       
+
+                       for (param = switch_xml_child(span, "param"); param; param = param->next) {
+                               char *var = (char *) switch_xml_attr_soft(param, "name");
+                               char *val = (char *) switch_xml_attr_soft(param, "value");
+                       
                                if (!strcmp(var, "dchan")) {
                                        SPANS[current_span]->dchan = atoi(val);
                                } else if (!strcmp(var, "bchan")) {