blob: d61e13f03de9e4ff1bf2d1684a83d7a4a5abb791 [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
2 * Copyright (c) 2003-2018, Great Software Laboratory Pvt. Ltd.
3 * Copyright (c) 2017 Intel Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __S1AP_STRUCTS_H_
19#define __S1AP_STRUCTS_H_
20
21#include <stdint.h>
22#include <stdbool.h>
23
24#include "sec.h"
25#include "ProcedureCode.h"
26#include "Criticality.h"
27#include "S1AP-PDU.h"
28#include "InitiatingMessage.h"
29
30#define NAS_RAND_SIZE 16
31#define NAS_AUTN_SIZE 16
32
33#define AUTH_REQ_NO_OF_IES 3
34#define SEC_MODE_NO_OF_IES 3
35#define ESM_REQ_NO_OF_IES 3
36#define ICS_REQ_NO_OF_IES 6
37#define DTCH_ACCEPT_NO_OF_IES 3
38#define UE_CTX_RELEASE_NO_OF_IES 3
39#define ATTACH_REJECT_NO_OF_IES 3
40
41#define ATTACH_ID_REQUEST_NO_OF_IES 3
42#define TAU_RSP_NO_OF_IES 3
43
44#define NI_UE_CTX_RELEASE_NO_OF_IES 3
45#define NI_DTCH_REQUEST_NO_OF_IES 3
46
47
48#define AUTH_REQ_NO_OF_NAS_IES 2
49#define SEC_MODE_NO_OF_NAS_IES 1
50#define ICS_REQ_NO_OF_NAS_IES 5
51#define TAU_RSP_NO_OF_NAS_IES 2
52
53#define SERVICE_REQ_SECURITY_HEADER 12
54#define SHORT_MAC_SIZE 2
55
56#define AUTHREQ_NAS_SECURITY_PARAM 0x01
57
58#define MSISDN_STR_LEN 10
59
60#define EMM_MAX_TAI_LIST 16
61
62#define SECURITY_KEY_SIZE 32
63
64#define MAC_SIZE 4
65#define AUTH_SYNC_FAILURE 21
66#define AUTH_RESPONSE 53
67/* ESM messages */
68 #define ESM_MSG_ACTV_DEF_BEAR__CTX_REQ 0xc1
69
70/*24.008 - 10.5.6.1
71APN name can be in range of min 3 octets to max 102 octets
72*/
73#define MAX_APN_LEN 102
74
75
76struct apn_name {
77 unsigned char len;
78 unsigned char val[MAX_APN_LEN];/*TODO: Make dynamic as range is big 3-102*/
79};
80
81/*TODO: Needed fro paging. Ignoring for now*/
82struct proto_conf {
83 int placeholder;
84};
85
86struct esm_sec_info {
87 struct proto_conf proto_config;
88};
89
90/*NAS MSG IE CODES */
91/* Message content :
92 3gpp 24.301
93 Table 8.2.4.1: IEI Column.*/
94typedef enum
95{
96 NAS_IE_TYPE_EPS_MOBILE_ID_IMSI=0x1,
97 NAS_IE_TYPE_UE_NETWORK_CAPABILITY=0x2,
98 NAS_IE_TYPE_ESM_MSG=0x3,
99 NAS_IE_TYPE_TMSI_STATUS=0x09,
100 NAS_IE_TYPE_MS_NETWORK_FEATURE_SUPPORT=0x0C,
101 NAS_IE_TYPE_GUTI_TYPE=0x0E,
102 NAS_IE_TYPE_ADDITIONAL_UPDATE_TYPE=0xF,
103 NAS_IE_TYPE_MS_CLASSMARK_2=0x11,
104 NAS_IE_TYPE_LAI=0x13,
105 NAS_IE_TYPE_PTMSI_SIGNATURE=0x19,
106 NAS_IE_TYPE_MS_CLASSMARK_3=0x20,
107 NAS_IE_TYPE_APN=0x28,
108 NAS_IE_TYPE_AUTH_FAIL_PARAM=0x30,
109 NAS_IE_TYPE_MS_NETWORK_CAPABILITY=0x31,
110 NAS_IE_TYPE_DRX_PARAM=0x5C,
111 NAS_IE_TYPE_TAI=0x52,
112 NAS_IE_TYPE_VOICE_DOMAIN_PREF_UE_USAGE_SETTING=0x5D,
113 NAS_IE_TYPE_TX_FLAG=0xAA,
114 NAS_IE_TYPE_PCO=0xAB,
115 NAS_IE_TYPE_PTI=0xAC,
116}nas_ie_type;
117typedef struct MS_net_capab {
118 bool pres;
119 unsigned char element_id;
120 unsigned char len;
121 unsigned char capab[6];
122}MS_net_capab;
123
124#if 0
125/* MS Network capability */
126typedef struct MS_net_capab {
127 unsigned char pres;
128 unsigned char len;
129 unsigned char gea1;
130 unsigned char smCapViaDdctdChan;
131 unsigned char smCapViaGprsChan;
132 unsigned char ucs2Supp;
133 unsigned char ssScrInd;
134 unsigned char soLsaCap;
135 unsigned char revLvlInd;
136 unsigned char pfcFeatMode;
137 unsigned char gea2;
138 unsigned char gea3;
139 unsigned char gea4;
140 unsigned char gea5;
141 unsigned char gea6;
142 unsigned char gea7;
143 unsigned char lcsVaCap;
144 unsigned char psInterRATho2UtranIuModeCap;
145 unsigned char psInterRATho2EutranS1ModeCap;
146 unsigned char csfbCap;
147 unsigned char isrSupp;
148 unsigned char srvcc2UtranCap;
149 unsigned char epcCap;
150}MS_net_capab;
151#endif
152
153struct UE_net_capab {
154 unsigned char len;
155 unsigned char capab[6];
156};
157#if 0
158/* UE Network capability */
159typedef struct UE_net_capab {
160 unsigned char pres;
161 unsigned char len;
162
163 unsigned char eea7;
164 unsigned char eea6;
165 unsigned char eea5;
166 unsigned char eea4;
167 unsigned char eea3;
168 unsigned char eea2_128;
169 unsigned char eea1_128;
170 unsigned char eea0;
171
172 unsigned char eia7;
173 unsigned char eia6;
174 unsigned char eia5;
175 unsigned char eia4;
176 unsigned char eia3;
177 unsigned char eia2_128;
178 unsigned char eia1_128;
179 unsigned char eia0;
180
181 unsigned char uea7;
182 unsigned char uea6;
183 unsigned char uea5;
184 unsigned char uea4;
185 unsigned char uea3;
186 unsigned char uea2;
187 unsigned char uea1;
188 unsigned char uea0;
189
190 unsigned char uia7;
191 unsigned char uia6;
192 unsigned char uia5;
193 unsigned char uia4;
194 unsigned char uia3;
195 unsigned char uia2;
196 unsigned char uia1;
197 unsigned char ucs2;
198
199 unsigned char vcc_1xsr;
200
201} UE_net_capab;
202#endif
203
204enum drx_params {
205 PAGINX_DRX32,
206 PAGINX_DRX64,
207 PAGINX_DRX128,
208 PAGINX_DRX256,
209 PAGINX_DRX512,
210};
211
212enum s1ap_cn_domain
213{
214 CN_DOMAIN_PS,
215 CN_DOMAIN_CS,
216 CN_DOMAIN_NONE
217};
218
219struct s1ap_header{
220 unsigned short procedure_code;
221 unsigned char criticality;
222};
223
224#pragma pack(1)
225
226/*36.413: 9.2.3.8 - MCC, MCN : Only 3 bytes are used*/
227struct PLMN {
228 unsigned char idx[3];
229};
230
231struct TAI {
232 struct PLMN plmn_id;
233 short tac; /*2 bytes. 36.413: 9.2.3.7*/
234};
235
236struct STMSI {
237 uint8_t mme_code;
238 uint32_t m_TMSI;
239};
240
241
242typedef struct tai_list {
243 uint8_t spare :1;
244 uint8_t type :2;
245 uint8_t num_of_elements :4;
246 struct TAI partial_list[EMM_MAX_TAI_LIST];
247} tai_list;
248
249typedef struct pdn_address {
250 uint8_t spare :5;
251 uint8_t type :3;
252 uint32_t ipv4; /* TODO: Revisit 24.301 - 9.9.4.9.1 */
253} pdn_address;
254
255typedef struct linked_transcation_id {
256 uint8_t flag :1;
257 uint8_t val :7;
258} linked_transcation_id;
259
260typedef struct esm_qos
261{
262 uint8_t reliability_class :3;
263 uint8_t delay_class :3;
264 uint8_t spare1 :2;
265 uint8_t precedence_class :3;
266 uint8_t spare2 :1;
267 uint8_t peak_throughput :4;
268 uint8_t mean_throughput :5;
269 uint8_t spare3 :3;
270 uint8_t delivery_err_sdu :3;
271 uint8_t delivery_order :2;
272 uint8_t traffic_class :3;
273 uint8_t max_sdu_size;
274 uint8_t mbr_ul;
275 uint8_t mbr_dl;
276 uint8_t sdu_err_ratio :4;
277 uint8_t residual_ber :4;
278 uint8_t trffic_prio :2;
279 uint8_t transfer_delay :6;
280 uint8_t gbr_ul;
281 uint8_t gbr_dl;
282 uint8_t src_stat_desc :4;
283 uint8_t sig_ind :1;
284 uint8_t spare4 :3;
285 uint8_t mbr_dl_ext;
286 uint8_t gbr_dl_ext;
287 uint8_t mbr_ul_ext;
288 uint8_t gbr_ul_ext;
289
290} esm_qos;
291
292/* TODO : Revisit 24.301 - 9.9.4.2.1 */
293typedef struct ESM_APN_AMBR {
294 uint8_t dl;
295 uint8_t reserved;
296 uint8_t dlext;
297 uint8_t ulext;
298 uint8_t dlext2;
299 /* uint8_t dl_total; */
300 uint8_t ulext2;
301 /* uint8_t ul_total; */
302} ESM_APN_AMBR;
303
304typedef struct guti {
305 uint8_t spare :4;
306 uint8_t odd_even_indication :1;
307 uint8_t id_type :3;
308 struct PLMN plmn_id;
309 uint16_t mme_grp_id;
310 uint8_t mme_code;
311 uint32_t m_TMSI;
312} guti;
313
314typedef struct esm_msg_container {
315 uint8_t eps_bearer_id :4;
316 uint8_t proto_discriminator :4;
317 uint8_t procedure_trans_identity;
318 uint8_t session_management_msgs;
319 uint8_t eps_qos; /* TODO: Revisit 24.301 - 9.9.4.3.1 */
320 struct apn_name apn;
321 pdn_address pdn_addr;
322 linked_transcation_id linked_ti;
323 esm_qos negotiated_qos;
324 ESM_APN_AMBR apn_ambr;
325} esm_msg_container;
326
327typedef struct ue_sec_capabilities {
328 uint8_t eea1 :1;
329 uint8_t eea2 :1;
330 uint8_t eea3 :1;
331 uint8_t eea4 :1;
332 uint8_t eea5 :1;
333 uint8_t eea6_128 :1;
334 uint8_t eea7_128 :1;
335 uint8_t eea8 :1;
336
337 uint8_t eia1 :1;
338 uint8_t eia2 :1;
339 uint8_t eia3 :1;
340 uint8_t eia4 :1;
341 uint8_t eia5 :1;
342 uint8_t eia6_128 :1;
343 uint8_t eia8_128 :1;
344 uint8_t eia8 :1;
345
346 uint8_t uea1 :1;
347 uint8_t uea2 :1;
348 uint8_t uea3 :1;
349 uint8_t uea4 :1;
350 uint8_t uea5 :1;
351 uint8_t uea6 :1;
352 uint8_t uea7 :1;
353 uint8_t uea8 :1;
354
355 uint8_t uia1 :1;
356 uint8_t uia2 :1;
357 uint8_t uia3 :1;
358 uint8_t uia4 :1;
359 uint8_t uia5 :1;
360 uint8_t uia6 :1;
361 uint8_t uia7 :1;
362 uint8_t spare1 :1;
363
364 uint8_t gea1 :1;
365 uint8_t gea2 :1;
366 uint8_t gea3 :1;
367 uint8_t gea4 :1;
368 uint8_t gea5 :1;
369 uint8_t gea6 :1;
370 uint8_t gea7 :1;
371 uint8_t spare2 :1;
372} ue_sec_capabilities;
373
374typedef struct nas_pdu_header {
375 unsigned char security_header_type:4;
376 unsigned char proto_discriminator:4;
377 unsigned char message_type;
378 unsigned char security_encryption_algo:4;
379 unsigned char security_integrity_algo:4;
380 unsigned char nas_security_param;
381 unsigned char mac[MAC_SIZE];
382 unsigned char short_mac[SHORT_MAC_SIZE];
383 unsigned char ksi;
384 unsigned char seq_no;
385 unsigned char eps_bearer_identity;
386 unsigned char procedure_trans_identity;
387 unsigned char detach_type;
388} nas_pdu_header;
389
390#pragma pack()
391
392/****Information elements presentations **/
393#define BINARY_IMSI_LEN 8 /*same as packet capture. TODO: Write macros*/
394#define BCD_IMSI_STR_LEN 15
395
396/*36.413 - 9.2.1.38*/
397struct CGI {
398 struct PLMN plmn_id;
399 int cell_id;
400};
401/*36.413: 9.2.1.37*/
402#define MACRO_ENB_ID_SIZE 20
403struct ie_global_enb_id {
404 int plmn;
405 char macro_enb_id[MACRO_ENB_ID_SIZE];
406 /*TODO: make union of enb IDs*/
407};
408
409/*36.413: 9.1.8.4*/
410#define ENB_NAME_SIZE 150
411struct ie_enb_name {
412 char enb_name[ENB_NAME_SIZE];
413};
414
415/*36.413: 9.2.1.3a*/
416enum ie_RRC_est_cause {
417 EMERGENCY,
418 HIGHPRIORITYACCESS,
419 MT_ACCESS,
420 MO_SIGNALLING,
421 MO_DATA,
422 DELAYTOLERANTACCESS,
423 MO_VOICECALL,
424 MO_EXCEPTIONDATA
425};
426
427/**E-RAB structure declarations**/
428struct eRAB_header { //TODO: making provision, chec -is it needed?
429 unsigned char criticality;
430};
431
432struct eRAB_setup_ctx_SU {
433 unsigned short eRAB_id;
434 unsigned short dont_know_byte;
435 unsigned int transp_layer_addr;
436 unsigned int gtp_teid;
437};
438
439union eRAB_IE {
440 struct eRAB_setup_ctx_SU su_res;
441};
442
443typedef struct eRAB_elements {
444 struct eRAB_header header;
445 unsigned char no_of_elements;
446 union eRAB_IE *elements;
447}eRAB_elements;
448/**eRAB structures end**/
449
450/**Information elements structs end**/
451typedef union nas_pdu_elements_union {
452 unsigned char rand[NAS_RAND_SIZE];
453 unsigned char autn[NAS_AUTN_SIZE];
454 unsigned char IMSI[BINARY_IMSI_LEN];
455 unsigned char short_mac[SHORT_MAC_SIZE];
456 struct esm_sec_info esm_info;
457 enum drx_params drx;
458 struct MS_net_capab ms_network;
459 struct UE_net_capab ue_network;
460
461 struct XRES auth_resp; /*Authentication response*/
462 struct AUTS auth_fail_resp; /*Authentication response*/
463
464 struct apn_name apn;
465
466 unsigned char attach_res;
467 unsigned char t3412;
468 tai_list tailist;
469 esm_msg_container esm_msg;
470 guti mi_guti;
471 bool esm_info_tx_required;
472 unsigned char pti;
473 unsigned char eps_res;
474 unsigned char spare;
475 unsigned short int pco_options[10];
476}nas_pdu_elements_union;
477typedef struct nas_pdu_elements {
478 nas_ie_type msgType;
479 nas_pdu_elements_union pduElement;
480}nas_pdu_elements;
481
482
483#define NAS_MSG_UE_IE_GUTI 0x00000001
484#define NAS_MSG_UE_IE_IMSI 0x00000002
485#define UE_ID_IMSI(flags) ((flags & NAS_MSG_UE_IE_IMSI) == NAS_MSG_UE_IE_IMSI)
486#define UE_ID_GUTI(flags) ((flags & NAS_MSG_UE_IE_GUTI) == NAS_MSG_UE_IE_GUTI)
487typedef struct nasPDU {
488 nas_pdu_header header;
489 unsigned char elements_len;
490 nas_pdu_elements *elements;
491 unsigned int flags;
492} nasPDU;
493
494#pragma pack(1)
495/* TODO : Change type */
496typedef struct ue_aggregate_maximum_bitrate {
497 uint32_t uEaggregateMaxBitRateDL;
498 uint32_t uEaggregateMaxBitRateUL;
499} ue_aggregate_maximum_bitrate;
500
501typedef struct allocation_retention_prio {
502 uint8_t prioLevel :4;
503 uint8_t preEmptionCapab :1;
504 uint8_t preEmptionVulnebility :1;
505 uint8_t spare :2;
506} allocation_retention_prio;
507
508typedef struct E_RAB_Level_QoS_Params {
509 uint8_t qci;
510 //uint8_t ext;
511 allocation_retention_prio arPrio;
512} E_RAB_Level_QoS_Params;
513
514typedef struct ERABSetup {
515 uint8_t e_RAB_ID;
516 E_RAB_Level_QoS_Params e_RAB_QoS_Params;
517 uint32_t transportLayerAddress;
518 uint32_t gtp_teid;
519 struct nasPDU nas;
520} ERABSetup;
521
522#pragma pack()
523/* Dependencies */
524typedef enum s1apCause_PR {
525 s1apCause_PR_NOTHING, /* No components present */
526 s1apCause_PR_radioNetwork,
527 s1apCause_PR_transport,
528 s1apCause_PR_nas,
529 s1apCause_PR_protocol,
530 s1apCause_PR_misc
531
532} s1apCause_PR;
533
534typedef enum s1apCause_PR_transporauseRadioNetwork {
535 s1apCauseRadioNetwork_unspecified = 0,
536 s1apCauseRadioNetwork_tx2relocoverall_expiry = 1,
537 s1apCauseRadioNetwork_successful_handover = 2,
538 s1apCauseRadioNetwork_release_due_to_eutran_generated_reason = 3,
539 s1apCauseRadioNetwork_handover_cancelled = 4,
540 s1apCauseRadioNetwork_partial_handover = 5,
541 s1apCauseRadioNetwork_ho_failure_in_target_EPC_eNB_or_target_system = 6,
542 s1apCauseRadioNetwork_ho_target_not_allowed = 7,
543 s1apCauseRadioNetwork_tS1relocoverall_expiry = 8,
544 s1apCauseRadioNetwork_tS1relocprep_expiry = 9,
545 s1apCauseRadioNetwork_cell_not_available = 10,
546 s1apCauseRadioNetwork_unknown_targetID = 11,
547 s1apCauseRadioNetwork_no_radio_resources_available_in_target_cell = 12,
548 s1apCauseRadioNetwork_unknown_mme_ue_s1ap_id = 13,
549 s1apCauseRadioNetwork_unknown_enb_ue_s1ap_id = 14,
550 s1apCauseRadioNetwork_unknown_pair_ue_s1ap_id = 15,
551 s1apCauseRadioNetwork_handover_desirable_for_radio_reason = 16,
552 s1apCauseRadioNetwork_time_critical_handover = 17,
553 s1apCauseRadioNetwork_resource_optimisation_handover = 18,
554 s1apCauseRadioNetwork_reduce_load_in_serving_cell = 19,
555 s1apCauseRadioNetwork_user_inactivity = 20,
556 s1apCauseRadioNetwork_radio_connection_with_ue_lost = 21,
557 s1apCauseRadioNetwork_load_balancing_tau_required = 22,
558 s1apCauseRadioNetwork_cs_fallback_triggered = 23,
559 s1apCauseRadioNetwork_ue_not_available_for_ps_service = 24,
560 s1apCauseRadioNetwork_radio_resources_not_available = 25,
561 s1apCauseRadioNetwork_failure_in_radio_interface_procedure = 26,
562 s1apCauseRadioNetwork_invalid_qos_combination = 27,
563 s1apCauseRadioNetwork_interrat_redirection = 28,
564 s1apCauseRadioNetwork_interaction_with_other_procedure = 29,
565 s1apCauseRadioNetwork_unknown_E_RAB_ID = 30,
566 s1apCauseRadioNetwork_multiple_E_RAB_ID_instances = 31,
567 s1apCauseRadioNetwork_encryption_and_or_integrity_protection_algorithms_not_supported = 32,
568 s1apCauseRadioNetwork_s1_intra_system_handover_triggered = 33,
569 s1apCauseRadioNetwork_s1_inter_system_handover_triggered = 34,
570 s1apCauseRadioNetwork_x2_handover_triggered = 35,
571 s1apCauseRadioNetwork_redirection_towards_1xRTT = 36,
572 s1apCauseRadioNetwork_not_supported_QCI_value = 37,
573 s1apCauseRadioNetwork_invalid_CSG_Id = 38,
574 s1apCauseRadioNetwork_release_due_to_pre_emption = 39
575} e_s1apCauseRadioNetwork;
576
577typedef enum s1apCauseTransport {
578 s1apCauseTransport_transport_resource_unavailable = 0,
579 s1apCauseTransport_unspecified = 1
580} e_s1apCauseTransport;
581
582typedef enum s1apCauseNas {
583 s1apCauseNas_normal_release = 0,
584 s1apCauseNas_authentication_failure = 1,
585 s1apCauseNas_detach = 2,
586 s1apCauseNas_unspecified = 3,
587 s1apCauseNas_csg_subscription_expiry = 4
588} e_s1apCauseNas;
589
590typedef enum s1apCauseProtocol {
591 s1apCauseProtocol_transfer_syntax_error = 0,
592 s1apCauseProtocol_abstract_syntax_error_reject = 1,
593 s1apCauseProtocol_abstract_syntax_error_ignore_and_notify = 2,
594 s1apCauseProtocol_message_not_compatible_with_receiver_state = 3,
595 s1apCauseProtocol_semantic_error = 4,
596 s1apCauseProtocol_abstract_syntax_error_falsely_constructed_message = 5,
597 s1apCauseProtocol_unspecified = 6
598} e_s1apCauseProtocol;
599
600typedef enum s1apCauseMisc {
601 s1apCauseMisc_control_processing_overload = 0,
602 s1apCauseMisc_not_enough_user_plane_processing_resources = 1,
603 s1apCauseMisc_hardware_failure = 2,
604 s1apCauseMisc_om_intervention = 3,
605 s1apCauseMisc_unspecified = 4,
606 s1apCauseMisc_unknown_PLMN = 5
607} e_s1apCauseMisc;
608
609/* s1apCauseMisc */
610typedef long s1apCauseMisc_t;
611/* s1apCauseProtocol */
612typedef long s1apCauseProtocol_t;
613/* s1apCauseNas */
614typedef long s1apCauseNas_t;
615/* s1apCauseTransport */
616typedef long s1apCauseTransport_t;
617/* s1apCauseRadioNetwork */
618typedef long s1apCauseRadioNetwork_t;
619
620typedef struct s1apCause {
621 s1apCause_PR present;
622 union s1apCause_u {
623 s1apCauseRadioNetwork_t radioNetwork;
624 s1apCauseTransport_t transport;
625 s1apCauseNas_t nas;
626 s1apCauseProtocol_t protocol;
627 s1apCauseMisc_t misc;
628 } choice;
629} s1apCause_t;
630
631
632typedef struct proto_IE_data {
633 int IE_type;
634 union value{
635 struct ie_enb_name enb_name;
636 struct ie_global_enb_id global_enb_id;
637 long enb_ue_s1ap_id;
638 long mme_ue_s1ap_id;
639 struct nasPDU nas;
640 struct s1apCause cause;
641 struct TAI tai;
642 struct CGI utran_cgi;
643 struct STMSI s_tmsi;
644 enum ie_RRC_est_cause rrc_est_cause;
645 struct eRAB_elements erab;
646 ue_aggregate_maximum_bitrate ue_aggrt_max_bit_rate;
647 ERABSetup E_RABToBeSetupItemCtxtSUReq;
648 ue_sec_capabilities ue_sec_capab;
649 uint8_t sec_key[SECURITY_KEY_SIZE];
650 }val;
651}proto_IEs;
652
653struct proto_IE {
654 ProcedureCode_t procedureCode;
655 Criticality_t criticality;
656 short no_of_IEs;
657 proto_IEs *data;
658 uint8_t ie_nas_index;
659 uint8_t ie_tai_index;
660 uint8_t ie_cgi_index;
661};
662
663enum protocolie_id {
664 id_MME_UE_S1AP_ID = 0,
665 id_Cause = 2,
666 id_eNB_UE_S1AP_ID = 8,
667 id_ERABToBeSetupListCtxtSUReq = 24,
668 id_NAS_PDU = 26,
669 id_ERABToBeSetupItemCtxtSUReq = 52,
670 id_uEaggregatedMaximumBitrate = 66,
671 id_SecurityKey = 73,
672 id_UE_S1AP_IDs = 99,
673 id_UESecurityCapabilities = 107,
674};
675
676enum protocol_discriminator{
677 EPSSessionManagementMessage = 2,
678 EPSMobilityManagementMessages = 7,
679};
680
681enum criticality{
682 CRITICALITY_REJECT = 0x0,
683 CRITICALITY_IGNORE = 0x40,
684 CRITICALITY_NOTIFY,
685};
686
687enum eps_nas_mesage_type {
688 AttachAccept = 0x42,
689 AttachReject = 0x44,
690 DetachAccept = 0x46,
691 DetachRequest = 0x45,
692 TauAccept = 0x49,
693 TauReject = 0x4b,
694 AuthenticationRequest = 0x52,
695 IdentityRequest = 0x55,
696 SecurityModeCommand = 0x5d,
697 ESMInformationRequest = 0xd9,
698};
699
700enum procedure_code {
701 id_InitialContextSetup = 9,
702 id_downlinkNASTransport = 11,
703 id_errorIndication = 15,
704 id_UEContexRelease = 23,
705};
706
707typedef struct s1ap_PDU {
708 unsigned char procedurecode;
709 unsigned char criticality;
710 struct proto_IE value;
711}s1ap_PDU;
712
713/* NAS Security Header */
714typedef enum security_header_type {
715 Plain = 0,
716 IntegrityProtected,
717 IntegrityProtectedCiphered,
718 IntegrityProtectedEPSSecCntxt,
719}security_header_type;
720
721typedef struct nas_pdu_header_sec {
722 unsigned char security_header_type:4;
723 unsigned char proto_discriminator:4;
724 unsigned char mac[MAC_SIZE];
725 unsigned char seq_no;
726}nas_pdu_header_sec;
727
728typedef struct nas_pdu_header_short {
729 unsigned char security_header_type:4;
730 unsigned char proto_discriminator:4;
731 unsigned char message_type;
732}nas_pdu_header_short;
733
734typedef struct nas_pdu_header_long {
735 unsigned char security_header_type:4;
736 unsigned char proto_discriminator:4;
737 unsigned char procedure_trans_identity;
738 unsigned char message_type;
739}nas_pdu_header_long;
740
741/* NAS Security Encryption Algorithm */
742typedef enum security_encryption_algo {
743 Algo_EEA0 = 0,
744
745}security_encryption_algo;
746
747/* NAS Security Integrity Algorithm */
748typedef enum security_integrity_algo {
749 Algo_EIA0 = 0,
750 Algo_128EIA1 = 1,
751}security_integrity_algo;
752
753
754#define BUFFER_SIZE 255
755
756typedef struct Buffer {
757 unsigned char buf[BUFFER_SIZE];
758 unsigned char pos;
759}Buffer;
760
761#endif /*__S1AP_STRUCTS_H*/