aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith <keith@rhizomatica.org>2021-05-07 05:59:21 +0200
committerlaforge <laforge@osmocom.org>2021-05-13 18:00:43 +0000
commitca8e6efca611c955f62981ea4ff2316e5a8cc794 (patch)
treec4b0b2da87667bf1e8e782d5dd7fc762be4c4abb
parented2e36316b4a7d2f9180187df903fb82065a9133 (diff)
vty: enable show subscribers filtered by IMEIHEADmaster
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
-rw-r--r--include/osmocom/hlr/db.h1
-rw-r--r--src/db.c1
-rw-r--r--src/db_hlr.c2
-rw-r--r--src/hlr_vty_subscr.c5
-rw-r--r--tests/test_nodes.vty2
5 files changed, 8 insertions, 3 deletions
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 @@ enum stmt_idx {
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 @@ static const char *stmt_sql[] = {
"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 @@ int db_subscrs_get(struct db_context *dbc, const char *filter_type, const char *
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 @@ static int get_subscrs(struct vty *vty, const char *filter_type, const char *fil
#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 @@ DEFUN(show_subscriber_filtered,
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 @@ OsmoHLR> list
...
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