hnb-test: add Security Mode Command handling
diff --git a/src/tests/hnb-test-layers.h b/src/tests/hnb-test-layers.h
index 4b17461..7ab273a 100644
--- a/src/tests/hnb-test-layers.h
+++ b/src/tests/hnb-test-layers.h
@@ -13,3 +13,4 @@
/* RANAP calls main with actual payload*/
void hnb_test_nas_rx_dtap(struct hnb_test *hnb, void *data, int len);
+void hnb_test_rx_secmode_cmd(struct hnb_test *hnb, long ip_alg);
diff --git a/src/tests/hnb-test-ranap.c b/src/tests/hnb-test-ranap.c
index 63e3d92..4986e98 100644
--- a/src/tests/hnb-test-ranap.c
+++ b/src/tests/hnb-test-ranap.c
@@ -17,6 +17,8 @@
{
int len;
char *data;
+ RANAP_PermittedIntegrityProtectionAlgorithms_t *algs;
+ RANAP_IntegrityProtectionAlgorithm_t *first_alg;
printf("rx ranap_msg->procedureCode %d\n",
ranap_msg->procedureCode);
@@ -32,5 +34,21 @@
hnb_test_nas_rx_dtap(hnb, data, len);
return;
+
+ case RANAP_ProcedureCode_id_SecurityModeControl:
+ printf("rx SecurityModeControl: presence = %hx\n",
+ ranap_msg->msg.securityModeCommandIEs.presenceMask);
+
+ /* Just pick the first available IP alg, don't care about
+ * encryption (yet?) */
+ algs = &ranap_msg->msg.securityModeCommandIEs.integrityProtectionInformation.permittedAlgorithms;
+ if (algs->list.count < 1) {
+ printf("Security Mode Command: No permitted algorithms.\n");
+ return;
+ }
+ first_alg = *algs->list.array;
+
+ hnb_test_rx_secmode_cmd(hnb, *first_alg);
+ return;
}
}
diff --git a/src/tests/hnb-test.c b/src/tests/hnb-test.c
index 9af5085..603f63b 100644
--- a/src/tests/hnb-test.c
+++ b/src/tests/hnb-test.c
@@ -432,6 +432,13 @@
}
}
+void hnb_test_rx_secmode_cmd(struct hnb_test *hnb, long ip_alg)
+{
+ printf(" :) Security Mode Command :)\n");
+ /* not caring about encryption yet, just pass 0 for No Encryption. */
+ hnb_test_tx_dt(hnb, ranap_new_msg_sec_mod_compl(ip_alg, 0));
+}
+
int hnb_test_hnbap_rx(struct hnb_test *hnb, struct msgb *msg)
{
HNBAP_PDU_t _pdu, *pdu = &_pdu;