summaryrefslogtreecommitdiff
path: root/gsm-tvoid/src/lib/gsmstack.c
diff options
context:
space:
mode:
Diffstat (limited to 'gsm-tvoid/src/lib/gsmstack.c')
-rw-r--r--gsm-tvoid/src/lib/gsmstack.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/gsm-tvoid/src/lib/gsmstack.c b/gsm-tvoid/src/lib/gsmstack.c
new file mode 100644
index 0000000..9fc4868
--- /dev/null
+++ b/gsm-tvoid/src/lib/gsmstack.c
@@ -0,0 +1,74 @@
+/*
+ * Invoke gsmstack() with any kind of burst. Automaticly decode and retrieve
+ * information.
+ */
+#include "system.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "gsmstack.h"
+#include "gsm_constants.h"
+#include "interleave.h"
+#include "sch.h"
+
+INTERLEAVE_CTX ictx;
+
+static void
+diff_decode(char *dst, char *src, int len)
+{
+ const unsigned char *end = src + len;
+ unsigned char last;
+
+ src += 3;
+ last = 0;
+ memset(dst, 0, 3);
+ dst += 3;
+
+ while (src < end)
+ {
+ *dst = !*src ^ last;
+ last = *dst;
+ src++;
+ dst++;
+ }
+}
+
+/*
+ * Initialize a new GSMSTACK context.
+ */
+int
+GS_new(GS_CTX *ctx)
+{
+ memset(ctx, 0, sizeof *ctx);
+ interleave_init(&ictx, 456, 114);
+
+ return 0;
+}
+
+/*
+ * 156 bit
+ */
+int
+GS_process(GS_CTX *ctx, int ts, int type, char *data)
+{
+ int fn;
+ int bsic;
+ int ret;
+ char buf[156];
+
+ diff_decode(buf, data, 156);
+
+ switch (type)
+ {
+ case SCH:
+ ret = decode_sch(buf, &fn, &bsic);
+ if (ret != 0)
+ break;
+ DEBUGF("FN %d, BSIC %d\n", fn, bsic);
+ break;
+ case NORMAL:
+ break;
+ }
+}
+
+
personal git repositories of Harald Welte. Your mileage may vary