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.
This commit is contained in:
parent
5f866dcf31
commit
99de0b0ce9
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue