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/src/lib/decoder/gsmstack.c | 30 +++++++++++------------------- gsm-receiver/src/lib/decoder/gsmstack.h | 4 +++- 2 files changed, 14 insertions(+), 20 deletions(-) (limited to 'gsm-receiver/src/lib/decoder') 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