Added GSMTAP IP option and fixed command line help output format
This commit is contained in:
parent
9f63e0e965
commit
d1c0b37bce
38
src/layer1.c
38
src/layer1.c
|
@ -1,4 +1,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <osmocom/abis/e1_input.h>
|
||||
#include <osmocom/core/gsmtap.h>
|
||||
#include <osmocom/core/gsmtap_util.h>
|
||||
|
@ -12,6 +14,7 @@
|
|||
#include "v5x_le_management.h"
|
||||
|
||||
extern int test_sa7;
|
||||
extern const char *gsmtap_ip;
|
||||
|
||||
extern struct v5x_instance *v5i;
|
||||
|
||||
|
@ -152,8 +155,10 @@ static void hdlc_rx_cb(struct e1inp_ts *ts, struct msgb *msg)
|
|||
LOGP(DLINP, LOGL_DEBUG, "Link %d L1->L2: %s\n", v5l->id, msgb_hexdump(msg));
|
||||
|
||||
/* send V5 data via gsmtap so wireshark can receive + decode it */
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id, ts->num, GSMTAP_E1T1_V5EF,
|
||||
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
if (g_gti) {
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id, ts->num, GSMTAP_E1T1_V5EF,
|
||||
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
}
|
||||
|
||||
lapv5ef_rx(v5l, msg);
|
||||
}
|
||||
|
@ -212,8 +217,10 @@ int ph_data_req_hdlc(struct msgb *msg, struct v5x_interface *v5if)
|
|||
struct e1inp_ts *ts = &e1_line->ts[v5if->cc_link->c_channel[0].ts->nr - 1];
|
||||
|
||||
/* send V5 data via gsmtap so wireshark can receive + decode it */
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
|
||||
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
if (g_gti) {
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | GSMTAP_ARFCN_F_UPLINK, ts->num,
|
||||
GSMTAP_E1T1_V5EF, 0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
}
|
||||
|
||||
return e1inp_ts_send_hdlc(ts, msg);
|
||||
}
|
||||
|
@ -240,8 +247,10 @@ int ph_data_req_dl_cc(struct msgb *msg, void *cbdata)
|
|||
LOGP(DLINP, LOGL_DEBUG, "Link %d L2->L1: %s\n", v5if->cc_link->id, msgb_hexdump(msg));
|
||||
|
||||
/* send V5 data via gsmtap so wireshark can receive + decode it */
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
|
||||
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
if (g_gti) {
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5if->cc_link->id | GSMTAP_ARFCN_F_UPLINK, ts->num,
|
||||
GSMTAP_E1T1_V5EF, 0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
}
|
||||
|
||||
return e1inp_ts_send_hdlc(ts, msg);
|
||||
}
|
||||
|
@ -268,8 +277,10 @@ int ph_data_req_dl_prot(struct msgb *msg, void *cbdata)
|
|||
LOGP(DLINP, LOGL_DEBUG, "Link %d L2->L1: %s\n", v5l->id, msgb_hexdump(msg));
|
||||
|
||||
/* send V5 data via gsmtap so wireshark can receive + decode it */
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id | GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
|
||||
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
if (g_gti) {
|
||||
gsmtap_send_ex(g_gti, GSMTAP_TYPE_E1T1, v5l->id | GSMTAP_ARFCN_F_UPLINK, ts->num, GSMTAP_E1T1_V5EF,
|
||||
0, 0, 0, 0, msgb_data(msg), msgb_length(msg));
|
||||
}
|
||||
|
||||
return e1inp_ts_send_hdlc(ts, msg);
|
||||
}
|
||||
|
@ -366,9 +377,14 @@ int e1_init(void)
|
|||
struct e1inp_line *e1_line;
|
||||
int i, ts;
|
||||
|
||||
g_gti = gsmtap_source_init("224.0.0.1", GSMTAP_UDP_PORT, 0);
|
||||
OSMO_ASSERT(g_gti);
|
||||
gsmtap_source_add_sink(g_gti);
|
||||
if (gsmtap_ip) {
|
||||
g_gti = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 0);
|
||||
if (!g_gti) {
|
||||
fprintf(stderr, "Failed to use '%s' as IP for GSMTAP\n", gsmtap_ip);
|
||||
return -EINVAL;
|
||||
}
|
||||
gsmtap_source_add_sink(g_gti);
|
||||
}
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
e1_line = e1inp_line_find(i);
|
||||
|
|
25
src/main.c
25
src/main.c
|
@ -72,6 +72,7 @@ void *tall_v5le_ctx = NULL;
|
|||
struct v5x_instance *v5i = NULL;
|
||||
|
||||
static int daemonize = 0;
|
||||
const char *gsmtap_ip = NULL;
|
||||
int test_sa7 = 0;
|
||||
|
||||
const char *v5le_copyright =
|
||||
|
@ -85,12 +86,13 @@ static char *config_file = "osmo-v5-le.cfg";
|
|||
static void print_help()
|
||||
{
|
||||
printf("Some useful options:\n");
|
||||
printf(" -h --help is printing this text.\n");
|
||||
printf(" -c --config-file filename The config file to use.\n");
|
||||
printf(" -s --disable-color\n");
|
||||
printf(" -D --daemonize Fork the process into a background daemon\n");
|
||||
printf(" -V --version Print the version number\n");
|
||||
printf(" -7 --rest-sa7 Continously toggle Sa7 when received. (Do loop interface.)\n");
|
||||
printf(" -h --help is printing this text.\n");
|
||||
printf(" -c --config-file filename The config file to use.\n");
|
||||
printf(" -s --disable-color Disable colors on debug output.\n");
|
||||
printf(" -D --daemonize Fork the process into a background daemon\n");
|
||||
printf(" -V --version Print the version number\n");
|
||||
printf(" -T --gsmtap IP Send GSMTAP messages to ip. (e.g. 224.0.0.1)\n");
|
||||
printf(" -7 --rest-sa7 Continously toggle Sa7 when received. (Do loop interface.)\n");
|
||||
|
||||
printf("\nVTY reference generation:\n");
|
||||
printf(" --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n");
|
||||
|
@ -135,11 +137,12 @@ static void handle_options(int argc, char **argv)
|
|||
{"disable-color", 0, 0, 's'},
|
||||
{"vty-ref-mode", 1, &long_option, 1},
|
||||
{"vty-ref-xml", 0, &long_option, 2},
|
||||
{"gsmtap", 1, 0, 'T'},
|
||||
{"test-sa7", 0, 0, '7'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "hc:sVD7", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "hc:sVDT:7", long_options, &option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
@ -165,6 +168,9 @@ static void handle_options(int argc, char **argv)
|
|||
case 'D':
|
||||
daemonize = 1;
|
||||
break;
|
||||
case 'T':
|
||||
gsmtap_ip = strdup(optarg);
|
||||
break;
|
||||
case '7':
|
||||
test_sa7 = 1;
|
||||
break;
|
||||
|
@ -244,7 +250,8 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
rc = e1_init();
|
||||
OSMO_ASSERT(rc == 0);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
/* start telnet after reading config for vty_get_bind_addr() */
|
||||
rc = telnet_init_dynif(tall_v5le_ctx, NULL,
|
||||
|
@ -301,5 +308,7 @@ int main(int argc, char **argv)
|
|||
/* destroy the universe */
|
||||
v5x_instance_free(v5i);
|
||||
|
||||
free((char *)gsmtap_ip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue