aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-09 01:39:56 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-30 14:10:39 +0200
commit3588810cb779274b5536263120be7796d41f69db (patch)
tree46b482bf8556167ea0b9d8fa07ee9feb494edc67 /src/tests
parent5dbb7b2c3fb0eaf357acf23b302167778f8d150d (diff)
hnb-test: answer MM Authentication Request
With hardcoded SRES matching the hardcoded auth tuple in openbsc's sysmocom/iu branch for testing.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/hnb-test.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c
index e64d077..a3c958d 100644
--- a/src/tests/hnb-test.c
+++ b/src/tests/hnb-test.c
@@ -209,6 +209,17 @@ static struct msgb *gen_nas_tmsi_realloc_compl()
return ranap_new_msg_dt(0, id_resp, sizeof(id_resp));
}
+static struct msgb *gen_nas_auth_resp()
+{
+ uint8_t id_resp[] = {
+ GSM48_PDISC_MM,
+ GSM48_MT_MM_AUTH_RESP,
+ 0x61, 0xb5, 0x69, 0xf5 /* hardcoded SRES */
+ };
+
+ return ranap_new_msg_dt(0, id_resp, sizeof(id_resp));
+}
+
static int hnb_test_nas_tx_dt(struct hnb_test *hnb, struct msgb *txm)
{
struct hnbtest_chan *chan;
@@ -313,6 +324,33 @@ void hnb_test_nas_rx_mm_info(struct msgb *rxm)
}
}
+static void hnb_test_nas_rx_auth_req(struct msgb *rxm)
+{
+ struct gsm48_hdr *gh;
+ struct gsm48_auth_req *ar;
+ int parse_res;
+ int length = msgb_l3len(rxm);
+
+ if (length < sizeof(*gh)) {
+ printf("GSM48 header does not fit.\n");
+ return;
+ }
+
+ gh = (struct gsm48_hdr *) msgb_l3(rxm);
+ length -= (const char *)&gh->data[0] - (const char *)gh;
+
+ if (length < sizeof(*ar)) {
+ printf("GSM48 Auth Req does not fit.\n");
+ return;
+ }
+
+ printf(" :) Authentication Request :)\n");
+
+ ar = (struct gsm48_auth_req*) &gh->data[0];
+ int seq = ar->key_seq;
+ printf("seq %d rand %s\n", seq, osmo_hexdump(ar->rand, sizeof(ar->rand)));
+}
+
static int hnb_test_nas_rx_mm(struct hnb_test *hnb, struct msgb *rxm)
{
struct hnbtest_chan *chan;
@@ -349,6 +387,10 @@ static int hnb_test_nas_rx_mm(struct hnb_test *hnb, struct msgb *rxm)
hnb_test_nas_rx_mm_info(rxm);
return 0;
+ case GSM48_MT_MM_AUTH_REQ:
+ hnb_test_nas_rx_auth_req(rxm);
+ return hnb_test_nas_tx_dt(hnb, gen_nas_auth_resp());
+
default:
printf("04.08 message type not handled by hnb-test: 0x%x\n",
msg_type);