first try on E-DSS-1 ISDN d-channel parsing
authorChristian Weiske <cweiske@cweiske.de>
Mon, 16 Jul 2012 20:58:34 +0000 (22:58 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 16 Jul 2012 20:58:34 +0000 (22:58 +0200)
docs/DerISDNDKanal.pdf [new file with mode: 0644]
dumps/intern22-zu-extern-kurz-abgenommen.bin [new file with mode: 0644]
src/callnotifier/EDSS1/Message.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parameter.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parser.php [new file with mode: 0644]
src/callnotifier/Logger/Echo.php
src/callnotifier/MessageHandler.php

diff --git a/docs/DerISDNDKanal.pdf b/docs/DerISDNDKanal.pdf
new file mode 100644 (file)
index 0000000..9c5e44a
Binary files /dev/null and b/docs/DerISDNDKanal.pdf differ
diff --git a/dumps/intern22-zu-extern-kurz-abgenommen.bin b/dumps/intern22-zu-extern-kurz-abgenommen.bin
new file mode 100644 (file)
index 0000000..08eab5d
--- /dev/null
@@ -0,0 +1,99 @@
+[DKANPROT-Debug 921167] T01: 00 97 01 C1 FF 0A
+[DKANPROT-Debug 031001] N01: 02 97 01 0F FF 0A
+[DKANPROT-Debug 033830] N01: 00 97 01 0F FF 0A
+[DKANPROT-Debug 034504] T01: 02 97 01 C1 FF 0A
+[DKANPROT-Debug 220955] T02: 00 A3 7F FF 0A
+[DKANPROT-Debug 221533] N02: 00 A3 73 FF 0A
+[DKANPROT-Debug 331049] T02: 00 A3 00 00 08 01 01 05 04 03 80 90 A3 6C 04 01 80 32 32 7D 02 91 81 FF 0A
+[DKANPROT-Debug 331761] N02: 00 A3 01 02 FF 0A
+[DKANPROT-Debug 441888] RXMSG KREVENT_SETUP Task 0x61 class L6MGR[0x0]
+[DKANPROT-Info 443924] KR_TXMSG_SETUP_ACK ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 444490] RXMSG KREVENT_ERSTAUFRUF Task 0x61 class KREIS[0x1]
+[DKANPROT-Debug 445021] RXMSG KREVENT_CDPN_WAHLZIFFER Task 0x61 class KREIS[0x1]
+[DKANPROT-Debug 445937] N02: 02 A3 00 02 08 01 81 0D 18 01 89 1E 02 81 88 FF 0A
+[DKANPROT-Debug 550986] T02: 02 A3 01 02 FF 0A
+[DKANPROT-Debug 661786] RXMSG KREVENT_KRTIM2 ohne task, class KREIS[0x1]
+[DKANPROT-Debug 770920] T02: 00 A3 02 02 08 01 01 7B 70 06 81 36 31 33 34 37 FF 0A
+[DKANPROT-Debug 772594] N02: 00 A3 01 04 FF 0A
+[DKANPROT-Debug 773864] RXMSG KREVENT_CDPN_WAHLZIFFER Task 0x61 class KREIS[0x1]
+[DKANPROT-Debug 774240] RXMSG KREVENT_ZIFFER Task 0x61 class KREIS[0x1]
+[DKANPROT-Debug 774886] RXMSG KREVENT_ERSTAUFRUF Task 0x61 class KREIS[0x1]
+[DKANPROT-Debug 775527] RXMSG KREVENT_ZIFFER Task 0x61 class KREIS[0x1]
+[DKANPROT-Debug 775935] RXMSG KREVENT_ZIFFER Task 0x61 class KREIS[0x1]
+[DKANPROT-Info 777714] KR_TXMSG_SETUP ueber task 0x62 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Debug 779202] RXMSG KREVENT_ERSTAUFRUF ohne task, class KREIS[0x1]
+[DKANPROT-Info 779652] KR_TXMSG_ZIF_INFO ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 780020] RXMSG KREVENT_ZIFFER Task 0x61 class KREIS[0x1]
+[DKANPROT-Info 780302] KR_TXMSG_ZIF_INFO ueber task 0x62 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Info 780842] KR_TXMSG_ZIF_INFO ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 781198] RXMSG KREVENT_ZIFFER Task 0x61 class KREIS[0x1]
+[DKANPROT-Info 781515] KR_TXMSG_ZIF_INFO ueber task 0x62 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Info 781958] KR_TXMSG_ZIF_INFO ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 782943] T01: 00 97 0E C0 08 01 25 05 04 03 90 90 A3 18 01 83 6C 07 01 80 34 30 38 36 32 FF 0A
+[DKANPROT-Debug 881235] N01: 00 97 01 10 FF 0A
+[DKANPROT-Debug 101077] N01: 02 97 C0 10 08 01 A5 0D 18 01 89 1E 02 82 88 FF 0A
+[DKANPROT-Debug 102737] T01: 02 97 01 C2 FF 0A
+[DKANPROT-Debug 104253] T01: 00 97 10 C2 08 01 25 7B 70 06 81 36 31 33 34 37 FF 0A
+[DKANPROT-Debug 210935] N01: 00 97 01 12 FF 0A
+[DKANPROT-Debug 431319] N01: 02 97 C2 12 08 01 A5 01 1C 12 91 A1 0F 02 02 28 B4 06 06 04 00 82 67 01 01 02 01 01 1E 02 82 88 1E 02 82 82 28 0D 43 43 4E 52 20 6D 6F 65 67 6C 69 63 68 FF 0A
+[DKANPROT-Debug 432042] T01: 02 97 01 C4 FF 0A
+[DKANPROT-Debug 433047] RXMSG KREVENT_GEBUEHREN Task 0x62 class KREIS[0x1]
+[DKANPROT-Info 433854] RXMSG KREVENT_ALERTING Slot 0x2 Port 0x0 Task 0x62 kreis 0x1 = class_inst, class_type=1
+[DKANPROT-Info 434545] KR_TXMSG_ALERT ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 436756] N02: 02 A3 02 04 08 01 81 01 1C 11 91 A1 0E 02 01 13 06 06 04 00 82 67 01 01 02 01 08 1E 02 81 88 28 0D 43 43 4E 52 20 6D 6F 65 67 6C 69 63 68 FF 0A
+[DKANPROT-Debug 540939] T02: 02 A3 01 04 FF 0A
+[DKANPROT-Debug 720980] RXMSG KREVENT_KRTIM2 ohne task, class KREIS[0x1]
+[DKANPROT-Debug 441207] N01: 02 FF FF 03 08 00 62 1C 12 91 A1 0F 02 02 28 B5 06 06 04 00 82 67 01 0A 02 01 01 70 0B A1 33 34 32 36 31 34 30 38 36 32 FF 0A
+[DKANPROT-Debug 441704] N01: 02 97 C4 12 08 01 A5 07 1E 02 82 82 29 05 0C 07 10 07 2E 4C 02 00 A3 FF 0A
+[DKANPROT-Debug 442240] T01: 00 97 01 C5 FF 0A
+[DKANPROT-Debug 442819] T01: 02 97 01 C6 FF 0A
+[DKANPROT-Debug 444386] RXMSG KREVENT_RUECKRUF Task 0x63 class L6MGR[0x0]
+[DKANPROT-Info 444822] KR_TXMSG_RELCOMP ueber task 0x63 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Info 445990] KR_TXMSG_RR ueber task 0x64 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 446675] RXMSG KREVENT_SYSTEMINFO Task 0x62 class KREIS[0x1]
+[DKANPROT-Debug 449333] N02: 02 FF FF 03 08 00 62 1C 11 91 A1 0E 02 01 14 06 06 04 00 82 67 01 0A 02 01 08 70 06 81 36 31 33 34 37 FF 0A
+[DKANPROT-Info 550976] RXMSG KREVENT_CONNECT Slot 0x2 Port 0x0 Task 0x62 kreis 0x1 = class_inst, class_type=1
+[DKANPROT-Info 552863] KR_TXMSG_CONNECT ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Info 554380] KR_TXMSG_DISPLAY ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Info 554944] KR_TXMSG_COPN_CHANGED ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Info 555363] KR_TXMSG_TAPI_STATE_FROM_L5 ueber task 0x62 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Debug 555918] RXMSG KREVENT_ERSTAUFRUF ohne task, class KREIS[0x1]
+[DKANPROT-Debug 556356] T02: 00 A3 01 05 FF 0A
+[DKANPROT-Debug 556713] N01: 00 97 01 13 FF 0A
+[DKANPROT-Debug 557355] T01: 00 97 12 C6 08 01 25 0F FF 0A
+[DKANPROT-Debug 557850] N02: 02 A3 01 05 FF 0A
+[DKANPROT-Debug 558937] N02: 00 A3 01 05 FF 0A
+[DKANPROT-Debug 661483] T02: 02 A3 01 05 FF 0A
+[DKANPROT-Debug 661839] N01: 00 97 01 14 FF 0A
+[DKANPROT-Debug 662689] N02: 02 A3 04 04 08 01 81 07 29 05 0C 07 10 07 2E 4C 07 00 80 36 31 33 34 37 FF 0A
+[DKANPROT-Debug 771068] T02: 02 A3 01 06 FF 0A
+[DKANPROT-Debug 771860] N02: 02 A3 06 04 08 01 81 7B 28 05 36 31 33 34 37 FF 0A
+[DKANPROT-Debug 880981] T02: 02 A3 01 08 FF 0A
+[DKANPROT-Debug 561019] N01: 02 97 01 15 FF 0A
+[DKANPROT-Debug 561565] T01: 02 97 01 C7 FF 0A
+[DKANPROT-Debug 891170] T02: 00 A3 01 09 FF 0A
+[DKANPROT-Debug 891865] N02: 02 A3 01 05 FF 0A
+[DKANPROT-Debug 892307] N02: 00 A3 01 05 FF 0A
+[DKANPROT-Debug 000953] T02: 02 A3 01 09 FF 0A
+[DKANPROT-Debug 950960] T02: 00 A3 04 08 08 01 01 45 08 02 80 90 FF 0A
+[DKANPROT-Debug 951592] N02: 00 A3 01 06 FF 0A
+[DKANPROT-Info 953475] RXMSG KREVENT_DISCONNECT Slot 0x1 Port 0x0 Task 0x61 kreis 0x1 = class_inst, class_type=1
+[DKANPROT-Info 954247] KR_TXMSG_TAPI_STATE_FORCE ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Info 955130] KR_TXMSG_RELEASE ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 956348] RXMSG KREVENT_ERSTAUFRUF ohne task, class KREIS[0x1]
+[DKANPROT-Info 956737] KR_TXMSG_DISC_REQ ueber task 0x62 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Debug 959297] T01: 00 97 14 C6 08 01 25 45 08 02 80 90 FF 0A
+[DKANPROT-Debug 960127] N02: 02 A3 08 06 08 01 81 4D FF 0A
+[DKANPROT-Debug 061002] T02: 02 A3 01 0A FF 0A
+[DKANPROT-Debug 061336] T02: 00 A3 06 0A 08 01 01 5A FF 0A
+[DKANPROT-Debug 061575] N01: 00 97 01 16 FF 0A
+[DKANPROT-Debug 062273] N02: 00 A3 01 08 FF 0A
+[DKANPROT-Debug 064172] RXMSG KREVENT_RELEASE_COMP Task 0x61 class L6MGR[0x0]
+[DKANPROT-Info 064488] KR_TXMSG_TAPI_STATE_FORCE ueber task 0x61 von tnid 0x19 (RN 22) an port 0x12 (S 1 P 0)
+[DKANPROT-Debug 171034] N01: 02 97 C6 16 08 01 A5 4D FF 0A
+[DKANPROT-Debug 172606] T01: 02 97 01 C8 FF 0A
+[DKANPROT-Debug 174718] T01: 00 97 16 C8 08 01 25 5A 08 02 80 9F FF 0A
+[DKANPROT-Debug 175229] RXMSG KREVENT_RELEASE Task 0x62 class L6MGR[0x0]
+[DKANPROT-Info 179022] KR_TXMSG_TAPI_STATE_FORCE ueber task 0x62 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Info 179758] KR_TXMSG_RELCOMP ueber task 0x62 von tnid 0x13 (RN ) an port 0x13 (S 2 P 0)
+[DKANPROT-Debug 285444] N01: 00 97 01 18 FF 0A
diff --git a/src/callnotifier/EDSS1/Message.php b/src/callnotifier/EDSS1/Message.php
new file mode 100644 (file)
index 0000000..3d22a82
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+namespace callnotifier;
+
+class EDSS1_Message
+{
+    const ALERTING = "\x01";
+    const CALL_PROCEEDING = "\x02";
+    const SETUP = "\x05";
+    const CONNECT = "\x07";
+    const SETUP_ACKNOWLEDGE = "\x0D";
+    const DISCONNECT = "\x45";
+    const RELEASE = "\x4D";
+    const RELEASE_COMPLETE = "\x5A";
+    const INFORMATION = "\x7B";
+    
+    /**
+     * @var integer
+     */
+    public $type;
+    public $parameters = array();
+
+
+    public function getTypeName()
+    {
+        $rc = new \ReflectionClass($this);
+        foreach ($rc->getConstants() as $name => $value) {
+            if (ord($value) == $this->type) {
+                return $name;
+            }
+        }
+        return '';
+    }
+}
+
+?>
diff --git a/src/callnotifier/EDSS1/Parameter.php b/src/callnotifier/EDSS1/Parameter.php
new file mode 100644 (file)
index 0000000..ded3030
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+namespace callnotifier;
+
+class EDSS1_Parameter
+{
+    const CALLING_PARTY_NUMBER = "\x6C";
+    const CALLED_PARTY_NUMBER = "\x70";
+    const CONNECTED_NUMBER = "\x4C";
+    const KEYPAD = "\x2C";
+
+    public $type;
+    public $length;
+    public $data;
+}
+
+?>
diff --git a/src/callnotifier/EDSS1/Parser.php b/src/callnotifier/EDSS1/Parser.php
new file mode 100644 (file)
index 0000000..5a298e5
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+namespace callnotifier;
+
+class EDSS1_Parser
+{
+    const PARAM = 0;
+    const PARAMLENGTH = 1;
+    const PARAMVAL = 2;
+
+    public function parse($bytes)
+    {
+        $m = new EDSS1_Message();
+        $m->type = ord($bytes{7});
+
+        $curpos = 7;
+        $complete = false;
+        do {
+            //parameter type
+            $curbit = $bytes{++$curpos};
+            if ($curbit == "\xFF" && $bytes{$curpos + 1} == "\n") {
+                $complete = true;
+                break;
+            }
+            $param = new EDSS1_Parameter();
+            $m->parameters[] = $param;
+            $param->type     = ord($curbit);
+
+            //parameter length
+            $curbit = $bytes{++$curpos};
+            $param->length = ord($curbit);
+
+            //parameter data
+            $param->data = substr($bytes, $curpos + 1, $param->length);
+            $curpos += $param->length;
+        } while ($curpos < strlen($bytes) - 1);
+
+        return $m;
+    }
+}
+
+?>
index c716db893cfcc1814f169b77cc5c168710ce162d..9ce5b090d653672547accd0228ce9dd40079710a 100644 (file)
@@ -11,6 +11,7 @@ class Logger_Echo implements Logger
         $this->blue = $cc->convert('%b');
         $this->red = $cc->convert('%r');
         $this->white = $cc->convert('%w');
         $this->blue = $cc->convert('%b');
         $this->red = $cc->convert('%r');
         $this->white = $cc->convert('%w');
