Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 1 | #include <osmocom/core/msgb.h> |
| 2 | #include <osmocom/ranap/ranap_ies_defs.h> |
| 3 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 4 | #include "hnb-test-layers.h" |
| 5 | |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 6 | static const char *printstr(OCTET_STRING_t *s) |
| 7 | { |
Neels Hofmeyr | c164a97 | 2016-02-29 09:25:46 +0100 | [diff] [blame] | 8 | return osmo_hexdump((char*)s->buf, s->size); |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 9 | } |
| 10 | |
| 11 | #define PP(octet_string_t) \ |
| 12 | printf(#octet_string_t " = %s\n",\ |
| 13 | printstr(&octet_string_t)) |
| 14 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 15 | void hnb_test_rua_dt_handle_ranap(struct hnb_test *hnb, |
| 16 | struct ranap_message_s *ranap_msg) |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 17 | { |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 18 | int len; |
| 19 | char *data; |
Neels Hofmeyr | 4a0a69a | 2016-04-19 00:06:28 +0200 | [diff] [blame] | 20 | RANAP_PermittedIntegrityProtectionAlgorithms_t *algs; |
| 21 | RANAP_IntegrityProtectionAlgorithm_t *first_alg; |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 22 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 23 | printf("rx ranap_msg->procedureCode %d\n", |
| 24 | ranap_msg->procedureCode); |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 25 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 26 | 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 Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 31 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 32 | len = ranap_msg->msg.directTransferIEs.nas_pdu.size; |
| 33 | data = ranap_msg->msg.directTransferIEs.nas_pdu.buf; |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 34 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 35 | hnb_test_nas_rx_dtap(hnb, data, len); |
| 36 | return; |
Neels Hofmeyr | 4a0a69a | 2016-04-19 00:06:28 +0200 | [diff] [blame] | 37 | |
| 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 Hofmeyr | bde4d3b | 2016-04-19 02:38:16 +0200 | [diff] [blame] | 53 | |
| 54 | case RANAP_ProcedureCode_id_Iu_Release: |
| 55 | hnb_test_rx_iu_release(hnb); |
| 56 | return; |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 57 | } |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 58 | } |
Neels Hofmeyr | 5ad72b9 | 2016-04-19 18:09:05 +0200 | [diff] [blame] | 59 | |
| 60 | void hnb_test_rua_cl_handle_ranap(struct hnb_test *hnb, |
| 61 | struct ranap_message_s *ranap_msg) |
| 62 | { |
| 63 | char imsi[16]; |
| 64 | |
| 65 | printf("rx ranap_msg->procedureCode %d\n", |
| 66 | ranap_msg->procedureCode); |
| 67 | |
| 68 | switch (ranap_msg->procedureCode) { |
| 69 | case RANAP_ProcedureCode_id_Paging: |
| 70 | if (ranap_msg->msg.pagingIEs.permanentNAS_UE_ID.present == RANAP_PermanentNAS_UE_ID_PR_iMSI) { |
| 71 | ranap_bcd_decode(imsi, sizeof(imsi), |
| 72 | ranap_msg->msg.pagingIEs.permanentNAS_UE_ID.choice.iMSI.buf, |
| 73 | ranap_msg->msg.pagingIEs.permanentNAS_UE_ID.choice.iMSI.size); |
| 74 | } else imsi[0] = '\0'; |
| 75 | |
| 76 | printf("rx Paging: presence=%hx domain=%d IMSI=%s\n", |
| 77 | ranap_msg->msg.pagingIEs.presenceMask, |
| 78 | ranap_msg->msg.pagingIEs.cN_DomainIndicator, |
| 79 | imsi |
| 80 | ); |
| 81 | |
| 82 | hnb_test_rx_paging(hnb, imsi); |
| 83 | return; |
| 84 | } |
| 85 | } |