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