<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/26216">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty: Introduce command 'gsmtap-remote-host' and 'gsmtap-category enable-all'<br><br>Related: OS#5306<br>Change-Id: Ibc6f78c46831b3c90ee3e97300fc13dc441df4c8<br>---<br>M doc/manuals/chapters/configuration.adoc<br>M src/gprs_pcu.h<br>M src/pcu_main.cpp<br>M src/pcu_vty.c<br>4 files changed, 150 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/16/26216/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/manuals/chapters/configuration.adoc b/doc/manuals/chapters/configuration.adoc</span><br><span>index d778929..8bdf4b8 100644</span><br><span>--- a/doc/manuals/chapters/configuration.adoc</span><br><span>+++ b/doc/manuals/chapters/configuration.adoc</span><br><span>@@ -422,3 +422,71 @@</span><br><span> accomplished and there's no penalty. However, if only EGPRS downlink data is sent</span><br><span> over that time frame, then the scheduler will force sending a RLCMAC Dummy</span><br><span> Block.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[[gsmtap]]</span><br><span style="color: hsl(120, 100%, 40%);">+=== Configuring GSMTAP tracing</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+In addition to being able to obtain pcap protocol traces of the NS/BSSGP</span><br><span style="color: hsl(120, 100%, 40%);">+communication and the text-based logging from the OsmoPCU software, there is</span><br><span style="color: hsl(120, 100%, 40%);">+also the capability of tracing all communication on the radio interface related</span><br><span style="color: hsl(120, 100%, 40%);">+to PS. To do so, OsmoPCU can encapsulate MAC blocks (23byte messages at the</span><br><span style="color: hsl(120, 100%, 40%);">+L2-L1 interface) into _GSMTAP_ and send them via UDP/IP. At that point, they can</span><br><span style="color: hsl(120, 100%, 40%);">+be captured with utilities like *tcpdump* or *tshark* for further analysis by</span><br><span style="color: hsl(120, 100%, 40%);">+the *wireshark* protocol analyzer.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+In order to activate this feature, you first need to make sure to specify</span><br><span style="color: hsl(120, 100%, 40%);">+the remote address of _GSMTAP_ host in the configuration file. In most</span><br><span style="color: hsl(120, 100%, 40%);">+cases, using 127.0.0.1 for passing the messages over the loopback (`lo`)</span><br><span style="color: hsl(120, 100%, 40%);">+device will be sufficient:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.Example: Enabling GSMTAP Um-frame logging to localhost</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+pcu</span><br><span style="color: hsl(120, 100%, 40%);">+ gsmtap-remote-host 127.0.0.1 <1></span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+<1> Destination address for _GSMTAP_ Um-frames</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+NOTE: Changing this parameter at run-time will not affect the existing</span><br><span style="color: hsl(120, 100%, 40%);">+_GSMTAP_ connection, full program restart is required.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+NOTE: Command line parameters `-i` and `--gsmtap-ip` have been deprecated.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+OsmoPCU can selectively trace such messages based on different categories, for</span><br><span style="color: hsl(120, 100%, 40%);">+both Ul and Dl. For a complete list of cateogry values, please refer to the</span><br><span style="color: hsl(120, 100%, 40%);">+_OsmoPCU VTY reference manual_ <<vty-ref-osmopcu>>.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+For example, to enable GSMTAP tracing for all DL EGPRS rlcmac data blocks, you</span><br><span style="color: hsl(120, 100%, 40%);">+can use the `gsmtap-category dl-data-egprs` command at the `pcu` node of the</span><br><span style="color: hsl(120, 100%, 40%);">+OsmoPCU VTY.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.Example: Enabling GSMTAP for for all DL EGPRS rlcmac data blocks</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+OsmoPCU> enable</span><br><span style="color: hsl(120, 100%, 40%);">+OsmoPCU# configure terminal</span><br><span style="color: hsl(120, 100%, 40%);">+OsmoPCU(config)# pcu</span><br><span style="color: hsl(120, 100%, 40%);">+OsmoPCU(pcu)# gsmtap-category dl-data-egprs</span><br><span style="color: hsl(120, 100%, 40%);">+OsmoPCU(trx)# write <1></span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+<1> the `write` command will make the configuration persistent in the</span><br><span style="color: hsl(120, 100%, 40%);">+configuration file. This is not required if you wish to enable GSMTAP</span><br><span style="color: hsl(120, 100%, 40%);">+only in the current session of OsmoPCU.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+De-activation can be performed similarly by using the `no gsmtap-category</span><br><span style="color: hsl(120, 100%, 40%);">+dl-data-egprs` command at the `pcu` node of the OsmoPCU VTY.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+It may be useful to enable all categories with a few exceptions, or vice versa</span><br><span style="color: hsl(120, 100%, 40%);">+disable everything using one command. For this purpose, the VTY provides</span><br><span style="color: hsl(120, 100%, 40%);">+`gsmtap-category enable-all` and `gsmtap-category disable-all` commands.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.Example: Enabling all categoriess except _dl-dummy_</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+pcu</span><br><span style="color: hsl(120, 100%, 40%);">+ gsmtap-category enable-all <1></span><br><span style="color: hsl(120, 100%, 40%);">+ no gsmtap-category dl-dummy <2></span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+<1> Enable all available SAPIs</span><br><span style="color: hsl(120, 100%, 40%);">+<2> Exclude DL RLCMAC blocks</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+From the moment they are enabled via VTY, GSMTAP messages will be</span><br><span style="color: hsl(120, 100%, 40%);">+generated and sent in UDP encapsulation to the IANA-registered UDP port</span><br><span style="color: hsl(120, 100%, 40%);">+for GSMTAP (4729) of the specified remote address.</span><br><span>diff --git a/src/gprs_pcu.h b/src/gprs_pcu.h</span><br><span>index fdcf5f7..ed00221 100644</span><br><span>--- a/src/gprs_pcu.h</span><br><span>+++ b/src/gprs_pcu.h</span><br><span>@@ -117,6 +117,7 @@</span><br><span> </span><br><span> struct gsmtap_inst *gsmtap;</span><br><span> uint32_t gsmtap_categ_mask;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *gsmtap_remote_host;</span><br><span> </span><br><span> struct llist_head bts_list; /* list of gprs_rlcmac_bts */</span><br><span> </span><br><span>diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp</span><br><span>index 38cf63b..16ca4d7 100644</span><br><span>--- a/src/pcu_main.cpp</span><br><span>+++ b/src/pcu_main.cpp</span><br><span>@@ -162,6 +162,8 @@</span><br><span> break;</span><br><span> case 'i':</span><br><span> gsmtap_addr = optarg;</span><br><span style="color: hsl(120, 100%, 40%);">+ fprintf(stderr, "Command line argument '-i' is deprecated, use VTY "</span><br><span style="color: hsl(120, 100%, 40%);">+ "parameter 'gsmtap-remote-host %s' instead.\n", gsmtap_addr);</span><br><span> break;</span><br><span> case 'r':</span><br><span> rt_prio = atoi(optarg);</span><br><span>@@ -284,6 +286,32 @@</span><br><span> fprintf(stderr, "No config file: '%s' Using default config.\n",</span><br><span> config_file);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Accept a GSMTAP host from VTY config, but a commandline option overrides that. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (gsmtap_addr != NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (pcu->gsmtap_remote_host != NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGP(DLGLOBAL, LOGL_NOTICE,</span><br><span style="color: hsl(120, 100%, 40%);">+ "Command line argument '-i %s' overrides "</span><br><span style="color: hsl(120, 100%, 40%);">+ "'gsmtap-remote-host %s' from the config file\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ gsmtap_addr, pcu->gsmtap_remote_host);</span><br><span style="color: hsl(120, 100%, 40%);">+ talloc_free(pcu->gsmtap_remote_host);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ pcu->gsmtap_remote_host = talloc_strdup(pcu, gsmtap_addr);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* TODO: move this to gsm_bts_alloc() */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (pcu->gsmtap_remote_host) {</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGP(DLGLOBAL, LOGL_NOTICE,</span><br><span style="color: hsl(120, 100%, 40%);">+ "Setting up GSMTAP Um forwarding to '%s:%u'\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ pcu->gsmtap_remote_host, GSMTAP_UDP_PORT);</span><br><span style="color: hsl(120, 100%, 40%);">+ pcu->gsmtap = gsmtap_source_init(pcu->gsmtap_remote_host,</span><br><span style="color: hsl(120, 100%, 40%);">+ GSMTAP_UDP_PORT, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (pcu->gsmtap == NULL) {</span><br><span style="color: hsl(120, 100%, 40%);">+ fprintf(stderr, "Failed during gsmtap_source_init()\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ exit(1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ gsmtap_source_add_sink(pcu->gsmtap);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> rc = telnet_init_dynif(tall_pcu_ctx, NULL, vty_get_bind_addr(),</span><br><span> OSMO_VTY_PORT_PCU);</span><br><span> if (rc < 0) {</span><br><span>diff --git a/src/pcu_vty.c b/src/pcu_vty.c</span><br><span>index c85e324..6201d60 100644</span><br><span>--- a/src/pcu_vty.c</span><br><span>+++ b/src/pcu_vty.c</span><br><span>@@ -70,6 +70,49 @@</span><br><span> { 0, NULL }</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_pcu_gsmtap_remote_host,</span><br><span style="color: hsl(120, 100%, 40%);">+ cfg_pcu_gsmtap_remote_host_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+ "gsmtap-remote-host [HOSTNAME]",</span><br><span style="color: hsl(120, 100%, 40%);">+ "Enable GSMTAP Um logging (see also 'gsmtap-category')\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "Remote IP address or hostname ('localhost' if omitted)\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_talloc_replace_string(the_pcu, &the_pcu->gsmtap_remote_host,</span><br><span style="color: hsl(120, 100%, 40%);">+ argc > 0 ? argv[0] : "localhost");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (vty->type != VTY_FILE)</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "%% This command requires restart%s", VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_pcu_no_gsmtap_remote_host,</span><br><span style="color: hsl(120, 100%, 40%);">+ cfg_pcu_no_gsmtap_remote_host_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+ "no gsmtap-remote-host",</span><br><span style="color: hsl(120, 100%, 40%);">+ NO_STR "Disable GSMTAP Um logging\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ if (the_pcu->gsmtap_remote_host)</span><br><span style="color: hsl(120, 100%, 40%);">+ TALLOC_FREE(the_pcu->gsmtap_remote_host);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (vty->type != VTY_FILE)</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "%% This command requires restart%s", VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_pcu_gsmtap_sapi_all, cfg_pcu_gsmtap_sapi_all_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+ "gsmtap-sapi (enable-all|disable-all)",</span><br><span style="color: hsl(120, 100%, 40%);">+ "Enable/disable sending of UL/DL messages over GSMTAP\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "Enable all kinds of messages (all SAPI)\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "Disable all kinds of messages (all SAPI)\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strcmp(argv[0], "enable-all") == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+ the_pcu->gsmtap_categ_mask = UINT32_MAX;</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ the_pcu->gsmtap_categ_mask = 0x00;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span> </span><br><span> DEFUN(cfg_pcu_gsmtap_categ, cfg_pcu_gsmtap_categ_cmd, "HIDDEN", "HIDDEN")</span><br><span> {</span><br><span>@@ -238,11 +281,14 @@</span><br><span> if (strcmp(the_pcu->pcu_sock_path, PCU_SOCK_DEFAULT))</span><br><span> vty_out(vty, " pcu-socket %s%s", the_pcu->pcu_sock_path, VTY_NEWLINE);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (the_pcu->gsmtap_remote_host)</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, " gsmtap-remote-host %s%s", the_pcu->gsmtap_remote_host, VTY_NEWLINE);</span><br><span> for (i = 0; i < 32; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t cs = ((uint32_t)1 << i);</span><br><span style="color: hsl(0, 100%, 40%);">- if (the_pcu->gsmtap_categ_mask & cs) {</span><br><span style="color: hsl(0, 100%, 40%);">- vty_out(vty, " gsmtap-category %s%s",</span><br><span style="color: hsl(0, 100%, 40%);">- get_value_string(pcu_gsmtap_categ_names, i), VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (the_pcu->gsmtap_categ_mask & ((uint32_t)1 << i)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ const char* category_buf;</span><br><span style="color: hsl(120, 100%, 40%);">+ if(!(category_buf = get_value_string_or_null(pcu_gsmtap_categ_names, i)))</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, " gsmtap-category %s%s", category_buf, VTY_NEWLINE);</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -1294,6 +1340,9 @@</span><br><span> install_element(PCU_NODE, &cfg_pcu_no_dl_tbf_preemptive_retransmission_cmd);</span><br><span> install_element(PCU_NODE, &cfg_pcu_ms_idle_time_cmd);</span><br><span> install_element(PCU_NODE, &cfg_pcu_no_ms_idle_time_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element(PCU_NODE, &cfg_pcu_gsmtap_remote_host_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element(PCU_NODE, &cfg_pcu_no_gsmtap_remote_host_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element(PCU_NODE, &cfg_pcu_gsmtap_sapi_all_cmd);</span><br><span> install_element(PCU_NODE, &cfg_pcu_gsmtap_categ_cmd);</span><br><span> install_element(PCU_NODE, &cfg_pcu_no_gsmtap_categ_cmd);</span><br><span> install_element(PCU_NODE, &cfg_pcu_sock_cmd);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/26216">change 26216</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-pcu/+/26216"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ibc6f78c46831b3c90ee3e97300fc13dc441df4c8 </div>
<div style="display:none"> Gerrit-Change-Number: 26216 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>