Change in ...osmo-bts[master]: vty: add "logging filter l1-sapi"

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Tue Sep 17 13:29:38 UTC 2019


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/15550


Change subject: vty: add "logging filter l1-sapi"
......................................................................

vty: add "logging filter l1-sapi"

Add VTY commands to filter by L1 SAPI. Allow to filter by multiple SAPIs
by running the filter command multiple times:

OsmoBTS> logging filter l1-sapi agch
OsmoBTS> logging filter l1-sapi pch

Related: OS#2356
Test: (osmo-ttcn3-hacks) I8c7f113eae7a93c6d4943cac9e3f49f153b323b1
Change-Id: I32d86d3d34757135b4cce59919c2fc2b67f0a889
---
M src/common/vty.c
1 file changed, 66 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/50/15550/1

diff --git a/src/common/vty.c b/src/common/vty.c
index 801f34c..842a9e7 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1600,6 +1600,70 @@
 	return CMD_SUCCESS;
 }
 
+#define L1_SAPI_STR "Filter log messages by L1 SAPI\n"
+#define L1_SAPI_ARG_STR "L1 SAPI to be used as filter\n"
+#define L1_SAPI_CMD_STR "logging filter l1-sapi (rach|agch|pch|bcch|pdtch|prach|ptcch|agch_dt)"
+
+uint16_t parse_l1_sapi_str(const char *sapi) {
+	if (!strcmp(sapi, "rach"))
+		return PCU_IF_SAPI_RACH;
+	else if (!strcmp(sapi, "agch"))
+		return PCU_IF_SAPI_AGCH;
+	else if (!strcmp(sapi, "pch"))
+		return PCU_IF_SAPI_PCH;
+	else if (!strcmp(sapi, "bcch"))
+		return PCU_IF_SAPI_BCCH;
+	else if (!strcmp(sapi, "pdtch"))
+		return PCU_IF_SAPI_PDTCH;
+	else if (!strcmp(sapi, "prach"))
+		return PCU_IF_SAPI_PRACH;
+	else if (!strcmp(sapi, "ptcch"))
+		return PCU_IF_SAPI_PTCCH;
+	else if (!strcmp(sapi, "agch_dt"))
+		return PCU_IF_SAPI_AGCH_DT;
+	return 0;
+}
+
+DEFUN(logging_fltr_l1_sapi,
+      logging_fltr_l1_sapi_cmd,
+      L1_SAPI_CMD_STR,
+      LOGGING_STR FILTER_STR L1_SAPI_STR L1_SAPI_ARG_STR)
+{
+	struct log_target *tgt = osmo_log_vty2tgt(vty);
+	uint16_t **sapi_mask;
+
+	if (!tgt)
+		return CMD_WARNING;
+
+	sapi_mask = (uint16_t **)&tgt->filter_data[LOG_FLT_L1_SAPI];
+	if (!*sapi_mask)
+		*sapi_mask = talloc(tgt, uint16_t);
+
+	**sapi_mask |= (1 << parse_l1_sapi_str(argv[0]));
+	tgt->filter_map |= (1 << LOG_FLT_L1_SAPI);
+
+	return CMD_SUCCESS;
+}
+
+DEFUN(no_logging_fltr_l1_sapi,
+      no_logging_fltr_l1_sapi_cmd,
+      "no " L1_SAPI_CMD_STR,
+      NO_STR LOGGING_STR FILTER_STR L1_SAPI_STR L1_SAPI_ARG_STR)
+{
+	struct log_target *tgt = osmo_log_vty2tgt(vty);
+	uint16_t *sapi_mask;
+
+	if (!tgt)
+		return CMD_WARNING;
+	if (!tgt->filter_data[LOG_FLT_L1_SAPI])
+		return CMD_SUCCESS;
+
+	sapi_mask = (uint16_t *)tgt->filter_data[LOG_FLT_L1_SAPI];
+	*sapi_mask &= ~(1 << parse_l1_sapi_str(argv[0]));
+
+	return CMD_SUCCESS;
+}
+
 int bts_vty_init(struct gsm_bts *bts)
 {
 	cfg_trx_gsmtap_sapi_cmd.string = vty_cmd_string_from_valstr(bts, gsmtap_sapi_names,
@@ -1621,6 +1685,8 @@
 	install_element_ve(&show_ts_cmd);
 	install_element_ve(&show_lchan_cmd);
 	install_element_ve(&show_lchan_summary_cmd);
+	install_element_ve(&logging_fltr_l1_sapi_cmd);
+	install_element_ve(&no_logging_fltr_l1_sapi_cmd);
 
 	logging_vty_add_cmds();
 	osmo_talloc_vty_add_cmds();

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/15550
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I32d86d3d34757135b4cce59919c2fc2b67f0a889
Gerrit-Change-Number: 15550
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190917/8d4ed41b/attachment.htm>


More information about the gerrit-log mailing list