summaryrefslogtreecommitdiff
path: root/gsm-tvoid/src/lib/gsmstack.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2008-11-27 08:35:42 +0530
committerHarald Welte <laforge@gnumonks.org>2008-11-27 08:35:42 +0530
commit6c274198ad9ed182545125fb6bfde2a99114cc0a (patch)
tree2326727068ef0c3412915d2b0a485a6ecec89ed3 /gsm-tvoid/src/lib/gsmstack.c
parenteb13897566ab93c56462b327b75bfd8eb317abc9 (diff)
Add PCAP (LINKTYPE GSM incl. gsmtap hdr) support
Diffstat (limited to 'gsm-tvoid/src/lib/gsmstack.c')
-rw-r--r--gsm-tvoid/src/lib/gsmstack.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/gsm-tvoid/src/lib/gsmstack.c b/gsm-tvoid/src/lib/gsmstack.c
index ecea4f9..e09420c 100644
--- a/gsm-tvoid/src/lib/gsmstack.c
+++ b/gsm-tvoid/src/lib/gsmstack.c
@@ -5,6 +5,7 @@
#include "system.h"
#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include <string.h>
#include "gsmstack.h"
#include "gsm_constants.h"
@@ -12,6 +13,8 @@
#include "sch.h"
#include "cch.h"
+#include "out_pcap.h"
+
static void out_gsmdecode(char type, int arfcn, int ts, int fn, char *data, int len);
#if 0
@@ -46,9 +49,14 @@ GS_new(GS_CTX *ctx)
interleave_init(&ctx->interleave_ctx, 456, 114);
ctx->fn = -1;
ctx->bsic = -1;
+
ctx->tun_fd = mktun("gsm", ctx->ether_addr);
if (ctx->tun_fd < 0)
- return -1;
+ fprintf(stderr, "cannot open 'gsm' tun device, did you create it?\n");
+
+ ctx->pcap_fd = open_pcap_file("tvoid.pcap");
+ if (ctx->pcap_fd < 0)
+ fprintf(stderr, "cannot open PCAP file: %s\n", strerror(errno));
return 0;
}
@@ -65,8 +73,14 @@ GS_process(GS_CTX *ctx, int ts, int type, const unsigned char *src)
unsigned char *data;
int len;
- if (ts != 0)
+ if (ts != 0) {
+ /* non-0 timeslots should end up in PCAP */
+ data = decode_cch(ctx, ctx->burst, &len);
+ if (data == NULL)
+ return -1;
+ write_pcap_packet(ctx->pcap_fd, 0 /* arfcn */, ts, 0, data, len);
return;
+ }
if (type == SCH)
{
@@ -111,6 +125,7 @@ GS_process(GS_CTX *ctx, int ts, int type, const unsigned char *src)
out_gsmdecode(0, 0, ts, ctx->fn - 4, data, len);
write_interface(ctx->tun_fd, data+1, len-1, ctx->ether_addr);
+ write_pcap_packet(ctx->pcap_fd, 0 /* arfcn */, ts, fn, data, len);
#if 0
if (ctx->fn % 51 != 0) && ( (((ctx->fn % 51 + 5) % 10 == 0) || (((ctx->fn % 51) + 1) % 10 ==0) ) )
ready = 1;
personal git repositories of Harald Welte. Your mileage may vary