+        $this->purple = $cc->convert('%p');
     }
 
     public function log($type, $arData)
     }
 
     public function log($type, $arData)
@@ -31,6 +32,25 @@ class Logger_Echo implements Logger
                 );
                 echo $this->red . '     bytes' . $this->end . ': ' . $line . "\n";
             }
                 );
                 echo $this->red . '     bytes' . $this->end . ': ' . $line . "\n";
             }
+        } else if ($type == 'edss1msg') {
+            $msg = $arData['msg'];
+            echo sprintf(
+                $this->purple . 'EDSS1_Message' . $this->end
+                . ' type %02X '
+                . $this->purple . '%s' . $this->end
+                . ', %d parameters',
+                $msg->type,
+                $msg->getTypeName(),
+                count($msg->parameters)
+            ) . "\n";
+            foreach ($msg->parameters as $param) {
+                echo sprintf(
+                    " Parameter type %02X, %d bytes: %s\n",
+                    $param->type,
+                    $param->length,
+                    preg_replace('/[^[:print:]]/', '?', $param->data)
+                );
+            }
         } else {
             echo $this->blue . $type . $this->end . ': '
                 . var_export($arData, true) . "\n";
         } else {
             echo $this->blue . $type . $this->end . ': '
                 . var_export($arData, true) . "\n";
index 89d07e72c73464a51ee0346b4ed4cd338a2b900d..6181e3a39a5e15545c17d49415278e7ce852e877 100644 (file)
@@ -14,7 +14,8 @@ class MessageHandler
      */
     protected $logger = array(
         'msgData' => array(),
      */
     protected $logger = array(
         'msgData' => array(),
-        'incomingCall' => array()
+        'incomingCall' => array(),
+        'edss1msg' => array(),
     );
 
 
     );
 
 
@@ -73,7 +74,7 @@ class MessageHandler
         );
 
         if ($type != 'Info') {
         );
 
         if ($type != 'Info') {
-            //we only want info messages
+            $this->parseEDSS1($details);
             return;
         }
         //Vegw/Ets-Cref:[0xffef]/[0x64] - VEGW_SETUP from upper layer to internal destination: CGPN[**22]->CDPN[41], 
             return;
         }
         //Vegw/Ets-Cref:[0xffef]/[0x64] - VEGW_SETUP from upper layer to internal destination: CGPN[**22]->CDPN[41], 
