aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith <keith@rhizomatica.org>2022-12-16 19:00:31 +0100
committerKeith Whyte <keith@rhizomatica.org>2023-11-22 19:56:48 +0000
commit8e497448db844bcf9f3a4eca723ae1c3b7e5869e (patch)
tree99c22b958c779fe03fc38c5c23c8d6e49b2c087e
parent74bddfaae5961bef7406270355823e56d10e9e90 (diff)
mslookup: Add a flag to not stop on receive age: zero
This allows using the DGSM system to search for duplicate IMSI entries across all HLRs Change-Id: Ic69d6bc9834099ba3a7f3b6f8334b5eac90f2897
-rw-r--r--include/osmocom/mslookup/mslookup_client.h2
-rw-r--r--src/mslookup/mslookup_client.c8
-rw-r--r--src/mslookup/osmo-mslookup-client.c12
3 files changed, 19 insertions, 3 deletions
diff --git a/include/osmocom/mslookup/mslookup_client.h b/include/osmocom/mslookup/mslookup_client.h
index cd0c21f..e2d36a6 100644
--- a/include/osmocom/mslookup/mslookup_client.h
+++ b/include/osmocom/mslookup/mslookup_client.h
@@ -37,6 +37,8 @@ typedef void (*osmo_mslookup_cb_t)(struct osmo_mslookup_client *client,
* This query handling info is not seen by the individual method implementations, to clarify that it is the
* osmo_mslookup_client layer that takes care of these details. */
struct osmo_mslookup_query_handling {
+ bool search_all;
+
/*! Wait at least this long before returning any results.
*
* If nonzero, result_cb will be called as soon as this delay has elapsed, either with the so far youngest age
diff --git a/src/mslookup/mslookup_client.c b/src/mslookup/mslookup_client.c
index ce46296..b87a90f 100644
--- a/src/mslookup/mslookup_client.c
+++ b/src/mslookup/mslookup_client.c
@@ -154,16 +154,20 @@ void osmo_mslookup_client_rx_result(struct osmo_mslookup_client *client, uint32_
if (result->rc != OSMO_MSLOOKUP_RC_RESULT)
return;
+ /* If the client wants to see all results, send this result now */
+ if (req->handling.search_all && result->age > 0)
+ req->handling.result_cb(client, request_handle, &req->query, result);
+
/* If we already stored an earlier successful result, keep that if its age is younger. */
if (req->result.rc == OSMO_MSLOOKUP_RC_RESULT
- && result->age >= req->result.age)
+ && result->age > req->result.age)
return;
req->result = *result;
/* If age == 0, it doesn't get any better, so return the result immediately. */
if (req->result.age == 0) {
- osmo_mslookup_request_send_result(req, true);
+ osmo_mslookup_request_send_result(req, !req->handling.search_all);
return;
}
diff --git a/src/mslookup/osmo-mslookup-client.c b/src/mslookup/osmo-mslookup-client.c
index 37f1256..3546185 100644
--- a/src/mslookup/osmo-mslookup-client.c
+++ b/src/mslookup/osmo-mslookup-client.c
@@ -133,6 +133,10 @@ CSV_HEADERS "\n"
" 1000-5000@sip.voice.123.msisdn Same, but silent for first second\n"
" 10000-@smpp.sms.567.msisdn Return 1 result after 10 seconds\n"
"\n"
+"--search-all -A\n"
+" Do not stop when a response with age of zero comes in.\n"
+" This can be used to \"search\" the entire dGSM network if for\n"
+" example there is a need to track down so-called \"evil twin\" hlr entries.\n"
"--format -f csv (default)\n"
" Format result lines in CSV format.\n"
"--no-csv-headers -H\n"
@@ -196,6 +200,7 @@ enum result_format {
};
static struct {
+ bool search_all;
bool daemon;
struct osmo_sockaddr_str mdns_addr;
uint32_t min_delay;
@@ -628,6 +633,7 @@ void start_query_str(const char *query_str)
const char *domain_str = query_str;
char *at;
struct osmo_mslookup_query_handling h = {
+ .search_all = cmdline_opts.search_all,
.min_wait_milliseconds = cmdline_opts.min_delay,
.result_timeout_milliseconds = cmdline_opts.timeout,
.result_cb = mslookup_result_cb,
@@ -730,6 +736,7 @@ int main(int argc, char **argv)
int option_index = 0;
static struct option long_options[] = {
+ { "search-all", 0, 0, 'A' },
{ "format", 1, 0, 'f' },
{ "no-csv-headers", 0, 0, 'H' },
{ "daemon", 0, 0, 'd' },
@@ -755,12 +762,15 @@ int main(int argc, char **argv)
} \
} while (0)
- c = getopt_long(argc, argv, "f:Hdm:M:D:t:T:s:SqhV", long_options, &option_index);
+ c = getopt_long(argc, argv, "Af:Hdm:M:D:t:T:s:SqhV", long_options, &option_index);
if (c == -1)
break;
switch (c) {
+ case 'A':
+ cmdline_opts.search_all = true;
+ break;
case 'f':
cmdline_opts.format_str = optarg;
break;