gbproxy: Track TLLI even when the IMSI is not known

Currently only TLLIs for which it is known that they may be patched
are put into the TLLI list.

This patch changes this to add TLLIs even when the IMSI is not yet
known. A enable_patching flag is added to the gbproxy_tlli_info
structure to control patching.

Note that this puts every active TLLI into the list where accesses
are O(N) currently.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c
index 769dc67..229d2d4 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.c
+++ b/openbsc/tests/gbproxy/gbproxy_test.c
@@ -116,10 +116,14 @@
 		llist_for_each_entry(tlli_info, &state->enabled_tllis, list) {
 			char mi_buf[200];
 			time_t age = now - tlli_info->timestamp;
-			snprintf(mi_buf, sizeof(mi_buf), "(invalid)");
-			gsm48_mi_to_string(mi_buf, sizeof(mi_buf),
-					   tlli_info->mi_data,
-					   tlli_info->mi_data_len);
+			if (tlli_info->mi_data_len > 0) {
+				snprintf(mi_buf, sizeof(mi_buf), "(invalid)");
+				gsm48_mi_to_string(mi_buf, sizeof(mi_buf),
+						   tlli_info->mi_data,
+						   tlli_info->mi_data_len);
+			} else {
+				snprintf(mi_buf, sizeof(mi_buf), "(none)");
+			}
 			rc = fprintf(stream,
 				     "%*s      TLLI %08x, IMSI %s, AGE %d\n",
 				     indent, "",
diff --git a/openbsc/tests/gbproxy/gbproxy_test.ok b/openbsc/tests/gbproxy/gbproxy_test.ok
index ee67c33..4553648 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.ok
+++ b/openbsc/tests/gbproxy/gbproxy_test.ok
@@ -1807,8 +1807,9 @@
     RAID patched              (SGSN): 3
     APN patched                     : 3
     Attach Request count            : 1
-    TLLI cache size                 : 1
-    TLLI-Cache: 1
+    TLLI cache size                 : 2
+    TLLI-Cache: 2
+      TLLI efe2b700, IMSI (none), AGE 0
       TLLI efe28117, IMSI 12131415161718, AGE 0
 PROCESSING DETACH REQ from 0x01020304:1111
 00 00 10 02 01 ef e2 b7 00 00 00 04 08 88 11 22 33 40 50 60 75 30 00 80 0e 00 15 01 c0 19 08 05 01 18 05 f4 ef e2 b7 00 19 03 b9 97 cb 7e e1 41 
@@ -1841,7 +1842,9 @@
     RAID patched              (SGSN): 3
     APN patched                     : 3
     Attach Request count            : 1
-    TLLI-Cache: 0
+    TLLI cache size                 : 1
+    TLLI-Cache: 1
+      TLLI efe28117, IMSI 12131415161718, AGE 0
 --- Bad cases ---
 
 TLLI is already detached, shouldn't patch
@@ -1879,7 +1882,10 @@
     RAID patched              (SGSN): 3
     APN patched                     : 3
     Attach Request count            : 1
-    TLLI-Cache: 0
+    TLLI cache size                 : 2
+    TLLI-Cache: 2
+      TLLI efe2b700, IMSI (none), AGE 0
+      TLLI efe28117, IMSI 12131415161718, AGE 0
 Test TLLI info expiry
 
 Test TLLI replacement: