From Pascal Quantin.
[obnox/wireshark/wip.git] / epan / dissectors / packet-nas_eps.c
1 /* packet-nas_eps.c
2  * Routines for Non-Access-Stratum (NAS) protocol for Evolved Packet System (EPS) dissection
3  *
4  * Copyright 2008 - 2010, Anders Broman <anders.broman@ericsson.com>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  *
26  * References: 3GPP TS 24.301 V9.6.0 (2011-03)
27  */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include <epan/asn1.h>
36
37 #include "packet-gsm_map.h"
38 #include "packet-gsm_a_common.h"
39 #include "packet-e212.h"
40 #include "packet-lcsap.h"
41
42 #define PNAME  "Non-Access-Stratum (NAS)PDU"
43 #define PSNAME "NAS-EPS"
44 #define PFNAME "nas-eps"
45
46 /* Initialize the protocol and registered fields */
47 static int proto_nas_eps = -1;
48
49 /* Dissector handles */
50 static dissector_handle_t gsm_a_dtap_handle;
51 static dissector_handle_t lpp_handle;
52
53 /* Forward declaration */
54 static void disect_nas_eps_esm_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset);
55
56 static int hf_nas_eps_msg_emm_type = -1;
57 int hf_nas_eps_common_elem_id = -1;
58 int hf_nas_eps_emm_elem_id = -1;
59 static int hf_nas_eps_bearer_id = -1;
60 static int hf_nas_eps_spare_bits = -1;
61 static int hf_nas_eps_security_header_type = -1;
62 static int hf_nas_eps_msg_auth_code = -1;
63 static int hf_nas_eps_seq_no = -1;
64 static int hf_nas_eps_seq_no_short = -1;
65 static int hf_nas_eps_emm_ebi0 = -1;
66 static int hf_nas_eps_emm_ebi1 = -1;
67 static int hf_nas_eps_emm_ebi2 = -1;
68 static int hf_nas_eps_emm_ebi3 = -1;
69 static int hf_nas_eps_emm_ebi4 = -1;
70 static int hf_nas_eps_emm_ebi5 = -1;
71 static int hf_nas_eps_emm_ebi6 = -1;
72 static int hf_nas_eps_emm_ebi7 = -1;
73 static int hf_nas_eps_emm_ebi8 = -1;
74 static int hf_nas_eps_emm_ebi9 = -1;
75 static int hf_nas_eps_emm_ebi10 = -1;
76 static int hf_nas_eps_emm_ebi11 = -1;
77 static int hf_nas_eps_emm_ebi12 = -1;
78 static int hf_nas_eps_emm_ebi13 = -1;
79 static int hf_nas_eps_emm_ebi14 = -1;
80 static int hf_nas_eps_emm_ebi15 = -1;
81 static int hf_nas_eps_emm_dl_nas_cnt = -1;
82 static int hf_nas_eps_emm_nonce_mme = -1;
83 static int hf_nas_eps_emm_nonce = -1;
84 static int hf_nas_eps_emm_paging_id = -1;
85 static int hf_nas_eps_emm_eps_att_type = -1;
86 static int hf_nas_eps_emm_cs_lcs_type = -1;
87 static int hf_nas_eps_emm_epc_lcs_type = -1;
88 static int hf_nas_eps_emm_emc_bs_type = -1;
89 static int hf_nas_eps_emm_ims_vops_type = -1;
90 static int hf_nas_eps_emm_nas_key_set_id = -1;
91 static int hf_nas_eps_tsc = -1;
92 static int hf_nas_eps_emm_odd_even = -1;
93 static int hf_nas_eps_emm_type_of_id = -1;
94 static int hf_nas_eps_emm_mme_grp_id = -1;
95 static int hf_nas_eps_emm_imsi = -1;
96 static int hf_nas_eps_emm_imei = -1;
97 static int hf_nas_eps_emm_mme_code = -1;
98 static int hf_nas_eps_emm_m_tmsi = -1;
99 static int hf_nas_eps_esm_msg_cont = -1;
100 static int hf_nas_eps_esm_imeisv_req = -1;
101 static int hf_nas_eps_emm_toi = -1;
102 static int hf_nas_eps_emm_toc = -1;
103 static int hf_nas_eps_emm_EPS_attach_result = -1;
104 static int hf_nas_eps_emm_spare_half_octet = -1;
105 static int hf_nas_eps_emm_add_upd_res = -1;
106 static int hf_nas_eps_emm_add_upd_type = -1;
107 static int hf_nas_eps_emm_res = -1;
108 static int hf_nas_eps_emm_csfb_resp = -1;
109 static int hf_nas_eps_emm_cause = -1;
110 static int hf_nas_eps_emm_id_type2 = -1;
111 static int hf_nas_eps_emm_short_mac = -1;
112 static int hf_nas_eps_emm_tai_tol = -1;
113 static int hf_nas_eps_emm_tai_n_elem = -1;
114 static int hf_nas_eps_emm_tai_tac = -1;
115 static int hf_nas_eps_emm_eea0 = -1;
116 static int hf_nas_eps_emm_128eea1 = -1;
117 static int hf_nas_eps_emm_128eea2 = -1;
118 static int hf_nas_eps_emm_eea3 = -1;
119 static int hf_nas_eps_emm_eea4 = -1;
120 static int hf_nas_eps_emm_eea5 = -1;
121 static int hf_nas_eps_emm_eea6 = -1;
122 static int hf_nas_eps_emm_eea7 = -1;
123 static int hf_nas_eps_emm_eia0 = -1;
124 static int hf_nas_eps_emm_128eia1 = -1;
125 static int hf_nas_eps_emm_128eia2 = -1;
126 static int hf_nas_eps_emm_eia3 = -1;
127 static int hf_nas_eps_emm_eia4 = -1;
128 static int hf_nas_eps_emm_eia5 = -1;
129 static int hf_nas_eps_emm_eia6 = -1;
130 static int hf_nas_eps_emm_eia7 = -1;
131 static int hf_nas_eps_emm_uea0 = -1;
132 static int hf_nas_eps_emm_uea1 = -1;
133 static int hf_nas_eps_emm_uea2 = -1;
134 static int hf_nas_eps_emm_uea3 = -1;
135 static int hf_nas_eps_emm_uea4 = -1;
136 static int hf_nas_eps_emm_uea5 = -1;
137 static int hf_nas_eps_emm_uea6 = -1;
138 static int hf_nas_eps_emm_uea7 = -1;
139 static int hf_nas_eps_emm_ucs2_supp = -1;
140 static int hf_nas_eps_emm_uia1 = -1;
141 static int hf_nas_eps_emm_uia2 = -1;
142 static int hf_nas_eps_emm_uia3 = -1;
143 static int hf_nas_eps_emm_uia4 = -1;
144 static int hf_nas_eps_emm_uia5 = -1;
145 static int hf_nas_eps_emm_uia6 = -1;
146 static int hf_nas_eps_emm_uia7 = -1;
147 static int hf_nas_eps_emm_gea1 = -1;
148 static int hf_nas_eps_emm_gea2 = -1;
149 static int hf_nas_eps_emm_gea3 = -1;
150 static int hf_nas_eps_emm_gea4 = -1;
151 static int hf_nas_eps_emm_gea5 = -1;
152 static int hf_nas_eps_emm_gea6 = -1;
153 static int hf_nas_eps_emm_gea7 = -1;
154 static int hf_nas_eps_emm_lpp_cap = -1;
155 static int hf_nas_eps_emm_lcs_cap = -1;
156 static int hf_nas_eps_emm_1xsrvcc_cap = -1;
157 static int hf_nas_eps_emm_nf_cap = -1;
158 static int hf_nas_eps_emm_ue_ra_cap_inf_upd_need_flg;
159 static int hf_nas_eps_emm_ss_code = -1;
160 static int hf_nas_eps_emm_lcs_ind = -1;
161 static int hf_nas_eps_emm_gen_msg_cont_type = -1;
162 static int hf_nas_eps_emm_apn_ambr_ul = -1;
163 static int hf_nas_eps_emm_apn_ambr_dl = -1;
164 static int hf_nas_eps_emm_apn_ambr_ul_ext = -1;
165 static int hf_nas_eps_emm_apn_ambr_dl_ext = -1;
166 static int hf_nas_eps_emm_apn_ambr_ul_ext2 = -1;
167 static int hf_nas_eps_emm_apn_ambr_dl_ext2 = -1;
168
169 static int hf_nas_eps_emm_switch_off = -1;
170 static int hf_nas_eps_emm_detach_type_UL = -1;
171 static int hf_nas_eps_emm_detach_type_DL = -1;
172
173 static int hf_nas_eps_qci = -1;
174 static int hf_nas_eps_mbr_ul = -1;
175 static int hf_nas_eps_mbr_dl = -1;
176 static int hf_nas_eps_gbr_ul = -1;
177 static int hf_nas_eps_gbr_dl = -1;
178 static int hf_nas_eps_embr_ul = -1;
179 static int hf_nas_eps_embr_dl = -1;
180 static int hf_nas_eps_egbr_ul = -1;
181 static int hf_nas_eps_egbr_dl = -1;
182
183 static int hf_nas_eps_esm_cause = -1;
184 static int hf_nas_eps_esm_eit = -1;
185 static int hf_nas_eps_esm_lnkd_eps_bearer_id = -1;
186 static int hf_nas_eps_esm_notif_ind = -1;
187 static int hf_nas_eps_esm_pdn_type = -1;
188 static int hf_nas_eps_esm_pdn_ipv4 = -1;
189 static int hf_nas_eps_esm_pdn_ipv6_if_id = -1;
190
191 static int hf_nas_eps_esm_linked_bearer_id = -1;
192
193 static int hf_nas_eps_active_flg = -1;
194 static int hf_nas_eps_eps_update_result_value = -1;
195 static int hf_nas_eps_eps_update_type_value = -1;
196 static int hf_nas_eps_service_type = -1;
197
198 static int hf_nas_eps_nas_msg_cont = -1;
199 static int hf_nas_eps_gen_msg_cont = -1;
200
201 static int hf_nas_eps_cmn_add_info = -1;
202
203 /* ESM */
204 static int hf_nas_eps_msg_esm_type = -1;
205 int hf_nas_eps_esm_elem_id = -1;
206 static int hf_nas_eps_esm_proc_trans_id = -1;
207
208 /* Initialize the subtree pointers */
209 static int ett_nas_eps = -1;
210 static int ett_nas_eps_esm_msg_cont = -1;
211 static int ett_nas_eps_nas_msg_cont = -1;
212 static int ett_nas_eps_gen_msg_cont = -1;
213 static int ett_nas_eps_cmn_add_info = -1;
214
215 /* Global variables */
216 static packet_info *gpinfo;
217
218 guint8 eps_nas_gen_msg_cont_type = 0;
219
220 /* Table 9.8.1: Message types for EPS mobility management
221  *  0   1   -   -   -   -   -   -       EPS mobility management messages
222  */
223 static const value_string nas_msg_emm_strings[] = {
224     { 0x41, "Attach request"},
225     { 0x42, "Attach accept"},
226     { 0x43, "Attach complete"},
227     { 0x44, "Attach reject"},
228     { 0x45, "Detach request"},
229     { 0x46, "Detach accept"},
230
231     { 0x48, "Tracking area update request"},
232     { 0x49, "Tracking area update accept"},
233     { 0x4a, "Tracking area update complete"},
234     { 0x4b, "Tracking area update reject"},
235
236     { 0x4c, "Extended service request"},
237     { 0x4e, "Service reject"},
238
239     { 0x50, "GUTI reallocation command"},
240     { 0x51, "GUTI reallocation complete"},
241     { 0x52, "Authentication request"},
242     { 0x53, "Authentication response"},
243     { 0x54, "Authentication reject"},
244     { 0x5c, "Authentication failure"},
245     { 0x55, "Identity request"},
246     { 0x56, "Identity response"},
247     { 0x5d, "Security mode command"},
248     { 0x5e, "Security mode complete"},
249     { 0x5f, "Security mode reject"},
250
251     { 0x60, "EMM status"},
252     { 0x61, "EMM information"},
253     { 0x62, "Downlink NAS transport"},
254     { 0x63, "Uplink NAS transport"},
255     { 0x64, "CS Service notification"},
256     { 0x68, "Downlink generic NAS transport"},
257     { 0x69, "Uplink generic NAS transport"},
258     { 0,    NULL }
259 };
260
261 /* Table 9.8.2: Message types for EPS session management */
262
263 static const value_string nas_msg_esm_strings[] = {
264     { 0xc1, "Activate default EPS bearer context request"},
265     { 0xc2, "Activate default EPS bearer context accept"},
266     { 0xc3, "Activate default EPS bearer context reject"},
267     { 0xc5, "Activate dedicated EPS bearer context request"},
268     { 0xc6, "Activate dedicated EPS bearer context accept"},
269     { 0xc7, "Activate dedicated EPS bearer context reject"},
270     { 0xc9, "Modify EPS bearer context request"},
271     { 0xca, "Modify EPS bearer context accept"},
272     { 0xcb, "Modify EPS bearer context reject"},
273     { 0xcd, "Deactivate EPS bearer context request"},
274     { 0xce, "Deactivate EPS bearer context accept"},
275     { 0xd0, "PDN connectivity request"},
276     { 0xd1, "PDN connectivity reject"},
277     { 0xd2, "PDN disconnect request"},
278     { 0xd3, "PDN disconnect reject"},
279     { 0xd4, "Bearer resource allocation request"},
280     { 0xd5, "Bearer resource allocation reject"},
281     { 0xd6, "Bearer resource modification request"},
282     { 0xd7, "Bearer resource modification reject"},
283     { 0xd9, "ESM information request"},
284     { 0xda, "ESM information response"},
285     { 0xdb, "Notification"},
286     { 0xe8, "ESM status"},
287     { 0,    NULL }
288 };
289
290 static const value_string security_header_type_vals[] = {
291     { 0,    "Plain NAS message, not security protected"},
292     { 1,    "Integrity protected"},
293     { 2,    "Integrity protected and ciphered"},
294     { 3,    "Integrity protected with new EPS security context"},
295     { 4,    "Integrity protected and ciphered with new EPS security context"},
296     { 5,    "Reserved"},
297     { 6,    "Reserved"},
298     { 7,    "Reserved"},
299     { 8,    "Reserved"},
300     { 9,    "Reserved"},
301     { 10,   "Reserved"},
302     { 11,   "Reserved"},
303     { 12,   "Security header for the SERVICE REQUEST message "},
304     { 13,   "These values are not used in this version of the protocol. If received they shall be interpreted as \"1100\""},
305     { 14,   "These values are not used in this version of the protocol. If received they shall be interpreted as \"1100\""},
306     { 15,   "These values are not used in this version of the protocol. If received they shall be interpreted as \"1100\""},
307     { 0,    NULL }
308 };
309 static value_string_ext security_header_type_vals_ext = VALUE_STRING_EXT_INIT(security_header_type_vals);
310
311 const value_string nas_eps_common_elem_strings[] = {
312     { 0x00, "Additional information" },                 /* 9.9.2.0  Additional information */
313     { 0x00, "EPS bearer context status" },              /* 9.9.2.1  EPS bearer context status */
314     { 0x00, "Location area identification" },           /* 9.9.2.2  Location area identification */
315     { 0x00, "Mobile identity" },                        /* 9.9.2.3  Mobile identity */
316     { 0x00, "Mobile station classmark 2" },             /* 9.9.2.4  Mobile station classmark 2 */
317     { 0x00, "Mobile station classmark 3" },             /* 9.9.2.5  Mobile station classmark 3 */
318     { 0x00, "NAS security parameters from E-UTRA" },    /* 9.9.2.6  NAS security parameters from E-UTRA */
319     { 0x00, "NAS security parameters to E-UTRA" },      /* 9.9.2.7  NAS security parameters to E-UTRA */
320     { 0x00, "PLMN list" },                              /* 9.9.2.8  PLMN list   */
321                                                         /* 9.9.2.9  Spare half octet */
322     { 0x00, "Supported codec list" },                   /* 9.9.2.10 Supported codec list */
323     { 0, NULL }
324 };
325 /* Utility functions */
326 static guint16
327 calc_bitrate(guint8 value){
328     guint16 return_value = value;
329
330     if (value > 63 && value <= 127) {
331         return_value = 64 + (value - 64) * 8;
332     }
333     else if (value > 127 && value <= 254) {
334         return_value = 576 + (value - 128) * 64;
335     }
336     else if (value==0xff) {
337         return_value = 0;
338     }
339     return return_value;
340 }
341 static guint32
342 calc_bitrate_ext(guint8 value){
343     guint32 return_value = 0;
344
345     if (value > 0 && value <= 0x4a) {
346         return_value = 8600 + value * 100;
347     }
348     else if (value > 0x4a && value <= 0xba) {
349         return_value = 16 + (value-0x4a);
350     }
351     else if (value > 0xba && value <= 0xfa) {
352         return_value = 128 + (value-0xba)*2;
353     }
354     else {
355         return_value = 256;
356     }
357
358     return return_value;
359 }
360
361 #define NUM_NAS_EPS_COMMON_ELEM (sizeof(nas_eps_common_elem_strings)/sizeof(value_string))
362 gint ett_nas_eps_common_elem[NUM_NAS_EPS_COMMON_ELEM];
363
364 typedef enum
365 {
366     DE_EPS_CMN_ADD_INFO,                        /* 9.9.2.0  Additional information */
367     DE_EPS_CMN_EPS_BE_CTX_STATUS,               /* 9.9.2.1  EPS bearer context status */
368     DE_EPS_CMN_LOC_AREA_ID,                     /* 9.9.2.2  Location area identification */
369     DE_EPS_CMN_MOB_ID,                          /* 9.9.2.3  Mobile identity */
370     DE_EPS_MS_CM_2,                             /* 9.9.2.4  Mobile station classmark 2 */
371     DE_EPS_MS_CM_3,                             /* 9.9.2.5  Mobile station classmark 3 */
372     DE_EPS_NAS_SEC_PAR_FROM_EUTRA,              /* 9.9.2.6  NAS security parameters from E-UTRA */
373     DE_EPS_NAS_SEC_PAR_TO_EUTRA,                /* 9.9.2.7  NAS security parameters to E-UTRA */
374
375     DE_EPS_CMN_PLM_LST,                         /* 9.9.2.8  PLMN list */
376     DE_EPS_CMN_SUP_CODEC_LST,                   /* 9.9.2.6  9.9.2.10    Supported codec list */
377     DE_EPS_COMMON_NONE                          /* NONE */
378 }
379 nas_eps_common_elem_idx_t;
380 /*
381  * 9.9.2    Common information elements
382  */
383
384 /* 9.9.2.0 Additional information */
385 static guint16
386 de_eps_cmn_add_info(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
387 {
388     proto_item *item;
389     proto_tree *sub_tree;
390     tvbuff_t *new_tvb;
391
392     item = proto_tree_add_item(tree, hf_nas_eps_cmn_add_info, tvb, offset, len, ENC_NA);
393     sub_tree = proto_item_add_subtree(item, ett_nas_eps_cmn_add_info);
394
395     new_tvb = tvb_new_subset(tvb, offset, len, len);
396
397     switch (eps_nas_gen_msg_cont_type) {
398     case 1:
399         /* LPP */
400         dissect_lcsap_Correlation_ID_PDU(new_tvb, pinfo, sub_tree);
401         break;
402     default:
403         break;
404     }
405
406     return(len);
407 }
408
409 /*
410  * 9.9.2.1  EPS bearer context status
411  */
412 static const true_false_string  nas_eps_emm_ebi_vals = {
413     "BEARER CONTEXT-ACTIVE",
414     "BEARER CONTEXT-INACTIVE"
415 };
416
417 static guint16
418 de_eps_cmn_eps_be_ctx_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
419 {
420     guint32 curr_offset;
421
422     curr_offset = offset;
423
424     /* EBI(7)  EBI(6)  EBI(5)  EBI(4)  EBI(3)  EBI(2)  EBI(1) EBI(0) octet 3 */
425     proto_tree_add_item(tree, hf_nas_eps_emm_ebi7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
426     proto_tree_add_item(tree, hf_nas_eps_emm_ebi6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
427     proto_tree_add_item(tree, hf_nas_eps_emm_ebi5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
428     /* EBI(0) - EBI(4): Bits 0 to 4 of octet 3 are spare and shall be coded as zero. */
429     proto_tree_add_item(tree, hf_nas_eps_emm_ebi4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
430     proto_tree_add_item(tree, hf_nas_eps_emm_ebi3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
431     proto_tree_add_item(tree, hf_nas_eps_emm_ebi2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
432     proto_tree_add_item(tree, hf_nas_eps_emm_ebi1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
433     proto_tree_add_item(tree, hf_nas_eps_emm_ebi0, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
434     curr_offset++;
435     /* EBI(15) EBI(14) EBI(13) EBI(12) EBI(11) EBI(10) EBI(9) EBI(8) octet 4 */
436     proto_tree_add_item(tree, hf_nas_eps_emm_ebi15, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
437     proto_tree_add_item(tree, hf_nas_eps_emm_ebi14, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
438     proto_tree_add_item(tree, hf_nas_eps_emm_ebi13, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
439     proto_tree_add_item(tree, hf_nas_eps_emm_ebi12, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
440     proto_tree_add_item(tree, hf_nas_eps_emm_ebi11, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
441     proto_tree_add_item(tree, hf_nas_eps_emm_ebi10, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
442     proto_tree_add_item(tree, hf_nas_eps_emm_ebi9, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
443     proto_tree_add_item(tree, hf_nas_eps_emm_ebi8, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
444
445     return len;
446 }
447 /*
448  * 9.9.2.2  Location area identification
449  * See subclause 10.5.1.3 in 3GPP TS 24.008 [6].
450  */
451 /*
452  * 9.9.2.3  Mobile identity
453  * See subclause 10.5.1.4 in 3GPP TS 24.008 [6].
454  * exported from gsm_a_common
455  */
456
457 /*
458  * 9.9.2.4  Mobile station classmark 2
459  * See subclause 10.5.1.6 in 3GPP TS 24.008 [13].
460  */
461 /*
462  * 9.9.2.5  Mobile station classmark 3
463  * See subclause 10.5.1.7 in 3GPP TS 24.008 [13].
464  */
465
466 /*
467  * 9.9.2.6  NAS security parameters from E-UTRA
468  */
469 guint16
470 de_emm_sec_par_from_eutra(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
471 {
472     guint32 curr_offset;
473
474     curr_offset = offset;
475
476     /* DL NAS COUNT value (short) (octet 2, bit 1 to 4)
477      * This field contains the 4 least significant bits of the binary representation of the downlink
478      * NAS COUNT value applicable when this information element is sent.
479      */
480     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
481     proto_tree_add_item(tree, hf_nas_eps_emm_dl_nas_cnt, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
482
483     return len;
484 }
485
486 /*
487  * 9.9.2.7  NAS security parameters to E-UTRA
488  */
489 guint16
490 de_emm_sec_par_to_eutra(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
491 {
492     guint32 curr_offset;
493
494     curr_offset = offset;
495     /* NonceMME value (octet 1 to 5)
496      * This field is coded as the nonce value in the Nonce information element (see subclause 9.9.3.25).
497      */
498     proto_tree_add_item(tree, hf_nas_eps_emm_nonce_mme, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
499     curr_offset+=4;
500     /* type of ciphering algorithm (octet 6, bit 5 to 7)
501      * These fields are coded as the type of integrity protection algorithm and type of ciphering algorithm
502      * in the NAS security algorithms information element (see subclause 9.9.3.23).
503      * Bit 4 and 8 of octet 6 are spare and shall be coded as zero.
504      */
505     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
506     proto_tree_add_item(tree, hf_nas_eps_emm_toc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
507     /* Type of integrity protection algorithm (octet 6, bit 1 to 3)*/
508     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, (curr_offset<<3)+4, 1, ENC_BIG_ENDIAN);
509     proto_tree_add_item(tree, hf_nas_eps_emm_toi, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
510     curr_offset++;
511     /*
512      * NAS key set identifier (octet 7, bit 1 to 3) and
513      * type of security context flag (TSC) (octet 7, bit 4)
514      * These fields are coded as the NAS key set identifier and type of security context flag in the
515      * NAS key set identifier information element (see subclause 9.9.3.21).
516      * Bit 5 to 8 of octet 7 are spare and shall be coded as zero.
517      */
518     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
519     /* Type of security context flag (TSC)  V   1/2 */
520     proto_tree_add_bits_item(tree, hf_nas_eps_tsc, tvb, (curr_offset<<3)+4, 1, ENC_BIG_ENDIAN);
521     /* NAS key set identifier */
522     proto_tree_add_bits_item(tree, hf_nas_eps_emm_nas_key_set_id, tvb, (curr_offset<<3)+5, 3, ENC_BIG_ENDIAN);
523     curr_offset++;
524     return len;
525 }
526
527 /*
528  * 9.9.2.8  PLMN list
529  * See subclause 10.5.1.13 in 3GPP TS 24.008 [6].
530  */
531 /*
532  * 9.9.2.9  Spare half octet
533  * This element is used in the description of EMM and ESM messages when an odd number of
534  * half octet type 1 information elements are used. This element is filled with spare bits
535  * set to zero and is placed in bits 5 to 8 of the octet unless otherwise specified.
536  * Coded Inline
537  */
538
539 /*
540  * 9.9.2.10 Supported codec list
541  * See subclause 10.5.4.32 in 3GPP TS 24.008 [13].
542  * Dissected in packet-gsm_a_dtap.c
543  */
544
545 guint16 (*nas_eps_common_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = {
546     /* 9.9.2    Common information elements */
547     de_eps_cmn_add_info,            /* 9.9.2.0  Additional information */
548     de_eps_cmn_eps_be_ctx_status,   /* 9.9.2.1  EPS bearer context status */
549     de_lai,                         /* 9.9.2.2  Location area identification */
550     de_mid,                         /* 9.9.2.3  Mobile identity See subclause 10.5.1.4 in 3GPP TS 24.008*/
551     de_ms_cm_2,                     /* 9.9.2.4  Mobile station classmark 2 */
552     de_ms_cm_3,                     /* 9.9.2.5  Mobile station classmark 3 */
553     de_emm_sec_par_from_eutra,      /* 9.9.2.6  NAS security parameters from E-UTRA */
554     de_emm_sec_par_to_eutra,        /* 9.9.2.7  NAS security parameters to E-UTRA */
555
556     de_plmn_list,                   /* 9.9.2.8  PLMN list */
557     NULL,                           /* 9.9.2.10 Supported codec list (packet-gsm_a_dtap.c) */
558     NULL,   /* NONE */
559 };
560
561 const value_string nas_emm_elem_strings[] = {
562     /* 9.9.3    EPS Mobility Management (EMM) information elements */
563     { 0x00, "Additional update result" },           /* 9.9.3.0A Additional update result */
564     { 0x00, "Additional update type" },             /* 9.9.3.0B Additional update type */
565     { 0x00, "Authentication failure parameter" },   /* 9.9.3.1  Authentication failure parameter */
566     { 0x00, "Authentication parameter AUTN" },      /* 9.9.3.2  Authentication parameter AUTN */
567     { 0x00, "Authentication parameter RAND" },      /* 9.9.3.3  Authentication parameter RAND */
568     { 0x00, "Authentication response parameter" },  /* 9.9.3.4  Authentication response parameter */
569     { 0x00, "CSFB response" },                      /* 9.9.3.5  CSFB response */
570     { 0x00, "Daylight saving time" },               /* 9.9.3.6  Daylight saving time */
571     { 0x00, "Detach type" },                        /* 9.9.3.7  Detach type */
572     { 0x00, "DRX parameter" },                      /* 9.9.3.8  DRX parameter */
573     { 0x00, "EMM cause" },                          /* 9.9.3.9  EMM cause */
574     { 0x00, "EPS attach result" },                  /* 9.9.3.10 EPS attach result */
575     { 0x00, "EPS attach type" },                    /* 9.9.3.11 EPS attach type */
576     { 0x00, "EPS mobile identity" },                /* 9.9.3.12 EPS mobile identity */
577     { 0x00, "EPS network feature support" },        /* 9.9.3.12 EPS mobile identity */
578     { 0x00, "EPS update result" },                  /* 9.9.3.13 EPS update result */
579     { 0x00, "EPS update type" },                    /* 9.9.3.14 EPS update type */
580     { 0x00, "ESM message container" },              /* 9.9.3.15 ESM message conta */
581     { 0x00, "GPRS timer" },                         /* 9.9.3.16 GPRS timer ,See subclause 10.5.7.3 in 3GPP TS 24.008 [6]. */
582     { 0x00, "Identity type 2" },                    /* 9.9.3.17 Identity type 2 ,See subclause 10.5.5.9 in 3GPP TS 24.008 [6]. */
583     { 0x00, "IMEISV request" },                     /* 9.9.3.18 IMEISV request ,See subclause 10.5.5.10 in 3GPP TS 24.008 [6]. */
584     { 0x00, "KSI and sequence number" },            /* 9.9.3.19 KSI and sequence number */
585     { 0x00, "MS network capability" },              /* 9.9.3.20 MS network capability ,See subclause 10.5.5.12 in 3GPP TS 24.008 [6]. */
586     { 0x00, "NAS key set identifier" },             /* 9.9.3.21 NAS key set identifier */
587     { 0x00, "NAS message container" },              /* 9.9.3.22 NAS message container */
588     { 0x00, "NAS security algorithms" },            /* 9.9.3.23 NAS security algorithms */
589     { 0x00, "Network name" },                       /* 9.9.3.24 Network name, See subclause 10.5.3.5a in 3GPP TS 24.008 [6]. */
590     { 0x00, "Nonce" },                              /* 9.9.3.25 Nonce */
591     { 0x00, "Paging identity" },                    /* 9.9.3.25A Paging identity */
592     { 0x00, "P-TMSI signature" },                   /* 9.9.3.26 P-TMSI signature, See subclause 10.5.5.8 in 3GPP TS 24.008 [6]. */
593     { 0x00, "Service type" },                       /* 9.9.3.27 Service type ,See subclause 10.5.5.15 in 3GPP TS 24.008 [6]. */
594     { 0x00, "Short MAC" },                          /* 9.9.3.28 Short MAC */
595     { 0x00, "Time zone" },                          /* 9.9.3.29 Time zone, See subclause 10.5.3.8 in 3GPP TS 24.008 [6]. */
596     { 0x00, "Time zone and time" },                 /* 9.9.3.30 Time zone and time, See subclause 10.5.3.9 in 3GPP TS 24.008 [6]. */
597     { 0x00, "TMSI status" },                        /* 9.9.3.31 TMSI status, See subclause 10.5.5.4 in 3GPP TS 24.008 [6]. */
598     { 0x00, "Tracking area identity" },             /* 9.9.3.32 Tracking area identity */
599     { 0x00, "Tracking area identity list" },        /* 9.9.3.33 Tracking area identity list */
600     { 0x00, "UE network capability" },              /* 9.9.3.34 UE network capability */
601     { 0x00, "UE radio capability information update needed" },  /* 9.9.3.35 UE radio capability information update needed */
602     { 0x00, "UE security capability" },             /* 9.9.3.36 UE security capability */
603     { 0x00, "Emergency Number List" },              /* 9.9.3.37 Emergency Number List */
604     { 0x00, "CLI" },                                /* 9.9.3.38 CLI */
605     { 0x00, "SS Code" },                            /* 9.9.3.39 SS Code */
606     { 0x00, "LCS indicator" },                      /* 9.9.3.40 LCS indicator */
607     { 0x00, "LCS client identity" },                /* 9.9.3.41 LCS client identity */
608     { 0x00, "Generic message container type" },     /* 9.9.3.42 Generic message container type */
609     { 0x00, "Generic message container" },          /* 9.9.3.43 Generic message container */
610     { 0x00, "Voice domain preference and UEs usage setting" }, /* 9.9.3.44 Voice domain preference and UEs usage setting */
611     { 0, NULL }
612 };
613 #define NUM_NAS_EMM_ELEM (sizeof(nas_emm_elem_strings)/sizeof(value_string))
614 gint ett_nas_eps_emm_elem[NUM_NAS_EMM_ELEM];
615
616 #if 0
617 This enum has been moved to packet-gsm_a_common to
618 make it possible to use element dissection from this dissector
619 in other dissectors.
620 It is left here as a comment for easier reference.
621
622 Note this enum must be of the same size as the element decoding list
623
624 typedef enum
625 {
626     /. 9.9.3    EPS Mobility Management (EMM) information elements ./
627     DE_EMM_ADD_UPD_RES,         /. 9.9.3.0A Additional update result ./
628     DE_EMM_ADD_UPD_TYPE,        /. 9.9.3.0B Additional update type ./
629     DE_EMM_AUTH_FAIL_PAR,       /. 9.9.3.1  Authentication failure parameter (dissected in packet-gsm_a_dtap.c)./
630     DE_EMM_AUTN,                /. 9.9.3.2  Authentication parameter AUTN ./
631     DE_EMM_AUTH_PAR_RAND,       /. 9.9.3.3  Authentication parameter RAND ./
632     DE_EMM_AUTH_RESP_PAR,       /. 9.9.3.4  Authentication response parameter ./
633     DE_EMM_CSFB_RESP,           /. 9.9.3.5  CSFB response ./
634     DE_EMM_DAYL_SAV_T,          /. 9.9.3.6  Daylight saving time ./
635     DE_EMM_DET_TYPE,            /. 9.9.3.7  Detach type ./
636     DE_EMM_DRX_PAR,             /. 9.9.3.8  DRX parameter (dissected in packet-gsm_a_gm.c)./
637     DE_EMM_CAUSE,               /. 9.9.3.9  EMM cause ./
638     DE_EMM_ATT_RES,             /. 9.9.3.10 EPS attach result (Coded inline ./
639     DE_EMM_ATT_TYPE,            /. 9.9.3.11 EPS attach type (Coded Inline)./
640     DE_EMM_EPS_MID,             /. 9.9.3.12 EPS mobile identity ./
641     DE_EMM_EPS_NET_FEATURE_SUP, /. 9.9.3.12A EPS network feature support ./
642     DE_EMM_EPS_UPD_RES,         /. 9.9.3.13 EPS update result ( Coded inline)./
643     DE_EMM_EPS_UPD_TYPE,        /. 9.9.3.14 EPS update type ./
644     DE_EMM_ESM_MSG_CONT,        /. 9.9.3.15 ESM message conta ./
645     DE_EMM_GPRS_TIMER,          /. 9.9.3.16 GPRS timer ,See subclause 10.5.7.3 in 3GPP TS 24.008 [6]. ./
646     DE_EMM_ID_TYPE_2,           /. 9.9.3.17 Identity type 2 ,See subclause 10.5.5.9 in 3GPP TS 24.008 [6]. ./
647     DE_EMM_IMEISV_REQ,          /. 9.9.3.18 IMEISV request ,See subclause 10.5.5.10 in 3GPP TS 24.008 [6]. ./
648     DE_EMM_KSI_AND_SEQ_NO,      /. 9.9.3.19 KSI and sequence number ./
649     DE_EMM_MS_NET_CAP,          /. 9.9.3.20 MS network capability ,See subclause 10.5.5.12 in 3GPP TS 24.008 [6]. ./
650     DE_EMM_NAS_KEY_SET_ID,      /. 9.9.3.21 NAS key set identifier (coded inline)./
651     DE_EMM_NAS_MSG_CONT,        /. 9.9.3.22 NAS message container ./
652     DE_EMM_NAS_SEC_ALGS,        /. 9.9.3.23 NAS security algorithms ./
653     DE_EMM_NET_NAME,            /. 9.9.3.24 Network name, See subclause 10.5.3.5a in 3GPP TS 24.008 [6]. ./
654     DE_EMM_NONCE,               /. 9.9.3.25 Nonce ./
655     DE_EMM_PAGING_ID,           /. 9.9.3.25A Paging identity ./
656     DE_EMM_P_TMSI_SIGN,         /. 9.9.3.26 P-TMSI signature, See subclause 10.5.5.8 in 3GPP TS 24.008 [6]. ./
657     DE_EMM_SERV_TYPE,           /. 9.9.3.27 Service type ./
658     DE_EMM_SHORT_MAC,           /. 9.9.3.28 Short MAC ./
659     DE_EMM_TZ,                  /. 9.9.3.29 Time zone, See subclause 10.5.3.8 in 3GPP TS 24.008 [6]. ./
660     DE_EMM_TZ_AND_T,            /. 9.9.3.30 Time zone and time, See subclause 10.5.3.9 in 3GPP TS 24.008 [6]. ./
661     DE_EMM_TMSI_STAT,           /. 9.9.3.31 TMSI status, See subclause 10.5.5.4 in 3GPP TS 24.008 [6]. ./
662     DE_EMM_TRAC_AREA_ID,        /. 9.9.3.32 Tracking area identity ./
663     DE_EMM_TRAC_AREA_ID_LST,    /. 9.9.3.33 Tracking area identity list ./
664     DE_EMM_UE_NET_CAP,          /. 9.9.3.34 UE network capability ./
665     DE_EMM_UE_RA_CAP_INF_UPD_NEED,  /. 9.9.3.35 UE radio capability information update needed ./
666     DE_EMM_UE_SEC_CAP,          /. 9.9.3.36 UE security capability ./
667     DE_EMM_EMERG_NUM_LST,       /. 9.9.3.37 Emergency Number List ./
668     DE_EMM_CLI,                 /. 9.9.3.38 CLI ./
669     DE_EMM_SS_CODE,             /. 9.9.3.39 SS Code ./
670     DE_EMM_LCS_IND,             /. 9.9.3.40 LCS indicator ./
671     DE_EMM_LCS_CLIENT_ID,       /. 9.9.3.41 LCS client identity ./
672     DE_EMM_GEN_MSG_CONT_TYPE,   /. 9.9.3.42 Generic message container type ./
673     DE_EMM_GEN_MSG_CONT,        /. 9.9.3.43 Generic message container ./
674     DE_EMM_VOICE_DMN_PREF,      /. 9.9.3.44 Voice domain preference and UEs usage setting ./
675     DE_EMM_NONE                 /. NONE ./
676
677 }
678 nas_emm_elem_idx_t;
679
680 #endif
681 /* TODO: Update to latest spec */
682 /* 9.9.3    EPS Mobility Management (EMM) information elements
683  */
684 /*
685  * 9.9.3.0A  Additional update result
686  */
687 static const value_string nas_eps_emm_add_upd_res_vals[] = {
688     { 0x0, "no additional information"},
689     { 0x1, "CS Fallback not preferred"},
690     { 0x2, "SMS only"},
691     { 0x3, "reserved"},
692     { 0, NULL }
693 };
694 static guint16
695 de_emm_add_upd_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
696 {
697     guint32 curr_offset, bit_offset;
698
699     curr_offset = offset;
700     bit_offset = (curr_offset<<3)+4;
701
702     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
703     bit_offset += 2;
704     proto_tree_add_bits_item(tree, hf_nas_eps_emm_add_upd_res, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
705     curr_offset++;
706
707     return (curr_offset - offset);
708 }
709 /*
710  * 9.9.3.0B  Additional update type
711  */
712 static const value_string nas_eps_emm_add_upd_type_vals[] = {
713     { 0x0, "no additional information (shall be interpreted as request for combined attach or combined tracking area updating)"},
714     { 0x1, "SMS only"},
715     { 0, NULL }
716 };
717 static guint16
718 de_emm_add_upd_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
719 {
720     guint32 curr_offset, bit_offset;
721
722     curr_offset = offset;
723     bit_offset = (curr_offset<<3)+4;
724
725     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
726     bit_offset += 3;
727     proto_tree_add_bits_item(tree, hf_nas_eps_emm_add_upd_type, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
728     curr_offset++;
729
730     return (curr_offset - offset);
731 }
732 /*
733  * 9.9.3.1  Authentication failure parameter
734  * See subclause 10.5.3.2.2 in 3GPP TS 24.008 [6].
735  * (dissected in packet-gsm_a_dtap.c)
736  */
737 /*
738  * 9.9.3.2  Authentication parameter AUTN
739  * See subclause 10.5.3.1.1 in 3GPP TS 24.008 [6].
740  */
741 /*
742  * 9.9.3.3  Authentication parameter RAND
743  * See subclause 10.5.3.1 in 3GPP TS 24.008 [6].
744  */
745 /*
746  * 9.9.3.4  Authentication response parameter
747  */
748 static guint16
749 de_emm_auth_resp_par(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
750 {
751     guint32 curr_offset;
752
753     curr_offset = offset;
754
755     proto_tree_add_item(tree, hf_nas_eps_emm_res, tvb, curr_offset, len, ENC_NA);
756
757     return len;
758 }
759 /*
760  * 9.9.3.4A Ciphering key sequence number
761  * See subclause 9.9.3.19 in 3GPP TS 24.008 [13].
762  */
763
764 /*
765  * 9.9.3.5  CSFB response
766  */
767
768 /*
769  * CSFB response value (octet 1)
770  */
771
772 static const value_string nas_eps_emm_csfb_resp_vals[] = {
773     { 0x0,  "CS fallback rejected by the UE"},
774     { 0x1,  "CS fallback accepted by the UE"},
775     { 0, NULL }
776 };
777
778 static guint16
779 de_emm_csfb_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
780 {
781     guint32 curr_offset, bit_offset;
782
783     curr_offset = offset;
784
785     /* bit 4 Spare */
786     bit_offset = curr_offset<<3;
787     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset+4, 1, ENC_BIG_ENDIAN);
788
789     proto_tree_add_item(tree, hf_nas_eps_emm_csfb_resp, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
790     curr_offset++;
791
792     return(curr_offset-offset);
793 }
794 /*
795  * 9.9.3.6  Daylight saving time
796  * See subclause 10.5.3.12 in 3GPP TS 24.008 [6].
797  */
798 /*
799  * 9.9.3.7  Detach type
800  * Coded inline
801  */
802 static const value_string nas_eps_emm_switch_off_vals[] = {
803     { 0x0,  "Normal detach"},
804     { 0x1,  "Switch off"},
805     { 0x2,  "Reserved"},
806     { 0x3,  "Reserved"},
807     { 0x4,  "Reserved"},
808     { 0x5,  "Reserved"},
809     { 0x6,  "Reserved"},
810     { 0x7,  "Reserved"},
811     { 0, NULL }
812 };
813 /* Type of detach (octet 1)
814  * In the UE to network direction:
815  */
816 static const value_string nas_eps_emm_type_of_dtatch_UL_vals[] = {
817     { 0x1,  "EPS detach"},
818     { 0x2,  "IMSI detach"},
819     { 0x3,  "Combined EPS/IMSI detach"},
820     { 0x4,  "Combined EPS/IMSI detach"}, /* All other values are interpreted as "combined EPS/IMSI detach" in this version of the protocol.*/
821     { 0x5,  "Combined EPS/IMSI detach"}, /* -"- */
822     { 0x6,  "Reserved"},
823     { 0x7,  "Reserved"},
824     { 0, NULL }
825 };
826
827 /*
828  * In the network to UE direction:
829  */
830
831 static const value_string nas_eps_emm_type_of_dtatch_DL_vals[] = {
832     { 0x1,  "Re-attach required"},
833     { 0x2,  "Re-attach not required"},
834     { 0x3,  "IMSI detach"},
835     { 0x4,  "Re-attach not required"}, /* All other values are interpreted as "re-attach not required" in this version of the protocol.*/
836     { 0x5,  "Re-attach not required"}, /* -"- */
837     { 0x6,  "Reserved"},
838     { 0x7,  "Reserved"},
839     { 0, NULL }
840 };
841
842 /*
843  * 9.9.3.8  DRX parameter
844  * See subclause 10.5.5.6 in 3GPP TS 24.008 [13].
845  */
846 /*
847  * 9.9.3.9  EMM cause
848  */
849 static const value_string nas_eps_emm_cause_values[] = {
850     { 0x2,  "IMSI unknown in HSS"},
851     { 0x3,  "Illegal UE"},
852     { 0x5,  "IMEI not accepted"},
853     { 0x6,  "Illegal ME"},
854     { 0x7,  "EPS services not allowed"},
855     { 0x8,  "EPS services and non-EPS services not allowed"},
856     { 0x9,  "UE identity cannot be derived by the network"},
857     { 0xa,  "Implicitly detached"},
858     { 0xb,  "PLMN not allowed"},
859     { 0xc,  "Tracking Area not allowed"},
860     { 0xd,  "Roaming not allowed in this tracking area"},
861     { 0xe,  "EPS services not allowed in this PLMN"},
862     { 0xf,  "No Suitable Cells In tracking area"},
863     { 0x10, "MSC temporarily not reachable"},
864     { 0x11, "Network failure"},
865     { 0x12, "CS domain not available"},
866     { 0x13, "ESM failure"},
867     { 0x14, "MAC failure"},
868     { 0x15, "Synch failure"},
869     { 0x16, "Congestion"},
870     { 0x17, "UE security capabilities mismatch"},
871     { 0x18, "Security mode rejected, unspecified"},
872     { 0x19, "Not authorized for this CSG"},
873     { 0x1a, "Non-EPS authentication unacceptable"},
874     { 0x27, "CS domain temporarily not available"},
875     { 0x28, "No EPS bearer context activated"},
876     { 0x5f, "Semantically incorrect message"},
877     { 0x60, "Invalid mandatory information"},
878     { 0x61, "Message type non-existent or not implemented"},
879     { 0x62, "Message type not compatible with the protocol state"},
880     { 0x63, "Information element non-existent or not implemented"},
881     { 0x64, "Conditional IE error"},
882     { 0x65, "Message not compatible with the protocol state"},
883     { 0x6f, "Protocol error, unspecified"},
884     { 0, NULL }
885 };
886
887 static guint16
888 de_emm_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
889 {
890     guint32 curr_offset;
891
892     curr_offset = offset;
893
894     proto_tree_add_item(tree, hf_nas_eps_emm_cause, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
895     curr_offset++;
896
897     return curr_offset-offset;}
898 /*
899  * 9.9.3.10 EPS attach result
900  */
901
902 static const value_string nas_eps_emm_EPS_attach_result_values[] = {
903     { 0,    "reserved"},
904     { 1,    "EPS only"},
905     { 2,    "Combined EPS/IMSI attach"},
906     { 3,    "reserved"},
907     { 4,    "reserved"},
908     { 5,    "reserved"},
909     { 6,    "reserved"},
910     { 7,    "reserved"},
911     { 0, NULL }
912 };
913 /* Coded inline */
914
915 /*
916  * 9.9.3.11 EPS attach type
917  */
918
919 static const value_string nas_eps_emm_eps_att_type_vals[] = {
920     { 0,    "EPS attach(unused)"},
921     { 1,    "EPS attach"},
922     { 2,    "Combined handover EPS/IMSI attach"},
923     { 3,    "EPS attach(unused)"},
924     { 4,    "EPS attach(unused)"},
925     { 5,    "EPS attach(unused)"},
926     { 6,    "EPS emergency attach"},
927     { 7,    "Reserved"},
928     { 0, NULL }
929 };
930 /* Coded inline */
931
932 /*
933  * 9.9.3.12 EPS mobile identity
934  */
935 static char *
936 unpack_eps_mid_digits(tvbuff_t *tvb) {
937
938     int length;
939     guint8 octet;
940     int i=0;
941     int offset = 0;
942     char *digit_str;
943
944     length = tvb_length(tvb);
945
946     digit_str = ep_alloc(length*2);
947
948     /* Get identity digit 1 */
949     octet = tvb_get_guint8(tvb,offset);
950     digit_str[i++] = (((octet>>4) & 0x0f) + '0');
951     offset++;
952
953     /* Loop on following octets to retrieve other identity digits */
954     while ( offset < length ){
955
956         octet = tvb_get_guint8(tvb,offset);
957         digit_str[i] = ((octet & 0x0f) + '0');
958         i++;
959
960         /*
961          * unpack second value in byte
962          */
963         octet = octet >> 4;
964
965         if (octet == 0x0f)  /* odd number bytes - hit filler */
966             break;
967
968         digit_str[i] = ((octet & 0x0f) + '0');
969         i++;
970         offset++;
971
972     }
973     digit_str[i]= '\0';
974     return digit_str;
975 }
976
977 static const value_string nas_eps_emm_type_of_id_vals[] = {
978     { 0,    "reserved"},
979     { 1,    "IMSI"},
980     { 2,    "reserved"},
981     { 3,    "IMEI"},
982     { 4,    "reserved"},
983     { 5,    "reserved"},
984     { 6,    "GUTI"},
985     { 7,    "reserved"},
986     { 0, NULL }
987 };
988 static guint16
989 de_emm_eps_mid(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
990 {
991     guint32 curr_offset;
992     guint8 octet;
993     char    *digit_str;
994     tvbuff_t *new_tvb;
995
996     curr_offset = offset;
997
998     octet = tvb_get_guint8(tvb,offset);
999     /* Type of identity (octet 3) */
1000     proto_tree_add_item(tree, hf_nas_eps_emm_odd_even, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1001     proto_tree_add_item(tree, hf_nas_eps_emm_type_of_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1002     switch (octet&0x7){
1003         case 1:
1004             /* IMSI */
1005             new_tvb = tvb_new_subset(tvb, curr_offset, len, len );
1006             digit_str = unpack_eps_mid_digits(new_tvb);
1007             proto_tree_add_string(tree, hf_nas_eps_emm_imsi, new_tvb, 0, -1, digit_str);
1008             break;
1009         case 3:
1010             /* IMEI */
1011             new_tvb = tvb_new_subset(tvb, curr_offset, len, len );
1012             digit_str = unpack_eps_mid_digits(new_tvb);
1013             proto_tree_add_string(tree, hf_nas_eps_emm_imei, new_tvb, 0, -1, digit_str);
1014             break;
1015         case 6:
1016             /* GUTI */
1017             curr_offset++;
1018             curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE);
1019             /* MME Group ID octet 7 - 8 */
1020             proto_tree_add_item(tree, hf_nas_eps_emm_mme_grp_id, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1021             curr_offset+=2;
1022             /* MME Code Octet 9 */
1023             proto_tree_add_item(tree, hf_nas_eps_emm_mme_code, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1024             curr_offset++;
1025             /* M-TMSI Octet 10 - 13 */
1026             proto_tree_add_item(tree, hf_nas_eps_emm_m_tmsi, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
1027             curr_offset+=4;
1028             break;
1029         default:
1030             proto_tree_add_text(tree, tvb, curr_offset, len - 1, "Type of identity not known");
1031             break;
1032     }
1033
1034     return(len);
1035 }
1036
1037 /*
1038  * 9.9.3.12A    EPS network feature support
1039  */
1040 static const value_string nas_eps_emm_cs_lcs_vals[] = {
1041     { 0,    "no information about support of location services via CS domain is available"},
1042     { 1,    "location services via CS domain not supported"},
1043     { 2,    "location services via CS domain supported"},
1044     { 3,    "reserved"},
1045     { 0, NULL }
1046 };
1047 static const true_false_string nas_eps_emm_epc_lcs_value = {
1048     "location services via EPC supported",
1049     "location services via EPC not supported"
1050 };
1051 static const true_false_string nas_eps_emm_emc_bs_value = {
1052     "emergency bearer services in S1 mode supported",
1053     "emergency bearer services in S1 mode not supported"
1054 };
1055 static const true_false_string nas_eps_emm_ims_vops_value = {
1056     "IMS voice over PS session in S1 mode supported",
1057     "IMS voice over PS session in S1 mode not supported"
1058 };
1059
1060 static guint16
1061 de_emm_eps_net_feature_sup(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1062 {
1063     guint32 curr_offset, bit_offset;
1064
1065     curr_offset = offset;
1066     bit_offset = curr_offset << 3;
1067     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
1068     bit_offset += 3;
1069     proto_tree_add_bits_item(tree, hf_nas_eps_emm_cs_lcs_type, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
1070     bit_offset += 2;
1071     proto_tree_add_bits_item(tree, hf_nas_eps_emm_epc_lcs_type, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1072     bit_offset += 1;
1073     proto_tree_add_bits_item(tree, hf_nas_eps_emm_emc_bs_type, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1074     bit_offset += 1;
1075     proto_tree_add_bits_item(tree, hf_nas_eps_emm_ims_vops_type, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1076     bit_offset += 1;
1077
1078     return len;
1079 }
1080 /*
1081  * 9.9.3.13 EPS update result
1082  */
1083 static const value_string nas_eps_emm_eps_update_result_vals[] = {
1084     { 0,    "TA updated"},
1085     { 1,    "Combined TA/LA updated"},
1086     { 2,    "Reserved"},
1087     { 3,    "Reserved"},
1088     { 4,    "TA updated and ISR activated"},
1089     { 5,    "Combined TA/LA updated and ISR activated"},
1090     { 6,    "Reserved"},
1091     { 7,    "Reserved"},
1092     { 0, NULL }
1093 };
1094
1095 /*
1096  * 9.9.3.14 EPS update type
1097  */
1098 static const true_false_string  nas_eps_emm_active_flg_value = {
1099     "Bearer establishment requested",
1100     "No bearer establishment requested"
1101 };
1102
1103 static const value_string nas_eps_emm_eps_update_type_vals[] = {
1104     { 0,    "TA updating"},
1105     { 1,    "Combined TA/LA updating"},
1106     { 2,    "Combined TA/LA updating with IMSI attach"},
1107     { 3,    "Periodic updating"},
1108     { 4,    "Unused; shall be interpreted as 'TA updating', if received by the network"},
1109     { 5,    "Unused; shall be interpreted as 'TA updating', if received by the network"},
1110     { 6,    "Reserved"},
1111     { 7,    "Reserved"},
1112     { 0, NULL }
1113 };
1114
1115 /*
1116  * 9.9.3.15 ESM message container
1117  */
1118 static guint16
1119 de_emm_esm_msg_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1120 {
1121     proto_item *item;
1122     proto_tree *sub_tree;
1123     tvbuff_t    *new_tvb;
1124     guint32 curr_offset;
1125
1126     curr_offset = offset;
1127
1128
1129     item = proto_tree_add_item(tree, hf_nas_eps_esm_msg_cont, tvb, curr_offset, len, ENC_NA);
1130     sub_tree = proto_item_add_subtree(item, ett_nas_eps_esm_msg_cont);
1131
1132     /* This IE can contain any ESM PDU as defined in subclause 8.3. */
1133     new_tvb = tvb_new_subset(tvb, curr_offset, len, len );
1134     /* Plain NAS message */
1135     disect_nas_eps_esm_msg(new_tvb, gpinfo, sub_tree, 0/* offset */);
1136
1137     return(len);
1138 }
1139 /*
1140  * 9.9.3.16 GPRS timer
1141  * See subclause 10.5.7.3 in 3GPP TS 24.008 [6].
1142  * packet-gsm_a_gm.c
1143  */
1144 /*
1145  * 9.9.3.17 Identity type 2
1146  * See subclause 10.5.5.9 in 3GPP TS 24.008 [6].
1147  */
1148 static const value_string nas_eps_emm_id_type2_vals[] = {
1149     { 1,    "IMSI"},
1150     { 2,    "IMEI"},
1151     { 3,    "IMEISV"},
1152     { 4,    "TMSI"},
1153     { 0, NULL }
1154 };
1155
1156 /*
1157  * 9.9.3.18 IMEISV request
1158  * See subclause 10.5.5.10 in 3GPP TS 24.008 [6].
1159  */
1160 /* IMEISV request value (octet 1) */
1161 static const value_string nas_eps_emm_imeisv_req_vals[] = {
1162     { 0,    "IMEISV not requested"},
1163     { 1,    "IMEISV requested"},
1164     { 2,    "IMEISV not requested"},
1165     { 3,    "IMEISV not requested"},
1166     { 4,    "IMEISV not requested"},
1167     { 5,    "IMEISV not requested"},
1168     { 6,    "IMEISV not requested"},
1169     { 7,    "IMEISV not requested"},
1170     { 0, NULL }
1171 };
1172 static guint16
1173 de_emm_nas_imeisv_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1174 {
1175     guint32 curr_offset;
1176     int bit_offset;
1177
1178     curr_offset = offset;
1179
1180     bit_offset = curr_offset<<3;
1181     bit_offset+=4;
1182     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1183     proto_tree_add_item(tree, hf_nas_eps_esm_imeisv_req, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1184     curr_offset++;
1185
1186     return(curr_offset - offset);
1187 }
1188 /*
1189  * 9.9.3.19 KSI and sequence number
1190  */
1191 static guint16
1192 de_emm_nas_ksi_and_seq_no(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1193 {
1194     guint32 curr_offset;
1195     int bit_offset;
1196
1197     curr_offset = offset;
1198     bit_offset = curr_offset<<3;
1199
1200     proto_tree_add_bits_item(tree, hf_nas_eps_emm_nas_key_set_id, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
1201     bit_offset += 3;
1202     proto_tree_add_bits_item(tree, hf_nas_eps_seq_no_short, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
1203     curr_offset++;
1204
1205     return(curr_offset - offset);
1206 }
1207
1208 /*
1209  * 9.9.3.20 MS network capability
1210  * See subclause 10.5.5.12 in 3GPP TS 24.008 [6].
1211  */
1212 /*
1213  * 9.9.3.21 NAS key set identifier
1214  */
1215 /*
1216  * Type of security context flag (TSC) (octet 1)
1217  */
1218 static const value_string nas_eps_tsc_vals[] = {
1219     { 0,    "Native security context (for KSIasme)"},
1220     { 1,    "Mapped security context (for KSIsgsn)"},
1221     { 0, NULL }
1222 };
1223
1224 /* NAS key set identifier (octet 1) Bits 3  2   1 */
1225
1226 static const value_string nas_eps_emm_NAS_key_set_identifier_vals[] = {
1227     { 0,    ""},
1228     { 1,    ""},
1229     { 2,    ""},
1230     { 3,    ""},
1231     { 4,    ""},
1232     { 5,    ""},
1233     { 6,    ""},
1234     { 7,    "No key is available"},
1235     { 0, NULL }
1236 };
1237
1238 /* Takes bit offset as input and consumes 4 bits */
1239 static void
1240 de_emm_nas_key_set_id_bits(tvbuff_t *tvb, proto_tree *tree, guint32 bit_offset, const gchar *add_string)
1241 {
1242     proto_item *item;
1243
1244     /* Type of security context flag (TSC) (octet 1)    V   1/2 */
1245     proto_tree_add_bits_item(tree, hf_nas_eps_tsc, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1246     bit_offset++;
1247     /* NAS key set identifier (octet 1) */
1248     item = proto_tree_add_bits_item(tree, hf_nas_eps_emm_nas_key_set_id, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
1249     if(add_string){
1250         proto_item_append_text(item, "%s", add_string);
1251     }
1252     bit_offset+=3;
1253 }
1254 /*
1255  * Note used for TV Short
1256  */
1257 static guint16
1258 de_emm_nas_key_set_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1259 {
1260     guint32 curr_offset, bit_offset;
1261
1262     curr_offset = offset;
1263
1264     /* Get the bit offset of the lover half of the octet bits 4 - 1 */
1265     bit_offset = curr_offset<<3;
1266     bit_offset+=4;
1267
1268     /* Type of security context flag (TSC) (octet 1)    V   1/2 */
1269     proto_tree_add_bits_item(tree, hf_nas_eps_tsc, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1270     bit_offset++;
1271     /* NAS key set identifier (octet 1) */
1272     proto_tree_add_bits_item(tree, hf_nas_eps_emm_nas_key_set_id, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
1273     bit_offset+=3;
1274     curr_offset++;
1275
1276     return(curr_offset - offset);
1277 }
1278
1279 /*
1280  * 9.9.3.22 NAS message container
1281  */
1282 static guint16
1283 de_emm_nas_msg_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1284 {
1285     proto_item *item;
1286     proto_tree *sub_tree;
1287     tvbuff_t *new_tvb;
1288     guint32 curr_offset;
1289
1290     curr_offset = offset;
1291
1292     /* NAS message container contents (octet 3 to octet n)
1293      * This IE can contain an SMS message (i.e. CP-DATA, CP-ACK or CP-ERROR)
1294      * as defined in subclause 7.2 in 3GPP TS 24.011 [13A].
1295      */
1296
1297     item = proto_tree_add_item(tree, hf_nas_eps_nas_msg_cont, tvb, curr_offset, len, ENC_NA);
1298     sub_tree = proto_item_add_subtree(item, ett_nas_eps_nas_msg_cont);
1299
1300     new_tvb = tvb_new_subset(tvb, curr_offset, len, len );
1301     if(gsm_a_dtap_handle)
1302         call_dissector(gsm_a_dtap_handle, new_tvb, gpinfo, sub_tree);
1303
1304     return(len);
1305 }
1306 /*
1307  * 9.9.3.23 NAS security algorithms
1308  */
1309 /* Type of integrity protection algorithm (octet 2, bit 1 to 3) */
1310 static const value_string nas_eps_emm_toi_vals[] = {
1311     { 0,    "EPS integrity algorithm EIA0 (null integrity protection algorithm)"},
1312     { 1,    "EPS integrity algorithm 128-EIA1"},
1313     { 2,    "EPS integrity algorithm 128-EIA2"},
1314     { 3,    "EPS integrity algorithm EIA3"},
1315     { 4,    "EPS integrity algorithm EIA4"},
1316     { 5,    "EPS integrity algorithm EIA5"},
1317     { 6,    "EPS integrity algorithm EIA6"},
1318     { 7,    "EPS integrity algorithm EIA7"},
1319     { 0, NULL }
1320 };
1321
1322 /* Type of ciphering algorithm (octet 2, bit 5 to 7) */
1323
1324 static const value_string nas_eps_emm_toc_vals[] = {
1325     { 0,    "EPS encryption algorithm EEA0 (null ciphering algorithm)"},
1326     { 1,    "EPS encryption algorithm 128-EEA1"},
1327     { 2,    "EPS encryption algorithm 128-EEA2"},
1328     { 3,    "EPS encryption algorithm EEA3"},
1329     { 4,    "EPS encryption algorithm EEA4"},
1330     { 5,    "EPS encryption algorithm EEA5"},
1331     { 6,    "EPS encryption algorithm EEA6"},
1332     { 7,    "EPS encryption algorithm EEA7"},
1333     { 0, NULL }
1334 };
1335 static guint16
1336 de_emm_nas_sec_alsgs(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1337 {
1338     int bit_offset;
1339     guint32 curr_offset;
1340
1341     curr_offset = offset;
1342
1343     bit_offset = offset<<3;
1344     /* Bit 4 and 8 of octet 2 are spare and shall be coded as zero. */
1345     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1346     /* Type of ciphering algorithm (octet 2, bit 5 to 7) */
1347     proto_tree_add_item(tree, hf_nas_eps_emm_toc, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1348     bit_offset+=4;
1349     /* Bit 4 and 8 of octet 2 are spare and shall be coded as zero. */
1350     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1351     /* Type of integrity protection algorithm (octet 2, bit 1 to 3) */
1352     proto_tree_add_item(tree, hf_nas_eps_emm_toi, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1353
1354     curr_offset++;
1355
1356     return(curr_offset-offset);
1357 }
1358 /*
1359  * 9.9.3.24 Network name
1360  * See subclause 10.5.3.5a in 3GPP TS 24.008 [6].
1361  */
1362 /*
1363  * 9.9.3.25 Nonce
1364  */
1365 static guint16
1366 de_emm_nonce(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1367 {
1368     guint32 curr_offset;
1369
1370     curr_offset = offset;
1371
1372     proto_tree_add_item(tree, hf_nas_eps_emm_nonce, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
1373     curr_offset+=4;
1374
1375     return(len);
1376 }
1377 /*
1378  * 9.9.3.25A Paging identity
1379  */
1380  static const true_false_string nas_eps_emm_paging_id_vals = {
1381     "TMSI",
1382     "IMSI"
1383 };
1384
1385 static guint16
1386 de_emm_paging_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1387 {
1388     guint32 curr_offset;
1389
1390     curr_offset = offset;
1391
1392     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 7, ENC_BIG_ENDIAN);
1393     proto_tree_add_bits_item(tree, hf_nas_eps_emm_paging_id, tvb, (curr_offset<<3)+7, 1, ENC_BIG_ENDIAN);
1394     curr_offset+=len;
1395
1396     return(len);
1397 }
1398 /*
1399  * 9.9.3.26 P-TMSI signature
1400  * See subclause 10.5.5.8 in 3GPP TS 24.008 [6].
1401  */
1402 /*
1403  * 9.9.3.27 Service type
1404  */
1405 static const value_string nas_eps_service_type_vals[] = {
1406     { 0,    "Mobile originating CS fallback or 1xCS fallback"},
1407     { 1,    "Mobile terminating CS fallback or 1xCS fallback"},
1408     { 2,    "Mobile originating CS fallback emergency call or 1xCS fallback emergency call"},
1409     { 0, NULL }
1410 };
1411
1412 /*
1413  * 9.9.3.28 Short MAC
1414  */
1415 static guint16
1416 de_emm_nas_short_mac(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1417 {
1418     guint32 curr_offset;
1419
1420     curr_offset = offset;
1421
1422
1423     proto_tree_add_item(tree, hf_nas_eps_emm_short_mac, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1424     curr_offset+=2;
1425
1426     return(curr_offset-offset);
1427 }
1428 /*
1429  * 9.9.3.29 Time zone
1430  * See subclause 10.5.3.8 in 3GPP TS 24.008 [6].
1431  */
1432 /*
1433  * 9.9.3.30 Time zone and time
1434  * See subclause 10.5.3.9 in 3GPP TS 24.008 [6].
1435  */
1436 /*
1437  * 9.9.3.31 TMSI status
1438  * See subclause 10.5.5.4 in 3GPP TS 24.008 [6].
1439  */
1440 /*
1441  * 9.9.3.32 Tracking area identity
1442  */
1443
1444 guint16
1445 de_emm_trac_area_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1446 {
1447     guint32 curr_offset;
1448
1449     curr_offset = offset;
1450
1451     curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE);
1452     proto_tree_add_item(tree, hf_nas_eps_emm_tai_tac, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1453     curr_offset+=2;
1454
1455     return(curr_offset-offset);
1456 }
1457 /*
1458  * 9.9.3.33 Tracking area identity list
1459  */
1460 /* Type of list (octet 1)
1461  * Bits 7 6
1462  */
1463 static const value_string nas_eps_emm_tai_tol_vals[] = {
1464     { 0,    "list of TACs belonging to one PLMN, with non-consecutive TAC values"},
1465     { 1,    "list of TACs belonging to one PLMN, with consecutive TAC values"},
1466     { 2,    "list of TAIs belonging to different PLMNs"},
1467     { 0, NULL }
1468 };
1469
1470 static guint16
1471 de_emm_trac_area_id_lst(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1472 {
1473     proto_item *item;
1474     guint32 curr_offset;
1475     guint8 octet, tol, n_elem;
1476     int i;
1477
1478     curr_offset = offset;
1479
1480     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
1481     /* Type of list (octet 1) Bits 7 6 */
1482     proto_tree_add_item(tree, hf_nas_eps_emm_tai_tol, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1483     /* Number of elements (octet 1) Bits 5 4 3 2 1 */
1484     octet = tvb_get_guint8(tvb,curr_offset)& 0x7f;
1485     tol = octet >> 5;
1486     n_elem = (octet & 0x1f)+1;
1487     item = proto_tree_add_item(tree, hf_nas_eps_emm_tai_n_elem, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1488     if(n_elem<16)
1489         proto_item_append_text(item, " [+1 = %u element(s)]", n_elem);
1490
1491     curr_offset++;
1492     if (tol>2){
1493         proto_tree_add_text(tree, tvb, curr_offset, len-(curr_offset-offset) , "Unknown type of list ( Not in 3GPP TS 24.301 version 8.1.0 Release 8 )");
1494         return len;
1495     }
1496
1497     switch(tol){
1498         case 0:
1499             /* MCC digit 2 MCC digit 1 octet 2
1500              * MNC digit 3 MCC digit 3 octet 3
1501              * MNC digit 2 MNC digit 1 octet 4
1502              */
1503             curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE);
1504             /* type of list = "000" */
1505             /* TAC 1             octet 5
1506              * TAC 1 (continued) octet 6
1507              * ...
1508              * ...
1509              * TAC k             octet 2k+3*
1510              * TAC k (continued) octet 2k+4*
1511              */
1512             if (len < (guint)(4+(n_elem*2))){
1513                 proto_tree_add_text(tree, tvb, curr_offset, len-1 , "[Wrong number of elements?]");
1514                 return len;
1515             }
1516             for (i=0; i < n_elem; i++, curr_offset+=2)
1517                 proto_tree_add_item(tree, hf_nas_eps_emm_tai_tac, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1518             break;
1519         case 1:
1520
1521             /* type of list = "010" */
1522             /* MCC digit 2 MCC digit 1 octet 2
1523              * MNC digit 3 MCC digit 3 octet 3
1524              * MNC digit 2 MNC digit 1 octet 4
1525              */
1526             curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE);
1527             proto_tree_add_item(tree, hf_nas_eps_emm_tai_tac, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1528             curr_offset+=2;
1529             break;
1530         case 2:
1531             if (len< (guint)(1+(n_elem*5))){
1532                 proto_tree_add_text(tree, tvb, curr_offset, len-1 , "[Wrong number of elements?]");
1533                 return len;
1534             }
1535
1536             for (i=0; i < n_elem; i++){
1537                 /* type of list = "001" */
1538                 /* MCC digit 2 MCC digit 1 octet 2
1539                  * MNC digit 3 MCC digit 3 octet 3
1540                  * MNC digit 2 MNC digit 1 octet 4
1541                  */
1542                 curr_offset = dissect_e212_mcc_mnc(tvb, gpinfo, tree, curr_offset, TRUE);
1543                 proto_tree_add_item(tree, hf_nas_eps_emm_tai_tac, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1544                 curr_offset+=2;
1545             }
1546             break;
1547         default:
1548             /* Unknown ( Not in 3GPP TS 24.301 version 8.1.0 Release 8 ) */
1549             break;
1550     }
1551     EXTRANEOUS_DATA_CHECK(len, curr_offset - offset);
1552
1553     return(curr_offset-offset);
1554 }
1555 /*
1556  * 9.9.3.34 UE network capability
1557  */
1558
1559 static const true_false_string  nas_eps_emm_supported_flg_value = {
1560     "Supported",
1561     "Not Supported"
1562 };
1563 static const true_false_string  nas_eps_emm_ucs2_supp_flg_value = {
1564     "The UE has no preference between the use of the default alphabet and the use of UCS2",
1565     "The UE has a preference for the default alphabet"
1566 };
1567 /* LPP capability (octet 7, bit 4) */
1568 static const true_false_string nas_eps_emm_lpp_cap_flg = {
1569     "LTE Positioning Protocol supported",
1570     "LTE Positioning Protocol not supported"
1571 };
1572 /* LCS capability (octet 7, bit 3) */
1573 static const true_false_string nas_eps_emm_lcs_cap_flg = {
1574     "Location services notification mechanisms supported",
1575     "Location services notification mechanisms not supported"
1576 };
1577 /* 1xSRVCC capability (octet 7, bit 2) */
1578 static const true_false_string  nas_eps_emm_1xsrvcc_cap_flg = {
1579     "SRVCC from E-UTRAN to cdma2000 1xCS supported",
1580     "SRVCC from E-UTRAN to cdma2000 1x CS not supported"
1581 };
1582 /* NF capability (octet 7, bit 1) */
1583 static const true_false_string  nas_eps_emm_nf_cap_flg = {
1584     "Notification procedure supported",
1585     "Notification procedure not supported"
1586 };
1587
1588 guint16
1589 de_emm_ue_net_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1590 {
1591     guint32 curr_offset;
1592
1593     curr_offset = offset;
1594
1595
1596     /* EPS encryption algorithms supported (octet 3) */
1597     /* EPS encryption algorithm EEA0 supported (octet 3, bit 8) */
1598     proto_tree_add_item(tree, hf_nas_eps_emm_eea0, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1599     /* EPS encryption algorithm 128-EEA1 supported (octet 3, bit 7) */
1600     proto_tree_add_item(tree, hf_nas_eps_emm_128eea1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1601     /* EPS encryption algorithm 128-EEA2 supported (octet 3, bit 6) */
1602     proto_tree_add_item(tree, hf_nas_eps_emm_128eea2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1603     /* EPS encryption algorithm 128-EEA3 supported (octet 3, bit 5) */
1604     proto_tree_add_item(tree, hf_nas_eps_emm_eea3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1605     /* EPS encryption algorithm 128-EEA4 supported (octet 3, bit 4) */
1606     proto_tree_add_item(tree, hf_nas_eps_emm_eea4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1607     /* EPS encryption algorithm 128-EEA5 supported (octet 3, bit 5) */
1608     proto_tree_add_item(tree, hf_nas_eps_emm_eea5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1609     /* EPS encryption algorithm 128-EEA6 supported (octet 3, bit 6) */
1610     proto_tree_add_item(tree, hf_nas_eps_emm_eea6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1611     /* EPS encryption algorithm 128-EEA7 supported (octet 3, bit 7) */
1612     proto_tree_add_item(tree, hf_nas_eps_emm_eea7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1613     curr_offset++;
1614
1615
1616     /* EPS integrity algorithms supported (octet 4) */
1617     /* EPS integrity algorithm EIA0 supported (octet 4, bit 8) */
1618     proto_tree_add_item(tree, hf_nas_eps_emm_eia0, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1619     /* EPS integrity algorithm 128-EIA1 supported (octet 4, bit 7) */
1620     proto_tree_add_item(tree, hf_nas_eps_emm_128eia1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1621     /* EPS integrity algorithm 128-EIA2 supported (octet 4, bit 6) */
1622     proto_tree_add_item(tree, hf_nas_eps_emm_128eia2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1623     /* EPS integrity algorithm EIA3 supported (octet 4, bit 5) */
1624     proto_tree_add_item(tree, hf_nas_eps_emm_eia3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1625     /* EPS integrity algorithm EIA4 supported (octet 4, bit 4) */
1626     proto_tree_add_item(tree, hf_nas_eps_emm_eia4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1627     /* EPS integrity algorithm EIA5 supported (octet 4, bit 3) */
1628     proto_tree_add_item(tree, hf_nas_eps_emm_eia5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1629     /* EPS integrity algorithm EIA6 supported (octet 4, bit 2) */
1630     proto_tree_add_item(tree, hf_nas_eps_emm_eia6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1631     /* EPS integrity algorithm EIA7 supported (octet 4, bit 1) */
1632     proto_tree_add_item(tree, hf_nas_eps_emm_eia7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1633     curr_offset++;
1634
1635
1636     /* Following octets are optional */
1637     if ((curr_offset - offset) >= len)
1638         return (len);
1639
1640     /* UMTS encryption algorithms supported (octet 5)
1641      * UMTS encryption algorithm UEA0 supported (octet 5, bit 8)
1642      */
1643     /* UMTS encryption algorithm 128-UEA0 supported (octet 5, bit 8) */
1644     proto_tree_add_item(tree, hf_nas_eps_emm_uea0, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1645     /* UMTS encryption algorithm 128-UEA0 supported (octet 5, bit 7) */
1646     proto_tree_add_item(tree, hf_nas_eps_emm_uea1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1647     /* UMTS encryption algorithm 128-UEA0 supported (octet 5, bit 6) */
1648     proto_tree_add_item(tree, hf_nas_eps_emm_uea2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1649     /* UMTS encryption algorithm 128-UEA0 supported (octet 5, bit 5) */
1650     proto_tree_add_item(tree, hf_nas_eps_emm_uea3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1651     /* EPS encryption algorithm 128-UEA0 supported (octet 5, bit 4) */
1652     proto_tree_add_item(tree, hf_nas_eps_emm_uea4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1653     /* UMTS encryption algorithm 128-UEA0 supported (octet 5, bit 5) */
1654     proto_tree_add_item(tree, hf_nas_eps_emm_uea5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1655     /* UMTS encryption algorithm 128-UEA0 supported (octet 5, bit 6) */
1656     proto_tree_add_item(tree, hf_nas_eps_emm_uea6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1657     /* UMTS encryption algorithm 128-UEA0 supported (octet 5, bit 7) */
1658     proto_tree_add_item(tree, hf_nas_eps_emm_uea7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1659     curr_offset++;
1660
1661     if ((curr_offset - offset) >= len)
1662         return (len);
1663
1664     /* UCS2 support (UCS2) (octet 6, bit 8)
1665      * This information field indicates the likely treatment of UCS2 encoded character strings
1666      * by the UE.
1667      */
1668     proto_tree_add_item(tree, hf_nas_eps_emm_ucs2_supp, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1669     /* UMTS integrity algorithms supported (octet 6) */
1670     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 7) */
1671     proto_tree_add_item(tree, hf_nas_eps_emm_uia1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1672     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 6) */
1673     proto_tree_add_item(tree, hf_nas_eps_emm_uia2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1674     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 5) */
1675     proto_tree_add_item(tree, hf_nas_eps_emm_uia3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1676     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 4) */
1677     proto_tree_add_item(tree, hf_nas_eps_emm_uia4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1678     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 3) */
1679     proto_tree_add_item(tree, hf_nas_eps_emm_uia5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1680     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 2) */
1681     proto_tree_add_item(tree, hf_nas_eps_emm_uia6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1682     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 1) */
1683     proto_tree_add_item(tree, hf_nas_eps_emm_uia7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1684     curr_offset++;
1685
1686     if ((curr_offset - offset) >= len)
1687         return (len);
1688
1689     /* Bits 8 to 5 of octet 7 are spare and shall be coded as zero. */
1690     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, (curr_offset<<3), 4, ENC_BIG_ENDIAN);
1691     /* LPP capability (octet 7, bit 4) */
1692     proto_tree_add_item(tree, hf_nas_eps_emm_lpp_cap, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1693     /* LCS capability (octet 7, bit 3) */
1694     proto_tree_add_item(tree, hf_nas_eps_emm_lcs_cap, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1695     /* 1xSRVCC capability (octet 7, bit 2) */
1696     proto_tree_add_item(tree, hf_nas_eps_emm_1xsrvcc_cap, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1697     /* NF capability (octet 7, bit 1) */
1698     proto_tree_add_item(tree, hf_nas_eps_emm_nf_cap, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1699     curr_offset++;
1700
1701     return(len);
1702 }
1703 /* UE radio capability information update needed flag (URC upd) (octet 1) */
1704 static const true_false_string  nas_eps_emm_ue_ra_cap_inf_upd_need_flg = {
1705     "UE radio capability information update needed",
1706     "UE radio capability information update not needed"
1707 };
1708
1709 /*
1710  * 9.9.3.35 UE radio capability information update needed
1711  */
1712
1713 static guint16
1714 de_emm_ue_ra_cap_inf_upd_need(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1715 {
1716     guint32 curr_offset;
1717
1718     curr_offset = offset;
1719
1720     proto_tree_add_item(tree, hf_nas_eps_emm_ue_ra_cap_inf_upd_need_flg, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1721
1722     return(len);
1723 }
1724 /*
1725  * 9.9.3.36 UE security capability
1726  */
1727
1728 static guint16
1729 de_emm_ue_sec_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1730 {
1731     guint32 curr_offset;
1732
1733     curr_offset = offset;
1734
1735     /* EPS encryption algorithms supported (octet 3) */
1736     /* EPS encryption algorithm EEA0 supported (octet 3, bit 8) */
1737     proto_tree_add_item(tree, hf_nas_eps_emm_eea0, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1738     /* EPS encryption algorithm 128-EEA1 supported (octet 3, bit 7) */
1739     proto_tree_add_item(tree, hf_nas_eps_emm_128eea1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1740     /* EPS encryption algorithm 128-EEA2 supported (octet 3, bit 6) */
1741     proto_tree_add_item(tree, hf_nas_eps_emm_128eea2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1742     /* EPS encryption algorithm 128-EEA3 supported (octet 3, bit 5) */
1743     proto_tree_add_item(tree, hf_nas_eps_emm_eea3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1744     /* EPS encryption algorithm 128-EEA4 supported (octet 3, bit 4) */
1745     proto_tree_add_item(tree, hf_nas_eps_emm_eea4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1746     /* EPS encryption algorithm 128-EEA5 supported (octet 3, bit 5) */
1747     proto_tree_add_item(tree, hf_nas_eps_emm_eea5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1748     /* EPS encryption algorithm 128-EEA6 supported (octet 3, bit 6) */
1749     proto_tree_add_item(tree, hf_nas_eps_emm_eea6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1750     /* EPS encryption algorithm 128-EEA7 supported (octet 3, bit 7) */
1751     proto_tree_add_item(tree, hf_nas_eps_emm_eea7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1752     curr_offset++;
1753
1754
1755     /* EPS integrity algorithms supported (octet 4) */
1756     /* EPS integrity algorithm EIA0 supported (octet 4, bit 8) */
1757     proto_tree_add_item(tree, hf_nas_eps_emm_eia0, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1758     /* EPS integrity algorithm 128-EIA1 supported (octet 4, bit 7) */
1759     proto_tree_add_item(tree, hf_nas_eps_emm_128eia1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1760     /* EPS integrity algorithm 128-EIA2 supported (octet 4, bit 6) */
1761     proto_tree_add_item(tree, hf_nas_eps_emm_128eia2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1762     /* EPS integrity algorithm EIA3 supported (octet 4, bit 5) */
1763     proto_tree_add_item(tree, hf_nas_eps_emm_eia3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1764     /* EPS integrity algorithm EIA4 supported (octet 4, bit 4) */
1765     proto_tree_add_item(tree, hf_nas_eps_emm_eia4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1766     /* EPS integrity algorithm EIA5 supported (octet 4, bit 3) */
1767     proto_tree_add_item(tree, hf_nas_eps_emm_eia5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1768     /* EPS integrity algorithm EIA6 supported (octet 4, bit 2) */
1769     proto_tree_add_item(tree, hf_nas_eps_emm_eia6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1770     /* EPS integrity algorithm EIA7 supported (octet 4, bit 1) */
1771     proto_tree_add_item(tree, hf_nas_eps_emm_eia7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1772     curr_offset++;
1773
1774
1775     /* Octets 5, 6, and 7 are optional. If octet 5 is included,
1776      * then also octet 6 shall be included and octet 7 may be included.
1777      */
1778     if(len==2)
1779         return(len);
1780
1781     /* UMTS encryption algorithms supported (octet 5) */
1782     /* UMTS encryption algorithm UEA0 supported (octet 5, bit 8) */
1783     proto_tree_add_item(tree, hf_nas_eps_emm_uea0, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1784     /* UMTS encryption algorithm UEA1 supported (octet 5, bit 7) */
1785     proto_tree_add_item(tree, hf_nas_eps_emm_uea1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1786     /* UMTS encryption algorithm UEA2 supported (octet 5, bit 6) */
1787     proto_tree_add_item(tree, hf_nas_eps_emm_uea2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1788     /* UMTS encryption algorithm UEA3 supported (octet 5, bit 5) */
1789     proto_tree_add_item(tree, hf_nas_eps_emm_uea3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1790     /* EPS encryption algorithm UEA4 supported (octet 5, bit 4) */
1791     proto_tree_add_item(tree, hf_nas_eps_emm_uea4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1792     /* UMTS encryption algorithm UEA5 supported (octet 5, bit 5) */
1793     proto_tree_add_item(tree, hf_nas_eps_emm_uea5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1794     /* UMTS encryption algorithm UEA6 supported (octet 5, bit 6) */
1795     proto_tree_add_item(tree, hf_nas_eps_emm_uea6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1796     /* UMTS encryption algorithm UEA7 supported (octet 5, bit 7) */
1797     proto_tree_add_item(tree, hf_nas_eps_emm_uea7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1798     curr_offset++;
1799
1800     /* UMTS integrity algorithms supported (octet 6) */
1801     /* Bit 8 of octet 6 is spare and shall be coded as zero. */
1802     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, (curr_offset<<3), 1, ENC_BIG_ENDIAN);
1803     /* UMTS integrity algorithm UIA1 supported (octet 6, bit 7) */
1804     proto_tree_add_item(tree, hf_nas_eps_emm_uia1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1805     /* UMTS integrity algorithm UIA2 supported (octet 6, bit 6) */
1806     proto_tree_add_item(tree, hf_nas_eps_emm_uia2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1807     /* UMTS integrity algorithm UIA3 supported (octet 6, bit 5) */
1808     proto_tree_add_item(tree, hf_nas_eps_emm_uia3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1809     /* UMTS integrity algorithm UIA4 supported (octet 6, bit 4) */
1810     proto_tree_add_item(tree, hf_nas_eps_emm_uia4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1811     /* UMTS integrity algorithm UIA5 supported (octet 6, bit 3) */
1812     proto_tree_add_item(tree, hf_nas_eps_emm_uia5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1813     /* UMTS integrity algorithm UIA6 supported (octet 6, bit 2) */
1814     proto_tree_add_item(tree, hf_nas_eps_emm_uia6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1815     /* UMTS integrity algorithm UIA7 supported (octet 6, bit 1) */
1816     proto_tree_add_item(tree, hf_nas_eps_emm_uia7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1817     curr_offset++;
1818
1819     if(len==4)
1820         return(len);
1821
1822     /* Bit 8 of octet 7 is spare and shall be coded as zero. */
1823     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, (curr_offset<<3), 1, ENC_BIG_ENDIAN);
1824     /* GPRS encryption algorithm GEA1 supported (octet 7, bit 7) */
1825     proto_tree_add_item(tree, hf_nas_eps_emm_gea1, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1826     /* GPRS encryption algorithm GEA2 supported (octet 7, bit 6) */
1827     proto_tree_add_item(tree, hf_nas_eps_emm_gea2, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1828     /* GPRS encryption algorithm GEA3 supported (octet 7, bit 5) */
1829     proto_tree_add_item(tree, hf_nas_eps_emm_gea3, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1830     /* GPRS encryption algorithm GEA4 supported (octet 7, bit 4) */
1831     proto_tree_add_item(tree, hf_nas_eps_emm_gea4, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1832     /* GPRS encryption algorithm GEA5 supported (octet 7, bit 3) */
1833     proto_tree_add_item(tree, hf_nas_eps_emm_gea5, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1834     /* GPRS encryption algorithm GEA6 supported (octet 7, bit 2) */
1835     proto_tree_add_item(tree, hf_nas_eps_emm_gea6, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1836     /* GPRS encryption algorithm GEA7 supported (octet 7, bit 1) */
1837     proto_tree_add_item(tree, hf_nas_eps_emm_gea7, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1838     curr_offset++;
1839
1840     return(len);
1841 }
1842 /*
1843  * 9.9.3.37 Emergency Number List
1844  * See subclause 10.5.3.13 in 3GPP TS 24.008 [13].
1845  * packet-gsm_a_dtap.c
1846  */
1847
1848 /*
1849  * 9.9.3.38 CLI
1850  */
1851
1852 /*
1853  * The coding of the CLI value part is the same as for octets 3 to 14
1854  * of the Calling party BCD number information element defined in
1855  * subclause 10.5.4.9 of 3GPP TS 24.008
1856  */
1857
1858 /*
1859  * 9.9.3.39 SS Code
1860  */
1861 static guint16
1862 de_emm_ss_code(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1863 {
1864     guint32 curr_offset;
1865
1866     curr_offset = offset;
1867
1868     /*
1869      * SS Code value
1870      * The coding of the SS Code value is given in subclause 17.7.5 of 3GPP TS 29.002 [15B].
1871      * value string imported from gsm map
1872      */
1873     proto_tree_add_item(tree, hf_nas_eps_emm_ss_code, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1874
1875     return(len);
1876 }
1877
1878 /*
1879  * 9.9.3.40 LCS indicator
1880  */
1881 /* LCS indicator value */
1882 static const value_string nas_eps_emm_lcs_ind_vals[] = {
1883     { 0,    "Normal, unspecified"},
1884     { 1,    "MT-LR"},
1885     { 0, NULL }
1886 };
1887
1888
1889 static guint16
1890 de_emm_lcs_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1891 {
1892     guint32 curr_offset;
1893
1894     curr_offset = offset;
1895
1896
1897     proto_tree_add_item(tree, hf_nas_eps_emm_lcs_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1898
1899     return(len);
1900 }
1901 /*
1902  * 9.9.3.41 LCS client identity
1903  */
1904 static guint16
1905 de_emm_lcs_client_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1906 {
1907     guint32 curr_offset;
1908     tvbuff_t *new_tvb;
1909
1910     curr_offset = offset;
1911
1912     /* LCS client identity (value part)
1913      * The coding of the value part of the LCS client identity is given
1914      * in subclause 17.7.13 of 3GPP TS 29.002 [15B](GSM MAP).
1915      */
1916     new_tvb = tvb_new_subset(tvb, curr_offset, len, len );
1917     dissect_gsm_map_lcs_LCS_ClientID_PDU( new_tvb, gpinfo, tree );
1918
1919     return(len);
1920 }
1921
1922 /*
1923  * 9.9.3.42 Generic message container type
1924  */
1925 static const value_string nas_eps_emm_gen_msg_cont_type_vals[] = {
1926     { 0,    "Reserved"},
1927     { 1,    "LTE Positioning Protocol (LPP) message container"},
1928     { 2,    "Location services message container "},
1929     { 0, NULL }
1930 };
1931
1932 static guint16
1933 de_emm_gen_msg_cont_type(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1934 {
1935     guint32 curr_offset;
1936
1937     curr_offset = offset;
1938
1939     eps_nas_gen_msg_cont_type = tvb_get_guint8(tvb, curr_offset);
1940     proto_tree_add_item(tree, hf_nas_eps_emm_gen_msg_cont_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
1941     curr_offset++;
1942
1943     return(curr_offset - offset);
1944 }
1945 /*
1946  * 9.9.3.43 Generic message container
1947  */
1948 static guint16
1949 de_emm_gen_msg_cont(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len, gchar *add_string _U_, int string_len _U_)
1950 {
1951     proto_item *item;
1952     proto_tree *sub_tree;
1953     tvbuff_t *new_tvb;
1954
1955     item = proto_tree_add_item(tree, hf_nas_eps_gen_msg_cont, tvb, offset, len, ENC_NA);
1956     sub_tree = proto_item_add_subtree(item, ett_nas_eps_gen_msg_cont);
1957
1958     new_tvb = tvb_new_subset(tvb, offset, len, len);
1959
1960     switch (eps_nas_gen_msg_cont_type) {
1961     case 1:
1962         /* LPP */
1963         if (lpp_handle) {
1964             call_dissector(lpp_handle, new_tvb, pinfo, sub_tree);
1965         }
1966         break;
1967     case 2:
1968         /* Location services */
1969         if (gsm_a_dtap_handle) {
1970             call_dissector(gsm_a_dtap_handle, new_tvb, pinfo, sub_tree);
1971         }
1972         break;
1973     default:
1974         break;
1975     }
1976
1977     return(len);
1978 }
1979 /*
1980  * 9.9.3.44 Voice domain preference and UE's usage setting
1981  * See subclause 10.5.5.28 in 3GPP TS 24.008 [13].
1982  * packet-gsm_a_dtap.c
1983  */
1984
1985  /*
1986  * 9.9.4    EPS Session Management (ESM) information elements
1987  */
1988
1989 /*
1990  * 9.9.4.1 Access point name
1991  * See subclause 10.5.6.1 in 3GPP TS 24.008 [6].
1992  */
1993 /*
1994  * 9.9.4.2 APN aggregate maximum bit rate
1995  */
1996
1997 static guint16
1998 de_esm_apn_aggr_max_br(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
1999 {
2000     guint32 curr_offset;
2001     guint8 octet;
2002     guint32 dl_total = 0;
2003     guint32 ul_total = 0;
2004     guint32 bitrate = 0;
2005
2006     curr_offset = offset;
2007     /* APN-AMBR for downlink    octet 3 */
2008     octet = tvb_get_guint8(tvb,curr_offset);
2009     if(octet==0){
2010         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_dl, tvb, curr_offset, 1, octet,
2011                        "Reserved");
2012     }else{
2013         bitrate = calc_bitrate(octet);
2014         dl_total += bitrate;
2015         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_dl, tvb, curr_offset, 1, octet,
2016                        "APN-AMBR for downlink : %u kbps", bitrate);
2017     }
2018     curr_offset++;
2019
2020     /* APN-AMBR for uplink  octet 4 */
2021     octet = tvb_get_guint8(tvb,curr_offset);
2022     if(octet==0){
2023         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_ul, tvb, curr_offset, 1, octet,
2024                        "Reserved");
2025     }else{
2026         bitrate = calc_bitrate(octet);
2027         ul_total += bitrate;
2028         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_ul, tvb, curr_offset, 1, octet,
2029                        "APN-AMBR for uplink : %u kbps", bitrate);
2030     }
2031     curr_offset++;
2032     if ((curr_offset - offset) >= len)
2033         return(len);
2034     /* APN-AMBR for downlink (extended) octet 5 */
2035     octet = tvb_get_guint8(tvb,curr_offset);
2036     if(octet==0){
2037         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_dl_ext, tvb, curr_offset, 1, octet,
2038                        "Use the value indicated by the APN-AMBR for downlink");
2039     }else{
2040         bitrate = calc_bitrate_ext(octet);
2041         dl_total += (octet > 0x4a) ? bitrate*1000 : bitrate;
2042         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_dl_ext, tvb, curr_offset, 1, octet,
2043                        "APN-AMBR for downlink (extended) : %u %s",
2044                        bitrate,
2045                        (octet > 0x4a) ? "Mbps" : "kbps");
2046     }
2047     if (len < 5) {
2048         /* APN-AMBR for downlink (extended-2) is not present; display total now */
2049         if (octet != 0) {
2050             /* Ignore value indicated by the APN-AMBR for downlink */
2051             dl_total = (octet > 0x4a) ? bitrate*1000 : bitrate;
2052         }
2053         if (dl_total >= 1000) {
2054             proto_tree_add_text(tree, tvb, curr_offset, 1,"Total APN-AMBR for downlink : %.3f Mbps", (gfloat)dl_total / 1000);
2055             } else {
2056             proto_tree_add_text(tree, tvb, curr_offset, 1,"Total APN-AMBR for downlink : %u kbps", dl_total);
2057         }
2058     }
2059     curr_offset++;
2060     if ((curr_offset - offset) >= len)
2061         return(len);
2062     /* APN-AMBR for uplink (extended)   octet 6 */
2063     octet = tvb_get_guint8(tvb,curr_offset);
2064     if(octet==0){
2065         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_ul_ext, tvb, curr_offset, 1, octet,
2066                        "Use the value indicated by the APN-AMBR for uplink");
2067     }else{
2068         bitrate = calc_bitrate_ext(octet);
2069         ul_total += (octet > 0x4a) ? bitrate*1000 : bitrate;
2070         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_ul_ext, tvb, curr_offset, 1, octet,
2071                        "APN-AMBR for uplink (extended) : %u %s",
2072                        bitrate,
2073                        (octet > 0x4a) ? "Mbps" : "kbps");
2074     }
2075     if (len < 6) {
2076         /* APN-AMBR for uplink (extended-2) is not present; display total now */
2077         if (octet != 0) {
2078             /* Ignore value indicated by the APN-AMBR for uplink */
2079             ul_total = (octet > 0x4a) ? bitrate*1000 : bitrate;
2080         }
2081         if (ul_total >= 1000) {
2082             proto_tree_add_text(tree, tvb, curr_offset, 1,"Total APN-AMBR for uplink : %.3f Mbps", (gfloat)ul_total / 1000);
2083             } else {
2084             proto_tree_add_text(tree, tvb, curr_offset, 1,"Total APN-AMBR for uplink : %u kbps", ul_total);
2085         }
2086     }
2087     curr_offset++;
2088     if ((curr_offset - offset) >= len)
2089         return(len);
2090     /* APN-AMBR for downlink (extended-2)   octet 7 */
2091     octet = tvb_get_guint8(tvb,curr_offset);
2092     if((octet==0)||(octet==0xff)){
2093         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_dl_ext2, tvb, curr_offset, 1, octet,
2094                        "Use the value indicated by the APN-AMBR for downlink and APN-AMBR for downlink (extended)");
2095     }else{
2096         dl_total += octet*256*1000;
2097         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_dl_ext2, tvb, curr_offset, 1, octet,
2098                        "APN-AMBR for downlink (extended-2) : %u Mbps",
2099                        (octet* 256));
2100     }
2101     proto_tree_add_text(tree, tvb, curr_offset, 1,"Total APN-AMBR for downlink : %.3f Mbps", (gfloat)dl_total / 1000);
2102     curr_offset++;
2103     if ((curr_offset - offset) >= len)
2104         return(len);
2105     /* APN-AMBR for uplink (extended-2) octet 8 */
2106     octet = tvb_get_guint8(tvb,curr_offset);
2107     if((octet==0)||(octet==0xff)){
2108         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_ul_ext2, tvb, curr_offset, 1, octet,
2109                        "Use the value indicated by the APN-AMBR for uplink and APN-AMBR for downlink (extended)");
2110     }else{
2111         ul_total += octet*256*1000;
2112         proto_tree_add_uint_format(tree, hf_nas_eps_emm_apn_ambr_ul_ext2, tvb, curr_offset, 1, octet,
2113                        "APN-AMBR for uplink (extended-2) : %u Mbps",
2114                        (octet* 256));
2115     }
2116     proto_tree_add_text(tree, tvb, curr_offset, 1,"Total APN-AMBR for uplink : %.3f Mbps", (gfloat)ul_total / 1000);
2117     curr_offset++;
2118
2119     return(len);
2120 }
2121 /*
2122  * 9.9.4.3 EPS quality of service
2123  */
2124
2125 /* Quality of Service Class Identifier (QCI), octet 3 (see 3GPP TS 23.203 [7]) */
2126 static const value_string nas_eps_qci_vals[] = {
2127     { 0,    "UE -> NW Network selects the QCI / NW -> UE Reserved"},
2128     { 1,    "QCI 1"},
2129     { 2,    "QCI 2"},
2130     { 3,    "QCI 3"},
2131     { 4,    "QCI 4"},
2132     { 5,    "QCI 5"},
2133     { 6,    "QCI 6"},
2134     { 7,    "QCI 7"},
2135     { 8,    "QCI 8"},
2136     { 9,    "QCI 9"},
2137     { 0, NULL }
2138 };
2139
2140
2141
2142 static guint16
2143 de_esm_qos(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2144 {
2145     guint32 curr_offset;
2146     guint8 octet;
2147
2148     curr_offset = offset;
2149
2150     /* QCI octet 3 */
2151     proto_tree_add_item(tree, hf_nas_eps_qci, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2152     curr_offset++;
2153     if ((curr_offset - offset) >= len)
2154         return(len);
2155     /* Maximum bit rate for uplink octet 4 */
2156     octet = tvb_get_guint8(tvb,curr_offset);
2157     if(octet==0){
2158         proto_tree_add_uint_format(tree, hf_nas_eps_mbr_ul, tvb, curr_offset, 1, octet,
2159                        "UE->NW Subscribed maximum bit rate for uplink/ NW->UE Reserved");
2160     }else{
2161         proto_tree_add_uint_format(tree, hf_nas_eps_mbr_ul, tvb, curr_offset, 1, octet,
2162                        "Maximum bit rate for uplink : %u kbps", calc_bitrate(octet));
2163     }
2164     curr_offset++;
2165     if ((curr_offset - offset) >= len)
2166         return(len);
2167     /* Maximum bit rate for downlink octet 5 */
2168     octet = tvb_get_guint8(tvb,curr_offset);
2169     if(octet==0){
2170         proto_tree_add_uint_format(tree, hf_nas_eps_mbr_dl, tvb, curr_offset, 1, octet,
2171                        "UE->NW Subscribed maximum bit rate for downlink/ NW->UE Reserved");
2172     }else{
2173         proto_tree_add_uint_format(tree, hf_nas_eps_mbr_dl, tvb, curr_offset, 1, octet,
2174                        "Maximum bit rate for downlink : %u kbps", calc_bitrate(octet));
2175     }
2176     curr_offset++;
2177     if ((curr_offset - offset) >= len)
2178         return(len);
2179     /* Guaranteed bit rate for uplink octet 6 */
2180     octet = tvb_get_guint8(tvb,curr_offset);
2181     proto_tree_add_uint_format(tree, hf_nas_eps_gbr_ul, tvb, curr_offset, 1, octet,
2182                    "Guaranteed bit rate for uplink : %u kbps", calc_bitrate(octet));
2183
2184     curr_offset++;
2185     if ((curr_offset - offset) >= len)
2186         return(len);
2187     /* Guaranteed bit rate for downlink octet 7 */
2188     octet = tvb_get_guint8(tvb,curr_offset);
2189     proto_tree_add_uint_format(tree, hf_nas_eps_gbr_ul, tvb, curr_offset, 1, octet,
2190                    "Guaranteed bit rate for downlink : %u kbps", calc_bitrate(octet));
2191
2192     curr_offset++;
2193     if ((curr_offset - offset) >= len)
2194         return(len);
2195     /* Maximum bit rate for uplink (extended) octet 8 */
2196     octet = tvb_get_guint8(tvb,curr_offset);
2197     if(octet==0){
2198         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2199                        "Use the value indicated by the maximum bit rate for uplink in octet 4.");
2200     }else{
2201         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2202                        "Maximum bit rate for uplink(extended) : %u %s",
2203                        calc_bitrate_ext(octet),
2204                        (octet > 0x4a) ? "Mbps" : "kbps");
2205     }
2206     curr_offset++;
2207     if ((curr_offset - offset) >= len)
2208         return(len);
2209     /* Maximum bit rate for downlink (extended) octet 9 */
2210     octet = tvb_get_guint8(tvb,curr_offset);
2211     if(octet==0){
2212         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2213                        "Use the value indicated by the maximum bit rate for downlink in octet 5.");
2214     }else{
2215         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2216                        "Maximum bit rate for downlink(extended) : %u %s",
2217                        calc_bitrate_ext(octet),
2218                        (octet > 0x4a) ? "Mbps" : "kbps");
2219     }
2220     curr_offset++;
2221     if ((curr_offset - offset) >= len)
2222         return(len);
2223     /* Guaranteed bit rate for uplink (extended) octet 10 */
2224     octet = tvb_get_guint8(tvb,curr_offset);
2225     if(octet==0){
2226         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2227                        "Use the value indicated by the Guaranteed bit rate for uplink in octet 6.");
2228     }else{
2229         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2230                        "Guaranteed bit rate for uplink(extended) : %u %s",
2231                        calc_bitrate_ext(octet),
2232                        (octet > 0x4a) ? "Mbps" : "kbps");
2233     }
2234     curr_offset++;
2235     if ((curr_offset - offset) >= len)
2236         return(len);
2237     /* Guaranteed bit rate for downlink (extended) octet 11 */
2238     octet = tvb_get_guint8(tvb,curr_offset);
2239     if(octet==0){
2240         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2241                        "Use the value indicated by the Guaranteed bit rate for downlink in octet 7.");
2242     }else{
2243         proto_tree_add_uint_format(tree, hf_nas_eps_embr_ul, tvb, curr_offset, 1, octet,
2244                        "Guaranteed bit rate for downlink(extended) : %u %s",
2245                        calc_bitrate_ext(octet),
2246                        (octet > 0x4a) ? "Mbps" : "kbps");
2247     }
2248     curr_offset++;
2249
2250     return(len);
2251 }
2252 /*
2253  * 9.9.4.4 ESM cause
2254  */
2255
2256 static const value_string nas_eps_esm_cause_vals[] = {
2257     { 0x08, "Operator Determined Barring"},
2258     { 0x1a, "Insufficient resources"},
2259     { 0x1b, "Unknown or missing APN"},
2260     { 0x1c, "Unknown PDN type"},
2261     { 0x1d, "User authentication failed"},
2262     { 0x1e, "Request rejected by Serving GW or PDN GW"},
2263     { 0x1f, "Request rejected, unspecified"},
2264     { 0x20, "Service option not supported"},
2265     { 0x21, "Requested service option not subscribed"},
2266     { 0x22, "Service option temporarily out of order"},
2267     { 0x23, "PTI already in use"},
2268     { 0x24, "Regular deactivation"},
2269     { 0x25, "EPS QoS not accepted"},
2270     { 0x26, "Network failure"},
2271     { 0x27, "Reactivation requested"},
2272     { 0x29, "Semantic error in the TFT operation"},
2273     { 0x2a, "Syntactical error in the TFT operation"},
2274     { 0x2b, "Invalid EPS bearer identity"},
2275     { 0x2c, "Semantic errors in packet filter(s)"},
2276     { 0x2d, "Syntactical errors in packet filter(s)"},
2277     { 0x2e, "EPS bearer context without TFT already activated"},
2278     { 0x2f, "PTI mismatch"},
2279     { 0x31, "Last PDN disconnection not allowed"},
2280     { 0x32, "PDN type IPv4 only allowed"},
2281     { 0x33, "PDN type IPv6 only allowed"},
2282     { 0x34, "Single address bearers only allowed"},
2283     { 0x35, "ESM information not received"},
2284     { 0x36, "PDN connection does not exist"},
2285     { 0x37, "Multiple PDN connections for a given APN not allowed"},
2286     { 0x38, "Collision with network initiated request"},
2287     { 0x3b, "Unsupported QCI value"},
2288     { 0x51, "Invalid PTI value"},
2289     { 0x5f, "Semantically incorrect message"},
2290     { 0x60, "Invalid mandatory information"},
2291     { 0x61, "Message type non-existent or not implemented"},
2292     { 0x62, "Message type not compatible with the protocol state"},
2293     { 0x63, "Information element non-existent or not implemented"},
2294     { 0x64, "Conditional IE error"},
2295     { 0x65, "Message not compatible with the protocol state"},
2296     { 0x6f, "Protocol error, unspecified"},
2297     { 0x70, "APN restriction value incompatible with active EPS bearer context"},
2298     { 0, NULL }
2299 };
2300
2301 static guint16
2302 de_esm_cause(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2303 {
2304     guint32 curr_offset;
2305
2306     curr_offset = offset;
2307
2308     proto_tree_add_item(tree, hf_nas_eps_esm_cause, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2309     curr_offset++;
2310
2311     return(curr_offset - offset);
2312 }
2313 /*
2314  * 9.9.4.5 ESM information transfer flag
2315  */
2316 /* EIT (ESM information transfer) */
2317 static const true_false_string  nas_eps_emm_eit_vals = {
2318     "Security protected ESM information transfer required",
2319     "Security protected ESM information transfer not required"
2320 };
2321 static guint16
2322 de_esm_inf_trf_flg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2323 {
2324     guint32 curr_offset;
2325
2326     curr_offset = offset;
2327
2328
2329     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, (curr_offset<<3)+4, 3, ENC_BIG_ENDIAN);
2330     proto_tree_add_item(tree, hf_nas_eps_esm_eit, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2331     curr_offset++;
2332     return(curr_offset-offset);
2333 }
2334 /*
2335  * 9.9.4.6 Linked EPS bearer identity
2336  */
2337 /*
2338  * Linked EPS bearer identity (bits 1-4)
2339  */
2340
2341 static const value_string nas_eps_esm_linked_bearer_id_vals[] = {
2342     { 0x0,  "Reserved"},
2343     { 0x1,  "Reserved"},
2344     { 0x2,  "Reserved"},
2345     { 0x3,  "Reserved"},
2346     { 0x4,  "Reserved"},
2347     { 0x5,  "EPS bearer identity value 5"},
2348     { 0x6,  "EPS bearer identity value 6"},
2349     { 0x7,  "EPS bearer identity value 7"},
2350     { 0x8,  "EPS bearer identity value 8"},
2351     { 0x9,  "EPS bearer identity value 9"},
2352     { 0xa,  "EPS bearer identity value 10"},
2353     { 0xb,  "EPS bearer identity value 11"},
2354     { 0xc,  "EPS bearer identity value 12"},
2355     { 0xd,  "EPS bearer identity value 13"},
2356     { 0xe,  "EPS bearer identity value 14"},
2357     { 0xf,  "EPS bearer identity value 15"},
2358     { 0, NULL }
2359 };
2360
2361
2362
2363 static guint16
2364 de_esm_lnkd_eps_bearer_id(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2365 {
2366     guint32 curr_offset;
2367
2368     curr_offset = offset;
2369
2370     proto_tree_add_item(tree, hf_nas_eps_esm_lnkd_eps_bearer_id, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2371
2372     return(len);
2373 }
2374
2375 /*
2376  * 9.9.4.7 LLC service access point identifier
2377  * See subclause 10.5.6.9 in 3GPP TS 24.008
2378  */
2379
2380 /*
2381  * 9.9.4.7a Notification indicator
2382  */
2383 static const value_string nas_eps_esm_notif_ind_vals[] = {
2384     { 0x0,  "Reserved"},
2385     { 0x1,  "SRVCC handover cancelled, IMS session re-establishment required"},
2386     { 0, NULL }
2387 };
2388
2389 static guint16
2390 de_esm_notif_ind(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2391 {
2392     guint32 curr_offset;
2393
2394     curr_offset = offset;
2395
2396     proto_tree_add_item(tree, hf_nas_eps_esm_notif_ind, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2397
2398     return(len);
2399 }
2400
2401 /*
2402  * 9.9.4.8 Packet flow identifier
2403  * See subclause 10.5.6.11 in 3GPP TS 24.008
2404  */
2405 /*
2406  * 9.9.4.9 PDN address
2407  */
2408 static guint16
2409 de_esm_pdn_addr(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len _U_, gchar *add_string _U_, int string_len _U_)
2410 {
2411     guint32 curr_offset;
2412     guint8 pdn_type;
2413
2414     curr_offset = offset;
2415
2416
2417     pdn_type  = tvb_get_guint8(tvb, offset) & 0x7;
2418     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 5, ENC_BIG_ENDIAN);
2419     proto_tree_add_item(tree, hf_nas_eps_esm_pdn_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
2420     curr_offset++;
2421
2422     switch(pdn_type){
2423         case 1:
2424             /* IPv4 */
2425             proto_tree_add_item(tree, hf_nas_eps_esm_pdn_ipv4, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
2426             curr_offset+=4;
2427             break;
2428         case 2:
2429             /* IPv6 3GPP TS 24.301 version 9.4.0 Release 9
2430              * If PDN type value indicates IPv6, the PDN address information in octet 4 to octet 11
2431              * contains an IPv6 interface identifier. Bit 8 of octet 4 represents the most significant bit
2432              * of the IPv6 interface identifier and bit 1 of octet 11 the least significant bit.
2433              */
2434             proto_tree_add_item(tree, hf_nas_eps_esm_pdn_ipv6_if_id, tvb, curr_offset, 8, ENC_NA);
2435             offset+=8;
2436             break;
2437         case 3:
2438             /* IPv4/IPv6 3GPP TS 24.301 version 9.4.0 Release 9
2439              * If PDN type value indicates IPv4v6, the PDN address information in octet 4 to octet 15
2440              * contains an IPv6 interface identifier and an IPv4 address. Bit 8 of octet 4 represents
2441              * the most significant bit of the IPv6 interface identifier and bit 1 of octet 11 the least
2442              * significant bit. Bit 8 of octet 12 represents the most significant bit of the IPv4 address
2443              * and bit 1 of octet 15 the least significant bit.
2444              */
2445             proto_tree_add_item(tree, hf_nas_eps_esm_pdn_ipv6_if_id, tvb, curr_offset, 8, ENC_NA);
2446             curr_offset+=8;
2447             proto_tree_add_item(tree, hf_nas_eps_esm_pdn_ipv4, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
2448             curr_offset+=4;
2449             break;
2450         default:
2451             break;
2452     }
2453
2454     return(curr_offset-offset);
2455 }
2456
2457 /*
2458  * 9.9.4.10 PDN type
2459  * Coded inline 1/2 octet
2460  */
2461 static const value_string nas_eps_esm_pdn_type_values[] = {
2462     { 0x1,  "IPv4" },
2463     { 0x2,  "IPv6" },
2464     { 0x3,  "IPv4v6" },
2465     { 0x4,  "Unused; shall be interpreted as IPv6 if received by the network" },
2466     { 0, NULL }
2467 };
2468
2469 /*
2470  * 9.9.4.11 Protocol configuration options
2471  * See subclause 10.5.6.3 in 3GPP TS 24.008
2472  */
2473 /*
2474  * 9.9.4.12 Quality of service
2475  * See subclause 10.5.6.5 in 3GPP TS 24.008
2476  */
2477 /*
2478  * 9.9.4.13 Radio priority
2479  * See subclause 10.5.7.2 in 3GPP TS 24.008
2480  */
2481 /*
2482  * 9.9.4.14 Request type
2483  * See subclause 10.5.6.17 in 3GPP TS 24.008
2484  */
2485 /*
2486  * 9.9.4.15 Traffic flow aggregate description
2487  * The Traffic flow aggregate description information element is encoded using the same format as the Traffic flow
2488  * template information element (see subclause 10.5.6.12 in 3GPP TS 24.008 [13]). When sending this IE, the UE shall
2489  * assign the packet filter identifier values so that they are unique across all packet filters for the PDN connection.
2490  */
2491 /*
2492  * 9.9.4.16 Traffic flow template
2493  * See subclause 10.5.6.12 in 3GPP TS 24.008
2494  * packet-gsm_a_gm.c
2495  */
2496 /*
2497  * 9.9.4.17 Transaction identifier
2498  * The Transaction identifier information element is coded as the Linked TI information element in 3GPP TS 24.008 [13],
2499  * subclause 10.5.6.7.
2500  * The coding of the TI flag, the TI value and the EXT bit is defined in 3GPP TS 24.007[20].
2501  */
2502
2503 guint16 (*emm_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = {
2504     /* 9.9.3    EPS Mobility Management (EMM) information elements */
2505     de_emm_add_upd_res,         /* 9.9.3.0A Additional update result */
2506     de_emm_add_upd_type,        /* 9.9.3.0B Additional update type */
2507     NULL,                       /* 9.9.3.1  Authentication failure parameter(dissected in packet-gsm_a_dtap.c) */
2508     NULL,                       /* 9.9.3.2  Authentication parameter AUTN(packet-gsm_a_dtap.c) */
2509     NULL,                       /* 9.9.3.3  Authentication parameter RAND */
2510     de_emm_auth_resp_par,       /* 9.9.3.4  Authentication response parameter */
2511     de_emm_csfb_resp,           /* 9.9.3.5  CSFB response */
2512     NULL,                       /* 9.9.3.6  Daylight saving time (packet-gsm_a_dtap.c)*/
2513     NULL,                       /* 9.9.3.7  Detach type */
2514     NULL,                       /* 9.9.3.8  DRX parameter */
2515     de_emm_cause,               /* 9.9.3.9  EMM cause */
2516     NULL,                       /* 9.9.3.10 EPS attach result (coded inline) */
2517     NULL,                       /* 9.9.3.11 EPS attach type(Coded Inline) */
2518     de_emm_eps_mid,             /* 9.9.3.12 EPS mobile identity */
2519     de_emm_eps_net_feature_sup, /* 9.9.3.12A EPS network feature support */
2520     NULL,                       /* 9.9.3.13 EPS update result (Coded Inline)*/
2521     NULL,                       /* 9.9.3.14 EPS update type (Inline)*/
2522     de_emm_esm_msg_cont,        /* 9.9.3.15 ESM message conta */
2523     NULL,                       /* 9.9.3.16 GPRS timer ,See subclause 10.5.7.3 in 3GPP TS 24.008 [6]. (packet-gsm_a_gm.c)*/
2524     NULL,                       /* 9.9.3.17 Identity type 2 ,See subclause 10.5.5.9 in 3GPP TS 24.008 [6]. */
2525     de_emm_nas_imeisv_req,      /* 9.9.3.18 IMEISV request ,See subclause 10.5.5.10 in 3GPP TS 24.008 [6]. */
2526     de_emm_nas_ksi_and_seq_no,  /* 9.9.3.19 KSI and sequence number */
2527     NULL,                       /* 9.9.3.20 MS network capability ,See subclause 10.5.5.12 in 3GPP TS 24.008 [6].(packet-gsm_a_gm.c) */
2528     de_emm_nas_key_set_id,      /* 9.9.3.21 NAS key set identifier (Coded Inline) */
2529     de_emm_nas_msg_cont,        /* 9.9.3.22 NAS message container */
2530     de_emm_nas_sec_alsgs,       /* 9.9.3.23 NAS security algorithms */
2531     NULL,                       /* 9.9.3.24 Network name, See subclause 10.5.3.5a in 3GPP TS 24.008 [6]. (packet-gsm_a_dtap.c)*/
2532     de_emm_nonce,               /* 9.9.3.25 Nonce */
2533     de_emm_paging_id,           /* 9.9.3.25A Paging identity */
2534     NULL,                       /* 9.9.3.26 P-TMSI signature, See subclause 10.5.5.8 in 3GPP TS 24.008 [6]. (packet-gsm_a_gm.c)*/
2535     NULL,                       /* 9.9.3.27 Service type  */
2536     de_emm_nas_short_mac,       /* 9.9.3.28 Short MAC */
2537     NULL,                       /* 9.9.3.29 Time zone, See subclause 10.5.3.8 in 3GPP TS 24.008 [6]. (packet-gsm_a_dtap.c)*/
2538     NULL,                       /* 9.9.3.30 Time zone and time, See subclause 10.5.3.9 in 3GPP TS 24.008 [6]. (packet-gsm_a_dtap.c)*/
2539     NULL,                       /* 9.9.3.31 TMSI status, See subclause 10.5.5.4 in 3GPP TS 24.008 [6]. (packet-gsm_a_gm.c)*/
2540     de_emm_trac_area_id,        /* 9.9.3.32 Tracking area identity */
2541     de_emm_trac_area_id_lst,    /* 9.9.3.33 Tracking area identity list */
2542     de_emm_ue_net_cap,          /* 9.9.3.34 UE network capability */
2543     de_emm_ue_ra_cap_inf_upd_need, /* 9.9.3.35  UE radio capability information update needed */
2544     de_emm_ue_sec_cap,          /* 9.9.3.36 UE security capability */
2545     NULL,                       /* 9.9.3.37 Emergency Number List (packet-gsm_A_dtap.c) */
2546     NULL,                       /* 9.9.3.38 CLI */
2547     de_emm_ss_code,             /* 9.9.3.39 SS Code */
2548     de_emm_lcs_ind,             /* 9.9.3.40 LCS indicator */
2549     de_emm_lcs_client_id,       /* 9.9.3.41 LCS client identity */
2550     de_emm_gen_msg_cont_type,   /* 9.9.3.42 Generic message container type */
2551     de_emm_gen_msg_cont,        /* 9.9.3.43 Generic message container */
2552     NULL,                       /* 9.9.3.44 Voice domain preference and UE's usage setting */
2553     NULL,   /* NONE */
2554 };
2555
2556 /* 9.9.4 EPS Session Management (ESM) information elements */
2557 const value_string nas_esm_elem_strings[] = {
2558     { 0x00, "Access point name" },                      /* 9.9.4.1 Access point name */
2559     { 0x00, "APN aggregate maximum bit rate" },         /* 9.9.4.2 APN aggregate maximum bit rate */
2560     { 0x00, "EPS quality of service" },                 /* 9.9.4.3 EPS quality of service */
2561     { 0x00, "ESM cause" },                              /* 9.9.4.4 ESM cause */
2562     { 0x00, "ESM information transfer flag" },          /* 9.9.4.5 ESM information transfer flag */
2563     { 0x00, "Linked EPS bearer identity" },             /* 9.9.4.6 Linked EPS bearer identity */
2564     { 0x00, "LLC service access point identifier" },    /* 9.9.4.7 LLC service access point identifier */
2565     { 0x00, "Notification indicator" },                 /* 9.9.4.7a Notification indicator */
2566     { 0x00, "Packet flow identifier" },                 /* 9.9.4.8 Packet flow identifier */
2567     { 0x00, "PDN address" },                            /* 9.9.4.9 PDN address */
2568     { 0x00, "PDN type" },                               /* 9.9.4.10 PDN type */
2569     { 0x00, "Protocol configuration options" },         /* 9.9.4.11 Protocol configuration options */
2570     { 0x00, "Quality of service" },                     /* 9.9.4.12 Quality of service */
2571     { 0x00, "Radio priority" },                         /* 9.9.4.13 Radio priority */
2572     { 0x00, "Request type" },                           /* 9.9.4.14 Request type */
2573     { 0x00, "Traffic flow aggregate description" },     /* 9.9.4.15 Traffic flow aggregate description */
2574     { 0x00, "Traffic flow templat" },                   /* 9.9.4.16 Traffic flow template */
2575     { 0x00, "Transaction identifier" },                 /* 9.9.4.17 Transaction identifier */
2576     { 0, NULL }
2577 };
2578
2579
2580 #define NUM_NAS_ESM_ELEM (sizeof(nas_esm_elem_strings)/sizeof(value_string))
2581 gint ett_nas_eps_esm_elem[NUM_NAS_ESM_ELEM];
2582
2583 typedef enum
2584 {
2585     DE_ESM_APN,                     /* 9.9.4.1 Access point name */
2586     DE_ESM_APN_AGR_MAX_BR,          /* 9.9.4.2 APN aggregate maximum bit rate */
2587     DE_ESM_EPS_QOS,                 /* 9.9.4.3 EPS quality of service */
2588     DE_ESM_CAUSE,                   /* 9.9.4.4 ESM cause */
2589     DE_ESM_INF_TRF_FLG,             /* 9.9.4.5 ESM information transfer flag */
2590     DE_ESM_LNKED_EPS_B_ID,          /* 9.9.4.6 Linked EPS bearer identity  */
2591     DE_ESM_LLC_SAPI,                /* 9.9.4.7 LLC service access point identifier */
2592     DE_ESM_NOTIF_IND,               /* 9.9.4.7a Notification indicator */
2593     DE_ESM_P_FLW_ID,                /* 9.9.4.8 Packet flow identifier  */
2594     DE_ESM_PDN_ADDR,                /* 9.9.4.9 PDN address */
2595     DE_ESM_PDN_TYPE,                /* 9.9.4.10 PDN type */
2596     DE_ESM_PROT_CONF_OPT,           /* 9.9.4.11 Protocol configuration options */
2597     DE_ESM_QOS,                     /* 9.9.4.12 Quality of service */
2598     DE_ESM_RA_PRI,                  /* 9.9.4.13 Radio priority  */
2599     DE_ESM_REQ_TYPE,                /* 9.9.4.14 Request type */
2600     DE_ESM_TRAF_FLOW_AGR_DESC,      /* 9.9.4.15 Traffic flow aggregate description */
2601     DE_ESM_TRAF_FLOW_TEMPL,         /* 9.9.4.16 Traffic flow template */
2602     DE_ESM_TID,                     /* 9.9.4.17 Transaction identifier  */
2603     DE_ESM_NONE                     /* NONE */
2604 }
2605
2606 nas_esm_elem_idx_t;
2607
2608 guint16 (*esm_elem_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len, gchar *add_string, int string_len) = {
2609     NULL,                           /* 9.9.4.1 Access point name */
2610     de_esm_apn_aggr_max_br,         /* 9.9.4.2 APN aggregate maximum bit rate */
2611     de_esm_qos,                     /* 9.9.4.3 EPS quality of service */
2612     de_esm_cause,                   /* 9.9.4.4 ESM cause */
2613     de_esm_inf_trf_flg,             /* 9.9.4.5 ESM information transfer flag */
2614     de_esm_lnkd_eps_bearer_id,      /* 9.9.4.6 Linked EPS bearer identity  */
2615     NULL,                           /* 9.9.4.7 LLC service access point identifier */
2616     de_esm_notif_ind,               /* 9.9.4.7a Notification indicator */
2617     NULL,                           /* 9.9.4.8 Packet flow identifier  */
2618     de_esm_pdn_addr,                /* 9.9.4.9 PDN address */
2619     NULL,                           /* 9.9.4.10 PDN type */
2620     NULL,                           /* 9.9.4.11 Protocol configuration options */
2621     NULL,                           /* 9.9.4.12 Quality of service */
2622     NULL,                           /* 9.9.4.13 Radio priority  */
2623     NULL,                           /* 9.9.4.14 Request type */
2624     NULL,                           /* 9.9.4.15 Traffic flow aggregate description */
2625     NULL,                           /* 9.9.4.16 Traffic flow template */
2626     NULL,                           /* 9.9.4.17 Transaction identifier  */
2627     NULL,   /* NONE */
2628 };
2629
2630 /* MESSAGE FUNCTIONS */
2631
2632 /*
2633  * 8.2.1    Attach accept
2634  */
2635
2636 static void
2637 nas_emm_attach_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2638 {
2639     guint32 curr_offset, bit_offset;
2640     guint32 consumed;
2641     guint   curr_len;
2642
2643     curr_offset = offset;
2644     curr_len = len;
2645
2646     /*  Spare half octet    Spare half octet 9.9.2.7    M   V   1/2 */
2647     bit_offset = curr_offset<<3;
2648     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2649     bit_offset+=4;
2650     /*  EPS attach result   EPS attach result 9.9.3.10  M   V   1/2 */
2651     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2652     bit_offset++;
2653     proto_tree_add_bits_item(tree, hf_nas_eps_emm_EPS_attach_result, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2654     bit_offset+=3;
2655     /* Fix up the lengths */
2656     curr_len--;
2657     curr_offset++;
2658     /*  T3412 value GPRS timer 9.9.3.16 M   V   1 */
2659     ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - T3412 value");
2660     /*  Tracking area identity list 9.9.3.33    M   LV  7-97 */
2661     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID_LST, " - TAI list");
2662     /*  ESM message container 9.9.3.15  M   LV-E    2-n */
2663     ELEM_MAND_LV_E(NAS_PDU_TYPE_EMM, DE_EMM_ESM_MSG_CONT, NULL);
2664     /* 50   GUTI    EPS mobile identity 9.9.3.12    O   TLV 13 */
2665     ELEM_OPT_TLV(0x50, NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - GUTI");
2666     /* 13   Location area identification    Location area identification 9.9.2.2    O   TV  6 */
2667     ELEM_OPT_TV(0x13, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_LOC_AREA_ID, NULL);
2668     /* 23   MS identity     Mobile identity 9.9.2.3 O   TLV 7-10 */
2669     ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_MOB_ID, " - MS identity");
2670     /* 53   EMM cause   EMM cause 9.9.3.9   O   TV  2 */
2671     ELEM_OPT_TV(0x53, NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
2672     /* 17   T3402 value GPRS timer 9.9.3.16 O   TV  2 */
2673     ELEM_OPT_TV(0x17, GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - T3402 value");
2674     /* 59   T3423 value GPRS timer 9.9.3.16 O   TV  2 */
2675     ELEM_OPT_TV(0x59, GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - T3423 value");
2676     /* 4A   Equivalent PLMNs    PLMN list 9.9.2.8   O   TLV 5-47 */
2677     ELEM_OPT_TLV(0x4a, NAS_PDU_TYPE_COMMON, DE_PLMN_LIST, " - Equivalent PLMNs");
2678     /* 34   Emergency Number List 9.9.3.37  O   TLV 5-50 */
2679     ELEM_OPT_TLV(0x34, GSM_A_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST, NULL);
2680     /* 64   EPS network feature support EPS network feature support 9.9.3.12A   O   TLV 3 */
2681     ELEM_OPT_TLV(0x64, NAS_PDU_TYPE_EMM, DE_EMM_EPS_NET_FEATURE_SUP, NULL);
2682     /* F-   Additional update result    Additional update result 9.9.3.0A   O   TV  1 */
2683     ELEM_OPT_TV_SHORT( 0xF0 , NAS_PDU_TYPE_EMM, DE_EMM_ADD_UPD_RES, NULL );
2684
2685     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2686 }
2687 /*
2688  * 8.2.2    Attach complete
2689  */
2690 static void
2691 nas_emm_attach_comp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2692 {
2693     guint32 curr_offset;
2694     guint32 consumed;
2695     guint   curr_len;
2696
2697     curr_offset = offset;
2698     curr_len = len;
2699
2700     /* ESM message container    ESM message container 9.9.3.15  M   LV-E    2-n */
2701     ELEM_MAND_LV_E(NAS_PDU_TYPE_EMM, DE_EMM_ESM_MSG_CONT, NULL);
2702
2703     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2704
2705 }
2706
2707 /*
2708  * 8.2.3    Attach reject
2709  */
2710 static void
2711 nas_emm_attach_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2712 {
2713     guint32 curr_offset;
2714     guint32 consumed;
2715     guint   curr_len;
2716
2717     curr_offset = offset;
2718     curr_len = len;
2719
2720     /* * EMM cause  EMM cause 9.9.3.9   M   V   1 */
2721     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
2722     /* 78 ESM message container ESM message container 9.9.3.15  O   TLV-E   4-n */
2723     ELEM_OPT_TLV_E(0x78, NAS_PDU_TYPE_EMM, DE_EMM_ESM_MSG_CONT, NULL);
2724
2725     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2726
2727 }
2728 /*
2729  * 8.2.4    Attach request
2730  */
2731 static void
2732 nas_emm_attach_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2733 {
2734     guint32 curr_offset, bit_offset;
2735     guint32 consumed;
2736     guint   curr_len;
2737
2738     curr_offset = offset;
2739     curr_len = len;
2740
2741     bit_offset = curr_offset<<3;
2742
2743     /* NAS key set identifier   NAS key set identifier 9.9.3.21 M   V   1/2 */
2744     de_emm_nas_key_set_id_bits(tvb, tree, bit_offset, NULL);
2745     bit_offset+=4;
2746
2747     /* EPS attach type  EPS attach type 9.9.3.11    M   V   1/2
2748      * Inline:
2749      */
2750     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2751     bit_offset++;
2752     proto_tree_add_bits_item(tree, hf_nas_eps_emm_eps_att_type, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2753     bit_offset+=3;
2754
2755     /* Fix the lengths */
2756     curr_len--;
2757     curr_offset++;
2758     /* Old GUTI or IMSI EPS mobile identity 9.9.3.12    M   LV  5-12 */
2759     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - Old GUTI or IMSI");
2760     /* UE network capability    UE network capability 9.9.3.34  M   LV  3-14 */
2761     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_UE_NET_CAP, NULL);
2762     /* ESM message container    ESM message container 9.9.3.15  M   LV-E    2-n */
2763     ELEM_MAND_LV_E(NAS_PDU_TYPE_EMM, DE_EMM_ESM_MSG_CONT, NULL);
2764     /* 19   Old P-TMSI signature    P-TMSI signature 10.5.5.8   O   TV  4 */
2765     ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG, " - Old P-TMSI Signature");
2766     /* 50   Additional GUTI EPS mobile identity 9.9.3.12    O   TLV 13 */
2767     ELEM_OPT_TLV( 0x50 , NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - Additional GUTI");
2768     /* 52 Last visited registered TAI   Tracking area identity 9.9.3.32 O   TV  6 */
2769     ELEM_OPT_TV(0x52, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, " - Last visited registered TAI");
2770     /* 5c DRX parameter DRX parameter 9.9.3.8   O   TV  3 */
2771     ELEM_OPT_TV(0x5c, GSM_A_PDU_TYPE_GM, DE_DRX_PARAM, NULL );
2772     /* 31 MS network capability MS network capability 9.9.3.20  M   LV  3-9 */
2773     ELEM_OPT_TLV( 0x31, GSM_A_PDU_TYPE_GM, DE_MS_NET_CAP , NULL );
2774     /* 13 Old location area identification  Location area identification 9.9.2.2    O   TV  6 */
2775     ELEM_OPT_TV(0x13, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_LOC_AREA_ID, " - Old location area identification");
2776     /* 9- TMSI status   TMSI status 9.9.3.31    O   TV  1 */
2777     ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL );
2778     /* 11   Mobile station classmark 2  Mobile station classmark 2 9.9.2.5  O   TLV 5 */
2779     ELEM_OPT_TLV( 0x11, NAS_PDU_TYPE_COMMON, DE_EPS_MS_CM_2 , NULL );
2780     /* 20   Mobile station classmark 3  Mobile station classmark 3 9.9.2.5  O   TLV 2-34 */
2781     ELEM_OPT_TLV( 0x20, NAS_PDU_TYPE_COMMON, DE_EPS_MS_CM_3 , NULL );
2782     /* 40   Supported Codecs    Supported Codec List 9.9.2.10   O   TLV 5-n */
2783     ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, " - Supported Codecs");
2784     /* F-   Additional update type  Additional update type 9.9.3.0B O   TV  1 */
2785     ELEM_OPT_TV_SHORT( 0xF0 , NAS_PDU_TYPE_EMM, DE_EMM_ADD_UPD_TYPE, NULL );
2786     /* 5D   Voice domain preference and UE's usage setting  Voice domain preference and UE's usage setting 9.9.3.44 O   TLV 3 */
2787     ELEM_OPT_TLV(0x5D, GSM_A_PDU_TYPE_GM, DE_VOICE_DOMAIN_PREF, NULL);
2788
2789     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2790 }
2791 /*
2792  * 8.2.5    Authentication failure
2793  */
2794 static void
2795 nas_emm_attach_fail(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2796 {
2797     guint32 curr_offset;
2798     guint32 consumed;
2799     guint   curr_len;
2800
2801     curr_offset = offset;
2802     curr_len = len;
2803
2804      /* EMM cause   EMM cause 9.9.3.9   M   V   1 */
2805     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
2806     /* 30 Authentication failure parameter  Authentication failure parameter 9.9.3.1    O   TLV 1 */
2807     ELEM_OPT_TLV(0x30, GSM_A_PDU_TYPE_DTAP, DE_AUTH_FAIL_PARAM, NULL);
2808
2809     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2810 }
2811 /*
2812  * 8.2.6    Authentication reject
2813  * No IE:s
2814  */
2815 /*
2816  * 8.2.7    Authentication request
2817  */
2818
2819 static void
2820 nas_emm_auth_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2821 {
2822     guint32 curr_offset, bit_offset;
2823     guint32 consumed;
2824     guint   curr_len;
2825
2826     curr_offset = offset;
2827     curr_len = len;
2828
2829     bit_offset = curr_offset<<3;
2830     /* H1 */
2831     /*  Spare half octet    Spare half octet 9.9.2.7    M   V   1/2 */
2832     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2833     bit_offset+=4;
2834     /* H0 */
2835     /*
2836      * NAS key set identifierASME   NAS key set identifier 9.9.3.21 M   V   1/2
2837      */
2838     de_emm_nas_key_set_id_bits(tvb, tree, bit_offset, " ASME");
2839     bit_offset+=4;
2840
2841     /* Fix the lengths */
2842     curr_len--;
2843     curr_offset++;
2844
2845     /*
2846      * Authentication parameter RAND (EPS challenge) 9.9.3.3    M   V   16
2847      */
2848     ELEM_MAND_V(GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_RAND, " - EPS challenge");
2849     /*
2850      * Authentication parameter AUTN (EPS challenge) 9.9.3.2    M   LV  17
2851      */
2852     ELEM_MAND_LV(GSM_A_PDU_TYPE_DTAP, DE_AUTH_PARAM_AUTN, " - EPS challenge");
2853
2854     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2855
2856 }
2857 /*
2858  * 8.2.8    Authentication response
2859  */
2860 static void
2861 nas_emm_auth_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2862 {
2863     guint32 curr_offset;
2864     guint32 consumed;
2865     guint   curr_len;
2866
2867     curr_offset = offset;
2868     curr_len = len;
2869
2870     /*
2871      * Authentication response parameter 9.9.3.4    M   LV  5-17
2872      */
2873     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_AUTH_RESP_PAR, NULL);
2874
2875     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2876 }
2877
2878 /*
2879  * 8.2.9    CS service notification
2880  */
2881
2882 static void
2883 nas_emm_cs_serv_not(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2884 {
2885     guint32 curr_offset;
2886     guint32 consumed;
2887     guint   curr_len;
2888
2889     curr_offset = offset;
2890     curr_len = len;
2891
2892     consumed = 0;
2893
2894     /* Paging identity  Paging identity 9.9.3.25A   M   V   1 */
2895     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_PAGING_ID, NULL);
2896     /* 60   CLI CLI 9.9.3.38    O   TLV 3-12 */
2897     ELEM_OPT_TLV(0x60, GSM_A_PDU_TYPE_DTAP, DE_CLD_PARTY_BCD_NUM, " - CLI");
2898     /* 61   SS Code SS Code 9.9.3.39    O   TV  2 */
2899     ELEM_OPT_TV(0x61, NAS_PDU_TYPE_EMM, DE_EMM_SS_CODE, NULL);
2900     /* 62   LCS indicator   LCS indicator 9.9.3.40  O   TV  2 */
2901     ELEM_OPT_TV(0x62, NAS_PDU_TYPE_EMM, DE_EMM_LCS_IND, NULL);
2902     /* 63   LCS client identity LCS client identity 9.9.3.41    O   TLV 3-257 */
2903     ELEM_OPT_TLV(0x63, NAS_PDU_TYPE_EMM, DE_EMM_LCS_CLIENT_ID, NULL);
2904
2905     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2906 }
2907 /*
2908  * 8.2.10   Detach accept
2909  * 8.2.10.1 Detach accept (UE originating detach)
2910  * No further IE's
2911  * 8.2.10.2 Detach accept (UE terminated detach)
2912  * No further IE's
2913  */
2914 /*
2915  * 8.2.11   Detach request
2916  * 8.2.11.1 Detach request (UE originating detach)
2917  */
2918
2919 static void
2920 nas_emm_detach_req_UL(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2921 {
2922     guint32 curr_offset,bit_offset;
2923     guint32 consumed;
2924     guint   curr_len;
2925
2926     curr_offset = offset;
2927     curr_len = len;
2928
2929     proto_tree_add_text(tree, tvb, curr_offset, len,"Up link");
2930     /* NAS key set identifier   NAS key set identifier 9.9.3.21 M   V   1/2 */
2931     bit_offset = curr_offset<<3;
2932     de_emm_nas_key_set_id_bits(tvb, tree, bit_offset, NULL);
2933     bit_offset+=4;
2934     /* Detach type  Detach type 9.9.3.6 M   V   1/2 */
2935     proto_tree_add_bits_item(tree, hf_nas_eps_emm_switch_off, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2936     bit_offset++;
2937     proto_tree_add_bits_item(tree, hf_nas_eps_emm_detach_type_UL, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2938     bit_offset+=3;
2939
2940     /* Fix the lengths */
2941     curr_len--;
2942     curr_offset++;
2943
2944     /* GUTI or IMSI EPS mobile identity 9.9.3.12    M   LV  5-12 */
2945     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - GUTI or IMSI");
2946
2947     return;
2948 }
2949 /*
2950  * 8.2.11.2 Detach request (UE terminated detach)
2951  */
2952 static void
2953 nas_emm_detach_req_DL(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
2954 {
2955     guint32 curr_offset, bit_offset;
2956     guint32 consumed;
2957     guint   curr_len;
2958
2959     curr_offset = offset;
2960     curr_len = len;
2961
2962     proto_tree_add_text(tree, tvb, curr_offset, len,"Down link");
2963     /* Spare half octet Spare half octet 9.9.2.7    M   V   1/2 */
2964     bit_offset = curr_offset<<3;
2965     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2966     bit_offset+=4;
2967     /* Detach type  Detach type 9.9.3.6 M   V   1/2 */
2968     /* In the network to UE direction bit 4 is spare. The network shall set this bit to zero. */
2969     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2970     bit_offset++;
2971     proto_tree_add_bits_item(tree, hf_nas_eps_emm_detach_type_DL, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2972     bit_offset+=3;
2973
2974     /* Fix the lengths */
2975     curr_len--;
2976     curr_offset++;
2977
2978     /* No more mandatory elements */
2979     if (curr_len==0)
2980         return;
2981
2982     /* EMM cause    EMM cause 9.9.3.9   O   TV  2 */
2983     ELEM_OPT_TV(0x53, NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
2984
2985     EXTRANEOUS_DATA_CHECK(curr_len, 0);
2986
2987     return;
2988 }
2989 static void
2990 nas_emm_detach_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
2991 {
2992     guint32 curr_offset;
2993     /*guint curr_len;*/
2994
2995     curr_offset = offset;
2996     /*curr_len = len;*/
2997
2998     if (pinfo){
2999         if(pinfo->link_dir==P2P_DIR_UL){
3000             nas_emm_detach_req_UL(tvb, tree, pinfo, offset, len);
3001             return;
3002         }else if(pinfo->link_dir==P2P_DIR_DL){
3003             nas_emm_detach_req_DL(tvb, tree, pinfo, offset, len);
3004             return;
3005         }
3006     }
3007     proto_tree_add_text(tree, tvb, curr_offset, len,"UL/DL not known, can't properly dissect");
3008     proto_tree_add_text(tree, tvb, curr_offset, len,"Trying to dissect as UE terminated detach");
3009     nas_emm_detach_req_DL(tvb, tree, pinfo, offset, len);
3010     proto_tree_add_text(tree, tvb, curr_offset, len,"Trying to dissect as UE originating detach");
3011     nas_emm_detach_req_UL(tvb, tree, pinfo, offset, len);
3012
3013     return;
3014
3015 }
3016
3017 /*
3018  * 8.2.12   Downlink NAS Transport
3019  */
3020 static void
3021 nas_emm_dl_nas_trans(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3022 {
3023     guint32 curr_offset;
3024     guint32 consumed;
3025     guint   curr_len;
3026
3027     curr_offset = offset;
3028     curr_len = len;
3029
3030     pinfo->link_dir = P2P_DIR_DL;
3031
3032     /* NAS message container    NAS message container 9.9.3.22  M   LV  3-252 */
3033     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_NAS_MSG_CONT, NULL);
3034
3035     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3036 }
3037 /*
3038  * 8.2.13   EMM information
3039  */
3040 static void
3041 nas_emm_emm_inf(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3042 {
3043     guint32 curr_offset;
3044     guint32 consumed;
3045     guint   curr_len;
3046
3047     curr_offset = offset;
3048     curr_len = len;
3049
3050     /* 43   Full name for network   Network name 9.9.3.24   O   TLV 3-? */
3051     ELEM_OPT_TLV(0x43, GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Full name for network");
3052     /* 45   Short name for network  Network name 9.9.3.24   O   TLV 3-? */
3053     ELEM_OPT_TLV(0x45, GSM_A_PDU_TYPE_DTAP, DE_NETWORK_NAME, " - Short Name");
3054     /* 46   Local time zone Time zone 9.9.3.29  O   TV  2 */
3055     ELEM_OPT_TV(0x46, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE, " - Local");
3056     /* 47   Universal time and local time zone  Time zone and time 9.9.3.30 O   TV  8 */
3057     ELEM_OPT_TV(0x47, GSM_A_PDU_TYPE_DTAP, DE_TIME_ZONE_TIME, " - Universal Time and Local Time Zone");
3058     /* 49   Network daylight saving time    Daylight saving time 9.9.3.6    O   TLV 3 */
3059     ELEM_OPT_TLV(0x49, GSM_A_PDU_TYPE_DTAP, DE_DAY_SAVING_TIME, NULL);
3060
3061     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3062 }
3063
3064
3065 /*
3066  * 8.2.14   EMM status
3067  */
3068 static void
3069 nas_emm_emm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3070 {
3071     guint32 curr_offset;
3072     guint32 consumed;
3073     guint   curr_len;
3074
3075     curr_offset = offset;
3076     curr_len = len;
3077
3078     /* EMM cause    EMM cause 9.9.3.9   M   V   1 */
3079     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
3080
3081     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3082 }
3083
3084 /*
3085  * 8.2.15   Extended service request
3086  */
3087 static void
3088 nas_emm_ext_serv_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3089 {
3090     guint32 curr_offset,bit_offset;
3091     guint32 consumed;
3092     guint   curr_len;
3093
3094     curr_offset = offset;
3095     curr_len = len;
3096
3097     bit_offset = curr_offset<<3;
3098
3099     /* NAS key set identifier   NAS key set identifier 9.9.3.21 M   V   1/2 */
3100     de_emm_nas_key_set_id_bits(tvb, tree, bit_offset, NULL);
3101     bit_offset+=4;
3102     /* Service type Service type 9.9.3.27   M   V   1/2 Service type*/
3103     proto_tree_add_bits_item(tree, hf_nas_eps_service_type, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3104     bit_offset+=4;
3105     /* Fix up the lengths */
3106     curr_len--;
3107     curr_offset++;
3108
3109     /* M-TMSI   Mobile identity 9.9.2.3 M   LV  6 */
3110     ELEM_MAND_LV(NAS_PDU_TYPE_COMMON, DE_EPS_CMN_MOB_ID, " - M-TMSI");
3111     /* B-   CSFB response   CSFB response 9.9.3.5   C   TV  1 */
3112     ELEM_OPT_TV_SHORT(0xb0, NAS_PDU_TYPE_EMM, DE_EMM_CSFB_RESP, NULL);
3113     /* 57   EPS bearer context status   EPS bearer context status 9.9.2.1   O   TLV 4 */
3114     ELEM_OPT_TLV(0x57, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_EPS_BE_CTX_STATUS, NULL);
3115
3116     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3117 }
3118 /*
3119  * 8.2.16   GUTI reallocation command
3120  */
3121 static void
3122 nas_emm_guti_realloc_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3123 {
3124     guint32 curr_offset;
3125     guint32 consumed;
3126     guint   curr_len;
3127
3128     curr_offset = offset;
3129     curr_len = len;
3130
3131     /* GUTI EPS mobile identity 9.9.3.12    M   LV  12 */
3132     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - GUTI");
3133
3134     /* 54   TAI list    Tracking area identity list 9.9.3.33    O   TLV 8-98 */
3135     ELEM_OPT_TLV(0x54, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID_LST, NULL);
3136
3137     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3138 }
3139
3140 /*
3141  * 8.2.17   GUTI reallocation complete
3142  * No more IE's
3143  */
3144 /*
3145  * 8.2.18   Identity request
3146  */
3147
3148 static void
3149 nas_emm_id_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3150 {
3151     guint32 curr_offset, bit_offset;
3152     /*guint32   consumed;*/
3153     guint   curr_len;
3154
3155     curr_offset = offset;
3156     curr_len = len;
3157
3158
3159     bit_offset=curr_offset<<3;
3160
3161     /* Spare half octet Spare half octet 9.9.2.7    M   V   1/2 */
3162     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3163     bit_offset+=4;
3164
3165     /* Identity type    Identity type 2 9.9.3.17    M   V   1/2 */
3166     proto_tree_add_bits_item(tree, hf_nas_eps_emm_id_type2, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3167     bit_offset+=4;
3168     /*consumed = 1;*/
3169
3170
3171     /* Fix up the lengths */
3172     curr_len--;
3173     curr_offset++;
3174
3175     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3176 }
3177 /*
3178  * 8.2.19   Identity response
3179  */
3180 static void
3181 nas_emm_id_res(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3182 {
3183     guint32 curr_offset;
3184     guint32 consumed;
3185     guint   curr_len;
3186
3187     curr_offset = offset;
3188     curr_len = len;
3189
3190     /* Mobile identity  Mobile identity 9.9.2.3 M   LV  4-10 */
3191     ELEM_MAND_LV(NAS_PDU_TYPE_COMMON, DE_EPS_CMN_MOB_ID, NULL);
3192
3193     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3194 }
3195
3196
3197
3198 /*
3199  * 8.2.20   Security mode command
3200  */
3201 static void
3202 nas_emm_sec_mode_cmd(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3203 {
3204     guint32 curr_offset, bit_offset;
3205     guint32 consumed;
3206     guint   curr_len;
3207
3208     curr_offset = offset;
3209     curr_len = len;
3210
3211     /*  Selected NAS security algorithms    NAS security algorithms 9.9.3.23    M   V   1  */
3212     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_NAS_SEC_ALGS, " - Selected NAS security algorithms");
3213
3214     bit_offset = curr_offset<<3;
3215     /* Spare half octet Spare half octet 9.9.2.7    M   V   1/2 */
3216     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3217     bit_offset+=4;
3218     /*  NAS key set identifierASME  NAS key set identifier 9.9.3.21 M   V   1/2 */
3219     de_emm_nas_key_set_id_bits(tvb, tree, bit_offset, " ASME");
3220     bit_offset+=4;
3221
3222     /* Fix up the lengths */
3223     curr_len--;
3224     curr_offset++;
3225
3226     /*  Replayed UE security capabilities   UE security capability 9.9.3.36 M   LV  3-6 */
3227     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_UE_SEC_CAP, " - Replayed UE security capabilities");
3228     /* C-   IMEISV request  IMEISV request 9.9.3.18 O   TV  1 */
3229     ELEM_OPT_TV_SHORT( 0xC0 , NAS_PDU_TYPE_EMM, DE_EMM_IMEISV_REQ , NULL );
3230     /* 55   Replayed NonceUE    Nonce 9.9.3.25  O   TV  5 */
3231     ELEM_OPT_TV(0x55, GSM_A_PDU_TYPE_GM, DE_EMM_NONCE, " - Replayed NonceUE");
3232     /* 56   NonceMME    Nonce 9.9.3.25  O   TV  5 */
3233     ELEM_OPT_TV(0x56, GSM_A_PDU_TYPE_GM, DE_EMM_NONCE, " - NonceMME");
3234
3235     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3236 }
3237 /*
3238  * 8.2.21   Security mode complete
3239  */
3240 static void
3241 nas_emm_sec_mode_comp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3242 {
3243     guint32 curr_offset;
3244     guint32 consumed;
3245     guint   curr_len;
3246
3247     curr_offset = offset;
3248     curr_len = len;
3249
3250     if (curr_len == 0)
3251         return;
3252
3253     /* 23   IMEISV  Mobile identity 9.9.2.3 O   TLV 11 */
3254     ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_MOB_ID, " - IMEISV");
3255
3256     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3257 }
3258 /*
3259  * 8.2.22   Security mode reject
3260  */
3261 static void
3262 nas_emm_sec_mode_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3263 {
3264     guint32 curr_offset;
3265     guint32 consumed;
3266     guint   curr_len;
3267
3268     curr_offset = offset;
3269     curr_len = len;
3270
3271     /* EMM cause    EMM cause 9.9.3.9   M   V   1 */
3272     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
3273
3274     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3275 }
3276 /*
3277  * 8.2.23   Security protected NAS message
3278  */
3279 #if 0
3280 static int
3281 nas_emm_sec_prot_msg(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3282 {
3283     guint32 curr_offset;
3284     guint   curr_len;
3285     guint8 security_header_type;
3286
3287     curr_offset = offset;
3288     curr_len = len;
3289
3290     /* Security header type Security header type 9.3.1 M V 1/2 */
3291     security_header_type = tvb_get_guint8(tvb,offset)>>4;
3292     proto_tree_add_item(tree, hf_nas_eps_security_header_type, tvb, 0, 1, ENC_BIG_ENDIAN);
3293     /* Protocol discriminator Protocol discriminator 9.2 M V 1/2 */
3294     proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, 0, 1, ENC_BIG_ENDIAN);
3295     offset++;
3296     /* Message authentication code  Message authentication code 9.5 M   V   4 */
3297     if (security_header_type !=0){
3298         /* Message authentication code */
3299         proto_tree_add_item(tree, hf_nas_eps_msg_auth_code, tvb, offset, 4, ENC_BIG_ENDIAN);
3300         offset+=4;
3301         if ((security_header_type==2)||(security_header_type==4)){
3302             /* Integrity protected and ciphered = 2, Integrity protected and ciphered with new EPS security context = 4 */
3303             proto_tree_add_text(tree, tvb, offset, len-5,"Ciphered message");
3304             return offset;
3305         }
3306     }else{
3307         proto_tree_add_text(tree, tvb, offset, len,"Not a security protected message");
3308         return offset;
3309     }
3310     /* Sequence number  Sequence number 9.6 M   V   1 */
3311     proto_tree_add_item(tree, hf_nas_eps_seq_no, tvb, offset, 1, ENC_BIG_ENDIAN);
3312     offset++;
3313     /* NAS message  NAS message 9.7 M   V   1-n  */
3314     return offset;
3315 }
3316 #endif
3317 /*
3318  * 8.2.24   Service reject
3319  */
3320 static void
3321 nas_emm_serv_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3322 {
3323     guint32 curr_offset;
3324     guint32 consumed;
3325     guint   curr_len;
3326
3327     curr_offset = offset;
3328     curr_len = len;
3329
3330     /* EMM cause    EMM cause 9.9.3.9   M   V   1 */
3331     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
3332
3333     /* 5B   T3442 value GPRS timer 9.9.3.16 C   TV  2 */
3334     ELEM_OPT_TV(0x5b, GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - T3442 value");
3335
3336     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3337 }
3338 /*
3339  * 8.2.25   Service request
3340  * This message is sent by the UE to the network to request the establishment
3341  * of a NAS signalling connection and of the radio and S1 bearers.
3342  * Its structure does not follow the structure of a standard layer 3 message. See table 8.2.25.1.
3343  */
3344 /* Table 8.2.25.1
3345  * Protocol discriminator Protocol discriminator 9.2 M V 1/2
3346  * Security header type Security header type 9.3.1 M V 1/2
3347  * KSI and sequence number KSI and sequence number 9.9.3.19 M V 1
3348  * Message authentication code (short) Short MAC 9.9.3.28 M V 2
3349  */
3350 static void
3351 nas_emm_service_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3352 {
3353     guint32 curr_offset;
3354     guint32 consumed;
3355     guint   curr_len;
3356
3357     curr_offset = offset;
3358     curr_len = len;
3359
3360     /* KSI and sequence number 9.9.3.19 M V 1   */
3361     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_KSI_AND_SEQ_NO, NULL);
3362
3363     /* Short MAC 9.9.3.28 M V 2 */
3364     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_SHORT_MAC, " - Message authentication code (short)");
3365
3366     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3367 }
3368
3369 /*
3370  * 8.2.26   Tracking area update accept
3371  */
3372 static void
3373 nas_emm_trac_area_upd_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3374 {
3375     guint32 curr_offset, bit_offset;
3376     guint32 consumed;
3377     guint   curr_len;
3378
3379     curr_offset = offset;
3380     curr_len = len;
3381
3382     /*  Spare half octet    Spare half octet 9.9.2.7    M   V   1/2 */
3383     bit_offset = curr_offset<<3;
3384     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3385     bit_offset+=4;
3386     /*  EPS update result   EPS update result 9.9.3.13  M   V   1/2 */
3387     proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3388     bit_offset++;
3389     proto_tree_add_bits_item(tree, hf_nas_eps_eps_update_result_value, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
3390     bit_offset+=3;
3391     /* Fix up the lengths */
3392     curr_len--;
3393     curr_offset++;
3394     /* No more mandatory elements */
3395     if (curr_len==0)
3396         return;
3397     /* 5A   T3412 value GPRS timer 9.9.3.16 O   TV  2 */
3398     ELEM_OPT_TV(0x5a, GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - T3412 value");
3399     /* 50   GUTI    EPS mobile identity 9.9.3.12    O   TLV 13 */
3400     ELEM_OPT_TLV(0x50, NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - GUTI");
3401     /* 54   TAI list    Tracking area identity list 9.9.3.33    O   TLV 8-98 */
3402     ELEM_OPT_TLV(0x54, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID_LST, NULL);
3403     /* 57   EPS bearer context status   EPS bearer context status 9.9.2.1   O   TLV 4 */
3404     ELEM_OPT_TLV(0x57, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_EPS_BE_CTX_STATUS, NULL);
3405     /* 13   Location area identification    Location area identification 9.9.2.2    O   TV  6 */
3406     ELEM_OPT_TV(0x13, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_LOC_AREA_ID, NULL);
3407     /* 23   MS identity Mobile identity 9.9.2.3 O   TLV 7-10  */
3408     ELEM_OPT_TLV(0x23, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_MOB_ID, " - MS identity");
3409     /* 53   EMM cause   EMM cause 9.9.3.9   O   TV  2  */
3410     ELEM_OPT_TV(0x53, NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
3411     /* 17   T3402 value GPRS timer 9.9.3.16 O   TV  2  */
3412     ELEM_OPT_TV(0x17, GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - T3402 value");
3413     /* 59   T3423 value GPRS timer 9.9.3.16 O   TV  2 */
3414     ELEM_OPT_TV(0x59, GSM_A_PDU_TYPE_GM, DE_GPRS_TIMER, " - T3423 value");
3415     /* 4A   Equivalent PLMNs    PLMN list 9.9.2.8   O   TLV 5-47 */
3416     ELEM_OPT_TLV(0x4a, NAS_PDU_TYPE_COMMON, DE_PLMN_LIST, " - PLMN list");
3417     /* 34   Emergency Number List   Emergency Number List 9.9.3.37  O   TLV 5-50 */
3418     ELEM_OPT_TLV(0x34, GSM_A_PDU_TYPE_DTAP, DE_EMERGENCY_NUM_LIST, NULL);
3419     /* 64   EPS network feature support EPS network feature support 9.9.3.12A   O   TLV 3 */
3420     ELEM_OPT_TLV(0x64, NAS_PDU_TYPE_EMM, DE_EMM_EPS_NET_FEATURE_SUP, NULL);
3421     /* F-   Additional update result    Additional update result 9.9.3.0A   O   TV  1 */
3422     ELEM_OPT_TV_SHORT( 0xF0 , NAS_PDU_TYPE_EMM, DE_EMM_ADD_UPD_RES, NULL );
3423
3424     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3425 }
3426 /*
3427  * 8.2.27   Tracking area update complete
3428  * No more IE's
3429  */
3430 /*
3431  * 8.2.28   Tracking area update reject
3432  */
3433 static void
3434 nas_emm_trac_area_upd_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3435 {
3436     guint32 curr_offset;
3437     guint32 consumed;
3438     guint   curr_len;
3439
3440     curr_offset = offset;
3441     curr_len = len;
3442
3443     /* EMM cause    EMM cause 9.9.3.9   M   V   1 */
3444     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_CAUSE, NULL);
3445
3446     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3447 }
3448 /*
3449  * 8.2.29   Tracking area update request
3450  */
3451 static void
3452 nas_emm_trac_area_upd_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3453 {
3454
3455     guint32 curr_offset, bit_offset;
3456     guint32 consumed;
3457     guint   curr_len;
3458
3459     curr_offset = offset;
3460     curr_len = len;
3461
3462     bit_offset = curr_offset<<3;
3463
3464     /*  NAS key set identifierASME  NAS key set identifier 9.9.3.21 M   V   1/2 */
3465     de_emm_nas_key_set_id_bits(tvb, tree, bit_offset, " ASME");
3466     bit_offset+=4;
3467
3468     /*  EPS update type EPS update type 9.9.3.14    M   V   1/2 */
3469     proto_tree_add_bits_item(tree, hf_nas_eps_active_flg, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
3470     bit_offset++;
3471     proto_tree_add_bits_item(tree, hf_nas_eps_eps_update_type_value, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
3472     bit_offset+=3;
3473
3474     /* Fix the lengths */
3475     curr_len--;
3476     curr_offset++;
3477     /*  Old GUTI    EPS mobile identity 9.9.3.12    M   LV  12 */
3478     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - Old GUTI");
3479     /* No more Mandatory elements */
3480
3481     /*  B-  NAS key set identifier  Non-current native NAS key set identifier 9.9.3.21  O   TV  1 */
3482     ELEM_OPT_TV_SHORT( 0xb0 , NAS_PDU_TYPE_EMM, DE_EMM_NAS_KEY_SET_ID , " - Non-current native NAS key set identifier" );
3483     /* 8-   GPRS ciphering key sequence number  Ciphering key sequence number 9.9.3.4a  O   TV  1  */
3484     ELEM_OPT_TV_SHORT(0x80, GSM_A_PDU_TYPE_COMMON, DE_CIPH_KEY_SEQ_NUM, " - GPRS ciphering key sequence number");
3485     /* 19   Old P-TMSI signature    P-TMSI signature 9.9.3.26   O   TV  4 */
3486     ELEM_OPT_TV( 0x19 , GSM_A_PDU_TYPE_GM, DE_P_TMSI_SIG, " - Old P-TMSI Signature");
3487     /* 50   Additional GUTI EPS mobile identity 9.9.3.12    O   TLV 13 */
3488     ELEM_OPT_TLV(0x50, NAS_PDU_TYPE_EMM, DE_EMM_EPS_MID, " - Additional GUTI");
3489     /* 55   NonceUE Nonce 9.9.3.25  O   TV  5 */
3490     ELEM_OPT_TV(0x55, GSM_A_PDU_TYPE_GM, DE_EMM_NONCE, " - NonceUE");
3491     /* 58   UE network capability   UE network capability 9.9.3.34  O   TLV 4-15 */
3492     ELEM_OPT_TLV(0x58, NAS_PDU_TYPE_EMM, DE_EMM_UE_NET_CAP, NULL);
3493     /* 52   Last visited registered TAI Tracking area identity 9.9.3.32 O   TV  6 */
3494     ELEM_OPT_TV(0x52, NAS_PDU_TYPE_EMM, DE_EMM_TRAC_AREA_ID, " - Last visited registered TAI");
3495     /* 5C   DRX parameter   DRX parameter 9.9.3.8   O   TV  3 */
3496     ELEM_OPT_TV(0x5c, GSM_A_PDU_TYPE_GM, DE_DRX_PARAM, NULL );
3497     /* A-   UE radio capability information update needed   UE radio capability information update needed 9.9.3.35  O   TV  1 */
3498     ELEM_OPT_TV_SHORT( 0xA0 , NAS_PDU_TYPE_EMM, DE_EMM_UE_RA_CAP_INF_UPD_NEED , NULL );
3499     /* 57   EPS bearer context status   EPS bearer context status 9.9.2.1   O   TLV 4 */
3500     ELEM_OPT_TLV(0x57, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_EPS_BE_CTX_STATUS, NULL);
3501     /* 31   MS network capability   MS network capability 9.9.3.20  O   TLV 4-10 */
3502     ELEM_OPT_TLV( 0x31 , GSM_A_PDU_TYPE_GM, DE_MS_NET_CAP , NULL );
3503     /* 13   Old location area identification    Location area identification 9.9.2.2    O   TV  6 */
3504     ELEM_OPT_TV(0x13, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_LOC_AREA_ID, " - Old location area identification");
3505     /* 9-   TMSI status TMSI status 9.9.3.31    O   TV  1  */
3506     ELEM_OPT_TV_SHORT( 0x90 , GSM_A_PDU_TYPE_GM, DE_TMSI_STAT , NULL );
3507     /* 11   Mobile station classmark 2  Mobile station classmark 2 9.9.2.5  O   TLV 5 */
3508     ELEM_OPT_TLV( 0x11, NAS_PDU_TYPE_COMMON, DE_EPS_MS_CM_2 , NULL );
3509     /* 20   Mobile station classmark 3  Mobile station classmark 3 9.9.2.5  O   TLV 2-34 */
3510     ELEM_OPT_TLV( 0x20, NAS_PDU_TYPE_COMMON, DE_EPS_MS_CM_3 , NULL );
3511     /* 40   Supported Codecs    Supported Codec List 9.9.2.10   O   TLV 5-n */
3512     ELEM_OPT_TLV(0x40, GSM_A_PDU_TYPE_DTAP, DE_SUP_CODEC_LIST, " - Supported Codecs");
3513     /* F-   Additional update type  Additional update type 9.9.3.0B O   TV  1 */
3514     ELEM_OPT_TV_SHORT( 0xF0 , NAS_PDU_TYPE_EMM, DE_EMM_ADD_UPD_TYPE, NULL );
3515     /* 5D   Voice domain preference and UE's usage setting  Voice domain preference and UE's usage setting 9.9.3.44 O   TLV 3 */
3516     ELEM_OPT_TLV(0x5D, GSM_A_PDU_TYPE_GM, DE_VOICE_DOMAIN_PREF, NULL);
3517
3518     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3519 }
3520
3521 /*
3522  * 8.2.30   Uplink NAS Transport
3523  */
3524 static void
3525 nas_emm_ul_nas_trans(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3526 {
3527     guint32 curr_offset;
3528     guint32 consumed;
3529     guint   curr_len;
3530
3531     curr_offset = offset;
3532     curr_len = len;
3533
3534     pinfo->link_dir = P2P_DIR_UL;
3535
3536     /* NAS message container    NAS message container 9.9.3.22  M   LV  3-252*/
3537     ELEM_MAND_LV(NAS_PDU_TYPE_EMM, DE_EMM_NAS_MSG_CONT, NULL);
3538
3539     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3540 }
3541
3542 /*
3543  * 8.2.31   Downlink generic NAS transport
3544  */
3545 static void
3546 nas_emm_dl_gen_nas_trans(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3547 {
3548     guint32 curr_offset;
3549     guint32 consumed;
3550     guint   curr_len;
3551
3552     curr_offset = offset;
3553     curr_len = len;
3554
3555     pinfo->link_dir = P2P_DIR_DL;
3556
3557     /* Generic message container type Generic message container type 9.9.3.42 M V 1 */
3558     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_GEN_MSG_CONT_TYPE, NULL);
3559     /* Generic message container Generic message container 9.9.3.43 M LV-E 3-n */
3560     ELEM_MAND_LV_E(NAS_PDU_TYPE_EMM, DE_EMM_GEN_MSG_CONT, NULL)
3561     /* 65 Additional information Additional information 9.9.2.0 O TLV 3-n */
3562     ELEM_OPT_TLV(0x65, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_ADD_INFO, NULL);
3563
3564     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3565
3566     eps_nas_gen_msg_cont_type = 0;
3567 }
3568
3569 /*
3570  * 8.2.32   Uplink generic NAS transport
3571  */
3572 static void
3573 nas_emm_ul_gen_nas_trans(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3574 {
3575     guint32 curr_offset;
3576     guint32 consumed;
3577     guint   curr_len;
3578
3579     curr_offset = offset;
3580     curr_len = len;
3581
3582     pinfo->link_dir = P2P_DIR_UL;
3583
3584     /* Generic message container type Generic message container type 9.9.3.42 M V 1 */
3585     ELEM_MAND_V(NAS_PDU_TYPE_EMM, DE_EMM_GEN_MSG_CONT_TYPE, NULL);
3586     /* Generic message container Generic message container 9.9.3.43 M LV-E 3-n */
3587     ELEM_MAND_LV_E(NAS_PDU_TYPE_EMM, DE_EMM_GEN_MSG_CONT, NULL)
3588     /* 65 Additional information Additional information 9.9.2.0 O TLV 3-n */
3589     ELEM_OPT_TLV(0x65, NAS_PDU_TYPE_COMMON, DE_EPS_CMN_ADD_INFO, NULL);
3590
3591     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3592
3593     eps_nas_gen_msg_cont_type = 0;
3594 }
3595
3596 /*
3597  * 8.3  EPS session management messages
3598  */
3599
3600 /*
3601  * 8.3.1    Activate dedicated EPS bearer context accept
3602  */
3603 static void
3604 nas_esm_act_ded_eps_bearer_ctx_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3605 {
3606     guint32 curr_offset;
3607     guint32 consumed;
3608     guint   curr_len;
3609
3610     if(len==0)
3611         return;
3612
3613     curr_offset = offset;
3614     curr_len = len;
3615
3616     /* This message is sent by the UE to the network */
3617     pinfo->link_dir = P2P_DIR_UL;
3618
3619     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3620     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3621
3622     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3623 }
3624
3625 /*
3626  * 8.3.2    Activate dedicated EPS bearer context reject
3627  */
3628 static void
3629 nas_esm_act_ded_eps_bearer_ctx_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3630 {
3631     guint32 curr_offset;
3632     guint32 consumed;
3633     guint   curr_len;
3634
3635     curr_offset = offset;
3636     curr_len = len;
3637
3638     /* This message is sent by UE to the network to reject activation of a dedicated EPS bearer context */
3639     pinfo->link_dir = P2P_DIR_UL;
3640
3641     /* ESM cause    ESM cause 9.9.4.2   M   V   1 */
3642     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
3643     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3644     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3645
3646     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3647 }
3648 /*
3649  * 8.3.3    Activate dedicated EPS bearer context request
3650  */
3651 static void
3652 nas_esm_act_ded_eps_bearer_ctx_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3653 {
3654     guint32 curr_offset, bit_offset;
3655     guint32 consumed;
3656     guint   curr_len;
3657
3658     curr_offset = offset;
3659     curr_len = len;
3660
3661     /* This message is sent by the network to the UE to request activation of a dedicated EPS bearer context... */
3662     pinfo->link_dir = P2P_DIR_DL;
3663
3664
3665     /* Spare half octet Spare half octet 9.9.2.9    M   V   1/2 */
3666     bit_offset = curr_offset<<3;
3667     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3668     bit_offset+=4;
3669     /* Linked EPS bearer identity   Linked EPS bearer identity 9.9.4.6  M   V   1/2 */
3670     proto_tree_add_bits_item(tree, hf_nas_eps_esm_linked_bearer_id, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3671     bit_offset+=4;
3672     /* Fix the lengths */
3673     curr_len--;
3674     curr_offset++;
3675
3676     /* EPS QoS  EPS quality of service 9.9.4.3  M   LV  2-10 */
3677     ELEM_MAND_LV(NAS_PDU_TYPE_ESM, DE_ESM_EPS_QOS, NULL);
3678     /* TFT  Traffic flow template 9.9.4.16  M   LV  2-256 */
3679     ELEM_MAND_LV( GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , NULL );
3680     /* 5D   Transaction identifier  Transaction identifier 9.9.4.17 O   TLV 3-4 */
3681     ELEM_OPT_TLV( 0x5d , GSM_A_PDU_TYPE_GM, DE_LINKED_TI , " - Transaction identifier" );
3682     /* 30   Negotiated QoS  Quality of service 9.9.4.12 O   TLV 14-18 */
3683     ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
3684     /* 32   Negotiated LLC SAPI LLC service access point identifier 9.9.4.7 O   TV  2 */
3685     ELEM_OPT_TV( 0x32 , GSM_A_PDU_TYPE_GM, DE_LLC_SAPI , " - Negotiated LLC SAPI" );
3686     /* 8-   Radio priority  Radio priority 9.9.4.13 O   TV  1 */
3687     ELEM_OPT_TV_SHORT ( 0x80 , GSM_A_PDU_TYPE_GM , DE_RAD_PRIO , NULL );
3688     /* 34   Packet flow Identifier  Packet flow Identifier 9.9.4.8  O   TLV 3 */
3689     ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL );
3690     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3691     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3692
3693     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3694 }
3695
3696 /*
3697  * 8.3.4    Activate default EPS bearer context accept
3698  */
3699 static void
3700 nas_esm_act_def_eps_bearer_ctx_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3701 {
3702     guint32 curr_offset;
3703     guint32 consumed;
3704     guint   curr_len;
3705
3706     curr_offset = offset;
3707     curr_len = len;
3708
3709     if(len==0)
3710         return;
3711
3712     /* This message is sent by the UE to the network to acknowledge activation of a default EPS bearer context */
3713     pinfo->link_dir = P2P_DIR_UL;
3714
3715     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253  */
3716     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3717
3718     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3719 }
3720
3721 /*
3722  * 8.3.5    Activate default EPS bearer context reject
3723  */
3724 static void
3725 nas_esm_act_def_eps_bearer_ctx_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3726 {
3727     guint32 curr_offset;
3728     guint32 consumed;
3729     guint   curr_len;
3730
3731     curr_offset = offset;
3732     curr_len = len;
3733
3734     /* This message is sent by UE to the network to reject activation of a default EPS bearer context. */
3735     pinfo->link_dir = P2P_DIR_UL;
3736
3737     /*  ESM cause   ESM cause 9.9.4.4   M   V   1 */
3738     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
3739     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3740     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3741
3742     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3743 }
3744
3745 /*
3746  * 8.3.6 Activate default EPS bearer context request
3747  */
3748 static void
3749 nas_esm_act_def_eps_bearer_ctx_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3750 {
3751     guint32 curr_offset;
3752     guint32 consumed;
3753     guint   curr_len;
3754
3755     curr_offset = offset;
3756     curr_len = len;
3757
3758     /* This message is sent by the network to the UE to request activation of a default EPS bearer context. */
3759     pinfo->link_dir = P2P_DIR_DL;
3760
3761     /*  EPS QoS EPS quality of service 9.9.4.3  M   LV  2-10 */
3762     ELEM_MAND_LV(NAS_PDU_TYPE_ESM, DE_ESM_EPS_QOS, NULL);
3763     /*  Access point name   Access point name 9.9.4.1   M   LV  2-101 */
3764     ELEM_MAND_LV( GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL );
3765     /*  PDN address PDN address 9.9.4.9 M   LV  6-14 DE_ESM_PDN_ADDR*/
3766     ELEM_MAND_LV( NAS_PDU_TYPE_ESM, DE_ESM_PDN_ADDR , NULL );
3767     /* 5D   Transaction identifier  Transaction identifier 9.9.4.17 O   TLV 3-4 */
3768     ELEM_OPT_TLV( 0x5d , GSM_A_PDU_TYPE_GM, DE_LINKED_TI , " - Transaction identifier" );
3769     /* 30   Negotiated QoS  Quality of service 9.9.4.12 O   TLV 14-18 */
3770     ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_GM, DE_QOS , " - Negotiated QoS" );
3771     /* 32   Negotiated LLC SAPI LLC service access point identifier 9.9.4.7 O   TV  2 */
3772     ELEM_OPT_TV( 0x32 , GSM_A_PDU_TYPE_GM, DE_LLC_SAPI , " - Negotiated LLC SAPI" );
3773     /* 8-   Radio priority  Radio priority 9.9.4.13 O   TV  1 */
3774     ELEM_OPT_TV_SHORT ( 0x80 , GSM_A_PDU_TYPE_GM , DE_RAD_PRIO , NULL );
3775     /* 34   Packet flow Identifier  Packet flow Identifier 9.9.4.8  O   TLV 3 */
3776     ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL );
3777     /* 5E   APN-AMBR    APN aggregate maximum bit rate 9.9.4.2  O   TLV 4-8 DE_ESM_APN_AGR_MAX_BR*/
3778     ELEM_OPT_TLV( 0x5e , NAS_PDU_TYPE_ESM, DE_ESM_APN_AGR_MAX_BR , NULL );
3779     /* 58   ESM cause   ESM cause 9.9.4.4   O   TV  2 */
3780     ELEM_OPT_TV( 0x58 , NAS_PDU_TYPE_ESM, DE_ESM_CAUSE , NULL );
3781     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3782     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3783
3784     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3785 }
3786
3787 /*
3788  * 8.3.7    Bearer resource allocation reject
3789  */
3790 static void
3791 nas_esm_bearer_res_all_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3792 {
3793     guint32 curr_offset;
3794     guint32 consumed;
3795     guint   curr_len;
3796
3797     curr_offset = offset;
3798     curr_len = len;
3799
3800     /* This message is sent by the network to the UE to reject the allocation of a dedicated bearer resource. */
3801     pinfo->link_dir = P2P_DIR_DL;
3802
3803     /*  ESM cause   ESM cause 9.9.4.4   M   V   1 */
3804     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
3805     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3806     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3807
3808     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3809 }
3810
3811 /*
3812  * 8.3.8    Bearer resource allocation request
3813  */
3814 static void
3815 nas_esm_bearer_res_all_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3816 {
3817     guint32 curr_offset, bit_offset;
3818     guint32 consumed;
3819     guint   curr_len;
3820
3821     curr_offset = offset;
3822     curr_len = len;
3823
3824     /* This message is sent by the UE to the network to request the allocation of a dedicated bearer resource. */
3825     pinfo->link_dir = P2P_DIR_UL;
3826
3827     /*  Spare half octet    Spare half octet 9.9.2.9    M   V   1/2 */
3828     bit_offset = curr_offset<<3;
3829     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3830     bit_offset+=4;
3831     /*  Linked EPS bearer identity  Linked EPS bearer identity 9.9.4.6  M   V   1/2 */
3832     proto_tree_add_bits_item(tree, hf_nas_eps_esm_linked_bearer_id, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3833     bit_offset+=4;
3834     /* Fix the lengths */
3835     curr_len--;
3836     curr_offset++;
3837
3838     /*  Traffic flow aggregate  Traffic flow aggregate description 9.9.4.15 M   LV  2-256 */
3839     ELEM_MAND_LV( GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , " - Traffic flow aggregate" );
3840     /*  Required traffic flow QoS   EPS quality of service 9.9.4.3  M   LV  2-10 */
3841     ELEM_MAND_LV(NAS_PDU_TYPE_ESM, DE_ESM_EPS_QOS, " - Required traffic flow QoS");
3842     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3843     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3844
3845     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3846 }
3847 /*
3848  * 8.3.9    Bearer resource modification reject
3849  */
3850 static void
3851 nas_esm_bearer_res_mod_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3852 {
3853     guint32 curr_offset;
3854     guint32 consumed;
3855     guint   curr_len;
3856
3857     curr_offset = offset;
3858     curr_len = len;
3859
3860     /* This message is sent by the network to the UE to reject the modification of a dedicated bearer resource. */
3861     pinfo->link_dir = P2P_DIR_DL;
3862
3863     /*  ESM cause   ESM cause 9.9.4.4   M   V   1 */
3864     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
3865     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3866     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3867
3868     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3869 }
3870 /*
3871  * 8.3.10   Bearer resource modification request
3872  */
3873 static void
3874 nas_esm_bearer_res_mod_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3875 {
3876     guint32 curr_offset, bit_offset;
3877     guint32 consumed;
3878     guint   curr_len;
3879
3880     curr_offset = offset;
3881     curr_len = len;
3882
3883     /* This message is sent by the UE to the network to request the modification of a dedicated bearer resource. */
3884     pinfo->link_dir = P2P_DIR_UL;
3885
3886     /*  Spare half octet    Spare half octet 9.9.2.9    M   V   1/2 */
3887     bit_offset = curr_offset<<3;
3888     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3889     bit_offset+=4;
3890     /* EPS bearer identity for packet filter    Linked EPS bearer identity 9.9.4.6  M   V   1/2 */
3891     proto_tree_add_bits_item(tree, hf_nas_eps_esm_linked_bearer_id, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
3892     bit_offset+=4;
3893     /* Fix the lengths */
3894     curr_len--;
3895     curr_offset++;
3896     /* Traffic flow aggregate   Traffic flow aggregate description 9.9.4.15 M   LV  2-256 */
3897     ELEM_MAND_LV( GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , " - Traffic flow aggregate" );
3898     /* 5B   Required traffic flow QoS   EPS quality of service 9.9.4.3  O   TLV 3-11 */
3899     ELEM_OPT_TLV( 0x5B , NAS_PDU_TYPE_ESM, DE_ESM_EPS_QOS , " - Required traffic flow QoS" );
3900     /* 58   ESM cause   ESM cause 9.9.4.4   O   TV  2 */
3901     ELEM_OPT_TV( 0x58 , NAS_PDU_TYPE_ESM, DE_ESM_CAUSE , NULL );
3902     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253  */
3903     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3904
3905     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3906 }
3907 /*
3908  * 8.3.11 Deactivate EPS bearer context accept
3909  */
3910 static void
3911 nas_esm_deact_eps_bearer_ctx_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3912 {
3913     guint32 curr_offset;
3914     guint32 consumed;
3915     guint   curr_len;
3916
3917     curr_offset = offset;
3918     curr_len = len;
3919
3920     if(len==0)
3921         return;
3922
3923     /* This message is sent by the UE to acknowledge deactivation of the EPS bearer context... */
3924     pinfo->link_dir = P2P_DIR_UL;
3925
3926     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV */
3927     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3928
3929     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3930 }
3931 /*
3932  * 8.3.12 Deactivate EPS bearer context request
3933  */
3934 static void
3935 nas_esm_deact_eps_bearer_ctx_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3936 {
3937     guint32 curr_offset;
3938     guint32 consumed;
3939     guint   curr_len;
3940
3941     curr_offset = offset;
3942     curr_len = len;
3943
3944     /* This message is sent by the network to request deactivation of an active EPS bearer context. */
3945     pinfo->link_dir = P2P_DIR_DL;
3946
3947     /*  ESM cause   ESM cause 9.9.4.4   M   V   1 */
3948     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
3949     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV */
3950     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3951
3952     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3953 }
3954
3955 /*
3956  * 8.3.13 ESM information request
3957  * No IE:s
3958  */
3959 static void
3960 nas_esm_inf_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
3961 {
3962     guint32 curr_offset;
3963     guint   curr_len;
3964
3965     curr_offset = offset;
3966     curr_len = len;
3967
3968     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3969 }
3970 /*
3971  * 8.3.14 ESM information response
3972  */
3973 static void
3974 nas_esm_inf_resp(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
3975 {
3976     guint32 curr_offset;
3977     guint32 consumed;
3978     guint   curr_len;
3979
3980     curr_offset = offset;
3981     curr_len = len;
3982
3983     if(len==0)
3984         return;
3985
3986     /* This message is sent by the UE to the network in response to an ESM INFORMATION REQUEST... */
3987     pinfo->link_dir = P2P_DIR_UL;
3988
3989     /* 28   Access point name   Access point name 9.9.4.1   O   TLV 3-102 */
3990     ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL );
3991     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
3992     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
3993
3994     EXTRANEOUS_DATA_CHECK(curr_len, 0);
3995 }
3996 /*
3997  * 8.3.15 ESM status
3998  */
3999 static void
4000 nas_esm_status(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4001 {
4002     guint32 curr_offset;
4003     guint32 consumed;
4004     guint   curr_len;
4005
4006     curr_offset = offset;
4007     curr_len = len;
4008
4009     /* ESM cause    ESM cause 9.9.4.4   M   V   1 */
4010     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
4011
4012     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4013 }
4014 /*
4015  * 8.3.16 Modify EPS bearer context accept
4016  */
4017 static void
4018 nas_esm_mod_eps_bearer_ctx_acc(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4019 {
4020     guint32 curr_offset;
4021     guint32 consumed;
4022     guint   curr_len;
4023
4024     curr_offset = offset;
4025     curr_len = len;
4026
4027     if(len==0)
4028         return;
4029
4030     /* This message is sent by the UE to the network to acknowledge the modification of an active EPS bearer context. */
4031     pinfo->link_dir = P2P_DIR_UL;
4032
4033     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
4034     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
4035
4036     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4037 }
4038 /*
4039  * 8.3.17 Modify EPS bearer context reject
4040  */
4041 static void
4042 nas_esm_mod_eps_bearer_ctx_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4043 {
4044     guint32 curr_offset;
4045     guint32 consumed;
4046     guint   curr_len;
4047
4048     curr_offset = offset;
4049     curr_len = len;
4050
4051     /* This message is sent by the UE or the network to reject a modification of an active EPS bearer context. */
4052     pinfo->link_dir = P2P_DIR_UL;
4053
4054     /* ESM cause    ESM cause 9.9.4.4   M   V   1 */
4055     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
4056     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
4057     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
4058
4059     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4060 }
4061 /*
4062  * 8.3.18 Modify EPS bearer context request
4063  */
4064 static void
4065 nas_esm_mod_eps_bearer_ctx_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4066 {
4067     guint32 curr_offset;
4068     guint32 consumed;
4069     guint   curr_len;
4070
4071     curr_offset = offset;
4072     curr_len = len;
4073
4074     if(len==0)
4075         return;
4076
4077     /*This message is sent by the network to inform the UE about events which are relevant for the upper layer... */
4078     pinfo->link_dir = P2P_DIR_DL;
4079
4080     /* 5B   New EPS QoS EPS quality of service 9.9.4.3  O   TLV 3-11 */
4081     ELEM_OPT_TLV( 0x5B , NAS_PDU_TYPE_ESM, DE_ESM_EPS_QOS , " - New EPS QoS" );
4082     /* 36   TFT Traffic flow template 9.9.4.16  O   TLV 3-257 */
4083     ELEM_OPT_TLV( 0x36 , GSM_A_PDU_TYPE_GM, DE_TRAFFIC_FLOW_TEMPLATE , NULL );
4084     /* 30   New QoS Quality of service 9.9.4.12 O   TLV 14-18 */
4085     ELEM_OPT_TLV( 0x30 , GSM_A_PDU_TYPE_GM, DE_QOS , " - New QoS" );
4086     /* 32   Negotiated LLC SAPI LLC service access point identifier 9.9.4.7 O   TV  2 */
4087     ELEM_OPT_TV( 0x32 , GSM_A_PDU_TYPE_GM, DE_LLC_SAPI , " - Negotiated LLC SAPI" );
4088     /* 8-   Radio priority  Radio priority 9.9.4.13 O   TV  1 */
4089     ELEM_OPT_TV_SHORT ( 0x80 , GSM_A_PDU_TYPE_GM , DE_RAD_PRIO , NULL );
4090     /* 34   Packet flow Identifier  Packet flow Identifier 9.9.4.8  O   TLV 3 */
4091     ELEM_OPT_TLV( 0x34 , GSM_A_PDU_TYPE_GM, DE_PACKET_FLOW_ID , NULL );
4092     /* 5E   APN-AMBR    APN aggregate maximum bit rate 9.9.4.2  O   TLV 4-8 */
4093     ELEM_OPT_TLV( 0x5E , NAS_PDU_TYPE_ESM, DE_ESM_APN_AGR_MAX_BR , NULL );
4094     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
4095     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
4096
4097     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4098 }
4099 /*
4100  * 8.3.18A Notification
4101  */
4102 static void
4103 nas_esm_notification(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len)
4104 {
4105     guint32 curr_offset;
4106     guint32 consumed;
4107     guint   curr_len;
4108
4109     curr_offset = offset;
4110     curr_len = len;
4111
4112     /* Notification indicator Notification indicator 9.9.4.7A M LV 2 */
4113     ELEM_MAND_LV(NAS_PDU_TYPE_ESM, DE_ESM_NOTIF_IND, NULL);
4114
4115     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4116 }
4117
4118 /*
4119  * 8.3.19 PDN connectivity reject
4120  */
4121 static void
4122 nas_esm_pdn_con_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4123 {
4124     guint32 curr_offset;
4125     guint32 consumed;
4126     guint   curr_len;
4127
4128     curr_offset = offset;
4129     curr_len = len;
4130
4131     /*This message is sent by the network to the UE to reject establishment of a PDN connection. */
4132     pinfo->link_dir = P2P_DIR_DL;
4133
4134     /* ESM cause    ESM cause 9.9.4.4   M   V   1 */
4135     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
4136     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
4137     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
4138
4139     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4140 }
4141
4142 /*
4143  * 8.3.20 PDN connectivity request
4144  */
4145 static void
4146 nas_esm_pdn_con_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4147 {
4148     guint32 curr_offset;
4149     guint32 consumed;
4150     guint   curr_len;
4151
4152     curr_offset = offset;
4153     curr_len = len;
4154
4155     /*This message is sent by the UE to the network to initiate establishment of a PDN connection. */
4156     pinfo->link_dir = P2P_DIR_UL;
4157
4158     /* PDN type PDN type 9.9.4.10 M V 1/2 */
4159     proto_tree_add_bits_item(tree, hf_nas_eps_esm_pdn_type, tvb, (curr_offset<<3), 4, ENC_BIG_ENDIAN);
4160
4161     /* Request type 9.9.4.14 M V 1/2 */
4162     ELEM_MAND_V(GSM_A_PDU_TYPE_GM, DE_REQ_TYPE, NULL);
4163
4164     /* D- ESM information transfer flag 9.9.4.5 O TV 1 */
4165     ELEM_OPT_TV_SHORT( 0xd0 , NAS_PDU_TYPE_ESM, DE_ESM_INF_TRF_FLG , NULL );
4166     /* 28 Access point name 9.9.4.1 O TLV 3-102 */
4167     ELEM_OPT_TLV( 0x28 , GSM_A_PDU_TYPE_GM, DE_ACC_POINT_NAME , NULL );
4168     /* 27 Protocol configuration options 9.9.4.11 O TLV 3-253 */
4169     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
4170
4171     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4172 }
4173 /*
4174  * 8.3.20 PDN disconnect reject
4175  */
4176 static void
4177 nas_esm_pdn_disc_rej(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4178 {
4179     guint32 curr_offset;
4180     guint32 consumed;
4181     guint   curr_len;
4182
4183     curr_offset = offset;
4184     curr_len = len;
4185
4186     /*This message is sent by the UE to the network to initiate establishment of a PDN connection. */
4187     pinfo->link_dir = P2P_DIR_UL;
4188
4189     /* ESM cause    ESM cause 9.9.4.4   M   V   1 */
4190     ELEM_MAND_V(NAS_PDU_TYPE_ESM, DE_ESM_CAUSE, NULL);
4191     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
4192     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
4193
4194     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4195 }
4196 /*
4197  * 8.3.21 PDN disconnect request
4198  */
4199 static void
4200 nas_esm_pdn_disc_req(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 offset, guint len)
4201 {
4202     guint32 curr_offset, bit_offset;
4203     guint32 consumed;
4204     guint   curr_len;
4205
4206     curr_offset = offset;
4207     curr_len = len;
4208
4209     /* This message is sent by the network to the UE to reject release of a PDN connection. */
4210     pinfo->link_dir = P2P_DIR_DL;
4211
4212     /*  Spare half octet    Spare half octet 9.9.2.9    M   V   1/2 */
4213     bit_offset = curr_offset<<3;
4214     proto_tree_add_bits_item(tree, hf_nas_eps_emm_spare_half_octet, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
4215     bit_offset+=4;
4216     /* Linked EPS bearer identity   Linked EPS bearer identity 9.9.4.6  M   V   1/2 */
4217     proto_tree_add_bits_item(tree, hf_nas_eps_esm_linked_bearer_id, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
4218     bit_offset+=4;
4219     /* Fix the lengths */
4220     curr_len--;
4221     curr_offset++;
4222     if (curr_len == 0)
4223         return;
4224     /* 27   Protocol configuration options  Protocol configuration options 9.9.4.11 O   TLV 3-253 */
4225     ELEM_OPT_TLV( 0x27 , GSM_A_PDU_TYPE_GM, DE_PRO_CONF_OPT , NULL );
4226
4227     EXTRANEOUS_DATA_CHECK(curr_len, 0);
4228 }
4229
4230
4231 #define NUM_NAS_MSG_ESM (sizeof(nas_msg_esm_strings)/sizeof(value_string))
4232 static gint ett_nas_msg_esm[NUM_NAS_MSG_ESM];
4233 static void (*nas_msg_esm_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
4234     nas_esm_act_def_eps_bearer_ctx_req, /* Activate default EPS bearer context request*/
4235     nas_esm_act_def_eps_bearer_ctx_acc, /* Activate default EPS bearer context accept*/
4236     nas_esm_act_def_eps_bearer_ctx_rej, /* Activate default EPS bearer context reject*/
4237     nas_esm_act_ded_eps_bearer_ctx_req, /* Activate dedicated EPS bearer context request*/
4238     nas_esm_act_ded_eps_bearer_ctx_acc, /* Activate dedicated EPS bearer context accept*/
4239     nas_esm_act_ded_eps_bearer_ctx_rej, /* Activate dedicated EPS bearer context reject*/
4240     nas_esm_mod_eps_bearer_ctx_req,     /* Modify EPS bearer context request*/
4241     nas_esm_mod_eps_bearer_ctx_acc,     /* Modify EPS bearer context accept*/
4242     nas_esm_mod_eps_bearer_ctx_rej,     /* Modify EPS bearer context reject*/
4243     nas_esm_deact_eps_bearer_ctx_req,   /* Deactivate EPS bearer context request*/
4244     nas_esm_deact_eps_bearer_ctx_acc,   /* Deactivate EPS bearer context accept*/
4245     nas_esm_pdn_con_req,                /* 8.3.18 PDN connectivity request */
4246     nas_esm_pdn_con_rej,                /* PDN connectivity reject*/
4247     nas_esm_pdn_disc_req,               /* PDN disconnect request*/
4248     nas_esm_pdn_disc_rej,               /* PDN disconnect reject*/
4249     nas_esm_bearer_res_all_req,         /* Bearer resource allocation request*/
4250     nas_esm_bearer_res_all_rej,         /* Bearer resource allocation reject*/
4251     nas_esm_bearer_res_mod_req,         /* Bearer resource modification request*/
4252     nas_esm_bearer_res_mod_rej,         /* Bearer resource modification reject*/
4253     nas_esm_inf_req,                    /* ESM information request, No IE:s*/
4254     nas_esm_inf_resp,                   /* ESM information response*/
4255     nas_esm_notification,               /* Notification */
4256     nas_esm_status,                     /* ESM status */
4257
4258     NULL,   /* NONE */
4259 };
4260
4261 static void
4262 get_nas_esm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn_p)
4263 {
4264     gint            idx;
4265
4266     *msg_str = match_strval_idx((guint32) (oct & 0xff), nas_msg_esm_strings, &idx);
4267     *ett_tree = ett_nas_msg_esm[idx];
4268     *hf_idx = hf_nas_eps_msg_esm_type;
4269     *msg_fcn_p = nas_msg_esm_fcn[idx];
4270
4271     return;
4272 }
4273
4274
4275
4276 #define NUM_NAS_MSG_EMM (sizeof(nas_msg_emm_strings)/sizeof(value_string))
4277 static gint ett_nas_msg_emm[NUM_NAS_MSG_EMM];
4278 static void (*nas_msg_emm_fcn[])(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len) = {
4279     nas_emm_attach_req,         /* Attach request */
4280     nas_emm_attach_acc,         /* Attach accept */
4281     nas_emm_attach_comp,        /* Attach complete */
4282     nas_emm_attach_rej,         /* Attach reject */
4283     nas_emm_detach_req,         /* Detach request */
4284     NULL,                       /* 8.2.10   Detach accept */
4285
4286     nas_emm_trac_area_upd_req,  /* Tracking area update request */
4287     nas_emm_trac_area_upd_acc,  /* Tracking area update accept */
4288     NULL,                       /* Tracking area update complete (No IE's)*/
4289     nas_emm_trac_area_upd_rej,  /* Tracking area update reject */
4290
4291     nas_emm_ext_serv_req,       /* Extended service request */
4292     nas_emm_serv_rej,           /* Service reject */
4293
4294     nas_emm_guti_realloc_cmd,   /* GUTI reallocation command */
4295     NULL,                       /* GUTI reallocation complete (No IE's) */
4296     nas_emm_auth_req,           /* Authentication request */
4297     nas_emm_auth_resp,          /* Authentication response */
4298     NULL,                       /* Authentication reject (No IE:s)*/
4299     nas_emm_attach_fail,        /* Authentication failure */
4300     nas_emm_id_req,             /* Identity request */
4301     nas_emm_id_res,             /* Identity response */
4302     nas_emm_sec_mode_cmd,       /* Security mode command */
4303     nas_emm_sec_mode_comp,      /* Security mode complete */
4304     nas_emm_sec_mode_rej,       /* Security mode reject */
4305
4306     nas_emm_emm_status,         /* EMM status */
4307     nas_emm_emm_inf,            /* EMM information */
4308     nas_emm_dl_nas_trans,       /* Downlink NAS transport */
4309     nas_emm_ul_nas_trans,       /* Uplink NAS transport */
4310     nas_emm_cs_serv_not,        /* 8.2.9    CS service notification */
4311     nas_emm_dl_gen_nas_trans,   /* Downlink generic NAS transport */
4312     nas_emm_ul_gen_nas_trans,   /* Uplink generic NAS transport */
4313     NULL,   /* NONE */
4314
4315 };
4316
4317 static void
4318 get_nas_emm_msg_params(guint8 oct, const gchar **msg_str, int *ett_tree, int *hf_idx, msg_fcn *msg_fcn_p)
4319 {
4320     gint            idx;
4321
4322     *msg_str = match_strval_idx((guint32) (oct & 0xff), nas_msg_emm_strings, &idx);
4323     *ett_tree = ett_nas_msg_emm[idx];
4324     *hf_idx = hf_nas_eps_msg_emm_type;
4325     *msg_fcn_p = nas_msg_emm_fcn[idx];
4326
4327     return;
4328 }
4329
4330 /*
4331  * EPS session management messages.
4332  * A plain NAS message is pased to this function
4333  */
4334 static void
4335 disect_nas_eps_esm_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
4336 {
4337     const gchar     *msg_str;
4338     guint32         len;
4339     gint            ett_tree;
4340     int             hf_idx;
4341     void            (*msg_fcn_p)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len);
4342     guint8          oct;
4343
4344     len = tvb_length(tvb);
4345     /*
4346      * EPS bearer identity 9.3.2
4347      */
4348     proto_tree_add_item(tree, hf_nas_eps_bearer_id, tvb, offset, 1, ENC_BIG_ENDIAN);
4349     /* Protocol discriminator 9.2 */
4350     proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
4351     offset++;
4352
4353     /* Procedure transaction identity 9.4
4354      * The procedure transaction identity and its use are defined in 3GPP TS 24.007
4355      */
4356     proto_tree_add_item(tree, hf_nas_eps_esm_proc_trans_id, tvb, offset, 1, ENC_BIG_ENDIAN);
4357     offset++;
4358
4359     /*messge type IE*/
4360     oct = tvb_get_guint8(tvb,offset);
4361     msg_fcn_p = NULL;
4362     ett_tree = -1;
4363     hf_idx = -1;
4364     msg_str = NULL;
4365
4366     get_nas_esm_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn_p);
4367
4368     if(msg_str){
4369         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, msg_str);
4370     }else{
4371         proto_tree_add_text(tree, tvb, offset, 1,"Unknown message 0x%x",oct);
4372         return;
4373     }
4374
4375     /*
4376      * Add NAS message name
4377      */
4378     proto_tree_add_item(tree, hf_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
4379     offset++;
4380
4381
4382     /*
4383      * decode elements
4384      */
4385     if (msg_fcn_p == NULL)
4386     {
4387         proto_tree_add_text(tree, tvb, offset, len - offset,
4388             "Message Elements");
4389     }
4390     else
4391     {
4392         (*msg_fcn_p)(tvb, tree, pinfo, offset, len - offset);
4393     }
4394
4395 }
4396 /*
4397  * The "real" security header has been dissected or if dissect_header = TRUE
4398  */
4399 static void
4400 dissect_nas_eps_emm_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, gboolean second_header)
4401 {
4402     const gchar     *msg_str;
4403     guint32         len;
4404     gint            ett_tree;
4405     int             hf_idx;
4406     void            (*msg_fcn_p)(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, guint32 offset, guint len);
4407     guint8          security_header_type, oct;
4408
4409     len = tvb_length(tvb);
4410
4411     /* 9.3.1    Security header type */
4412     if(second_header){
4413         security_header_type = tvb_get_guint8(tvb,offset)>>4;
4414         proto_tree_add_item(tree, hf_nas_eps_security_header_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4415         proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
4416         offset++;
4417         if (security_header_type !=0){
4418             /* Message authentication code */
4419             proto_tree_add_item(tree, hf_nas_eps_msg_auth_code, tvb, offset, 4, ENC_BIG_ENDIAN);
4420             offset+=4;
4421             /* Sequence number */
4422             proto_tree_add_item(tree, hf_nas_eps_seq_no, tvb, offset, 1, ENC_BIG_ENDIAN);
4423             offset++;
4424             if ((security_header_type==2)||(security_header_type==4))
4425                 /* Integrity protected and ciphered = 2, Integrity protected and ciphered with new EPS security context = 4 */
4426                 return;
4427             proto_tree_add_item(tree, hf_nas_eps_security_header_type, tvb, offset, 1, ENC_BIG_ENDIAN);
4428             proto_tree_add_item(tree, hf_gsm_a_L3_protocol_discriminator, tvb, offset, 1, ENC_BIG_ENDIAN);
4429             offset++;
4430         }
4431     }
4432     /* Messge type IE*/
4433     oct = tvb_get_guint8(tvb,offset);
4434     msg_fcn_p = NULL;
4435     ett_tree = -1;
4436     hf_idx = -1;
4437     msg_str = NULL;
4438
4439     get_nas_emm_msg_params(oct, &msg_str, &ett_tree, &hf_idx, &msg_fcn_p);
4440
4441     if(msg_str){
4442         col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, msg_str);
4443     }else{
4444         proto_tree_add_text(tree, tvb, offset, 1,"Unknown message 0x%x",oct);
4445         return;
4446     }
4447
4448     /*
4449      * Add NAS message name
4450      */
4451     proto_tree_add_item(tree, hf_idx, tvb, offset, 1, ENC_BIG_ENDIAN);
4452     offset++;
4453
4454
4455     /*
4456      * decode elements
4457      */
4458     if (msg_fcn_p == NULL)
4459     {
4460         proto_tree_add_text(tree, tvb, offset, len - offset,
4461             "Message Elements");
4462     }
4463     else
4464     {
4465         (*msg_fcn_p)(tvb, tree, pinfo, offset, len - offset);
4466     }
4467
4468 }
4469 /* TS 24.301 8.2.1
4470  * 9    General message format and information elements coding
4471  * 9.1  Overview
4472  * Within the protocols defined in the present document, every message, except the SERVICE REQUEST message,
4473  * is a standard L3 message as defined in 3GPP TS 24.007 [12]. This means that the message consists of the following parts:
4474  * 1)   if the message is a plain NAS message:
4475  *  a)  protocol discriminator;
4476  *  b)  EPS bearer identity or security header type;
4477  *  c)  procedure transaction identity;
4478  *  d)  message type;
4479  *  e)  other information elements, as required.
4480  * 2)   if the message is a security protected NAS message:
4481  *  a)  protocol discriminator;
4482  *  b)  security header type;
4483  *  c)  message authentication code;
4484  *  d)  sequence number;
4485  *  e)  plain NAS message, as defined in item 1.
4486  *
4487  * The EPS bearer identity and the procedure transaction identity are only used in messages
4488  * with protocol discriminator EPS session management. Octet 1a with the procedure transaction
4489  * identity shall only be included in these messages.
4490  */
4491
4492 /*
4493  * All messages recived here will have the security header:
4494  *  Figure 9.1.2: General message organization example for a security protected NAS message
4495  *      9.3.1 Bits 5 to 8 of the first octet of every EPS Mobility Management (EMM)
4496  *            message contain the Security header type IE.
4497  *      4.4.4.2 All ESM messages are integrity protected.
4498  */
4499
4500 static void
4501 dissect_nas_eps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4502 {
4503     proto_item  *item;
4504     proto_tree  *nas_eps_tree;
4505     guint8      pd, security_header_type;
4506     int     offset = 0;
4507     guint32     len;
4508     guint32     msg_auth_code;
4509
4510     /* Save pinfo */
4511     gpinfo = pinfo;
4512     len = tvb_length(tvb);
4513
4514     /* make entry in the Protocol column on summary display */
4515     col_append_str(pinfo->cinfo, COL_PROTOCOL, "/NAS-EPS");
4516
4517     item = proto_tree_add_item(tree, proto_nas_eps, tvb, 0, -1, ENC_BIG_ENDIAN);
4518     nas_eps_tree = proto_item_add_subtree(item, ett_nas_eps);
4519
4520     /* Security header type Security header type 9.3.1 M V 1/2 */
4521     security_header_type = tvb_get_guint8(tvb,offset)>>4;
4522     proto_tree_add_item(nas_eps_tree, hf_nas_eps_security_header_type, tvb, 0, 1, ENC_BIG_ENDIAN);
4523     /* Protocol discriminator Protocol discriminator 9.2 M V 1/2 */
4524     proto_tree_add_item(nas_eps_tree, hf_gsm_a_L3_protocol_discriminator, tvb, 0, 1, ENC_BIG_ENDIAN);
4525     pd = tvb_get_guint8(tvb,offset)&0x0f;
4526     offset++;
4527     /* Message authentication code  Message authentication code 9.5 M   V   4 */
4528     if (security_header_type == 0){
4529         if(pd==7){
4530             /* Plain EPS mobility management messages. */
4531             dissect_nas_eps_emm_msg(tvb, pinfo, nas_eps_tree, offset, ENC_BIG_ENDIAN);
4532             return;
4533         }else{
4534             proto_tree_add_text(tree, tvb, offset, len, "All ESM messages should be integrity protected");
4535             return;
4536         }
4537     }else{
4538         /* SERVICE REQUEST (12)  is not a plain NAS message treat separately */
4539         if (security_header_type == 12){
4540             col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "SERVICE REQUEST");
4541             nas_emm_service_req(tvb, nas_eps_tree, pinfo, offset, len-offset);
4542             return;
4543         }
4544         /* Message authentication code */
4545         proto_tree_add_item(nas_eps_tree, hf_nas_eps_msg_auth_code, tvb, offset, 4, ENC_BIG_ENDIAN);
4546         msg_auth_code = tvb_get_ntohl(tvb, offset);
4547         offset+=4;
4548         if ((security_header_type==2)||(security_header_type==4)){
4549             /* Possible ciphered message */
4550             if(msg_auth_code!=0){
4551                 /* Sequence number  Sequence number 9.6 M   V   1 */
4552                 proto_tree_add_item(nas_eps_tree, hf_nas_eps_seq_no, tvb, offset, 1, ENC_BIG_ENDIAN);
4553                 offset++;
4554                 /* Integrity protected and ciphered = 2, Integrity protected and ciphered with new EPS security context = 4 */
4555                 pd = tvb_get_guint8(tvb,offset)&0x0f;
4556 #if 0
4557                                 /* Does not work see Bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6348 
4558                                  * 9.2 Protocol discriminator
4559                                  * :
4560                                  * The protocol discriminator in the header (see 3GPP TS 24.007 [12]) of a 
4561                                  * security protected NAS message is encoded as "EPS mobility management messages".
4562                                  * XXX Should we check for PD == 7?
4563                                  */
4564                 /* If pd is in plaintext this message probably isn't ciphered */
4565                 if((pd!=7)&&(pd!=2)&&(pd!=15)){
4566                     proto_tree_add_text(nas_eps_tree, tvb, offset, len-6,"Ciphered message");
4567                     return;
4568                 }
4569 #else
4570                 proto_tree_add_text(nas_eps_tree, tvb, offset, len-6,"Ciphered message");
4571                 return;
4572 #endif
4573             }else{
4574                 /* msg_auth_code == 0, probably not ciphered */
4575                 /* Sequence number  Sequence number 9.6 M   V   1 */
4576                 proto_tree_add_item(nas_eps_tree, hf_nas_eps_seq_no, tvb, offset, 1, ENC_BIG_ENDIAN);
4577                 offset++;
4578             }
4579         }else{
4580             /* Sequence number  Sequence number 9.6 M   V   1 */
4581             proto_tree_add_item(nas_eps_tree, hf_nas_eps_seq_no, tvb, offset, 1, ENC_BIG_ENDIAN);
4582             offset++;
4583         }
4584     }
4585     /* NAS message  NAS message 9.7 M   V   1-n  */
4586
4587     pd = tvb_get_guint8(tvb,offset)&0x0f;
4588     switch (pd){
4589         case 2:
4590             /* EPS session management messages.
4591              * Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
4592              */
4593             disect_nas_eps_esm_msg(tvb, pinfo, nas_eps_tree, offset);
4594             break;
4595         case 7:
4596             /* EPS mobility management messages.
4597              * Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
4598              */
4599             dissect_nas_eps_emm_msg(tvb, pinfo, nas_eps_tree, offset, TRUE);
4600             break;
4601         case 15:
4602             /* Special conformance testing functions for User Equipment messages.
4603              * Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
4604              */
4605             if (gsm_a_dtap_handle){
4606                 tvbuff_t *new_tvb = tvb_new_subset(tvb, offset, -1, -1);
4607                 call_dissector(gsm_a_dtap_handle, new_tvb, pinfo, nas_eps_tree);
4608                 break;
4609             } /* else fall through default */
4610         default:
4611             proto_tree_add_text(nas_eps_tree, tvb, offset, -1, "Not a NAS EPS PD %u(%s)",pd,val_to_str(pd, protocol_discriminator_vals,"unknown"));
4612             break;
4613     }
4614
4615 }
4616
4617 static void
4618 dissect_nas_eps_plain(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
4619 {
4620     proto_item  *item;
4621     proto_tree  *nas_eps_tree;
4622     guint8      pd;
4623     int     offset = 0;
4624
4625     /* Save pinfo */
4626     gpinfo = pinfo;
4627
4628     /* make entry in the Protocol column on summary display */
4629     col_append_str(pinfo->cinfo, COL_PROTOCOL, "/NAS-EPS");
4630
4631     item = proto_tree_add_item(tree, proto_nas_eps, tvb, 0, -1, ENC_BIG_ENDIAN);
4632     nas_eps_tree = proto_item_add_subtree(item, ett_nas_eps);
4633
4634     pd = tvb_get_guint8(tvb,offset)&0x0f;
4635     switch (pd){
4636         case 2:
4637             /* EPS session management messages.
4638              * Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
4639              */
4640             disect_nas_eps_esm_msg(tvb, pinfo, nas_eps_tree, offset);
4641             break;
4642         case 7:
4643             /* EPS mobility management messages.
4644              * Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
4645              */
4646             dissect_nas_eps_emm_msg(tvb, pinfo, nas_eps_tree, offset, TRUE);
4647             break;
4648         case 15:
4649             /* Special conformance testing functions for User Equipment messages.
4650              * Ref 3GPP TS 24.007 version 8.0.0 Release 8, Table 11.2: Protocol discriminator values
4651              */
4652             if (gsm_a_dtap_handle){
4653                 tvbuff_t *new_tvb = tvb_new_subset(tvb, offset, -1, -1);
4654                 call_dissector(gsm_a_dtap_handle, new_tvb,pinfo, nas_eps_tree);
4655                 break;
4656             } /* else fall through default */
4657         default:
4658             proto_tree_add_text(nas_eps_tree, tvb, offset, -1, "Not a NAS EPS PD %u(%s)",pd,val_to_str(pd, protocol_discriminator_vals,"unknown"));
4659             break;
4660     }
4661
4662 }
4663
4664 void proto_register_nas_eps(void) {
4665     guint       i;
4666     guint       last_offset;
4667
4668     /* List of fields */
4669
4670   static hf_register_info hf[] = {
4671     { &hf_nas_eps_msg_emm_type,
4672         { "NAS EPS Mobility Management Message Type",   "nas_eps.nas_msg_emm_type",
4673         FT_UINT8, BASE_HEX, VALS(nas_msg_emm_strings), 0x0,
4674         NULL, HFILL }
4675     },
4676     { &hf_nas_eps_common_elem_id,
4677         { "Element ID", "nas_eps.common.elem_id",
4678         FT_UINT8, BASE_DEC, NULL, 0,
4679         NULL, HFILL }
4680     },
4681     { &hf_nas_eps_emm_elem_id,
4682         { "Element ID", "nas_eps.emm.elem_id",
4683         FT_UINT8, BASE_DEC, NULL, 0,
4684         NULL, HFILL }
4685     },
4686     { &hf_nas_eps_bearer_id,
4687         { "EPS bearer identity",    "nas_eps.bearer_id",
4688         FT_UINT8, BASE_HEX, NULL, 0xf0,
4689         NULL, HFILL }
4690     },
4691     { &hf_nas_eps_spare_bits,
4692         { "Spare bit(s)", "nas_eps.spare_bits",
4693         FT_UINT8, BASE_HEX, NULL, 0x0,
4694         NULL, HFILL }
4695     },
4696     { &hf_nas_eps_security_header_type,
4697         { "Security header type","nas_eps.security_header_type",
4698         FT_UINT8,BASE_DEC|BASE_EXT_STRING, &security_header_type_vals_ext, 0xf0,
4699         NULL, HFILL }
4700     },
4701     { &hf_nas_eps_msg_auth_code,
4702         { "Message authentication code","nas_eps.msg_auth_code",
4703         FT_UINT32,BASE_HEX, NULL, 0x0,
4704         NULL, HFILL }
4705     },
4706     { &hf_nas_eps_seq_no,
4707         { "Sequence number","nas_eps.seq_no",
4708         FT_UINT8,BASE_DEC, NULL, 0x0,
4709         NULL, HFILL }
4710     },
4711     { &hf_nas_eps_seq_no_short,
4712         { "Sequence number (short)","nas_eps.seq_no_short",
4713         FT_UINT8,BASE_DEC, NULL, 0x0,
4714         NULL, HFILL }
4715     },
4716     { &hf_nas_eps_emm_ebi0,
4717         { "EBI(0) spare","nas_eps.emm.ebi0",
4718         FT_BOOLEAN, 8, NULL, 0x01,
4719         NULL, HFILL }
4720     },
4721     { &hf_nas_eps_emm_ebi1,
4722         { "EBI(1) spare","nas_eps.emm.ebi1",
4723         FT_BOOLEAN, 8, NULL, 0x02,
4724         NULL, HFILL }
4725     },
4726     { &hf_nas_eps_emm_ebi2,
4727         { "EBI(2) spare","nas_eps.emm.ebi2",
4728         FT_BOOLEAN, 8, NULL, 0x04,
4729         NULL, HFILL }
4730     },
4731     { &hf_nas_eps_emm_ebi3,
4732         { "EBI(3) spare","nas_eps.emm.ebi3",
4733         FT_BOOLEAN, 8, NULL, 0x08,
4734         NULL, HFILL }
4735     },
4736     { &hf_nas_eps_emm_ebi4,
4737         { "EBI(4) spare","nas_eps.emm.ebi4",
4738         FT_BOOLEAN, 8, NULL, 0x10,
4739         NULL, HFILL }
4740     },
4741     { &hf_nas_eps_emm_ebi5,
4742         { "EBI(5)","nas_eps.emm.ebi5",
4743         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x20,
4744         NULL, HFILL }
4745     },
4746     { &hf_nas_eps_emm_ebi6,
4747         { "EBI(6)","nas_eps.emm.ebi6",
4748         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x40,
4749         NULL, HFILL }
4750     },
4751     { &hf_nas_eps_emm_ebi7,
4752         { "EBI(7)","nas_eps.emm.ebi7",
4753         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x80,
4754         NULL, HFILL }
4755     },
4756     { &hf_nas_eps_emm_ebi8,
4757         { "EBI(8)","nas_eps.emm.ebi8",
4758         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x01,
4759         NULL, HFILL }
4760     },
4761     { &hf_nas_eps_emm_ebi9,
4762         { "EBI(9)","nas_eps.emm.ebi9",
4763         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x02,
4764         NULL, HFILL }
4765     },
4766     { &hf_nas_eps_emm_ebi10,
4767         { "EBI(10)","nas_eps.emm.ebi10",
4768         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x04,
4769         NULL, HFILL }
4770     },
4771     { &hf_nas_eps_emm_ebi11,
4772         { "EBI(11)","nas_eps.emm.ebi11",
4773         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x08,
4774         NULL, HFILL }
4775     },
4776     { &hf_nas_eps_emm_ebi12,
4777         { "EBI(12)","nas_eps.emm.ebi12",
4778         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x10,
4779         NULL, HFILL }
4780     },
4781     { &hf_nas_eps_emm_ebi13,
4782         { "EBI(13)","nas_eps.emm.ebi13",
4783         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x20,
4784         NULL, HFILL }
4785     },
4786     { &hf_nas_eps_emm_ebi14,
4787         { "EBI(14)","nas_eps.emm.ebi14",
4788         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x40,
4789         NULL, HFILL }
4790     },
4791     { &hf_nas_eps_emm_ebi15,
4792         { "EBI(15)","nas_eps.emm.ebi15",
4793         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ebi_vals), 0x80,
4794         NULL, HFILL }
4795     },
4796     { &hf_nas_eps_emm_dl_nas_cnt,
4797         { "DL NAS COUNT value","nas_eps.emm.dl_nas_cnt",
4798         FT_UINT8,BASE_DEC, NULL, 0x0f,
4799         NULL, HFILL }
4800     },
4801     {&hf_nas_eps_emm_nonce_mme,
4802         { "NonceMME","nas_eps.emm.nonce_mme",
4803         FT_UINT32,BASE_HEX, NULL, 0x0,
4804         NULL, HFILL }
4805     },
4806     {&hf_nas_eps_emm_nonce,
4807         { "Nonce","nas_eps.emm.nonce",
4808         FT_UINT32,BASE_HEX, NULL, 0x0,
4809         NULL, HFILL }
4810     },
4811     { &hf_nas_eps_emm_paging_id,
4812         { "Paging identity value","nas_eps.emm.paging_id",
4813         FT_BOOLEAN, 8, TFS(&nas_eps_emm_paging_id_vals), 0x0,
4814         NULL, HFILL }
4815     },
4816     { &hf_nas_eps_emm_eps_att_type,
4817         { "EPS attach type","nas_eps.emm.eps_att_type",
4818         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_eps_att_type_vals), 0x0,
4819         NULL, HFILL }
4820     },
4821     { &hf_nas_eps_emm_cs_lcs_type,
4822         { "CS-LCS","nas_eps.emm.cs_lcs",
4823         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_cs_lcs_vals), 0x0,
4824         "Location services indicator in CS", HFILL }
4825     },
4826     { &hf_nas_eps_emm_epc_lcs_type,
4827         { "EPC-LCS","nas_eps.emm.epc_lcs",
4828         FT_BOOLEAN ,BASE_NONE, TFS(&nas_eps_emm_epc_lcs_value), 0x0,
4829         "Location services indicator in EPC", HFILL }
4830     },
4831     { &hf_nas_eps_emm_emc_bs_type,
4832         { "EMC BS","nas_eps.emm.emc_bs",
4833         FT_BOOLEAN, BASE_NONE, TFS(&nas_eps_emm_emc_bs_value), 0x0,
4834         "Emergency bearer services indicator", HFILL }
4835     },
4836     { &hf_nas_eps_emm_ims_vops_type,
4837         { "IMS VoPS","nas_eps.emm.ims_vops",
4838         FT_BOOLEAN, BASE_NONE, TFS(&nas_eps_emm_ims_vops_value), 0x0,
4839         "IMS voice over PS session indicator", HFILL }
4840     },
4841     { &hf_nas_eps_tsc,
4842         { "Type of security context flag (TSC)","nas_eps.emm.tsc",
4843         FT_UINT8,BASE_DEC, VALS(nas_eps_tsc_vals), 0x0,
4844         NULL, HFILL }
4845     },
4846     { &hf_nas_eps_emm_nas_key_set_id,
4847         { "NAS key set identifier","nas_eps.emm.nas_key_set_id",
4848         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_NAS_key_set_identifier_vals), 0x0,
4849         NULL, HFILL }
4850     },
4851     { &hf_nas_eps_emm_odd_even,
4852         { "odd/even indic","nas_eps.emm.odd_even",
4853         FT_UINT8,BASE_DEC, NULL, 0x8,
4854         NULL, HFILL }
4855     },
4856     { &hf_nas_eps_emm_type_of_id,
4857         { "Type of identity","nas_eps.emm.type_of_id",
4858         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_type_of_id_vals), 0x07,
4859         NULL, HFILL }
4860     },
4861     { &hf_nas_eps_emm_mme_grp_id,
4862         { "MME Group ID","nas_eps.emm.mme_grp_id",
4863         FT_UINT16, BASE_DEC, NULL, 0x0,
4864         NULL, HFILL }
4865     },
4866     { &hf_nas_eps_emm_imsi,
4867         { "IMSI", "nas_eps.emm.imsi",
4868           FT_STRING, BASE_NONE, NULL, 0,
4869           NULL, HFILL }
4870     },
4871     { &hf_nas_eps_emm_imei,
4872         { "IMEI", "nas_eps.emm.imei",
4873           FT_STRING, BASE_NONE, NULL, 0,
4874           NULL, HFILL }
4875     },
4876     { &hf_nas_eps_emm_mme_code,
4877         { "MME Code","nas_eps.emm.mme_code",
4878         FT_UINT8, BASE_DEC, NULL, 0x0,
4879         NULL, HFILL }
4880     },
4881     { &hf_nas_eps_emm_m_tmsi,
4882         { "M-TMSI","nas_eps.emm.m_tmsi",
4883         FT_UINT32, BASE_HEX, NULL, 0x0,
4884         NULL, HFILL }
4885     },
4886     { &hf_nas_eps_esm_msg_cont,
4887         { "ESM message container contents","nas_eps.emm.esm_msg_cont",
4888         FT_BYTES, BASE_NONE, NULL, 0x0,
4889         NULL, HFILL }
4890     },
4891     { &hf_nas_eps_esm_imeisv_req,
4892         { "IMEISV request","nas_eps.emm.imeisv_req",
4893         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_imeisv_req_vals), 0x07,
4894         NULL, HFILL }
4895     },
4896     { &hf_nas_eps_emm_toi,
4897         { "Type of integrity protection algorithm","nas_eps.emm.toi",
4898         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_toi_vals), 0x07,
4899         NULL, HFILL }
4900     },
4901     { &hf_nas_eps_emm_toc,
4902         { "Type of ciphering algorithm","nas_eps.emm.toc",
4903         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_toc_vals), 0x70,
4904         NULL, HFILL }
4905     },
4906     { &hf_nas_eps_emm_EPS_attach_result,
4907         { "Attach result","nas_eps.emm.EPS_attach_result",
4908         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_EPS_attach_result_values), 0x0,
4909         NULL, HFILL }
4910     },
4911     { &hf_nas_eps_emm_spare_half_octet,
4912         { "Spare half octet","nas_eps.emm.EPS_attach_result",
4913         FT_UINT8,BASE_DEC, NULL, 0x0,
4914         NULL, HFILL }
4915     },
4916     { &hf_nas_eps_emm_add_upd_res,
4917         { "AURV","nas_eps.emm.add_upd_res",
4918         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_add_upd_res_vals), 0x0,
4919         "Additional update result value", HFILL }
4920     },
4921     { &hf_nas_eps_emm_add_upd_type,
4922         { "AUTV","nas_eps.emm.add_upd_type",
4923         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_add_upd_type_vals), 0x0,
4924         "Additional update type value", HFILL }
4925     },
4926     { &hf_nas_eps_emm_res,
4927         { "RES","nas_eps.emm.res",
4928         FT_BYTES, BASE_NONE, NULL, 0x0,
4929         NULL, HFILL }
4930     },
4931     { &hf_nas_eps_emm_csfb_resp,
4932         { "CSFB response","nas_eps.emm.csfb_resp",
4933         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_csfb_resp_vals), 0x03,
4934         NULL, HFILL }
4935     },
4936     { &hf_nas_eps_emm_cause,
4937         { "Cause","nas_eps.emm.cause",
4938         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_cause_values), 0x0,
4939         NULL, HFILL }
4940     },
4941     { &hf_nas_eps_emm_id_type2,
4942         { "Identity type 2","nas_eps.emm.id_type2",
4943         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_id_type2_vals), 0x0,
4944         NULL, HFILL }
4945     },
4946     { &hf_nas_eps_emm_short_mac,
4947         { "Message authentication code (short)","nas_eps.emm.short_mac",
4948         FT_UINT16, BASE_HEX, NULL, 0x0,
4949         NULL, HFILL }
4950     },
4951     { &hf_nas_eps_emm_tai_tol,
4952         { "Type of list","nas_eps.emm.tai_tol",
4953         FT_UINT8, BASE_DEC, VALS(nas_eps_emm_tai_tol_vals), 0x60,
4954         NULL, HFILL }
4955     },
4956     { &hf_nas_eps_emm_tai_n_elem,
4957         { "Number of elements","nas_eps.emm.tai_n_elem",
4958         FT_UINT8, BASE_DEC,  NULL, 0x1f,
4959         NULL, HFILL }
4960     },
4961     { &hf_nas_eps_emm_tai_tac,
4962         { "Tracking area code(TAC)","nas_eps.emm.tai_tac",
4963         FT_UINT16, BASE_HEX,  NULL, 0x0,
4964         NULL, HFILL }
4965     },
4966     { &hf_nas_eps_emm_eea0,
4967         { "EEA0","nas_eps.emm.eea0",
4968         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x80,
4969         NULL, HFILL }
4970     },
4971     { &hf_nas_eps_emm_128eea1,
4972         { "128-EEA1","nas_eps.emm.128eea1",
4973         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x40,
4974         NULL, HFILL }
4975     },
4976     { &hf_nas_eps_emm_128eea2,
4977         { "128-EEA2","nas_eps.emm.128eea2",
4978         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x20,
4979         NULL, HFILL }
4980     },
4981     { &hf_nas_eps_emm_eea3,
4982         { "EEA3","nas_eps.emm.eea3",
4983         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x10,
4984         NULL, HFILL }
4985     },
4986     { &hf_nas_eps_emm_eea4,
4987         { "EEA4","nas_eps.emm.eea4",
4988         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x08,
4989         NULL, HFILL }
4990     },
4991     { &hf_nas_eps_emm_eea5,
4992         { "EEA5","nas_eps.emm.eea5",
4993         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x04,
4994         NULL, HFILL }
4995     },
4996     { &hf_nas_eps_emm_eea6,
4997         { "EEA6","nas_eps.emm.eea6",
4998         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x02,
4999         NULL, HFILL }
5000     },
5001     { &hf_nas_eps_emm_eea7,
5002         { "EEA7","nas_eps.emm.eea7",
5003         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x01,
5004         NULL, HFILL }
5005     },
5006     { &hf_nas_eps_emm_eia0,
5007         { "EIA0","nas_eps.emm.eia0",
5008         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x80,
5009         NULL, HFILL }
5010     },
5011     { &hf_nas_eps_emm_128eia1,
5012         { "128-EIA1","nas_eps.emm.128eia1",
5013         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x40,
5014         NULL, HFILL }
5015     },
5016     { &hf_nas_eps_emm_128eia2,
5017         { "128-EIA2","nas_eps.emm.128eia2",
5018         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x20,
5019         NULL, HFILL }
5020     },
5021     { &hf_nas_eps_emm_eia3,
5022         { "EIA3","nas_eps.emm.eia3",
5023         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x10,
5024         NULL, HFILL }
5025     },
5026     { &hf_nas_eps_emm_eia4,
5027         { "EIA4","nas_eps.emm.eia4",
5028         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x08,
5029         NULL, HFILL }
5030     },
5031     { &hf_nas_eps_emm_eia5,
5032         { "EIA5","nas_eps.emm.eia5",
5033         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x04,
5034         NULL, HFILL }
5035     },
5036     { &hf_nas_eps_emm_eia6,
5037         { "EIA6","nas_eps.emm.eia6",
5038         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x02,
5039         NULL, HFILL }
5040     },
5041     { &hf_nas_eps_emm_eia7,
5042         { "EIA7","nas_eps.emm.eia7",
5043         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x01,
5044         NULL, HFILL }
5045     },
5046
5047
5048     { &hf_nas_eps_emm_uea0,
5049         { "UEA0","nas_eps.emm.uea0",
5050         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x80,
5051         NULL, HFILL }
5052     },
5053     { &hf_nas_eps_emm_uea1,
5054         { "UEA1","nas_eps.emm.uea1",
5055         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x40,
5056         NULL, HFILL }
5057     },
5058     { &hf_nas_eps_emm_uea2,
5059         { "UEA2","nas_eps.emm.uea2",
5060         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x20,
5061         NULL, HFILL }
5062     },
5063     { &hf_nas_eps_emm_uea3,
5064         { "UEA3","nas_eps.emm.uea3",
5065         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x10,
5066         NULL, HFILL }
5067     },
5068     { &hf_nas_eps_emm_uea4,
5069         { "UEA4","nas_eps.emm.uea4",
5070         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x08,
5071         NULL, HFILL }
5072     },
5073     { &hf_nas_eps_emm_uea5,
5074         { "UEA5","nas_eps.emm.uea5",
5075         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x04,
5076         NULL, HFILL }
5077     },
5078     { &hf_nas_eps_emm_uea6,
5079         { "UEA6","nas_eps.emm.uea6",
5080         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x02,
5081         NULL, HFILL }
5082     },
5083     { &hf_nas_eps_emm_uea7,
5084         { "UEA7","nas_eps.emm.uea7",
5085         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x01,
5086         NULL, HFILL }
5087     },
5088     { &hf_nas_eps_emm_ucs2_supp,
5089         { "UCS2 support (UCS2)","nas_eps.emm.emm_ucs2_supp",
5090         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ucs2_supp_flg_value), 0x80,
5091         NULL, HFILL }
5092     },
5093     { &hf_nas_eps_emm_uia1,
5094         { "UMTS integrity algorithm UIA1","nas_eps.emm.uia1",
5095         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x40,
5096         NULL, HFILL }
5097     },
5098     { &hf_nas_eps_emm_uia2,
5099         { "UMTS integrity algorithm UIA2","nas_eps.emm.uia2",
5100         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x20,
5101         NULL, HFILL }
5102     },
5103     { &hf_nas_eps_emm_uia3,
5104         { "UMTS integrity algorithm UIA3","nas_eps.emm.uia3",
5105         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x10,
5106         NULL, HFILL }
5107     },
5108     { &hf_nas_eps_emm_uia4,
5109         { "UMTS integrity algorithm UIA4","nas_eps.emm.uia4",
5110         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x08,
5111         NULL, HFILL }
5112     },
5113     { &hf_nas_eps_emm_uia5,
5114         { "UMTS integrity algorithm UIA5","nas_eps.emm.uia5",
5115         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x04,
5116         NULL, HFILL }
5117     },
5118     { &hf_nas_eps_emm_uia6,
5119         { "UMTS integrity algorithm UIA6","nas_eps.emm.uia6",
5120         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x02,
5121         NULL, HFILL }
5122     },
5123     { &hf_nas_eps_emm_uia7,
5124         { "UMTS integrity algorithm UIA7","nas_eps.emm.uia7",
5125         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x01,
5126         NULL, HFILL }
5127     },
5128     { &hf_nas_eps_emm_gea1,
5129         { "GPRS encryption algorithm GEA1","nas_eps.emm.gea1",
5130         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x40,
5131         NULL, HFILL }
5132     },
5133     { &hf_nas_eps_emm_gea2,
5134         { "GPRS encryption algorithm GEA2","nas_eps.emm.gea2",
5135         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x20,
5136         NULL, HFILL }
5137     },
5138     { &hf_nas_eps_emm_gea3,
5139         { "GPRS encryption algorithm GEA3","nas_eps.emm.gea3",
5140         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x10,
5141         NULL, HFILL }
5142     },
5143     { &hf_nas_eps_emm_gea4,
5144         { "GPRS encryption algorithm GEA4","nas_eps.emm.gea4",
5145         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x08,
5146         NULL, HFILL }
5147     },
5148     { &hf_nas_eps_emm_gea5,
5149         { "GPRS encryption algorithm GEA5","nas_eps.emm.gea5",
5150         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x04,
5151         NULL, HFILL }
5152     },
5153     { &hf_nas_eps_emm_gea6,
5154         { "GPRS encryption algorithm GEA6","nas_eps.emm.gea6",
5155         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x02,
5156         NULL, HFILL }
5157     },
5158     { &hf_nas_eps_emm_gea7,
5159         { "GPRS encryption algorithm GEA7","nas_eps.emm.gea7",
5160         FT_BOOLEAN, 8, TFS(&nas_eps_emm_supported_flg_value), 0x01,
5161         NULL, HFILL }
5162     },
5163     { &hf_nas_eps_emm_lpp_cap,
5164         { "LPP capability","nas_eps.emm.lpp_cap",
5165         FT_BOOLEAN, 8, TFS(&nas_eps_emm_lpp_cap_flg), 0x08,
5166         NULL, HFILL }
5167     },
5168     { &hf_nas_eps_emm_lcs_cap,
5169         { "LCS capability","nas_eps.emm.lcs_cap",
5170         FT_BOOLEAN, 8, TFS(&nas_eps_emm_lcs_cap_flg), 0x04,
5171         NULL, HFILL }
5172     },
5173     { &hf_nas_eps_emm_1xsrvcc_cap,
5174         { "1xSRVCC capability","nas_eps.emm.1xsrvcc_cap",
5175         FT_BOOLEAN, 8, TFS(&nas_eps_emm_1xsrvcc_cap_flg), 0x02,
5176         NULL, HFILL }
5177     },
5178     { &hf_nas_eps_emm_nf_cap,
5179         { "NF capability","nas_eps.emm.nf_cap",
5180         FT_BOOLEAN, 8, TFS(&nas_eps_emm_nf_cap_flg), 0x01,
5181         NULL, HFILL }
5182     },
5183     { &hf_nas_eps_emm_ue_ra_cap_inf_upd_need_flg,
5184         { "1xSRVCC capability","nas_eps.emm.ue_ra_cap_inf_upd_need_flg",
5185         FT_BOOLEAN, 8, TFS(&nas_eps_emm_ue_ra_cap_inf_upd_need_flg), 0x01,
5186         NULL, HFILL }
5187     },
5188     { &hf_nas_eps_emm_ss_code,
5189         { "SS Code","nas_eps.emm.eps_update_result_value",
5190         FT_UINT8,BASE_DEC, VALS(ssCode_vals), 0x0,
5191         NULL, HFILL }
5192     },
5193     { &hf_nas_eps_emm_lcs_ind,
5194         { "LCS indicator","nas_eps.emm.emm_lcs_ind",
5195         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_lcs_ind_vals), 0x0,
5196         NULL, HFILL }
5197     },
5198     { &hf_nas_eps_emm_gen_msg_cont_type,
5199         { "Container type","nas_eps.emm.gen_msg_cont_type",
5200         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_gen_msg_cont_type_vals), 0x0,
5201         NULL, HFILL }
5202     },
5203     { &hf_nas_eps_emm_apn_ambr_ul,
5204         { "APN-AMBR for uplink","nas_eps.emm.apn_ambr_ul",
5205         FT_UINT8,BASE_DEC, NULL, 0x0,
5206         NULL, HFILL }
5207     },
5208     { &hf_nas_eps_emm_apn_ambr_dl,
5209         { "APN-AMBR for downlink","nas_eps.emm.apn_ambr_dl",
5210         FT_UINT8,BASE_DEC, NULL, 0x0,
5211         NULL, HFILL }
5212     },
5213     { &hf_nas_eps_emm_apn_ambr_ul_ext,
5214         { "APN-AMBR for uplink(Extended)","nas_eps.emm.apn_ambr_ul_ext",
5215         FT_UINT8,BASE_DEC, NULL, 0x0,
5216         NULL, HFILL }
5217     },
5218     { &hf_nas_eps_emm_apn_ambr_dl_ext,
5219         { "APN-AMBR for downlink(Extended)","nas_eps.emm.apn_ambr_dl_ext",
5220         FT_UINT8,BASE_DEC, NULL, 0x0,
5221         NULL, HFILL }
5222     },
5223     { &hf_nas_eps_emm_apn_ambr_ul_ext2,
5224         { "APN-AMBR for uplink(Extended-2)","nas_eps.emm.apn_ambr_ul_ext2",
5225         FT_UINT8,BASE_DEC, NULL, 0x0,
5226         NULL, HFILL }
5227     },
5228     { &hf_nas_eps_emm_apn_ambr_dl_ext2,
5229         { "APN-AMBR for downlink(Extended-2)","nas_eps.emm.apn_ambr_dl_ext2",
5230         FT_UINT8,BASE_DEC, NULL, 0x0,
5231         NULL, HFILL }
5232     },
5233     { &hf_nas_eps_emm_switch_off,
5234         { "Switch off","nas_eps.emm.switch_off",
5235         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_switch_off_vals), 0x0,
5236         NULL, HFILL }
5237     },
5238     { &hf_nas_eps_emm_detach_type_UL,
5239         { "Detach Type","nas_eps.emm.detach_type_ul",
5240         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_type_of_dtatch_UL_vals), 0x0,
5241         NULL, HFILL }
5242     },
5243     { &hf_nas_eps_emm_detach_type_DL,
5244         { "Detach Type","nas_eps.emm.detach_type_dl",
5245         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_type_of_dtatch_DL_vals), 0x0,
5246         NULL, HFILL }
5247     },
5248     { &hf_nas_eps_qci,
5249         { "Quality of Service Class Identifier (QCI)","nas_eps.emm.qci",
5250         FT_UINT8,BASE_DEC, VALS(nas_eps_qci_vals), 0x0,
5251         NULL, HFILL }
5252     },
5253     { &hf_nas_eps_mbr_ul,
5254         { "Maximum bit rate for uplink","nas_eps.emm.mbr_ul",
5255         FT_UINT8,BASE_DEC, NULL, 0x0,
5256         NULL, HFILL }
5257     },
5258     { &hf_nas_eps_mbr_dl,
5259         { "Maximum bit rate for downlink","nas_eps.emm.mbr_dl",
5260         FT_UINT8,BASE_DEC, NULL, 0x0,
5261         NULL, HFILL }
5262     },
5263     { &hf_nas_eps_gbr_ul,
5264         { "Guaranteed bit rate for uplink","nas_eps.emm.gbr_ul",
5265         FT_UINT8,BASE_DEC, NULL, 0x0,
5266         NULL, HFILL }
5267     },
5268     { &hf_nas_eps_gbr_dl,
5269         { "Guaranteed bit rate for downlink","nas_eps.emm.gbr_dl",
5270         FT_UINT8,BASE_DEC, NULL, 0x0,
5271         NULL, HFILL }
5272     },
5273     { &hf_nas_eps_embr_ul,
5274         { "Maximum bit rate for uplink(ext)","nas_eps.emm.embr_ul",
5275         FT_UINT8,BASE_DEC, NULL, 0x0,
5276         NULL, HFILL }
5277     },
5278     { &hf_nas_eps_embr_dl,
5279         { "Maximum bit rate for downlink(ext)","nas_eps.emm.embr_dl",
5280         FT_UINT8,BASE_DEC, NULL, 0x0,
5281         NULL, HFILL }
5282     },
5283     { &hf_nas_eps_egbr_ul,
5284         { "Guaranteed bit rate for uplink(ext)","nas_eps.emm.egbr_ul",
5285         FT_UINT8,BASE_DEC, NULL, 0x0,
5286         NULL, HFILL }
5287     },
5288     { &hf_nas_eps_egbr_dl,
5289         { "Guaranteed bit rate for downlink(ext)","nas_eps.emm.egbr_dl",
5290         FT_UINT8,BASE_DEC, NULL, 0x0,
5291         NULL, HFILL }
5292     },
5293     { &hf_nas_eps_esm_cause,
5294         { "Cause","nas_eps.esm.cause",
5295         FT_UINT8,BASE_DEC, VALS(nas_eps_esm_cause_vals), 0x0,
5296         NULL, HFILL }
5297     },
5298     { &hf_nas_eps_esm_eit,
5299         { "EIT (ESM information transfer)", "nas_eps.emm.eit",
5300         FT_BOOLEAN, 8, TFS(&nas_eps_emm_active_flg_value), 0x01,
5301         NULL, HFILL }
5302     },
5303     { &hf_nas_eps_esm_lnkd_eps_bearer_id,
5304         { "Linked EPS bearer identity","nas_eps.esm.lnkd_eps_bearer_id",
5305         FT_UINT8,BASE_DEC, VALS(nas_eps_esm_linked_bearer_id_vals), 0x0f,
5306         NULL, HFILL }
5307     },
5308     { &hf_nas_eps_esm_notif_ind,
5309         { "Notification indicator value","nas_eps.esm.notif_ind",
5310         FT_UINT8,BASE_DEC, VALS(nas_eps_esm_notif_ind_vals), 0x0,
5311         NULL, HFILL }
5312     },
5313     { &hf_nas_eps_esm_pdn_ipv4,
5314         {"PDN IPv4", "nas_eps.esm.pdn_ipv4",
5315         FT_IPv4, BASE_NONE, NULL, 0x0,
5316         NULL, HFILL}
5317     },
5318     { &hf_nas_eps_esm_pdn_ipv6_if_id,
5319         {"PDN IPv6 if id", "nas_eps.esm.pdn_ipv6_if_id",
5320         FT_BYTES, BASE_NONE, NULL, 0x0,
5321         NULL, HFILL}
5322     },
5323     { &hf_nas_eps_esm_linked_bearer_id,
5324         { "Linked EPS bearer identity","nas_eps.esm.linked_bearer_id",
5325         FT_UINT8,BASE_DEC, VALS(nas_eps_esm_linked_bearer_id_vals), 0x0,
5326         NULL, HFILL }
5327     },
5328     { &hf_nas_eps_active_flg,
5329         { "Active flag", "nas_eps.emm.active_flg",
5330         FT_BOOLEAN, BASE_NONE, TFS(&nas_eps_emm_active_flg_value), 0x0,
5331         NULL, HFILL }
5332     },
5333     { &hf_nas_eps_eps_update_result_value,
5334         { "EPS update result value","nas_eps.emm.eps_update_result_value",
5335         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_eps_update_result_vals), 0x0,
5336         NULL, HFILL }
5337     },
5338     { &hf_nas_eps_eps_update_type_value,
5339         { "EPS update type value", "nas_eps.emm.update_type_value",
5340         FT_UINT8,BASE_DEC, VALS(nas_eps_emm_eps_update_type_vals), 0x0,
5341         NULL, HFILL }
5342     },
5343     { &hf_nas_eps_service_type,
5344         { "Service type", "nas_eps.emm.service_type",
5345         FT_UINT8,BASE_DEC, VALS(nas_eps_service_type_vals), 0x0,
5346         NULL, HFILL }
5347     },
5348     { &hf_nas_eps_nas_msg_cont,
5349         { "NAS message container content", "nas_eps.emm.nas_msg_cont",
5350         FT_BYTES, BASE_NONE, NULL, 0x0,
5351         NULL, HFILL }
5352     },
5353     { &hf_nas_eps_gen_msg_cont,
5354         { "Generic message container content", "nas_eps.emm.gen_msg_cont",
5355         FT_BYTES, BASE_NONE, NULL, 0x0,
5356         NULL, HFILL }
5357     },
5358     { &hf_nas_eps_cmn_add_info,
5359         { "Additional information content", "nas_eps.cmn.add_info",
5360         FT_BYTES, BASE_NONE, NULL, 0x0,
5361         NULL, HFILL }
5362     },
5363     /* ESM hf cvariables */
5364     { &hf_nas_eps_msg_esm_type,
5365         { "NAS EPS session management messages",    "nas_eps.nas_msg_esm_type",
5366         FT_UINT8, BASE_HEX, VALS(nas_msg_esm_strings), 0x0,
5367         NULL, HFILL }
5368     },
5369     { &hf_nas_eps_esm_elem_id,
5370         { "Element ID", "nas_eps.esm.elem_id",
5371         FT_UINT8, BASE_DEC, NULL, 0,
5372         NULL, HFILL }
5373     },
5374     { &hf_nas_eps_esm_proc_trans_id,
5375         { "Procedure transaction identity", "nas_eps.esm.proc_trans_id",
5376         FT_UINT8, BASE_DEC, NULL, 0,
5377         NULL, HFILL }
5378     },
5379     { &hf_nas_eps_esm_pdn_type,
5380         { "PDN type",   "nas_eps.nas_eps_esm_pdn_type",
5381         FT_UINT8, BASE_DEC, VALS(nas_eps_esm_pdn_type_values), 0x0,
5382         NULL, HFILL }
5383     },
5384   };
5385
5386     /* Setup protocol subtree array */
5387 #define NUM_INDIVIDUAL_ELEMS    5
5388     gint *ett[NUM_INDIVIDUAL_ELEMS +
5389           NUM_NAS_EPS_COMMON_ELEM +
5390           NUM_NAS_MSG_EMM + NUM_NAS_EMM_ELEM+
5391           NUM_NAS_MSG_ESM + NUM_NAS_ESM_ELEM];
5392
5393     ett[0] = &ett_nas_eps;
5394     ett[1] = &ett_nas_eps_esm_msg_cont;
5395     ett[2] = &ett_nas_eps_nas_msg_cont;
5396     ett[3] = &ett_nas_eps_gen_msg_cont;
5397     ett[4] = &ett_nas_eps_cmn_add_info;
5398
5399     last_offset = NUM_INDIVIDUAL_ELEMS;
5400
5401     for (i=0; i < NUM_NAS_EPS_COMMON_ELEM; i++, last_offset++)
5402     {
5403         ett_nas_eps_common_elem[i] = -1;
5404         ett[last_offset] = &ett_nas_eps_common_elem[i];
5405     }
5406
5407     /* EMM */
5408     for (i=0; i < NUM_NAS_MSG_EMM; i++, last_offset++)
5409     {
5410         ett_nas_msg_emm[i] = -1;
5411         ett[last_offset] = &ett_nas_msg_emm[i];
5412     }
5413
5414     for (i=0; i < NUM_NAS_EMM_ELEM; i++, last_offset++)
5415     {
5416         ett_nas_eps_emm_elem[i] = -1;
5417         ett[last_offset] = &ett_nas_eps_emm_elem[i];
5418     }
5419     /* EPS */
5420     for (i=0; i < NUM_NAS_MSG_ESM; i++, last_offset++)
5421     {
5422         ett_nas_msg_esm[i] = -1;
5423         ett[last_offset] = &ett_nas_msg_esm[i];
5424     }
5425
5426     for (i=0; i < NUM_NAS_ESM_ELEM; i++, last_offset++)
5427     {
5428         ett_nas_eps_esm_elem[i] = -1;
5429         ett[last_offset] = &ett_nas_eps_esm_elem[i];
5430     }
5431
5432     /* Register protocol */
5433     proto_nas_eps = proto_register_protocol(PNAME, PSNAME, PFNAME);
5434     /* Register fields and subtrees */
5435     proto_register_field_array(proto_nas_eps, hf, array_length(hf));
5436     proto_register_subtree_array(ett, array_length(ett));
5437
5438     /* Register dissector */
5439     register_dissector(PFNAME, dissect_nas_eps, proto_nas_eps);
5440
5441     /* Register dissector */
5442     register_dissector("nas-eps_plain", dissect_nas_eps_plain, proto_nas_eps);
5443 }
5444
5445 void
5446 proto_reg_handoff_nas_eps(void)
5447 {
5448     gsm_a_dtap_handle = find_dissector("gsm_a_dtap");
5449     lpp_handle = find_dissector("lpp");
5450 }