msuraev has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/31386 )
Change subject: GSMTAP: allow configuring local address ......................................................................
GSMTAP: allow configuring local address
Change-Id: If047cbaf95b343ee115690bf7a724a8edc5df735 --- M include/osmo-bts/bts.h M src/common/main.c M src/common/vty.c M tests/osmo-bts.vty 4 files changed, 54 insertions(+), 5 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, but someone else must approve msuraev: Looks good to me, approved Jenkins Builder: Verified
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h index 0ecec1e..ed3da1d 100644 --- a/include/osmo-bts/bts.h +++ b/include/osmo-bts/bts.h @@ -366,6 +366,7 @@ struct { struct gsmtap_inst *inst; char *remote_host; + char *local_host; uint32_t sapi_mask; uint8_t sapi_acch; } gsmtap; diff --git a/src/common/main.c b/src/common/main.c index 2b86a77..074ab22 100644 --- a/src/common/main.c +++ b/src/common/main.c @@ -354,12 +354,12 @@ /* TODO: move this to gsm_bts_alloc() */ if (g_bts->gsmtap.remote_host != NULL) { LOGP(DLGLOBAL, LOGL_NOTICE, - "Setting up GSMTAP Um forwarding to '%s:%u'\n", - g_bts->gsmtap.remote_host, GSMTAP_UDP_PORT); - g_bts->gsmtap.inst = gsmtap_source_init(g_bts->gsmtap.remote_host, - GSMTAP_UDP_PORT, 1); + "Setting up GSMTAP Um forwarding '%s->'%s:%u'\n", + g_bts->gsmtap.local_host, g_bts->gsmtap.remote_host, GSMTAP_UDP_PORT); + g_bts->gsmtap.inst = gsmtap_source_init2(g_bts->gsmtap.local_host, 0, + g_bts->gsmtap.remote_host, GSMTAP_UDP_PORT, 1); if (g_bts->gsmtap.inst == NULL) { - fprintf(stderr, "Failed during gsmtap_source_init()\n"); + fprintf(stderr, "Failed during gsmtap_source_init2()\n"); exit(1); } gsmtap_source_add_sink(g_bts->gsmtap.inst); diff --git a/src/common/vty.c b/src/common/vty.c index 5877a41..76da14b 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -2217,6 +2217,22 @@ return CMD_SUCCESS; }
+DEFUN(cfg_bts_gsmtap_local_host, + cfg_bts_gsmtap_local_host_cmd, + "gsmtap-local-host HOSTNAME", + "Enable local bind for GSMTAP Um logging (see also 'gsmtap-sapi')\n" + "Local IP address or hostname\n") +{ + struct gsm_bts *bts = vty->index; + + osmo_talloc_replace_string(bts, &bts->gsmtap.local_host, argv[0]); + + if (vty->type != VTY_FILE) + vty_out(vty, "%% This command requires restart%s", VTY_NEWLINE); + + return CMD_SUCCESS; +} + DEFUN(cfg_bts_no_gsmtap_remote_host, cfg_bts_no_gsmtap_remote_host_cmd, "no gsmtap-remote-host", @@ -2234,6 +2250,24 @@ return CMD_SUCCESS; }
+DEFUN(cfg_bts_no_gsmtap_local_host, + cfg_bts_no_gsmtap_local_host_cmd, + "no gsmtap-local-host", + NO_STR "Disable local bind for GSMTAP Um logging\n") +{ + struct gsm_bts *bts = vty->index; + + if (bts->gsmtap.local_host != NULL) + talloc_free(bts->gsmtap.local_host); + + bts->gsmtap.local_host = NULL; + + if (vty->type != VTY_FILE) + vty_out(vty, "%% This command requires restart%s", VTY_NEWLINE); + + return CMD_SUCCESS; +} + DEFUN(cfg_bts_gsmtap_sapi_all, cfg_bts_gsmtap_sapi_all_cmd, "gsmtap-sapi (enable-all|disable-all)", "Enable/disable sending of UL/DL messages over GSMTAP\n" @@ -2652,6 +2686,8 @@
install_element(BTS_NODE, &cfg_bts_gsmtap_remote_host_cmd); install_element(BTS_NODE, &cfg_bts_no_gsmtap_remote_host_cmd); + install_element(BTS_NODE, &cfg_bts_gsmtap_local_host_cmd); + install_element(BTS_NODE, &cfg_bts_no_gsmtap_local_host_cmd); install_element(BTS_NODE, &cfg_bts_gsmtap_sapi_all_cmd); install_element(BTS_NODE, &cfg_bts_gsmtap_sapi_cmd); install_element(BTS_NODE, &cfg_bts_no_gsmtap_sapi_cmd); diff --git a/tests/osmo-bts.vty b/tests/osmo-bts.vty index 0b67ae9..3e526e7 100644 --- a/tests/osmo-bts.vty +++ b/tests/osmo-bts.vty @@ -251,6 +251,8 @@ smscb queue-hysteresis <0-30> gsmtap-remote-host [HOSTNAME] no gsmtap-remote-host + gsmtap-local-host HOSTNAME + no gsmtap-local-host gsmtap-sapi (enable-all|disable-all) gsmtap-sapi (bcch|ccch|rach|agch|pch|sdcch|tch/f|tch/h|pacch|pdtch|ptcch|cbch|sacch) no gsmtap-sapi (bcch|ccch|rach|agch|pch|sdcch|tch/f|tch/h|pacch|pdtch|ptcch|cbch|sacch) @@ -274,6 +276,7 @@ supp-meas-info Configure the RSL Supplementary Measurement Info smscb SMSCB (SMS Cell Broadcast) / CBCH configuration gsmtap-remote-host Enable GSMTAP Um logging (see also 'gsmtap-sapi') + gsmtap-local-host Enable local bind for GSMTAP Um logging (see also 'gsmtap-sapi') gsmtap-sapi Enable/disable sending of UL/DL messages over GSMTAP osmux Configure Osmux trx Select a TRX to configure