aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/gbproxy/gbproxy_test.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-02 14:40:11 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2014-09-09 10:09:50 +0200
commitea1698e32203de923ce40b7cf13027b5a9254760 (patch)
tree64aa081326f5adfcc421b67dd5be7ed40a2808d3 /openbsc/tests/gbproxy/gbproxy_test.c
parentb1ee5cd3b65be7e462bc0eccc2931478483c49e5 (diff)
gbproxy/test: Add test cases for IMSI acquisition
If the Attach Request procedure gets restarted e.g. because of a lost message, all of these messages are stored if IMSI acquisition is in progress. This patch adds a test for this case and modifies the dump_peers function to output the number of stored messages. Note that the number of stored messages currently increases with each (repeatedly) received Attach Request which is not the desired behaviour. Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/tests/gbproxy/gbproxy_test.c')
-rw-r--r--openbsc/tests/gbproxy/gbproxy_test.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c
index 9d5b84969..6fd54857f 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.c
+++ b/openbsc/tests/gbproxy/gbproxy_test.c
@@ -121,6 +121,11 @@ static int dump_peers(FILE *stream, int indent, time_t now,
llist_for_each_entry(tlli_info, &state->enabled_tllis, list) {
char mi_buf[200];
time_t age = now ? now - tlli_info->timestamp : 0;
+ int stored_msgs = 0;
+ struct llist_head *iter;
+ llist_for_each(iter, &tlli_info->stored_msgs)
+ stored_msgs++;
+
if (tlli_info->mi_data_len > 0) {
snprintf(mi_buf, sizeof(mi_buf), "(invalid)");
gsm48_mi_to_string(mi_buf, sizeof(mi_buf),
@@ -143,15 +148,15 @@ static int dump_peers(FILE *stream, int indent, time_t now,
fprintf(stream, ", IMSI %s, AGE %d",
mi_buf, (int)age);
+ if (stored_msgs)
+ fprintf(stream, ", STORED %d", stored_msgs);
+
if (cfg->check_imsi && tlli_info->enable_patching)
fprintf(stream, ", IMSI matches");
if (tlli_info->imsi_acq_pending)
fprintf(stream, ", IMSI acquisition in progress");
- if (!llist_empty(&tlli_info->stored_msgs))
- fprintf(stream, ", stored messages");
-
rc = fprintf(stream, "\n");
if (rc < 0)
return rc;
@@ -2036,6 +2041,20 @@ static void test_gbproxy_imsi_acquisition()
dump_peers(stdout, 0, 0, &gbcfg);
+ /* Special case: Repeated Attach Requests */
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ send_llc_ul_ui(nsi, "ATTACH REQUEST", &bss_peer[0], 0x1002,
+ foreign_bss_tlli, &rai_unknown, cell_id,
+ GPRS_SAPI_GMM, bss_nu++,
+ dtap_attach_req, sizeof(dtap_attach_req));
+
+ dump_peers(stdout, 0, 0, &gbcfg);
+
dump_global(stdout, 0);
gbprox_reset(&gbcfg);