"Fossies" - the Fresh Open Source Software Archive

Member "wireshark-3.6.1/epan/dissectors/packet-nas_5gs.c" (29 Dec 2021, 491393 Bytes) of package /linux/misc/wireshark-3.6.1.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 last Fossies "Diffs" side-by-side code changes report: 3.5.0_vs_3.6.0rc1.

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