gprs/test: Add Detach messages to test
This patch adds a Detach Request (MO) / Detach Accept sequence to the
test, followed by another (here invalid) Act PDP Context Req which
should be APN patched.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c
index 75dc173..a0c202a 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.c
+++ b/openbsc/tests/gbproxy/gbproxy_test.c
@@ -124,6 +124,29 @@
0x00, 0x5a, 0xff, 0x02
};
+/* Base Station Subsystem GPRS Protocol: GSM A-I/F DTAP - Detach Request */
+static const unsigned char bssgp_detach_req[44] = {
+ 0x01, 0xef, 0xe2, 0xb7, 0x00, 0x00, 0x00, 0x04,
+ 0x08, 0x88, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60,
+ 0x75, 0x30, 0x00, 0x80, 0x0e, 0x00, 0x15, 0x01,
+ 0xc0, 0x19, 0x08, 0x05, 0x01, 0x18, 0x05, 0xf4,
+ 0xef, 0xe2, 0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97,
+ 0xcb, 0x7e, 0xe1, 0x41
+};
+
+/* Base Station Subsystem GPRS Protocol: GSM A-I/F DTAP - Detach Accept */
+static const unsigned char bssgp_detach_acc[67] = {
+ 0x00, 0xef, 0xe2, 0xb7, 0x00, 0x00, 0x50, 0x20,
+ 0x16, 0x82, 0x02, 0x58, 0x13, 0x99, 0x18, 0xb3,
+ 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60, 0x80,
+ 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba,
+ 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80, 0x00, 0x0a,
+ 0x82, 0x08, 0x02, 0x0d, 0x88, 0x11, 0x12, 0x13,
+ 0x14, 0x15, 0x16, 0x17, 0x18, 0x00, 0x81, 0x00,
+ 0x0e, 0x89, 0x41, 0xc0, 0x15, 0x08, 0x06, 0x00,
+ 0xf7, 0x35, 0xf0
+};
+
static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text,
struct sockaddr_in *peer, const unsigned char* data,
size_t data_len);
@@ -882,11 +905,22 @@
&bss_peer[0], 0x1002,
bssgp_act_pdp_ctx_req, sizeof(bssgp_act_pdp_ctx_req));
+ /* Detach */
+ send_ns_unitdata(nsi, "DETACH REQ", &bss_peer[0], 0x1002,
+ bssgp_detach_req, sizeof(bssgp_detach_req));
+
+ send_ns_unitdata(nsi, "DETACH ACC", &sgsn_peer, 0x1002,
+ bssgp_detach_acc, sizeof(bssgp_detach_acc));
+
gbprox_dump_global(stdout, 0);
gbprox_dump_peers(stdout, 0);
printf("--- Bad cases ---\n\n");
+ printf("TLLI is already detached, shouldn't patch (expected failure)\n");
+ send_ns_unitdata(nsi, "ACT PDP CTX REQ", &bss_peer[0], 0x1002,
+ bssgp_act_pdp_ctx_req, sizeof(bssgp_act_pdp_ctx_req));
+
send_bssgp_reset_ack(nsi, &sgsn_peer, 0x1eee);
send_bssgp_suspend_ack(nsi, &sgsn_peer, &rai_unknown);