Change in osmo-hlr[master]: vty: enable show subscribers filtered by IMEI

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/.

laforge gerrit-no-reply at lists.osmocom.org
Thu May 13 18:00:43 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/24217 )

Change subject: vty: enable show subscribers filtered by IMEI
......................................................................

vty: enable show subscribers filtered by IMEI

In 89fda3024a0c9a422cc5e5033b016ce0ab6c1ff3 I added a
vty command to show a summary of filtered subscribers by imsi
or msisdn. In practice there is a also need to be able to
filter on IMEI.

The idea here is not to replace every operation that could be
done directly on the sql database in the vty, but this one
is useful.

Change-Id: Ic4a11d3ebcf8909c68e9f4617e94dc822491e008
---
M include/osmocom/hlr/db.h
M src/db.c
M src/db_hlr.c
M src/hlr_vty_subscr.c
M tests/test_nodes.vty
5 files changed, 8 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmocom/hlr/db.h b/include/osmocom/hlr/db.h
index f70df83..a771409 100644
--- a/include/osmocom/hlr/db.h
+++ b/include/osmocom/hlr/db.h
@@ -12,6 +12,7 @@
 	DB_STMT_SEL_ALL_ORDER_LAST_SEEN,
 	DB_STMT_SEL_FILTER_MSISDN,
 	DB_STMT_SEL_FILTER_IMSI,
+	DB_STMT_SEL_FILTER_IMEI,
 	DB_STMT_SEL_FILTER_CS,
 	DB_STMT_SEL_FILTER_PS,
 	DB_STMT_SEL_BY_IMSI,
diff --git a/src/db.c b/src/db.c
index 09a17b6..3a7cf49 100644
--- a/src/db.c
+++ b/src/db.c
@@ -56,6 +56,7 @@
 		"WHERE last_lu_seen IS NOT NULL ORDER BY last_lu_seen;",
 	[DB_STMT_SEL_FILTER_MSISDN] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE msisdn LIKE $search ORDER BY msisdn",
 	[DB_STMT_SEL_FILTER_IMSI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imsi LIKE $search ORDER BY imsi",
+	[DB_STMT_SEL_FILTER_IMEI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imei LIKE $search ORDER BY imei",
 	[DB_STMT_SEL_FILTER_CS] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE nam_cs = $search ORDER BY last_lu_seen",
 	[DB_STMT_SEL_FILTER_PS] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE nam_ps = $search ORDER BY last_lu_seen",
 	[DB_STMT_SEL_BY_IMSI] = "SELECT " SEL_COLUMNS " FROM subscriber WHERE imsi = ?",
diff --git a/src/db_hlr.c b/src/db_hlr.c
index a4c467e..e88b5fc 100644
--- a/src/db_hlr.c
+++ b/src/db_hlr.c
@@ -648,6 +648,8 @@
 
 	if (!filter_type) {
 		stmt = dbc->stmt[DB_STMT_SEL_ALL];
+	} else if (strcmp(filter_type, "imei") == 0) {
+		stmt = dbc->stmt[DB_STMT_SEL_FILTER_IMEI];
 	} else if (strcmp(filter_type, "imsi") == 0) {
 		stmt = dbc->stmt[DB_STMT_SEL_FILTER_IMSI];
 	} else if (strcmp(filter_type, "msisdn") == 0) {
diff --git a/src/hlr_vty_subscr.c b/src/hlr_vty_subscr.c
index ad16045..82e0043 100644
--- a/src/hlr_vty_subscr.c
+++ b/src/hlr_vty_subscr.c
@@ -256,7 +256,7 @@
 #define SUBSCRS_SHOW_HELP "Show all subscribers (with filter possibility)\n"
 
 #define SUBSCR_ID "(imsi|msisdn|id|imei) IDENT"
-#define SUBSCR_FILTER "(imsi|msisdn) FILTER"
+#define SUBSCR_FILTER "(imei|imsi|msisdn) FILTER"
 
 #define SUBSCR_ID_HELP \
 	"Identify subscriber by IMSI\n" \
@@ -307,7 +307,8 @@
       show_subscriber_filtered_cmd,
       "show subscribers " SUBSCR_FILTER,
       SHOW_STR SUBSCRS_SHOW_HELP
-      "Filter Subscribers by IMSI\n" "Filter Subscribers by MSISDN\n" "String to match in msisdn or imsi\n")
+      "Filter Subscribers by IMEI\n" "Filter Subscribers by IMSI\n" "Filter Subscribers by MSISDN\n"
+      "String to match in imei, imsi or msisdn\n")
 {
 	const char *filter_type = argv[0];
 	const char *filter = argv[1];
diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty
index cce5703..bebe9a0 100644
--- a/tests/test_nodes.vty
+++ b/tests/test_nodes.vty
@@ -14,7 +14,7 @@
 ...
   show gsup-connections
   show subscribers all
-  show subscribers (imsi|msisdn) FILTER
+  show subscribers (imei|imsi|msisdn) FILTER
   show subscribers (cs|ps) (on|off)
   show subscribers last-seen
   subscriber (imsi|msisdn|id|imei) IDENT show

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

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: Ic4a11d3ebcf8909c68e9f4617e94dc822491e008
Gerrit-Change-Number: 24217
Gerrit-PatchSet: 3
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210513/e2d773d3/attachment.htm>


More information about the gerrit-log mailing list