]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use the new sysfs way of mISDN 1.2 to check if a port is NT or not.
authorNadi Sarrar <ns@beronet.com>
Tue, 3 Apr 2007 09:37:00 +0000 (09:37 +0000)
committerNadi Sarrar <ns@beronet.com>
Tue, 3 Apr 2007 09:37:00 +0000 (09:37 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@59788 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/misdn/chan_misdn_config.h
channels/misdn_config.c

index e21c59fdb0a680be5a0f54343ec448d9229c04ca..9305df500b584f5b42c92ad6f6f463a2c0d22f1f 100644 (file)
@@ -68,7 +68,9 @@ enum misdn_cfg_elements {
        
        /* general config items */
        MISDN_GEN_FIRST,
+#ifndef MISDN_1_2
        MISDN_GEN_MISDN_INIT,           /* char[] */
+#endif
        MISDN_GEN_DEBUG,               /* int */
        MISDN_GEN_TRACEFILE,           /* char[] */
        MISDN_GEN_BRIDGING,            /* int (bool) */
index cd6a7ffd7fdb45eeb4e2c8449bf3addae3a4ed35..2345bc235a844707cf33ef03f69ef0a2deb885bf 100644 (file)
@@ -128,7 +128,9 @@ static const struct misdn_cfg_spec port_spec[] = {
 
 static const struct misdn_cfg_spec gen_spec[] = {
        { "debug", MISDN_GEN_DEBUG, MISDN_CTYPE_INT, "0", NONE },
+#ifndef MISDN_1_2
        { "misdn_init", MISDN_GEN_MISDN_INIT, MISDN_CTYPE_STR, "/etc/misdn-init.conf", NONE },
+#endif
        { "tracefile", MISDN_GEN_TRACEFILE, MISDN_CTYPE_STR, "/var/log/asterisk/misdn.log", NONE },
        { "bridging", MISDN_GEN_BRIDGING, MISDN_CTYPE_BOOL, "yes", NONE },
        { "stop_tone_after_first_digit", MISDN_GEN_STOP_TONE, MISDN_CTYPE_BOOL, "yes", NONE },
@@ -670,6 +672,7 @@ static void _build_port_config (struct ast_variable *v, char *cat)
 
 void misdn_cfg_update_ptp (void)
 {
+#ifndef MISDN_1_2
        char misdn_init[BUFFERSIZE];
        char line[BUFFERSIZE];
        FILE *fp;
@@ -700,6 +703,26 @@ void misdn_cfg_update_ptp (void)
                        ast_log(LOG_WARNING,"Couldn't open %s: %s\n", misdn_init, strerror(errno));
                }
        }
+#else
+       int i;
+       int proto;
+       char filename[128];
+       FILE *fp;
+
+       for (i = 1; i <= max_ports; ++i) {
+               snprintf(filename, sizeof(filename), "/sys/class/mISDN-stacks/st-%08x/protocol", i << 8);
+               fp = fopen(filename, "r");
+               if (!fp) {
+                       ast_log(LOG_WARNING, "Could not open %s: %s\n", filename, strerror(errno));
+                       continue;
+               }
+               if (fscanf(fp, "0x%08x", &proto) != 1)
+                       ast_log(LOG_WARNING, "Could not parse contents of %s!\n", filename);
+               else
+                       ptp[i] = proto & 1<<4 ? 1 : 0;
+               fclose(fp);
+       }
+#endif
 }
 
 static void _fill_defaults (void)