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