gbproxy: Pass tlli_info around
This patch modifies the code to pass a pointer to the tlli_info
around once it has been acquired. To achieve this,
gbprox_register_tlli() and gbprox_update_state() are modified to
return it (if it has been found or created), and gbprox_patch_llc(),
gbprox_patch_bssgp(), and gbprox_update_state_after() are modified to
take it as parameter.
Add a new function gbprox_touch_tlli() to update timestamp and list
ordering for existing tlli_infos.
The motivation behind this patch is to make the tlli_info available to
the patching code and to avoid repeated searches for the same TLLI.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c
index f1c24f9..cca5094 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.c
+++ b/openbsc/tests/gbproxy/gbproxy_test.c
@@ -1358,12 +1358,18 @@
OSMO_ASSERT(peer->patch_state.enabled_tllis_count == 0);
printf(" Add TLLI 1, IMSI 1\n");
- gbprox_register_tlli(peer, tlli1, imsi1, ARRAY_SIZE(imsi1), now);
+ tlli_info = gbprox_register_tlli(peer, tlli1,
+ imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(tlli_info);
+ OSMO_ASSERT(tlli_info->tlli == tlli1);
OSMO_ASSERT(peer->patch_state.enabled_tllis_count == 1);
/* replace the old entry */
printf(" Add TLLI 2, IMSI 1 (should replace TLLI 1)\n");
- gbprox_register_tlli(peer, tlli2, imsi1, ARRAY_SIZE(imsi1), now);
+ tlli_info = gbprox_register_tlli(peer, tlli2,
+ imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(tlli_info);
+ OSMO_ASSERT(tlli_info->tlli == tlli2);
OSMO_ASSERT(peer->patch_state.enabled_tllis_count == 1);
dump_peers(stdout, 2, now, &cfg);
@@ -1391,12 +1397,18 @@
OSMO_ASSERT(peer->patch_state.enabled_tllis_count == 0);
printf(" Add TLLI 1, IMSI 1\n");
- gbprox_register_tlli(peer, tlli1, imsi1, ARRAY_SIZE(imsi1), now);
+ tlli_info = gbprox_register_tlli(peer, tlli1,
+ imsi1, ARRAY_SIZE(imsi1), now);
+ OSMO_ASSERT(tlli_info);
+ OSMO_ASSERT(tlli_info->tlli == tlli1);
OSMO_ASSERT(peer->patch_state.enabled_tllis_count == 1);
/* try to replace the old entry */
printf(" Add TLLI 1, IMSI 2 (should replace IMSI 1)\n");
- gbprox_register_tlli(peer, tlli1, imsi2, ARRAY_SIZE(imsi2), now);
+ tlli_info = gbprox_register_tlli(peer, tlli1,
+ imsi2, ARRAY_SIZE(imsi2), now);
+ OSMO_ASSERT(tlli_info);
+ OSMO_ASSERT(tlli_info->tlli == tlli1);
OSMO_ASSERT(peer->patch_state.enabled_tllis_count == 1);
dump_peers(stdout, 2, now, &cfg);