aboutsummaryrefslogtreecommitdiffstats
path: root/src/hdlc-test.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-11-14 21:29:01 +0100
committerHarald Welte <laforge@gnumonks.org>2016-11-14 21:29:01 +0100
commit1df5cf49501226ebc9ba7f9989cc7c07d38a3062 (patch)
treeb181b436aa8edf968ef09e24d00d302e7b7ec9e8 /src/hdlc-test.c
parent6daa71dbd2898ee4afad984eff79c30ce171d0d6 (diff)
e1cap_dump: Implement functional HDLC decode of super-channel
Finally the bit ordering and bit format of the SuperChannel has been figured out. * the data as read from DAHDI must be flipped (0->1 / 1->0). why? * the data must be read lsb-first when converting into a bit-buffer We are now getting the following output e.g. for a OM2000 "TX Configuration Request" message: fa 03 8a 8a 80 80 00 13 00 b0 0b 00 ff 01 20 00 2e 2b 1c 00 06 01 95 81 76 00 e9 bf ^ lapd hdr ^ OML ^l ^OM2000 TX Config Req for 43 dBm
Diffstat (limited to 'src/hdlc-test.c')
-rw-r--r--src/hdlc-test.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/hdlc-test.c b/src/hdlc-test.c
new file mode 100644
index 0000000..1c7c6ef
--- /dev/null
+++ b/src/hdlc-test.c
@@ -0,0 +1,42 @@
+#include <string.h>
+#include "hdlc.h"
+
+#include <osmocom/core/utils.h>
+#include <osmocom/core/bits.h>
+
+const char *tdata = "7e7e7e7e7a76f20609167d3cfcfcfc";
+
+static void hdlc_process_hex_str(struct hdlc_proc *hdlc, const char *hex)
+{
+ uint8_t *bytes, *bits;
+ int string_len = strlen(hex);
+ int byte_len = string_len/2;
+ int bit_len = byte_len*8;
+ int rc;
+
+ printf("hex string = %s\n", hex);
+ bytes = alloca(byte_len);
+ bits = alloca(bit_len);
+ rc = osmo_hexparse(hex, bytes, byte_len);
+ printf("parsed bytes = %s\n", osmo_hexdump(bytes, byte_len));
+
+ printf("MSB mode\n");
+ osmo_pbit2ubit(bits, bytes, bit_len);
+ process_raw_hdlc(hdlc, bits, bit_len);
+
+ printf("LSB mode\n");
+ memset(hdlc, 0, sizeof(*hdlc));
+ osmo_pbit2ubit_ext(bits, 0, bytes, 0, bit_len, 1);
+ process_raw_hdlc(hdlc, bits, bit_len);
+}
+
+int main(int argc, char **argv)
+{
+ struct hdlc_proc hdlc;
+ memset(&hdlc, 0, sizeof(hdlc));
+
+ if (argc < 2)
+ exit(1);
+
+ hdlc_process_hex_str(&hdlc, argv[1]);
+}