Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 1 | /* Test HNB */ |
| 2 | |
| 3 | /* (C) 2015 by Daniel Willmann <dwillmann@sysmocom.de> |
| 4 | * (C) 2015 by Sysmocom s.f.m.c. GmbH |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU Affero General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU Affero General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Affero General Public License |
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <unistd.h> |
| 23 | #include <stdio.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <string.h> |
| 26 | #include <getopt.h> |
| 27 | #include <errno.h> |
| 28 | #include <signal.h> |
| 29 | |
| 30 | #include <sys/types.h> |
| 31 | #include <sys/socket.h> |
| 32 | #include <netinet/in.h> |
| 33 | #include <netinet/sctp.h> |
| 34 | #include <arpa/inet.h> |
| 35 | |
| 36 | #include <osmocom/core/application.h> |
| 37 | #include <osmocom/core/talloc.h> |
| 38 | #include <osmocom/core/select.h> |
| 39 | #include <osmocom/core/logging.h> |
| 40 | #include <osmocom/core/socket.h> |
| 41 | #include <osmocom/core/msgb.h> |
| 42 | #include <osmocom/core/write_queue.h> |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 43 | #include <osmocom/netif/stream.h> |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 44 | #include <osmocom/gsm/tlv.h> |
| 45 | #include <osmocom/gsm/gsm48.h> |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 46 | |
| 47 | #include <osmocom/vty/telnet_interface.h> |
| 48 | #include <osmocom/vty/logging.h> |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 49 | #include <osmocom/vty/command.h> |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 50 | |
Neels Hofmeyr | 26779f8 | 2016-04-18 17:04:17 +0200 | [diff] [blame] | 51 | #include <osmocom/crypt/auth.h> |
| 52 | |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 53 | #include "hnb-test.h" |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 54 | #include "hnb-test-layers.h" |
Daniel Willmann | a1e202e | 2015-12-07 17:21:07 +0100 | [diff] [blame] | 55 | #include "hnbap_common.h" |
| 56 | #include "hnbap_ies_defs.h" |
Harald Welte | b66c5d0 | 2016-01-03 18:04:28 +0100 | [diff] [blame] | 57 | #include "rua_msg_factory.h" |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 58 | #include "asn1helpers.h" |
Neels Hofmeyr | 96979af | 2016-01-05 15:19:44 +0100 | [diff] [blame] | 59 | #include <osmocom/ranap/iu_helpers.h> |
Harald Welte | 87ffeb9 | 2015-12-25 15:34:22 +0100 | [diff] [blame] | 60 | #include "test_common.h" |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 61 | |
Neels Hofmeyr | 96979af | 2016-01-05 15:19:44 +0100 | [diff] [blame] | 62 | #include <osmocom/ranap/ranap_msg_factory.h> |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 63 | |
Neels Hofmeyr | 0968a58 | 2016-01-11 15:19:38 +0100 | [diff] [blame] | 64 | #include <osmocom/rua/RUA_RUA-PDU.h> |
| 65 | |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 66 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
| 67 | |
| 68 | #include <osmocom/ranap/RANAP_ProcedureCode.h> |
| 69 | #include <osmocom/ranap/RANAP_Criticality.h> |
| 70 | #include <osmocom/ranap/RANAP_DirectTransfer.h> |
| 71 | |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 72 | static void *tall_hnb_ctx; |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 73 | |
| 74 | struct hnb_test g_hnb_test = { |
Neels Hofmeyr | 5f9be1e | 2016-02-29 13:33:44 +0100 | [diff] [blame] | 75 | .gw_addr = "127.0.0.1", |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 76 | .gw_port = IUH_DEFAULT_SCTP_PORT, |
| 77 | }; |
| 78 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 79 | struct msgb *rua_new_udt(struct msgb *inmsg); |
| 80 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 81 | static int hnb_test_ue_de_register_tx(struct hnb_test *hnb_test) |
Daniel Willmann | 19dedbb | 2015-12-17 11:57:41 +0100 | [diff] [blame] | 82 | { |
| 83 | struct msgb *msg; |
| 84 | int rc, imsi_len; |
| 85 | uint32_t ctx_id; |
| 86 | |
| 87 | UEDe_Register_t dereg; |
| 88 | UEDe_RegisterIEs_t dereg_ies; |
| 89 | memset(&dereg_ies, 0, sizeof(dereg_ies)); |
| 90 | |
| 91 | asn1_u24_to_bitstring(&dereg_ies.context_ID, &ctx_id, hnb_test->ctx_id); |
| 92 | dereg_ies.cause.present = Cause_PR_radioNetwork; |
| 93 | dereg_ies.cause.choice.radioNetwork = CauseRadioNetwork_connection_with_UE_lost; |
| 94 | |
| 95 | memset(&dereg, 0, sizeof(dereg)); |
| 96 | rc = hnbap_encode_uede_registeries(&dereg, &dereg_ies); |
| 97 | |
| 98 | msg = hnbap_generate_initiating_message(ProcedureCode_id_UEDe_Register, |
| 99 | Criticality_ignore, |
| 100 | &asn_DEF_UEDe_Register, |
| 101 | &dereg); |
| 102 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 103 | ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_UEDe_Register, &dereg); |
Daniel Willmann | 19dedbb | 2015-12-17 11:57:41 +0100 | [diff] [blame] | 104 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 105 | msgb_sctp_ppid(msg) = IUH_PPI_HNBAP; |
Daniel Willmann | 19dedbb | 2015-12-17 11:57:41 +0100 | [diff] [blame] | 106 | |
| 107 | return osmo_wqueue_enqueue(&hnb_test->wqueue, msg); |
| 108 | } |
| 109 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 110 | static int hnb_test_ue_register_tx(struct hnb_test *hnb_test, const char *imsi_str) |
Daniel Willmann | 479cb30 | 2015-12-09 17:54:59 +0100 | [diff] [blame] | 111 | { |
Daniel Willmann | 4e31250 | 2015-12-09 17:59:24 +0100 | [diff] [blame] | 112 | struct msgb *msg; |
| 113 | int rc, imsi_len; |
| 114 | |
| 115 | char imsi_buf[16]; |
Daniel Willmann | 141a0ba | 2015-12-17 18:03:52 +0100 | [diff] [blame] | 116 | |
Daniel Willmann | 4e31250 | 2015-12-09 17:59:24 +0100 | [diff] [blame] | 117 | UERegisterRequest_t request_out; |
| 118 | UERegisterRequestIEs_t request; |
| 119 | memset(&request, 0, sizeof(request)); |
| 120 | |
| 121 | request.uE_Identity.present = UE_Identity_PR_iMSI; |
| 122 | |
Harald Welte | 056984f | 2016-01-03 16:31:31 +0100 | [diff] [blame] | 123 | imsi_len = ranap_imsi_encode(imsi_buf, sizeof(imsi_buf), imsi_str); |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 124 | OCTET_STRING_fromBuf(&request.uE_Identity.choice.iMSI, imsi_buf, imsi_len); |
Daniel Willmann | 4e31250 | 2015-12-09 17:59:24 +0100 | [diff] [blame] | 125 | |
| 126 | request.registration_Cause = Registration_Cause_normal; |
| 127 | request.uE_Capabilities.access_stratum_release_indicator = Access_stratum_release_indicator_rel_6; |
| 128 | request.uE_Capabilities.csg_capability = CSG_Capability_not_csg_capable; |
| 129 | |
| 130 | memset(&request_out, 0, sizeof(request_out)); |
| 131 | rc = hnbap_encode_ueregisterrequesties(&request_out, &request); |
| 132 | |
| 133 | msg = hnbap_generate_initiating_message(ProcedureCode_id_UERegister, |
| 134 | Criticality_reject, |
| 135 | &asn_DEF_UERegisterRequest, |
| 136 | &request_out); |
| 137 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 138 | ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_UERegisterRequest, &request_out); |
Daniel Willmann | 4e31250 | 2015-12-09 17:59:24 +0100 | [diff] [blame] | 139 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 140 | msgb_sctp_ppid(msg) = IUH_PPI_HNBAP; |
Daniel Willmann | 4e31250 | 2015-12-09 17:59:24 +0100 | [diff] [blame] | 141 | |
| 142 | return osmo_wqueue_enqueue(&hnb_test->wqueue, msg); |
Daniel Willmann | 479cb30 | 2015-12-09 17:54:59 +0100 | [diff] [blame] | 143 | } |
| 144 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 145 | static int hnb_test_rx_hnb_register_acc(struct hnb_test *hnb, ANY_t *in) |
Daniel Willmann | 479cb30 | 2015-12-09 17:54:59 +0100 | [diff] [blame] | 146 | { |
| 147 | int rc; |
| 148 | HNBRegisterAcceptIEs_t accept; |
| 149 | |
| 150 | rc = hnbap_decode_hnbregisteraccepties(&accept, in); |
| 151 | if (rc < 0) { |
| 152 | } |
| 153 | |
| 154 | hnb->rnc_id = accept.rnc_id; |
| 155 | printf("HNB Register accept with RNC ID %u\n", hnb->rnc_id); |
| 156 | |
Daniel Willmann | 11e912a | 2016-01-07 13:19:30 +0100 | [diff] [blame] | 157 | hnbap_free_hnbregisteraccepties(&accept); |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 158 | return 0; |
Daniel Willmann | 479cb30 | 2015-12-09 17:54:59 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 161 | static int hnb_test_rx_ue_register_acc(struct hnb_test *hnb, ANY_t *in) |
Daniel Willmann | a7b0240 | 2015-12-09 19:05:09 +0100 | [diff] [blame] | 162 | { |
| 163 | int rc; |
| 164 | uint32_t ctx_id; |
| 165 | UERegisterAcceptIEs_t accept; |
| 166 | char imsi[16]; |
| 167 | |
| 168 | rc = hnbap_decode_ueregisteraccepties(&accept, in); |
| 169 | if (rc < 0) { |
| 170 | return rc; |
| 171 | } |
| 172 | |
| 173 | if (accept.uE_Identity.present != UE_Identity_PR_iMSI) { |
| 174 | printf("Wrong type in UE register accept\n"); |
| 175 | return -1; |
| 176 | } |
| 177 | |
| 178 | ctx_id = asn1bitstr_to_u24(&accept.context_ID); |
| 179 | |
Harald Welte | 056984f | 2016-01-03 16:31:31 +0100 | [diff] [blame] | 180 | ranap_bcd_decode(imsi, sizeof(imsi), accept.uE_Identity.choice.iMSI.buf, |
Daniel Willmann | a7b0240 | 2015-12-09 19:05:09 +0100 | [diff] [blame] | 181 | accept.uE_Identity.choice.iMSI.size); |
| 182 | printf("UE Register accept for IMSI %s, context %u\n", imsi, ctx_id); |
| 183 | |
Daniel Willmann | 19dedbb | 2015-12-17 11:57:41 +0100 | [diff] [blame] | 184 | hnb->ctx_id = ctx_id; |
Daniel Willmann | 11e912a | 2016-01-07 13:19:30 +0100 | [diff] [blame] | 185 | hnbap_free_ueregisteraccepties(&accept); |
Daniel Willmann | 19dedbb | 2015-12-17 11:57:41 +0100 | [diff] [blame] | 186 | |
Daniel Willmann | a7b0240 | 2015-12-09 19:05:09 +0100 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 190 | static struct msgb *gen_nas_id_resp() |
| 191 | { |
| 192 | uint8_t id_resp[] = { |
Neels Hofmeyr | 5c1cc8c | 2016-02-29 09:28:48 +0100 | [diff] [blame] | 193 | GSM48_PDISC_MM, |
| 194 | GSM48_MT_MM_ID_RESP, |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 195 | /* IMEISV */ |
| 196 | 0x09, /* len */ |
| 197 | 0x03, /* first digit (0000) + even (0) + id IMEISV (011) */ |
| 198 | 0x31, 0x91, 0x06, 0x00, 0x28, 0x47, 0x11, /* digits */ |
| 199 | 0xf2, /* filler (1111) + last digit (0010) */ |
| 200 | }; |
| 201 | |
Neels Hofmeyr | e1f709f | 2016-02-28 00:50:45 +0100 | [diff] [blame] | 202 | return ranap_new_msg_dt(0, id_resp, sizeof(id_resp)); |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 203 | } |
| 204 | |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 205 | static struct msgb *gen_nas_tmsi_realloc_compl() |
| 206 | { |
| 207 | uint8_t id_resp[] = { |
| 208 | GSM48_PDISC_MM, |
| 209 | GSM48_MT_MM_TMSI_REALL_COMPL, |
| 210 | }; |
| 211 | |
| 212 | return ranap_new_msg_dt(0, id_resp, sizeof(id_resp)); |
| 213 | } |
| 214 | |
Neels Hofmeyr | 26779f8 | 2016-04-18 17:04:17 +0200 | [diff] [blame] | 215 | static struct msgb *gen_nas_auth_resp(uint8_t *sres) |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 216 | { |
| 217 | uint8_t id_resp[] = { |
| 218 | GSM48_PDISC_MM, |
Neels Hofmeyr | 9987260 | 2016-04-05 11:51:15 +0200 | [diff] [blame] | 219 | 0x80 | GSM48_MT_MM_AUTH_RESP, /* simulate sequence nr 2 */ |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 220 | 0x61, 0xb5, 0x69, 0xf5 /* hardcoded SRES */ |
| 221 | }; |
| 222 | |
Neels Hofmeyr | 26779f8 | 2016-04-18 17:04:17 +0200 | [diff] [blame] | 223 | memcpy(id_resp + 2, sres, 4); |
| 224 | |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 225 | return ranap_new_msg_dt(0, id_resp, sizeof(id_resp)); |
| 226 | } |
| 227 | |
Neels Hofmeyr | c28ed37 | 2016-04-19 01:24:34 +0200 | [diff] [blame] | 228 | static int hnb_test_tx_dt(struct hnb_test *hnb, struct msgb *txm) |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 229 | { |
| 230 | struct hnbtest_chan *chan; |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 231 | struct msgb *rua; |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 232 | |
| 233 | chan = hnb->cs.chan; |
| 234 | if (!chan) { |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 235 | printf("hnb_test_nas_tx_tmsi_realloc_compl(): No CS channel established yet.\n"); |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 236 | return -1; |
| 237 | } |
| 238 | |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 239 | rua = rua_new_dt(chan->is_ps, chan->conn_id, txm); |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 240 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 241 | return 0; |
| 242 | } |
| 243 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 244 | static struct tlv_parsed *parse_mm(struct gsm48_hdr *gh, int len) |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 245 | { |
| 246 | static struct tlv_parsed tp; |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 247 | int parse_res; |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 248 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 249 | len -= (const char *)&gh->data[0] - (const char *)gh; |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 250 | |
Neels Hofmeyr | d7ad0ac | 2016-04-05 11:52:27 +0200 | [diff] [blame] | 251 | OSMO_ASSERT(gsm48_hdr_pdisc(gh) == GSM48_PDISC_MM); |
| 252 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 253 | parse_res = tlv_parse(&tp, &gsm48_mm_att_tlvdef, &gh->data[0], len, 0, 0); |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 254 | if (parse_res <= 0) { |
Neels Hofmeyr | 7c28f6f | 2016-04-05 11:49:53 +0200 | [diff] [blame] | 255 | uint8_t msg_type = gsm48_hdr_msg_type(gh); |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 256 | printf("Error parsing MM message 0x%hhx: %d\n", msg_type, parse_res); |
| 257 | return NULL; |
| 258 | } |
| 259 | |
| 260 | return &tp; |
| 261 | } |
| 262 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 263 | int hnb_test_nas_rx_lu_accept(struct gsm48_hdr *gh, int len, int *sent_tmsi) |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 264 | { |
| 265 | printf(" :D Location Update Accept :D\n"); |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 266 | struct gsm48_loc_area_id *lai; |
Neels Hofmeyr | c04eb53 | 2016-03-04 12:38:43 +0100 | [diff] [blame] | 267 | |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 268 | lai = (struct gsm48_loc_area_id *)&gh->data[0]; |
| 269 | |
| 270 | uint16_t mcc, mnc, lac; |
| 271 | gsm48_decode_lai(lai, &mcc, &mnc, &lac); |
| 272 | printf("LU: mcc %hd mnc %hd lac %hd\n", |
| 273 | mcc, mnc, lac); |
| 274 | |
Neels Hofmeyr | c04eb53 | 2016-03-04 12:38:43 +0100 | [diff] [blame] | 275 | struct tlv_parsed tp; |
| 276 | int parse_res; |
| 277 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 278 | len -= (const char *)&gh->data[0] - (const char *)gh; |
| 279 | parse_res = tlv_parse(&tp, &gsm48_mm_att_tlvdef, &gh->data[0], len, 0, 0); |
Neels Hofmeyr | c04eb53 | 2016-03-04 12:38:43 +0100 | [diff] [blame] | 280 | if (parse_res <= 0) { |
| 281 | printf("Error parsing Location Update Accept message: %d\n", parse_res); |
| 282 | return -1; |
| 283 | } |
| 284 | |
| 285 | if (TLVP_PRESENT(&tp, GSM48_IE_MOBILE_ID)) { |
| 286 | uint8_t type = TLVP_VAL(&tp, GSM48_IE_NAME_SHORT)[0] & 0x0f; |
| 287 | if (type == GSM_MI_TYPE_TMSI) |
| 288 | *sent_tmsi = 1; |
| 289 | else *sent_tmsi = 0; |
| 290 | } |
| 291 | return 0; |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 292 | } |
| 293 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 294 | void hnb_test_nas_rx_mm_info(struct gsm48_hdr *gh, int len) |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 295 | { |
| 296 | printf(" :) MM Info :)\n"); |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 297 | struct tlv_parsed *tp = parse_mm(gh, len); |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 298 | if (!tp) |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 299 | return; |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 300 | |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 301 | if (TLVP_PRESENT(tp, GSM48_IE_NAME_SHORT)) { |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 302 | char name[128] = {0}; |
| 303 | gsm_7bit_decode_n(name, 127, |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 304 | TLVP_VAL(tp, GSM48_IE_NAME_SHORT)+1, |
| 305 | (TLVP_LEN(tp, GSM48_IE_NAME_SHORT)-1)*8/7); |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 306 | printf("Info: Short Network Name: %s\n", name); |
| 307 | } |
| 308 | |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 309 | if (TLVP_PRESENT(tp, GSM48_IE_NAME_LONG)) { |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 310 | char name[128] = {0}; |
| 311 | gsm_7bit_decode_n(name, 127, |
Neels Hofmeyr | d4598fa | 2016-03-09 01:37:40 +0100 | [diff] [blame] | 312 | TLVP_VAL(tp, GSM48_IE_NAME_LONG)+1, |
| 313 | (TLVP_LEN(tp, GSM48_IE_NAME_LONG)-1)*8/7); |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 314 | printf("Info: Long Network Name: %s\n", name); |
| 315 | } |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 316 | } |
| 317 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 318 | static int hnb_test_nas_rx_auth_req(struct hnb_test *hnb, struct gsm48_hdr *gh, |
| 319 | int len) |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 320 | { |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 321 | struct gsm48_auth_req *ar; |
| 322 | int parse_res; |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 323 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 324 | len -= (const char *)&gh->data[0] - (const char *)gh; |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 325 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 326 | if (len < sizeof(*ar)) { |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 327 | printf("GSM48 Auth Req does not fit.\n"); |
| 328 | return; |
| 329 | } |
| 330 | |
| 331 | printf(" :) Authentication Request :)\n"); |
| 332 | |
| 333 | ar = (struct gsm48_auth_req*) &gh->data[0]; |
| 334 | int seq = ar->key_seq; |
Neels Hofmeyr | 26779f8 | 2016-04-18 17:04:17 +0200 | [diff] [blame] | 335 | |
| 336 | /* Generate SRES from *HARDCODED* Ki for Iuh testing */ |
| 337 | struct osmo_auth_vector vec; |
| 338 | /* Ki 000102030405060708090a0b0c0d0e0f */ |
| 339 | struct osmo_sub_auth_data auth = { |
| 340 | .type = OSMO_AUTH_TYPE_GSM, |
| 341 | .algo = OSMO_AUTH_ALG_COMP128v1, |
| 342 | .u.gsm.ki = { |
| 343 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, |
| 344 | 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, |
| 345 | 0x0e, 0x0f |
| 346 | }, |
| 347 | }; |
| 348 | |
| 349 | memset(&vec, 0, sizeof(vec)); |
| 350 | osmo_auth_gen_vec(&vec, &auth, ar->rand); |
| 351 | |
| 352 | printf("seq %d rand %s", |
| 353 | seq, osmo_hexdump(ar->rand, sizeof(ar->rand))); |
| 354 | printf(" --> sres %s\n", |
| 355 | osmo_hexdump(vec.sres, 4)); |
| 356 | |
Neels Hofmeyr | c28ed37 | 2016-04-19 01:24:34 +0200 | [diff] [blame] | 357 | return hnb_test_tx_dt(hnb, gen_nas_auth_resp(vec.sres)); |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 358 | } |
| 359 | |
Neels Hofmeyr | bde4d3b | 2016-04-19 02:38:16 +0200 | [diff] [blame] | 360 | void hnb_test_tx_iu_release_req(struct hnb_test *hnb) |
| 361 | { |
| 362 | RANAP_Cause_t cause = { |
| 363 | .present = RANAP_Cause_PR_radioNetwork, |
| 364 | .choice.transmissionNetwork = RANAP_CauseRadioNetwork_release_due_to_UE_generated_signalling_connection_release, |
| 365 | }; |
| 366 | hnb_test_tx_dt(hnb, ranap_new_msg_iu_rel_req(&cause)); |
| 367 | } |
| 368 | |
| 369 | void hnb_test_tx_iu_release_compl(struct hnb_test *hnb) |
| 370 | { |
| 371 | hnb_test_tx_dt(hnb, ranap_new_msg_iu_rel_compl()); |
| 372 | } |
| 373 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 374 | static int hnb_test_nas_rx_mm(struct hnb_test *hnb, struct gsm48_hdr *gh, int len) |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 375 | { |
| 376 | struct hnbtest_chan *chan; |
| 377 | |
| 378 | chan = hnb->cs.chan; |
| 379 | if (!chan) { |
| 380 | printf("hnb_test_nas_rx_mm(): No CS channel established yet.\n"); |
| 381 | return -1; |
| 382 | } |
| 383 | |
| 384 | OSMO_ASSERT(!chan->is_ps); |
| 385 | |
Neels Hofmeyr | 7c28f6f | 2016-04-05 11:49:53 +0200 | [diff] [blame] | 386 | uint8_t msg_type = gsm48_hdr_msg_type(gh); |
Neels Hofmeyr | c04eb53 | 2016-03-04 12:38:43 +0100 | [diff] [blame] | 387 | int sent_tmsi; |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 388 | |
| 389 | switch (msg_type) { |
| 390 | case GSM48_MT_MM_ID_REQ: |
Neels Hofmeyr | c28ed37 | 2016-04-19 01:24:34 +0200 | [diff] [blame] | 391 | return hnb_test_tx_dt(hnb, gen_nas_id_resp()); |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 392 | |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 393 | case GSM48_MT_MM_LOC_UPD_ACCEPT: |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 394 | if (hnb_test_nas_rx_lu_accept(gh, len, &sent_tmsi)) |
Neels Hofmeyr | c04eb53 | 2016-03-04 12:38:43 +0100 | [diff] [blame] | 395 | return -1; |
| 396 | if (sent_tmsi) |
Neels Hofmeyr | c28ed37 | 2016-04-19 01:24:34 +0200 | [diff] [blame] | 397 | return hnb_test_tx_dt(hnb, gen_nas_tmsi_realloc_compl()); |
Neels Hofmeyr | c04eb53 | 2016-03-04 12:38:43 +0100 | [diff] [blame] | 398 | else |
| 399 | return 0; |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 400 | |
Neels Hofmeyr | 5dbb7b2 | 2016-03-09 01:38:13 +0100 | [diff] [blame] | 401 | case GSM48_MT_MM_LOC_UPD_REJECT: |
| 402 | printf("Received Location Update Reject\n"); |
| 403 | return 0; |
| 404 | |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 405 | case GSM48_MT_MM_INFO: |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 406 | hnb_test_nas_rx_mm_info(gh, len); |
Neels Hofmeyr | bde4d3b | 2016-04-19 02:38:16 +0200 | [diff] [blame] | 407 | hnb_test_tx_iu_release_req(hnb); |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 408 | return 0; |
| 409 | |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 410 | case GSM48_MT_MM_AUTH_REQ: |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 411 | return hnb_test_nas_rx_auth_req(hnb, gh, len); |
Neels Hofmeyr | 3588810 | 2016-03-09 01:39:56 +0100 | [diff] [blame] | 412 | |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 413 | default: |
Neels Hofmeyr | ae93712 | 2016-02-29 09:32:00 +0100 | [diff] [blame] | 414 | printf("04.08 message type not handled by hnb-test: 0x%x\n", |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 415 | msg_type); |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | } |
| 420 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 421 | void hnb_test_nas_rx_dtap(struct hnb_test *hnb, void *data, int len) |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 422 | { |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 423 | int rc; |
| 424 | printf("got %d bytes: %s\n", len, osmo_hexdump(data, len)); |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 425 | |
| 426 | // nas_pdu == '05 08 12' ==> IMEI Identity request |
| 427 | // '05 04 0d' ==> LU reject |
| 428 | |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 429 | struct gsm48_hdr *gh = data; |
| 430 | if (len < sizeof(*gh)) { |
| 431 | printf("hnb_test_nas_rx_dtap(): NAS PDU is too short: %d. Ignoring.\n", |
| 432 | len); |
| 433 | return; |
Neels Hofmeyr | 8c2b4ec | 2016-04-04 19:27:53 +0200 | [diff] [blame] | 434 | } |
Neels Hofmeyr | 7c28f6f | 2016-04-05 11:49:53 +0200 | [diff] [blame] | 435 | uint8_t pdisc = gsm48_hdr_pdisc(gh); |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 436 | |
| 437 | switch (pdisc) { |
| 438 | case GSM48_PDISC_MM: |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 439 | rc = hnb_test_nas_rx_mm(hnb, gh, len); |
| 440 | if (rc != 0) |
| 441 | printf("Error receiving MM message: %d\n", rc); |
| 442 | return; |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 443 | default: |
| 444 | printf("04.08 discriminator not handled by hnb-test: %d\n", |
| 445 | pdisc); |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 446 | return; |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 447 | } |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 448 | } |
| 449 | |
Neels Hofmeyr | 4a0a69a | 2016-04-19 00:06:28 +0200 | [diff] [blame] | 450 | void hnb_test_rx_secmode_cmd(struct hnb_test *hnb, long ip_alg) |
| 451 | { |
| 452 | printf(" :) Security Mode Command :)\n"); |
| 453 | /* not caring about encryption yet, just pass 0 for No Encryption. */ |
| 454 | hnb_test_tx_dt(hnb, ranap_new_msg_sec_mod_compl(ip_alg, 0)); |
| 455 | } |
| 456 | |
Neels Hofmeyr | bde4d3b | 2016-04-19 02:38:16 +0200 | [diff] [blame] | 457 | void hnb_test_rx_iu_release(struct hnb_test *hnb) |
| 458 | { |
| 459 | hnb_test_tx_iu_release_compl(hnb); |
| 460 | } |
| 461 | |
Neels Hofmeyr | 5ad72b9 | 2016-04-19 18:09:05 +0200 | [diff] [blame] | 462 | void hnb_test_rx_paging(struct hnb_test *hnb, const char *imsi) |
| 463 | { |
| 464 | printf(" :) Paging Request for %s :)\n", imsi); |
| 465 | /* TODO reply */ |
| 466 | } |
| 467 | |
Daniel Willmann | 479cb30 | 2015-12-09 17:54:59 +0100 | [diff] [blame] | 468 | int hnb_test_hnbap_rx(struct hnb_test *hnb, struct msgb *msg) |
| 469 | { |
| 470 | HNBAP_PDU_t _pdu, *pdu = &_pdu; |
| 471 | asn_dec_rval_t dec_ret; |
| 472 | int rc; |
| 473 | |
| 474 | memset(pdu, 0, sizeof(*pdu)); |
| 475 | dec_ret = aper_decode(NULL, &asn_DEF_HNBAP_PDU, (void **) &pdu, |
| 476 | msg->data, msgb_length(msg), 0, 0); |
| 477 | if (dec_ret.code != RC_OK) { |
| 478 | LOGP(DMAIN, LOGL_ERROR, "Error in ASN.1 decode\n"); |
| 479 | return rc; |
| 480 | } |
| 481 | |
| 482 | if (pdu->present != HNBAP_PDU_PR_successfulOutcome) { |
| 483 | printf("Unexpected HNBAP message received\n"); |
| 484 | } |
| 485 | |
| 486 | switch (pdu->choice.successfulOutcome.procedureCode) { |
| 487 | case ProcedureCode_id_HNBRegister: |
| 488 | /* Get HNB id and send UE Register request */ |
| 489 | rc = hnb_test_rx_hnb_register_acc(hnb, &pdu->choice.successfulOutcome.value); |
| 490 | break; |
| 491 | case ProcedureCode_id_UERegister: |
Daniel Willmann | a7b0240 | 2015-12-09 19:05:09 +0100 | [diff] [blame] | 492 | rc = hnb_test_rx_ue_register_acc(hnb, &pdu->choice.successfulOutcome.value); |
Daniel Willmann | 479cb30 | 2015-12-09 17:54:59 +0100 | [diff] [blame] | 493 | break; |
| 494 | default: |
| 495 | break; |
| 496 | } |
| 497 | |
| 498 | return rc; |
| 499 | } |
| 500 | |
Neels Hofmeyr | b984f36 | 2016-02-18 01:18:20 +0100 | [diff] [blame] | 501 | extern void direct_transfer_nas_pdu_print(ANY_t *in); |
| 502 | |
Neels Hofmeyr | 0968a58 | 2016-01-11 15:19:38 +0100 | [diff] [blame] | 503 | int hnb_test_rua_rx(struct hnb_test *hnb, struct msgb *msg) |
| 504 | { |
| 505 | RUA_RUA_PDU_t _pdu, *pdu = &_pdu; |
| 506 | asn_dec_rval_t dec_ret; |
| 507 | int rc; |
| 508 | |
| 509 | memset(pdu, 0, sizeof(*pdu)); |
| 510 | dec_ret = aper_decode(NULL, &asn_DEF_RUA_RUA_PDU, (void **) &pdu, |
| 511 | msg->data, msgb_length(msg), 0, 0); |
| 512 | if (dec_ret.code != RC_OK) { |
| 513 | LOGP(DMAIN, LOGL_ERROR, "Error in ASN.1 decode\n"); |
| 514 | return rc; |
| 515 | } |
| 516 | |
| 517 | switch (pdu->present) { |
| 518 | case RUA_RUA_PDU_PR_successfulOutcome: |
| 519 | printf("RUA_RUA_PDU_PR_successfulOutcome\n"); |
| 520 | break; |
| 521 | case RUA_RUA_PDU_PR_initiatingMessage: |
| 522 | printf("RUA_RUA_PDU_PR_initiatingMessage\n"); |
| 523 | break; |
| 524 | case RUA_RUA_PDU_PR_NOTHING: |
| 525 | printf("RUA_RUA_PDU_PR_NOTHING\n"); |
| 526 | break; |
| 527 | case RUA_RUA_PDU_PR_unsuccessfulOutcome: |
| 528 | printf("RUA_RUA_PDU_PR_unsuccessfulOutcome\n"); |
| 529 | break; |
| 530 | default: |
| 531 | printf("Unexpected RUA message received\n"); |
| 532 | break; |
| 533 | } |
| 534 | |
| 535 | switch (pdu->choice.successfulOutcome.procedureCode) { |
| 536 | case RUA_ProcedureCode_id_ConnectionlessTransfer: |
| 537 | printf("RUA rx Connectionless Transfer\n"); |
Neels Hofmeyr | 5ad72b9 | 2016-04-19 18:09:05 +0200 | [diff] [blame] | 538 | hnb_test_rua_cl_handle(hnb, &pdu->choice.successfulOutcome.value); |
Neels Hofmeyr | 0968a58 | 2016-01-11 15:19:38 +0100 | [diff] [blame] | 539 | break; |
| 540 | case RUA_ProcedureCode_id_Connect: |
| 541 | printf("RUA rx Connect\n"); |
| 542 | break; |
| 543 | case RUA_ProcedureCode_id_DirectTransfer: |
| 544 | printf("RUA rx DirectTransfer\n"); |
Neels Hofmeyr | 4470f93 | 2016-04-19 00:13:53 +0200 | [diff] [blame] | 545 | hnb_test_rua_dt_handle(hnb, &pdu->choice.successfulOutcome.value); |
Neels Hofmeyr | 0968a58 | 2016-01-11 15:19:38 +0100 | [diff] [blame] | 546 | break; |
| 547 | case RUA_ProcedureCode_id_Disconnect: |
| 548 | printf("RUA rx Disconnect\n"); |
| 549 | break; |
| 550 | case RUA_ProcedureCode_id_ErrorIndication: |
| 551 | printf("RUA rx ErrorIndication\n"); |
| 552 | break; |
| 553 | case RUA_ProcedureCode_id_privateMessage: |
| 554 | printf("RUA rx privateMessage\n"); |
| 555 | break; |
| 556 | default: |
| 557 | printf("RUA rx unknown message\n"); |
| 558 | break; |
| 559 | } |
| 560 | |
| 561 | return rc; |
| 562 | } |
| 563 | |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 564 | static int hnb_read_cb(struct osmo_fd *fd) |
| 565 | { |
| 566 | struct hnb_test *hnb_test = fd->data; |
| 567 | struct sctp_sndrcvinfo sinfo; |
| 568 | struct msgb *msg = msgb_alloc(IUH_MSGB_SIZE, "Iuh rx"); |
| 569 | int flags = 0; |
| 570 | int rc; |
| 571 | |
| 572 | if (!msg) |
| 573 | return -ENOMEM; |
| 574 | |
| 575 | rc = sctp_recvmsg(fd->fd, msgb_data(msg), msgb_tailroom(msg), |
| 576 | NULL, NULL, &sinfo, &flags); |
| 577 | if (rc < 0) { |
| 578 | LOGP(DMAIN, LOGL_ERROR, "Error during sctp_recvmsg()\n"); |
| 579 | /* FIXME: clean up after disappeared HNB */ |
Daniel Willmann | 6637a28 | 2015-12-17 14:47:51 +0100 | [diff] [blame] | 580 | close(fd->fd); |
| 581 | osmo_fd_unregister(fd); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 582 | return rc; |
Daniel Willmann | 6637a28 | 2015-12-17 14:47:51 +0100 | [diff] [blame] | 583 | } else if (rc == 0) { |
| 584 | LOGP(DMAIN, LOGL_INFO, "Connection to HNB closed\n"); |
| 585 | close(fd->fd); |
| 586 | osmo_fd_unregister(fd); |
| 587 | fd->fd = -1; |
| 588 | |
| 589 | return -1; |
| 590 | } else { |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 591 | msgb_put(msg, rc); |
Daniel Willmann | 6637a28 | 2015-12-17 14:47:51 +0100 | [diff] [blame] | 592 | } |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 593 | |
| 594 | if (flags & MSG_NOTIFICATION) { |
Daniel Willmann | 3279780 | 2015-12-17 12:53:05 +0100 | [diff] [blame] | 595 | LOGP(DMAIN, LOGL_DEBUG, "Ignoring SCTP notification\n"); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 596 | msgb_free(msg); |
| 597 | return 0; |
| 598 | } |
| 599 | |
| 600 | sinfo.sinfo_ppid = ntohl(sinfo.sinfo_ppid); |
| 601 | |
| 602 | switch (sinfo.sinfo_ppid) { |
| 603 | case IUH_PPI_HNBAP: |
Neels Hofmeyr | 0968a58 | 2016-01-11 15:19:38 +0100 | [diff] [blame] | 604 | printf("HNBAP message received\n"); |
Daniel Willmann | 479cb30 | 2015-12-09 17:54:59 +0100 | [diff] [blame] | 605 | rc = hnb_test_hnbap_rx(hnb_test, msg); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 606 | break; |
| 607 | case IUH_PPI_RUA: |
Neels Hofmeyr | 0968a58 | 2016-01-11 15:19:38 +0100 | [diff] [blame] | 608 | printf("RUA message received\n"); |
| 609 | rc = hnb_test_rua_rx(hnb_test, msg); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 610 | break; |
| 611 | case IUH_PPI_SABP: |
| 612 | case IUH_PPI_RNA: |
| 613 | case IUH_PPI_PUA: |
| 614 | LOGP(DMAIN, LOGL_ERROR, "Unimplemented SCTP PPID=%u received\n", |
| 615 | sinfo.sinfo_ppid); |
| 616 | rc = 0; |
| 617 | break; |
| 618 | default: |
| 619 | LOGP(DMAIN, LOGL_ERROR, "Unknown SCTP PPID=%u received\n", |
| 620 | sinfo.sinfo_ppid); |
| 621 | rc = 0; |
| 622 | break; |
| 623 | } |
| 624 | |
| 625 | msgb_free(msg); |
| 626 | return rc; |
| 627 | } |
| 628 | |
| 629 | static int hnb_write_cb(struct osmo_fd *fd, struct msgb *msg) |
| 630 | { |
| 631 | struct hnb_test *ctx = fd->data; |
| 632 | struct sctp_sndrcvinfo sinfo = { |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 633 | .sinfo_ppid = htonl(msgb_sctp_ppid(msg)), |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 634 | .sinfo_stream = 0, |
| 635 | }; |
| 636 | int rc; |
| 637 | |
Neels Hofmeyr | e25faa8 | 2016-03-04 02:49:52 +0100 | [diff] [blame] | 638 | printf("Sending: %s\n", osmo_hexdump(msgb_data(msg), msgb_length(msg))); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 639 | rc = sctp_send(fd->fd, msgb_data(msg), msgb_length(msg), |
| 640 | &sinfo, 0); |
| 641 | /* we don't need to msgb_free(), write_queue does this for us */ |
| 642 | return rc; |
| 643 | } |
| 644 | |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 645 | static void hnb_send_register_req(struct hnb_test *hnb_test) |
| 646 | { |
Daniel Willmann | a1e202e | 2015-12-07 17:21:07 +0100 | [diff] [blame] | 647 | HNBRegisterRequest_t request_out; |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 648 | struct msgb *msg; |
| 649 | int rc; |
Daniel Willmann | a1e202e | 2015-12-07 17:21:07 +0100 | [diff] [blame] | 650 | uint16_t lac, sac; |
| 651 | uint8_t rac; |
| 652 | uint32_t cid; |
| 653 | uint8_t plmn[] = {0x09, 0xf1, 0x99}; |
| 654 | char identity[50] = "ATestHNB@"; |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 655 | |
Daniel Willmann | a1e202e | 2015-12-07 17:21:07 +0100 | [diff] [blame] | 656 | HNBRegisterRequestIEs_t request; |
| 657 | memset(&request, 0, sizeof(request)); |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 658 | |
Daniel Willmann | a1e202e | 2015-12-07 17:21:07 +0100 | [diff] [blame] | 659 | lac = 0xc0fe; |
| 660 | sac = 0xabab; |
| 661 | rac = 0x42; |
Daniel Willmann | d6a45b4 | 2015-12-08 13:55:17 +0100 | [diff] [blame] | 662 | cid = 0xadceaab; |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 663 | |
Daniel Willmann | a1e202e | 2015-12-07 17:21:07 +0100 | [diff] [blame] | 664 | asn1_u16_to_str(&request.lac, &lac, lac); |
| 665 | asn1_u16_to_str(&request.sac, &sac, sac); |
| 666 | asn1_u8_to_str(&request.rac, &rac, rac); |
Daniel Willmann | d6a45b4 | 2015-12-08 13:55:17 +0100 | [diff] [blame] | 667 | asn1_u28_to_bitstring(&request.cellIdentity, &cid, cid); |
Daniel Willmann | a1e202e | 2015-12-07 17:21:07 +0100 | [diff] [blame] | 668 | |
| 669 | request.hnB_Identity.hNB_Identity_Info.buf = identity; |
| 670 | request.hnB_Identity.hNB_Identity_Info.size = strlen(identity); |
| 671 | |
| 672 | request.plmNidentity.buf = plmn; |
| 673 | request.plmNidentity.size = 3; |
| 674 | |
| 675 | |
| 676 | |
| 677 | memset(&request_out, 0, sizeof(request_out)); |
| 678 | rc = hnbap_encode_hnbregisterrequesties(&request_out, &request); |
| 679 | if (rc < 0) { |
| 680 | printf("Could not encode HNB register request IEs\n"); |
| 681 | } |
| 682 | |
| 683 | msg = hnbap_generate_initiating_message(ProcedureCode_id_HNBRegister, |
| 684 | Criticality_reject, |
| 685 | &asn_DEF_HNBRegisterRequest, |
| 686 | &request_out); |
| 687 | |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 688 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 689 | msgb_sctp_ppid(msg) = IUH_PPI_HNBAP; |
| 690 | |
| 691 | osmo_wqueue_enqueue(&hnb_test->wqueue, msg); |
| 692 | } |
| 693 | |
| 694 | static void hnb_send_deregister_req(struct hnb_test *hnb_test) |
| 695 | { |
| 696 | struct msgb *msg; |
| 697 | int rc; |
| 698 | |
| 699 | HNBDe_RegisterIEs_t request; |
| 700 | memset(&request, 0, sizeof(request)); |
| 701 | |
| 702 | request.cause.present = Cause_PR_misc; |
| 703 | request.cause.choice.misc = CauseMisc_o_and_m_intervention; |
| 704 | |
| 705 | HNBDe_Register_t request_out; |
| 706 | memset(&request_out, 0, sizeof(request_out)); |
| 707 | rc = hnbap_encode_hnbde_registeries(&request_out, &request); |
| 708 | if (rc < 0) { |
| 709 | printf("Could not encode HNB deregister request IEs\n"); |
| 710 | } |
| 711 | |
| 712 | msg = hnbap_generate_initiating_message(ProcedureCode_id_HNBDe_Register, |
| 713 | Criticality_reject, |
| 714 | &asn_DEF_HNBDe_Register, |
| 715 | &request_out); |
| 716 | |
| 717 | msgb_sctp_ppid(msg) = IUH_PPI_HNBAP; |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 718 | |
| 719 | osmo_wqueue_enqueue(&hnb_test->wqueue, msg); |
| 720 | } |
| 721 | |
| 722 | |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 723 | static const struct log_info_cat log_cat[] = { |
| 724 | [DMAIN] = { |
Daniel Willmann | 3279780 | 2015-12-17 12:53:05 +0100 | [diff] [blame] | 725 | .name = "DMAIN", .loglevel = LOGL_INFO, .enabled = 1, |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 726 | .color = "", |
| 727 | .description = "Main program", |
| 728 | }, |
Daniel Willmann | 3279780 | 2015-12-17 12:53:05 +0100 | [diff] [blame] | 729 | [DHNBAP] = { |
| 730 | .name = "DHNBAP", .loglevel = LOGL_DEBUG, .enabled = 1, |
| 731 | .color = "", |
| 732 | .description = "Home Node B Application Part", |
| 733 | }, |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 734 | }; |
| 735 | |
| 736 | static const struct log_info hnb_test_log_info = { |
| 737 | .cat = log_cat, |
| 738 | .num_cat = ARRAY_SIZE(log_cat), |
| 739 | }; |
| 740 | |
| 741 | static struct vty_app_info vty_info = { |
| 742 | .name = "OsmoHNB-Test", |
| 743 | .version = "0", |
| 744 | }; |
| 745 | |
Daniel Willmann | 4abdee0 | 2015-12-09 17:57:32 +0100 | [diff] [blame] | 746 | static int sctp_sock_init(int fd) |
| 747 | { |
| 748 | struct sctp_event_subscribe event; |
| 749 | int rc; |
| 750 | |
| 751 | /* subscribe for all events */ |
| 752 | memset((uint8_t *)&event, 1, sizeof(event)); |
| 753 | rc = setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, |
| 754 | &event, sizeof(event)); |
| 755 | |
| 756 | return rc; |
| 757 | } |
| 758 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 759 | #define HNBAP_STR "HNBAP related commands\n" |
| 760 | #define HNB_STR "HomeNodeB commands\n" |
| 761 | #define UE_STR "User Equipment commands\n" |
| 762 | #define RANAP_STR "RANAP related commands\n" |
| 763 | #define CSPS_STR "Circuit Switched\n" "Packet Switched\n" |
| 764 | |
| 765 | DEFUN(hnb_register, hnb_register_cmd, |
| 766 | "hnbap hnb register", HNBAP_STR HNB_STR "Send HNB-REGISTER REQUEST") |
| 767 | { |
| 768 | hnb_send_register_req(&g_hnb_test); |
| 769 | |
| 770 | return CMD_SUCCESS; |
| 771 | } |
| 772 | |
| 773 | DEFUN(hnb_deregister, hnb_deregister_cmd, |
| 774 | "hnbap hnb deregister", HNBAP_STR HNB_STR "Send HNB-DEREGISTER REQUEST") |
| 775 | { |
| 776 | hnb_send_deregister_req(&g_hnb_test); |
| 777 | |
| 778 | return CMD_SUCCESS; |
| 779 | } |
| 780 | |
| 781 | DEFUN(ue_register, ue_register_cmd, |
| 782 | "hnbap ue register IMSI", HNBAP_STR UE_STR "Send UE-REGISTER REQUEST") |
| 783 | { |
| 784 | hnb_test_ue_register_tx(&g_hnb_test, argv[0]); |
| 785 | |
| 786 | return CMD_SUCCESS; |
| 787 | } |
| 788 | |
| 789 | DEFUN(asn_dbg, asn_dbg_cmd, |
| 790 | "asn-debug (1|0)", "Enable or disabel libasn1c debugging") |
| 791 | { |
| 792 | asn_debug = atoi(argv[0]); |
| 793 | |
| 794 | return CMD_SUCCESS; |
| 795 | } |
| 796 | |
| 797 | DEFUN(ranap_reset, ranap_reset_cmd, |
| 798 | "ranap reset (cs|ps)", RANAP_STR "Send RANAP RESET\n" CSPS_STR) |
| 799 | { |
| 800 | int is_ps = 0; |
| 801 | struct msgb *msg, *rua; |
| 802 | |
| 803 | RANAP_Cause_t cause = { |
| 804 | .present = RANAP_Cause_PR_transmissionNetwork, |
| 805 | .choice.transmissionNetwork = RANAP_CauseTransmissionNetwork_signalling_transport_resource_failure, |
| 806 | }; |
| 807 | |
| 808 | if (!strcmp(argv[0], "ps")) |
| 809 | is_ps = 1; |
| 810 | |
| 811 | msg = ranap_new_msg_reset(is_ps, &cause); |
| 812 | rua = rua_new_udt(msg); |
| 813 | //msgb_free(msg); |
| 814 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 815 | |
| 816 | return CMD_SUCCESS; |
| 817 | } |
| 818 | |
| 819 | |
| 820 | enum my_vty_nodes { |
| 821 | CHAN_NODE = _LAST_OSMOVTY_NODE, |
| 822 | }; |
| 823 | |
| 824 | static struct cmd_node chan_node = { |
| 825 | CHAN_NODE, |
| 826 | "%s(chan)> ", |
| 827 | 1, |
| 828 | }; |
| 829 | |
| 830 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 831 | static struct msgb *gen_initue_lu(int is_ps, uint32_t conn_id, const char *imsi) |
| 832 | { |
Neels Hofmeyr | 5c1cc8c | 2016-02-29 09:28:48 +0100 | [diff] [blame] | 833 | uint8_t lu[] = { GSM48_PDISC_MM, GSM48_MT_MM_LOC_UPD_REQUEST, |
| 834 | 0x70, 0x62, 0xf2, 0x30, 0xff, 0xf3, 0x57, |
Neels Hofmeyr | 3282870 | 2016-01-14 13:06:47 +0100 | [diff] [blame] | 835 | /* len, IMSI/type, IMSI-------------------------------- */ |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 836 | 0x08, 0x29, 0x26, 0x24, 0x10, 0x32, 0x54, 0x76, 0x98, |
| 837 | 0x33, 0x03, 0x57, 0x18 , 0xb2 }; |
| 838 | uint8_t plmn_id[] = { 0x09, 0x01, 0x99 }; |
| 839 | RANAP_GlobalRNC_ID_t rnc_id = { |
| 840 | .rNC_ID = 23, |
| 841 | .pLMNidentity.buf = plmn_id, |
| 842 | .pLMNidentity.size = sizeof(plmn_id), |
| 843 | }; |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 844 | |
| 845 | /* FIXME: patch imsi */ |
Neels Hofmeyr | 7b81128 | 2016-01-14 13:05:24 +0100 | [diff] [blame] | 846 | /* Note: the Mobile Identitiy IE's IMSI data has the identity type and |
| 847 | * an even/odd indicator bit encoded in the first octet. So the first |
| 848 | * octet looks like this: |
| 849 | * |
| 850 | * 8 7 6 5 | 4 | 3 2 1 |
| 851 | * IMSI-digit | even/odd | type |
| 852 | * |
| 853 | * followed by the remaining IMSI digits. |
| 854 | * If digit count is even (bit 4 == 0), that first high-nibble is 0xf. |
| 855 | * (derived from Iu pcap Location Update Request msg and TS 25.413) |
| 856 | * |
| 857 | * TODO I'm only 90% sure about this |
| 858 | */ |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 859 | |
Neels Hofmeyr | 6a62e54 | 2016-01-15 03:07:45 +0100 | [diff] [blame] | 860 | return ranap_new_msg_initial_ue(conn_id, is_ps, &rnc_id, lu, sizeof(lu)); |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | DEFUN(chan, chan_cmd, |
| 864 | "channel (cs|ps) lu imsi IMSI", |
| 865 | "Open a new Signalling Connection\n" |
| 866 | "To Circuit-Switched CN\n" |
| 867 | "To Packet-Switched CN\n" |
| 868 | "Performing a Location Update\n" |
| 869 | ) |
| 870 | { |
| 871 | struct hnbtest_chan *chan; |
| 872 | struct msgb *msg, *rua; |
Daniel Willmann | 8592716 | 2016-01-14 15:36:49 +0100 | [diff] [blame] | 873 | static uint16_t conn_id = 42; |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 874 | |
| 875 | chan = talloc_zero(tall_hnb_ctx, struct hnbtest_chan); |
| 876 | if (!strcmp(argv[0], "ps")) |
| 877 | chan->is_ps = 1; |
| 878 | chan->imsi = talloc_strdup(chan, argv[1]); |
Daniel Willmann | 8592716 | 2016-01-14 15:36:49 +0100 | [diff] [blame] | 879 | chan->conn_id = conn_id; |
| 880 | conn_id++; |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 881 | |
| 882 | msg = gen_initue_lu(chan->is_ps, chan->conn_id, chan->imsi); |
| 883 | rua = rua_new_conn(chan->is_ps, chan->conn_id, msg); |
| 884 | |
| 885 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 886 | |
| 887 | vty->index = chan; |
| 888 | vty->node = CHAN_NODE; |
| 889 | |
Neels Hofmeyr | 860a129 | 2016-02-18 23:03:15 +0100 | [diff] [blame] | 890 | if (!chan->is_ps) |
| 891 | g_hnb_test.cs.chan = chan; |
| 892 | |
| 893 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 894 | return CMD_SUCCESS; |
| 895 | } |
| 896 | |
| 897 | static void hnbtest_vty_init(void) |
| 898 | { |
| 899 | install_element_ve(&asn_dbg_cmd); |
| 900 | install_element_ve(&hnb_register_cmd); |
| 901 | install_element_ve(&hnb_deregister_cmd); |
| 902 | install_element_ve(&ue_register_cmd); |
| 903 | install_element_ve(&ranap_reset_cmd); |
| 904 | install_element_ve(&chan_cmd); |
| 905 | |
| 906 | install_node(&chan_node, NULL); |
| 907 | vty_install_default(CHAN_NODE); |
| 908 | } |
| 909 | |
Daniel Willmann | 141a0ba | 2015-12-17 18:03:52 +0100 | [diff] [blame] | 910 | static void handle_options(int argc, char **argv) |
| 911 | { |
| 912 | while (1) { |
| 913 | int idx = 0, c; |
| 914 | static const struct option long_options[] = { |
| 915 | { "ues", 1, 0, 'u' }, |
Neels Hofmeyr | 5f9be1e | 2016-02-29 13:33:44 +0100 | [diff] [blame] | 916 | { "gw-addr", 1, 0, 'g' }, |
Daniel Willmann | 141a0ba | 2015-12-17 18:03:52 +0100 | [diff] [blame] | 917 | { 0, 0, 0, 0 }, |
| 918 | }; |
| 919 | |
Neels Hofmeyr | 5f9be1e | 2016-02-29 13:33:44 +0100 | [diff] [blame] | 920 | c = getopt_long(argc, argv, "u:g:", long_options, &idx); |
Daniel Willmann | 141a0ba | 2015-12-17 18:03:52 +0100 | [diff] [blame] | 921 | |
| 922 | if (c == -1) |
| 923 | break; |
| 924 | |
| 925 | switch (c) { |
| 926 | case 'u': |
| 927 | g_hnb_test.ues = atoi(optarg); |
| 928 | break; |
Neels Hofmeyr | 5f9be1e | 2016-02-29 13:33:44 +0100 | [diff] [blame] | 929 | case 'g': |
| 930 | g_hnb_test.gw_addr = optarg; |
| 931 | break; |
Daniel Willmann | 141a0ba | 2015-12-17 18:03:52 +0100 | [diff] [blame] | 932 | } |
| 933 | } |
| 934 | } |
| 935 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 936 | int main(int argc, char **argv) |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 937 | { |
| 938 | int rc; |
| 939 | |
Harald Welte | 87ffeb9 | 2015-12-25 15:34:22 +0100 | [diff] [blame] | 940 | test_common_init(); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 941 | |
Harald Welte | 87ffeb9 | 2015-12-25 15:34:22 +0100 | [diff] [blame] | 942 | tall_hnb_ctx = talloc_named_const(NULL, 0, "hnb_context"); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 943 | |
| 944 | vty_init(&vty_info); |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 945 | hnbtest_vty_init(); |
| 946 | |
Neels Hofmeyr | a0d2147 | 2016-02-24 20:50:31 +0100 | [diff] [blame] | 947 | printf("VTY at %s %d\n", vty_get_bind_addr(), 2324); |
| 948 | rc = telnet_init_dynif(NULL, NULL, vty_get_bind_addr(), 2324); |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 949 | if (rc < 0) { |
| 950 | perror("Error binding VTY port"); |
| 951 | exit(1); |
| 952 | } |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 953 | |
Daniel Willmann | 141a0ba | 2015-12-17 18:03:52 +0100 | [diff] [blame] | 954 | handle_options(argc, argv); |
| 955 | |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 956 | osmo_wqueue_init(&g_hnb_test.wqueue, 16); |
| 957 | g_hnb_test.wqueue.bfd.data = &g_hnb_test; |
| 958 | g_hnb_test.wqueue.read_cb = hnb_read_cb; |
| 959 | g_hnb_test.wqueue.write_cb = hnb_write_cb; |
| 960 | |
| 961 | rc = osmo_sock_init_ofd(&g_hnb_test.wqueue.bfd, AF_INET, SOCK_STREAM, |
Neels Hofmeyr | 5f9be1e | 2016-02-29 13:33:44 +0100 | [diff] [blame] | 962 | IPPROTO_SCTP, g_hnb_test.gw_addr, |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 963 | g_hnb_test.gw_port, OSMO_SOCK_F_CONNECT); |
| 964 | if (rc < 0) { |
| 965 | perror("Error connecting to Iuh port"); |
| 966 | exit(1); |
| 967 | } |
Daniel Willmann | 4abdee0 | 2015-12-09 17:57:32 +0100 | [diff] [blame] | 968 | sctp_sock_init(g_hnb_test.wqueue.bfd.fd); |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 969 | |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 970 | #if 0 |
| 971 | /* some hard-coded message generation. Doesn't make sense from |
| 972 | * a protocol point of view but enables to look at the encoded |
| 973 | * results in wireshark for manual verification */ |
| 974 | { |
| 975 | struct msgb *msg, *rua; |
| 976 | const uint8_t nas[] = { 0, 1, 2, 3 }; |
| 977 | const uint8_t ik[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; |
| 978 | |
| 979 | msg = ranap_new_msg_dt(0, nas, sizeof(nas)); |
| 980 | rua = rua_new_udt(msg); |
| 981 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 982 | |
Daniel Willmann | f44d12c | 2016-04-20 10:16:37 +0200 | [diff] [blame] | 983 | msg = ranap_new_msg_sec_mod_cmd(ik, ik, RANAP_KeyStatus_new); |
Harald Welte | c385122 | 2015-12-24 15:41:21 +0100 | [diff] [blame] | 984 | rua = rua_new_udt(msg); |
| 985 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 986 | |
| 987 | msg = ranap_new_msg_iu_rel_cmd() |
| 988 | rua = rua_new_udt(msg); |
| 989 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 990 | |
| 991 | msg = ranap_new_msg_paging_cmd("901990123456789", NULL, 0, 0); |
| 992 | rua = rua_new_udt(msg); |
| 993 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 994 | |
| 995 | msg = ranap_new_msg_rab_assign_voice(1, 0x01020304, 0x1020); |
| 996 | rua = rua_new_udt(msg); |
| 997 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 998 | |
| 999 | msg = ranap_new_msg_rab_assign_data(2, 0x01020304, 0x11223344); |
| 1000 | rua = rua_new_udt(msg); |
| 1001 | osmo_wqueue_enqueue(&g_hnb_test.wqueue, rua); |
| 1002 | } |
| 1003 | #endif |
Daniel Willmann | 4aeef6c | 2015-12-03 17:02:13 +0100 | [diff] [blame] | 1004 | |
Daniel Willmann | 97374c0 | 2015-12-03 09:37:58 +0100 | [diff] [blame] | 1005 | while (1) { |
| 1006 | rc = osmo_select_main(0); |
| 1007 | if (rc < 0) |
| 1008 | exit(3); |
| 1009 | } |
| 1010 | |
| 1011 | /* not reached */ |
| 1012 | exit(0); |
| 1013 | } |