From 99de0b0ce9ac711eaca1b3d8951e3bfc606306d8 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 22 May 2011 11:56:01 +0200 Subject: GSMTAP: update to new libosmocore-0.3.1 (integrated GSMTAP sink) This means you now no longer need a local 'nc' or iptables rules to avoid getting ICMP port unreachable messages in your protocol trace. --- gsm-receiver/configure.ac | 2 +- gsm-receiver/src/lib/decoder/gsmstack.c | 30 +++++++++++------------------- gsm-receiver/src/lib/decoder/gsmstack.h | 4 +++- 3 files changed, 15 insertions(+), 21 deletions(-) (limited to 'gsm-receiver') diff --git a/gsm-receiver/configure.ac b/gsm-receiver/configure.ac index a9199f8..9c53646 100644 --- a/gsm-receiver/configure.ac +++ b/gsm-receiver/configure.ac @@ -27,7 +27,7 @@ m4_include([config/gr_standalone.m4]) GR_STANDALONE dnl Check for libosmocore (gsmtap support) -PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.1.13) +PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.3.1) AC_CONFIG_FILES([\ Makefile \ diff --git a/gsm-receiver/src/lib/decoder/gsmstack.c b/gsm-receiver/src/lib/decoder/gsmstack.c index 73d9028..340990f 100644 --- a/gsm-receiver/src/lib/decoder/gsmstack.c +++ b/gsm-receiver/src/lib/decoder/gsmstack.c @@ -196,12 +196,11 @@ get_chan_type(enum TIMESLOT_TYPE type, int fn, uint8_t *ss) int GS_new(GS_CTX *ctx) { - int rc; struct sockaddr_in sin; sin.sin_family = AF_INET; sin.sin_port = htons(GSMTAP_UDP_PORT); - inet_aton("224.0.0.1", &sin.sin_addr); + inet_aton("127.0.0.1", &sin.sin_addr); memset(ctx, 0, sizeof *ctx); interleave_init(&ctx->interleave_ctx, 456, 114); @@ -209,20 +208,14 @@ GS_new(GS_CTX *ctx) interleave_init_facch_f(&ctx->interleave_facch_f2_ctx, 456, 114, 4); ctx->fn = -1; ctx->bsic = -1; - ctx->gsmtap_fd = -1; - rc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (rc < 0) { - perror("creating UDP socket\n"); - return rc; - } - ctx->gsmtap_fd = rc; - rc = connect(rc, (struct sockaddr *)&sin, sizeof(sin)); - if (rc < 0) { - perror("connectiong UDP socket"); - close(ctx->gsmtap_fd); - return rc; + ctx->gsmtap_inst = gsmtap_source_init("127.0.0.1", GSMTAP_UDP_PORT, 0); + if (!ctx->gsmtap_inst) { + perror("creating gsmtap socket\n"); + return -EIO; } + /* Add a local sink to the existing GSMTAP source */ + gsmtap_source_add_sink(ctx->gsmtap_inst); return 0; } @@ -270,7 +263,7 @@ GS_process(GS_CTX *ctx, int ts, int type, const unsigned char *src, int fn, int out_gsmdecode(0, 0, ts, ctx->fn, data, len); - if (ctx->gsmtap_fd >= 0) { + if (ctx->gsmtap_inst) { struct msgb *msg; uint8_t chan_type = GSMTAP_CHANNEL_TCH_F; uint8_t ss = 0; @@ -278,7 +271,7 @@ GS_process(GS_CTX *ctx, int ts, int type, const unsigned char *src, int fn, int msg = gsmtap_makemsg(0, ts, chan_type, ss, ctx->fn, 0, 0, data, len); if (msg) - write(ctx->gsmtap_fd, msg->data, msg->len); + gsmtap_sendmsg(ctx->gsmtap_inst, msg); } return 0; } @@ -312,7 +305,7 @@ GS_process(GS_CTX *ctx, int ts, int type, const unsigned char *src, int fn, int out_gsmdecode(0, 0, ts, ctx->fn, data, len); - if (ctx->gsmtap_fd >= 0) { + if (ctx->gsmtap_inst) { /* Dieter: set channel type according to configuration */ struct msgb *msg; uint8_t chan_type = GSMTAP_CHANNEL_BCCH; @@ -325,8 +318,7 @@ GS_process(GS_CTX *ctx, int ts, int type, const unsigned char *src, int fn, int msg = gsmtap_makemsg(0, ts, chan_type, ss, ctx->fn, 0, 0, data, len); if (msg) - write(ctx->gsmtap_fd, msg->data, - msg->len); + gsmtap_sendmsg(ctx->gsmtap_inst, msg); } #if 0 diff --git a/gsm-receiver/src/lib/decoder/gsmstack.h b/gsm-receiver/src/lib/decoder/gsmstack.h index 67c7bbf..33bdaf7 100644 --- a/gsm-receiver/src/lib/decoder/gsmstack.h +++ b/gsm-receiver/src/lib/decoder/gsmstack.h @@ -39,6 +39,8 @@ struct gs_ts_ctx { enum TIMESLOT_TYPE type; }; +struct gsmtap_inst; + typedef struct { int flags; @@ -52,7 +54,7 @@ typedef struct struct gs_ts_ctx ts_ctx[8]; - int gsmtap_fd; + struct gsmtap_inst *gsmtap_inst; } GS_CTX; int GS_new(GS_CTX *ctx); -- cgit v1.2.3