@@ -84,6 +85,45 @@ class MessageHandler
         }
     }
 
         }
     }
 
+    /**
+     * Example string: "T02: 00 A3 06 0A 08 01 01 5A FF 0A"
+     *
+     * @param string $details Detail string of a debug message
+     *
+     */
+    protected function parseEDSS1($details)
+    {
+        if ($details{0} != 'T' && $details{0} != 'N') {
+            //we only want byte data
+            return;
+        }
+        if (substr($details, 16, 4) != ' 08 ') {
+            //only E-DSS-1, no other packets
+            return;
+        }
+        
+        $bytestring = substr($details, 5);
+        $bytes = '';
+        foreach (explode(' ', $bytestring) as $strbyte) {
+            $bytes .= chr(hexdec($strbyte));
+        }
+
+        $msgtype = $bytes{7};
+        static $interestingTyps = array(
+            EDSS1_Message::SETUP,
+            EDSS1_Message::CONNECT,
+            EDSS1_Message::INFORMATION
+        );
+        if (!in_array($msgtype, $interestingTyps)) {
+            //return;
+        }
+
+        $mp = new EDSS1_Parser();
+        $msg = $mp->parse($bytes);
+
+        $this->log('edss1msg', array('msg' => $msg));
+    }
+
     protected function log($type, $arData)
     {
         if (!isset($this->logger[$type])) {
     protected function log($type, $arData)
     {
         if (!isset($this->logger[$type])) {