gbproxy: Add test program to test gbproxy message handling

This program tests the gbproxy implementation by passing NS messages
to a modified gbproxy that dumps the resulting messages, signals, and
state.

It focusses on testing abnormal situations like port changes.

Ticket: OW#874
Sponsored-by: On-Waves ehf
diff --git a/openbsc/tests/gbproxy/gbproxy_test.ok b/openbsc/tests/gbproxy/gbproxy_test.ok
new file mode 100644
index 0000000..0835921
--- /dev/null
+++ b/openbsc/tests/gbproxy/gbproxy_test.ok
@@ -0,0 +1,359 @@
+===== NS protocol test START
+--- Initialise BSS 1 ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 10 01 04 82 10 00 
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS, msg length 9
+03 01 82 10 01 04 82 10 00 
+
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a 
+
+MESSAGE to BSS, msg length 1
+0b 
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06 
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:1111
+
+MESSAGE to BSS, msg length 1
+07 
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b 
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:1111, BVCI 0x1002(4098)
+
+PROCESSING UNITDATA from 0x01020304:1111
+00 00 00 00 22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 
+
+CALLBACK, event 0, msg length 22, bvci 0x0000
+22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22
+22 04 82 10 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 
+
+result (UNITDATA) = 0
+
+Current NS-VCIs:
+    VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+
+Peers:
+  NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96
+--- Initialise BSS 2 ---
+
+Setup NS-VC: remote 0x01020304:2222, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:2222
+02 00 81 01 01 82 20 01 04 82 20 00 
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:2222
+
+MESSAGE to BSS, msg length 9
+03 01 82 20 01 04 82 20 00 
+
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:2222
+0a 
+
+MESSAGE to BSS, msg length 1
+0b 
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:2222
+06 
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:2222
+
+MESSAGE to BSS, msg length 1
+07 
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:2222
+0b 
+
+result (ALIVE_ACK) = 0
+
+Setup BSSGP: remote 0x01020304:2222, BVCI 0x2002(8194)
+
+PROCESSING UNITDATA from 0x01020304:2222
+00 00 00 00 22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 
+
+CALLBACK, event 0, msg length 22, bvci 0x0000
+22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 
+
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 22
+22 04 82 20 02 07 81 08 08 88 10 20 30 40 50 60 10 00 00 00 00 00 
+
+result (UNITDATA) = 0
+
+Current NS-VCIs:
+    VCI 0x2001, NSEI 0x2000, peer 0x01020304:2222
+    VCI 0x1001, NSEI 0x1000, peer 0x01020304:1111
+
+Peers:
+  NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96
+  NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96
+--- Move BSS 1 to new port ---
+
+Setup NS-VC: remote 0x01020304:3333, NSVCI 0x1001(4097), NSEI 0x1000(4096)
+
+PROCESSING RESET from 0x01020304:3333
+02 00 81 01 01 82 10 01 04 82 10 00 
+
+==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:3333
+
+MESSAGE to BSS, msg length 9
+03 01 82 10 01 04 82 10 00 
+
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:3333
+0a 
+
+MESSAGE to BSS, msg length 1
+0b 
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:3333
+06 
+
+==> got signal NS_UNBLOCK, NS-VC 0x1001/1.2.3.4:3333
+
+MESSAGE to BSS, msg length 1
+07 
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:3333
+0b 
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+    VCI 0x2001, NSEI 0x2000, peer 0x01020304:2222
+    VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+
+Peers:
+  NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96
+  NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96
+--- Move BSS 2 to former BSS 1 port ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 20 01 04 82 20 00 
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS, msg length 9
+03 01 82 20 01 04 82 20 00 
+
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a 
+
+MESSAGE to BSS, msg length 1
+0b 
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06 
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS, msg length 1
+07 
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b 
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+    VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
+    VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+
+Peers:
+  NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96
+  NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96
+--- Move BSS 1 to current BSS 2 port ---
+
+Setup NS-VC: remote 0x01020304:1111, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:1111
+02 00 81 01 01 82 20 01 04 82 20 00 
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS, msg length 9
+03 01 82 20 01 04 82 20 00 
+
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:1111
+0a 
+
+MESSAGE to BSS, msg length 1
+0b 
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:1111
+06 
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:1111
+
+MESSAGE to BSS, msg length 1
+07 
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:1111
+0b 
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+    VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
+    VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+
+Peers:
+  NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96
+  NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96
+--- Move BSS 2 to new port ---
+
+Setup NS-VC: remote 0x01020304:4444, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:4444
+02 00 81 01 01 82 20 01 04 82 20 00 
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:4444
+
+MESSAGE to BSS, msg length 9
+03 01 82 20 01 04 82 20 00 
+
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:4444
+0a 
+
+MESSAGE to BSS, msg length 1
+0b 
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:4444
+06 
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:4444
+
+MESSAGE to BSS, msg length 1
+07 
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:4444
+0b 
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+    VCI 0x2001, NSEI 0x2000, peer 0x01020304:4444
+    VCI 0x1001, NSEI 0x1000, peer 0x01020304:3333
+
+Peers:
+  NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96
+  NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96
+--- Move BSS 2 to former BSS 1 port ---
+
+Setup NS-VC: remote 0x01020304:3333, NSVCI 0x2001(8193), NSEI 0x2000(8192)
+
+PROCESSING RESET from 0x01020304:3333
+02 00 81 01 01 82 20 01 04 82 20 00 
+
+==> got signal NS_REPLACED: 0x2001/1.2.3.4:4444 -> 0x1001/1.2.3.4:3333
+
+==> got signal NS_RESET, NS-VC 0x2001/1.2.3.4:3333
+
+MESSAGE to BSS, msg length 9
+03 01 82 20 01 04 82 20 00 
+
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET) = 9
+
+PROCESSING ALIVE from 0x01020304:3333
+0a 
+
+MESSAGE to BSS, msg length 1
+0b 
+
+result (ALIVE) = 1
+
+PROCESSING UNBLOCK from 0x01020304:3333
+06 
+
+==> got signal NS_UNBLOCK, NS-VC 0x2001/1.2.3.4:3333
+
+MESSAGE to BSS, msg length 1
+07 
+
+result (UNBLOCK) = 1
+
+PROCESSING ALIVE_ACK from 0x01020304:3333
+0b 
+
+result (ALIVE_ACK) = 0
+
+Current NS-VCIs:
+    VCI 0x2001, NSEI 0x2000, peer 0x01020304:3333
+         NS-VC replaced other count: 1
+    VCI 0x1001, NSEI 0x1000, peer 0x00000000:0
+
+Peers:
+  NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96
+  NSEI 4096, BVCI 4098, not blocked, RAC 10-32-16464-96
+===== NS protocol test END
+