"Fossies" - the Fresh Open Source Software Archive 
Member "wireshark-4.0.8/epan/dissectors/packet-nas_5gs.c" (23 Aug 2023, 496886 Bytes) of package /linux/misc/wireshark-4.0.8.tar.xz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "packet-nas_5gs.c" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
4.0.7_vs_4.0.8.
1 /* packet-nas_5gs.c
2 * Routines for Non-Access-Stratum (NAS) protocol for 5G System (5GS) dissection
3 *
4 * Copyright 2018-2022, Anders Broman <anders.broman@ericsson.com>
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
12 * References: 3GPP TS 24.501 16.8.0
13 */
14
15 #include "config.h"
16
17 #include <epan/packet.h>
18 #include <epan/expert.h>
19 #include <epan/proto_data.h>
20 #include <epan/ipproto.h>
21 #include <epan/etypes.h>
22 #include <epan/exceptions.h>
23 #include <epan/show_exception.h>
24 #include <epan/to_str.h>
25
26 #include <wsutil/pow2.h>
27 #include <wsutil/pint.h>
28 #include <wsutil/wsjson.h>
29
30 #include "packet-gsm_a_common.h"
31 #include "packet-e212.h"
32 #include "packet-http.h"
33 #include "packet-tcp.h"
34
35 void proto_register_nas_5gs(void);
36 void proto_reg_handoff_nas_5gs(void);
37
38 static gboolean g_nas_5gs_null_decipher = FALSE;
39 enum {
40 DECODE_USER_DATA_AS_NONE,
41 DECODE_USER_DATA_AS_IP,
42 DECODE_USER_DATA_AS_NON_IP,
43 DECODE_USER_DATA_AS_ETHERNET
44 };
45 static const enum_val_t nas_5gs_user_data_container_as_vals[] = {
46 {"none", "None", DECODE_USER_DATA_AS_NONE},
47 {"ip", "IP", DECODE_USER_DATA_AS_IP},
48 {"non_ip","Non IP", DECODE_USER_DATA_AS_NON_IP},
49 {"ethernet","Ethernet", DECODE_USER_DATA_AS_ETHERNET},
50 {NULL, NULL, -1}
51 };
52 static gint g_nas_5gs_decode_user_data_container_as = DECODE_USER_DATA_AS_NONE;
53 static const gchar *g_nas_5gs_non_ip_data_dissector = "";
54
55
56 static int dissect_nas_5gs_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, void* data);
57 static int dissect_nas_5gs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data);
58 static guint16 de_nas_5gs_cmn_dnn(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
59 static guint16 de_nas_5gs_mm_pdu_ses_id_2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_);
60 static guint16 de_nas_5gs_cmn_add_inf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_);
61 static void nas_5gs_mm_5gmm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len);
62 static guint16 de_nas_5gs_mm_req_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_);
63
64 static dissector_handle_t nas_5gs_handle;
65 static dissector_handle_t eap_handle;
66 static dissector_handle_t nas_eps_handle;
67 static dissector_handle_t nas_eps_plain_handle;
68 static dissector_handle_t lpp_handle;
69 static dissector_handle_t gsm_a_dtap_handle;
70 static dissector_handle_t ipv4_handle;
71 static dissector_handle_t ipv6_handle;
72 static dissector_handle_t non_ip_data_handle;
73 static dissector_handle_t ethernet_handle;
74
75 #define PNAME "Non-Access-Stratum 5GS (NAS)PDU"
76 #define PSNAME "NAS-5GS"
77 #define PFNAME "nas-5gs"
78
79 static int proto_json = -1;
80
81 static int proto_nas_5gs = -1;
82
83 int hf_nas_5gs_common_elem_id = -1;
84 int hf_nas_5gs_mm_elem_id = -1;
85 int hf_nas_5gs_sm_elem_id = -1;
86 int hf_nas_5gs_updp_elem_id = -1;
87
88 static int hf_nas_5gs_epd = -1;
89 static int hf_nas_5gs_spare_bits = -1;
90 static int hf_nas_5gs_spare_b7 = -1;
91 static int hf_nas_5gs_spare_b6 = -1;
92 static int hf_nas_5gs_spare_b5 = -1;
93 static int hf_nas_5gs_spare_b4 = -1;
94 static int hf_nas_5gs_spare_b3 = -1;
95 static int hf_nas_5gs_spare_b2 = -1;
96 static int hf_nas_5gs_spare_b1 = -1;
97 static int hf_nas_5gs_spare_b0 = -1;
98 static int hf_nas_5gs_rfu_b2;
99 static int hf_nas_5gs_rfu_b1;
100 static int hf_nas_5gs_rfu_b0;
101 static int hf_nas_5gs_security_header_type = -1;
102 static int hf_nas_5gs_msg_auth_code = -1;
103 static int hf_nas_5gs_seq_no = -1;
104 static int hf_nas_5gs_mm_msg_type = -1;
105 static int hf_nas_5gs_sm_msg_type = -1;
106 static int hf_nas_5gs_updp_msg_type = -1;
107 static int hf_nas_5gs_proc_trans_id = -1;
108 static int hf_nas_5gs_spare_half_octet = -1;
109 static int hf_nas_5gs_spare_octet = -1;
110 static int hf_nas_5gs_pdu_session_id = -1;
111 static int hf_nas_5gs_msg_elems = -1;
112 static int hf_nas_5gs_mm_for = -1;
113 static int hf_nas_5gs_cmn_add_info = -1;
114 static int hf_nas_5gs_cmn_acc_type = -1;
115 static int hf_nas_5gs_cmn_dnn = -1;
116 static int hf_nas_5gs_mm_sms_requested = -1;
117 static int hf_nas_5gs_mm_ng_ran_rcu = -1;
118 static int hf_nas_5gs_mm_5gs_pnb_ciot = -1;
119 static int hf_nas_5gs_mm_eps_pnb_ciot = -1;
120 static int hf_nas_5gs_mm_5gs_reg_type = -1;
121 static int hf_nas_5gs_mm_tsc = -1;
122 static int hf_nas_5gs_mm_nas_key_set_id = -1;
123 static int hf_nas_5gs_mm_tsc_h1 = -1;
124 static int hf_nas_5gs_mm_nas_key_set_id_h1 = -1;
125 static int hf_nas_5gs_mm_5gmm_cause = -1;
126 static int hf_nas_5gs_mm_pld_cont_type = -1;
127 static int hf_nas_5gs_mm_sst = -1;
128 static int hf_nas_5gs_mm_sd = -1;
129 static int hf_nas_5gs_mm_mapped_hplmn_sst = -1;
130 static int hf_nas_5gs_mm_mapped_hplmn_ssd = -1;
131 static int hf_nas_5gs_mm_switch_off = -1;
132 static int hf_nas_5gs_mm_re_reg_req = -1;
133 static int hf_nas_5gs_mm_acc_type = -1;
134 static int hf_nas_5gs_mm_raai_b0 = -1;
135 static int hf_nas_5gs_mm_sprti_b1 = -1;
136 static int hf_nas_5gs_mm_ma_pdu_session_info_value = -1;
137 static int hf_nas_5gs_mm_len_of_mapped_s_nssai = -1;
138 static int hf_nas_5gs_mm_conf_upd_ind_ack_b0 = -1;
139 static int hf_nas_5gs_mm_conf_upd_ind_red_b1 = -1;
140 static int hf_nas_5gs_mm_cag_info_entry_len = -1;
141 static int hf_nas_5gs_mm_cag_info_entry_cag_only = -1;
142 static int hf_nas_5gs_mm_cag_info_entry_cag_id = -1;
143 static int hf_nas_5gs_mm_ciot_small_data_cont_data_type = -1;
144 static int hf_nas_5gs_mm_ciot_small_data_cont_ddx = -1;
145 static int hf_nas_5gs_mm_ciot_small_data_cont_pdu_session_id = -1;
146 static int hf_nas_5gs_mm_ciot_small_data_cont_add_info_len = -1;
147 static int hf_nas_5gs_mm_ciot_small_data_cont_add_info = -1;
148 static int hf_nas_5gs_mm_ciot_small_data_cont_data_contents = -1;
149 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_1 = -1;
150 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_2 = -1;
151 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_3 = -1;
152 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_4 = -1;
153 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_5 = -1;
154 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_6 = -1;
155 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_7 = -1;
156 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_8 = -1;
157 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_1 = -1;
158 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_2 = -1;
159 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_3 = -1;
160 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_4 = -1;
161 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_5 = -1;
162 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_6 = -1;
163 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_7 = -1;
164 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_8 = -1;
165 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_9 = -1;
166 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_10 = -1;
167 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_11 = -1;
168 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_12 = -1;
169 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_13 = -1;
170 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_14 = -1;
171 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_15 = -1;
172 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_16 = -1;
173 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_17 = -1;
174 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_18 = -1;
175 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_19 = -1;
176 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_20 = -1;
177 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_21 = -1;
178 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_22 = -1;
179 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_23 = -1;
180 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_24 = -1;
181 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_25 = -1;
182 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_3_1 = -1;
183 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_4_1 = -1;
184 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_5_1 = -1;
185 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_1 = -1;
186 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_2 = -1;
187 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_3 = -1;
188 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_4 = -1;
189 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_5 = -1;
190 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_6 = -1;
191 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_7 = -1;
192 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_8 = -1;
193 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_1 = -1;
194 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_2 = -1;
195 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_3 = -1;
196 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_4 = -1;
197 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_5 = -1;
198 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_6 = -1;
199 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_7 = -1;
200 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_8 = -1;
201 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_9 = -1;
202 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_10 = -1;
203 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_11 = -1;
204 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_12 = -1;
205 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_13 = -1;
206 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_14 = -1;
207 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_15 = -1;
208 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_16 = -1;
209 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_17 = -1;
210 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_18 = -1;
211 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_19 = -1;
212 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_20 = -1;
213 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_21 = -1;
214 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_22 = -1;
215 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_23 = -1;
216 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_3_1 = -1;
217 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_4_1 = -1;
218 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_5_1 = -1;
219 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_6_1 = -1;
220 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_6_2 = -1;
221 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_6_3 = -1;
222 static int hf_nas_5gs_mm_ciph_key_data_ciphering_set_id = -1;
223 static int hf_nas_5gs_mm_ciph_key_data_ciphering_key = -1;
224 static int hf_nas_5gs_mm_ciph_key_data_c0_len = -1;
225 static int hf_nas_5gs_mm_ciph_key_data_c0 = -1;
226 static int hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_len = -1;
227 static int hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_len = -1;
228 static int hf_nas_5gs_mm_ciph_key_data_validity_start_time = -1;
229 static int hf_nas_5gs_mm_ciph_key_data_validity_duration = -1;
230 static int hf_nas_5gs_mm_ciph_key_data_tais_list_len = -1;
231 static int hf_nas_5gs_mm_ctrl_plane_serv_type = -1;
232 static int hf_nas_5gs_mm_nas_sec_algo_enc = -1;
233 static int hf_nas_5gs_mm_nas_sec_algo_ip = -1;
234 static int hf_nas_5gs_mm_s1_mode_b0 = -1;
235 static int hf_nas_5gs_mm_ho_attach_b1 = -1;
236 static int hf_nas_5gs_mm_lpp_cap_b2 = -1;
237 static int hf_nas_5gs_mm_restrict_ec_b3 = -1;
238 static int hf_nas_5gs_mm_5g_cp_ciot_b4 = -1;
239 static int hf_nas_5gs_mm_n3_data_b5 = -1;
240 static int hf_nas_5gs_mm_5g_iphc_cp_ciot_b6 = -1;
241 static int hf_nas_5gs_mm_sgc_b7 = -1;
242 static int hf_nas_5gs_mm_5g_srvcc_b0 = -1;
243 static int hf_nas_5gs_mm_5g_up_ciot_b1 = -1;
244 static int hf_nas_5gs_mm_v2x_b2 = -1;
245 static int hf_nas_5gs_mm_v2xcepc5_b3 = -1;
246 static int hf_nas_5gs_mm_v2xcnpc5_b4 = -1;
247 static int hf_nas_5gs_mm_5g_lcs_b5 = -1;
248 static int hf_nas_5gs_mm_nssaa_b6 = -1;
249 static int hf_nas_5gs_mm_racs_b7 = -1;
250 static int hf_nas_5gs_mm_cag_b0 = -1;
251 static int hf_nas_5gs_mm_wsusa_b1 = -1;
252 static int hf_nas_5gs_mm_multiple_up_b2 = -1;
253 static int hf_nas_5gs_mm_5g_ehc_cp_ciot_b3 = -1;
254 static int hf_nas_5gs_mm_type_id = -1;
255 static int hf_nas_5gs_mm_odd_even = -1;
256 static int hf_nas_5gs_mm_length = -1;
257 static int hf_nas_5gs_mm_pld_cont = -1;
258 static int hf_nas_5gs_mm_pld_cont_nb_entries = -1;
259 static int hf_nas_5gs_mm_pld_cont_pld_cont_len = -1;
260 static int hf_nas_5gs_mm_pld_cont_nb_opt_ies = -1;
261 static int hf_nas_5gs_mm_pld_cont_pld_cont_type = -1;
262 static int hf_nas_5gs_mm_pld_cont_opt_ie_type = -1;
263 static int hf_nas_5gs_mm_pld_cont_opt_ie_len = -1;
264 static int hf_nas_5gs_mm_pld_cont_opt_ie_val = -1;
265 static int hf_nas_5gs_mm_req_type = -1;
266 static int hf_nas_5gs_mm_serv_type = -1;
267 static int hf_nas_5gs_mm_5g_ea0 = -1;
268 static int hf_nas_5gs_mm_128_5g_ea1 = -1;
269 static int hf_nas_5gs_mm_128_5g_ea2 = -1;
270 static int hf_nas_5gs_mm_128_5g_ea3 = -1;
271 static int hf_nas_5gs_mm_5g_ea4 = -1;
272 static int hf_nas_5gs_mm_5g_ea5 = -1;
273 static int hf_nas_5gs_mm_5g_ea6 = -1;
274 static int hf_nas_5gs_mm_5g_ea7 = -1;
275 static int hf_nas_5gs_mm_5g_ia0 = -1;
276 static int hf_nas_5gs_mm_5g_128_ia1 = -1;
277 static int hf_nas_5gs_mm_5g_128_ia2 = -1;
278 static int hf_nas_5gs_mm_5g_128_ia3 = -1;
279 static int hf_nas_5gs_mm_5g_ia4 = -1;
280 static int hf_nas_5gs_mm_5g_ia5 = -1;
281 static int hf_nas_5gs_mm_5g_ia6 = -1;
282 static int hf_nas_5gs_mm_5g_ia7 = -1;
283 static int hf_nas_5gs_mm_eea0 = -1;
284 static int hf_nas_5gs_mm_128eea1 = -1;
285 static int hf_nas_5gs_mm_128eea2 = -1;
286 static int hf_nas_5gs_mm_eea3 = -1;
287 static int hf_nas_5gs_mm_eea4 = -1;
288 static int hf_nas_5gs_mm_eea5 = -1;
289 static int hf_nas_5gs_mm_eea6 = -1;
290 static int hf_nas_5gs_mm_eea7 = -1;
291 static int hf_nas_5gs_mm_eia0 = -1;
292 static int hf_nas_5gs_mm_128eia1 = -1;
293 static int hf_nas_5gs_mm_128eia2 = -1;
294 static int hf_nas_5gs_mm_eia3 = -1;
295 static int hf_nas_5gs_mm_eia4 = -1;
296 static int hf_nas_5gs_mm_eia5 = -1;
297 static int hf_nas_5gs_mm_eia6 = -1;
298 static int hf_nas_5gs_mm_eia7 = -1;
299 static int hf_nas_5gs_mm_n1_mode_reg_b1 = -1;
300 static int hf_nas_5gs_mm_s1_mode_reg_b0 = -1;
301
302 static int hf_nas_5gs_mm_sal_al_t = -1;
303 static int hf_nas_5gs_mm_sal_t_li = -1;
304 static int hf_nas_5gs_mm_sal_num_e = -1;
305
306 static int hf_nas_5gs_pdu_ses_sts_psi_7_b7 = -1;
307 static int hf_nas_5gs_pdu_ses_sts_psi_6_b6 = -1;
308 static int hf_nas_5gs_pdu_ses_sts_psi_5_b5 = -1;
309 static int hf_nas_5gs_pdu_ses_sts_psi_4_b4 = -1;
310 static int hf_nas_5gs_pdu_ses_sts_psi_3_b3 = -1;
311 static int hf_nas_5gs_pdu_ses_sts_psi_2_b2 = -1;
312 static int hf_nas_5gs_pdu_ses_sts_psi_1_b1 = -1;
313 static int hf_nas_5gs_pdu_ses_sts_psi_0_b0 = -1;
314
315 static int hf_nas_5gs_pdu_ses_sts_psi_15_b7 = -1;
316 static int hf_nas_5gs_pdu_ses_sts_psi_14_b6 = -1;
317 static int hf_nas_5gs_pdu_ses_sts_psi_13_b5 = -1;
318 static int hf_nas_5gs_pdu_ses_sts_psi_12_b4 = -1;
319 static int hf_nas_5gs_pdu_ses_sts_psi_11_b3 = -1;
320 static int hf_nas_5gs_pdu_ses_sts_psi_10_b2 = -1;
321 static int hf_nas_5gs_pdu_ses_sts_psi_9_b1 = -1;
322 static int hf_nas_5gs_pdu_ses_sts_psi_8_b0 = -1;
323
324 static int hf_nas_5gs_pdu_ses_rect_res_psi_7_b7 = -1;
325 static int hf_nas_5gs_pdu_ses_rect_res_psi_6_b6 = -1;
326 static int hf_nas_5gs_pdu_ses_rect_res_psi_5_b5 = -1;
327 static int hf_nas_5gs_pdu_ses_rect_res_psi_4_b4 = -1;
328 static int hf_nas_5gs_pdu_ses_rect_res_psi_3_b3 = -1;
329 static int hf_nas_5gs_pdu_ses_rect_res_psi_2_b2 = -1;
330 static int hf_nas_5gs_pdu_ses_rect_res_psi_1_b1 = -1;
331 static int hf_nas_5gs_pdu_ses_rect_res_psi_0_b0 = -1;
332
333 static int hf_nas_5gs_pdu_ses_rect_res_psi_15_b7 = -1;
334 static int hf_nas_5gs_pdu_ses_rect_res_psi_14_b6 = -1;
335 static int hf_nas_5gs_pdu_ses_rect_res_psi_13_b5 = -1;
336 static int hf_nas_5gs_pdu_ses_rect_res_psi_12_b4 = -1;
337 static int hf_nas_5gs_pdu_ses_rect_res_psi_11_b3 = -1;
338 static int hf_nas_5gs_pdu_ses_rect_res_psi_10_b2 = -1;
339 static int hf_nas_5gs_pdu_ses_rect_res_psi_9_b1 = -1;
340 static int hf_nas_5gs_pdu_ses_rect_res_psi_8_b0 = -1;
341
342 static int hf_nas_5gs_ul_data_sts_psi_7_b7 = -1;
343 static int hf_nas_5gs_ul_data_sts_psi_6_b6 = -1;
344 static int hf_nas_5gs_ul_data_sts_psi_5_b5 = -1;
345 static int hf_nas_5gs_ul_data_sts_psi_4_b4 = -1;
346 static int hf_nas_5gs_ul_data_sts_psi_3_b3 = -1;
347 static int hf_nas_5gs_ul_data_sts_psi_2_b2 = -1;
348 static int hf_nas_5gs_ul_data_sts_psi_1_b1 = -1;
349 static int hf_nas_5gs_ul_data_sts_psi_0_b0 = -1;
350
351 static int hf_nas_5gs_ul_data_sts_psi_15_b7 = -1;
352 static int hf_nas_5gs_ul_data_sts_psi_14_b6 = -1;
353 static int hf_nas_5gs_ul_data_sts_psi_13_b5 = -1;
354 static int hf_nas_5gs_ul_data_sts_psi_12_b4 = -1;
355 static int hf_nas_5gs_ul_data_sts_psi_11_b3 = -1;
356 static int hf_nas_5gs_ul_data_sts_psi_10_b2 = -1;
357 static int hf_nas_5gs_ul_data_sts_psi_9_b1 = -1;
358 static int hf_nas_5gs_ul_data_sts_psi_8_b0 = -1;
359
360 static int hf_nas_5gs_allow_pdu_ses_sts_psi_7_b7 = -1;
361 static int hf_nas_5gs_allow_pdu_ses_sts_psi_6_b6 = -1;
362 static int hf_nas_5gs_allow_pdu_ses_sts_psi_5_b5 = -1;
363 static int hf_nas_5gs_allow_pdu_ses_sts_psi_4_b4 = -1;
364 static int hf_nas_5gs_allow_pdu_ses_sts_psi_3_b3 = -1;
365 static int hf_nas_5gs_allow_pdu_ses_sts_psi_2_b2 = -1;
366 static int hf_nas_5gs_allow_pdu_ses_sts_psi_1_b1 = -1;
367 static int hf_nas_5gs_allow_pdu_ses_sts_psi_0_b0 = -1;
368
369 static int hf_nas_5gs_allow_pdu_ses_sts_psi_15_b7 = -1;
370 static int hf_nas_5gs_allow_pdu_ses_sts_psi_14_b6 = -1;
371 static int hf_nas_5gs_allow_pdu_ses_sts_psi_13_b5 = -1;
372 static int hf_nas_5gs_allow_pdu_ses_sts_psi_12_b4 = -1;
373 static int hf_nas_5gs_allow_pdu_ses_sts_psi_11_b3 = -1;
374 static int hf_nas_5gs_allow_pdu_ses_sts_psi_10_b2 = -1;
375 static int hf_nas_5gs_allow_pdu_ses_sts_psi_9_b1 = -1;
376 static int hf_nas_5gs_allow_pdu_ses_sts_psi_8_b0 = -1;
377
378 static int hf_nas_5gs_sm_pdu_session_type = -1;
379 static int hf_nas_5gs_sm_sc_mode = -1;
380 static int hf_nas_5gs_sm_eplmnc = -1;
381 static int hf_nas_5gs_sm_ratc = -1;
382 static int hf_nas_5gs_sm_ept_s1 = -1;
383 static int hf_nas_5gs_sm_abo = -1;
384 static int hf_nas_5gs_sm_atsss_cont = -1;
385 static int hf_nas_5gs_sm_cpoi = -1;
386 static int hf_nas_5gs_sm_ip_hdr_comp_config_p0104 = -1;
387 static int hf_nas_5gs_sm_ip_hdr_comp_config_p0103 = -1;
388 static int hf_nas_5gs_sm_ip_hdr_comp_config_p0102 = -1;
389 static int hf_nas_5gs_sm_ip_hdr_comp_config_p0006 = -1;
390 static int hf_nas_5gs_sm_ip_hdr_comp_config_p0004 = -1;
391 static int hf_nas_5gs_sm_ip_hdr_comp_config_p0003 = -1;
392 static int hf_nas_5gs_sm_ip_hdr_comp_config_p0002 = -1;
393 static int hf_nas_5gs_sm_ip_hdr_comp_config_max_cid = -1;
394 static int hf_nas_5gs_sm_ip_hdr_comp_config_add_ip_hdr_compr_cxt_setup_params_type = -1;
395 static int hf_nas_5gs_sm_ip_hdr_comp_config_add_ip_hdr_compr_cxt_setup_params_cont = -1;
396 static int hf_nas_5gs_sm_ds_tt_eth_port_mac_addr = -1;
397 static int hf_nas_5gs_sm_ue_ds_tt_residence_time = -1;
398 static int hf_nas_5gs_sm_port_mgmt_info_cont = -1;
399 static int hf_nas_5gs_sm_eth_hdr_comp_config_cid_len = -1;
400 static int hf_nas_5gs_sm_sel_sc_mode = -1;
401 static int hf_nas_5gs_sm_tpmic_b7 = -1;
402 static int hf_nas_5gs_sm_atsss_st_b3_b6 = -1;
403 static int hf_nas_5gs_sm_ept_s1_b2 = -1;
404 static int hf_nas_5gs_sm_mh6_pdu_b1 = -1;
405 static int hf_nas_5gs_sm_rqos_b0 = -1;
406 static int hf_nas_5gs_sm_5gsm_cause = -1;
407 static int hf_nas_5gs_sm_apsi = -1;
408 static int hf_nas_5gs_sm_apsr = -1;
409 static int hf_nas_5gs_sm_int_prot_max_data_rate_ul = -1;
410 static int hf_nas_5gs_sm_int_prot_max_data_rate_dl = -1;
411 static int hf_nas_5gs_sm_si6lla = -1;
412 static int hf_nas_5gs_sm_pdu_ses_type = -1;
413 static int hf_nas_5gs_sm_pdu_addr_inf_ipv4 = -1;
414 static int hf_nas_5gs_sm_pdu_addr_inf_ipv6 = -1;
415 static int hf_nas_5gs_sm_smf_ipv6_lla = -1;
416 static int hf_nas_5gs_sm_qos_rule_id = -1;
417 static int hf_nas_5gs_sm_length = -1;
418 static int hf_nas_5gs_sm_rop = -1;
419 static int hf_nas_5gs_sm_dqr = -1;
420 static int hf_nas_5gs_sm_nof_pkt_filters = -1;
421 static int hf_nas_5gs_sm_pkt_flt_id = -1;
422 static int hf_nas_5gs_sm_pkt_flt_dir = -1;
423 static int hf_nas_5gs_sm_pf_len = -1;
424 static int hf_nas_5gs_sm_pf_type = -1;
425 static int hf_nas_5gs_sm_e = -1;
426 static int hf_nas_5gs_sm_nof_params = -1;
427 static int hf_nas_5gs_sm_param_id = -1;
428 static int hf_nas_5gs_sm_param_len = -1;
429 static int hf_nas_5gs_sm_qos_rule_precedence = -1;
430 static int hf_nas_5gs_sm_segregation = -1;
431 static int hf_nas_5gs_sm_param_cont = -1;
432 static int hf_nas_5gs_sm_5qi = -1;
433 static int hf_nas_5gs_sm_unit_for_gfbr_ul = -1;
434 static int hf_nas_5gs_sm_gfbr_ul = -1;
435 static int hf_nas_5gs_sm_unit_for_gfbr_dl = -1;
436 static int hf_nas_5gs_sm_gfbr_dl = -1;
437 static int hf_nas_5gs_sm_unit_for_mfbr_ul = -1;
438 static int hf_nas_5gs_sm_mfbr_ul = -1;
439 static int hf_nas_5gs_sm_unit_for_mfbr_dl = -1;
440 static int hf_nas_5gs_sm_mfbr_dl = -1;
441 static int hf_nas_5gs_sm_averaging_window = -1;
442 static int hf_nas_5gs_sm_eps_bearer_id = -1;
443 static int hf_nas_5gs_sm_qfi = -1;
444 static int hf_nas_5gs_sm_mapd_eps_b_cont_id = -1;
445 static int hf_nas_5gs_sm_mapd_eps_b_cont_opt_code = -1;
446 static int hf_nas_5gs_sm_qos_des_flow_opt_code = -1;
447 static int hf_nas_5gs_sm_mapd_eps_b_cont_E = -1;
448 static int hf_nas_5gs_sm_mapd_eps_b_cont_num_eps_parms = -1;
449 static int hf_nas_5gs_sm_mapd_eps_b_cont_E_mod = -1;
450 static int hf_nas_5gs_sm_mapd_eps_b_cont_param_id = -1;
451
452 static int hf_nas_5gs_sm_unit_for_session_ambr_dl = -1;
453 static int hf_nas_5gs_sm_session_ambr_dl = -1;
454 static int hf_nas_5gs_sm_unit_for_session_ambr_ul = -1;
455 static int hf_nas_5gs_sm_session_ambr_ul = -1;
456 static int hf_nas_5gs_sm_dm_spec_id = -1;
457 static int hf_nas_5gs_sm_all_ssc_mode_b0 = -1;
458 static int hf_nas_5gs_sm_all_ssc_mode_b1 = -1;
459 static int hf_nas_5gs_sm_all_ssc_mode_b2 = -1;
460 static int hf_nas_5gs_addr_mask_ipv4 = -1;
461 static int hf_nas_5gs_ipv6 = -1;
462 static int hf_nas_5gs_ipv6_prefix_len = -1;
463 static int hf_nas_5gs_protocol_identifier_or_next_hd = -1;
464 static int hf_nas_5gs_mm_rinmr = -1;
465 static int hf_nas_5gs_mm_hdp = -1;
466 static int hf_nas_5gs_mm_cipher_key = -1;
467 static int hf_nas_5gs_mm_dcni = -1;
468 static int hf_nas_5gs_mm_nssci = -1;
469 static int hf_nas_5gs_mm_nssai_inc_mode = -1;
470 static int hf_nas_5gs_mm_ue_usage_setting = -1;
471 static int hf_nas_5gs_mm_5gs_drx_param = -1;
472 static int hf_nas_5gs_sup_andsp = -1;
473
474 static int ett_nas_5gs = -1;
475 static int ett_nas_5gs_mm_nssai = -1;
476 static int ett_nas_5gs_mm_pdu_ses_id = -1;
477 static int ett_nas_5gs_sm_qos_rules = -1;
478 static int ett_nas_5gs_sm_qos_params = -1;
479 static int ett_nas_5gs_plain = -1;
480 static int ett_nas_5gs_sec = -1;
481 static int ett_nas_5gs_mm_part_sal = -1;
482 static int ett_nas_5gs_mm_part_tal = -1;
483 static int ett_nas_5gs_sm_mapd_eps_b_cont = -1;
484 static int ett_nas_5gs_sm_mapd_eps_b_cont_params_list = -1;
485 static int ett_nas_5gs_enc = -1;
486 static int ett_nas_5gs_mm_ladn_indic = -1;
487 static int ett_nas_5gs_mm_sor = -1;
488 static int ett_nas_5gs_sm_pkt_filter_components = -1;
489 static int ett_nas_5gs_updp_ue_policy_section_mgm_lst = -1;
490 static int ett_nas_5gs_updp_ue_policy_section_mgm_sublst = -1;
491 static int ett_nas_5gs_ue_policies_ursp = -1;
492 static int ett_nas_5gs_ursp_traff_desc = -1;
493 static int ett_nas_5gs_ursp_r_sel_desc_cont = -1;
494 static int ett_nas_5gs_updp_upsi_list = -1;
495 static int ett_nas_5gs_mm_rej_nssai = -1;
496 static int ett_nas_5gs_mm_scheme_output = -1;
497 static int ett_nas_5gs_mm_pld_cont_pld_entry = -1;
498 static int ett_nas_5gs_mm_pld_cont_opt_ie = -1;
499 static int ett_nas_5gs_mm_cag_info_entry = -1;
500 static int ett_nas_5gs_ciot_small_data_cont_data_contents = -1;
501 static int ett_nas_5gs_user_data_cont = -1;
502 static int ett_nas_5gs_ciph_data_set = -1;
503 static int ett_nas_5gs_mm_mapped_nssai = -1;
504 static int ett_nas_5gs_mm_partial_extended_rejected_nssai_list = -1;
505 static int ett_nas_5gs_mm_ext_rej_nssai = -1;
506 static int ett_nas_5gs_mm_op_def_acc_cat_def = -1;
507 static int ett_nas_5gs_mm_op_def_acc_cat_criteria_component = -1;
508 static int ett_nas_5gs_mm_op_def_acc_cat_criteria = -1;
509
510 static int hf_nas_5gs_mm_abba = -1;
511 static int hf_nas_5gs_mm_supi_fmt = -1;
512 static int hf_nas_5gs_mm_routing_indicator = -1;
513 static int hf_nas_5gs_mm_prot_scheme_id = -1;
514 static int hf_nas_5gs_mm_pki = -1;
515 static int hf_nas_5gs_mm_suci_msin = -1;
516 static int hf_nas_5gs_mm_scheme_output = -1;
517 static int hf_nas_5gs_mm_scheme_output_ecc_public_key = -1;
518 static int hf_nas_5gs_mm_scheme_output_ciphertext = -1;
519 static int hf_nas_5gs_mm_scheme_output_mac_tag = -1;
520 static int hf_nas_5gs_mm_suci_nai = -1;
521 static int hf_nas_5gs_mm_imei = -1;
522 static int hf_nas_5gs_mm_imeisv = -1;
523 static int hf_nas_5gs_mm_mauri = -1;
524 static int hf_nas_5gs_mm_mac_addr = -1;
525 static int hf_nas_5gs_mm_eui_64 = -1;
526 static int hf_nas_5gs_mm_reg_res_res = -1;
527 static int hf_nas_5gs_mm_reg_res_sms_allowed = -1;
528 static int hf_nas_5gs_mm_reg_res_nssaa_perf = -1;
529 static int hf_nas_5gs_mm_reg_res_emergency_reg = -1;
530 static int hf_nas_5gs_amf_region_id = -1;
531 static int hf_nas_5gs_amf_set_id = -1;
532 static int hf_nas_5gs_amf_pointer = -1;
533 static int hf_nas_5gs_5g_tmsi = -1;
534 static int hf_nas_5gs_mm_op_def_access_cat_len = -1;
535 static int hf_nas_5gs_mm_op_def_access_cat_precedence = -1;
536 static int hf_nas_5gs_mm_op_def_access_cat_psac = -1;
537 static int hf_nas_5gs_mm_op_def_access_cat_number = -1;
538 static int hf_nas_5gs_mm_op_def_access_cat_criteria_length = -1;
539 static int hf_nas_5gs_mm_op_def_access_cat_criteria_type = -1;
540 static int hf_nas_5gs_mm_op_def_access_cat_criteria_dnn_count = -1;
541 static int hf_nas_5gs_mm_op_def_access_cat_criteria_dnn_len = -1;
542 static int hf_nas_5gs_mm_op_def_access_cat_criteria_os_id_os_app_id_count = -1;
543 static int hf_nas_5gs_mm_op_def_access_cat_criteria_os_id = -1;
544 static int hf_nas_5gs_mm_op_def_access_cat_criteria_os_app_id_len = -1;
545 static int hf_nas_5gs_mm_op_def_access_cat_criteria_os_app_id = -1;
546 static int hf_nas_5gs_mm_op_def_access_cat_criteria_s_nssai_count = -1;
547 static int hf_nas_5gs_mm_op_def_access_cat_criteria_s_nssai_len = -1;
548 static int hf_nas_5gs_mm_op_def_access_cat_standardized_number = -1;
549 static int hf_nas_5gs_mm_sms_indic_sai = -1;
550
551 static int hf_nas_5gs_nw_feat_sup_mpsi_b7 = -1;
552 static int hf_nas_5gs_nw_feat_sup_ims_iwk_n26_b6 = -1;
553 static int hf_nas_5gs_nw_feat_sup_ims_emf_b5b4 = -1;
554 static int hf_nas_5gs_nw_feat_sup_ims_emc_b3b2 = -1;
555 static int hf_nas_5gs_nw_feat_sup_ims_vops_3gpp = -1;
556 static int hf_nas_5gs_nw_feat_sup_ims_vops_n3gpp = -1;
557 static int hf_nas_5gs_nw_feat_sup_emcn3 = -1;
558 static int hf_nas_5gs_nw_feat_sup_mcsi = -1;
559 static int hf_nas_5gs_nw_feat_sup_restrict_ec = -1;
560 static int hf_nas_5gs_nw_feat_sup_5g_cp_ciot = -1;
561 static int hf_nas_5gs_nw_feat_sup_n3_data = -1;
562 static int hf_nas_5gs_nw_feat_sup_5g_iphc_cp_ciot = -1;
563 static int hf_nas_5gs_nw_feat_sup_5g_ciot_up = -1;
564 static int hf_nas_5gs_nw_feat_sup_5g_lcs = -1;
565 static int hf_nas_5gs_nw_feat_sup_ats_ind = -1;
566 static int hf_nas_5gs_nw_feat_sup_5g_ehc_cp_ciot = -1;
567
568 static int hf_nas_5gs_tac = -1;
569
570 static int hf_nas_5gs_mm_tal_t_li = -1;
571 static int hf_nas_5gs_mm_tal_num_e = -1;
572 static int hf_nas_5gs_sm_mapd_eps_b_cont_eps_param_cont = -1;
573
574 static int hf_nas_5gs_sm_max_nb_sup_pkt_flt_nb = -1;
575 static int hf_nas_5gs_sm_max_nb_sup_pkt_flt_spare = -1;
576
577 static int hf_nas_5gs_kacf = -1;
578 static int hf_nas_5gs_ncc = -1;
579
580 static int hf_nas_5gs_sor_hdr0_ack = -1;
581 static int hf_nas_5gs_sor_hdr0_list_type = -1;
582 static int hf_nas_5gs_sor_hdr0_list_ind = -1;
583 static int hf_nas_5gs_sor_hdr0_sor_data_type = -1;
584 static int hf_nas_5gs_sor_mac_iue = -1;
585 static int hf_nas_5gs_sor_mac_iausf = -1;
586 static int hf_nas_5gs_counter_sor = -1;
587 static int hf_nas_5gs_sor_sec_pkt = -1;
588
589 static int hf_nas_5gs_access_tech_o1_b7 = -1;
590 static int hf_nas_5gs_access_tech_o1_b6 = -1;
591 static int hf_nas_5gs_access_tech_o1_b5 = -1;
592 static int hf_nas_5gs_access_tech_o1_b4 = -1;
593 static int hf_nas_5gs_access_tech_o1_b3 = -1;
594 static int hf_nas_5gs_access_tech_o2_b7 = -1;
595 static int hf_nas_5gs_access_tech_o2_b6 = -1;
596 static int hf_nas_5gs_access_tech_o2_b5 = -1;
597 static int hf_nas_5gs_access_tech_o2_b4 = -1;
598 static int hf_nas_5gs_access_tech_o2_b3 = -1;
599 static int hf_nas_5gs_access_tech_o2_b2 = -1;
600 static int hf_nas_5gs_single_port_type = -1;
601 static int hf_nas_5gs_port_range_type_low = -1;
602 static int hf_nas_5gs_port_range_type_high = -1;
603 static int hf_nas_5gs_sec_param_idx = -1;
604 static int hf_nas_5gs_tos_tc_val = -1;
605 static int hf_nas_5gs_tos_tc_mask = -1;
606 static int hf_nas_5gs_flow_label = -1;
607 static int hf_nas_5gs_mac_addr = -1;
608 static int hf_nas_5gs_vlan_tag_vid = -1;
609 static int hf_nas_5gs_vlan_tag_pcp = -1;
610 static int hf_nas_5gs_vlan_tag_dei = -1;
611 static int hf_nas_5gs_ethertype = -1;
612 static int hf_nas_5gs_updp_ue_pol_sect_sublst_len = -1;
613 static int hf_nas_5gs_updp_ue_pol_sect_subresult_len = -1;
614 static int hf_nas_5gs_updp_instr_len = -1;
615 static int hf_nas_5gs_updp_upsc = -1;
616 static int hf_nas_5gs_updp_failed_instruction_order = -1;
617 static int hf_nas_5gs_updp_policy_len = -1;
618 static int hf_nas_5gs_updp_ue_policy_part_type = -1;
619 static int hf_nas_5gs_updp_ue_policy_part_cont = -1;
620 static int hf_nas_5gs_ursp_rule_len = -1;
621 static int hf_nas_5gs_ursp_rule_prec = -1;
622 static int hf_nas_5gs_ursp_traff_desc_lst_len = -1;
623 static int hf_nas_5gs_ursp_traff_desc = -1;
624 static int hf_nas_5gs_ursp_r_sel_desc_lst_len = -1;
625 static int hf_nas_5gs_ursp_r_sel_desc_lst = -1;
626 static int hf_nas_5gs_ursp_traff_desc_ipv4 = -1;
627 static int hf_nas_5gs_ursp_traff_desc_ipv4_mask = -1;
628 static int hf_nas_5gs_ursp_traff_desc_next_hdr = -1;
629 static int hf_nas_5gs_ursp_traff_desc_len = -1;
630 static int hf_nas_5gs_ursp_r_sel_des_prec = -1;
631 static int hf_nas_5gs_ursp_r_sel_des_cont_len = -1;
632 static int hf_nas_5gs_ursp_ursp_r_sel_desc_comp_type = -1;
633 static int hf_nas_5gs_dnn_len = -1;
634 static int hf_nas_5gs_upsi_sublist_len = -1;
635 static int hf_nas_5gs_upsc = -1;
636 static int hf_nas_5gs_os_id = -1;
637 static int hf_nas_5gs_os_id_len = -1;
638 static int hf_nas_5gs_upds_cause = -1;
639 static int hf_nas_5gs_v2xuui = -1;
640 static int hf_nas_5gs_v2xpc5i = -1;
641 static int hf_nas_5gs_os_app_id_len = -1;
642 static int hf_nas_5gs_os_app_id = -1;
643 static int hf_nas_5gs_mm_len_of_rej_s_nssai = -1;
644 static int hf_nas_5gs_mm_rej_s_nssai_cause = -1;
645 static int hf_nas_5gs_mm_ue_radio_cap_id = -1;
646 static int hf_nas_5gs_mm_ue_radio_cap_id_del_req = -1;
647 static int hf_nas_5gs_mm_trunc_amf_set_id = -1;
648 static int hf_nas_5gs_mm_trunc_amf_pointer = -1;
649 static int hf_nas_5gs_mm_n5gcreg_b0 = -1;
650 static int hf_nas_5gs_mm_nb_n1_drx_value = -1;
651 static int hf_nas_5gs_mm_scmr = -1;
652 static int hf_nas_5gs_mm_extended_rejected_s_nssai_number_of_element = -1;
653 static int hf_nas_5gs_mm_extended_rejected_s_nssai_type_of_list = -1;
654 static int hf_nas_5gs_mm_extended_rejected_s_nssai_spare = -1;
655 static int hf_nas_5gs_mm_extended_rejected_s_nssai_back_off_timer = -1;
656 static int hf_nas_5gs_mm_len_of_rejected_s_nssai = -1;
657 static int hf_nas_5gs_mm_rejected_s_nssai_cause_value = -1;
658
659 static expert_field ei_nas_5gs_extraneous_data = EI_INIT;
660 static expert_field ei_nas_5gs_unknown_pd = EI_INIT;
661 static expert_field ei_nas_5gs_mm_unknown_msg_type = EI_INIT;
662 static expert_field ei_nas_5gs_sm_unknown_msg_type = EI_INIT;
663 static expert_field ei_nas_5gs_updp_unknown_msg_type = EI_INIT;
664 static expert_field ei_nas_5gs_msg_not_dis = EI_INIT;
665 static expert_field ei_nas_5gs_ie_not_dis = EI_INIT;
666 static expert_field ei_nas_5gs_missing_mandatory_element = EI_INIT;
667 static expert_field ei_nas_5gs_dnn_too_long = EI_INIT;
668 static expert_field ei_nas_5gs_unknown_value = EI_INIT;
669 static expert_field ei_nas_5gs_num_pkt_flt = EI_INIT;
670 static expert_field ei_nas_5gs_not_diss = EI_INIT;
671
672 #define NAS_5GS_PLAIN_NAS_MSG 0
673 #define NAS_5GS_INTEG_NAS_MSG 1
674 #define NAS_5GS_INTEG_CIPH_NAS_MSG 2
675 #define NAS_5GS_INTEG_NEW_NAS_MSG 3
676 #define NAS_5GS_INTEG_CIPH_NEW_NAS_MSG 4
677
678 static void dissect_nas_5gs_updp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, int offset);
679
680 static const value_string nas_5gs_security_header_type_vals[] = {
681 { NAS_5GS_PLAIN_NAS_MSG, "Plain NAS message, not security protected"},
682 { NAS_5GS_INTEG_NAS_MSG, "Integrity protected"},
683 { NAS_5GS_INTEG_CIPH_NAS_MSG, "Integrity protected and ciphered"},
684 { NAS_5GS_INTEG_NEW_NAS_MSG, "Integrity protected with new 5GS security context"},
685 { NAS_5GS_INTEG_CIPH_NEW_NAS_MSG, "Integrity protected and ciphered with new 5GS security context"},
686 { 0, NULL }
687 };
688
689 #define N1_SMINFO_FROM_UE "n1SmInfoFromUe"
690 #define N1_SMINFO_TO_UE "n1SmInfoToUe"
691 #define UNKNOWN_N1_SMINFO "unknownN1SmInfo"
692
693 #define TGPP_PD_5GMM 0x7e
694 #define TGPP_PD_5GSM 0x2e
695
696 static const value_string nas_5gs_epd_vals[] = {
697 { 0x00, "Group call control" },
698 { 0x01, "Broadcast call control" },
699 { 0x02, "EPS session management messages" },
700 { 0x03, "Call Control; call related SS messages" },
701 { 0x04, "GPRS Transparent Transport Protocol (GTTP)" },
702 { 0x05, "Mobility Management messages" },
703 { 0x06, "Radio Resources Management messages" },
704 { 0x07, "EPS mobility management messages" },
705 { 0x08, "GPRS mobility management messages" },
706 { 0x09, "SMS messages" },
707 { 0x0a, "GPRS session management messages" },
708 { 0x0b, "Non call related SS messages" },
709 { 0x0c, "Location services specified in 3GPP TS 44.071" },
710 { 0x0d, "Unknown" },
711 /*{0x0e, "Reserved for extension of the PD to one octet length "},*/
712 { 0x0f, "Tests procedures described in 3GPP TS 44.014, 3GPP TS 34.109 and 3GPP TS 36.509" },
713 { TGPP_PD_5GSM, "5G session management messages" },
714 { TGPP_PD_5GMM, "5G mobility management messages" },
715 { 0, NULL }
716 };
717
718 struct nas5gs_private_data {
719 guint32 payload_container_type;
720 };
721
722 static struct nas5gs_private_data*
723 nas5gs_get_private_data(packet_info *pinfo)
724 {
725 struct nas5gs_private_data *nas5gs_data = (struct nas5gs_private_data*)p_get_proto_data(pinfo->pool, pinfo, proto_nas_5gs, pinfo->curr_layer_num);
726 if (!nas5gs_data) {
727 nas5gs_data = wmem_new0(pinfo->pool, struct nas5gs_private_data);
728 p_add_proto_data(pinfo->pool, pinfo, proto_nas_5gs, pinfo->curr_layer_num, nas5gs_data);
729 }
730 return nas5gs_data;
731 }
732
733 static guint32
734 get_ext_ambr_unit(guint32 unit, const char **unit_str)
735 {
736 guint32 mult;
737
738 if (unit == 0) {
739 mult = 1;
740 *unit_str = "Unit value 0, Illegal";
741 return mult;
742 }
743
744 if (unit <= 0x05) {
745 mult = pow4(guint32, unit - 0x01);
746 *unit_str = "Kbps";
747 } else if (unit <= 0x0a) {
748 mult = pow4(guint32, unit - 0x06);
749 *unit_str = "Mbps";
750 } else if (unit <= 0x0f) {
751 mult = pow4(guint32, unit - 0x0b);
752 *unit_str = "Gbps";
753 } else if (unit <= 0x14) {
754 mult = pow4(guint32, unit - 0x10);
755 *unit_str = "Tbps";
756 } else if (unit <= 0x19) {
757 mult = pow4(guint32, unit - 0x15);
758 *unit_str = "Pbps";
759 } else {
760 mult = 256;
761 *unit_str = "Pbps";
762 }
763 return mult;
764 }
765
766 /*
767 * 9.11.3 5GS mobility management (5GMM) information elements
768 */
769
770 /*
771 * 9.11.3.1 5GMM capability
772 */
773 static guint16
774 de_nas_5gs_mm_5gmm_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
775 guint32 offset, guint len,
776 gchar *add_string _U_, int string_len _U_)
777 {
778 guint32 curr_offset;
779
780 static int * const flags1[] = {
781 &hf_nas_5gs_mm_sgc_b7,
782 &hf_nas_5gs_mm_5g_iphc_cp_ciot_b6,
783 &hf_nas_5gs_mm_n3_data_b5,
784 &hf_nas_5gs_mm_5g_cp_ciot_b4,
785 &hf_nas_5gs_mm_restrict_ec_b3,
786 &hf_nas_5gs_mm_lpp_cap_b2,
787 &hf_nas_5gs_mm_ho_attach_b1,
788 &hf_nas_5gs_mm_s1_mode_b0,
789 NULL
790 };
791
792 static int * const flags2[] = {
793 &hf_nas_5gs_mm_racs_b7,
794 &hf_nas_5gs_mm_nssaa_b6,
795 &hf_nas_5gs_mm_5g_lcs_b5,
796 &hf_nas_5gs_mm_v2xcnpc5_b4,
797 &hf_nas_5gs_mm_v2xcepc5_b3,
798 &hf_nas_5gs_mm_v2x_b2,
799 &hf_nas_5gs_mm_5g_up_ciot_b1,
800 &hf_nas_5gs_mm_5g_srvcc_b0,
801 NULL
802 };
803
804 static int * const flags3[] = {
805 &hf_nas_5gs_spare_b7,
806 &hf_nas_5gs_spare_b6,
807 &hf_nas_5gs_spare_b5,
808 &hf_nas_5gs_spare_b4,
809 &hf_nas_5gs_mm_5g_ehc_cp_ciot_b3,
810 &hf_nas_5gs_mm_multiple_up_b2,
811 &hf_nas_5gs_mm_wsusa_b1,
812 &hf_nas_5gs_mm_cag_b0,
813 NULL
814 };
815 curr_offset = offset;
816
817 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags1, ENC_BIG_ENDIAN);
818 curr_offset++;
819
820 if ((curr_offset - offset) >= len)
821 return (len);
822
823 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags2, ENC_BIG_ENDIAN);
824 curr_offset++;
825
826 if ((curr_offset - offset) >= len)
827 return (len);
828
829 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags3, ENC_BIG_ENDIAN);
830 curr_offset++;
831
832 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
833
834 return (curr_offset - offset);
835 }
836
837 /*
838 * 9.11.3.2 5GMM cause
839 */
840
841 static const value_string nas_5gs_mm_cause_vals[] = {
842 { 0x03, "Illegal UE" },
843 { 0x05, "PEI not accepted" },
844 { 0x06, "Illegal ME" },
845 { 0x07, "5GS services not allowed" },
846 { 0x09, "UE identity cannot be derived by the network" },
847 { 0x0a, "Implicitly deregistered" },
848 { 0x0b, "PLMN not allowed" },
849 { 0x0c, "Tracking area not allowed" },
850 { 0x0d, "Roaming not allowed in this tracking area" },
851 { 0x0f, "No suitable cells in tracking area" },
852 { 0x14, "MAC failure" },
853 { 0x15, "Synch failure" },
854 { 0x16, "Congestion" },
855 { 0x17, "UE security capabilities mismatch" },
856 { 0x18, "Security mode rejected, unspecified" },
857 { 0x1a, "Non-5G authentication unacceptable" },
858 { 0x1b, "N1 mode not allowed" },
859 { 0x1c, "Restricted service area" },
860 { 0x1f, "Redirection to EPC required" },
861 { 0x2b, "LADN not available" },
862 { 0x3e, "No network slices available" },
863 { 0x41, "Maximum number of PDU sessions reached" },
864 { 0x43, "Insufficient resources for specific slice and DNN" },
865 { 0x45, "Insufficient resources for specific slice" },
866 { 0x47, "ngKSI already in use" },
867 { 0x48, "Non-3GPP access to 5GCN not allowed" },
868 { 0x49, "Serving network not authorized" },
869 { 0x4a, "Temporarily not authorized for this SNPN" },
870 { 0x4b, "Permanently not authorized for this SNPN" },
871 { 0x4c, "Not authorized for this CAG or authorized for CAG cells only" },
872 { 0x4d, "Wireline access area not allowed" },
873 { 0x5a, "Payload was not forwarded" },
874 { 0x5b, "DNN not supported or not subscribed in the slice" },
875 { 0x5c, "Insufficient user-plane resources for the PDU session" },
876 { 0x5f, "Semantically incorrect message" },
877 { 0x60, "Invalid mandatory information" },
878 { 0x61, "Message type non-existent or not implemented" },
879 { 0x62, "Message type not compatible with the protocol state" },
880 { 0x63, "Information element non-existent or not implemented" },
881 { 0x64, "Conditional IE error" },
882 { 0x65, "Message not compatible with the protocol state" },
883 { 0x6f, "Protocol error, unspecified" },
884 { 0, NULL }
885 };
886
887 static guint16
888 de_nas_5gs_mm_5gmm_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
889 guint32 offset, guint len _U_,
890 gchar *add_string _U_, int string_len _U_)
891 {
892 guint32 cause;
893
894 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_mm_5gmm_cause, tvb, offset, 1, ENC_BIG_ENDIAN, &cause);
895
896 col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)",
897 val_to_str_const(cause, nas_5gs_mm_cause_vals, "Unknown"));
898
899
900 return 1;
901 }
902
903
904 static const value_string nas_5gs_mm_drx_vals[] = {
905 { 0x0, "DRX value not specified" },
906 { 0x1, "DRX cycle parameter T = 32" },
907 { 0x2, "DRX cycle parameter T = 64" },
908 { 0x3, "DRX cycle parameter T = 128" },
909 { 0x4, "DRX cycle parameter T = 256" },
910 { 0, NULL }
911 };
912
913
914 /* 9.11.3.2A 5GS DRX parameters*/
915 static guint16
916 de_nas_5gs_mm_5gs_drx_param(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
917 guint32 offset, guint len _U_,
918 gchar *add_string _U_, int string_len _U_)
919 {
920
921 proto_tree_add_item(tree, hf_nas_5gs_mm_5gs_drx_param, tvb, offset, 1, ENC_BIG_ENDIAN);
922
923 return 1;
924 }
925
926 /*
927 * 9.11.3.3 5GS identity type
928 */
929 static guint16
930 de_nas_5gs_mm_5gs_identity_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
931 guint32 offset, guint len _U_,
932 gchar *add_string _U_, int string_len _U_)
933 {
934
935 proto_tree_add_item(tree, hf_nas_5gs_mm_type_id, tvb, offset, 1, ENC_BIG_ENDIAN);
936
937 return 1;
938 }
939
940 /*
941 * 9.11.3.4 5GS mobile identity
942 */
943 static const value_string nas_5gs_mm_type_id_vals[] = {
944 { 0x0, "No identity" },
945 { 0x1, "SUCI" },
946 { 0x2, "5G-GUTI" },
947 { 0x3, "IMEI" },
948 { 0x4, "5G-S-TMSI" },
949 { 0x5, "IMEISV" },
950 { 0x6, "MAC address" },
951 { 0x7, "EUI-64" },
952 { 0, NULL }
953 };
954
955 static true_false_string nas_5gs_odd_even_tfs = {
956 "Odd number of identity digits",
957 "Even number of identity digits"
958 };
959
960 static const value_string nas_5gs_mm_supi_fmt_vals[] = {
961 { 0x0, "IMSI" },
962 { 0x1, "Network Specific Identifier" },
963 { 0x2, "GCI" },
964 { 0x3, "GLI" },
965 { 0, NULL }
966 };
967
968 static const value_string nas_5gs_mm_prot_scheme_id_vals[] = {
969 { 0x0, "NULL scheme" },
970 { 0x1, "ECIES scheme profile A" },
971 { 0x2, "ECIES scheme profile B" },
972 { 0, NULL }
973 };
974
975 static true_false_string nas_5gs_mauri_tfs = {
976 "MAC address is not usable as an equipment identifier",
977 "No restrictions"
978 };
979
980 static guint16
981 de_nas_5gs_mm_5gs_mobile_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
982 guint32 offset, guint len,
983 gchar *add_string _U_, int string_len _U_)
984 {
985 guint8 oct, type_id, supi_fmt;
986 guint32 scheme_id, fiveg_tmsi;
987 tvbuff_t * new_tvb;
988 const char *route_id_str;
989 proto_item* ti;
990
991 static int * const flags_spare_tid[] = {
992 &hf_nas_5gs_spare_b7,
993 &hf_nas_5gs_spare_b6,
994 &hf_nas_5gs_spare_b5,
995 &hf_nas_5gs_spare_b4,
996 &hf_nas_5gs_spare_b3,
997 &hf_nas_5gs_mm_type_id,
998 NULL
999 };
1000
1001 static int * const flags_supi_fmt_tid[] = {
1002 &hf_nas_5gs_spare_b7,
1003 &hf_nas_5gs_mm_supi_fmt,
1004 &hf_nas_5gs_spare_b3,
1005 &hf_nas_5gs_mm_type_id,
1006 NULL
1007 };
1008
1009 static int * const flags_odd_even_tid[] = {
1010 &hf_nas_5gs_mm_odd_even,
1011 &hf_nas_5gs_mm_type_id,
1012 NULL
1013 };
1014
1015 static int * const flags_mauri_tid[] = {
1016 &hf_nas_5gs_spare_b7,
1017 &hf_nas_5gs_spare_b6,
1018 &hf_nas_5gs_spare_b5,
1019 &hf_nas_5gs_spare_b4,
1020 &hf_nas_5gs_mm_mauri,
1021 &hf_nas_5gs_mm_type_id,
1022 NULL
1023 };
1024
1025 oct = tvb_get_guint8(tvb, offset);
1026 type_id = oct & 0x07;
1027
1028 switch (type_id) {
1029 case 0:
1030 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_spare_tid, ENC_BIG_ENDIAN);
1031 break;
1032 case 1:
1033 /* SUCI */
1034 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_supi_fmt_tid, ENC_BIG_ENDIAN);
1035 offset++;
1036
1037 supi_fmt = (oct & 0x70) >> 4;
1038 if (supi_fmt == 0) {
1039 /* IMSI */
1040
1041 /* MCC digit 2 MCC digit 1
1042 * MNC digit 3 MCC digit 3
1043 * MNC digit 2 MNC digit 1
1044 */
1045 offset = dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_NONE, TRUE);
1046 /* Routing indicator octet 8-9 */
1047 new_tvb = tvb_new_subset_length(tvb, offset, 2);
1048 route_id_str = tvb_bcd_dig_to_str(pinfo->pool, new_tvb, 0, (tvb_get_guint8(new_tvb, 1) == 0xff) ? 1 : 2, NULL, FALSE);
1049 proto_tree_add_string(tree, hf_nas_5gs_mm_routing_indicator, new_tvb, 0, -1, route_id_str);
1050 offset += 2;
1051 /* Protection scheme id octet 10 */
1052 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_mm_prot_scheme_id, tvb, offset, 1, ENC_BIG_ENDIAN, &scheme_id);
1053 offset += 1;
1054 /* Home network public key identifier octet 11 */
1055 proto_tree_add_item(tree, hf_nas_5gs_mm_pki, tvb, offset, 1, ENC_BIG_ENDIAN);
1056 offset += 1;
1057 /* Scheme output octet 12-x */
1058 if (scheme_id == 0) {
1059 new_tvb = tvb_new_subset_length(tvb, offset, len - 8);
1060 proto_tree_add_item(tree, hf_nas_5gs_mm_suci_msin, new_tvb, 0, -1, ENC_BCD_DIGITS_0_9);
1061 } else {
1062 proto_item *pi = proto_tree_add_item(tree, hf_nas_5gs_mm_scheme_output, tvb, offset, len - 8, ENC_NA);
1063 if ((scheme_id == 1 && len >= 49) || (scheme_id == 2 && len >= 50)) {
1064 guint32 public_key_len;
1065 proto_tree *subtree = proto_item_add_subtree(pi, ett_nas_5gs_mm_scheme_output);
1066 if (scheme_id == 1) {
1067 public_key_len = 32;
1068 } else {
1069 public_key_len = 33;
1070 }
1071 proto_tree_add_item(subtree, hf_nas_5gs_mm_scheme_output_ecc_public_key, tvb, offset, public_key_len, ENC_NA);
1072 offset += public_key_len;
1073 proto_tree_add_item(subtree, hf_nas_5gs_mm_scheme_output_ciphertext, tvb, offset, len - public_key_len - 16, ENC_NA);
1074 offset += len - public_key_len - 16;
1075 proto_tree_add_item(subtree, hf_nas_5gs_mm_scheme_output_mac_tag, tvb, offset, 8, ENC_BIG_ENDIAN);
1076 }
1077 }
1078 } else if (supi_fmt == 1 ||supi_fmt == 2 ||supi_fmt == 3) {
1079 /* NAI */
1080 proto_tree_add_item(tree, hf_nas_5gs_mm_suci_nai, tvb, offset, len - 1, ENC_UTF_8 | ENC_NA);
1081 } else {
1082 proto_tree_add_expert(tree, pinfo, &ei_nas_5gs_unknown_value, tvb, offset, len - 1);
1083 }
1084 break;
1085 case 2:
1086 /* 5G-GUTI*/
1087 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_spare_tid, ENC_BIG_ENDIAN);
1088 offset++;
1089 /* MCC digit 2 MCC digit 1
1090 * MNC digit 3 MCC digit 3
1091 * MNC digit 2 MNC digit 1
1092 */
1093 offset = dissect_e212_mcc_mnc(tvb, pinfo, tree, offset, E212_GUAMI, TRUE);
1094 /* AMF Region ID octet 7 */
1095 proto_tree_add_item(tree, hf_nas_5gs_amf_region_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1096 offset += 1;
1097 /* AMF Set ID octet 8 */
1098 proto_tree_add_item(tree, hf_nas_5gs_amf_set_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1099 offset++;
1100 /* AMF AMF Pointer AMF Set ID (continued) */
1101 proto_tree_add_item(tree, hf_nas_5gs_amf_pointer, tvb, offset, 1, ENC_BIG_ENDIAN);
1102 offset++;
1103 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_5g_tmsi, tvb, offset, 4, ENC_BIG_ENDIAN, &fiveg_tmsi);
1104 ti = proto_tree_add_uint(tree, hf_3gpp_tmsi, tvb, offset, 4, fiveg_tmsi);
1105 proto_item_set_hidden(ti);
1106 break;
1107 case 3:
1108 /* IMEI */
1109 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_odd_even_tid, ENC_BIG_ENDIAN);
1110 proto_tree_add_item(tree, hf_nas_5gs_mm_imei, tvb, offset, len, ENC_BCD_DIGITS_0_9 | ENC_BCD_SKIP_FIRST);
1111 break;
1112 case 4:
1113 /*5G-S-TMSI*/
1114 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_odd_even_tid, ENC_BIG_ENDIAN);
1115 offset++;
1116 /* AMF Set ID */
1117 proto_tree_add_item(tree, hf_nas_5gs_amf_set_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1118 offset++;
1119 /* AMF Pointer AMF Set ID (continued) */
1120 proto_tree_add_item(tree, hf_nas_5gs_amf_pointer, tvb, offset, 1, ENC_BIG_ENDIAN);
1121 offset++;
1122 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_5g_tmsi, tvb, offset, 4, ENC_BIG_ENDIAN, &fiveg_tmsi);
1123 ti = proto_tree_add_uint(tree, hf_3gpp_tmsi, tvb, offset, 4, fiveg_tmsi);
1124 proto_item_set_hidden(ti);
1125 break;
1126 case 5:
1127 /* IMEISV */
1128 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_odd_even_tid, ENC_BIG_ENDIAN);
1129 /* XXXX Do we need the odd/even bit?*/
1130 proto_tree_add_item(tree, hf_nas_5gs_mm_imeisv, tvb, offset, len, ENC_BCD_DIGITS_0_9 | ENC_BCD_SKIP_FIRST);
1131 break;
1132 case 6:
1133 /* MAC address */
1134 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_mauri_tid, ENC_BIG_ENDIAN);
1135 offset++;
1136 proto_tree_add_item(tree, hf_nas_5gs_mm_mac_addr, tvb, offset, 6, ENC_NA);
1137 break;
1138 case 7:
1139 /* EUI-64 */
1140 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags_spare_tid, ENC_BIG_ENDIAN);
1141 offset++;
1142 proto_tree_add_item(tree, hf_nas_5gs_mm_eui_64, tvb, offset, 8, ENC_NA);
1143 break;
1144
1145 default:
1146 proto_tree_add_item(tree, hf_nas_5gs_mm_type_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1147 proto_tree_add_expert(tree, pinfo, &ei_nas_5gs_unknown_value, tvb, offset, len);
1148 break;
1149 }
1150
1151 return len;
1152 }
1153
1154 /*
1155 * 9.11.3.5 5GS network feature support
1156 */
1157
1158 static const value_string nas_5gs_nw_feat_sup_emc_values[] = {
1159 { 0x0, "Emergency services not supported" },
1160 { 0x1, "Emergency services supported in NR connected to 5GCN only" },
1161 { 0x2, "Emergency services supported in E-UTRA connected to 5GCN only" },
1162 { 0x3, "Emergency services supported in NR connected to 5GCN and E-UTRA connected to 5GCN" },
1163 { 0, NULL }
1164 };
1165
1166 static const value_string nas_5gs_nw_feat_sup_emf_values[] = {
1167 { 0x0, "Emergency services fallback not supported" },
1168 { 0x1, "Emergency services fallback supported in NR connected to 5GCN only" },
1169 { 0x2, "Emergency services fallback supported in E-UTRA connected to 5GCN only" },
1170 { 0x3, "Emergency services fallback supported in NR connected to 5GCN and E-UTRA connected to 5GCN" },
1171 { 0, NULL }
1172 };
1173
1174 static const true_false_string tfs_nas_5gs_nw_feat_sup_mpsi = {
1175 "Access identity 1 valid in RPLMN or equivalent PLMN",
1176 "Access identity 1 not valid in RPLMN or equivalent PLMN"
1177 };
1178
1179 static const true_false_string tfs_nas_5gs_nw_feat_sup_mcsi = {
1180 "Access identity 2 valid",
1181 "Access identity 2 not valid"
1182 };
1183
1184 static const value_string nas_5gs_nw_feat_sup_restrict_ec_values[] = {
1185 { 0x0, "WB-N1: Both CE mode A and CE mode B are not restricted / NB-N1: Use of enhanced coverage is not restricted" },
1186 { 0x1, "WB-N1: Both CE mode A and CE mode B are restricted / NB-N1: Use of enhanced coverage is restricted" },
1187 { 0x2, "WB-N1: CE mode B is restricted / NB-N1: Restricted" },
1188 { 0x3, "Restricted" },
1189 { 0, NULL }
1190 };
1191
1192 static guint16
1193 de_nas_5gs_mm_5gs_nw_feat_sup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
1194 guint32 offset, guint len,
1195 gchar *add_string _U_, int string_len _U_)
1196 {
1197 guint32 curr_offset = offset;
1198
1199 static int * const flags_oct3[] = {
1200 &hf_nas_5gs_nw_feat_sup_mpsi_b7,
1201 &hf_nas_5gs_nw_feat_sup_ims_iwk_n26_b6,
1202 &hf_nas_5gs_nw_feat_sup_ims_emf_b5b4,
1203 &hf_nas_5gs_nw_feat_sup_ims_emc_b3b2,
1204 &hf_nas_5gs_nw_feat_sup_ims_vops_n3gpp,
1205 &hf_nas_5gs_nw_feat_sup_ims_vops_3gpp,
1206 NULL
1207 };
1208
1209 static int * const flags_oct4[] = {
1210 &hf_nas_5gs_nw_feat_sup_5g_ciot_up,
1211 &hf_nas_5gs_nw_feat_sup_5g_iphc_cp_ciot,
1212 &hf_nas_5gs_nw_feat_sup_n3_data,
1213 &hf_nas_5gs_nw_feat_sup_5g_cp_ciot,
1214 &hf_nas_5gs_nw_feat_sup_restrict_ec,
1215 &hf_nas_5gs_nw_feat_sup_mcsi,
1216 &hf_nas_5gs_nw_feat_sup_emcn3,
1217 NULL
1218 };
1219
1220 static int * const flags_oct5[] = {
1221 &hf_nas_5gs_spare_b7,
1222 &hf_nas_5gs_spare_b6,
1223 &hf_nas_5gs_spare_b5,
1224 &hf_nas_5gs_spare_b4,
1225 &hf_nas_5gs_spare_b3,
1226 &hf_nas_5gs_nw_feat_sup_5g_ehc_cp_ciot,
1227 &hf_nas_5gs_nw_feat_sup_ats_ind,
1228 &hf_nas_5gs_nw_feat_sup_5g_lcs,
1229 NULL
1230 };
1231
1232 /* MPSI IWK N26 EMF EMC IMS VoPS octet 3*/
1233 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags_oct3, ENC_BIG_ENDIAN);
1234 curr_offset++;
1235
1236 if (len == 1) {
1237 return len;
1238 }
1239
1240 /* 5G-UP CIoT 5G-IPHC-CP CIoT N3 data 5G-CP CIoT RestrictEC MCSI EMCN3 octet 4*/
1241 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags_oct4, ENC_BIG_ENDIAN);
1242 curr_offset++;
1243
1244 if (len == 2) {
1245 return len;
1246 }
1247
1248 /* spare spare spare spare spare 5G-EHC-CP CIoT ATS-IND 5G-LCS octet 5*/
1249 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags_oct5, ENC_BIG_ENDIAN);
1250 curr_offset++;
1251
1252 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
1253
1254 return len;
1255 }
1256
1257 /*
1258 * 9.11.3.6 5GS registration result
1259 */
1260
1261 static const value_string nas_5gs_mm_reg_res_values[] = {
1262 { 0x1, "3GPP access" },
1263 { 0x2, "Non-3GPP access" },
1264 { 0x3, "3GPP access and non-3GPP access" },
1265 { 0, NULL }
1266 };
1267
1268 static true_false_string tfs_nas_5gs_mm_reg_res_nssaa_perf = {
1269 "Network slice-specific authentication and authorization is to be performed",
1270 "Network slice-specific authentication and authorization is not to be performed"
1271 };
1272
1273 static true_false_string tfs_nas_5gs_mm_reg_res_emergency_reg = {
1274 "Registered for emergency services",
1275 "Not registered for emergency services"
1276 };
1277
1278 static guint16
1279 de_nas_5gs_mm_5gs_reg_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
1280 guint32 offset, guint len _U_,
1281 gchar *add_string _U_, int string_len _U_)
1282 {
1283
1284 static int* const flags[] = {
1285 &hf_nas_5gs_mm_reg_res_emergency_reg,
1286 &hf_nas_5gs_mm_reg_res_nssaa_perf,
1287 &hf_nas_5gs_mm_reg_res_sms_allowed,
1288 &hf_nas_5gs_mm_reg_res_res,
1289 NULL
1290 };
1291
1292 /* 0 Spare 0 Spare 0 Spare NSSAA Performed SMS allowed 5GS registration result value */
1293 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
1294
1295 return 1;
1296 }
1297
1298 /*
1299 * 9.11.3.7 5GS registration type
1300 */
1301
1302 static const value_string nas_5gs_registration_type_values[] = {
1303 { 0x1, "initial registration" },
1304 { 0x2, "mobility registration updating" },
1305 { 0x3, "periodic registration updating" },
1306 { 0x4, "emergency registration" },
1307 { 0x7, "reserved" },
1308 { 0, NULL }
1309 };
1310
1311 static true_false_string nas_5gs_for_tfs = {
1312 "Follow-on request pending",
1313 "No follow-on request pending"
1314 };
1315
1316 static int * const nas_5gs_registration_type_flags[] = {
1317 &hf_nas_5gs_mm_for,
1318 &hf_nas_5gs_mm_5gs_reg_type,
1319 NULL
1320 };
1321
1322 static guint16
1323 de_nas_5gs_mm_5gs_reg_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
1324 guint32 offset, guint len _U_,
1325 gchar *add_string _U_, int string_len _U_)
1326 {
1327
1328
1329
1330 /* FOR SMS requested 5GS registration type value octet 3*/
1331 proto_tree_add_bitmask_list(tree, tvb, offset, 1, nas_5gs_registration_type_flags, ENC_BIG_ENDIAN);
1332
1333 return 1;
1334 }
1335
1336 /*
1337 * 9.11.3.8 5GS tracking area identity
1338 */
1339 static guint16
1340 de_nas_5gs_mm_5gs_ta_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
1341 guint32 offset, guint len _U_,
1342 gchar *add_string _U_, int string_len _U_)
1343 {
1344 /* MCC digit 2 MCC digit 1 Octet 2*/
1345 /* MNC digit 3 MCC digit 3 Octet 3*/
1346 /* MNC digit 2 MNC digit 1 Octet 4*/
1347 /* TAC Octet 5 - 7 */
1348 guint32 curr_offset;
1349
1350 curr_offset = offset;
1351
1352 curr_offset = dissect_e212_mcc_mnc(tvb, pinfo, tree, curr_offset, E212_5GSTAI, TRUE);
1353 proto_tree_add_item(tree, hf_nas_5gs_tac, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
1354 curr_offset += 3;
1355
1356 return(curr_offset - offset);
1357 }
1358
1359 /*
1360 * 9.11.3.9 5GS tracking area identity list
1361 */
1362 static const value_string nas_5gs_mm_tal_t_li_values[] = {
1363 { 0x00, "list of TACs belonging to one PLMN or SNPN, with non-consecutive TAC values" },
1364 { 0x01, "list of TACs belonging to one PLMN or SNPN, with consecutive TAC values" },
1365 { 0x02, "list of TAIs belonging to different PLMNs" },
1366 { 0, NULL } };
1367
1368 static const value_string nas_5gs_mm_tal_num_e[] = {
1369 { 0x00, "1 element" },
1370 { 0x01, "2 elements" },
1371 { 0x02, "3 elements" },
1372 { 0x03, "4 elements" },
1373 { 0x04, "5 elements" },
1374 { 0x05, "6 elements" },
1375 { 0x06, "7 elements" },
1376 { 0x07, "8 elements" },
1377 { 0x08, "9 elements" },
1378 { 0x09, "10 elements" },
1379 { 0x0a, "11 elements" },
1380 { 0x0b, "12 elements" },
1381 { 0x0c, "13 elements" },
1382 { 0x0d, "14 elements" },
1383 { 0x0e, "15 elements" },
1384 { 0x0f, "16 elements" },
1385 { 0, NULL }
1386 };
1387
1388 static guint16
1389 de_nas_5gs_mm_5gs_ta_id_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
1390 guint32 offset, guint len,
1391 gchar *add_string _U_, int string_len _U_)
1392 {
1393 proto_tree *sub_tree;
1394 proto_item *item;
1395
1396 static int * const flags[] = {
1397 &hf_nas_5gs_mm_tal_t_li,
1398 &hf_nas_5gs_mm_tal_num_e,
1399 NULL
1400 };
1401
1402 guint num_par_tal = 1;
1403 guint32 curr_offset = offset;
1404 guint32 start_offset;
1405 guint8 tal_head, tal_t_li, tal_num_e;
1406
1407 /*Partial tracking area list*/
1408 while ((curr_offset - offset) < len) {
1409 start_offset = curr_offset;
1410 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_part_tal, &item, "Partial tracking area list %u", num_par_tal);
1411 /*Head of Partial tracking area list*/
1412 /* Type of list Number of elements octet 1 */
1413 tal_head = tvb_get_guint8(tvb, curr_offset);
1414 tal_t_li = (tal_head & 0x60) >> 5;
1415 tal_num_e = (tal_head & 0x1f) + 1;
1416 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, flags, ENC_BIG_ENDIAN);
1417 curr_offset++;
1418 switch (tal_t_li) {
1419 case 0:
1420 /*octet 2 MCC digit2 MCC digit1*/
1421 /*octet 3 MNC digit3 MCC digit3*/
1422 /*octet 4 MNC digit2 MNC digit1*/
1423 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
1424 curr_offset += 3;
1425 while (tal_num_e > 0) {
1426 proto_tree_add_item(sub_tree, hf_nas_5gs_tac, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
1427 curr_offset += 3;
1428 tal_num_e--;
1429 }
1430 break;
1431 case 1:
1432 /*octet 2 MCC digit2 MCC digit1*/
1433 /*octet 3 MNC digit3 MCC digit3*/
1434 /*octet 4 MNC digit2 MNC digit1*/
1435 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
1436 curr_offset += 3;
1437
1438 /*octet 5 TAC 1*/
1439 proto_tree_add_item(sub_tree, hf_nas_5gs_tac, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
1440 curr_offset+=3;
1441 break;
1442 case 2:
1443 while (tal_num_e > 0) {
1444 /*octet 2 MCC digit2 MCC digit1*/
1445 /*octet 3 MNC digit3 MCC digit3*/
1446 /*octet 4 MNC digit2 MNC digit1*/
1447 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
1448 curr_offset += 3;
1449
1450 /*octet 5 TAC 1*/
1451 proto_tree_add_item(sub_tree, hf_nas_5gs_tac, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
1452 curr_offset += 3;
1453
1454 tal_num_e--;
1455 }
1456 break;
1457 case 3:
1458 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
1459 curr_offset += 3;
1460 break;
1461 default:
1462 proto_tree_add_expert(sub_tree, pinfo, &ei_nas_5gs_unknown_value, tvb, curr_offset, len - 1);
1463 }
1464
1465 /*calculate the length of IE?*/
1466 proto_item_set_len(item, curr_offset - start_offset);
1467 /*calculate the number of Partial tracking area list*/
1468 num_par_tal++;
1469 }
1470
1471 return len;
1472 }
1473
1474 /*
1475 * 9.11.3.9A 5GS update type
1476 */
1477 static const value_string nas_5gs_mm_5gs_pnb_ciot_values[] = {
1478 { 0x0, "no additional information" },
1479 { 0x1, "control plane CIoT 5GS optimization" },
1480 { 0x2, "user plane CIoT 5GS optimization" },
1481 { 0x3, "reserved" },
1482 { 0, NULL }
1483 };
1484
1485 static const value_string nas_5gs_mm_eps_pnb_ciot_values[] = {
1486 { 0x0, "no additional information" },
1487 { 0x1, "control plane CIoT EPS optimization" },
1488 { 0x2, "user plane CIoT EPS optimization" },
1489 { 0x3, "reserved" },
1490 { 0, NULL }
1491 };
1492
1493 static guint16
1494 de_nas_5gs_mm_update_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
1495 guint32 offset, guint len _U_,
1496 gchar *add_string _U_, int string_len _U_)
1497 {
1498 static int * const flags[] = {
1499 &hf_nas_5gs_spare_b7,
1500 &hf_nas_5gs_spare_b6,
1501 &hf_nas_5gs_mm_eps_pnb_ciot,
1502 &hf_nas_5gs_mm_5gs_pnb_ciot,
1503 &hf_nas_5gs_mm_ng_ran_rcu,
1504 &hf_nas_5gs_mm_sms_requested,
1505 NULL
1506 };
1507
1508 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
1509
1510 return 1;
1511
1512 }
1513
1514 /*
1515 * 9.11.3.10 ABBA
1516 */
1517 static guint16
1518 de_nas_5gs_mm_abba(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
1519 guint32 offset, guint len,
1520 gchar *add_string _U_, int string_len _U_)
1521 {
1522 proto_tree_add_item(tree, hf_nas_5gs_mm_abba, tvb, offset, len, ENC_NA);
1523
1524 return len;
1525 }
1526
1527 /*
1528 * 9.11.3.11 Void
1529 */
1530
1531 /*
1532 * 9.11.3.12 Additional 5G security information
1533 */
1534 static guint16
1535 de_nas_5gs_mm_add_5g_sec_inf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
1536 guint32 offset, guint len _U_,
1537 gchar *add_string _U_, int string_len _U_)
1538 {
1539 static int * const flags[] = {
1540 &hf_nas_5gs_spare_b7,
1541 &hf_nas_5gs_spare_b6,
1542 &hf_nas_5gs_spare_b5,
1543 &hf_nas_5gs_spare_b4,
1544 &hf_nas_5gs_spare_b3,
1545 &hf_nas_5gs_spare_b2,
1546 &hf_nas_5gs_mm_rinmr,
1547 &hf_nas_5gs_mm_hdp,
1548 NULL
1549 };
1550
1551 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
1552
1553 return 1;
1554 }
1555
1556 /*
1557 * 9.11.3.12A Additional information requested
1558 */
1559 static guint16
1560 de_nas_5gs_mm_add_inf_req(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
1561 guint32 offset, guint len _U_,
1562 gchar* add_string _U_, int string_len _U_)
1563 {
1564 static int* const flags[] = {
1565 &hf_nas_5gs_spare_b7,
1566 &hf_nas_5gs_spare_b6,
1567 &hf_nas_5gs_spare_b5,
1568 &hf_nas_5gs_spare_b4,
1569 &hf_nas_5gs_spare_b3,
1570 &hf_nas_5gs_spare_b2,
1571 &hf_nas_5gs_spare_b1,
1572 &hf_nas_5gs_mm_cipher_key,
1573 NULL
1574 };
1575
1576 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
1577
1578 return 1;
1579 }
1580
1581 /*
1582 * 9.11.3.13 Allowed PDU session status
1583 */
1584 static true_false_string tfs_nas_5gs_allow_pdu_ses_sts_psi = {
1585 "user-plane resources of corresponding PDU session can be re-established over 3GPP access",
1586 "user-plane resources of corresponding PDU session is not allowed to be re-established over 3GPP access"
1587 };
1588
1589 static guint16
1590 de_nas_5gs_mm_allow_pdu_ses_sts(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
1591 guint32 offset, guint len,
1592 gchar *add_string _U_, int string_len _U_)
1593
1594 {
1595 int curr_offset;
1596
1597 static int * const psi_0_7_flags[] = {
1598 &hf_nas_5gs_allow_pdu_ses_sts_psi_7_b7,
1599 &hf_nas_5gs_allow_pdu_ses_sts_psi_6_b6,
1600 &hf_nas_5gs_allow_pdu_ses_sts_psi_5_b5,
1601 &hf_nas_5gs_allow_pdu_ses_sts_psi_4_b4,
1602 &hf_nas_5gs_allow_pdu_ses_sts_psi_3_b3,
1603 &hf_nas_5gs_allow_pdu_ses_sts_psi_2_b2,
1604 &hf_nas_5gs_allow_pdu_ses_sts_psi_1_b1,
1605 &hf_nas_5gs_allow_pdu_ses_sts_psi_0_b0,
1606 NULL
1607 };
1608
1609 static int * const psi_8_15_flags[] = {
1610 &hf_nas_5gs_allow_pdu_ses_sts_psi_15_b7,
1611 &hf_nas_5gs_allow_pdu_ses_sts_psi_14_b6,
1612 &hf_nas_5gs_allow_pdu_ses_sts_psi_13_b5,
1613 &hf_nas_5gs_allow_pdu_ses_sts_psi_12_b4,
1614 &hf_nas_5gs_allow_pdu_ses_sts_psi_11_b3,
1615 &hf_nas_5gs_allow_pdu_ses_sts_psi_10_b2,
1616 &hf_nas_5gs_allow_pdu_ses_sts_psi_9_b1,
1617 &hf_nas_5gs_allow_pdu_ses_sts_psi_8_b0,
1618 NULL
1619 };
1620
1621 curr_offset = offset;
1622 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_0_7_flags, ENC_BIG_ENDIAN);
1623 curr_offset++;
1624
1625 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_8_15_flags, ENC_BIG_ENDIAN);
1626 curr_offset++;
1627
1628 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
1629
1630 return (curr_offset - offset);
1631 }
1632
1633 /*
1634 * 9.11.3.14 Authentication failure parameter
1635 */
1636 /* See subclause 10.5.3.2.2 in 3GPP TS 24.008 */
1637
1638 /*
1639 * 9.11.3.15 Authentication parameter AUTN
1640 */
1641 /* See subclause 10.5.3.1 in 3GPP TS 24.008 */
1642
1643 /*
1644 * 9.11.3.16 Authentication parameter RAND
1645 */
1646
1647 /* See subclause 10.5.3.1 in 3GPP TS 24.008 */
1648
1649 /*
1650 * 9.11.3.17 Authentication response parameter
1651 */
1652 /* See subclause 9.9.3.4 in 3GPP TS 24.301 */
1653
1654 /*
1655 * 9.11.3.18 Configuration update indication
1656 */
1657 static guint16
1658 de_nas_5gs_mm_conf_upd_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
1659 guint32 offset, guint len _U_,
1660 gchar *add_string _U_, int string_len _U_)
1661 {
1662
1663 static int * const flags[] = {
1664 &hf_nas_5gs_spare_b3,
1665 &hf_nas_5gs_spare_b2,
1666 &hf_nas_5gs_mm_conf_upd_ind_red_b1,
1667 &hf_nas_5gs_mm_conf_upd_ind_ack_b0,
1668 NULL
1669 };
1670
1671
1672 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
1673
1674 return 1;
1675 }
1676
1677 /*
1678 * 9.11.3.18A CAG information list
1679 */
1680 static true_false_string tfs_5gs_mm_cag_info_entry_cag_only = {
1681 "the UE is not allowed to access 5GS via non-CAG cells",
1682 "the UE is allowed to access 5GS via non-CAG cells"
1683 };
1684
1685 static guint16
1686 de_nas_5gs_mm_cag_information_list(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo,
1687 guint32 offset, guint len,
1688 gchar* add_string _U_, int string_len _U_)
1689 {
1690 proto_tree *sub_tree;
1691 proto_item *item;
1692 guint num_entry = 1;
1693 guint32 curr_offset = offset;
1694 guint32 start_offset, entry_len;
1695
1696 while ((curr_offset - offset) < len) {
1697 start_offset = curr_offset;
1698 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_cag_info_entry,
1699 &item, "CAG information entry %u", num_entry);
1700 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_cag_info_entry_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &entry_len);
1701 curr_offset++;
1702 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_NONE, TRUE);
1703 curr_offset += 3;
1704 proto_tree_add_bits_item(sub_tree, hf_nas_5gs_spare_bits, tvb, (curr_offset << 3), 7, ENC_BIG_ENDIAN);
1705 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_cag_info_entry_cag_only, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1706 curr_offset++;
1707 while ((curr_offset - start_offset) < entry_len) {
1708 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_cag_info_entry_cag_id, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
1709 curr_offset += 4;
1710 }
1711 proto_item_set_len(item, curr_offset - start_offset);
1712 num_entry++;
1713 }
1714
1715 return len;
1716 }
1717
1718 /*
1719 * 9.11.3.18B CIoT small data container
1720 */
1721 static void
1722 nas_5gs_decode_user_data_cont(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo,
1723 guint32 offset, guint len, int hfindex)
1724 {
1725 proto_item *item;
1726
1727 item = proto_tree_add_item(tree, hfindex, tvb, offset, len, ENC_NA);
1728 if (g_nas_5gs_decode_user_data_container_as != DECODE_USER_DATA_AS_NONE) {
1729 tvbuff_t *user_data_cont_tvb;
1730 volatile dissector_handle_t handle;
1731
1732 user_data_cont_tvb = tvb_new_subset_length(tvb, offset, len);
1733 if (g_nas_5gs_decode_user_data_container_as == DECODE_USER_DATA_AS_IP) {
1734 guint8 first_byte = tvb_get_guint8(user_data_cont_tvb, 0);
1735 if (first_byte >= 0x45 && first_byte <= 0x4f && len > 20)
1736 handle = ipv4_handle;
1737 else if ((first_byte & 0xf0) == 0x60 && len > 40)
1738 handle = ipv6_handle;
1739 else
1740 handle = NULL;
1741 } else if (g_nas_5gs_decode_user_data_container_as == DECODE_USER_DATA_AS_NON_IP) {
1742 handle = non_ip_data_handle;
1743 } else {
1744 handle = ethernet_handle;
1745 }
1746 if (handle) {
1747 col_append_str(pinfo->cinfo, COL_PROTOCOL, "/");
1748 col_set_fence(pinfo->cinfo, COL_PROTOCOL);
1749 col_append_str(pinfo->cinfo, COL_INFO, ", ");
1750 col_set_fence(pinfo->cinfo, COL_INFO);
1751 TRY {
1752 proto_tree *toptree = proto_tree_get_root(tree);
1753 call_dissector_only(handle, user_data_cont_tvb, pinfo, toptree, NULL);
1754 } CATCH_BOUNDS_ERRORS {
1755 /* Dissection exception: message was probably non IP and heuristic was too weak */
1756 proto_tree *subtree = proto_item_add_subtree(item, ett_nas_5gs_user_data_cont);
1757 show_exception(user_data_cont_tvb, pinfo, subtree, EXCEPT_CODE, GET_MESSAGE);
1758 } ENDTRY
1759 }
1760 }
1761 }
1762
1763 static const value_string nas_5gs_mm_ciot_small_data_cont_data_type_values[] = {
1764 { 0x00, "Control plane user data" },
1765 { 0x01, "SMS" },
1766 { 0x02, "Location services message container" },
1767 { 0, NULL }
1768 };
1769
1770 static const value_string nas_5gs_mm_ciot_small_data_cont_ddx_values[] = {
1771 { 0x00, "No information available" },
1772 { 0x01, "No further uplink and no further downlink data transmission subsequent to the uplink data transmission is expected" },
1773 { 0x02, "Only a single downlink data transmission and no further uplink data transmission subsequent to the uplink data transmission is expected" },
1774 { 0x03, "Reserved" },
1775 { 0, NULL }
1776 };
1777
1778 static guint16
1779 de_nas_5gs_mm_ciot_small_data_cont(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo,
1780 guint32 offset, guint len,
1781 gchar* add_string _U_, int string_len _U_)
1782 {
1783 guint32 curr_offset = offset;
1784 guint32 data_type, add_info_len;
1785 proto_tree *sub_tree;
1786 proto_item *item;
1787
1788 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_mm_ciot_small_data_cont_data_type,
1789 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &data_type);
1790 switch (data_type) {
1791 case 0:
1792 proto_tree_add_item(tree, hf_nas_5gs_mm_ciot_small_data_cont_ddx,
1793 tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1794 proto_tree_add_item(tree, hf_nas_5gs_mm_ciot_small_data_cont_pdu_session_id,
1795 tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1796 curr_offset++;
1797 nas_5gs_decode_user_data_cont(tvb, tree, pinfo, curr_offset, len - curr_offset,
1798 hf_nas_5gs_mm_ciot_small_data_cont_data_contents);
1799 break;
1800 case 1:
1801 proto_tree_add_bits_item(tree, hf_nas_5gs_spare_bits, tvb,
1802 (curr_offset << 3) + 3, 5, ENC_BIG_ENDIAN);
1803 curr_offset++;
1804 item = proto_tree_add_item(tree, hf_nas_5gs_mm_ciot_small_data_cont_data_contents,
1805 tvb, curr_offset, len - curr_offset, ENC_NA);
1806 if (gsm_a_dtap_handle) {
1807 sub_tree = proto_item_add_subtree(item, ett_nas_5gs_ciot_small_data_cont_data_contents);
1808 call_dissector(gsm_a_dtap_handle, tvb_new_subset_length(tvb, curr_offset, curr_offset - len), pinfo, sub_tree);
1809 }
1810 break;
1811 case 2:
1812 proto_tree_add_item(tree, hf_nas_5gs_mm_ciot_small_data_cont_ddx,
1813 tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1814 proto_tree_add_bits_item(tree, hf_nas_5gs_spare_bits, tvb,
1815 (curr_offset << 3) + 5, 3, ENC_BIG_ENDIAN);
1816 curr_offset++;
1817 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_mm_ciot_small_data_cont_add_info_len,
1818 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &add_info_len);
1819 curr_offset++;
1820 if (add_info_len > 0) {
1821 proto_tree_add_item(tree, hf_nas_5gs_mm_ciot_small_data_cont_add_info,
1822 tvb, curr_offset, add_info_len, ENC_NA);
1823 curr_offset += add_info_len;
1824 }
1825 proto_tree_add_item(tree, hf_nas_5gs_mm_ciot_small_data_cont_data_contents,
1826 tvb, curr_offset, len - curr_offset, ENC_NA);
1827 break;
1828 default:
1829 proto_tree_add_expert(tree, pinfo, &ei_nas_5gs_unknown_value, tvb, curr_offset, len);
1830 break;
1831 }
1832
1833 return len;
1834 }
1835
1836 /*
1837 * 9.11.3.18C Ciphering key data
1838 */
1839 static const true_false_string nas_5gs_applicable_not_applicable = {
1840 "Applicable",
1841 "Not applicable"
1842 };
1843
1844 static guint16
1845 de_nas_5gs_mm_ciphering_key_data(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo,
1846 guint32 offset, guint len,
1847 gchar* add_string _U_, int string_len _U_)
1848 {
1849 guint32 saved_offset, curr_offset = offset, c0_len, pos_sib_len, tai_len, i = 1;
1850 guint8 oct;
1851 struct tm tm;
1852 nstime_t tv;
1853 proto_item *pi;
1854 proto_tree *sub_tree;
1855
1856 while ((curr_offset - offset) < len) {
1857 static int * const eutra_flags1[] = {
1858 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_1,
1859 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_2,
1860 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_3,
1861 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_4,
1862 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_5,
1863 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_6,
1864 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_7,
1865 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_1_8,
1866 NULL
1867 };
1868 static int * const eutra_flags2[] = {
1869 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_1,
1870 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_2,
1871 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_3,
1872 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_4,
1873 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_5,
1874 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_6,
1875 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_7,
1876 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_8,
1877 NULL
1878 };
1879 static int * const eutra_flags3[] = {
1880 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_9,
1881 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_10,
1882 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_11,
1883 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_12,
1884 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_13,
1885 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_14,
1886 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_15,
1887 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_16,
1888 NULL
1889 };
1890 static int * const eutra_flags4[] = {
1891 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_17,
1892 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_18,
1893 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_19,
1894 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_20,
1895 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_21,
1896 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_22,
1897 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_23,
1898 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_24,
1899 NULL
1900 };
1901 static int * const eutra_flags5[] = {
1902 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_2_25,
1903 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_3_1,
1904 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_4_1,
1905 &hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_type_5_1,
1906 &hf_nas_5gs_spare_b3,
1907 &hf_nas_5gs_spare_b2,
1908 &hf_nas_5gs_spare_b1,
1909 &hf_nas_5gs_spare_b0,
1910 NULL
1911 };
1912 static int * const nr_flags1[] = {
1913 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_1,
1914 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_2,
1915 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_3,
1916 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_4,
1917 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_5,
1918 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_6,
1919 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_7,
1920 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_1_8,
1921 NULL
1922 };
1923 static int * const nr_flags2[] = {
1924 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_1,
1925 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_2,
1926 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_3,
1927 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_4,
1928 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_5,
1929 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_6,
1930 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_7,
1931 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_8,
1932 NULL
1933 };
1934 static int * const nr_flags3[] = {
1935 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_9,
1936 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_10,
1937 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_11,
1938 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_12,
1939 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_13,
1940 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_14,
1941 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_15,
1942 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_16,
1943 NULL
1944 };
1945 static int * const nr_flags4[] = {
1946 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_17,
1947 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_18,
1948 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_19,
1949 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_20,
1950 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_21,
1951 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_22,
1952 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_2_23,
1953 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_3_1,
1954 NULL
1955 };
1956 static int * const nr_flags5[] = {
1957 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_4_1,
1958 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_5_1,
1959 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_6_1,
1960 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_6_2,
1961 &hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_type_6_3,
1962 &hf_nas_5gs_spare_b2,
1963 &hf_nas_5gs_spare_b1,
1964 &hf_nas_5gs_spare_b0,
1965 NULL
1966 };
1967
1968 saved_offset = curr_offset;
1969 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_ciph_data_set,
1970 &pi, "Ciphering data set #%u", i++);
1971 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_ciph_key_data_ciphering_set_id, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1972 curr_offset += 2;
1973 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_ciph_key_data_ciphering_key, tvb, curr_offset, 16, ENC_NA);
1974 curr_offset += 16;
1975 proto_tree_add_bits_item(sub_tree, hf_nas_5gs_spare_bits, tvb, offset<<3, 3, ENC_BIG_ENDIAN);
1976 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_ciph_key_data_c0_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &c0_len);
1977 curr_offset++;
1978 if (c0_len) {
1979 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_ciph_key_data_c0, tvb, curr_offset, c0_len, ENC_NA);
1980 curr_offset += c0_len;
1981 }
1982 proto_tree_add_bits_item(sub_tree, hf_nas_5gs_spare_bits, tvb, offset<<3, 4, ENC_BIG_ENDIAN);
1983 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_ciph_key_data_eutra_pos_sib_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &pos_sib_len);
1984 curr_offset++;
1985 if (pos_sib_len > 0) {
1986 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, eutra_flags1, ENC_NA);
1987 if (pos_sib_len >= 2)
1988 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 1, 1, eutra_flags2, ENC_NA);
1989 if (pos_sib_len >= 3)
1990 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 2, 1, eutra_flags3, ENC_NA);
1991 if (pos_sib_len >= 4)
1992 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 3, 1, eutra_flags4, ENC_NA);
1993 if (pos_sib_len >= 5)
1994 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 4, 1, eutra_flags5, ENC_NA);
1995 curr_offset += pos_sib_len;
1996 }
1997 proto_tree_add_bits_item(sub_tree, hf_nas_5gs_spare_bits, tvb, offset<<3, 4, ENC_BIG_ENDIAN);
1998 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_ciph_key_data_nr_pos_sib_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &pos_sib_len);
1999 curr_offset++;
2000 if (pos_sib_len > 0) {
2001 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, nr_flags1, ENC_NA);
2002 if (pos_sib_len >= 2)
2003 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 1, 1, nr_flags2, ENC_NA);
2004 if (pos_sib_len >= 3)
2005 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 2, 1, nr_flags3, ENC_NA);
2006 if (pos_sib_len >= 4)
2007 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 3, 1, nr_flags4, ENC_NA);
2008 if (pos_sib_len >= 5)
2009 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset + 4, 1, nr_flags5, ENC_NA);
2010 curr_offset += pos_sib_len;
2011 }
2012 tm.tm_wday = 0;
2013 tm.tm_yday = 0;
2014 tm.tm_isdst = -1;
2015 oct = tvb_get_guint8(tvb, curr_offset);
2016 tm.tm_year = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4) + 100;
2017 oct = tvb_get_guint8(tvb, curr_offset+1);
2018 tm.tm_mon = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4) - 1;
2019 oct = tvb_get_guint8(tvb, curr_offset+2);
2020 tm.tm_mday = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4);
2021 oct = tvb_get_guint8(tvb, curr_offset+3);
2022 tm.tm_hour = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4);
2023 oct = tvb_get_guint8(tvb, curr_offset+4);
2024 tm.tm_min = (oct & 0x0f)*10 + ((oct & 0xf0) >> 4);
2025 tm.tm_sec = 0;
2026 tv.secs = mktime(&tm);
2027 tv.nsecs = 0;
2028 proto_tree_add_time_format_value(sub_tree, hf_nas_5gs_mm_ciph_key_data_validity_start_time, tvb, curr_offset, 5, &tv,
2029 "%s", abs_time_to_str(pinfo->pool, &tv, ABSOLUTE_TIME_LOCAL, FALSE));
2030 curr_offset += 5;
2031 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_ciph_key_data_validity_duration, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
2032 curr_offset += 2;
2033 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_ciph_key_data_tais_list_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &tai_len);
2034 curr_offset++;
2035 if (tai_len) {
2036 de_nas_5gs_mm_5gs_ta_id_list(tvb, sub_tree, pinfo, curr_offset, tai_len, NULL, 0);
2037 curr_offset += tai_len;
2038 }
2039 proto_item_set_len(pi, curr_offset - saved_offset);
2040 }
2041
2042 return len;
2043 }
2044
2045 /*
2046 * 9.11.3.18D Control plane service type
2047 */
2048 static const value_string nas_5gs_mm_ctrl_plane_serv_type_values[] = {
2049 { 0x00, "mobile originating request" },
2050 { 0x01, "mobile terminating request" },
2051 { 0x02, "emergency services" },
2052 { 0x03, "emergency services fallback" },
2053 { 0, NULL }
2054 };
2055
2056 static guint16
2057 de_nas_5gs_mm_ctrl_plane_service_type(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
2058 guint32 offset, guint len,
2059 gchar* add_string _U_, int string_len _U_)
2060 {
2061 static int * const flags[] = {
2062 &hf_nas_5gs_spare_b3,
2063 &hf_nas_5gs_mm_ctrl_plane_serv_type,
2064 NULL
2065 };
2066
2067 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_NA);
2068
2069 return len;
2070 }
2071
2072 /*
2073 * 9.11.3.19 Daylight saving time
2074 */
2075 /* See subclause 10.5.3.12 in 3GPP TS 24.008 */
2076
2077 /*
2078 * 9.11.3.20 De-registration type
2079 */
2080 static const true_false_string nas_5gs_mm_switch_off_tfs = {
2081 "Switch off",
2082 "Normal de-registration"
2083 };
2084
2085 static const true_false_string nas_5gs_mm_re_reg_req_tfs = {
2086 "re-registration required",
2087 "re-registration not required"
2088 };
2089
2090 static const value_string nas_5gs_mm_acc_type_vals[] = {
2091 { 0x1, "3GPP access"},
2092 { 0x2, "Non-3GPP access"},
2093 { 0x3, "3GPP access and non-3GPP access"},
2094 { 0, NULL }
2095 };
2096
2097 static guint16
2098 de_nas_5gs_mm_de_reg_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2099 guint32 offset, guint len _U_,
2100 gchar *add_string _U_, int string_len _U_)
2101 {
2102 /* Switch off Re-registration required Access type */
2103 proto_tree_add_item(tree, hf_nas_5gs_mm_switch_off, tvb, offset, 1, ENC_BIG_ENDIAN);
2104 proto_tree_add_item(tree, hf_nas_5gs_mm_re_reg_req, tvb, offset, 1, ENC_BIG_ENDIAN);
2105 proto_tree_add_item(tree, hf_nas_5gs_mm_acc_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2106
2107 return 1;
2108 }
2109
2110 /* 9.11.3.21 Void*/
2111 /* 9.11.3.22 Void*/
2112
2113 /*
2114 * 9.11.3.23 Emergency number list
2115 */
2116 /* See subclause 10.5.3.13 in 3GPP TS 24.008 */
2117
2118 /*
2119 * 9.11.3.24 EPS NAS message container
2120 */
2121 static guint16
2122 de_nas_5gs_mm_eps_nas_msg_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2123 guint32 offset, guint len,
2124 gchar *add_string _U_, int string_len _U_)
2125 {
2126 /* an EPS NAS message as specified in 3GPP TS 24.301 */
2127 if (nas_eps_handle) {
2128 col_append_str(pinfo->cinfo, COL_PROTOCOL, "/");
2129 col_set_fence(pinfo->cinfo, COL_PROTOCOL);
2130 call_dissector(nas_eps_handle, tvb_new_subset_length(tvb, offset, len), pinfo, tree);
2131 }
2132
2133 return len;
2134 }
2135
2136 /*
2137 * 9.11.3.25 EPS NAS security algorithms
2138 */
2139 /* See subclause 9.9.3.23 in 3GPP TS 24.301 */
2140
2141 /*
2142 * 9.11.3.26 Extended emergency number list
2143 */
2144 /* See subclause 9.9.3.37A in 3GPP TS 24.301 */
2145
2146 /*
2147 * 9.11.3.26A Extended DRX parameters
2148 */
2149 /* See subclause 10.5.5.32 in 3GPP TS 24.008 */
2150
2151 /* 9.11.3.27 Void*/
2152
2153 /*
2154 * 9.11.3.28 IMEISV request
2155 */
2156 /* See subclause 10.5.5.10 in 3GPP TS 24.008 */
2157
2158 /*
2159 * 9.11.3.29 LADN indication
2160 */
2161
2162 static guint16
2163 de_nas_5gs_mm_ladn_indic(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2164 guint32 offset, guint len,
2165 gchar *add_string _U_, int string_len _U_)
2166 {
2167 proto_tree *sub_tree;
2168 proto_item *item;
2169 int i = 1;
2170 guint32 length;
2171 guint32 curr_offset;
2172
2173 curr_offset = offset;
2174
2175 while ((curr_offset - offset) < len) {
2176 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, 2, ett_nas_5gs_mm_ladn_indic, &item, "LADN DNN value %u", i);
2177 /*LADN DNN value is coded as the length and value part of DNN information element as specified in subclause 9.11.2.1B starting with the second octet*/
2178 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_length, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &length);
2179 curr_offset++;
2180 curr_offset += de_nas_5gs_cmn_dnn(tvb, sub_tree, pinfo, curr_offset, length, NULL, 0);
2181 proto_item_set_len(item, length + 1);
2182
2183 i++;
2184
2185 }
2186
2187 return len;
2188 }
2189
2190 /*
2191 * 9.11.3.30 LADN information
2192 */
2193
2194 static guint16
2195 de_nas_5gs_mm_ladn_inf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2196 guint32 offset, guint len,
2197 gchar *add_string _U_, int string_len _U_)
2198 {
2199 proto_tree *sub_tree;
2200 proto_item *item;
2201 int i = 1;
2202 guint32 length;
2203 guint32 curr_offset;
2204
2205 curr_offset = offset;
2206
2207 while ((curr_offset - offset) < len) {
2208 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, 2, ett_nas_5gs_mm_ladn_indic, &item, "LADN %u", i);
2209 /* DNN value (octet 5 to octet m):
2210 * LADN DNN value is coded as the length and value part of DNN information element as specified in
2211 * subclause 9.11.2.1B starting with the second octet
2212 */
2213 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_length, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &length);
2214 curr_offset++;
2215 curr_offset += de_nas_5gs_cmn_dnn(tvb, sub_tree, pinfo, curr_offset, length, NULL, 0);
2216 /* 5GS tracking area identity list (octet m+1 to octet a):
2217 * 5GS tracking area identity list field is coded as the length and the value part of the
2218 * 5GS Tracking area identity list information element as specified in subclause 9.11.3.9
2219 * starting with the second octet
2220 */
2221 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_length, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &length);
2222 curr_offset++;
2223 curr_offset += de_nas_5gs_mm_5gs_ta_id_list(tvb, sub_tree, pinfo, curr_offset, length, NULL, 0);
2224
2225 proto_item_set_len(item, curr_offset - offset);
2226
2227 i++;
2228
2229 }
2230
2231 return len;
2232 }
2233
2234 /*
2235 * 9.11.3.31 MICO indication
2236 */
2237 static const true_false_string tfs_nas_5gs_raai = {
2238 "all PLMN registration area allocated",
2239 "all PLMN registration area not allocated"
2240 };
2241
2242 static guint16
2243 de_nas_5gs_mm_mico_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2244 guint32 offset, guint len _U_,
2245 gchar *add_string _U_, int string_len _U_)
2246 {
2247 static int * const flags[] = {
2248 &hf_nas_5gs_spare_b3,
2249 &hf_nas_5gs_spare_b2,
2250 &hf_nas_5gs_mm_sprti_b1,
2251 &hf_nas_5gs_mm_raai_b0,
2252 NULL
2253 };
2254
2255 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
2256
2257 return 1;
2258 }
2259
2260 /*
2261 * 9.11.3.31A MA PDU session information
2262 */
2263 static const value_string nas_5gs_mm_ma_pdu_session_info_vals[] = {
2264 { 0x1, "MA PDU session network upgrade is allowed"},
2265 { 0, NULL }
2266 };
2267
2268 static guint16
2269 de_nas_5gs_mm_ma_pdu_ses_inf(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
2270 guint32 offset, guint len,
2271 gchar* add_string _U_, int string_len _U_)
2272 {
2273 proto_tree_add_item(tree, hf_nas_5gs_mm_ma_pdu_session_info_value, tvb, offset, 1, ENC_BIG_ENDIAN);
2274
2275 return len;
2276 }
2277
2278 /*
2279 * 9.11.3.31B Mapped NSSAI
2280 */
2281 static const value_string nas_5gs_mm_sst_vals[] = {
2282 { 0x1, "eMBB"},
2283 { 0x2, "URLLC"},
2284 { 0x3, "MIoT"},
2285 { 0x4, "V2X"},
2286 { 0, NULL }
2287 };
2288
2289 static guint16
2290 de_nas_5gs_mm_mapped_nssai(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
2291 guint32 offset, guint len,
2292 gchar* add_string _U_, int string_len _U_)
2293 {
2294 proto_tree* sub_tree;
2295 proto_item* item;
2296 guint num_items = 1;
2297 guint32 curr_offset = offset;
2298 guint32 start_offset, nssai_len;
2299
2300 /* Rejected NSSAI */
2301 while ((curr_offset - offset) < len) {
2302 start_offset = curr_offset;
2303 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_mapped_nssai,
2304 &item, "Mapped S-NSSAI content %u", num_items);
2305
2306 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_len_of_mapped_s_nssai, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &nssai_len);
2307 curr_offset++;
2308 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_sst, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2309 curr_offset++;
2310 if (nssai_len > 1) {
2311 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_sd, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
2312 curr_offset += 3;
2313 }
2314 proto_item_set_len(item, curr_offset - start_offset);
2315 }
2316
2317 return len;
2318 }
2319
2320 /*
2321 * 9.11.3.31C Mobile station classmark 2
2322 */
2323 /* See subclause 10.5.1.6 in 3GPP TS 24.008 */
2324
2325 /*
2326 * 9.11.3.32 NAS key set identifier
2327 */
2328 static const true_false_string nas_5gs_mm_tsc_tfs = {
2329 "Mapped security context (for KSIASME)",
2330 "Native security context (for KSIAMF)"
2331 };
2332
2333 static guint16
2334 de_nas_5gs_mm_nas_key_set_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2335 guint32 offset, guint len _U_,
2336 gchar *add_string _U_, int string_len _U_)
2337 {
2338 static int * const flags[] = {
2339 &hf_nas_5gs_mm_tsc,
2340 &hf_nas_5gs_mm_nas_key_set_id,
2341 NULL
2342 };
2343
2344 /* NAS key set identifier IEI TSC NAS key set identifier */
2345 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
2346
2347 return 1;
2348 }
2349
2350 /* High nibble version (LEFT_NIBBLE) */
2351 static guint16
2352 de_nas_5gs_mm_nas_key_set_id_h1(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
2353 guint32 offset, guint len _U_,
2354 gchar* add_string _U_, int string_len _U_)
2355 {
2356 static int* const flags[] = {
2357 &hf_nas_5gs_mm_tsc_h1,
2358 &hf_nas_5gs_mm_nas_key_set_id_h1,
2359 NULL
2360 };
2361
2362 /* NAS key set identifier IEI TSC NAS key set identifier */
2363 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
2364
2365 return 1;
2366 }
2367
2368
2369 /*
2370 * 9.11.3.33 NAS message container
2371 */
2372 static guint16
2373 de_nas_5gs_mm_nas_msg_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2374 guint32 offset, guint len,
2375 gchar *add_string _U_, int string_len _U_)
2376 {
2377 /* The purpose of the NAS message container IE is to encapsulate a plain 5GS NAS message. */
2378 /* a NAS message without NAS security heade */
2379
2380 dissect_nas_5gs(tvb_new_subset_length(tvb, offset, len), pinfo, tree, NULL);
2381
2382 return len;
2383 }
2384
2385 /*
2386 * 9.11.3.34 NAS security algorithms
2387 */
2388
2389 static const value_string nas_5gs_mm_type_of_ip_algo_vals[] = {
2390 { 0x0, "5G-IA0 (null integrity protection algorithm)"},
2391 { 0x1, "128-5G-IA1"},
2392 { 0x2, "128-5G-IA2"},
2393 { 0x3, "128-5G-IA3"},
2394 { 0x4, "5G-IA4"},
2395 { 0x5, "5G-IA5"},
2396 { 0x6, "5G-IA6"},
2397 { 0x7, "5G-IA7"},
2398 { 0, NULL }
2399 };
2400
2401 static const value_string nas_5gs_mm_type_of_enc_algo_vals[] = {
2402 { 0x0, "5G-EA0 (null ciphering algorithm)"},
2403 { 0x1, "128-5G-EA1"},
2404 { 0x2, "128-5G-EA2"},
2405 { 0x3, "128-5G-EA3"},
2406 { 0x4, "5G-EA4"},
2407 { 0x5, "5G-EA5"},
2408 { 0x6, "5G-EA6"},
2409 { 0x7, "5G-EA7"},
2410 { 0, NULL }
2411 };
2412
2413 static guint16
2414 de_nas_5gs_mm_nas_sec_algo(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2415 guint32 offset, guint len _U_,
2416 gchar *add_string _U_, int string_len _U_)
2417 {
2418
2419 static int * const flags[] = {
2420 &hf_nas_5gs_mm_nas_sec_algo_enc,
2421 &hf_nas_5gs_mm_nas_sec_algo_ip,
2422 NULL
2423 };
2424
2425 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
2426
2427 return 1;
2428 }
2429
2430
2431 /*
2432 * 9.11.3.35 Network name
2433 */
2434 /* See subclause 10.5.3.5a in 3GPP TS 24.008 */
2435
2436
2437 /*
2438 * 9.11.3.36 Network slicing indication
2439 */
2440
2441 static const true_false_string nas_5gs_mm_dcni_tfs = {
2442 "Requested NSSAI created from default configured NSSAI",
2443 "Requested NSSAI not created from default configured NSSAI"
2444 };
2445
2446 static guint16
2447 de_nas_5gs_mm_nw_slicing_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2448 guint32 offset, guint len,
2449 gchar *add_string _U_, int string_len _U_)
2450 {
2451 static int * const flags[] = {
2452 &hf_nas_5gs_spare_b3,
2453 &hf_nas_5gs_spare_b2,
2454 &hf_nas_5gs_mm_dcni,
2455 &hf_nas_5gs_mm_nssci,
2456 NULL
2457 };
2458
2459 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
2460
2461 return len;
2462 }
2463
2464 /*
2465 * 9.11.3.37 NSSAI
2466 */
2467 static guint16
2468 de_nas_5gs_mm_nssai(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2469 guint32 offset, guint len,
2470 gchar *add_string _U_, int string_len _U_)
2471 {
2472 proto_tree *sub_tree;
2473 proto_item *item;
2474 int i = 1;
2475 guint32 length;
2476 guint32 curr_offset;
2477
2478 curr_offset = offset;
2479
2480 while ((curr_offset - offset) < len) {
2481 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, 2, ett_nas_5gs_mm_nssai, &item, "S-NSSAI %u", i);
2482
2483 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_length, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &length);
2484 curr_offset++;
2485 curr_offset += de_nas_5gs_cmn_s_nssai(tvb, sub_tree, pinfo, curr_offset, length, NULL, 0);
2486 proto_item_set_len(item, length + 1);
2487 i++;
2488
2489 }
2490
2491 return len;
2492 }
2493
2494 /*
2495 * 9.11.3.37A NSSAI inclusion mode
2496 */
2497
2498
2499 static const value_string nas_5gs_mm_nssai_inc_mode_vals[] = {
2500 { 0x00, "A" },
2501 { 0x01, "B" },
2502 { 0x02, "C" },
2503 { 0x03, "D" },
2504 { 0, NULL } };
2505
2506 static guint16
2507 de_nas_5gs_mm_nssai_inc_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2508 guint32 offset, guint len,
2509 gchar *add_string _U_, int string_len _U_)
2510 {
2511 static int * const flags[] = {
2512 &hf_nas_5gs_spare_b3,
2513 &hf_nas_5gs_spare_b2,
2514 &hf_nas_5gs_mm_nssai_inc_mode,
2515 NULL
2516 };
2517
2518 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
2519
2520 return len;
2521 }
2522
2523 /*
2524 * 9.11.3.38 Operator-defined access category definitions
2525 */
2526
2527 static void
2528 nas_5gs_mm_access_cat_number(gchar *s, guint32 val)
2529 {
2530 snprintf(s, ITEM_LABEL_LENGTH, "%u (%u)", 32+val, val);
2531 }
2532
2533 static void
2534 nas_5gs_mm_access_standardized_cat_number(gchar *s, guint32 val)
2535 {
2536 if (val <= 7)
2537 snprintf(s, ITEM_LABEL_LENGTH, "%u", val);
2538 else
2539 snprintf(s, ITEM_LABEL_LENGTH, "Reserved (%u)", val);
2540 }
2541
2542 static const value_string nas_5gs_mm_op_def_access_cat_criteria_type_vals[] = {
2543 { 0, "DNN" },
2544 { 1, "OS Id + OS App Id" },
2545 { 2, "S-NSSAI" },
2546 { 0, NULL }
2547 };
2548
2549 static guint16
2550 de_nas_5gs_mm_op_def_acc_cat_def(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2551 guint32 offset, guint len,
2552 gchar *add_string _U_, int string_len _U_)
2553 {
2554 proto_tree *sub_tree, *sub_tree2, *sub_tree3;
2555 proto_item *item, *item2, *item3;
2556 guint32 i = 1, j, k;
2557 guint32 length, criteria_length, criteria_type, criteria_count;
2558 guint32 curr_offset, saved_offset, saved_offset2, saved_offset3, criteria_offset;
2559 gboolean psac;
2560
2561 curr_offset = offset;
2562
2563 while ((curr_offset - offset) < len) {
2564 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, 4, ett_nas_5gs_mm_op_def_acc_cat_def,
2565 &item, "Operator-defined access category definition %u", i);
2566
2567 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_op_def_access_cat_len, tvb,
2568 curr_offset, 1, ENC_BIG_ENDIAN, &length);
2569 curr_offset++;
2570 saved_offset = curr_offset;
2571 /* Precedence value */
2572 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_op_def_access_cat_precedence,
2573 tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2574 curr_offset++;
2575 /* PSAC 0 Spare 0 Spare Operator-defined access category number */
2576 proto_tree_add_item_ret_boolean(sub_tree, hf_nas_5gs_mm_op_def_access_cat_psac,
2577 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &psac);
2578 proto_tree_add_bits_item(sub_tree, hf_nas_5gs_spare_bits, tvb,
2579 (curr_offset << 3)+1, 2, ENC_BIG_ENDIAN);
2580 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_op_def_access_cat_number,
2581 tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2582 curr_offset++;
2583 /* Length of criteria */
2584 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_op_def_access_cat_criteria_length,
2585 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &criteria_length);
2586 curr_offset++;
2587 criteria_offset = curr_offset;
2588 j = 1;
2589 while ((curr_offset - criteria_offset) < criteria_length) {
2590 saved_offset2 = curr_offset;
2591 sub_tree2 = proto_tree_add_subtree_format(sub_tree, tvb, curr_offset, 1, ett_nas_5gs_mm_op_def_acc_cat_criteria_component,
2592 &item2, "Criteria component %u", j++);
2593 /* Criteria */
2594 proto_tree_add_item_ret_uint(sub_tree2, hf_nas_5gs_mm_op_def_access_cat_criteria_type,
2595 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &criteria_type);
2596 curr_offset++;
2597 switch (criteria_type) {
2598 case 0:
2599 proto_tree_add_item_ret_uint(sub_tree2, hf_nas_5gs_mm_op_def_access_cat_criteria_dnn_count,
2600 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &criteria_count);
2601 curr_offset++;
2602 for (k = 1; k <= criteria_count; k++) {
2603 guint32 dnn_len;
2604 saved_offset3 = curr_offset;
2605 sub_tree3 = proto_tree_add_subtree_format(sub_tree2, tvb, curr_offset, -1,
2606 ett_nas_5gs_mm_op_def_acc_cat_criteria, &item3, "DNN %u", k);
2607 proto_tree_add_item_ret_uint(sub_tree3, hf_nas_5gs_mm_op_def_access_cat_criteria_dnn_len,
2608 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &dnn_len);
2609 curr_offset++;
2610 de_nas_5gs_cmn_dnn(tvb, sub_tree3, pinfo, curr_offset, dnn_len, NULL, 0);
2611 curr_offset += dnn_len;
2612 proto_item_set_len(item3, curr_offset - saved_offset3);
2613 }
2614 break;
2615 case 1:
2616 proto_tree_add_item_ret_uint(sub_tree2, hf_nas_5gs_mm_op_def_access_cat_criteria_os_id_os_app_id_count,
2617 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &criteria_count);
2618 curr_offset++;
2619 for (k = 1; k <= criteria_count; k++) {
2620 guint32 os_app_id_len;
2621 saved_offset3 = curr_offset;
2622 sub_tree3 = proto_tree_add_subtree_format(sub_tree2, tvb, curr_offset, -1, ett_nas_5gs_mm_op_def_acc_cat_criteria,
2623 &item3, "OS Id + Os App Id %u", k);
2624 proto_tree_add_item(sub_tree3, hf_nas_5gs_mm_op_def_access_cat_criteria_os_id,
2625 tvb, curr_offset, 16, ENC_NA);
2626 curr_offset += 16;
2627 proto_tree_add_item_ret_uint(sub_tree3, hf_nas_5gs_mm_op_def_access_cat_criteria_os_app_id_len,
2628 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &os_app_id_len);
2629 curr_offset++;
2630 proto_tree_add_item(sub_tree3, hf_nas_5gs_mm_op_def_access_cat_criteria_os_app_id,
2631 tvb, curr_offset, os_app_id_len, ENC_NA);
2632 curr_offset += os_app_id_len;
2633 proto_item_set_len(item3, curr_offset - saved_offset3);
2634 }
2635 break;
2636 case 2:
2637 proto_tree_add_item_ret_uint(sub_tree2, hf_nas_5gs_mm_op_def_access_cat_criteria_s_nssai_count,
2638 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &criteria_count);
2639 curr_offset++;
2640 for (k = 1; k <= criteria_count; k++) {
2641 guint32 s_nssai_len;
2642 saved_offset3 = curr_offset;
2643 sub_tree3 = proto_tree_add_subtree_format(sub_tree2, tvb, curr_offset, -1,
2644 ett_nas_5gs_mm_op_def_acc_cat_criteria, &item3, "S-NSSAI %u", k);
2645 proto_tree_add_item_ret_uint(sub_tree3, hf_nas_5gs_mm_op_def_access_cat_criteria_s_nssai_len,
2646 tvb, curr_offset, 1, ENC_BIG_ENDIAN, &s_nssai_len);
2647 curr_offset++;
2648 curr_offset += de_nas_5gs_cmn_s_nssai(tvb, sub_tree3, pinfo, curr_offset, s_nssai_len, NULL, 0);
2649 proto_item_set_len(item3, curr_offset - saved_offset3);
2650 }
2651 break;
2652 default:
2653 break;
2654 }
2655 proto_item_set_len(item2, curr_offset - saved_offset2);
2656 }
2657 if (psac) {
2658 /* 0 Spare 0 Spare 0 Spare Standardized access category */
2659 proto_tree_add_bits_item(sub_tree, hf_nas_5gs_spare_bits, tvb,
2660 (curr_offset << 3), 3, ENC_BIG_ENDIAN);
2661 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_op_def_access_cat_standardized_number,
2662 tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2663 }
2664 curr_offset = saved_offset + length;
2665 proto_item_set_len(item, length + 1);
2666 i++;
2667 }
2668
2669 return len;
2670 }
2671
2672 static const value_string nas_5gs_mm_pld_cont_opt_ie_type_vals[] = {
2673 { 0x12, "PDU session ID" },
2674 { 0x22, "S-NSSAI" },
2675 { 0x24, "Additional information" },
2676 { 0x25, "DNN" },
2677 { 0x37, "Back-off timer value" },
2678 { 0x58, "5GMM cause" },
2679 { 0x59, "Old PDU session ID" },
2680 { 0x80, "Request type" },
2681 { 0xa0, "MA PDU session information" },
2682 { 0xf0, "Release assistance indication" },
2683 { 0, NULL }
2684 };
2685
2686 /*
2687 * 9.11.3.39 Payload container
2688 */
2689 static guint16
2690 de_nas_5gs_mm_pld_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2691 guint32 offset, guint len,
2692 gchar *add_string _U_, int string_len _U_)
2693 {
2694 struct nas5gs_private_data *nas5gs_data = nas5gs_get_private_data(pinfo);
2695
2696 switch (nas5gs_data->payload_container_type) {
2697 case 1: /* N1 SM information */
2698 dissect_nas_5gs_common(tvb_new_subset_length(tvb, offset, len), pinfo, tree, 0, NULL);
2699 break;
2700 case 2: /* SMS */
2701 if (gsm_a_dtap_handle) {
2702 call_dissector(gsm_a_dtap_handle, tvb_new_subset_length(tvb, offset, len), pinfo, tree);
2703 } else {
2704 proto_tree_add_item(tree, hf_nas_5gs_mm_pld_cont, tvb, offset, len, ENC_NA);
2705 }
2706 break;
2707 case 3: /* LPP */
2708 if (lpp_handle) {
2709 call_dissector(lpp_handle, tvb_new_subset_length(tvb, offset, len), pinfo, tree);
2710 } else {
2711 proto_tree_add_item(tree, hf_nas_5gs_mm_pld_cont, tvb, offset, len, ENC_NA);
2712 }
2713 break;
2714 case 5: /* UE policy container */
2715 dissect_nas_5gs_updp(tvb_new_subset_length(tvb, offset, len), pinfo, tree, 0);
2716 break;
2717 case 8: /* CIoT user data container */
2718 nas_5gs_decode_user_data_cont(tvb, tree, pinfo, offset, len, hf_nas_5gs_mm_pld_cont);
2719 break;
2720 case 15: /* multiple payloads */
2721 {
2722 guint32 curr_offset, entry_offset, payloads_count, payload_len, opt_ies_count, payload_type;
2723 guint32 opt_ie_type, opt_ie_len, type_backup;
2724 guint i, j;
2725
2726 curr_offset = offset;
2727 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_mm_pld_cont_nb_entries, tvb, curr_offset, 1, ENC_NA, &payloads_count);
2728 curr_offset++;
2729 for (i = 0; i < payloads_count; i++) {
2730 proto_item *item;
2731 proto_tree *subtree, *subtree2;
2732
2733 entry_offset = curr_offset;
2734 subtree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_pld_cont_pld_entry, &item, "Payload container entry %d", i + 1);
2735 proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_pld_cont_len, tvb, curr_offset, 2, ENC_BIG_ENDIAN, &payload_len);
2736 proto_item_set_len(item, payload_len + 2);
2737 curr_offset += 2;
2738 proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_nb_opt_ies, tvb, curr_offset, 1, ENC_NA, &opt_ies_count);
2739 proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_pld_cont_type, tvb, curr_offset, 1, ENC_NA, &payload_type);
2740 curr_offset++;
2741 for (j = 0; j < opt_ies_count; j++) {
2742 item = proto_tree_add_item_ret_uint(subtree, hf_nas_5gs_mm_pld_cont_opt_ie_type, tvb, curr_offset, 1, ENC_NA, &opt_ie_type);
2743 curr_offset++;
2744 subtree2 = proto_item_add_subtree(item, ett_nas_5gs_mm_pld_cont_opt_ie);
2745 proto_tree_add_item_ret_uint(subtree2, hf_nas_5gs_mm_pld_cont_opt_ie_len, tvb, curr_offset, 1, ENC_NA, &opt_ie_len);
2746 curr_offset++;
2747 switch (opt_ie_type) {
2748 case 0x12:
2749 de_nas_5gs_mm_pdu_ses_id_2(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2750 break;
2751 case 0x22:
2752 de_nas_5gs_cmn_s_nssai(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2753 break;
2754 case 0x24:
2755 de_nas_5gs_cmn_add_inf(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2756 break;
2757 case 0x25:
2758 de_nas_5gs_cmn_dnn(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2759 break;
2760 case 0x37:
2761 de_gc_timer3(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2762 break;
2763 case 0x58:
2764 nas_5gs_mm_5gmm_status(tvb, subtree2, pinfo, curr_offset, opt_ie_len);
2765 break;
2766 case 0x59:
2767 de_nas_5gs_mm_pdu_ses_id_2(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2768 break;
2769 case 0x80:
2770 de_nas_5gs_mm_req_type(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2771 break;
2772 case 0xa0:
2773 de_nas_5gs_mm_ma_pdu_ses_inf(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2774 break;
2775 case 0xf0:
2776 de_esm_rel_assist_ind(tvb, subtree2, pinfo, curr_offset, opt_ie_len, NULL, 0);
2777 break;
2778 default:
2779 proto_tree_add_item(subtree2, hf_nas_5gs_mm_pld_cont_opt_ie_val, tvb, curr_offset, opt_ie_len, ENC_NA);
2780 break;
2781 }
2782 curr_offset += opt_ie_len;
2783 }
2784 type_backup = nas5gs_data->payload_container_type;
2785 nas5gs_data->payload_container_type = payload_type;
2786 /* N.B. this recursive call can overwrite nas5gs_data->payload_container_type */
2787 de_nas_5gs_mm_pld_cont(tvb, subtree, pinfo, curr_offset, payload_len - (curr_offset - entry_offset), NULL, 0);
2788 curr_offset = entry_offset + payload_len + 2;
2789 nas5gs_data->payload_container_type = type_backup;
2790 }
2791 }
2792 break;
2793 default:
2794 proto_tree_add_item(tree, hf_nas_5gs_mm_pld_cont, tvb, offset, len, ENC_NA);
2795 break;
2796 }
2797
2798 return len;
2799 }
2800
2801 /*
2802 * 9.11.3.40 Payload container type
2803 */
2804 static const value_string nas_5gs_mm_pld_cont_type_vals[] = {
2805 { 0x01, "N1 SM information" },
2806 { 0x02, "SMS" },
2807 { 0x03, "LTE Positioning Protocol (LPP) message container" },
2808 { 0x04, "SOR transparent container" },
2809 { 0x05, "UE policy container" },
2810 { 0x06, "UE parameters update transparent container" },
2811 { 0x07, "Location services message container" },
2812 { 0x08, "CIoT user data container" },
2813 { 0x0f, "Multiple payloads" },
2814 { 0, NULL } };
2815
2816 static guint16
2817 de_nas_5gs_mm_pld_cont_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2818 guint32 offset, guint len _U_,
2819 gchar *add_string _U_, int string_len _U_)
2820 {
2821 struct nas5gs_private_data *nas5gs_data = nas5gs_get_private_data(pinfo);
2822
2823 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_mm_pld_cont_type, tvb, offset, 1, ENC_BIG_ENDIAN, &nas5gs_data->payload_container_type);
2824
2825 return 1;
2826 }
2827
2828 /*
2829 * 9.11.3.41 PDU session identity 2
2830 */
2831 static guint16
2832 de_nas_5gs_mm_pdu_ses_id_2(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2833 guint32 offset, guint len _U_,
2834 gchar *add_string _U_, int string_len _U_)
2835 {
2836 proto_tree_add_item(tree, hf_nas_5gs_pdu_session_id, tvb, offset, 1, ENC_BIG_ENDIAN);
2837
2838 return 1;
2839 }
2840
2841 /*
2842 * 9.11.3.42 PDU session reactivation result
2843 */
2844
2845
2846 static true_false_string tfs_nas_5gs_pdu_ses_rect_res_psi = {
2847 "1",
2848 "0"
2849 };
2850
2851 static guint16
2852 de_nas_5gs_mm_pdu_ses_react_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2853 guint32 offset, guint len,
2854 gchar *add_string _U_, int string_len _U_)
2855 {
2856 int curr_offset;
2857
2858 static int * const psi_0_7_flags[] = {
2859 &hf_nas_5gs_pdu_ses_rect_res_psi_7_b7,
2860 &hf_nas_5gs_pdu_ses_rect_res_psi_6_b6,
2861 &hf_nas_5gs_pdu_ses_rect_res_psi_5_b5,
2862 &hf_nas_5gs_pdu_ses_rect_res_psi_4_b4,
2863 &hf_nas_5gs_pdu_ses_rect_res_psi_3_b3,
2864 &hf_nas_5gs_pdu_ses_rect_res_psi_2_b2,
2865 &hf_nas_5gs_pdu_ses_rect_res_psi_1_b1,
2866 &hf_nas_5gs_pdu_ses_rect_res_psi_0_b0,
2867 NULL
2868 };
2869
2870 static int * const psi_8_15_flags[] = {
2871 &hf_nas_5gs_pdu_ses_rect_res_psi_15_b7,
2872 &hf_nas_5gs_pdu_ses_rect_res_psi_14_b6,
2873 &hf_nas_5gs_pdu_ses_rect_res_psi_13_b5,
2874 &hf_nas_5gs_pdu_ses_rect_res_psi_12_b4,
2875 &hf_nas_5gs_pdu_ses_rect_res_psi_11_b3,
2876 &hf_nas_5gs_pdu_ses_rect_res_psi_10_b2,
2877 &hf_nas_5gs_pdu_ses_rect_res_psi_9_b1,
2878 &hf_nas_5gs_pdu_ses_rect_res_psi_8_b0,
2879 NULL
2880 };
2881
2882 curr_offset = offset;
2883 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_0_7_flags, ENC_BIG_ENDIAN);
2884 curr_offset++;
2885
2886 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_8_15_flags, ENC_BIG_ENDIAN);
2887 curr_offset++;
2888
2889 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
2890
2891 return (curr_offset - offset);
2892
2893 }
2894
2895 /*
2896 * 9.11.3.43 PDU session reactivation result error cause
2897 */
2898 static guint16
2899 de_nas_5gs_mm_pdu_ses_react_res_err_c(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2900 guint32 offset, guint len,
2901 gchar *add_string _U_, int string_len _U_)
2902 {
2903 guint32 curr_offset = offset;
2904
2905 /*Partial service area list*/
2906 while ((curr_offset - offset) < len) {
2907 proto_tree_add_item(tree, hf_nas_5gs_pdu_session_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2908 curr_offset++;
2909 proto_tree_add_item(tree, hf_nas_5gs_mm_5gmm_cause, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2910 curr_offset++;
2911 }
2912
2913 return len;
2914 }
2915
2916 /*
2917 * 9.11.3.44 PDU session status
2918 */
2919
2920 static true_false_string tfs_nas_5gs_pdu_ses_sts_psi = {
2921 "Not PDU SESSION INACTIVE",
2922 "PDU SESSION INACTIVE"
2923 };
2924
2925 static guint16
2926 de_nas_5gs_mm_pdu_ses_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
2927 guint32 offset, guint len,
2928 gchar *add_string _U_, int string_len _U_)
2929 {
2930 int curr_offset;
2931
2932 static int * const psi_0_7_flags[] = {
2933 &hf_nas_5gs_pdu_ses_sts_psi_7_b7,
2934 &hf_nas_5gs_pdu_ses_sts_psi_6_b6,
2935 &hf_nas_5gs_pdu_ses_sts_psi_5_b5,
2936 &hf_nas_5gs_pdu_ses_sts_psi_4_b4,
2937 &hf_nas_5gs_pdu_ses_sts_psi_3_b3,
2938 &hf_nas_5gs_pdu_ses_sts_psi_2_b2,
2939 &hf_nas_5gs_pdu_ses_sts_psi_1_b1,
2940 &hf_nas_5gs_pdu_ses_sts_psi_0_b0,
2941 NULL
2942 };
2943
2944 static int * const psi_8_15_flags[] = {
2945 &hf_nas_5gs_pdu_ses_sts_psi_15_b7,
2946 &hf_nas_5gs_pdu_ses_sts_psi_14_b6,
2947 &hf_nas_5gs_pdu_ses_sts_psi_13_b5,
2948 &hf_nas_5gs_pdu_ses_sts_psi_12_b4,
2949 &hf_nas_5gs_pdu_ses_sts_psi_11_b3,
2950 &hf_nas_5gs_pdu_ses_sts_psi_10_b2,
2951 &hf_nas_5gs_pdu_ses_sts_psi_9_b1,
2952 &hf_nas_5gs_pdu_ses_sts_psi_8_b0,
2953 NULL
2954 };
2955
2956 curr_offset = offset;
2957 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_0_7_flags, ENC_BIG_ENDIAN);
2958 curr_offset++;
2959
2960 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_8_15_flags, ENC_BIG_ENDIAN);
2961 curr_offset++;
2962
2963 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
2964
2965 return (curr_offset - offset);
2966
2967 }
2968
2969
2970 /*
2971 * 9.11.3.45 PLMN list
2972 */
2973 /* See subclause 10.5.1.13 in 3GPP TS 24.008 */
2974
2975 /*
2976 * 9.11.3.46 Rejected NSSAI
2977 */
2978 static const value_string nas_5gs_mm_rej_s_nssai_cause_vals[] = {
2979 { 0x00, "S-NSSAI not available in the current PLMN or SNPN" },
2980 { 0x01, "S-NSSAI not available in the current registration area" },
2981 { 0x02, "S-NSSAI not available due to the failed or revoked network slice-specific authentication and authorization" },
2982 { 0, NULL } };
2983
2984 static guint16
2985 de_nas_5gs_mm_rej_nssai(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
2986 guint32 offset, guint len,
2987 gchar *add_string _U_, int string_len _U_)
2988 {
2989 proto_tree* sub_tree;
2990 proto_item* item;
2991 guint num_items = 1;
2992 guint32 curr_offset = offset;
2993 guint32 start_offset, nssai_len;
2994
2995 /* Rejected NSSAI */
2996 while ((curr_offset - offset) < len) {
2997 start_offset = curr_offset;
2998 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_rej_nssai, &item, "Rejected S-NSSAI %u", num_items);
2999
3000 /* Length of rejected S-NSSAI Cause value */
3001 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_mm_len_of_rej_s_nssai, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &nssai_len);
3002 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_rej_s_nssai_cause, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3003 curr_offset++;
3004 /* SST */
3005 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_sst, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3006 curr_offset += 1;
3007 if (nssai_len > 1) {
3008 /* SD octet 3 - octet 5* */
3009 proto_tree_add_item(sub_tree, hf_nas_5gs_mm_sd, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
3010 curr_offset += 3;
3011 }
3012 proto_item_set_len(item, curr_offset - start_offset);
3013 }
3014
3015 return len;
3016 }
3017
3018 /*
3019 * 9.11.3.46A Release assistance indication
3020 */
3021 /* See subclause 9.9.4.25 in 3GPP TS 24.301 */
3022
3023 /*
3024 * 9.11.3.47 Request type
3025 */
3026 static const value_string nas_5gs_mm_req_type_vals[] = {
3027 { 0x01, "Initial request" },
3028 { 0x02, "Existing PDU session" },
3029 { 0x03, "Initial emergency request" },
3030 { 0x04, "Existing emergency PDU session" },
3031 { 0x05, "Modification request" },
3032 { 0x06, "MA PDU request" },
3033 { 0x07, "Reserved" },
3034 { 0, NULL } };
3035
3036 static guint16
3037 de_nas_5gs_mm_req_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
3038 guint32 offset, guint len _U_,
3039 gchar *add_string _U_, int string_len _U_)
3040 {
3041
3042 proto_tree_add_item(tree, hf_nas_5gs_mm_req_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3043
3044 return 1;
3045 }
3046
3047
3048 /*
3049 * 9.11.3.48 S1 UE network capability
3050 */
3051 /* See subclause 9.9.3.34 in 3GPP TS 24.301 */
3052
3053 /*
3054 * 9.11.3.48A S1 UE security capability
3055 */
3056 /*See subclause 9.9.3.36 in 3GPP TS 24.301 */
3057
3058 /*
3059 * 9.11.3.49 Service area list
3060 */
3061 static true_false_string tfs_nas_5gs_sal_al_t = {
3062 "TAIs in the list are in the non-allowed area",
3063 "TAIs in the list are in the allowed area"
3064 };
3065
3066 static const value_string nas_5gs_mm_sal_t_li_values[] = {
3067 { 0x00, "list of TACs belonging to one PLMN, with non-consecutive TAC values" },
3068 { 0x01, "list of TACs belonging to one PLMN, with consecutive TAC values" },
3069 { 0x02, "list of TAIs belonging to different PLMNs" },
3070 { 0x03, "All TAIs belonging to the PLMN are in the allowed area" },
3071 { 0, NULL } };
3072
3073 static const value_string nas_5gs_mm_sal_num_e_vals[] = {
3074 { 0x00, "1" },
3075 { 0x01, "2" },
3076 { 0x02, "3" },
3077 { 0x03, "4" },
3078 { 0x04, "5" },
3079 { 0x05, "6" },
3080 { 0x06, "7" },
3081 { 0x07, "8" },
3082 { 0x08, "9" },
3083 { 0x09, "10" },
3084 { 0x0a, "11" },
3085 { 0x0b, "12" },
3086 { 0x0c, "13" },
3087 { 0x0d, "14" },
3088 { 0x0e, "15" },
3089 { 0x0f, "16" },
3090 { 0, NULL } };
3091
3092
3093
3094 static guint16
3095 de_nas_5gs_mm_sal(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
3096 guint32 offset, guint len,
3097 gchar *add_string _U_, int string_len _U_)
3098 {
3099 proto_tree *sub_tree;
3100 proto_item *item;
3101
3102 static int * const flags_sal[] = {
3103 &hf_nas_5gs_mm_sal_al_t,
3104 &hf_nas_5gs_mm_sal_t_li,
3105 &hf_nas_5gs_mm_sal_num_e,
3106 NULL
3107 };
3108
3109 guint num_par_sal = 1;
3110 guint32 curr_offset = offset;
3111 guint32 start_offset;
3112 guint8 sal_head, sal_t_li, sal_num_e;
3113
3114 /*Partial service area list*/
3115 while ((curr_offset - offset) < len) {
3116 start_offset = curr_offset;
3117 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_part_sal, &item, "Partial service area list %u", num_par_sal);
3118 /*Head of Partial service area list*/
3119 /* Allowed type Type of list Number of elements octet 1 */
3120 sal_head = tvb_get_guint8(tvb, curr_offset);
3121 sal_t_li = (sal_head & 0x60) >> 5;
3122 sal_num_e = (sal_head & 0x1f) + 1;
3123 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, flags_sal, ENC_BIG_ENDIAN);
3124 curr_offset++;
3125 switch (sal_t_li) {
3126 case 0:
3127 /*octet 2 MCC digit2 MCC digit1*/
3128 /*octet 3 MNC digit3 MCC digit3*/
3129 /*octet 4 MNC digit2 MNC digit1*/
3130 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
3131 curr_offset += 3;
3132 while (sal_num_e > 0) {
3133 proto_tree_add_item(sub_tree, hf_nas_5gs_tac, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
3134 curr_offset += 3;
3135 sal_num_e--;
3136 }
3137 break;
3138 case 1:
3139 /*octet 2 MCC digit2 MCC digit1*/
3140 /*octet 3 MNC digit3 MCC digit3*/
3141 /*octet 4 MNC digit2 MNC digit1*/
3142 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
3143 curr_offset += 3;
3144
3145 /*octet 5 TAC 1*/
3146 proto_tree_add_item(sub_tree, hf_nas_5gs_tac, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
3147 curr_offset+=3;
3148 break;
3149 case 2:
3150 while (sal_num_e > 0) {
3151 /*octet 2 MCC digit2 MCC digit1*/
3152 /*octet 3 MNC digit3 MCC digit3*/
3153 /*octet 4 MNC digit2 MNC digit1*/
3154 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
3155 curr_offset += 3;
3156
3157 /*octet 5 TAC 1*/
3158 proto_tree_add_item(sub_tree, hf_nas_5gs_tac, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
3159 curr_offset += 3;
3160
3161 sal_num_e--;
3162 }
3163 break;
3164 case 3:
3165 dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_5GSTAI, TRUE);
3166 curr_offset += 3;
3167 break;
3168 default:
3169 proto_tree_add_expert(sub_tree, pinfo, &ei_nas_5gs_unknown_value, tvb, curr_offset, len - 1);
3170 }
3171
3172
3173
3174 /*calculate the length of IE?*/
3175 proto_item_set_len(item, curr_offset - start_offset);
3176 /*calculate the number of Partial service area list*/
3177 num_par_sal++;
3178 }
3179
3180 return len;
3181 }
3182
3183
3184 /*
3185 * 9.11.3.50 Service type
3186 */
3187
3188 /* Used inline as H1 (Upper nibble)*/
3189 static const value_string nas_5gs_mm_serv_type_vals[] = {
3190 { 0x00, "Signalling" },
3191 { 0x01, "Data" },
3192 { 0x02, "Mobile terminated services" },
3193 { 0x03, "Emergency services" },
3194 { 0x04, "Emergency services fallback" },
3195 { 0x05, "High priority access" },
3196 { 0x06, "Elevated signalling" },
3197 { 0, NULL }
3198 };
3199
3200 static guint16
3201 de_nas_5gs_mm_serv_type(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3202 guint32 offset, guint len,
3203 gchar* add_string _U_, int string_len _U_)
3204 {
3205
3206 proto_tree_add_item(tree, hf_nas_5gs_mm_serv_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3207
3208 return len;
3209 }
3210
3211 /*
3212 * 9.11.3.50A SMS indication
3213 */
3214 static guint16
3215 de_nas_5gs_mm_sms_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
3216 guint32 offset, guint len,
3217 gchar *add_string _U_, int string_len _U_)
3218 {
3219
3220 static int * const flags[] = {
3221 &hf_nas_5gs_spare_b3,
3222 &hf_nas_5gs_spare_b2,
3223 &hf_nas_5gs_spare_b1,
3224 &hf_nas_5gs_mm_sms_indic_sai,
3225 NULL
3226 };
3227
3228 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3229
3230 return len;
3231 }
3232
3233 /*
3234 * 9.11.3.51 SOR transparent container
3235 */
3236 static true_false_string tfs_nas_5gs_list_type = {
3237 "PLMN ID and access technology list",
3238 "Secured packet"
3239 };
3240
3241 static true_false_string tfs_nas_5gs_list_ind = {
3242 "List of preferred PLMN/access technology combinations is provided",
3243 "No list of preferred PLMN/access technology combinations is provided"
3244 };
3245
3246 static true_false_string tfs_nas_5gs_sor_data_type = {
3247 "Carries acknowledgement of successful reception of the steering of roaming information",
3248 "Carries steering of roaming information"
3249 };
3250
3251 static guint16
3252 de_nas_5gs_mm_sor_transp_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
3253 guint32 offset, guint len,
3254 gchar *add_string _U_, int string_len _U_)
3255 {
3256 /* Layout differs depending on SOR data type*/
3257 static int * const flags_dt0[] = {
3258 &hf_nas_5gs_spare_b7,
3259 &hf_nas_5gs_spare_b6,
3260 &hf_nas_5gs_spare_b5,
3261 &hf_nas_5gs_spare_b4,
3262 &hf_nas_5gs_sor_hdr0_ack,
3263 &hf_nas_5gs_sor_hdr0_list_type,
3264 &hf_nas_5gs_sor_hdr0_list_ind,
3265 &hf_nas_5gs_sor_hdr0_sor_data_type,
3266 NULL
3267 };
3268
3269 static int * const flags_dt1[] = {
3270 &hf_nas_5gs_spare_b7,
3271 &hf_nas_5gs_spare_b6,
3272 &hf_nas_5gs_spare_b5,
3273 &hf_nas_5gs_spare_b4,
3274 &hf_nas_5gs_spare_b3,
3275 &hf_nas_5gs_spare_b2,
3276 &hf_nas_5gs_spare_b1,
3277 &hf_nas_5gs_sor_hdr0_sor_data_type,
3278 NULL
3279 };
3280 /* 3GPP TS 31.102 [22] subclause 4.2.5 */
3281 static int * const flags_access_tech_1[] = {
3282 &hf_nas_5gs_access_tech_o1_b7,
3283 &hf_nas_5gs_access_tech_o1_b6,
3284 &hf_nas_5gs_access_tech_o1_b5,
3285 &hf_nas_5gs_access_tech_o1_b4,
3286 &hf_nas_5gs_access_tech_o1_b3,
3287 &hf_nas_5gs_rfu_b2,
3288 &hf_nas_5gs_rfu_b1,
3289 &hf_nas_5gs_rfu_b0,
3290 NULL
3291 };
3292
3293 static int * const flags_access_tech_2[] = {
3294 &hf_nas_5gs_access_tech_o2_b7,
3295 &hf_nas_5gs_access_tech_o2_b6,
3296 &hf_nas_5gs_access_tech_o2_b5,
3297 &hf_nas_5gs_access_tech_o2_b4,
3298 &hf_nas_5gs_access_tech_o2_b3,
3299 &hf_nas_5gs_access_tech_o2_b2,
3300 &hf_nas_5gs_rfu_b1,
3301 &hf_nas_5gs_rfu_b0,
3302 NULL
3303 };
3304
3305 proto_tree *sub_tree;
3306
3307 guint8 oct, data_type, list_type;
3308 guint32 curr_offset = offset;
3309 int i = 1;
3310
3311 oct = tvb_get_guint8(tvb, offset);
3312 data_type = oct & 0x01;
3313 if (data_type == 0) {
3314 /* SOR header octet 4*/
3315 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags_dt0, ENC_BIG_ENDIAN);
3316 curr_offset++;
3317 list_type = (oct & 0x4) >> 2;
3318 /* SOR-MAC-IAUSF octet 5-20 */
3319 proto_tree_add_item(tree, hf_nas_5gs_sor_mac_iausf, tvb, curr_offset, 16, ENC_NA);
3320 curr_offset += 16;
3321 /* CounterSOR octet 21-22 */
3322 proto_tree_add_item(tree, hf_nas_5gs_counter_sor, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
3323 curr_offset += 2;
3324 if (list_type == 0) {
3325 /* Secured packet octet 23* - 2048* */
3326 proto_tree_add_item(tree, hf_nas_5gs_sor_sec_pkt, tvb, curr_offset, len - 19, ENC_NA);
3327 curr_offset = curr_offset + (len - 19);
3328 } else {
3329 /* PLMN ID and access technology list octet 23*-102* */
3330 while ((curr_offset - offset) < len) {
3331 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_sor, NULL, "List item %u", i);
3332 /* The PLMN ID and access technology list consists of PLMN ID and access technology identifier
3333 * and are coded as specified in 3GPP TS 31.102 [22] subclause 4.2.5
3334 * PLMN
3335 * Contents:
3336 * - Mobile Country Code (MCC) followed by the Mobile Network Code (MNC).
3337 * Coding:
3338 * - according to TS 24.008 [9].
3339 */
3340 /* PLMN ID 1 octet 23*- 25* */
3341 curr_offset = dissect_e212_mcc_mnc(tvb, pinfo, sub_tree, curr_offset, E212_NONE, TRUE);
3342 /* access technology identifier 1 octet 26*- 27* */
3343 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags_access_tech_1, ENC_BIG_ENDIAN);
3344 curr_offset++;
3345 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags_access_tech_2, ENC_BIG_ENDIAN);
3346 curr_offset++;
3347 i++;
3348 }
3349 }
3350
3351 } else {
3352 /* SOR header octet 4*/
3353 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags_dt1, ENC_BIG_ENDIAN);
3354 curr_offset++;
3355 /* SOR-MAC-IUE octet 5 - 20*/
3356 proto_tree_add_item(tree, hf_nas_5gs_sor_mac_iue, tvb, curr_offset, 16, ENC_NA);
3357 curr_offset+=16;
3358 }
3359
3360 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
3361
3362 return (curr_offset - offset);
3363
3364 }
3365
3366 /*
3367 * 9.11.3.52 Time zone
3368 */
3369 /* See subclause 10.5.3.8 in 3GPP TS 24.008 */
3370
3371 /*
3372 * 9.11.3.53 Time zone and time
3373 */
3374 /* See subclause 10.5.3.9 in 3GPP TS 24.00 */
3375
3376 /*
3377 * 9.11.3.53A UE parameters update transparent container
3378 */
3379 static guint16
3380 de_nas_5gs_mm_ue_par_upd_trasnsp_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
3381 guint32 offset, guint len,
3382 gchar *add_string _U_, int string_len _U_)
3383 {
3384 proto_tree_add_expert(tree, pinfo, &ei_nas_5gs_ie_not_dis, tvb, offset, len);
3385
3386 return len;
3387 }
3388
3389
3390 /*
3391 * 9.11.3.54 UE security capability
3392 */
3393
3394 static guint16
3395 de_nas_5gs_mm_ue_sec_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
3396 guint32 offset, guint len,
3397 gchar *add_string _U_, int string_len _U_)
3398 {
3399 guint32 curr_offset;
3400
3401 static int * const oct3_flags[] = {
3402 &hf_nas_5gs_mm_5g_ea0,
3403 &hf_nas_5gs_mm_128_5g_ea1,
3404 &hf_nas_5gs_mm_128_5g_ea2,
3405 &hf_nas_5gs_mm_128_5g_ea3,
3406 &hf_nas_5gs_mm_5g_ea4,
3407 &hf_nas_5gs_mm_5g_ea5,
3408 &hf_nas_5gs_mm_5g_ea6,
3409 &hf_nas_5gs_mm_5g_ea7,
3410 NULL
3411 };
3412
3413 static int * const oct4_flags[] = {
3414 &hf_nas_5gs_mm_5g_ia0,
3415 &hf_nas_5gs_mm_5g_128_ia1,
3416 &hf_nas_5gs_mm_5g_128_ia2,
3417 &hf_nas_5gs_mm_5g_128_ia3,
3418 &hf_nas_5gs_mm_5g_ia4,
3419 &hf_nas_5gs_mm_5g_ia5,
3420 &hf_nas_5gs_mm_5g_ia6,
3421 &hf_nas_5gs_mm_5g_ia7,
3422 NULL
3423 };
3424
3425 static int * const oct5_flags[] = {
3426 &hf_nas_5gs_mm_eea0,
3427 &hf_nas_5gs_mm_128eea1,
3428 &hf_nas_5gs_mm_128eea2,
3429 &hf_nas_5gs_mm_eea3,
3430 &hf_nas_5gs_mm_eea4,
3431 &hf_nas_5gs_mm_eea5,
3432 &hf_nas_5gs_mm_eea6,
3433 &hf_nas_5gs_mm_eea7,
3434 NULL
3435 };
3436
3437 static int * const oct6_flags[] = {
3438 &hf_nas_5gs_mm_eia0,
3439 &hf_nas_5gs_mm_128eia1,
3440 &hf_nas_5gs_mm_128eia2,
3441 &hf_nas_5gs_mm_eia3,
3442 &hf_nas_5gs_mm_eia4,
3443 &hf_nas_5gs_mm_eia5,
3444 &hf_nas_5gs_mm_eia6,
3445 &hf_nas_5gs_mm_eia7,
3446 NULL
3447 };
3448
3449 curr_offset = offset;
3450
3451
3452 /* 5G-EA0 128-5G-EA1 128-5G-EA2 128-5G-EA3 5G-EA4 5G-EA5 5G-EA6 5G-EA7 octet 3 */
3453 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, oct3_flags, ENC_NA);
3454 curr_offset++;
3455
3456 /* 5G-IA0 128-5G-IA1 128-5G-IA2 128-5G-IA3 5G-IA4 5G-IA5 5G-IA6 5G-IA7 octet 4 */
3457 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, oct4_flags, ENC_NA);
3458 curr_offset++;
3459
3460 if (len == 2) {
3461 return len;
3462 }
3463
3464 /* EEA0 128-EEA1 128-EEA2 128-EEA3 EEA4 EEA5 EEA6 EEA7 octet 5 */
3465 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, oct5_flags, ENC_NA);
3466 curr_offset++;
3467
3468 /* EIA0 128-EIA1 128-EIA2 128-EIA3 EIA4 EIA5 EIA6 EIA7 octet 6 */
3469 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, oct6_flags, ENC_NA);
3470
3471
3472 return len;
3473 }
3474
3475 /*
3476 * 9.11.3.55 UE's usage setting
3477 */
3478 static true_false_string tfs_nas_5gs_mm_ue_usage_setting = {
3479 "Data centric",
3480 "Voice centric"
3481 };
3482
3483 static guint16
3484 de_nas_5gs_mm_ue_usage_set(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
3485 guint32 offset, guint len,
3486 gchar *add_string _U_, int string_len _U_)
3487 {
3488 static int * const flags[] = {
3489 &hf_nas_5gs_spare_b3,
3490 &hf_nas_5gs_spare_b2,
3491 &hf_nas_5gs_spare_b1,
3492 &hf_nas_5gs_mm_ue_usage_setting,
3493 NULL
3494 };
3495
3496 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3497
3498 return len;
3499 }
3500
3501 /*
3502 * 9.11.3.56 UE status
3503 */
3504
3505 static true_false_string tfs_nas_5gs_mm_n1_mod = {
3506 "UE is in 5GMM-REGISTERED state",
3507 "UE is not in 5GMM-REGISTERED state"
3508 };
3509
3510 static true_false_string tfs_nas_5gs_mm_s1_mod = {
3511 "UE is in EMM-REGISTERED state",
3512 "UE is not in EMM-REGISTERED state"
3513 };
3514
3515
3516
3517 static guint16
3518 de_nas_5gs_mm_ue_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
3519 guint32 offset, guint len _U_,
3520 gchar *add_string _U_, int string_len _U_)
3521 {
3522 static int * const flags[] = {
3523 &hf_nas_5gs_spare_b7,
3524 &hf_nas_5gs_spare_b6,
3525 &hf_nas_5gs_spare_b5,
3526 &hf_nas_5gs_spare_b4,
3527 &hf_nas_5gs_spare_b3,
3528 &hf_nas_5gs_spare_b2,
3529 &hf_nas_5gs_mm_n1_mode_reg_b1,
3530 &hf_nas_5gs_mm_s1_mode_reg_b0,
3531 NULL
3532 };
3533
3534 /* 0 Spare 0 Spare 0 Spare 0 Spare 0 Spare 0 Spare N1 mode S1 mode reg */
3535 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3536
3537 return 1;
3538 }
3539
3540 /*
3541 * 9.11.3.57 Uplink data status
3542 */
3543
3544 static true_false_string tfs_nas_5gs_ul_data_sts_psi = {
3545 "uplink data are pending",
3546 "no uplink data are pending"
3547 };
3548
3549 static guint16
3550 de_nas_5gs_mm_ul_data_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
3551 guint32 offset, guint len,
3552 gchar *add_string _U_, int string_len _U_)
3553 {
3554 int curr_offset;
3555
3556 static int * const psi_0_7_flags[] = {
3557 &hf_nas_5gs_ul_data_sts_psi_7_b7,
3558 &hf_nas_5gs_ul_data_sts_psi_6_b6,
3559 &hf_nas_5gs_ul_data_sts_psi_5_b5,
3560 &hf_nas_5gs_ul_data_sts_psi_4_b4,
3561 &hf_nas_5gs_ul_data_sts_psi_3_b3,
3562 &hf_nas_5gs_ul_data_sts_psi_2_b2,
3563 &hf_nas_5gs_ul_data_sts_psi_1_b1,
3564 &hf_nas_5gs_ul_data_sts_psi_0_b0,
3565 NULL
3566 };
3567
3568 static int * const psi_8_15_flags[] = {
3569 &hf_nas_5gs_ul_data_sts_psi_15_b7,
3570 &hf_nas_5gs_ul_data_sts_psi_14_b6,
3571 &hf_nas_5gs_ul_data_sts_psi_13_b5,
3572 &hf_nas_5gs_ul_data_sts_psi_12_b4,
3573 &hf_nas_5gs_ul_data_sts_psi_11_b3,
3574 &hf_nas_5gs_ul_data_sts_psi_10_b2,
3575 &hf_nas_5gs_ul_data_sts_psi_9_b1,
3576 &hf_nas_5gs_ul_data_sts_psi_8_b0,
3577 NULL
3578 };
3579
3580 curr_offset = offset;
3581 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_0_7_flags, ENC_BIG_ENDIAN);
3582 curr_offset++;
3583
3584 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, psi_8_15_flags, ENC_BIG_ENDIAN);
3585 curr_offset++;
3586
3587 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
3588
3589 return (curr_offset - offset);
3590 }
3591
3592 /*
3593 * 9.11.3.58 Void
3594 * 9.11.3.59 Void
3595 * 9.11.3.60 Void
3596 * 9.11.3.61 Void
3597 * 9.11.3.62 Void
3598 * 9.11.3.63 Void
3599 * 9.11.3.64 Void
3600 * 9.11.3.65 Void
3601 * 9.11.3.66 Void
3602 * 9.11.3.67 Void
3603 */
3604
3605 /*
3606 * 9.11.3.68 UE radio capability ID
3607 */
3608 /*
3609 * The UE radio capability ID contents contain the UE radio capability ID as specified in 3GPP TS 23.003
3610 * with each digit coded in BCD, starting with the first digit coded in bits 4 to 1 of octet 3,
3611 * the second digit coded in bits 8 to 5 of octet 3, and so on. If the UE radio capability ID contains
3612 * an odd number of digits, bits 8 to 5 of the last octet (octet n) shall be coded as "1111".
3613 */
3614
3615 guint16
3616 de_nas_5gs_mm_ue_radio_cap_id(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3617 guint32 offset, guint len,
3618 gchar* add_string _U_, int string_len _U_)
3619 {
3620 int curr_offset;
3621
3622 curr_offset = offset;
3623
3624 proto_tree_add_item(tree, hf_nas_5gs_mm_ue_radio_cap_id, tvb, curr_offset, len, ENC_BCD_DIGITS_0_9);
3625
3626 return len;
3627 }
3628
3629 /*
3630 * 9.11.3.69 UE radio capability ID deletion indication
3631 */
3632 static const value_string nas_5gs_mm_ue_radio_cap_id_del_req_vals[] = {
3633 { 0x0, "UE radio capability ID deletion not requested" },
3634 { 0x1, "Network-assigned UE radio capability IDs deletion requested" },
3635 { 0, NULL }
3636 };
3637
3638 static guint16
3639 de_nas_5gs_mm_ue_radio_cap_id_del_ind(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3640 guint32 offset, guint len,
3641 gchar* add_string _U_, int string_len _U_)
3642 {
3643 static int* const flags[] = {
3644 &hf_nas_5gs_spare_b3,
3645 &hf_nas_5gs_mm_ue_radio_cap_id_del_req,
3646 NULL
3647 };
3648
3649 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3650
3651 return len;
3652 }
3653
3654 /*
3655 * 9.11.3.70 Truncated 5G-S-TMSI configuration
3656 */
3657 static const value_string nas_5gs_mm_amf_trunc_set_id_vals[] = {
3658 { 0x0, "reserved" },
3659 { 0x1, "1 least significant bit of the AMF Set ID" },
3660 { 0x2, "2 least significant bit of the AMF Set ID" },
3661 { 0x3, "3 least significant bit of the AMF Set ID" },
3662 { 0x4, "4 least significant bit of the AMF Set ID" },
3663 { 0x5, "5 least significant bit of the AMF Set ID" },
3664 { 0x6, "6 least significant bit of the AMF Set ID" },
3665 { 0x7, "7 least significant bit of the AMF Set ID" },
3666 { 0x8, "8 least significant bit of the AMF Set ID" },
3667 { 0x9, "9 least significant bit of the AMF Set ID" },
3668 { 0xa, "10 least significant bit of the AMF Set ID" },
3669 { 0, NULL }
3670 };
3671
3672 static const value_string nas_5gs_mm_amf_trunc_pointer_vals[] = {
3673 { 0x0, "reserved" },
3674 { 0x1, "1 least significant bit of the AMF Pointer" },
3675 { 0x2, "2 least significant bit of the AMF Pointer" },
3676 { 0x3, "3 least significant bit of the AMF Pointer" },
3677 { 0x4, "4 least significant bit of the AMF Pointer" },
3678 { 0x5, "5 least significant bit of the AMF Pointer" },
3679 { 0x6, "6 least significant bit of the AMF Pointer" },
3680 { 0, NULL }
3681 };
3682
3683 static guint16
3684 de_nas_5gs_mm_truncated_5g_s_tmsi_conf(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3685 guint32 offset, guint len,
3686 gchar* add_string _U_, int string_len _U_)
3687 {
3688 proto_tree_add_item(tree, hf_nas_5gs_mm_trunc_amf_set_id, tvb, offset, 1, ENC_BIG_ENDIAN);
3689 proto_tree_add_item(tree, hf_nas_5gs_mm_trunc_amf_pointer, tvb, offset, 1, ENC_BIG_ENDIAN);
3690
3691 return len;
3692 }
3693
3694 /*
3695 * 9.11.3.71 WUS assistance information
3696 */
3697 /* See subclause 9.9.3.62 in 3GPP TS 24.301 */
3698
3699 /*
3700 * 9.11.3.72 N5GC indication
3701 */
3702 static guint16
3703 de_nas_5gs_mm_n5gc_indication(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3704 guint32 offset, guint len _U_,
3705 gchar* add_string _U_, int string_len _U_)
3706 {
3707 static int* const flags[] = {
3708 &hf_nas_5gs_spare_b3,
3709 &hf_nas_5gs_spare_b2,
3710 &hf_nas_5gs_spare_b1,
3711 &hf_nas_5gs_mm_n5gcreg_b0,
3712 NULL
3713 };
3714
3715 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3716
3717 return 1;
3718
3719 }
3720
3721 /*
3722 * 9.11.3.73 NB-N1 mode DRX parameters
3723 */
3724 static const value_string nas_5gs_mm_nb_n1_drx_params_vals[] = {
3725 { 0x0, "DRX value not specified"},
3726 { 0x1, "DRX cycle parameter T = 32"},
3727 { 0x2, "DRX cycle parameter T = 64"},
3728 { 0x3, "DRX cycle parameter T = 128"},
3729 { 0x4, "DRX cycle parameter T = 256"},
3730 { 0x5, "DRX cycle parameter T = 512"},
3731 { 0x7, "DRX cycle parameter T = 1024"},
3732 { 0, NULL }
3733 };
3734
3735 static guint16
3736 de_nas_5gs_mm_nb_n1_mode_drx_pars(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3737 guint32 offset, guint len _U_,
3738 gchar* add_string _U_, int string_len _U_)
3739 {
3740 proto_tree_add_bits_item(tree, hf_nas_5gs_spare_bits, tvb, offset << 3, 4, ENC_BIG_ENDIAN);
3741 proto_tree_add_item(tree, hf_nas_5gs_mm_nb_n1_drx_value, tvb, offset, 1, ENC_BIG_ENDIAN);
3742
3743 return 1;
3744 }
3745
3746 /*
3747 * 9.11.3.74 Additional configuration indication
3748 */
3749 static true_false_string tfs_nas_5gs_mm_scmr = {
3750 "release of N1 NAS signalling connection not required",
3751 "no additional information"
3752 };
3753
3754 static guint16
3755 de_nas_5gs_mm_additional_conf_ind(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3756 guint32 offset, guint len _U_,
3757 gchar* add_string _U_, int string_len _U_)
3758 {
3759 static int* const flags[] = {
3760 &hf_nas_5gs_spare_b3,
3761 &hf_nas_5gs_spare_b2,
3762 &hf_nas_5gs_spare_b1,
3763 &hf_nas_5gs_mm_scmr,
3764 NULL
3765 };
3766
3767 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3768
3769 return 1;
3770 }
3771
3772 /*
3773 * 9.11.3.75 Extended rejected NSSAI
3774 */
3775 static const value_string nas_5gs_mm_extended_rej_s_nssai_cause_vals[] = {
3776 { 0x00, "S-NSSAI not available in the current PLMN or SNPN" },
3777 { 0x01, "S-NSSAI not available in the current registration area" },
3778 { 0x02, "S-NSSAI not available due to the failed or revoked network slice-specific authentication and authorization" },
3779 { 0x03, "S-NSSAI not available due to maximum number of UEs reached" },
3780 { 0, NULL } };
3781
3782 static guint16
3783 de_nas_5gs_mm_extended_rejected_nssai(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
3784 guint32 offset, guint len,
3785 gchar* add_string _U_, int string_len _U_)
3786 {
3787 proto_tree* sub_partial_tree;
3788 proto_tree* sub_rejected_tree;
3789 proto_item* item;
3790 int i = 1;
3791 guint num_partial_items = 1;
3792 guint32 curr_offset = offset;
3793 guint32 type_of_list, number_of_element, nssai_len;
3794
3795 /* Rejected NSSAI */
3796 while ((curr_offset - offset) < len) {
3797 sub_partial_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_mm_partial_extended_rejected_nssai_list,
3798 &item, "Partial extended rejected NSSAI list %u", num_partial_items);
3799
3800 proto_tree_add_item(sub_partial_tree, hf_nas_5gs_mm_extended_rejected_s_nssai_spare, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3801 proto_tree_add_item_ret_uint(sub_partial_tree, hf_nas_5gs_mm_extended_rejected_s_nssai_type_of_list, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &type_of_list);
3802 proto_tree_add_item_ret_uint(sub_partial_tree, hf_nas_5gs_mm_extended_rejected_s_nssai_number_of_element, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &number_of_element);
3803 curr_offset++;
3804
3805 if (type_of_list > 0) {
3806 proto_tree_add_item(sub_partial_tree, hf_nas_5gs_mm_extended_rejected_s_nssai_back_off_timer, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3807 curr_offset++;
3808 }
3809
3810 for (i = 0; i < (int)number_of_element; i++)
3811 {
3812 sub_rejected_tree = proto_tree_add_subtree_format(sub_partial_tree, tvb, curr_offset, -1, ett_nas_5gs_mm_ext_rej_nssai,
3813 &item, "Rejected S-NSSAI %u", i+1);
3814
3815 /* Octet 3 and octet 4 shall always be included*/
3816 proto_tree_add_item_ret_uint(sub_rejected_tree, hf_nas_5gs_mm_len_of_rejected_s_nssai, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &nssai_len);
3817 proto_tree_add_item(sub_rejected_tree, hf_nas_5gs_mm_rejected_s_nssai_cause_value, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3818 proto_item_set_len(item, nssai_len);
3819 curr_offset++;
3820 proto_tree_add_item(sub_rejected_tree, hf_nas_5gs_mm_sst, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3821 curr_offset++;
3822 if (nssai_len < 3) {
3823 continue;
3824 }
3825 /* If the octet 5 is included, then octet 6 and octet 7 shall be included.*/
3826 proto_tree_add_item(sub_rejected_tree, hf_nas_5gs_mm_sd, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
3827 curr_offset += 3;
3828 if (nssai_len < 6) {
3829 continue;
3830 }
3831 /* If the octet 8 is included, then octets 9, 10, and 11 may be included*/
3832 /* Mapped HPLMN SST */
3833 proto_tree_add_item(sub_rejected_tree, hf_nas_5gs_mm_mapped_hplmn_sst, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
3834 curr_offset += 1;
3835 if (nssai_len < 7) {
3836 continue;
3837 }
3838 /* Mapped HPLMN SD */
3839 proto_tree_add_item(sub_rejected_tree, hf_nas_5gs_mm_mapped_hplmn_ssd, tvb, offset, 3, ENC_BIG_ENDIAN);
3840 curr_offset += 3;
3841 }
3842 num_partial_items++;
3843 }
3844 return len;
3845 }
3846
3847 /*
3848 * 9.11.4 5GS session management (5GSM) information elements
3849 */
3850
3851 /*
3852 * 9.11.4.1 5GSM capability
3853 */
3854 static const value_string nas_5gs_sm_atsss_st_b3_b6_vals[] = {
3855 { 0x0, "ATSSS not supported" },
3856 { 0x1, "ATSSS Low-Layer functionality with any steering mode supported" },
3857 { 0x2, "MPTCP functionality with any steering mode and ATSSS-LL functionality with only active-standby steering mode supported" },
3858 { 0x3, "MPTCP functionality with any steering mode and ATSSS-LL functionality with any steering mode supported" },
3859 { 0, NULL }
3860 };
3861
3862 static guint16
3863 de_nas_5gs_sm_5gsm_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
3864 guint32 offset, guint len,
3865 gchar *add_string _U_, int string_len _U_)
3866 {
3867 guint32 curr_offset = offset;
3868
3869 static int * const flags[] = {
3870 &hf_nas_5gs_sm_tpmic_b7,
3871 &hf_nas_5gs_sm_atsss_st_b3_b6,
3872 &hf_nas_5gs_sm_ept_s1_b2,
3873 &hf_nas_5gs_sm_mh6_pdu_b1,
3874 &hf_nas_5gs_sm_rqos_b0,
3875 NULL
3876 };
3877
3878 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags, ENC_BIG_ENDIAN);
3879 curr_offset++;
3880
3881 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
3882
3883 return (curr_offset - offset);
3884 }
3885
3886 /*
3887 * 9.11.4.2 5GSM cause
3888 */
3889
3890 const value_string nas_5gs_sm_cause_vals[] = {
3891 { 0x08, "Operator determined barring" },
3892 { 0x1a, "Insufficient resources" },
3893 { 0x1b, "Missing or unknown DNN" },
3894 { 0x1c, "Unknown PDU session type" },
3895 { 0x1d, "User authentication or authorization failed" },
3896 { 0x1f, "Request rejected, unspecified" },
3897 { 0x20, "Service option not supported" },
3898 { 0x21, "Requested service option not subscribed" },
3899 { 0x22, "Service option temporarily out of order" }, /* no more defined, kept for backward compatibility */
3900 { 0x23, "PTI already in use" },
3901 { 0x24, "Regular deactivation" },
3902 { 0x26, "Network failure" },
3903 { 0x27, "Reactivation requested" },
3904 { 0x29, "Semantic error in the TFT operation" },
3905 { 0x2a, "Syntactical error in the TFT operation" },
3906 { 0x2b, "Invalid PDU session identity" },
3907 { 0x2c, "Semantic errors in packet filter(s)" },
3908 { 0x2d, "Syntactical error in packet filter(s)" },
3909 { 0x2e, "Out of LADN service area" },
3910 { 0x2f, "PTI mismatch" },
3911 { 0x32, "PDU session type IPv4 only allowed" },
3912 { 0x33, "PDU session type IPv6 only allowed" },
3913 { 0x36, "PDU session does not exist" },
3914 { 0x39, "PDU session type IPv4v6 only allowed" },
3915 { 0x3a, "PDU session type Unstructured only allowed" },
3916 { 0x3b, "Unsupported 5QI value" },
3917 { 0x3d, "PDU session type Ethernet only allowed" },
3918 { 0x43, "Insufficient resources for specific slice and DNN" },
3919 { 0x44, "Not supported SSC mode" },
3920 { 0x45, "Insufficient resources for specific slice" },
3921 { 0x46, "Missing or unknown DNN in a slice" },
3922 { 0x51, "Invalid PTI value" },
3923 { 0x52, "Maximum data rate per UE for user-plane integrity protection is too low" },
3924 { 0x53, "Semantic error in the QoS operation" },
3925 { 0x54, "Syntactical error in the QoS operation" },
3926 { 0x55, "Invalid mapped EPS bearer identity" },
3927 { 0x5f, "Semantically incorrect message" },
3928 { 0x60, "Invalid mandatory information" },
3929 { 0x61, "Message type non-existent or not implemented" },
3930 { 0x62, "Message type not compatible with the protocol state" },
3931 { 0x63, "Information element non-existent or not implemented" },
3932 { 0x64, "Conditional IE error" },
3933 { 0x65, "Message not compatible with the protocol state" },
3934 { 0x6f, "Protocol error, unspecified" },
3935 { 0, NULL }
3936 };
3937
3938 static guint16
3939 de_nas_5gs_sm_5gsm_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
3940 guint32 offset, guint len _U_,
3941 gchar *add_string _U_, int string_len _U_)
3942 {
3943 guint32 cause;
3944
3945 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_sm_5gsm_cause, tvb, offset, 1, ENC_BIG_ENDIAN, &cause);
3946
3947 col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)",
3948 val_to_str_const(cause, nas_5gs_sm_cause_vals, "Unknown"));
3949
3950
3951 return 1;
3952 }
3953
3954 /*
3955 * 9.11.4.3 Always-on PDU session indication
3956 */
3957 static true_false_string tfs_nas_5gs_sm_apsi = {
3958 "required",
3959 "not allowed"
3960 };
3961
3962 static guint16
3963 de_nas_5gs_sm_always_on_pdu_ses_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
3964 guint32 offset, guint len,
3965 gchar *add_string _U_, int string_len _U_)
3966 {
3967 static int * const flags[] = {
3968 &hf_nas_5gs_spare_b3,
3969 &hf_nas_5gs_spare_b2,
3970 &hf_nas_5gs_spare_b1,
3971 &hf_nas_5gs_sm_apsi,
3972 NULL
3973 };
3974
3975 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3976
3977 return len;
3978 }
3979
3980 /*
3981 * 9.11.4.4 Always-on PDU session requested
3982 */
3983 static guint16
3984 de_nas_5gs_sm_always_on_pdu_ses_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
3985 guint32 offset, guint len,
3986 gchar *add_string _U_, int string_len _U_)
3987 {
3988 static int * const flags[] = {
3989 &hf_nas_5gs_spare_b3,
3990 &hf_nas_5gs_spare_b2,
3991 &hf_nas_5gs_spare_b1,
3992 &hf_nas_5gs_sm_apsr,
3993 NULL
3994 };
3995
3996 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
3997
3998 return len;
3999 }
4000
4001 /*
4002 * 9.11.4.5 Allowed SSC mode
4003 */
4004
4005 static guint16
4006 de_nas_5gs_sm_5gsm_allowed_ssc_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4007 guint32 offset, guint len _U_,
4008 gchar *add_string _U_, int string_len _U_)
4009 {
4010
4011 static int * const flags[] = {
4012 &hf_nas_5gs_spare_b3,
4013 &hf_nas_5gs_sm_all_ssc_mode_b2,
4014 &hf_nas_5gs_sm_all_ssc_mode_b1,
4015 &hf_nas_5gs_sm_all_ssc_mode_b0,
4016 NULL
4017 };
4018
4019
4020 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
4021
4022 return 1;
4023 }
4024
4025 /*
4026 * 9.11.4.6 Extended protocol configuration options
4027 */
4028 /* See subclause 10.5.6.3A in 3GPP TS 24.008 */
4029
4030 /*
4031 * 9.11.4.7 Integrity protection maximum data rate
4032 */
4033 static const value_string nas_5gs_sm_int_prot_max_data_rate_vals[] = {
4034 { 0x00, "64 kbps" },
4035 { 0x01, "NULL" },
4036 { 0xff, "Full data rate" },
4037 { 0, NULL }
4038 };
4039
4040 static guint16
4041 de_nas_5gs_sm_int_prot_max_data_rte(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4042 guint32 offset, guint len _U_,
4043 gchar *add_string _U_, int string_len _U_)
4044 {
4045 /* Maximum data rate per UE for user-plane integrity protection for uplink */
4046 proto_tree_add_item(tree, hf_nas_5gs_sm_int_prot_max_data_rate_ul, tvb, offset, 1, ENC_BIG_ENDIAN);
4047
4048 /* Maximum data rate per UE for user-plane integrity protection for downlink */
4049 proto_tree_add_item(tree, hf_nas_5gs_sm_int_prot_max_data_rate_dl, tvb, offset+1, 1, ENC_BIG_ENDIAN);
4050
4051 return 2;
4052 }
4053
4054 /*
4055 * 9.11.4.8 Mapped EPS bearer contexts
4056 */
4057 static const value_string nas_5gs_sm_mapd_eps_b_cont_opt_code_vals[] = {
4058 { 0x0, "Reserved" },
4059 { 0x01, "Create new EPS bearer" },
4060 { 0x02, "Delete existing EPS bearer" },
4061 { 0x03, "Modify existing EPS bearer" },
4062 { 0, NULL }
4063 };
4064
4065 static const value_string nas_5gs_sm_mapd_eps_b_cont_E_vals[] = {
4066 { 0x0, "parameters list is not included" },
4067 { 0x01, "parameters list is included" },
4068 { 0, NULL }
4069 };
4070
4071 static const value_string nas_5gs_sm_mapd_eps_b_cont_E_Modify_vals[] = {
4072 { 0x0, "extension of previously provided parameters list" },
4073 { 0x01, "replacement of all previously provided parameters list" },
4074 { 0, NULL }
4075 };
4076
4077 static const value_string nas_5gs_sm_mapd_eps_b_cont_param_id_vals[] = {
4078 { 0x01, "Mapped EPS QoS parameters" },
4079 { 0x02, "Mapped extended EPS QoS parameters" },
4080 { 0x03, "Traffic flow template" },
4081 { 0x04, "APN-AMBR" },
4082 { 0x05, "Extended APN-AMBR" },
4083 { 0, NULL }
4084 };
4085
4086 static guint16
4087 de_nas_5gs_sm_mapped_eps_b_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
4088 guint32 offset, guint len,
4089 gchar *add_string _U_, int string_len _U_)
4090 {
4091
4092 guint32 curr_offset;
4093 proto_tree * sub_tree, *sub_tree1;
4094 guint32 num_cont, length, opt_code, num_eps_parms, param_id;
4095 proto_item * item;
4096 guint i, curr_len;
4097
4098 curr_len = len;
4099 curr_offset = offset;
4100 num_cont = 1;
4101
4102 static int * const mapd_eps_b_cont_flags[] = {
4103 &hf_nas_5gs_sm_mapd_eps_b_cont_opt_code,
4104 &hf_nas_5gs_spare_b5,
4105 &hf_nas_5gs_sm_mapd_eps_b_cont_E,
4106 &hf_nas_5gs_sm_mapd_eps_b_cont_num_eps_parms,
4107 NULL
4108 };
4109
4110 static int * const mapd_eps_b_cont_flags_modify[] = {
4111 &hf_nas_5gs_sm_mapd_eps_b_cont_opt_code,
4112 &hf_nas_5gs_spare_b5,
4113 &hf_nas_5gs_sm_mapd_eps_b_cont_E_mod,
4114 &hf_nas_5gs_sm_mapd_eps_b_cont_num_eps_parms,
4115 NULL
4116 };
4117
4118 /* The IE contains a number of Mapped EPS bearer context */
4119 while ((curr_offset - offset) < len) {
4120 /* Figure 9.11.4.5.2: Mapped EPS bearer context */
4121 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_sm_mapd_eps_b_cont, &item,
4122 "Mapped EPS bearer context %u", num_cont);
4123
4124 /* EPS bearer identity */
4125 proto_tree_add_item(sub_tree, hf_nas_5gs_sm_mapd_eps_b_cont_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4126 curr_offset++;
4127 curr_len--;
4128
4129 /* Length of Mapped EPS bearer context*/
4130 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_sm_length, tvb, curr_offset, 2, ENC_BIG_ENDIAN, &length);
4131 curr_offset += 2;
4132 curr_len -= 2;
4133
4134 /* 8 7 6 5 4 3 2 1 */
4135 /* operation code | spare | E | number of EPS params */
4136 proto_item_set_len(item, length + 3);
4137
4138 num_eps_parms = tvb_get_guint8(tvb, curr_offset);
4139
4140 opt_code = (num_eps_parms & 0xc0) >> 6;
4141 num_eps_parms = num_eps_parms & 0x0f;
4142
4143 /* operation code = 3 Modify existing EPS bearer */
4144 if (opt_code == 3) {
4145 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, mapd_eps_b_cont_flags_modify, ENC_BIG_ENDIAN);
4146
4147 } else {
4148 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, mapd_eps_b_cont_flags, ENC_BIG_ENDIAN);
4149
4150 }
4151 curr_offset++;
4152 curr_len--;
4153 i = 1;
4154
4155 /* EPS parameters list */
4156 while (num_eps_parms > 0) {
4157
4158 sub_tree1 = proto_tree_add_subtree_format(sub_tree, tvb, curr_offset, -1, ett_nas_5gs_sm_mapd_eps_b_cont_params_list, &item,
4159 "EPS parameter %u", i);
4160
4161 /* EPS parameter identifier */
4162 proto_tree_add_item_ret_uint(sub_tree1, hf_nas_5gs_sm_mapd_eps_b_cont_param_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN, ¶m_id);
4163 proto_item_append_text(item, " - %s", val_to_str_const(param_id, nas_5gs_sm_mapd_eps_b_cont_param_id_vals, "Unknown"));
4164 curr_offset++;
4165 curr_len--;
4166
4167 /*length of the EPS parameter contents field */
4168 proto_tree_add_item_ret_uint(sub_tree1, hf_nas_5gs_sm_length, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &length);
4169 curr_offset++;
4170 curr_len--;
4171
4172 proto_item_set_len(item, length + 2);
4173 /*content of the EPS parameter contents field */
4174 switch (param_id) {
4175 case 1:
4176 /* 01H (Mapped EPS QoS parameters) */
4177 de_esm_qos(tvb, sub_tree1, pinfo, curr_offset, length, NULL, 0);
4178 break;
4179 case 2:
4180 /* 02H (Mapped extended EPS QoS parameters) */
4181 de_esm_ext_eps_qos(tvb, sub_tree1, pinfo, curr_offset, length, NULL, 0);
4182 break;
4183 case 3:
4184 /* 03H (Traffic flow template)*/
4185 de_sm_tflow_temp(tvb, sub_tree1, pinfo, curr_offset, length, NULL, 0);
4186 break;
4187 case 4:
4188 /* 04H (APN-AMBR) */
4189 de_esm_apn_aggr_max_br(tvb, sub_tree1, pinfo, curr_offset, length, NULL, 0);
4190 break;
4191 case 5:
4192 /* 05H (extended APN-AMBR). */
4193 de_esm_ext_apn_agr_max_br(tvb, sub_tree1, pinfo, curr_offset, length, NULL, 0);
4194 break;
4195 default:
4196 proto_tree_add_item(sub_tree1, hf_nas_5gs_sm_mapd_eps_b_cont_eps_param_cont, tvb, curr_offset, length, ENC_NA);
4197 break;
4198 }
4199 curr_offset +=length;
4200 curr_len -= length;
4201 i++;
4202 num_eps_parms--;
4203 }
4204
4205 num_cont++;
4206 }
4207
4208 return len;
4209
4210
4211 }
4212
4213 /*
4214 * 9.11.4.9 Maximum number of supported packet filters
4215 */
4216 static guint16
4217 de_nas_5gs_sm_max_num_sup_pkt_flt(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4218 guint32 offset, guint len _U_,
4219 gchar *add_string _U_, int string_len _U_)
4220 {
4221 static int * const flags[] = {
4222 &hf_nas_5gs_sm_max_nb_sup_pkt_flt_nb,
4223 &hf_nas_5gs_sm_max_nb_sup_pkt_flt_spare,
4224 NULL
4225 };
4226
4227 proto_tree_add_bitmask_list(tree, tvb, offset, 2, flags, ENC_BIG_ENDIAN);
4228
4229 return 2;
4230 }
4231
4232 /*
4233 * 9.11.4.10 PDU address
4234 */
4235
4236 static const value_string nas_5gs_sm_pdu_ses_type_vals[] = {
4237 { 0x1, "IPv4" },
4238 { 0x2, "IPv6" },
4239 { 0x3, "IPv4v6" },
4240 { 0, NULL }
4241 };
4242
4243
4244 static guint16
4245 de_nas_5gs_sm_pdu_address(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
4246 guint32 offset, guint len,
4247 gchar *add_string _U_, int string_len _U_)
4248 {
4249 proto_item *ti;
4250 gboolean si6lla;
4251 guint32 pdu_addr;
4252 guint8 interface_id[8];
4253
4254 /* 0 Spare 0 Spare 0 Spare 0 Spare SI6LLA PDU session type value */
4255 proto_tree_add_item_ret_boolean(tree, hf_nas_5gs_sm_si6lla, tvb, offset, 1, ENC_BIG_ENDIAN, &si6lla);
4256 ti = proto_tree_add_item_ret_uint(tree, hf_nas_5gs_sm_pdu_ses_type, tvb, offset, 1, ENC_BIG_ENDIAN, &pdu_addr);
4257 offset++;
4258
4259 /* PDU address information */
4260 switch (pdu_addr) {
4261 case 1:
4262 /* IPv4 */
4263 proto_tree_add_item(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4264 offset += 4;
4265 break;
4266 case 2:
4267 /* If the PDU session type value indicates IPv6, the PDU address information in octet 4 to octet 11
4268 * contains an interface identifier for the IPv6 link local address.
4269 */
4270 tvb_memcpy(tvb, interface_id, offset, 8);
4271 proto_tree_add_bytes_format_value(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv6, tvb, offset, 8, NULL,
4272 "::%x:%x:%x:%x", pntoh16(&interface_id[0]), pntoh16(&interface_id[2]),
4273 pntoh16(&interface_id[4]), pntoh16(&interface_id[6]));
4274 offset += 8;
4275 break;
4276 case 3:
4277 /* If the PDU session type value indicates IPv4v6, the PDU address information in octet 4 to octet 11
4278 * contains an interface identifier for the IPv6 link local address and in octet 12 to octet 15
4279 * contains an IPv4 address.
4280 */
4281 tvb_memcpy(tvb, interface_id, offset, 8);
4282 proto_tree_add_bytes_format_value(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv6, tvb, offset, 8, NULL,
4283 "::%x:%x:%x:%x", pntoh16(&interface_id[0]), pntoh16(&interface_id[2]),
4284 pntoh16(&interface_id[4]), pntoh16(&interface_id[6]));
4285 offset += 8;
4286 proto_tree_add_item(tree, hf_nas_5gs_sm_pdu_addr_inf_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4287 offset += 4;
4288 break;
4289 default:
4290 expert_add_info(pinfo, ti, &ei_nas_5gs_unknown_value);
4291 return len;
4292 }
4293
4294 /* SMF's IPv6 link local address */
4295 if (si6lla) {
4296 proto_tree_add_item(tree, hf_nas_5gs_sm_smf_ipv6_lla, tvb, offset, 16, ENC_NA);
4297 }
4298
4299 return len;
4300 }
4301
4302 /*
4303 * 9.11.4.11 PDU session type
4304 */
4305 static const value_string nas_5gs_pdu_session_type_values[] = {
4306 { 0x1, "IPv4" },
4307 { 0x2, "Ipv6" },
4308 { 0x3, "Ipv4v6" },
4309 { 0x4, "Unstructured" },
4310 { 0x5, "Ethernet" },
4311 { 0, NULL }
4312 };
4313
4314
4315 static guint16
4316 de_nas_5gs_sm_pdu_session_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4317 guint32 offset, guint len _U_,
4318 gchar *add_string _U_, int string_len _U_)
4319 {
4320
4321 proto_tree_add_item(tree, hf_nas_5gs_sm_pdu_session_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4322
4323 return 1;
4324 }
4325
4326 /*
4327 * 9.11.4.12 QoS flow descriptions
4328 */
4329
4330 static const value_string nas_5gs_sm_qos_des_flow_opt_code_vals[] = {
4331 { 0x00, "Reserved" },
4332 { 0x01, "Create new QoS flow description" },
4333 { 0x02, "Delete existing QoS flow description" },
4334 { 0x03, "Modify existing QoS flow description" },
4335 { 0, NULL }
4336 };
4337
4338 static const value_string nas_5gs_sm_param_id_values[] = {
4339 { 0x01, "5QI" },
4340 { 0x02, "GFBR uplink" },
4341 { 0x03, "GFBR downlink" },
4342 { 0x04, "MFBR uplink" },
4343 { 0x05, "MFBR downlink" },
4344 { 0x06, "Averaging window" },
4345 { 0x07, "EPS bearer identity" },
4346 { 0, NULL }
4347 };
4348
4349 guint16
4350 de_nas_5gs_sm_qos_flow_des(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4351 guint32 offset, guint len,
4352 gchar *add_string _U_, int string_len _U_)
4353 {
4354
4355 proto_tree *sub_tree, *sub_tree2;
4356 proto_item *item, *sub_item;
4357 int i = 1, j;
4358 guint32 param_len, param_id;
4359 guint32 curr_offset, start_offset, start_offset2;
4360 guint8 num_param;
4361 guint32 unit, mult, val;
4362 const char *unit_str;
4363 int hf_unit, hf_val;
4364
4365 static int * const param_flags[] = {
4366 &hf_nas_5gs_sm_e,
4367 &hf_nas_5gs_sm_nof_params,
4368 NULL
4369 };
4370
4371 curr_offset = offset;
4372
4373 while ((curr_offset - offset) < len) {
4374
4375 /* QoS flow description */
4376 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, len - (curr_offset - offset), ett_nas_5gs_sm_qos_params, &item, "QoS flow description %u", i);
4377 start_offset = curr_offset;
4378
4379 /* 0 0 QFI */
4380 proto_tree_add_item(sub_tree, hf_nas_5gs_sm_qfi, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4381 curr_offset += 1;
4382
4383 /* Operation code */
4384 proto_tree_add_item(sub_tree, hf_nas_5gs_sm_qos_des_flow_opt_code, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4385 curr_offset++;
4386
4387 /* 0 Spare E Number of parameters */
4388 j = 1;
4389 num_param = tvb_get_guint8(tvb, curr_offset);
4390 num_param = num_param & 0x3f;
4391 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, param_flags, ENC_BIG_ENDIAN);
4392 curr_offset++;
4393
4394
4395 while (num_param > 0) {
4396 /* Parameter list */
4397 sub_tree2 = proto_tree_add_subtree_format(sub_tree, tvb, curr_offset, len - (curr_offset - offset), ett_nas_5gs_sm_qos_rules, &sub_item, "Parameter %u", j);
4398 start_offset2 = curr_offset;
4399
4400 /* Parameter identifier */
4401 proto_tree_add_item_ret_uint(sub_tree2, hf_nas_5gs_sm_param_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN, ¶m_id);
4402 proto_item_append_text(item, " - %s", val_to_str_const(param_id, nas_5gs_sm_param_id_values, "Unknown"));
4403 curr_offset++;
4404 /* Length of parameter contents */
4405 proto_tree_add_item_ret_uint(sub_tree2, hf_nas_5gs_sm_param_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN, ¶m_len);
4406 curr_offset++;
4407
4408 /*parameter content*/
4409 switch (param_id) {
4410 /* 01H (5QI)*/
4411 case 0x01:
4412 proto_tree_add_item(sub_tree2, hf_nas_5gs_sm_5qi, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4413 curr_offset += param_len;
4414 break;
4415 /* 02H (GFBR uplink); 04H (MFBR uplink);*/
4416 case 0x02:
4417 case 0x03:
4418 case 0x04:
4419 case 0x05:
4420 if (param_id == 2) {
4421 hf_unit = hf_nas_5gs_sm_unit_for_gfbr_ul;
4422 hf_val = hf_nas_5gs_sm_gfbr_ul;
4423 } else if (param_id == 3) {
4424 hf_unit = hf_nas_5gs_sm_unit_for_gfbr_dl;
4425 hf_val = hf_nas_5gs_sm_gfbr_dl;
4426 } else if (param_id == 4) {
4427 hf_unit = hf_nas_5gs_sm_unit_for_mfbr_ul;
4428 hf_val = hf_nas_5gs_sm_mfbr_ul;
4429 } else {
4430 hf_unit = hf_nas_5gs_sm_unit_for_mfbr_dl;
4431 hf_val = hf_nas_5gs_sm_mfbr_dl;
4432 }
4433 proto_tree_add_item_ret_uint(sub_tree2, hf_unit, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &unit);
4434 curr_offset++;
4435 mult = get_ext_ambr_unit(unit, &unit_str);
4436 val = tvb_get_ntohs(tvb, curr_offset);
4437 proto_tree_add_uint_format_value(sub_tree2, hf_val, tvb, curr_offset, param_len - 1,
4438 val, "%u %s (%u)", val * mult, unit_str, val);
4439 curr_offset += (param_len - 1);
4440 break;
4441 case 0x06:
4442 proto_tree_add_item(sub_tree2, hf_nas_5gs_sm_averaging_window, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
4443 curr_offset += param_len;
4444 break;
4445 case 0x07:
4446 proto_tree_add_item(sub_tree2, hf_nas_5gs_sm_eps_bearer_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4447 curr_offset += param_len;
4448 break;
4449 default:
4450 proto_tree_add_item(sub_tree2, hf_nas_5gs_sm_param_cont, tvb, curr_offset, param_len, ENC_NA);
4451 curr_offset += param_len;
4452 break;
4453 }
4454 num_param--;
4455 j++;
4456 proto_item_set_len(sub_item, curr_offset - start_offset2);
4457 }
4458 i++;
4459 proto_item_set_len(item, curr_offset - start_offset);
4460 }
4461
4462 return len;
4463 }
4464 /*
4465 * 9.11.4.13 QoS rules
4466 */
4467
4468 static true_false_string tfs_nas_5gs_sm_dqr = {
4469 "The QoS rule is the default QoS rule",
4470 "The QoS rule is not the default QoS rule"
4471 };
4472
4473 static const value_string nas_5gs_rule_operation_code_values[] = {
4474 { 0x0, "Reserved" },
4475 { 0x1, "Create new QoS rule" },
4476 { 0x2, "Delete existing QoS rule" },
4477 { 0x3, "Modify existing QoS rule and add packet filters" },
4478 { 0x4, "Modify existing QoS rule and replace packet filters" },
4479 { 0x5, "Modify existing QoS rule and delete packet filters" },
4480 { 0x6, "Modify existing QoS rule without modifying packet filters" },
4481 { 0x7, "Reserved" },
4482 { 0, NULL }
4483 };
4484
4485 static const value_string nas_5gs_sm_pf_type_values[] = {
4486 { 0x01, "Match-all type" },
4487 { 0x10, "IPv4 remote address type" },
4488 { 0x11, "IPv4 local address type" },
4489 { 0x21, "IPv6 remote address/prefix length type" },
4490 { 0x23, "IPv6 local address/prefix length type" },
4491 { 0x30, "Protocol identifier/Next header type" },
4492 { 0x40, "Single local port type" },
4493 { 0x41, "Local port range type" },
4494 { 0x50, "Single remote port type" },
4495 { 0x51, "Remote port range type" },
4496 { 0x60, "Security parameter index type" },
4497 { 0x70, "Type of service/Traffic class type" },
4498 { 0x80, "Flow label type" },
4499 { 0x81, "Destination MAC address type" },
4500 { 0x82, "Source MAC address type" },
4501 { 0x83, "802.1Q C-TAG VID type" },
4502 { 0x84, "802.1Q S-TAG VID type" },
4503 { 0x85, "802.1Q C-TAG PCP/DEI type" },
4504 { 0x86, "802.1Q S-TAG PCP/DEI type" },
4505 { 0x87, "Ethertype type" },
4506 { 0, NULL }
4507 };
4508
4509 static const value_string nas_5gs_sm_pkt_flt_dir_values[] = {
4510 { 0x00, "Reserved" },
4511 { 0x01, "Downlink only" },
4512 { 0x02, "Uplink only" },
4513 { 0x03, "Bidirectional" },
4514 { 0, NULL }
4515 };
4516
4517 guint16
4518 de_nas_5gs_sm_qos_rules(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo,
4519 guint32 offset, guint len,
4520 gchar *add_string _U_, int string_len _U_)
4521 {
4522
4523 proto_tree *sub_tree, *sub_tree2, *sub_tree3;
4524 proto_item *item, *item2;
4525 int i = 1, j, k = 1;
4526 guint32 qos_rule_id, pf_len, pf_type, pfc_len;
4527 guint32 length, curr_offset, saved_offset, start_offset;
4528 guint8 num_pkt_flt, rop;
4529
4530 static int * const pkt_flt_flags[] = {
4531 &hf_nas_5gs_sm_rop,
4532 &hf_nas_5gs_sm_dqr,
4533 &hf_nas_5gs_sm_nof_pkt_filters,
4534 NULL
4535 };
4536
4537 curr_offset = offset;
4538
4539 while ((curr_offset - offset) < len) {
4540
4541 /* QoS Rule */
4542 sub_tree = proto_tree_add_subtree_format(tree, tvb, curr_offset, -1, ett_nas_5gs_sm_qos_rules, &item, "QoS rule %u", i);
4543
4544 /* QoS rule identifier Octet 4*/
4545 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_sm_qos_rule_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &qos_rule_id);
4546 curr_offset += 1;
4547 /* Length of QoS rule Octet 5 - 6*/
4548 proto_tree_add_item_ret_uint(sub_tree, hf_nas_5gs_sm_length, tvb, curr_offset, 2, ENC_BIG_ENDIAN, &length);
4549 curr_offset += 2;
4550
4551 saved_offset = curr_offset;
4552 proto_item_set_len(item, length + 3);
4553
4554 /* Rule operation code DQR bit Number of packet filters */
4555 num_pkt_flt = tvb_get_guint8(tvb, curr_offset);
4556 rop = num_pkt_flt >> 5;
4557 num_pkt_flt = num_pkt_flt & 0x0f;
4558 proto_tree_add_bitmask_list(sub_tree, tvb, curr_offset, 1, pkt_flt_flags, ENC_BIG_ENDIAN);
4559 curr_offset++;
4560
4561 /* For the "delete existing QoS rule" operation and for the "modify existing QoS rule without modifying packet filters"
4562 * operation, the number of packet filters shall be coded as 0.
4563 */
4564 if ((rop == 0) || (rop == 7)) {
4565 /* Reserved */
4566 proto_tree_add_expert(tree, pinfo, &ei_nas_5gs_unknown_value, tvb, curr_offset, length - 1);
4567 i++;
4568 curr_offset += (length - 1);
4569 continue;
4570 }
4571 if ((rop == 2) || (rop == 6)) {
4572 if (num_pkt_flt != 0) {
4573 proto_tree_add_expert(tree, pinfo, &ei_nas_5gs_num_pkt_flt, tvb, curr_offset, length - 1);
4574 i++;
4575 curr_offset += (length - 1);
4576 continue;
4577 }
4578 }
4579
4580 /* Packet filter list */
4581 j = 1;
4582 while (num_pkt_flt > 0) {
4583 sub_tree2 = proto_tree_add_subtree_format(sub_tree, tvb, curr_offset, -1, ett_nas_5gs_sm_qos_rules, &item, "Packet filter %u", j);
4584 start_offset = curr_offset;
4585 if (rop == 5) {
4586 /* modify existing QoS rule and delete packet filters */
4587 /* 0 0 0 0 Packet filter identifier x*/
4588 proto_tree_add_item(sub_tree2, hf_nas_5gs_sm_pkt_flt_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4589 curr_offset++;
4590 } else {
4591 /* "create new QoS rule", or "modify existing QoS rule and add packet filters"
4592 * or "modify existing QoS rule and replace packet filters"
4593 */
4594 /* 0 0 Packet filter direction 1 Packet filter identifier 1*/
4595 proto_tree_add_item(sub_tree2, hf_nas_5gs_sm_pkt_flt_dir, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4596 proto_tree_add_item(sub_tree2, hf_nas_5gs_sm_pkt_flt_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4597 curr_offset++;
4598 /* Length of packet filter contents */
4599 proto_tree_add_item_ret_uint(sub_tree2, hf_nas_5gs_sm_pf_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &pf_len);
4600 curr_offset++;
4601
4602 k = 1;
4603 /* Packet filter contents */
4604 while (pf_len > 0) {
4605 sub_tree3 = proto_tree_add_subtree_format(sub_tree2, tvb, curr_offset, -1, ett_nas_5gs_sm_pkt_filter_components, &item2, "Packet filter component %u", k);
4606 /* Each packet filter component shall be encoded as a sequence of a one octet packet filter component type identifier
4607 * and a fixed length packet filter component value field.
4608 * The packet filter component type identifier shall be transmitted first.
4609 */
4610 proto_tree_add_item_ret_uint(sub_tree3, hf_nas_5gs_sm_pf_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &pf_type);
4611 curr_offset++;
4612 /* Packet filter length contains the length of component type and content */
4613 pf_len--;
4614 switch (pf_type) {
4615 case 1:
4616 /* Match-all type
4617 * . If the "match-all type" packet filter component is present in the packet filter, no other packet filter
4618 * component shall be present in the packet filter and the length of the packet filter contents field shall
4619 * be set to one.
4620 */
4621 pfc_len = 0;
4622 break;
4623 case 16:
4624 /* For "IPv4 remote address type", the packet filter component value field shall be encoded as a sequence
4625 * of a four octet IPv4 address field and a four octet IPv4 address mask field.
4626 * The IPv4 address field shall be transmitted first.
4627 */
4628 case 17:
4629 /* For "IPv4 local address type", the packet filter component value field shall be encoded as defined
4630 * for "IPv4 remote address type"
4631 */
4632 proto_tree_add_item(sub_tree3, hf_nas_5gs_sm_pdu_addr_inf_ipv4, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
4633 curr_offset += 4;
4634 proto_tree_add_item(sub_tree3, hf_nas_5gs_addr_mask_ipv4, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
4635 curr_offset += 4;
4636 pfc_len = 8;
4637 break;
4638 case 33:
4639 case 35:
4640 proto_tree_add_item(sub_tree3, hf_nas_5gs_ipv6, tvb, curr_offset, 16, ENC_NA);
4641 curr_offset += 16;
4642 proto_tree_add_item(sub_tree3, hf_nas_5gs_ipv6_prefix_len, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4643 curr_offset++;
4644 pfc_len = 17;
4645 break;
4646 case 48:
4647 proto_tree_add_item(sub_tree3, hf_nas_5gs_protocol_identifier_or_next_hd, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4648 curr_offset++;
4649 pfc_len = 1;
4650 break;
4651 case 64:
4652 case 80:
4653 proto_tree_add_item(sub_tree3, hf_nas_5gs_single_port_type, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
4654 curr_offset += 2;
4655 pfc_len = 2;
4656 break;
4657 case 65:
4658 case 81:
4659 proto_tree_add_item(sub_tree3, hf_nas_5gs_port_range_type_low, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
4660 curr_offset += 2;
4661 proto_tree_add_item(sub_tree3, hf_nas_5gs_port_range_type_high, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
4662 curr_offset += 2;
4663 pfc_len = 4;
4664 break;
4665 case 96:
4666 proto_tree_add_item(sub_tree3, hf_nas_5gs_sec_param_idx, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
4667 curr_offset += 4;
4668 pfc_len = 4;
4669 break;
4670 case 112:
4671 proto_tree_add_item(sub_tree3, hf_nas_5gs_tos_tc_val, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4672 curr_offset++;
4673 proto_tree_add_item(sub_tree3, hf_nas_5gs_tos_tc_mask, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4674 curr_offset++;
4675 pfc_len = 2;
4676 break;
4677 case 128:
4678 proto_tree_add_item(sub_tree3, hf_nas_5gs_flow_label, tvb, curr_offset, 3, ENC_BIG_ENDIAN);
4679 curr_offset += 3;
4680 pfc_len = 3;
4681 break;
4682 case 129:
4683 case 130:
4684 proto_tree_add_item(sub_tree3, hf_nas_5gs_mac_addr, tvb, curr_offset, 6, ENC_NA);
4685 curr_offset += 6;
4686 pfc_len = 6;
4687 break;
4688 case 131:
4689 case 132:
4690 proto_tree_add_item(sub_tree3, hf_nas_5gs_vlan_tag_vid, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
4691 curr_offset += 2;
4692 pfc_len = 2;
4693 break;
4694 case 133:
4695 case 134:
4696 proto_tree_add_item(sub_tree3, hf_nas_5gs_vlan_tag_pcp, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4697 proto_tree_add_item(sub_tree3, hf_nas_5gs_vlan_tag_dei, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4698 curr_offset++;
4699 pfc_len = 1;
4700 break;
4701 case 135:
4702 proto_tree_add_item(sub_tree3, hf_nas_5gs_ethertype, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
4703 curr_offset += 2;
4704 pfc_len = 2;
4705 break;
4706 default:
4707 proto_tree_add_expert(sub_tree3, pinfo, &ei_nas_5gs_not_diss, tvb, curr_offset, pf_len);
4708 curr_offset += pf_len;
4709 pfc_len = pf_len;
4710 break;
4711 }
4712 pf_len -= pfc_len;
4713 k++;
4714 proto_item_set_len(item2, pfc_len + 1);
4715 }
4716 }
4717 num_pkt_flt--;
4718 j++;
4719 proto_item_set_len(item, curr_offset - start_offset);
4720
4721 }
4722 if (rop != 2 && (curr_offset - saved_offset) < length) { /* Delete existing QoS rule */
4723 /* QoS rule precedence (octet z+1)
4724 * For the "delete existing QoS rule" operation, the QoS rule precedence value field shall not be included.
4725 * For the "create new QoS rule" operation, the QoS rule precedence value field shall be included.
4726 */
4727 proto_tree_add_item(sub_tree, hf_nas_5gs_sm_qos_rule_precedence, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4728 curr_offset++;
4729 if ((curr_offset - saved_offset) < length) {
4730 /* QoS flow identifier (QFI) (bits 6 to 1 of octet z+2)
4731 * For the "delete existing QoS rule" operation, the QoS flow identifier value field shall not be included.
4732 * For the "create new QoS rule" operation, the QoS flow identifier value field shall be included.
4733 */
4734 proto_tree_add_item(sub_tree, hf_nas_5gs_spare_b7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4735 /* Segregation bit (bit 7 of octet z+2) */
4736 if (pinfo->link_dir == P2P_DIR_UL)
4737 proto_tree_add_item(sub_tree, hf_nas_5gs_sm_segregation, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4738 else
4739 proto_tree_add_item(sub_tree, hf_nas_5gs_spare_b6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4740 proto_tree_add_item(sub_tree, hf_nas_5gs_sm_qfi, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
4741 curr_offset++;
4742 }
4743 }
4744
4745 i++;
4746 }
4747
4748 return len;
4749 }
4750
4751 /*
4752 * 9.11.4.14 Session-AMBR
4753 */
4754
4755 static const value_string nas_5gs_sm_unit_for_session_ambr_values[] = {
4756 { 0x00, "value is not used" },
4757 { 0x01, "value is incremented in multiples of 1 Kbps" },
4758 { 0x02, "value is incremented in multiples of 4 Kbps" },
4759 { 0x03, "value is incremented in multiples of 16 Kbps" },
4760 { 0x04, "value is incremented in multiples of 64 Kbps" },
4761 { 0x05, "value is incremented in multiples of 256 kbps" },
4762 { 0x06, "value is incremented in multiples of 1 Mbps" },
4763 { 0x07, "value is incremented in multiples of 4 Mbps" },
4764 { 0x08, "value is incremented in multiples of 16 Mbps" },
4765 { 0x09, "value is incremented in multiples of 64 Mbps" },
4766 { 0x0a, "value is incremented in multiples of 256 Mbps" },
4767 { 0x0b, "value is incremented in multiples of 1 Gbps" },
4768 { 0x0c, "value is incremented in multiples of 4 Gbps" },
4769 { 0x0d, "value is incremented in multiples of 16 Gbps" },
4770 { 0x0e, "value is incremented in multiples of 64 Gbps" },
4771 { 0x0f, "value is incremented in multiples of 256 Gbps" },
4772 { 0x10, "value is incremented in multiples of 1 Tbps" },
4773 { 0x11, "value is incremented in multiples of 4 Tbps" },
4774 { 0x12, "value is incremented in multiples of 16 Tbps" },
4775 { 0x13, "value is incremented in multiples of 64 Tbps" },
4776 { 0x14, "value is incremented in multiples of 256 Tbps" },
4777 { 0x15, "value is incremented in multiples of 1 Pbps" },
4778 { 0x16, "value is incremented in multiples of 4 Pbps" },
4779 { 0x17, "value is incremented in multiples of 16 Pbps" },
4780 { 0x18, "value is incremented in multiples of 64 Pbps" },
4781 { 0x19, "value is incremented in multiples of 256 Pbps" },
4782 { 0, NULL }
4783 };
4784
4785
4786 guint16
4787 de_nas_5gs_sm_session_ambr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4788 guint32 offset, guint len,
4789 gchar *add_string _U_, int string_len _U_)
4790 {
4791 guint32 unit, mult, ambr_val;
4792 const char *unit_str;
4793
4794 /* Unit for Session-AMBR for downlink */
4795 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_sm_unit_for_session_ambr_dl, tvb, offset, 1, ENC_BIG_ENDIAN, &unit);
4796 offset++;
4797
4798 /* Session-AMBR for downlink (octets 4 and 5) */
4799 mult = get_ext_ambr_unit(unit, &unit_str);
4800 ambr_val = tvb_get_ntohs(tvb, offset);
4801 proto_tree_add_uint_format_value(tree, hf_nas_5gs_sm_session_ambr_dl, tvb, offset, 2,
4802 ambr_val, "%u %s (%u)", ambr_val * mult, unit_str, ambr_val);
4803 offset += 2;
4804
4805 proto_tree_add_item_ret_uint(tree, hf_nas_5gs_sm_unit_for_session_ambr_ul, tvb, offset, 1, ENC_NA, &unit);
4806 offset++;
4807 mult = get_ext_ambr_unit(unit, &unit_str);
4808 ambr_val = tvb_get_ntohs(tvb, offset);
4809 proto_tree_add_uint_format_value(tree, hf_nas_5gs_sm_session_ambr_ul, tvb, offset, 2,
4810 ambr_val, "%u %s (%u)", ambr_val * mult, unit_str, ambr_val);
4811
4812 return len;
4813 }
4814
4815 /*
4816 * 9.11.4.15 SM PDU DN request container
4817 */
4818 /* The SM PDU DN request container contains a DN-specific identity of the UE in the network access identifier (NAI) format */
4819 static guint16
4820 de_nas_5gs_sm_pdu_dn_req_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4821 guint32 offset, guint len,
4822 gchar *add_string _U_, int string_len _U_)
4823 {
4824 proto_tree_add_item(tree, hf_nas_5gs_sm_dm_spec_id, tvb, offset, len, ENC_UTF_8);
4825
4826 return len;
4827 }
4828
4829 /*
4830 * 9.11.4.16 SSC mode
4831 */
4832
4833 static const value_string nas_5gs_sc_mode_values[] = {
4834 { 0x1, "SSC mode 1" },
4835 { 0x2, "SSC mode 2" },
4836 { 0x3, "SSC mode 3" },
4837 { 0, NULL }
4838 };
4839
4840
4841 static guint16
4842 de_nas_5gs_sm_ssc_mode(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
4843 guint32 offset, guint len _U_,
4844 gchar *add_string _U_, int string_len _U_)
4845 {
4846
4847 proto_tree_add_item(tree, hf_nas_5gs_sm_sc_mode, tvb, offset, 1, ENC_BIG_ENDIAN);
4848
4849 return 1;
4850 }
4851
4852 /*
4853 * 9.11.4.17 Re-attempt indicator
4854 */
4855 static true_false_string tfs_nas_5gs_sm_eplmnc = {
4856 "UE is not allowed to re-attempt the procedure in an equivalent PLMN",
4857 "UE is allowed to re-attempt the procedure in an equivalent PLMN"
4858 };
4859
4860 static true_false_string tfs_nas_5gs_sm_ratc = {
4861 "UE is not allowed to re-attempt the procedure in S1 mode",
4862 "UE is allowed to re-attempt the procedure in S1 mode"
4863 };
4864
4865 static guint16
4866 de_nas_5gs_sm_re_attempt_ind(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
4867 guint32 offset, guint len,
4868 gchar* add_string _U_, int string_len _U_)
4869 {
4870 static int* const flags[] = {
4871 &hf_nas_5gs_spare_b7,
4872 &hf_nas_5gs_spare_b6,
4873 &hf_nas_5gs_spare_b5,
4874 &hf_nas_5gs_spare_b4,
4875 &hf_nas_5gs_spare_b3,
4876 &hf_nas_5gs_spare_b2,
4877 &hf_nas_5gs_sm_eplmnc,
4878 &hf_nas_5gs_sm_ratc,
4879 NULL
4880 };
4881
4882 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
4883
4884 return len;
4885 }
4886 /*
4887 * 9.11.4.18 5GSM network feature support
4888 */
4889 static guint16
4890 de_nas_5gs_sm_5gsm_nw_feature_sup(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
4891 guint32 offset, guint len,
4892 gchar* add_string _U_, int string_len _U_)
4893 {
4894 guint32 curr_offset = offset;
4895
4896 static int* const flags[] = {
4897 &hf_nas_5gs_spare_b7,
4898 &hf_nas_5gs_spare_b6,
4899 &hf_nas_5gs_spare_b5,
4900 &hf_nas_5gs_spare_b4,
4901 &hf_nas_5gs_spare_b3,
4902 &hf_nas_5gs_spare_b2,
4903 &hf_nas_5gs_spare_b1,
4904 &hf_nas_5gs_sm_ept_s1,
4905 NULL
4906 };
4907
4908 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags, ENC_BIG_ENDIAN);
4909 curr_offset++;
4910
4911 EXTRANEOUS_DATA_CHECK(len, curr_offset - offset, pinfo, &ei_nas_5gs_extraneous_data);
4912
4913 return (curr_offset - offset);
4914 }
4915 /*
4916 * 9.11.4.19 Void
4917 */
4918
4919 /*
4920 * 9.11.4.20 Serving PLMN rate control
4921 * See subclause 9.9.4.28 in 3GPP TS 24.301
4922 */
4923
4924 /*
4925 * 9.11.4.21 5GSM congestion re-attempt indicator
4926 */
4927 static true_false_string tfs_5gs_sm_abo = {
4928 "The back-off timer is applied in all PLMNs",
4929 "The back-off timer is applied in the registered PLMN"
4930 };
4931
4932 static guint16
4933 de_nas_5gs_sm_5gsm_cong_re_attempt_ind(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
4934 guint32 offset, guint len,
4935 gchar* add_string _U_, int string_len _U_)
4936 {
4937 static int* const flags[] = {
4938 &hf_nas_5gs_spare_b7,
4939 &hf_nas_5gs_spare_b6,
4940 &hf_nas_5gs_spare_b5,
4941 &hf_nas_5gs_spare_b4,
4942 &hf_nas_5gs_spare_b3,
4943 &hf_nas_5gs_spare_b2,
4944 &hf_nas_5gs_spare_b1,
4945 &hf_nas_5gs_sm_abo,
4946 NULL
4947 };
4948
4949 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
4950
4951 return len;
4952 }
4953
4954 /*
4955 * 9.11.4.22 ATSSS container
4956 */
4957 static guint16
4958 de_nas_5gs_sm_atsss_cont(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
4959 guint32 offset, guint len,
4960 gchar* add_string _U_, int string_len _U_)
4961 {
4962 proto_tree_add_item(tree, hf_nas_5gs_sm_atsss_cont, tvb, offset, len, ENC_NA);
4963
4964 return len;
4965 }
4966
4967 /*
4968 * 9.11.4.23 Control plane only indication
4969 */
4970 static true_false_string tfs_5gs_sm_cpoi = {
4971 "PDU session can be used for control plane CIoT 5GS optimization only",
4972 "reserved"
4973 };
4974
4975 static guint16
4976 de_nas_5gs_sm_ctl_plane_only_ind(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
4977 guint32 offset, guint len _U_,
4978 gchar* add_string _U_, int string_len _U_)
4979 {
4980 static int* const flags[] = {
4981 &hf_nas_5gs_spare_b3,
4982 &hf_nas_5gs_spare_b2,
4983 &hf_nas_5gs_spare_b1,
4984 &hf_nas_5gs_sm_cpoi,
4985 NULL
4986 };
4987
4988 proto_tree_add_bitmask_list(tree, tvb, offset, 1, flags, ENC_BIG_ENDIAN);
4989
4990 return 1;
4991 }
4992 /*
4993 * 9.11.4.24 IP header compression configuration
4994 */
4995 static const value_string nas_5gs_sm_ip_hdr_comp_config_add_ip_hdr_compr_cxt_setup_params_type_vals[] = {
4996 { 0x00, "0x0000 (No Compression)" },
4997 { 0x01, "0x0002 (UDP/IP)" },
4998 { 0x02, "0x0003 (ESP/IP)" },
4999 { 0x03, "0x0004 (IP)" },
5000 { 0x04, "0x0006 (TCP/IP)" },
5001 { 0x05, "0x0102 (UDP/IP)" },
5002 { 0x06, "0x0103 (ESP/IP)" },
5003 { 0x07, "0x0104 (IP)" },
5004 { 0x08, "Other" },
5005 { 0x0, NULL }
5006 };
5007
5008 static guint16
5009 de_nas_5gs_sm_ip_hdr_comp_conf(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
5010 guint32 offset, guint len,
5011 gchar* add_string _U_, int string_len _U_)
5012 {
5013 guint32 curr_offset = offset;
5014
5015 static int * const flags[] = {
5016 &hf_nas_5gs_spare_b7,
5017 &hf_nas_5gs_sm_ip_hdr_comp_config_p0104,
5018 &hf_nas_5gs_sm_ip_hdr_comp_config_p0103,
5019 &hf_nas_5gs_sm_ip_hdr_comp_config_p0102,
5020 &hf_nas_5gs_sm_ip_hdr_comp_config_p0006,
5021 &hf_nas_5gs_sm_ip_hdr_comp_config_p0004,
5022 &hf_nas_5gs_sm_ip_hdr_comp_config_p0003,
5023 &hf_nas_5gs_sm_ip_hdr_comp_config_p0002,
5024 NULL
5025 };
5026
5027 proto_tree_add_bitmask_list(tree, tvb, curr_offset, 1, flags, ENC_NA);
5028 curr_offset++;
5029 proto_tree_add_item(tree, hf_nas_5gs_sm_ip_hdr_comp_config_max_cid, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
5030 curr_offset += 2;
5031
5032 if ((curr_offset - offset) >= len) {
5033 return len;
5034 }
5035
5036 proto_tree_add_item(tree, hf_nas_5gs_sm_ip_hdr_comp_config_add_ip_hdr_compr_cxt_setup_params_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
5037 curr_offset++;
5038 proto_tree_add_item(tree, hf_nas_5gs_sm_ip_hdr_comp_config_add_ip_hdr_compr_cxt_setup_params_cont, tvb, curr_offset, len - (curr_offset - offset), ENC_NA);
5039
5040 return len;
5041 }
5042 /*
5043 * 9.11.4.25 DS-TT Ethernet port MAC address
5044 */
5045 static guint16
5046 de_nas_5gs_sm_ds_tt_eth_port_mac_addr(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
5047 guint32 offset, guint len,
5048 gchar* add_string _U_, int string_len _U_)
5049 {
5050 proto_tree_add_item(tree, hf_nas_5gs_sm_ds_tt_eth_port_mac_addr, tvb, offset, 6, ENC_NA);
5051
5052 return len;
5053 }
5054
5055 /*
5056 * 9.11.4.26 UE-DS-TT residence time
5057 */
5058 static guint16
5059 de_nas_5gs_sm_ue_ds_tt_residence_t(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
5060 guint32 offset, guint len,
5061 gchar* add_string _U_, int string_len _U_)
5062 {
5063 proto_tree_add_item(tree, hf_nas_5gs_sm_ue_ds_tt_residence_time, tvb, offset, 8, ENC_NA);
5064
5065 return len;
5066 }
5067
5068 /*
5069 * 9.11.4.27 Port management information container
5070 */
5071 static guint16
5072 de_nas_5gs_sm_port_mgnt_inf_cont(tvbuff_t* tvb, proto_tree* tree, packet_info* pinfo _U_,
5073 guint32 offset, guint len,
5074 gchar* add_string _U_, int string_len _U_)
5075 {
5076 proto_tree_add_item(tree, hf_nas_5gs_sm_port_mgmt_info_cont, tvb, offset, len, ENC_NA);
5077
5078 return len;
5079 }
5080
5081 /*
5082 * 9.11.4.28 Ethernet header compression configuration
5083 */
5084 static const value_string nas_5gs_sm_eth_hdr_comp_config_cid_len_vals[] = {
5085 { 0x0, "Ethernet header compression not used" },
5086 { 0x1, "7 bits" },
5087 { 0x2, "15 bits" },
5088 { 0x0, NULL }
5089 };
5090
5091 static guint16
5092 de_nas_5gs_sm_eth_hdr_comp_conf(tvbuff_t* tvb, proto_tree