blob: 4986e98f02a18a62f5ec595c09203c8b637f8f93 [file] [log] [blame]
Neels Hofmeyrb984f362016-02-18 01:18:20 +01001#include <osmocom/core/msgb.h>
2#include <osmocom/ranap/ranap_ies_defs.h>
3
Neels Hofmeyr4470f932016-04-19 00:13:53 +02004#include "hnb-test-layers.h"
5
Neels Hofmeyrb984f362016-02-18 01:18:20 +01006static const char *printstr(OCTET_STRING_t *s)
7{
Neels Hofmeyrc164a972016-02-29 09:25:46 +01008 return osmo_hexdump((char*)s->buf, s->size);
Neels Hofmeyrb984f362016-02-18 01:18:20 +01009}
10
11#define PP(octet_string_t) \
12 printf(#octet_string_t " = %s\n",\
13 printstr(&octet_string_t))
14
Neels Hofmeyr4470f932016-04-19 00:13:53 +020015void hnb_test_rua_dt_handle_ranap(struct hnb_test *hnb,
16 struct ranap_message_s *ranap_msg)
Neels Hofmeyrb984f362016-02-18 01:18:20 +010017{
Neels Hofmeyr4470f932016-04-19 00:13:53 +020018 int len;
19 char *data;
Neels Hofmeyr4a0a69a2016-04-19 00:06:28 +020020 RANAP_PermittedIntegrityProtectionAlgorithms_t *algs;
21 RANAP_IntegrityProtectionAlgorithm_t *first_alg;
Neels Hofmeyrb984f362016-02-18 01:18:20 +010022
Neels Hofmeyr4470f932016-04-19 00:13:53 +020023 printf("rx ranap_msg->procedureCode %d\n",
24 ranap_msg->procedureCode);
Neels Hofmeyrb984f362016-02-18 01:18:20 +010025
Neels Hofmeyr4470f932016-04-19 00:13:53 +020026 switch (ranap_msg->procedureCode) {
27 case RANAP_ProcedureCode_id_DirectTransfer:
28 printf("rx DirectTransfer: presence = %hx\n",
29 ranap_msg->msg.directTransferIEs.presenceMask);
30 PP(ranap_msg->msg.directTransferIEs.nas_pdu);
Neels Hofmeyrb984f362016-02-18 01:18:20 +010031
Neels Hofmeyr4470f932016-04-19 00:13:53 +020032 len = ranap_msg->msg.directTransferIEs.nas_pdu.size;
33 data = ranap_msg->msg.directTransferIEs.nas_pdu.buf;
Neels Hofmeyrb984f362016-02-18 01:18:20 +010034
Neels Hofmeyr4470f932016-04-19 00:13:53 +020035 hnb_test_nas_rx_dtap(hnb, data, len);
36 return;
Neels Hofmeyr4a0a69a2016-04-19 00:06:28 +020037
38 case RANAP_ProcedureCode_id_SecurityModeControl:
39 printf("rx SecurityModeControl: presence = %hx\n",
40 ranap_msg->msg.securityModeCommandIEs.presenceMask);
41
42 /* Just pick the first available IP alg, don't care about
43 * encryption (yet?) */
44 algs = &ranap_msg->msg.securityModeCommandIEs.integrityProtectionInformation.permittedAlgorithms;
45 if (algs->list.count < 1) {
46 printf("Security Mode Command: No permitted algorithms.\n");
47 return;
48 }
49 first_alg = *algs->list.array;
50
51 hnb_test_rx_secmode_cmd(hnb, *first_alg);
52 return;
Neels Hofmeyr4470f932016-04-19 00:13:53 +020053 }
Neels Hofmeyrb984f362016-02-18 01:18:20 +010054}