Further restructure the DECT dissector:
[obnox/wireshark/wip.git] / epan / dissectors / packet-dect.c
1 /* packet-dect.c
2  *
3  * Dissector for the Digital Enhanced Cordless Telecommunications
4  * protocol.
5  *
6  * $Id$
7  *
8  * Copyright 2008-2009:
9  * - Andreas Schuler <andreas (A) schulerdev.de>
10  * - Matthias Wenzel <dect (A) mazzoo.de>
11  *
12  * Wireshark - Network traffic analyzer
13  * By Gerald Combs <gerald@wireshark.org>
14  * Copyright 1998 Gerald Combs
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29  */
30
31 /*
32  TODO (roughly in that order)
33  - Expand beyond full slot, 2-level modulation
34  - Make things stateful
35  - Once the capture format has stabilized, get rid of the Ethernet
36    hack and use a proper capture type.
37  */
38
39 #ifdef HAVE_CONFIG_H
40 # include "config.h"
41 #endif
42
43 #include <epan/packet.h>
44 #include <epan/etypes.h>
45 #include <string.h>
46
47 #define ETHERTYPE_DECT 0x2323
48
49 #define DECT_PACKET_INFO_LEN 11
50
51 #define DECT_PACKET_PP 0
52 #define DECT_PACKET_FP 1
53
54 #define DECT_AFIELD_SIZE      8
55 #define DECT_AFIELD_TAIL_SIZE 5
56 #define DECT_BFIELD_DATA_SIZE 128
57
58 #define DECT_A_TA_MASK 0xE0
59 #define DECT_A_TA_SHIFT 5
60 #define DECT_A_BA_MASK 0x0E
61 #define DECT_A_BA_SHIFT 1
62 #define DECT_A_Q1_MASK 0x10
63 #define DECT_A_Q2_MASK 0x01
64
65 enum {
66         DECT_TA_CT0 = 0,
67         DECT_TA_CT1,
68         DECT_TA_NT_CL,
69         DECT_TA_NT,
70         DECT_TA_QT,
71         DECT_TA_ESC,
72         DECT_TA_MT,
73         DECT_TA_PT,
74         DECT_TA_MT_FIRST = DECT_TA_PT
75 };
76
77 /* ETSI EN 300 175-3 V2.3.0  6.2.4 and Annex E */
78 /* scramble table with corrections by Jakub Hruska */
79 static const guint8 scrt[8][31]=
80 {
81         {0x3B, 0xCD, 0x21, 0x5D, 0x88, 0x65, 0xBD, 0x44, 0xEF, 0x34, 0x85, 0x76, 0x21, 0x96, 0xF5, 0x13, 0xBC, 0xD2, 0x15, 0xD8, 0x86, 0x5B, 0xD4, 0x4E, 0xF3, 0x48, 0x57, 0x62, 0x19, 0x6F, 0x51},
82         {0x32, 0xDE, 0xA2, 0x77, 0x9A, 0x42, 0xBB, 0x10, 0xCB, 0x7A, 0x89, 0xDE, 0x69, 0x0A, 0xEC, 0x43, 0x2D, 0xEA, 0x27, 0x79, 0xA4, 0x2B, 0xB1, 0x0C, 0xB7, 0xA8, 0x9D, 0xE6, 0x90, 0xAE, 0xC4},
83         {0x2D, 0xEA, 0x27, 0x79, 0xA4, 0x2B, 0xB1, 0x0C, 0xB7, 0xA8, 0x9D, 0xE6, 0x90, 0xAE, 0xC4, 0x32, 0xDE, 0xA2, 0x77, 0x9A, 0x42, 0xBB, 0x10, 0xCB, 0x7A, 0x89, 0xDE, 0x69, 0x0A, 0xEC, 0x43},
84         {0x27, 0x79, 0xA4, 0x2B, 0xB1, 0x0C, 0xB7, 0xA8, 0x9D, 0xE6, 0x90, 0xAE, 0xC4, 0x32, 0xDE, 0xA2, 0x77, 0x9A, 0x42, 0xBB, 0x10, 0xCB, 0x7A, 0x89, 0xDE, 0x69, 0x0A, 0xEC, 0x43, 0x2D, 0xEA},
85         {0x19, 0x6F, 0x51, 0x3B, 0xCD, 0x21, 0x5D, 0x88, 0x65, 0xBD, 0x44, 0xEF, 0x34, 0x85, 0x76, 0x21, 0x96, 0xF5, 0x13, 0xBC, 0xD2, 0x15, 0xD8, 0x86, 0x5B, 0xD4, 0x4E, 0xF3, 0x48, 0x57, 0x62},
86         {0x13, 0xBC, 0xD2, 0x15, 0xD8, 0x86, 0x5B, 0xD4, 0x4E, 0xF3, 0x48, 0x57, 0x62, 0x19, 0x6F, 0x51, 0x3B, 0xCD, 0x21, 0x5D, 0x88, 0x65, 0xBD, 0x44, 0xEF, 0x34, 0x85, 0x76, 0x21, 0x96, 0xF5},
87         {0x0C, 0xB7, 0xA8, 0x9D, 0xE6, 0x90, 0xAE, 0xC4, 0x32, 0xDE, 0xA2, 0x77, 0x9A, 0x42, 0xBB, 0x10, 0xCB, 0x7A, 0x89, 0xDE, 0x69, 0x0A, 0xEC, 0x43, 0x2D, 0xEA, 0x27, 0x79, 0xA4, 0x2B, 0xB1},
88         {0x79, 0xA4, 0x2B, 0xB1, 0x0C, 0xB7, 0xA8, 0x9D, 0xE6, 0x90, 0xAE, 0xC4, 0x32, 0xDE, 0xA2, 0x77, 0x9A, 0x42, 0xBB, 0x10, 0xCB, 0x7A, 0x89, 0xDE, 0x69, 0x0A, 0xEC, 0x43, 0x2D, 0xEA, 0x27}
89 };
90
91
92 static int proto_dect = -1;
93
94
95 static gint ett_dect                            = -1;
96 static gint ett_columns                         = -1;
97 static gint ett_afield                          = -1;
98 static gint ett_ahead                           = -1;
99 static gint ett_atail                           = -1;
100 static gint ett_aqt                             = -1;
101 static gint ett_bfield                          = -1;
102 static gint ett_bfdescrdata                     = -1;
103
104 static int hf_dect_transceivermode              = -1;
105 static int hf_dect_preamble                     = -1;
106 static int hf_dect_type                         = -1;
107 static int hf_dect_channel                      = -1;
108 static int hf_dect_framenumber                  = -1;
109 static int hf_dect_rssi                         = -1;
110 static int hf_dect_slot                         = -1;
111 static int hf_dect_cc                           = -1;
112 static int hf_dect_cc_TA                        = -1;
113 static int hf_dect_cc_AField                    = -1;
114 static int hf_dect_cc_BField                    = -1;
115 static int hf_dect_A                            = -1;
116 static int hf_dect_A_Head                       = -1;
117 static int hf_dect_A_Head_TA_FP                 = -1;
118 static int hf_dect_A_Head_TA_PP                 = -1;
119 static int hf_dect_A_Head_Q1                    = -1;
120 static int hf_dect_A_Head_BA                    = -1;
121 static int hf_dect_A_Head_Q2                    = -1;
122 static int hf_dect_A_Tail                       = -1;
123 static int hf_dect_A_Tail_Nt                    = -1;
124 static int hf_dect_A_Tail_Qt_Qh                 = -1;
125 static int hf_dect_A_Tail_Qt_0_Sn               = -1;
126 static int hf_dect_A_Tail_Qt_0_Nr               = -1;
127 static int hf_dect_A_Tail_Qt_0_Sp               = -1;
128 static int hf_dect_A_Tail_Qt_0_Esc              = -1;
129 static int hf_dect_A_Tail_Qt_0_Txs              = -1;
130 static int hf_dect_A_Tail_Qt_0_Mc               = -1;
131 static int hf_dect_A_Tail_Qt_0_CA               = -1;
132 static int hf_dect_A_Tail_Qt_0_Spr1             = -1;
133 static int hf_dect_A_Tail_Qt_0_Cn               = -1;
134 static int hf_dect_A_Tail_Qt_0_Spr2             = -1;
135 static int hf_dect_A_Tail_Qt_0_PSCN             = -1;
136 static int hf_dect_A_Tail_Qt_3_A12              = -1;
137 static int hf_dect_A_Tail_Qt_3_A13              = -1;
138 static int hf_dect_A_Tail_Qt_3_A14              = -1;
139 static int hf_dect_A_Tail_Qt_3_A15              = -1;
140 static int hf_dect_A_Tail_Qt_3_A16              = -1;
141 static int hf_dect_A_Tail_Qt_3_A17              = -1;
142 static int hf_dect_A_Tail_Qt_3_A18              = -1;
143 static int hf_dect_A_Tail_Qt_3_A19              = -1;
144 static int hf_dect_A_Tail_Qt_3_A20              = -1;
145 static int hf_dect_A_Tail_Qt_3_A21              = -1;
146 static int hf_dect_A_Tail_Qt_3_A22              = -1;
147 static int hf_dect_A_Tail_Qt_3_A23              = -1;
148 static int hf_dect_A_Tail_Qt_3_A24              = -1;
149 static int hf_dect_A_Tail_Qt_3_A25              = -1;
150 static int hf_dect_A_Tail_Qt_3_A26              = -1;
151 static int hf_dect_A_Tail_Qt_3_A27              = -1;
152 static int hf_dect_A_Tail_Qt_3_A28              = -1;
153 static int hf_dect_A_Tail_Qt_3_A29              = -1;
154 static int hf_dect_A_Tail_Qt_3_A30              = -1;
155 static int hf_dect_A_Tail_Qt_3_A31              = -1;
156 static int hf_dect_A_Tail_Qt_3_A32              = -1;
157 static int hf_dect_A_Tail_Qt_3_A33              = -1;
158 static int hf_dect_A_Tail_Qt_3_A34              = -1;
159 static int hf_dect_A_Tail_Qt_3_A35              = -1;
160 static int hf_dect_A_Tail_Qt_3_A36              = -1;
161 static int hf_dect_A_Tail_Qt_3_A37              = -1;
162 static int hf_dect_A_Tail_Qt_3_A38              = -1;
163 static int hf_dect_A_Tail_Qt_3_A39              = -1;
164 static int hf_dect_A_Tail_Qt_3_A40              = -1;
165 static int hf_dect_A_Tail_Qt_3_A41              = -1;
166 static int hf_dect_A_Tail_Qt_3_A42              = -1;
167 static int hf_dect_A_Tail_Qt_3_A43              = -1;
168 static int hf_dect_A_Tail_Qt_3_A44              = -1;
169 static int hf_dect_A_Tail_Qt_3_A45              = -1;
170 static int hf_dect_A_Tail_Qt_3_A46              = -1;
171 static int hf_dect_A_Tail_Qt_3_A47              = -1;
172 static int hf_dect_A_Tail_Qt_4_CRFPHops         = -1;
173 static int hf_dect_A_Tail_Qt_4_CRFPEnc          = -1;
174 static int hf_dect_A_Tail_Qt_4_REFHops          = -1;
175 static int hf_dect_A_Tail_Qt_4_REPCap           = -1;
176 static int hf_dect_A_Tail_Qt_4_Sync             = -1;
177 static int hf_dect_A_Tail_Qt_4_A20              = -1;
178 static int hf_dect_A_Tail_Qt_4_MACSusp          = -1;
179 static int hf_dect_A_Tail_Qt_4_MACIpq           = -1;
180 static int hf_dect_A_Tail_Qt_4_A23              = -1;
181 static int hf_dect_A_Tail_Qt_4_A24              = -1;
182 static int hf_dect_A_Tail_Qt_4_A25              = -1;
183 static int hf_dect_A_Tail_Qt_4_A26              = -1;
184 static int hf_dect_A_Tail_Qt_4_A27              = -1;
185 static int hf_dect_A_Tail_Qt_4_A28              = -1;
186 static int hf_dect_A_Tail_Qt_4_A29              = -1;
187 static int hf_dect_A_Tail_Qt_4_A30              = -1;
188 static int hf_dect_A_Tail_Qt_4_A31              = -1;
189 static int hf_dect_A_Tail_Qt_4_A32              = -1;
190 static int hf_dect_A_Tail_Qt_4_A33              = -1;
191 static int hf_dect_A_Tail_Qt_4_A34              = -1;
192 static int hf_dect_A_Tail_Qt_4_A35              = -1;
193 static int hf_dect_A_Tail_Qt_4_A36              = -1;
194 static int hf_dect_A_Tail_Qt_4_A37              = -1;
195 static int hf_dect_A_Tail_Qt_4_A38              = -1;
196 static int hf_dect_A_Tail_Qt_4_A39              = -1;
197 static int hf_dect_A_Tail_Qt_4_A40              = -1;
198 static int hf_dect_A_Tail_Qt_4_A41              = -1;
199 static int hf_dect_A_Tail_Qt_4_A42              = -1;
200 static int hf_dect_A_Tail_Qt_4_A43              = -1;
201 static int hf_dect_A_Tail_Qt_4_A44              = -1;
202 static int hf_dect_A_Tail_Qt_4_A45              = -1;
203 static int hf_dect_A_Tail_Qt_4_A46              = -1;
204 static int hf_dect_A_Tail_Qt_4_A47              = -1;
205 static int hf_dect_A_Tail_Qt_6_Spare            = -1;
206 static int hf_dect_A_Tail_Qt_6_Mfn              = -1;
207 static int hf_dect_A_Tail_Mt_Mh                 = -1;
208 static int hf_dect_A_Tail_Mt_Mh_attr            = -1;
209 static int hf_dect_A_Tail_Mt_Mh_fmid            = -1;
210 static int hf_dect_A_Tail_Mt_Mh_pmid            = -1;
211 static int hf_dect_A_Tail_Mt_BasicConCtrl       = -1;
212 static int hf_dect_A_Tail_Mt_Encr_Cmd1          = -1;
213 static int hf_dect_A_Tail_Mt_Encr_Cmd2          = -1;
214 static int hf_dect_A_Tail_Pt_ExtFlag            = -1;
215 static int hf_dect_A_Tail_Pt_SDU                = -1;
216 static int hf_dect_A_Tail_Pt_RFPI               = -1;
217 static int hf_dect_A_Tail_Pt_BsData             = -1; 
218 static int hf_dect_A_Tail_Pt_InfoType           = -1;
219 static int hf_dect_A_Tail_Pt_SlotPairs          = -1;
220 static int hf_dect_A_Tail_Pt_Fillbits           = -1;
221 static int hf_dect_A_Tail_Pt_Bearer_Sn          = -1;
222 static int hf_dect_A_Tail_Pt_Bearer_Cn          = -1;
223 static int hf_dect_A_Tail_Pt_Bearer_Sp          = -1;
224 static int hf_dect_A_RCRC                       = -1;
225 static int hf_dect_B                            = -1;
226 static int hf_dect_B_Data                       = -1;
227 static int hf_dect_B_DescrambledData            = -1;
228 static int hf_dect_B_fn                         = -1;
229 static int hf_dect_B_XCRC                       = -1;
230
231 static const value_string tranceiver_mode[]=
232 {
233         {0, "Receive"},
234         {1, "Send"},
235         {0, NULL}
236 };
237
238 /* ETSI EN 300 175-3 V2.3.0  7.1.2 */
239 static const value_string TA_vals_FP[]=
240 {
241         {0, "Ct Next Data Packet"},
242         {1, "Ct First Data Packet"},
243         {2, "Nt Identities Information on Connectionless Bearer"},
244         {3, "Nt Identities Information"},
245         {4, "Qt Multiframe Synchronisation and System Information"},
246         {5, "Escape"},
247         {6, "Mt MAC Layer Control"},
248         {7, "Pt Paging Tail"},
249         {0, NULL}
250 };
251
252 /* ETSI EN 300 175-3 V2.3.0  7.1.2 */
253 static const value_string TA_vals_PP[]=
254 {
255         {0, "Ct Next Data Packet"},
256         {1, "Ct First Data Packet"},
257         {2, "Nt Identities Information on Connectionless Bearer"},
258         {3, "Nt Identities Information"},
259         {4, "Qt Multiframe Synchronisation and System Information"},
260         {5, "Escape"},
261         {6, "Mt MAC Layer Control"},
262         {7, "Mt MAC Layer Control,first packet"},
263         {0, NULL}
264 };
265
266 /* ETSI EN 300 175-3 V2.3.0  7.1.4 */
267 static const value_string BA_vals[]=
268 {
269         {0, "U-Type, In, SIn or Ip Packet No. 0 or No Valid Ip_error_detect Channel Data"},
270         {1, "U-Type, Ip_error_detect or Ip Packet No. 1 or SIn or No Valid In Channel Data"},
271         {2, "Double-Slot Required / E-Type, all Cf or CLf, Packet No. 0"},
272         {3, "E-Type, All Cf, Packet No. 1"},
273         {4, "Half-Slot Required / E-Type, not all Cf or CLf, Cf Packet No. 0"},
274         {5, "E-Type, not all Cf, Cf Packet No. 1"},
275         {6, "E-Type, All MAC control (unnumbered)"},
276         {7, "No B-Field"},
277         {0, NULL}
278 };
279
280 /* ETSI EN 300 175-3 V2.3.0  7.2.3.1 */
281 static const value_string QTHead_vals[]=
282 {
283         {0, "Static System Info"},
284         {1, "Static System Info"},
285         {2, "Extended RF Carriers Part 1"},
286         {3, "Fixed Part Capabilities"},
287         {4, "Extended Fixed Part Capabilities"},
288         {5, "SARI List Contents"},
289         {6, "Multi-Frame No."},
290         {7, "Escape"},
291         {8, "Obsolete"},
292         {9, "Extended RF Carriers Part 2"},
293         {10, "Reserved("},
294         {11, "Transmit Information"},
295         {12, "Extended Fixed Part Capabilities 2"},
296         {13, "Reserved"},
297         {14, "Reserved"},
298         {15, "Reserved"},
299         {0, NULL}
300 };
301
302 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.2 */
303 static const value_string QTNormalReverse_vals[]=
304 {
305         {0, "Normal RFP Transmit Half-Frame"},
306         {1, "Normal PP Transmit Half-Frame"},
307         {0, NULL}
308 };
309
310 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.3 */
311 static const value_string QTSlotNumber_vals[]=
312 {
313         {0, "Slot Pair 0/12"},
314         {1, "Slot Pair 1/13"},
315         {2, "Slot Pair 2/14"},
316         {3, "Slot Pair 3/15"},
317         {4, "Slot Pair 4/16"},
318         {5, "Slot Pair 5/17"},
319         {6, "Slot Pair 6/18"},
320         {7, "Slot Pair 7/19"},
321         {8, "Slot Pair 8/20"},
322         {9, "Slot Pair 9/21"},
323         {10, "Slot Pair 10/22"},
324         {11, "Slot Pair 11/23"},
325         {12, "Reserved"},
326         {13, "Reserved"},
327         {14, "Reserved"},
328         {15, "Reserved"},
329         {0, NULL}
330 };
331
332 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.4 */
333 static const value_string QTStartPosition_vals[]=
334 {
335         {0, "S-Field starts at Bit F0"},
336         {1, "Reserved for Future Use"},
337         {2, "S-Field starts at Bit F240"},
338         {3, "Reserved for Future Use"},
339         {0, NULL}
340 };
341
342 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.5 */
343 static const value_string QTEscape_vals[]=
344 {
345         {0, "No QT Escape is broadcast"},
346         {1, "The QT Escape is broadcast"},
347         {0, NULL}
348 };
349
350 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.6 */
351 static const value_string QTTranceiver_vals[]=
352 {
353         {0, "RFP has 1 Transceiver"},
354         {1, "RFP has 2 Transceiver"},
355         {2, "RFP has 3 Transceiver"},
356         {3, "RFP has 4 or more Transceiver"},
357         {0, NULL}
358 };
359
360 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.7 */
361 static const value_string QTExtendedCarrier_vals[]=
362 {
363         {0, "No Extended RF Carrier Information Message"},
364         {1, "Extended RF Carrier Information Message shall be transmitted in the next Multiframe"},
365         {0, NULL}
366 };
367
368 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.9 */
369 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.11 */
370 static const value_string QTSpr_vals[]=
371 {
372         {0, "OK"},
373         {1, "Reserved"},
374         {2, "Reserved"},
375         {3, "Reserved"},
376         {0, NULL}
377 };
378
379 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.10 */
380 static const value_string QTCarrierNumber_vals[]=
381 {
382         {0, "RF Carrier 0"},
383         {1, "RF Carrier 1"},
384         {2, "RF Carrier 2"},
385         {3, "RF Carrier 3"},
386         {4, "RF Carrier 4"},
387         {5, "RF Carrier 5"},
388         {6, "RF Carrier 6"},
389         {7, "RF Carrier 7"},
390         {8, "RF Carrier 8"},
391         {9, "RF Carrier 9"},
392         {10, "RF Carrier 10"},
393         {11, "RF Carrier 11"},
394         {12, "RF Carrier 12"},
395         {13, "RF Carrier 13"},
396         {14, "RF Carrier 14"},
397         {15, "RF Carrier 15"},
398         {16, "RF Carrier 16"},
399         {17, "RF Carrier 17"},
400         {18, "RF Carrier 18"},
401         {19, "RF Carrier 19"},
402         {20, "RF Carrier 20"},
403         {21, "RF Carrier 21"},
404         {22, "RF Carrier 22"},
405         {23, "RF Carrier 23"},
406         {24, "RF Carrier 24"},
407         {25, "RF Carrier 25"},
408         {26, "RF Carrier 26"},
409         {27, "RF Carrier 27"},
410         {28, "RF Carrier 28"},
411         {29, "RF Carrier 29"},
412         {30, "RF Carrier 30"},
413         {31, "RF Carrier 31"},
414         {32, "RF Carrier 32"},
415         {33, "RF Carrier 33"},
416         {34, "RF Carrier 34"},
417         {35, "RF Carrier 35"},
418         {36, "RF Carrier 36"},
419         {37, "RF Carrier 37"},
420         {38, "RF Carrier 38"},
421         {39, "RF Carrier 39"},
422         {40, "RF Carrier 40"},
423         {41, "RF Carrier 41"},
424         {42, "RF Carrier 42"},
425         {43, "RF Carrier 43"},
426         {44, "RF Carrier 44"},
427         {45, "RF Carrier 45"},
428         {46, "RF Carrier 46"},
429         {47, "RF Carrier 47"},
430         {48, "RF Carrier 48"},
431         {49, "RF Carrier 49"},
432         {50, "RF Carrier 50"},
433         {51, "RF Carrier 51"},
434         {52, "RF Carrier 52"},
435         {53, "RF Carrier 53"},
436         {54, "RF Carrier 54"},
437         {55, "RF Carrier 55"},
438         {56, "RF Carrier 56"},
439         {57, "RF Carrier 57"},
440         {58, "RF Carrier 58"},
441         {59, "RF Carrier 59"},
442         {60, "RF Carrier 60"},
443         {61, "RF Carrier 61"},
444         {62, "RF Carrier 62"},
445         {63, "RF Carrier 63"},
446         {0, NULL}
447 };
448
449 /* ETSI EN 300 175-3 V2.3.0  7.2.3.2.12 */
450 static const value_string QTScanCarrierNum_vals[]=
451 {
452         {0, "Primary Scan next on RF Carrier 0"},
453         {1, "Primary Scan next on RF Carrier 1"},
454         {2, "Primary Scan next on RF Carrier 2"},
455         {3, "Primary Scan next on RF Carrier 3"},
456         {4, "Primary Scan next on RF Carrier 4"},
457         {5, "Primary Scan next on RF Carrier 5"},
458         {6, "Primary Scan next on RF Carrier 6"},
459         {7, "Primary Scan next on RF Carrier 7"},
460         {8, "Primary Scan next on RF Carrier 8"},
461         {9, "Primary Scan next on RF Carrier 9"},
462         {10, "Primary Scan next on RF Carrier 10"},
463         {11, "Primary Scan next on RF Carrier 11"},
464         {12, "Primary Scan next on RF Carrier 12"},
465         {13, "Primary Scan next on RF Carrier 13"},
466         {14, "Primary Scan next on RF Carrier 14"},
467         {15, "Primary Scan next on RF Carrier 15"},
468         {16, "Primary Scan next on RF Carrier 16"},
469         {17, "Primary Scan next on RF Carrier 17"},
470         {18, "Primary Scan next on RF Carrier 18"},
471         {19, "Primary Scan next on RF Carrier 19"},
472         {20, "Primary Scan next on RF Carrier 20"},
473         {21, "Primary Scan next on RF Carrier 21"},
474         {22, "Primary Scan next on RF Carrier 22"},
475         {23, "Primary Scan next on RF Carrier 23"},
476         {24, "Primary Scan next on RF Carrier 24"},
477         {25, "Primary Scan next on RF Carrier 25"},
478         {26, "Primary Scan next on RF Carrier 26"},
479         {27, "Primary Scan next on RF Carrier 27"},
480         {28, "Primary Scan next on RF Carrier 28"},
481         {29, "Primary Scan next on RF Carrier 29"},
482         {30, "Primary Scan next on RF Carrier 30"},
483         {31, "Primary Scan next on RF Carrier 31"},
484         {32, "Primary Scan next on RF Carrier 32"},
485         {33, "Primary Scan next on RF Carrier 33"},
486         {34, "Primary Scan next on RF Carrier 34"},
487         {35, "Primary Scan next on RF Carrier 35"},
488         {36, "Primary Scan next on RF Carrier 36"},
489         {37, "Primary Scan next on RF Carrier 37"},
490         {38, "Primary Scan next on RF Carrier 38"},
491         {39, "Primary Scan next on RF Carrier 39"},
492         {40, "Primary Scan next on RF Carrier 40"},
493         {41, "Primary Scan next on RF Carrier 41"},
494         {42, "Primary Scan next on RF Carrier 42"},
495         {43, "Primary Scan next on RF Carrier 43"},
496         {44, "Primary Scan next on RF Carrier 44"},
497         {45, "Primary Scan next on RF Carrier 45"},
498         {46, "Primary Scan next on RF Carrier 46"},
499         {47, "Primary Scan next on RF Carrier 47"},
500         {48, "Primary Scan next on RF Carrier 48"},
501         {49, "Primary Scan next on RF Carrier 49"},
502         {50, "Primary Scan next on RF Carrier 50"},
503         {51, "Primary Scan next on RF Carrier 51"},
504         {52, "Primary Scan next on RF Carrier 52"},
505         {53, "Primary Scan next on RF Carrier 53"},
506         {54, "Primary Scan next on RF Carrier 54"},
507         {55, "Primary Scan next on RF Carrier 55"},
508         {56, "Primary Scan next on RF Carrier 56"},
509         {57, "Primary Scan next on RF Carrier 57"},
510         {58, "Primary Scan next on RF Carrier 58"},
511         {59, "Primary Scan next on RF Carrier 59"},
512         {60, "Primary Scan next on RF Carrier 60"},
513         {61, "Primary Scan next on RF Carrier 61"},
514         {62, "Primary Scan next on RF Carrier 62"},
515         {63, "Primary Scan next on RF Carrier 63"},
516         {0, NULL}
517 };
518
519 /* ETSI EN 300 175-3 V2.3.0  7.2.3.4.2 */
520 static const value_string Qt_A12_vals[]=
521 {
522         {0, "   Extended FP Info"},
523         {1, "Extended FP Info"},
524         {0, NULL}
525 };
526
527 static const value_string Qt_A13_vals[]=
528 {
529         {0, "   Double Duplex Bearer Connections"},
530         {1, "Double Duplex Bearer Connections"},
531         {0, NULL}
532 };
533
534 static const value_string Qt_A14_vals[]=
535 {
536         {0, "   Reserved"},
537         {1, "Reserved"},
538         {0, NULL}
539 };
540
541 static const value_string Qt_A15_vals[]=
542 {
543         {0, "   Double Slot"},
544         {1, "Double Slot"},
545         {0, NULL}
546 };
547
548 static const value_string Qt_A16_vals[]=
549 {
550         {0, "   Half Slot"},
551         {1, "Half Slot"},
552         {0, NULL}
553 };
554
555 static const value_string Qt_A17_vals[]=
556 {
557         {0, "   Full Slot"},
558         {1, "Full Slot"},
559         {0, NULL}
560 };
561
562 static const value_string Qt_A18_vals[]=
563 {
564         {0, "   Frequency Control"},
565         {1, "Frequency Control"},
566         {0, NULL}
567 };
568
569 static const value_string Qt_A19_vals[]=
570 {
571         {0, "   Page Repetition"},
572         {1, "Page Repetition"},
573         {0, NULL}
574 };
575
576 static const value_string Qt_A20_vals[]=
577 {
578         {0, "   C/O Setup on Dummy allowed"},
579         {1, "C/O Setup on Dummy allowed"},
580         {0, NULL}
581 };
582
583 static const value_string Qt_A21_vals[]=
584 {
585         {0, "   C/L Uplink"},
586         {1, "C/L Uplink"},
587         {0, NULL}
588 };
589
590 static const value_string Qt_A22_vals[]=
591 {
592         {0, "   C/L Downlink"},
593         {1, "C/L Downlink"},
594         {0, NULL}
595 };
596
597 static const value_string Qt_A23_vals[]=
598 {
599         {0, "   Basic A-Field Set-Up"},
600         {1, "Basic A-Field Set-Up"},
601         {0, NULL}
602 };
603
604 static const value_string Qt_A24_vals[]=
605 {
606         {0, "   Advanced A-Field Set-Up"},
607         {1, "Advanced A-Field Set-Up"},
608         {0, NULL}
609 };
610
611 static const value_string Qt_A25_vals[]=
612 {
613         {0, "   B-field Set-Up"},
614         {1, "B-field Set-Up"},
615         {0, NULL}
616 };
617
618 static const value_string Qt_A26_vals[]=
619 {
620         {0, "   Cf Messages"},
621         {1, "Cf Messages"},
622         {0, NULL}
623 };
624
625 static const value_string Qt_A27_vals[]=
626 {
627         {0, "   In Minimum Delay"},
628         {1, "In Minimum Delay"},
629         {0, NULL}
630 };
631
632 static const value_string Qt_A28_vals[]=
633 {
634         {0, "   In Normal Delay"},
635         {1, "In Normal Delay"},
636         {0, NULL}
637 };
638
639 static const value_string Qt_A29_vals[]=
640 {
641         {0, "   Ip Error Detection"},
642         {1, "Ip Error Detection"},
643         {0, NULL}
644 };
645
646 static const value_string Qt_A30_vals[]=
647 {
648         {0, "   Ip Error Correction"},
649         {1, "Ip Error Correction"},
650         {0, NULL}
651 };
652
653 static const value_string Qt_A31_vals[]=
654 {
655         {0, "   Multibearer Connections"},
656         {1, "Multibearer Connections"},
657         {0, NULL}
658 };
659
660 /* ETSI EN 300 175-5 V2.3.0  Annex F */
661 static const value_string Qt_A32_vals[]=
662 {
663         {0, "   ADPCM/G.726 Voice service"},
664         {1, "ADPCM/G.726 Voice service"},
665         {0, NULL}
666 };
667
668 static const value_string Qt_A33_vals[]=
669 {
670         {0, "   GAP basic speech"},
671         {1, "GAP basic speech"},
672         {0, NULL}
673 };
674
675 static const value_string Qt_A34_vals[]=
676 {
677         {0, "   Non-voice circuit switched service"},
678         {1, "Non-voice circuit switched service"},
679         {0, NULL}
680 };
681
682 static const value_string Qt_A35_vals[]=
683 {
684         {0, "   Non-voice packet switched service"},
685         {1, "Non-voice packet switched service"},
686         {0, NULL}
687 };
688
689 static const value_string Qt_A36_vals[]=
690 {
691         {0, "   Standard authentication required"},
692         {1, "Standard authentication required"},
693         {0, NULL}
694 };
695
696 static const value_string Qt_A37_vals[]=
697 {
698         {0, "   Standard ciphering supported"},
699         {1, "Standard ciphering supported"},
700         {0, NULL}
701 };
702
703 static const value_string Qt_A38_vals[]=
704 {
705         {0, "   Location registration supported"},
706         {1, "Location registration supported"},
707         {0, NULL}
708 };
709
710 static const value_string Qt_A39_vals[]=
711 {
712         {0, "   SIM services available"},
713         {1, "SIM services available"},
714         {0, NULL}
715 };
716
717 static const value_string Qt_A40_vals[]=
718 {
719         {0, "   Non-static Fixed Part (FP)"},
720         {1, "Non-static Fixed Part (FP)"},
721         {0, NULL}
722 };
723
724 static const value_string Qt_A41_vals[]=
725 {
726         {0, "   CISS services available"},
727         {1, "CISS services available"},
728         {0, NULL}
729 };
730
731 static const value_string Qt_A42_vals[]=
732 {
733         {0, "   CLMS service available"},
734         {1, "CLMS service available"},
735         {0, NULL}
736 };
737
738 static const value_string Qt_A43_vals[]=
739 {
740         {0, "   COMS service available"},
741         {1, "COMS service available"},
742         {0, NULL}
743 };
744
745 static const value_string Qt_A44_vals[]=
746 {
747         {0, "   Access rights requests supported"},
748         {1, "Access rights requests supported"},
749         {0, NULL}
750 };
751
752 static const value_string Qt_A45_vals[]=
753 {
754         {0, "   External handover supported"},
755         {1, "External handover supported"},
756         {0, NULL}
757 };
758
759 static const value_string Qt_A46_vals[]=
760 {
761         {0, "   Connection handover supported"},
762         {1, "Connection handover supported"},
763         {0, NULL}
764 };
765
766 static const value_string Qt_A47_vals[]=
767 {
768         {0, "   Reserved"},
769         {1, "Reserved"},
770         {0, NULL}
771 };
772
773
774 static const value_string Qt_EA20_vals[]=
775 {
776         {0, "   Reserved"},
777         {1, "Reserved"},
778         {0, NULL}
779 };
780
781 /* ETSI EN 300 175-3 V2.3.0  7.2.3.5.2.1 */
782 static const value_string Qt_CRFPHops_vals[]=
783 {
784         {0, "1 CRFP is allowed"},
785         {1, "2 CRFP allowed in cascade"},
786         {2, "3 CRFP allowed in cascade"},
787         {3, "No CRFP allowed"},
788         {0, NULL}
789 };
790
791 static const value_string Qt_CRFPEnc_vals[]=
792 {
793         {0, "CRFP encryption not supported"},
794         {1, "CRFP encryption supported"},
795         {0, NULL}
796 };
797
798 static const value_string Qt_REPHops_vals[]=
799 {
800         {0, "REP not supported"},
801         {1, "1 REP is allowed"},
802         {2, "2 REP are allowed in cascade"},
803         {3, "3 REP are allowed in cascade"},
804         {0, NULL}
805 };
806
807 static const value_string Qt_REPCap_vals[]=
808 {
809         {0, "REP interlacing not supported"},
810         {1, "REP interlacing supported"},
811         {0, NULL}
812 };
813
814 /* ETSI EN 300 175-3 V2.3.0  7.2.3.5.2.2 */
815 static const value_string Qt_Sync_vals[]=
816 {
817         {0, "standard, see EN 300 175-2 [2], clauses 4.6 and 5.2"},
818         {1, "prolonged preamble, see EN 300 175-2 [2], annex C (see note)"},
819         {2, "reserved"},
820         {3, "reserved"},
821         {0, NULL}
822 };
823
824 /* ETSI EN 300 175-3 V2.3.0  7.2.3.5.2.3 */
825 static const value_string Qt_MACSusp_vals[]=
826 {
827         {0, "Suspend and Resume not supported"},
828         {1, "Suspend and Resume supported"},
829         {0, NULL}
830 };
831
832 /* ETSI EN 300 175-3 V2.3.0  7.2.3.5.2.4 */
833 static const value_string Qt_MACIpq_vals[]=
834 {
835         {0, "Ipq not supported"},
836         {1, "Ipq supported"},
837         {0, NULL}
838 };
839
840 /* ETSI EN 300 175-3 V2.3.0  7.2.3.5.2 */
841 static const value_string Qt_EA23_vals[]=
842 {
843         {0, "   Extended Fixed Part Info 2"},
844         {1, "Extended Fixed Part Info 2"},
845         {0, NULL}
846 };
847
848 static const value_string Qt_EA24_vals[]=
849 {
850         {0, "   Unused"},
851         {1, "Unused"},
852         {0, NULL}
853 };
854
855 /* ETSI EN 300 175-5 V2.3.0  Annex F */
856 static const value_string Qt_EA25_vals[]=
857 {
858         {0, "   F-MMS Interworking profile supported"},
859         {1, "F-MMS Interworking profile supported"},
860         {0, NULL}
861 };
862
863 static const value_string Qt_EA26_vals[]=
864 {
865         {0, "   Basic ODAP supported"},
866         {1, "Basic ODAP supported"},
867         {0, NULL}
868 };
869
870 static const value_string Qt_EA27_vals[]=
871 {
872         {0, "   Generic Media Encapsulation transport (DPRS) supported"},
873         {1, "Generic Media Encapsulation transport (DPRS) supported"},
874         {0, NULL}
875 };
876
877 static const value_string Qt_EA28_vals[]=
878 {
879         {0, "   IP Roaming unrestricted supported"},
880         {1, "IP Roaming unrestricted supported"},
881         {0, NULL}
882 };
883
884 static const value_string Qt_EA29_vals[]=
885 {
886         {0, "   Ethernet"},
887         {1, "Ethernet"},
888         {0, NULL}
889 };
890
891 static const value_string Qt_EA30_vals[]=
892 {
893         {0, "   Token Ring"},
894         {1, "Token Ring"},
895         {0, NULL}
896 };
897
898 static const value_string Qt_EA31_vals[]=
899 {
900         {0, "   IP"},
901         {1, "IP"},
902         {0, NULL}
903 };
904
905 static const value_string Qt_EA32_vals[]=
906 {
907         {0, "   PPP"},
908         {1, "PPP"},
909         {0, NULL}
910 };
911
912 static const value_string Qt_EA33_vals[]=
913 {
914         {0, "   V.24"},
915         {1, "V.24"},
916         {0, NULL}
917 };
918
919 static const value_string Qt_EA34_vals[]=
920 {
921         {0, "   Reserved"},
922         {1, "Reserved"},
923         {0, NULL}
924 };
925
926 static const value_string Qt_EA35_vals[]=
927 {
928         {0, "   Reserved"},
929         {1, "Reserved"},
930         {0, NULL}
931 };
932
933 static const value_string Qt_EA36_vals[]=
934 {
935         {0, "   RAP Part 1 Profile"},
936         {1, "RAP Part 1 Profile"},
937         {0, NULL}
938 };
939
940 static const value_string Qt_EA37_vals[]=
941 {
942         {0, "   ISDN intermediate system"},
943         {1, "ISDN intermediate system"},
944         {0, NULL}
945 };
946
947 static const value_string Qt_EA38_vals[]=
948 {
949         {0, "   Synchronization to GPS achieved"},
950         {1, "Synchronization to GPS achieved"},
951         {0, NULL}
952 };
953
954 static const value_string Qt_EA39_vals[]=
955 {
956         {0, "   Location registration with TPUI allowed"},
957         {1, "Location registration with TPUI allowed"},
958         {0, NULL}
959 };
960
961 static const value_string Qt_EA40_vals[]=
962 {
963         {0, "   Emergency call supported"},
964         {1, "Emergency call supported"},
965         {0, NULL}
966 };
967
968 static const value_string Qt_EA41_vals[]=
969 {
970         {0, "   Asymmetric bearers supported"},
971         {1, "Asymmetric bearers supported"},
972         {0, NULL}
973 };
974
975 static const value_string Qt_EA42_vals[]=
976 {
977         {0, "   Reserved"},
978         {1, "Reserved"},
979         {0, NULL}
980 };
981
982 static const value_string Qt_EA43_vals[]=
983 {
984         {0, "   LRMS"},
985         {1, "LRMS"},
986         {0, NULL}
987 };
988
989 static const value_string Qt_EA44_vals[]=
990 {
991         {0, "   Data Service Profile D"},
992         {1, "Data Service Profile D"},
993         {0, NULL}
994 };
995
996 static const value_string Qt_EA45_vals[]=
997 {
998         {0, "   DPRS Stream"},
999         {1, "DPRS Stream"},
1000         {0, NULL}
1001 };
1002
1003 static const value_string Qt_EA46_vals[]=
1004 {
1005         {0, "   DPRS FREL"},
1006         {1, "DPRS FREL"},
1007         {0, NULL}
1008 };
1009
1010 static const value_string Qt_EA47_vals[]=
1011 {
1012         {0, "   ISDN Data Services"},
1013         {1, "ISDN Data Services"},
1014         {0, NULL}
1015 };
1016
1017 /* ETSI EN 300 175-3 V2.3.0  7.2.5.1 */
1018 static const value_string MTHead_vals[]=
1019 {
1020         {0, "Basic Connection Control"},
1021         {1, "Advanced Connection Control"},
1022         {2, "MAC Layer Test Messages"},
1023         {3, "Quality Control"},
1024         {4, "Broadcast and Connectionless Services"},
1025         {5, "Encryption Control"},
1026         {6, "Tail for use with the first Transmission of a B-Field \"bearer request\" Message"},
1027         {7, "Escape"},
1028         {8, "TARI Message"},
1029         {9, "REP Connection Control"},
1030         {10, "Reserved"},
1031         {11, "Reserved"},
1032         {12, "Reserved"},
1033         {13, "Reserved"},
1034         {14, "Reserved"},
1035         {15, "Reserved"},
1036         {0, NULL}
1037 };
1038
1039 /* ETSI EN 300 175-3 V2.3.0  7.2.5.2 */
1040 static const value_string MTBasicConCtrl_vals[]=
1041 {
1042         {0, "Access Request"},
1043         {1, "Bearer Handover Request"},
1044         {2, "Connection Handover Request"},
1045         {3, "Unconfirmed Access Request"},
1046         {4, "Bearer Confirm"},
1047         {5, "Wait"},
1048         {6, "Attributes T Request"},
1049         {7, "Attributes T Confirm"},
1050         {8, "Reserved"},
1051         {9, "Reserved"},
1052         {10, "Reserved"},
1053         {11, "Reserved"},
1054         {12, "Reserved"},
1055         {13, "Reserved"},
1056         {14, "Reserved"},
1057         {15, "Release"},
1058         {0, NULL}
1059 };
1060
1061 /* ETSI EN 300 175-3 V2.3.0  7.2.5.7 */
1062 static const value_string MTEncrCmd1_vals[]=
1063 {
1064         {0, "Start Encryption"},
1065         {1, "Stop Encryption"},
1066         {2, "reserved"},
1067         {3, "reserved"},
1068         {0, NULL}
1069 };
1070
1071 static const value_string MTEncrCmd2_vals[]=
1072 {
1073         {0, "Request"},
1074         {1, "Confirm"},
1075         {2, "Grant"},
1076         {3, "Reserved"},
1077         {0, NULL}
1078 };
1079
1080 /* ETSI EN 300 175-3 V2.3.0  7.2.4.2.2 */
1081 static const value_string PTExtFlag_vals[]=
1082 {
1083         {0, "Next normal Page in Frame 0"},
1084         {1, "Another Page in next Frame"},
1085         {0, NULL}
1086 };
1087
1088 /* ETSI EN 300 175-3 V2.3.0  7.2.4.2.3 */
1089 static const value_string PTSDU_vals[]=
1090 {
1091         {0, "Zero Length Page"},
1092         {1, "Short Page"},
1093         {2, "Full Page"},
1094         {3, "MAC resume page"},
1095         {4, "Not the last 36 Bits of a Long Page"},
1096         {5, "The first 36 Bits of a Long Page"},
1097         {6, "The last 36 Bits of a Long Page"},
1098         {7, "All of a Long Page (first and last)"},
1099         {0, NULL}
1100 };
1101
1102 /* ETSI EN 300 175-3 V2.3.0  7.2.4.3.1 */
1103 static const value_string PTInfoType_vals[]=
1104 {
1105         {0, "Fill Bits"},
1106         {1, "Blind Full Slot Information for Circuit Mode Service"},
1107         {2, "Other Bearer"},
1108         {3, "Recommended Other Bearer"},
1109         {4, "Good RFP Bearer"},
1110         {5, "Dummy or connectionless Bearer Position"},
1111         {6, "Extended Modulation Types"},
1112         {7, "Escape"},
1113         {8, "Dummy or connectionless Bearer Marker"},
1114         {9, "Bearer Handover/Replacement Information"},
1115         {10, "RFP Status and Modulation Types"},
1116         {11, "Active Carriers"},
1117         {12, "Connectionless Bearer Position"},
1118         {13, "RFP Power Level"},
1119         {14, "Blind Double Slot/RFP-FP Interface Resource Information"},
1120         {15, "Blind Full Slot Information for Packet Mode Service"},
1121         {0, NULL}
1122 };
1123
1124 /* ETSI EN 300 175-3 V2.3.0  7.2.4.3.10 */
1125 static const value_string PTRFPPower_vals[]=
1126 {
1127         {0, "0 dBm"},
1128         {1, "2 dBm"},
1129         {2, "4 dBm"},
1130         {3, "6 dBm"},
1131         {4, "8 dBm"},
1132         {5, "10 dBm"},
1133         {6, "12 dBm"},
1134         {7, "14 dBm"},
1135         {8, "16 dBm"},
1136         {9, "18 dBm"},
1137         {10, "20 dBm"},
1138         {11, "22 dBm"},
1139         {12, "24 dBm"},
1140         {13, "26 dBm"},
1141         {14, "28 dBm"},
1142         {15, "30 dBm"},
1143         {0, NULL}
1144 };
1145
1146
1147 static unsigned char
1148 dect_getbit(guint8 *data, int bit)
1149 {
1150         guint8 byte=data[bit/8];
1151
1152         return (byte>>bit%8)&1;
1153 }
1154
1155 static void
1156 dect_setbit(guint8 *data, int bit, guint8 value)
1157 {
1158         if(!value)
1159                 data[bit/8]&=~(1<<(bit%8));
1160         else
1161                 data[bit/8]|=(1<<(bit%8));
1162 }
1163
1164 /* EN 300 175-3 V2.3.0  6.2.5.4 */
1165 static guint8
1166 calc_xcrc(guint8* data, guint8 length)
1167 {
1168         guint8 bits[21];
1169         guint8 gp=0x1;
1170         guint8 crc;
1171         guint8 next;
1172         int y, x;
1173
1174         for(y=0;y<=length-4;y++)
1175         {
1176                 dect_setbit(bits, y, dect_getbit(data, y+48*(1+(int)(y/16))));
1177         }
1178         length=10;
1179         crc=bits[0];
1180         y=0;
1181         while(y<length)
1182         {
1183                 if(y<(length-1))
1184                         next=bits[y+1];
1185                 else
1186                         next=0;
1187                 y++;
1188                 x=0;
1189                 while(x<8)
1190                 {
1191                         while(!(crc&0x80))
1192                         {
1193                                 crc<<=1;
1194                                 crc|=!!(next&0x80);
1195                                 next<<=1;
1196                                 x++;
1197                                 if(x>7)
1198                                         break;
1199                         }
1200                         if(x>7)
1201                                 break;
1202                         crc<<=1;
1203                         crc|=!!(next&0x80);
1204                         next<<=1;
1205                         x++;
1206                         crc^=(gp<<4);
1207                 }
1208         }
1209         return crc;
1210 }
1211
1212 /* EN 300 175-3 V2.3.0  6.2.5.2 */
1213 static guint16
1214 calc_rcrc(guint8* data)
1215 {
1216         guint16 gp=0x0589; /* 10000010110001001 without the leading 1 */
1217
1218         guint16 crc;
1219         guint8 next;
1220         int y, x;
1221
1222         crc=data[0]<<8|data[1];
1223         y=0;
1224         while(y<6)
1225         {
1226                 next=data[2+y];
1227                 y++;
1228                 x=0;
1229                 while(x<8)
1230                 {
1231                         while(!(crc&0x8000))
1232                         {
1233                                 crc<<=1;
1234                                 crc|=!!(next&0x80);
1235                                 next<<=1;
1236                                 x++;
1237                                 if(x>7)
1238                                         break;
1239                         }
1240                         if(x>7)
1241                                 break;
1242                         crc<<=1;
1243                         crc|=!!(next&0x80);
1244                         next<<=1;
1245                         x++;
1246                         crc^=gp;
1247                 }
1248         }
1249         crc^=1;
1250         return crc;
1251 }
1252
1253 /* ETSI EN 300 175-3 V2.3.0  6.2.1.3 */
1254 static gint
1255 dissect_bfield(gboolean dect_packet_type _U_, guint8 ba,
1256         packet_info *pinfo _U_, tvbuff_t *tvb, gint offset, proto_tree *DectTree, proto_tree *ColumnsTree)
1257 {
1258         guint8 xcrc, xcrclen;
1259         guint16 blen;
1260         gint start_offset;
1261         char *bfield_str;
1262         char *bfield_short_str;
1263
1264         proto_item *bfieldti        = NULL;
1265         proto_tree *BField          = NULL;
1266
1267         proto_item *bfdescrdatati   = NULL;
1268         proto_tree *BFDescrData     = NULL;
1269
1270         guint8 bfield_data[DECT_BFIELD_DATA_SIZE];
1271         guint bfield_length = tvb_length_remaining(tvb, offset);
1272
1273         if (bfield_length > DECT_BFIELD_DATA_SIZE)
1274                 bfield_length = DECT_BFIELD_DATA_SIZE;
1275
1276         if (bfield_length)
1277                 tvb_memcpy(tvb, bfield_data, offset, bfield_length);
1278         else
1279                 memset(bfield_data, 0, DECT_BFIELD_DATA_SIZE);
1280
1281         /* B-Field */
1282         switch(ba)
1283         {
1284         case 0:
1285         case 1:
1286         case 3:
1287         case 5:
1288         case 6:
1289                 blen=40;
1290                 xcrclen=4;
1291
1292                 bfield_short_str="Full Slot";
1293                 bfield_str="Full Slot (320 bit data, 4 bit xcrc)";
1294                 break;
1295         case 2:
1296                 blen=100;
1297                 xcrclen=4;
1298
1299                 bfield_short_str="Double Slot";
1300                 bfield_str="Double Slot (800 bit data, 4 bit xcrc)";
1301                 break;
1302         case 4:
1303                 blen=10;
1304                 xcrclen=4;
1305
1306                 bfield_short_str="Half Slot";
1307                 bfield_str="Half Slot (80 bit data, 4 bit xcrc)";
1308                 break;
1309         case 7:
1310         default:
1311                 blen=0;
1312                 xcrclen=0;
1313
1314                 bfield_short_str="No B-Field";
1315                 bfield_str="No B-Field";
1316                 break;
1317         }
1318
1319         proto_tree_add_string(ColumnsTree, hf_dect_cc_BField, tvb, offset, 1, bfield_short_str);
1320
1321         if(blen)
1322         {
1323                 bfieldti                = proto_tree_add_item(DectTree, hf_dect_B, tvb, offset, blen, FALSE);
1324                 BField                  = proto_item_add_subtree(bfieldti, ett_bfield);
1325
1326                 proto_tree_add_none_format(BField, hf_dect_B_Data, tvb, offset, blen, "%s", bfield_str);
1327
1328                 bfdescrdatati   = proto_tree_add_item(BField, hf_dect_B_DescrambledData, tvb, offset, blen, FALSE);
1329                 BFDescrData             = proto_item_add_subtree(bfdescrdatati, ett_bfdescrdata);
1330         }
1331
1332         start_offset=offset;
1333
1334         if(blen<=bfield_length)
1335         {
1336                 gint fn;
1337                 guint16 x, y;
1338                 for(fn=0;fn<8;fn++)
1339                 {
1340                         guint16 bytecount=0;
1341
1342                         offset=start_offset;
1343
1344                         proto_tree_add_none_format(BFDescrData, hf_dect_B_fn, tvb, offset, 0, "Framenumber %u/%u", fn, fn+8);
1345                         for(x=0;x<blen;x+=16)
1346                         {
1347                                 /*
1348                                  * XXX - should this just be an FTYPE_BYTES
1349                                  * field, and possibly just displayed as
1350                                  * "Data: N bytes" rather than giving all
1351                                  * the bytes of data?
1352                                  *
1353                                  * No, it gives you the bytes in descrambled
1354                                  * form depending on the framenumber. Sometimes,
1355                                  * you doesn't know the real framenumber, so you need
1356                                  * the range of all possible descramblings. (a.schuler)
1357                                  */
1358                                 emem_strbuf_t *string;
1359                                 string = ep_strbuf_new(NULL);
1360                                 for(y=0;y<16;y++)
1361                                 {
1362                                         if((x+y)>=blen)
1363                                                 break;
1364
1365                                         ep_strbuf_append_printf(string,"%.2x ", bfield_data[x+y]^scrt[fn][bytecount%31]);
1366                                         bytecount++;
1367                                 }
1368                                 proto_tree_add_none_format(BFDescrData, hf_dect_B_Data, tvb, offset, y, "Data: %s", string->str);
1369                                 offset+=y;
1370                         }
1371                 }
1372         }
1373         else
1374                 proto_tree_add_none_format(BField, hf_dect_B_Data, tvb, offset, 0, "Data too Short");
1375
1376         if(blen==40)
1377                 xcrc=calc_xcrc(bfield_data, 83);
1378         else
1379                 xcrc=0;
1380
1381         if((unsigned)(blen+1)<=bfield_length)
1382         {
1383                 if(xcrc!=(bfield_data[40]&0xf0))
1384                         /* XXX: pkt_bfield->Data[40]&0xf0 isn't really the Recv value?? */
1385                         proto_tree_add_uint_format(bfieldti, hf_dect_B_XCRC, tvb, offset, 1, 0, "X-CRC Error (Calc:%.2x, Recv:%.2x)",xcrc, bfield_data[40]&0xf0);
1386                 else
1387                         /* XXX: pkt_bfield->Data[40]&0xf0 isn't really the Recv value?? */
1388                         proto_tree_add_uint_format(bfieldti, hf_dect_B_XCRC, tvb, offset, 1, 1, "X-CRC Match (Calc:%.2x, Recv:%.2x)", xcrc, bfield_data[40]&0xf0);
1389         }
1390         else
1391                 proto_tree_add_uint_format(bfieldti, hf_dect_B_XCRC, tvb, offset, 1, 0, "No X-CRC logged (Calc:%.2x)", xcrc);
1392
1393         return offset;
1394 }
1395
1396 /* ETSI EN 300 175-3 V2.3.0  6.2.1.2 */
1397 static void
1398 dissect_afield(gboolean dect_packet_type, guint8 *ba,
1399         packet_info *pinfo _U_, tvbuff_t *tvb, gint offset, proto_tree *DectTree, proto_tree *ColumnsTree)
1400 {
1401         guint8 ta;
1402         guint8 rcrcdat[8];
1403         guint16 computed_rcrc;
1404         emem_strbuf_t *afield_str;
1405
1406         proto_item *afieldti    = NULL;
1407         proto_item *aheadti     = NULL;
1408         proto_item *atailti     = NULL;
1409         proto_tree *AField      = NULL;
1410         proto_tree *AHead       = NULL;
1411         proto_tree *ATail       = NULL;
1412
1413         guint8  header, tail_0, tail_1, tail_2, tail_3, tail_4;
1414         guint16 rcrc;
1415
1416         afield_str = ep_strbuf_new(NULL);
1417
1418         /************************** A-Field ***********************************/
1419
1420         /* ETSI EN 300 175-3 V2.3.0  7.1.1, 7.2.1
1421          *
1422          *  |   TA   |Q1|   BA   |Q2|        Tail       |    R-CRC    |
1423          *  +-----------------------+--------/ /--------+-------------+
1424          *  |a0 a1 a2 a3 a4 a5 a6 a7|a8  |    |    | a47|a48   |   a63|
1425          */
1426
1427         /* A-Field */
1428         header = tvb_get_guint8(tvb, offset+0);
1429         tail_0 = tvb_get_guint8(tvb, offset+1);
1430         tail_1 = tvb_get_guint8(tvb, offset+2);
1431         tail_2 = tvb_get_guint8(tvb, offset+3);
1432         tail_3 = tvb_get_guint8(tvb, offset+4);
1433         tail_4 = tvb_get_guint8(tvb, offset+5);
1434         rcrc = tvb_get_ntohs(tvb, offset+6);
1435
1436         ta = (header & DECT_A_TA_MASK) >> DECT_A_TA_SHIFT;
1437         *ba = (header & DECT_A_BA_MASK) >> DECT_A_BA_SHIFT;
1438
1439         afieldti        = proto_tree_add_item(DectTree, hf_dect_A, tvb, offset, DECT_AFIELD_SIZE, FALSE);
1440         AField          = proto_item_add_subtree(afieldti, ett_afield);
1441
1442         /* Header */
1443         aheadti         = proto_tree_add_item(afieldti, hf_dect_A_Head, tvb, offset, 1, FALSE);
1444         AHead           = proto_item_add_subtree(aheadti, ett_ahead);
1445
1446         if(dect_packet_type==DECT_PACKET_FP)
1447                 proto_tree_add_item(AHead, hf_dect_A_Head_TA_FP, tvb, offset, 1, FALSE);
1448         else
1449                 proto_tree_add_item(AHead, hf_dect_A_Head_TA_PP, tvb, offset, 1, FALSE);
1450
1451         proto_tree_add_item(AHead, hf_dect_A_Head_Q1, tvb, offset, 1, FALSE);
1452         proto_tree_add_item(AHead, hf_dect_A_Head_BA, tvb, offset, 1, FALSE);
1453         proto_tree_add_item(AHead, hf_dect_A_Head_Q2, tvb, offset, 1, FALSE);
1454         offset++;
1455
1456         /* Tail */
1457         if(dect_packet_type==DECT_PACKET_FP)
1458         {
1459                 atailti = proto_tree_add_none_format(afieldti, hf_dect_A_Tail, tvb, offset, 5, 
1460                         "FP-Tail: %s", val_to_str(ta, TA_vals_FP, "Error, please report: %d"));
1461         }
1462         else
1463         {
1464                 atailti = proto_tree_add_none_format(afieldti, hf_dect_A_Tail, tvb, offset, 5, 
1465                         "PP-Tail: %s", val_to_str(ta, TA_vals_PP, "Error, please report: %d"));
1466         }
1467
1468         ATail = proto_item_add_subtree(atailti, ett_atail);
1469
1470         if((ta==DECT_TA_CT0)||(ta==DECT_TA_CT1))
1471         {
1472                 /* ETSI EN 300 175-3 V2.3.0  10.8.1.1.1 */
1473                 proto_tree_add_string(ColumnsTree, hf_dect_cc_TA, tvb, offset, 1, "[Ct]");
1474
1475                 if(ta==DECT_TA_CT0)
1476                         ep_strbuf_append_printf(afield_str,"C-Channel Next  Data: %s",tvb_bytes_to_str(tvb, offset, 5));
1477                 else
1478                         ep_strbuf_append_printf(afield_str,"C-Channel First Data: %s",tvb_bytes_to_str(tvb, offset, 5));
1479
1480                 proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, afield_str->str);
1481         }
1482         else if((ta==DECT_TA_NT)||(ta==DECT_TA_NT_CL))
1483         {
1484                 /* ETSI EN 300 175-3 V2.3.0  7.2.2 */
1485                 proto_tree_add_string(ColumnsTree, hf_dect_cc_TA, tvb, offset, 1, "[Nt]");
1486
1487                 ep_strbuf_append_printf(afield_str,"RFPI: %s",tvb_bytes_to_str(tvb, offset, 5));
1488                 proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, afield_str->str);
1489
1490                 proto_tree_add_item(atailti, hf_dect_A_Tail_Nt, tvb, offset, 5, FALSE);
1491         }
1492         else if(ta==DECT_TA_QT)
1493         {
1494                 /* ETSI EN 300 175-3 V2.3.0  7.2.3 */
1495                 proto_tree_add_string(ColumnsTree, hf_dect_cc_TA, tvb, offset, 1, "[Qt]");
1496
1497                 proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_Qh, tvb, offset, 1, FALSE);
1498
1499                 switch(tail_0>>4)
1500                 {
1501                 case 0:         /* Static System Info */
1502                 case 1:
1503                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.2 */
1504                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Static System Info");
1505
1506                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Nr, tvb, offset, 1, FALSE);
1507                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Sn, tvb, offset, 1, FALSE);
1508                         offset++;
1509
1510                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Sp, tvb, offset, 1, FALSE);
1511                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Esc, tvb, offset, 1, FALSE);
1512                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Txs, tvb, offset, 1, FALSE);
1513                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Mc, tvb, offset, 1, FALSE);
1514
1515                         proto_tree_add_none_format(ATail, hf_dect_A_Tail_Qt_0_CA, tvb, offset, 2, " Carrier%s%s%s%s%s%s%s%s%s%s available",
1516                                 (tail_1&0x02)?" 0":"", (tail_1&0x01)?" 1":"", (tail_2&0x80)?" 2":"",
1517                                 (tail_2&0x40)?" 3":"", (tail_2&0x20)?" 4":"", (tail_2&0x10)?" 5":"",
1518                                 (tail_2&0x08)?" 6":"", (tail_2&0x04)?" 7":"", (tail_2&0x02)?" 8":"",
1519                                 (tail_2&0x01)?" 9":"");
1520                         offset+=2;
1521
1522                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Spr1, tvb, offset, 1, FALSE);
1523                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Cn, tvb, offset, 1, FALSE);
1524                         offset++;
1525
1526                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_Spr2, tvb, offset, 1, FALSE);
1527                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_0_PSCN, tvb, offset, 1, FALSE);
1528                         offset++;
1529                         /* due to addition further down */
1530                         offset-=5;
1531                         break;
1532                 case 2:         /* Extended RF Carriers Part 1 */
1533                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.3 */
1534                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Extended RF Carriers Part 1");
1535                         /* TODO */
1536                         break;
1537                 case 3:         /* Fixed Part Capabilities */
1538                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.4 */
1539                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Fixed Part Capabilities");
1540
1541                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A12, tvb, offset, 1, FALSE);
1542                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A13, tvb, offset, 1, FALSE);
1543                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A14, tvb, offset, 1, FALSE);
1544                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A15, tvb, offset, 1, FALSE);
1545                         offset++;
1546
1547                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A16, tvb, offset, 1, FALSE);
1548                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A17, tvb, offset, 1, FALSE);
1549                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A18, tvb, offset, 1, FALSE);
1550                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A19, tvb, offset, 1, FALSE);
1551                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A20, tvb, offset, 1, FALSE);
1552                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A21, tvb, offset, 1, FALSE);
1553                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A22, tvb, offset, 1, FALSE);
1554                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A23, tvb, offset, 1, FALSE);
1555                         offset++;
1556
1557                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A24, tvb, offset, 1, FALSE);
1558                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A25, tvb, offset, 1, FALSE);
1559                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A26, tvb, offset, 1, FALSE);
1560                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A27, tvb, offset, 1, FALSE);
1561                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A28, tvb, offset, 1, FALSE);
1562                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A29, tvb, offset, 1, FALSE);
1563                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A30, tvb, offset, 1, FALSE);
1564                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A31, tvb, offset, 1, FALSE);
1565                         offset++;
1566
1567
1568                         /* higher layer capabilities */
1569                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A32, tvb, offset, 1, FALSE);
1570                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A33, tvb, offset, 1, FALSE);
1571                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A34, tvb, offset, 1, FALSE);
1572                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A35, tvb, offset, 1, FALSE);
1573                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A36, tvb, offset, 1, FALSE);
1574                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A37, tvb, offset, 1, FALSE);
1575                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A38, tvb, offset, 1, FALSE);
1576                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A39, tvb, offset, 1, FALSE);
1577                         offset++;
1578
1579                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A40, tvb, offset, 1, FALSE);
1580                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A41, tvb, offset, 1, FALSE);
1581                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A42, tvb, offset, 1, FALSE);
1582                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A43, tvb, offset, 1, FALSE);
1583                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A44, tvb, offset, 1, FALSE);
1584                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A45, tvb, offset, 1, FALSE);
1585                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A46, tvb, offset, 1, FALSE);
1586                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_3_A47, tvb, offset, 1, FALSE);
1587                         offset++;
1588
1589                         /* due to addition further down */
1590                         offset-=5;
1591                         break;
1592                 case 4:         /* Extended Fixed Part Capabilities */
1593                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.5 */
1594                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Extended Fixed Part Capabilities");
1595
1596
1597                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_CRFPHops, tvb, offset, 1, FALSE);
1598                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_CRFPEnc, tvb, offset, 1, FALSE);
1599                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_REFHops, tvb, offset, 2, FALSE);
1600                         offset++;
1601
1602                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_REPCap, tvb, offset, 1, FALSE);
1603                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_Sync, tvb, offset, 1, FALSE);
1604                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A20, tvb, offset, 1, FALSE);
1605                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_MACSusp, tvb, offset, 1, FALSE);
1606                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_MACIpq, tvb, offset, 1, FALSE);
1607                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A23, tvb, offset, 1, FALSE);
1608                         offset++;
1609
1610
1611                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A24, tvb, offset, 1, FALSE);
1612
1613                         /* higher layer capabilities */
1614                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A25, tvb, offset, 1, FALSE);
1615                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A26, tvb, offset, 1, FALSE);
1616                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A27, tvb, offset, 1, FALSE);
1617                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A28, tvb, offset, 1, FALSE);
1618                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A29, tvb, offset, 1, FALSE);
1619                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A30, tvb, offset, 1, FALSE);
1620                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A31, tvb, offset, 1, FALSE);
1621                         offset++;
1622
1623
1624                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A32, tvb, offset, 1, FALSE);
1625                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A33, tvb, offset, 1, FALSE);
1626                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A34, tvb, offset, 1, FALSE);
1627                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A35, tvb, offset, 1, FALSE);
1628                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A36, tvb, offset, 1, FALSE);
1629                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A37, tvb, offset, 1, FALSE);
1630                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A38, tvb, offset, 1, FALSE);
1631                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A39, tvb, offset, 1, FALSE);
1632                         offset++;
1633
1634                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A40, tvb, offset, 1, FALSE);
1635                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A41, tvb, offset, 1, FALSE);
1636                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A42, tvb, offset, 1, FALSE);
1637                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A43, tvb, offset, 1, FALSE);
1638                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A44, tvb, offset, 1, FALSE);
1639                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A45, tvb, offset, 1, FALSE);
1640                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A46, tvb, offset, 1, FALSE);
1641                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_4_A47, tvb, offset, 1, FALSE);
1642                         offset++;
1643
1644                         /* due to addition further down */
1645                         offset-=5;
1646                         break;
1647                 case 5:         /* SARI List Contents */
1648                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.6 */
1649                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "SARI List Contents");
1650                         /* TODO */
1651                         break;
1652                 case 6:         /* Multi-Frame No */
1653                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.7  */
1654                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_6_Spare, tvb, offset, 2, FALSE);
1655                         offset+=2;
1656
1657                         ep_strbuf_append_printf(afield_str,"Multi-Frame No.: %s",tvb_bytes_to_str(tvb, offset, 3));
1658                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, afield_str->str);
1659
1660                         proto_tree_add_item(ATail, hf_dect_A_Tail_Qt_6_Mfn, tvb, offset, 3, FALSE);
1661                         offset+=3;
1662
1663                         /* due to addition further down */
1664                         offset-=5;
1665                         break;
1666                 case 7:         /* Escape */
1667                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.8 */
1668                         ep_strbuf_append_printf(afield_str,"Escape Data: %s",tvb_bytes_to_str(tvb, offset, 5));
1669                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, afield_str->str);
1670                         break;
1671                 case 8:         /* Obsolete */
1672                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.1 */
1673                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Obsolete");
1674                         break;
1675                 case 9:         /* Extended RF Carriers Part 2 */
1676                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.9 */
1677                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Extended RF Carriers Part 2");
1678                         /* TODO */
1679                         break;
1680                 case 11:        /* Transmit Information */
1681                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.10 */
1682                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Transmit Information");
1683                         /* TODO */
1684                         break;
1685                 case 12:        /* Extended Fixed Part Capabilities 2 */
1686                         /* ETSI EN 300 175-3 V2.3.0  7.2.3.11 */
1687                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Extended Fixed Part Capabilities 2");
1688                         /* TODO */
1689                         break;
1690                 case 10:        /* Reserved */
1691                 case 13:
1692                 case 14:
1693                 case 15:
1694                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Reserved");
1695                         break;
1696                 }
1697         }
1698         else if(ta==DECT_TA_ESC)
1699         {
1700                 /* ETSI EN 300 175-3 V2.3.0  7.2.3.8 */
1701                 /* Provide hook for escape message dissector */
1702         }
1703         else if((ta==DECT_TA_MT)||((ta==DECT_TA_MT_FIRST)&&(dect_packet_type==DECT_PACKET_PP)))
1704         {
1705                 /* ETSI EN 300 175-3 V2.3.0  7.2.5 */
1706                 proto_tree_add_string(ColumnsTree, hf_dect_cc_TA, tvb, offset, 1, "[Mt]");
1707
1708                 proto_tree_add_uint(ATail, hf_dect_A_Tail_Mt_Mh, tvb, offset, 1, tail_0);
1709
1710                 switch(tail_0>>4)
1711                 {
1712                 case 0:         /* Basic Connection Control */
1713                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.2 */
1714                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Basic Connection Control");
1715                         proto_tree_add_item(ATail, hf_dect_A_Tail_Mt_BasicConCtrl, tvb, offset, 1, FALSE);
1716                         offset++;
1717
1718                         if(((tail_0 & 0x0f)==6)||((tail_0 & 0x0f)==7))
1719                         {
1720                                 /* TODO See ETSI EN 300 175-3 V2.3.0  7.2.5.2.4 */
1721                                 proto_tree_add_none_format(ATail, hf_dect_A_Tail_Mt_Mh_attr, tvb, offset, 4, "More infos at ETSI EN 300 175-3 V2.3.0  7.2.5.2.4");
1722                                 offset +=4;
1723                         }
1724                         else
1725                         {
1726                                 proto_tree_add_item(ATail, hf_dect_A_Tail_Mt_Mh_fmid, tvb, offset, 2, FALSE);
1727                                 offset++;
1728
1729                                 proto_tree_add_item(ATail, hf_dect_A_Tail_Mt_Mh_pmid, tvb, offset, 3, FALSE);
1730                                 offset+=3;
1731                         }
1732
1733                         /* due to addition further down */
1734                         offset-=5;
1735                         break;
1736                 case 1:         /* Advanced Connection Control */
1737                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.3 */
1738                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Advanced Connection Control");
1739                         break;
1740                 case 2:         /* MAC Layer Test Messages */
1741                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.4 */
1742                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "MAC Layer Test Messages");
1743                         break;
1744                 case 3:         /* Quality Control */
1745                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.5 */
1746                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Quality Control");
1747                         break;
1748                 case 4:         /* Broadcast and Connectionless Services */
1749                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.6 */
1750                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Broadcast and Connectionless Services");
1751                         break;
1752                 case 5:         /* Encryption Control */
1753                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.7 */
1754                         ep_strbuf_append_printf(afield_str,"Encryption Control: %s %s",
1755                                 val_to_str((tail_0&0x0c)>>2, MTEncrCmd1_vals, "Error, please report: %d"),
1756                                 val_to_str(tail_0&0x03, MTEncrCmd2_vals, "Error, please report: %d"));
1757
1758                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, afield_str->str);
1759
1760                         proto_tree_add_item(ATail, hf_dect_A_Tail_Mt_Encr_Cmd1, tvb, offset, 1, FALSE);
1761                         proto_tree_add_item(ATail, hf_dect_A_Tail_Mt_Encr_Cmd2, tvb, offset, 1, FALSE);
1762                         offset++;
1763
1764                         proto_tree_add_item(ATail, hf_dect_A_Tail_Mt_Mh_fmid, tvb, offset, 2, FALSE);
1765                         offset++;
1766
1767                         proto_tree_add_item(ATail, hf_dect_A_Tail_Mt_Mh_pmid, tvb, offset, 3, FALSE);
1768                         offset+=3;
1769
1770                         /* due to addition further down */
1771                         offset-=5;
1772                         break;
1773                 case 6:         /* Tail for use with the first Transmission of a B-Field \"bearer request\" Message */
1774                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.8 */
1775                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Tail for use with the first Transmission of a B-Field \"bearer request\" Message");
1776                         break;
1777                 case 7:         /* Escape */
1778                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.9 */
1779                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Escape");
1780                         break;
1781                 case 8:         /* TARI Message */
1782                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.10 */
1783                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "TARI Message");
1784                         break;
1785                 case 9:         /* REP Connection Control */
1786                         /* ETSI EN 300 175-3 V2.3.0  7.2.5.11 */
1787                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "REP Connection Control");
1788                         break;
1789                 case 10:        /* Reserved */
1790                 case 11:
1791                 case 12:
1792                 case 13:
1793                 case 14:
1794                 case 15:
1795                         proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, "Reserved");
1796                         break;
1797                 }
1798         }
1799         else if((ta==DECT_TA_PT)&&(dect_packet_type==DECT_PACKET_FP))
1800         {
1801                 /* ETSI EN 300 175-3 V2.3.0  7.2.4 */
1802                 proto_tree_add_string(ColumnsTree, hf_dect_cc_TA, tvb, offset, 1, "[Pt]");
1803
1804                 proto_tree_add_item(ATail, hf_dect_A_Tail_Pt_ExtFlag, tvb, offset, 1, FALSE);
1805                 proto_tree_add_item(ATail, hf_dect_A_Tail_Pt_SDU, tvb, offset, 1, FALSE);
1806
1807                 if(((tail_0&0x70)>>4)&0xfe)
1808                         ep_strbuf_append_printf(afield_str,"%s, ",val_to_str((tail_0&0x70)>>4, PTSDU_vals, "Error, please report: %d"));
1809         
1810                 switch((tail_0&0x70)>>4)
1811                 {
1812                 case 0:         /* Zero Length Page */
1813                 case 1:         /* Short Page */
1814                         if(((tail_0&0x70)>>4)==0)
1815                         {
1816                                 ep_strbuf_append_printf(afield_str,"RFPI: xxxxx%.1x%.2x%.2x, ", (tail_0&0x0f), tail_1, tail_2);
1817                                 proto_tree_add_none_format(atailti, hf_dect_A_Tail_Pt_RFPI, tvb, offset, 3, "RFPI: xxxxx%.1x%.2x%.2x", (tail_0&0x0f), tail_1, tail_2);
1818                                 offset+=3;
1819
1820                                 proto_tree_add_item(ATail, hf_dect_A_Tail_Pt_InfoType, tvb, offset, 1, FALSE);
1821                         }
1822                         else
1823                         {
1824                                 ep_strbuf_append_printf(afield_str,"Bs Data: %.1x%.2x%.2x, ", (tail_0&0x0f), tail_1, tail_2);
1825                                 proto_tree_add_none_format(atailti, hf_dect_A_Tail_Pt_BsData, tvb, offset, 3, "Bs Data: %.1x%.2x%.2x", (tail_0&0x0f), tail_1, tail_2);
1826                                 offset+=3;
1827
1828                                 proto_tree_add_item(ATail, hf_dect_A_Tail_Pt_InfoType, tvb, offset, 1, FALSE);
1829                         }
1830
1831                         ep_strbuf_append_printf(afield_str,"%s",val_to_str(tail_3>>4, PTInfoType_vals, "Error, please report: %d"));
1832
1833                         switch(tail_3>>4)
1834                         {
1835                         case 0: /* Fill Bits */
1836                                 proto_tree_add_none_format(ATail, hf_dect_A_Tail_Pt_Fillbits, tvb, offset, 2, "Fillbits: %.1x%.2x", tail_3&0x0f, tail_4);
1837                                 offset+=2;
1838                                 break;
1839                         case 1: /* Blind Full Slot Information for Circuit Mode Service */
1840                                 offset+=2;
1841                                 break;
1842                         case 7: /* Escape */
1843                                 offset+=2;
1844                                 break;
1845                         case 8: /* Dummy or connectionless Bearer Marker */
1846                                 proto_tree_add_none_format(ATail, hf_dect_A_Tail_Pt_SlotPairs, tvb, offset, 2, " Slot-Pairs: %s%s%s%s%s%s%s%s%s%s%s%s available",
1847                                         (tail_3&0x08)?" 0/12":"", (tail_3&0x04)?" 1/13":"", (tail_3&0x02)?" 2/14":"",
1848                                         (tail_3&0x01)?" 3/15":"", (tail_4&0x80)?" 4/16":"", (tail_4&0x40)?" 5/17":"",
1849                                         (tail_4&0x20)?" 6/18":"", (tail_4&0x10)?" 7/19":"", (tail_4&0x08)?" 8/20":"",
1850                                         (tail_4&0x04)?" 9/21":"", (tail_4&0x02)?" 10/22":"", (tail_4&0x01)?" 11/23":"");
1851
1852                                 offset+=2;
1853                                 break;
1854                         case 2: /* Other Bearer */
1855                         case 3: /* Recommended Other Bearer */
1856                         case 4: /* Good RFP Bearer */
1857                         case 5: /* Dummy or connectionless Bearer Position */
1858                         case 12: /* Connectionless Bearer Position */
1859                                 proto_tree_add_item(ATail, hf_dect_A_Tail_Pt_Bearer_Sn, tvb, offset, 1, FALSE);
1860                                 offset++;
1861
1862                                 proto_tree_add_item(ATail, hf_dect_A_Tail_Pt_Bearer_Sp, tvb, offset, 1, FALSE);
1863                                 proto_tree_add_item(ATail, hf_dect_A_Tail_Pt_Bearer_Cn, tvb, offset, 1, FALSE);
1864                                 offset++;
1865                                 break;
1866                         case 6: /* Extended Modulation Types */
1867                                 offset+=2;
1868                                 break;
1869                         case 9: /* Bearer Handover/Replacement Information */
1870                                 offset+=2;
1871                                 break;
1872                         case 10: /* RFP Status and Modulation Types */
1873                                 offset+=2;
1874                                 break;
1875                         case 11: /* Active Carriers */
1876                                 offset+=2;
1877                                 break;
1878                         case 13: /* RFP Power Level */
1879                                 offset+=2;
1880                                 break;
1881                         case 14: /* Blind Double Slot/RFP-FP Interface Resource Information */
1882                                 offset+=2;
1883                                 break;
1884                         case 15: /* Blind Full Slot Information for Packet Mode Service */
1885                                 offset+=2;
1886                                 break;
1887                         }
1888                         /* due to addition further down */
1889                         offset-=5;
1890                         break;
1891                 case 2:         /* Full Page */
1892                         ep_strbuf_append_printf(afield_str,"Full Page");
1893                         break;
1894                 case 3:         /* MAC Resume Page */
1895                         ep_strbuf_append_printf(afield_str,"MAC Resume Page");
1896                         break;
1897                 case 4:         /* Not the Last 36 Bits of a Long Page */
1898                         ep_strbuf_append_printf(afield_str,"Not the Last 36 Bits");
1899                         break;
1900                 case 5:         /* The First 36 Bits of a Long Page */
1901                         ep_strbuf_append_printf(afield_str,"The First 36 Bits");
1902                         break;
1903                 case 6:         /* The Last 36 Bits of a Long Page */
1904                         ep_strbuf_append_printf(afield_str,"The Last 36 Bits");
1905                         break;
1906                 case 7:         /* All of a Long Page */
1907                         ep_strbuf_append_printf(afield_str,"All of a Long Page");
1908                         break;
1909                 }
1910
1911                 proto_tree_add_string(ColumnsTree, hf_dect_cc_AField, tvb, offset, 1, afield_str->str);
1912         }
1913
1914         offset+=5;
1915
1916         /* R-CRC */
1917         /* ETSI EN 300 175-3 V2.3.0  6.2.5.1 */
1918         tvb_memcpy(tvb, rcrcdat, DECT_PACKET_INFO_LEN, 6);
1919         rcrcdat[6]=0;
1920         rcrcdat[7]=0;
1921         computed_rcrc=calc_rcrc(rcrcdat);
1922         if(computed_rcrc!=rcrc)
1923                 proto_tree_add_uint_format(afieldti, hf_dect_A_RCRC, tvb, offset, 2, 0, "R-CRC Error (Calc:%.4x, Recv:%.4x)", computed_rcrc, rcrc);
1924         else
1925                 proto_tree_add_uint_format(afieldti, hf_dect_A_RCRC, tvb, offset, 2, 1, "R-CRC Match (Calc:%.4x, Recv:%.4x)", computed_rcrc, rcrc);
1926
1927         offset+=2;
1928 }
1929
1930 static void
1931 dissect_dect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1932 {
1933         proto_item *ti          =NULL;
1934         proto_item *typeti      =NULL;
1935         proto_tree *DectTree    =NULL;
1936         gint offset             =0;
1937
1938         guint16                 type;
1939         guint                   pkt_len;
1940         guint8                  ba;
1941
1942         /************************** Custom Columns ****************************/
1943         proto_item *columnstreeti;
1944         proto_tree *ColumnsTree;
1945
1946         col_clear(pinfo->cinfo, COL_INFO);
1947         col_append_fstr(pinfo->cinfo, COL_INFO, "Use Custom Columns for Infos");
1948
1949         col_set_str(pinfo->cinfo, COL_PROTOCOL, "DECT");
1950
1951         pkt_len=tvb_length(tvb);
1952
1953         if(pkt_len<=DECT_PACKET_INFO_LEN)
1954         {
1955                 col_set_str(pinfo->cinfo, COL_INFO, "No Data");
1956                 return;
1957         }
1958
1959         ti=proto_tree_add_item(tree, proto_dect, tvb, 0, -1, FALSE);
1960         DectTree=proto_item_add_subtree(ti, ett_dect);
1961
1962         proto_tree_add_item(DectTree, hf_dect_transceivermode, tvb, offset, 1, FALSE);
1963         offset++;
1964
1965         proto_tree_add_item(DectTree, hf_dect_channel, tvb, offset, 1, FALSE);
1966         offset++;
1967
1968         proto_tree_add_item(DectTree, hf_dect_slot, tvb, offset, 2, FALSE);
1969         offset+=2;
1970
1971         proto_tree_add_item(DectTree, hf_dect_framenumber, tvb, offset, 1, FALSE);
1972         offset++;
1973
1974         proto_tree_add_item(DectTree, hf_dect_rssi, tvb, offset, 1, FALSE);
1975         offset++;
1976
1977         proto_tree_add_item(DectTree, hf_dect_preamble, tvb, offset, 3, FALSE);
1978         offset+=3;
1979
1980         typeti=proto_tree_add_item(DectTree, hf_dect_type, tvb, offset, 2, FALSE);
1981
1982         type=tvb_get_ntohs(tvb, offset);
1983         offset+=2;
1984
1985         columnstreeti = proto_tree_add_item(DectTree, hf_dect_cc, tvb, 0, 0, FALSE);
1986         ColumnsTree   = proto_item_add_subtree(columnstreeti, ett_afield);
1987
1988         switch(type) {
1989         case 0x1675:
1990                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DECT PP");
1991                 proto_item_append_text(typeti, " Phone Packet");
1992                 dissect_afield(DECT_PACKET_PP, &ba, pinfo, tvb, offset, DectTree, ColumnsTree);
1993                 offset += DECT_AFIELD_SIZE;
1994                 dissect_bfield(DECT_PACKET_PP, ba, pinfo, tvb, offset, DectTree, ColumnsTree);
1995                 break;
1996         case 0xe98a:
1997                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DECT RFP");
1998                 proto_item_append_text(typeti, " Station Packet");
1999                 dissect_afield(DECT_PACKET_FP, &ba, pinfo, tvb, offset, DectTree, ColumnsTree);
2000                 offset += DECT_AFIELD_SIZE;
2001                 dissect_bfield(DECT_PACKET_FP, ba, pinfo, tvb, offset, DectTree, ColumnsTree);
2002                 break;
2003         default:
2004                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DECT Unk");
2005                 proto_item_append_text(typeti, " Unknown Packet");
2006                 break;
2007         }
2008 }
2009
2010 void
2011 proto_register_dect(void)
2012 {
2013         static hf_register_info hf[]=
2014         {
2015                 { &hf_dect_transceivermode,
2016                 {"Tranceiver-Mode", "dect.tranceivermode", FT_UINT8, BASE_HEX, VALS(tranceiver_mode),
2017                         0x0, NULL, HFILL}},
2018
2019                 { &hf_dect_channel,
2020                 {"Channel", "dect.channel", FT_UINT8, BASE_DEC, NULL,
2021                         0x0, NULL, HFILL}},
2022
2023                 { &hf_dect_framenumber,
2024                 {"Frame#", "dect.framenumber", FT_UINT16, BASE_DEC, NULL,
2025                         0x0, NULL, HFILL}},
2026
2027                 { &hf_dect_rssi,
2028                 {"RSSI", "dect.rssi", FT_UINT8, BASE_DEC, NULL,
2029                         0x0, NULL, HFILL}},
2030
2031                 { &hf_dect_slot,
2032                 {"Slot", "dect.slot", FT_UINT16, BASE_DEC, NULL,
2033                         0x0, NULL, HFILL}},
2034
2035                 { &hf_dect_preamble,
2036                 {"Preamble", "dect.preamble", FT_BYTES, BASE_NONE, NULL,
2037                         0x0, NULL, HFILL}},
2038
2039                 { &hf_dect_type,
2040                 {"Packet-Type", "dect.type", FT_BYTES, BASE_NONE, NULL,
2041                         0x0, NULL, HFILL}},
2042
2043
2044         /* **************** Custom Columns ***********************/
2045
2046                 { &hf_dect_cc,
2047                 {"Columns", "dect.cc", FT_NONE, BASE_NONE, NULL,
2048                         0x0, NULL, HFILL}},
2049
2050                 { &hf_dect_cc_TA,
2051                 {"TA", "dect.cc.TA", FT_STRING, BASE_NONE, NULL,
2052                         0x0, NULL, HFILL}},
2053
2054                 { &hf_dect_cc_AField,
2055                 {"A-Field", "dect.cc.afield", FT_STRING, BASE_NONE, NULL,
2056                         0x0, NULL, HFILL}},
2057
2058                 { &hf_dect_cc_BField,
2059                 {"B-Field", "dect.cc.bfield", FT_STRING, BASE_NONE, NULL,
2060                         0x0, NULL, HFILL}},
2061
2062         /* **************** A-Field ******************************/
2063         /* ***** Header ***** */
2064                 { &hf_dect_A,
2065                 {"A-Field", "dect.afield", FT_BYTES, BASE_NONE, NULL,
2066                         0x0, NULL, HFILL}},
2067
2068                 { &hf_dect_A_Head,
2069                 {"A-Field Header", "dect.afield.head", FT_UINT8, BASE_HEX, NULL,
2070                         0x0, NULL, HFILL}},
2071
2072                 { &hf_dect_A_Head_TA_FP,
2073                 {"TA", "dect.afield.head.TA", FT_UINT8, BASE_DEC, VALS(TA_vals_FP),
2074                         DECT_A_TA_MASK, NULL, HFILL}},
2075
2076                 { &hf_dect_A_Head_TA_PP,
2077                 {"TA", "dect.afield.head.TA", FT_UINT8, BASE_DEC, VALS(TA_vals_PP),
2078                         DECT_A_TA_MASK, NULL, HFILL}},
2079
2080                 { &hf_dect_A_Head_Q1,
2081                 {"Q1", "dect.afield.head.Q1", FT_UINT8, BASE_DEC, NULL,
2082                         DECT_A_Q1_MASK, NULL, HFILL}},
2083
2084                 { &hf_dect_A_Head_BA,
2085                 {"BA", "dect.afield.head.BA", FT_UINT8, BASE_DEC, VALS(BA_vals),
2086                         DECT_A_BA_MASK, NULL, HFILL}},
2087
2088                 { &hf_dect_A_Head_Q2,
2089                 {"Q2", "dect.afield.head.Q2", FT_UINT8, BASE_DEC, NULL,
2090                         DECT_A_Q2_MASK, NULL, HFILL}},
2091
2092         /* ***** Tail ***** */
2093                 { &hf_dect_A_Tail,
2094                 {"A-Field Tail", "dect.afield.tail", FT_NONE, BASE_NONE, NULL,
2095                         0x0, NULL, HFILL}},
2096
2097         /* Nt */
2098                 { &hf_dect_A_Tail_Nt,
2099                 {"RFPI", "dect.afield.tail.Nt", FT_BYTES, BASE_NONE, NULL,
2100                         0x0, "A-Field Tail: Nt/RFPI", HFILL}},
2101
2102         /* Qt */
2103                 { &hf_dect_A_Tail_Qt_Qh,
2104                 {"Qh", "dect.afield.tail.Qt.Qh", FT_UINT8, BASE_DEC, VALS(QTHead_vals),
2105                         0xF0, NULL, HFILL}},
2106
2107         /* Qt Static System Information */
2108         /* Byte 0 */
2109                 { &hf_dect_A_Tail_Qt_0_Nr,
2110                 {"NR", "dect.afield.tail.Qt.NR", FT_UINT8, BASE_DEC, VALS(QTNormalReverse_vals),
2111                         0x10, NULL, HFILL}},
2112
2113                 { &hf_dect_A_Tail_Qt_0_Sn,
2114                 {"SN", "dect.afield.tail.Qt.SN", FT_UINT8, BASE_DEC, VALS(QTSlotNumber_vals),
2115                         0x0F, NULL, HFILL}},
2116
2117         /* Byte 1 */
2118                 { &hf_dect_A_Tail_Qt_0_Sp,
2119                 {"SP", "dect.afield.tail.Qt.SP", FT_UINT8, BASE_DEC, VALS(QTStartPosition_vals),
2120                         0xC0, NULL, HFILL}},
2121
2122                 { &hf_dect_A_Tail_Qt_0_Esc,
2123                 {"Esc", "dect.afield.tail.Qt.Esc", FT_UINT8, BASE_DEC, VALS(QTEscape_vals),
2124                         0x20, NULL, HFILL}},
2125
2126                 { &hf_dect_A_Tail_Qt_0_Txs,
2127                 {"Txs", "dect.afield.tail.Qt.Txs", FT_UINT8, BASE_DEC, VALS(QTTranceiver_vals),
2128                         0x18, NULL, HFILL}},
2129
2130                 { &hf_dect_A_Tail_Qt_0_Mc,
2131                 {"Mc", "dect.afield.tail.Qt.Mc", FT_UINT8, BASE_DEC, VALS(QTExtendedCarrier_vals),
2132                         0x04, NULL, HFILL}},
2133
2134         /* Byte 2 */
2135                 { &hf_dect_A_Tail_Qt_0_CA,
2136                 {"CA", "dect.afield.tail.Qt.CA", FT_NONE, BASE_NONE, NULL,
2137                         0x0, NULL, HFILL}},
2138                         
2139         /* Byte 3 */
2140                 { &hf_dect_A_Tail_Qt_0_Spr1,
2141                 {"Spr1", "dect.afield.tail.Qt.Spr1", FT_UINT8, BASE_DEC, VALS(QTSpr_vals),
2142                         0xC0, NULL, HFILL}},
2143
2144                 { &hf_dect_A_Tail_Qt_0_Cn,
2145                 {"CN", "dect.afield.tail.Qt.CN", FT_UINT8, BASE_DEC, VALS(QTCarrierNumber_vals),
2146                         0x3F, NULL, HFILL}},
2147
2148         /* Byte 4 */
2149                 { &hf_dect_A_Tail_Qt_0_Spr2,
2150                 {"Spr2", "dect.afield.tail.Qt.Spr2", FT_UINT8, BASE_DEC, VALS(QTSpr_vals),
2151                         0xC0, NULL, HFILL}},
2152
2153                 { &hf_dect_A_Tail_Qt_0_PSCN,
2154                 {"PSCN", "dect.afield.tail.Qt.PSCN", FT_UINT8, BASE_DEC, VALS(QTScanCarrierNum_vals),
2155                         0x3F, NULL, HFILL}},
2156
2157         /* Qt Fixed Part Capabilities */
2158                 { &hf_dect_A_Tail_Qt_3_A12,
2159                 {"A12", "dect.afield.tail.Qt.Fp.A12", FT_UINT8, BASE_DEC, VALS(Qt_A12_vals),
2160                         0x08, NULL, HFILL}},
2161
2162                 { &hf_dect_A_Tail_Qt_3_A13,
2163                 {"A13", "dect.afield.tail.Qt.Fp.A13", FT_UINT8, BASE_DEC, VALS(Qt_A13_vals),
2164                         0x04, NULL, HFILL}},
2165
2166                 { &hf_dect_A_Tail_Qt_3_A14,
2167                 {"A14", "dect.afield.tail.Qt.Fp.A14", FT_UINT8, BASE_DEC, VALS(Qt_A14_vals),
2168                         0x02, NULL, HFILL}},
2169
2170                 { &hf_dect_A_Tail_Qt_3_A15,
2171                 {"A15", "dect.afield.tail.Qt.Fp.A15", FT_UINT8, BASE_DEC, VALS(Qt_A15_vals),
2172                         0x01, NULL, HFILL}},
2173
2174                 { &hf_dect_A_Tail_Qt_3_A16,
2175                 {"A16", "dect.afield.tail.Qt.Fp.A16", FT_UINT8, BASE_DEC, VALS(Qt_A16_vals),
2176                         0x80, NULL, HFILL}},
2177
2178                 { &hf_dect_A_Tail_Qt_3_A17,
2179                 {"A17", "dect.afield.tail.Qt.Fp.A17", FT_UINT8, BASE_DEC, VALS(Qt_A17_vals),
2180                         0x40, NULL, HFILL}},
2181
2182                 { &hf_dect_A_Tail_Qt_3_A18,
2183                 {"A18", "dect.afield.tail.Qt.Fp.A18", FT_UINT8, BASE_DEC, VALS(Qt_A18_vals),
2184                         0x20, NULL, HFILL}},
2185
2186                 { &hf_dect_A_Tail_Qt_3_A19,
2187                 {"A19", "dect.afield.tail.Qt.Fp.A19", FT_UINT8, BASE_DEC, VALS(Qt_A19_vals),
2188                         0x10, NULL, HFILL}},
2189
2190                 { &hf_dect_A_Tail_Qt_3_A20,
2191                 {"A20", "dect.afield.tail.Qt.Fp.A20", FT_UINT8, BASE_DEC, VALS(Qt_A20_vals),
2192                         0x08, NULL, HFILL}},
2193
2194                 { &hf_dect_A_Tail_Qt_3_A21,
2195                 {"A21", "dect.afield.tail.Qt.Fp.A21", FT_UINT8, BASE_DEC, VALS(Qt_A21_vals),
2196                         0x04, NULL, HFILL}},
2197
2198                 { &hf_dect_A_Tail_Qt_3_A22,
2199                 {"A22", "dect.afield.tail.Qt.Fp.A22", FT_UINT8, BASE_DEC, VALS(Qt_A22_vals),
2200                         0x02, NULL, HFILL}},
2201
2202                 { &hf_dect_A_Tail_Qt_3_A23,
2203                 {"A23", "dect.afield.tail.Qt.Fp.A23", FT_UINT8, BASE_DEC, VALS(Qt_A23_vals),
2204                         0x01, NULL, HFILL}},
2205
2206                 { &hf_dect_A_Tail_Qt_3_A24,
2207                 {"A24", "dect.afield.tail.Qt.Fp.A24", FT_UINT8, BASE_DEC, VALS(Qt_A24_vals),
2208                         0x80, NULL, HFILL}},
2209
2210                 { &hf_dect_A_Tail_Qt_3_A25,
2211                 {"A25", "dect.afield.tail.Qt.Fp.A25", FT_UINT8, BASE_DEC, VALS(Qt_A25_vals),
2212                         0x40, NULL, HFILL}},
2213
2214                 { &hf_dect_A_Tail_Qt_3_A26,
2215                 {"A26", "dect.afield.tail.Qt.Fp.A26", FT_UINT8, BASE_DEC, VALS(Qt_A26_vals),
2216                         0x20, NULL, HFILL}},
2217
2218                 { &hf_dect_A_Tail_Qt_3_A27,
2219                 {"A27", "dect.afield.tail.Qt.Fp.A27", FT_UINT8, BASE_DEC, VALS(Qt_A27_vals),
2220                         0x10, NULL, HFILL}},
2221
2222                 { &hf_dect_A_Tail_Qt_3_A28,
2223                 {"A28", "dect.afield.tail.Qt.Fp.A28", FT_UINT8, BASE_DEC, VALS(Qt_A28_vals),
2224                         0x08, NULL, HFILL}},
2225
2226                 { &hf_dect_A_Tail_Qt_3_A29,
2227                 {"A29", "dect.afield.tail.Qt.Fp.A29", FT_UINT8, BASE_DEC, VALS(Qt_A29_vals),
2228                         0x04, NULL, HFILL}},
2229
2230                 { &hf_dect_A_Tail_Qt_3_A30,
2231                 {"A30", "dect.afield.tail.Qt.Fp.A30", FT_UINT8, BASE_DEC, VALS(Qt_A30_vals),
2232                         0x02, NULL, HFILL}},
2233
2234                 { &hf_dect_A_Tail_Qt_3_A31,
2235                 {"A31", "dect.afield.tail.Qt.Fp.A31", FT_UINT8, BASE_DEC, VALS(Qt_A31_vals),
2236                         0x01, NULL, HFILL}},
2237
2238
2239                 /* higher layer capabilities */
2240                 { &hf_dect_A_Tail_Qt_3_A32,
2241                 {"A32", "dect.afield.tail.Qt.Fp.A32", FT_UINT8, BASE_DEC, VALS(Qt_A32_vals),
2242                         0x80, NULL, HFILL}},
2243
2244                 { &hf_dect_A_Tail_Qt_3_A33,
2245                 {"A33", "dect.afield.tail.Qt.Fp.A33", FT_UINT8, BASE_DEC, VALS(Qt_A33_vals),
2246                         0x40, NULL, HFILL}},
2247
2248                 { &hf_dect_A_Tail_Qt_3_A34,
2249                 {"A34", "dect.afield.tail.Qt.Fp.A34", FT_UINT8, BASE_DEC, VALS(Qt_A34_vals),
2250                         0x20, NULL, HFILL}},
2251
2252                 { &hf_dect_A_Tail_Qt_3_A35,
2253                 {"A35", "dect.afield.tail.Qt.Fp.A35", FT_UINT8, BASE_DEC, VALS(Qt_A35_vals),
2254                         0x10, NULL, HFILL}},
2255
2256                 { &hf_dect_A_Tail_Qt_3_A36,
2257                 {"A36", "dect.afield.tail.Qt.Fp.A36", FT_UINT8, BASE_DEC, VALS(Qt_A36_vals),
2258                         0x08, NULL, HFILL}},
2259
2260                 { &hf_dect_A_Tail_Qt_3_A37,
2261                 {"A37", "dect.afield.tail.Qt.Fp.A37", FT_UINT8, BASE_DEC, VALS(Qt_A37_vals),
2262                         0x04, NULL, HFILL}},
2263
2264                 { &hf_dect_A_Tail_Qt_3_A38,
2265                 {"A38", "dect.afield.tail.Qt.Fp.A38", FT_UINT8, BASE_DEC, VALS(Qt_A38_vals),
2266                         0x02, NULL, HFILL}},
2267
2268                 { &hf_dect_A_Tail_Qt_3_A39,
2269                 {"A39", "dect.afield.tail.Qt.Fp.A39", FT_UINT8, BASE_DEC, VALS(Qt_A39_vals),
2270                         0x01, NULL, HFILL}},
2271
2272                 { &hf_dect_A_Tail_Qt_3_A40,
2273                 {"A40", "dect.afield.tail.Qt.Fp.A40", FT_UINT8, BASE_DEC, VALS(Qt_A40_vals),
2274                         0x80, NULL, HFILL}},
2275
2276                 { &hf_dect_A_Tail_Qt_3_A41,
2277                 {"A41", "dect.afield.tail.Qt.Fp.A41", FT_UINT8, BASE_DEC, VALS(Qt_A41_vals),
2278                         0x40, NULL, HFILL}},
2279
2280                 { &hf_dect_A_Tail_Qt_3_A42,
2281                 {"A42", "dect.afield.tail.Qt.Fp.A42", FT_UINT8, BASE_DEC, VALS(Qt_A42_vals),
2282                         0x20, NULL, HFILL}},
2283
2284                 { &hf_dect_A_Tail_Qt_3_A43,
2285                 {"A43", "dect.afield.tail.Qt.Fp.A43", FT_UINT8, BASE_DEC, VALS(Qt_A43_vals),
2286                         0x10, NULL, HFILL}},
2287
2288                 { &hf_dect_A_Tail_Qt_3_A44,
2289                 {"A44", "dect.afield.tail.Qt.Fp.A44", FT_UINT8, BASE_DEC, VALS(Qt_A44_vals),
2290                         0x08, NULL, HFILL}},
2291
2292                 { &hf_dect_A_Tail_Qt_3_A45,
2293                 {"A45", "dect.afield.tail.Qt.Fp.A45", FT_UINT8, BASE_DEC, VALS(Qt_A45_vals),
2294                         0x04, NULL, HFILL}},
2295
2296                 { &hf_dect_A_Tail_Qt_3_A46,
2297                 {"A46", "dect.afield.tail.Qt.Fp.A46", FT_UINT8, BASE_DEC, VALS(Qt_A46_vals),
2298                         0x02, NULL, HFILL}},
2299
2300                 { &hf_dect_A_Tail_Qt_3_A47,
2301                 {"A47", "dect.afield.tail.Qt.Fp.A47", FT_UINT8, BASE_DEC, VALS(Qt_A47_vals),
2302                         0x01, NULL, HFILL}},
2303
2304         /* Qt Extended Fixed Part Capabilities */
2305
2306                 { &hf_dect_A_Tail_Qt_4_CRFPHops,
2307                 {"CRFP Hops", "dect.afield.tail.Qt.Efp.CRFPHops", FT_UINT8, BASE_DEC, VALS(Qt_CRFPHops_vals),
2308                         0x0C, NULL, HFILL}},
2309
2310                 { &hf_dect_A_Tail_Qt_4_CRFPEnc,
2311                 {"CRFP Enc", "dect.afield.tail.Qt.Efp.CRFPEnc", FT_UINT8, BASE_DEC, VALS(Qt_CRFPEnc_vals),
2312                         0x02, NULL, HFILL}},
2313
2314                 { &hf_dect_A_Tail_Qt_4_REFHops,
2315                 {"REP Hops", "dect.afield.tail.Qt.Efp.REPHops", FT_UINT16, BASE_DEC, VALS(Qt_REPHops_vals),
2316                         0x0180, NULL, HFILL}},
2317
2318                 { &hf_dect_A_Tail_Qt_4_REPCap,
2319                 {"REP Cap.", "dect.afield.tail.Qt.Efp.REPCap", FT_UINT8, BASE_DEC, VALS(Qt_REPCap_vals),
2320                         0x40, NULL, HFILL}},
2321
2322                 { &hf_dect_A_Tail_Qt_4_Sync,
2323                 {"Sync", "dect.afield.tail.Qt.Efp.Sync", FT_UINT8, BASE_DEC, VALS(Qt_Sync_vals),
2324                         0x30, NULL, HFILL}},
2325
2326                 { &hf_dect_A_Tail_Qt_4_A20,
2327                 {"A20", "dect.afield.tail.Qt.Efp.A20", FT_UINT8, BASE_DEC, VALS(Qt_EA20_vals),
2328                         0x08, NULL, HFILL}},
2329
2330                 { &hf_dect_A_Tail_Qt_4_MACSusp,
2331                 {"MAC Suspend", "dect.afield.tail.Qt.Efp.MACSusp", FT_UINT8, BASE_DEC, VALS(Qt_MACSusp_vals),
2332                         0x04, NULL, HFILL}},
2333
2334                 { &hf_dect_A_Tail_Qt_4_MACIpq,
2335                 {"MAC Ipq", "dect.afield.tail.Qt.Efp.MACIpq", FT_UINT8, BASE_DEC, VALS(Qt_MACIpq_vals),
2336                         0x02, NULL, HFILL}},
2337
2338                 { &hf_dect_A_Tail_Qt_4_A23,
2339                 {"A23", "dect.afield.tail.Qt.Efp.A23", FT_UINT8, BASE_DEC, VALS(Qt_EA23_vals),
2340                         0x01, NULL, HFILL}},
2341
2342                 { &hf_dect_A_Tail_Qt_4_A24,
2343                 {"A24", "dect.afield.tail.Qt.Efp.A24", FT_UINT8, BASE_DEC, VALS(Qt_EA24_vals),
2344                         0x80, NULL, HFILL}},
2345
2346
2347                 /* Higher Layer Capabilities */
2348
2349                 { &hf_dect_A_Tail_Qt_4_A25,
2350                 {"A25", "dect.afield.tail.Qt.Efp.A25", FT_UINT8, BASE_DEC, VALS(Qt_EA25_vals),
2351                         0x40, NULL, HFILL}},
2352
2353                 { &hf_dect_A_Tail_Qt_4_A26,
2354                 {"A26", "dect.afield.tail.Qt.Efp.A26", FT_UINT8, BASE_DEC, VALS(Qt_EA26_vals),
2355                         0x20, NULL, HFILL}},
2356
2357                 { &hf_dect_A_Tail_Qt_4_A27,
2358                 {"A27", "dect.afield.tail.Qt.Efp.A27", FT_UINT8, BASE_DEC, VALS(Qt_EA27_vals),
2359                         0x10, NULL, HFILL}},
2360
2361                 { &hf_dect_A_Tail_Qt_4_A28,
2362                 {"A28", "dect.afield.tail.Qt.Efp.A28", FT_UINT8, BASE_DEC, VALS(Qt_EA28_vals),
2363                         0x08, NULL, HFILL}},
2364
2365                 { &hf_dect_A_Tail_Qt_4_A29,
2366                 {"A29", "dect.afield.tail.Qt.Efp.A29", FT_UINT8, BASE_DEC, VALS(Qt_EA29_vals),
2367                         0x04, NULL, HFILL}},
2368
2369                 { &hf_dect_A_Tail_Qt_4_A30,
2370                 {"A30", "dect.afield.tail.Qt.Efp.A30", FT_UINT8, BASE_DEC, VALS(Qt_EA30_vals),
2371                         0x02, NULL, HFILL}},
2372
2373                 { &hf_dect_A_Tail_Qt_4_A31,
2374                 {"A31", "dect.afield.tail.Qt.Efp.A31", FT_UINT8, BASE_DEC, VALS(Qt_EA31_vals),
2375                         0x01, NULL, HFILL}},
2376
2377                 { &hf_dect_A_Tail_Qt_4_A32,
2378                 {"A32", "dect.afield.tail.Qt.Efp.A32", FT_UINT8, BASE_DEC, VALS(Qt_EA32_vals),
2379                         0x80, NULL, HFILL}},
2380
2381                 { &hf_dect_A_Tail_Qt_4_A33,
2382                 {"A33", "dect.afield.tail.Qt.Efp.A33", FT_UINT8, BASE_DEC, VALS(Qt_EA33_vals),
2383                         0x40, NULL, HFILL}},
2384
2385                 { &hf_dect_A_Tail_Qt_4_A34,
2386                 {"A34", "dect.afield.tail.Qt.Efp.A34", FT_UINT8, BASE_DEC, VALS(Qt_EA34_vals),
2387                         0x20, NULL, HFILL}},
2388
2389                 { &hf_dect_A_Tail_Qt_4_A35,
2390                 {"A35", "dect.afield.tail.Qt.Efp.A35", FT_UINT8, BASE_DEC, VALS(Qt_EA35_vals),
2391                         0x10, NULL, HFILL}},
2392
2393                 { &hf_dect_A_Tail_Qt_4_A36,
2394                 {"A36", "dect.afield.tail.Qt.Efp.A36", FT_UINT8, BASE_DEC, VALS(Qt_EA36_vals),
2395                         0x08, NULL, HFILL}},
2396
2397                 { &hf_dect_A_Tail_Qt_4_A37,
2398                 {"A37", "dect.afield.tail.Qt.Efp.A37", FT_UINT8, BASE_DEC, VALS(Qt_EA37_vals),
2399                         0x04, NULL, HFILL}},
2400
2401                 { &hf_dect_A_Tail_Qt_4_A38,
2402                 {"A38", "dect.afield.tail.Qt.Efp.A38", FT_UINT8, BASE_DEC, VALS(Qt_EA38_vals),
2403                         0x02, NULL, HFILL}},
2404
2405                 { &hf_dect_A_Tail_Qt_4_A39,
2406                 {"A39", "dect.afield.tail.Qt.Efp.A39", FT_UINT8, BASE_DEC, VALS(Qt_EA39_vals),
2407                         0x01, NULL, HFILL}},
2408
2409                 { &hf_dect_A_Tail_Qt_4_A40,
2410                 {"A40", "dect.afield.tail.Qt.Efp.A40", FT_UINT8, BASE_DEC, VALS(Qt_EA40_vals),
2411                         0x80, NULL, HFILL}},
2412
2413                 { &hf_dect_A_Tail_Qt_4_A41,
2414                 {"A41", "dect.afield.tail.Qt.Efp.A41", FT_UINT8, BASE_DEC, VALS(Qt_EA41_vals),
2415                         0x40, NULL, HFILL}},
2416
2417                 { &hf_dect_A_Tail_Qt_4_A42,
2418                 {"A42", "dect.afield.tail.Qt.Efp.A42", FT_UINT8, BASE_DEC, VALS(Qt_EA42_vals),
2419                         0x20, NULL, HFILL}},
2420
2421                 { &hf_dect_A_Tail_Qt_4_A43,
2422                 {"A43", "dect.afield.tail.Qt.Efp.A43", FT_UINT8, BASE_DEC, VALS(Qt_EA43_vals),
2423                         0x10, NULL, HFILL}},
2424
2425                 { &hf_dect_A_Tail_Qt_4_A44,
2426                 {"A44", "dect.afield.tail.Qt.Efp.A44", FT_UINT8, BASE_DEC, VALS(Qt_EA44_vals),
2427                         0x08, NULL, HFILL}},
2428
2429                 { &hf_dect_A_Tail_Qt_4_A45,
2430                 {"A45", "dect.afield.tail.Qt.Efp.A45", FT_UINT8, BASE_DEC, VALS(Qt_EA45_vals),
2431                         0x04, NULL, HFILL}},
2432
2433                 { &hf_dect_A_Tail_Qt_4_A46,
2434                 {"A46", "dect.afield.tail.Qt.Efp.A46", FT_UINT8, BASE_DEC, VALS(Qt_EA46_vals),
2435                         0x02, NULL, HFILL}},
2436
2437                 { &hf_dect_A_Tail_Qt_4_A47,
2438                 {"A47", "dect.afield.tail.Qt.Efp.A47", FT_UINT8, BASE_DEC, VALS(Qt_EA47_vals),
2439                         0x01, NULL, HFILL}},
2440
2441
2442         /* Qt Multiframe  Number */
2443                 { &hf_dect_A_Tail_Qt_6_Spare,
2444                 {"Spare Bits", "dect.afield.tail.Qt.Mfn.Spare", FT_UINT16, BASE_HEX, NULL,
2445                         0x0FFF, NULL, HFILL}},
2446
2447                 { &hf_dect_A_Tail_Qt_6_Mfn,
2448                 {"Multiframe Number", "dect.afield.tail.Qt.Mfn.Mfn", FT_BYTES, BASE_NONE, NULL,
2449                         0x0, NULL, HFILL}},
2450
2451
2452         /* Mt */
2453                 { &hf_dect_A_Tail_Mt_Mh,
2454                 {"Mh", "dect.afield.tail.Mt.Mh", FT_UINT8, BASE_DEC, VALS(MTHead_vals),
2455                         0xF0, NULL, HFILL}},
2456
2457                 { &hf_dect_A_Tail_Mt_Mh_attr,
2458                 {"Mh", "dect.afield.tail.Mt.Mh.attr", FT_NONE, BASE_NONE, NULL,
2459                         0x0, NULL, HFILL}},
2460
2461                 { &hf_dect_A_Tail_Mt_Mh_fmid,
2462                 {"Mh/FMID", "dect.afield.tail.Mt.Mh.fmid", FT_UINT16, BASE_HEX, NULL,
2463                         0x0FF0, NULL, HFILL}},
2464
2465                 { &hf_dect_A_Tail_Mt_Mh_pmid,
2466                 {"Mh/PMID", "dect.afield.tail.Mt.Mh.pmid", FT_UINT24, BASE_HEX, NULL,
2467                         0x0FFFFF, NULL, HFILL}},
2468
2469         /* Mt Basic Connection Control */
2470                 { &hf_dect_A_Tail_Mt_BasicConCtrl,
2471                 {"Cmd", "dect.afield.tail.Mt.BasicConCtrl", FT_UINT8, BASE_DEC, VALS(MTBasicConCtrl_vals),
2472                         0x0F, NULL, HFILL}},
2473
2474         /* Mt Encryption Control */
2475                 { &hf_dect_A_Tail_Mt_Encr_Cmd1,
2476                 {"Cmd1", "dect.afield.tail.Mt.Encr.Cmd1", FT_UINT8, BASE_DEC, VALS(MTEncrCmd1_vals),
2477                         0x0C, NULL, HFILL}},
2478
2479                 { &hf_dect_A_Tail_Mt_Encr_Cmd2,
2480                 {"Cmd2", "dect.afield.tail.Mt.Encr.Cmd2", FT_UINT8, BASE_DEC, VALS(MTEncrCmd2_vals),
2481                         0x03, NULL, HFILL}},
2482
2483         /* Pt */
2484                 { &hf_dect_A_Tail_Pt_ExtFlag,
2485                 {"ExtFlag", "dect.afield.tail.Pt.ExtFlag", FT_UINT8, BASE_DEC, VALS(PTExtFlag_vals),
2486                         0x80, NULL, HFILL}},
2487
2488                 { &hf_dect_A_Tail_Pt_SDU,
2489                 {"Bs SDU", "dect.afield.tail.Pt.SDU", FT_UINT8, BASE_DEC, VALS(PTSDU_vals),
2490                         0x70, NULL, HFILL}},
2491
2492                 { &hf_dect_A_Tail_Pt_RFPI,
2493                 {"InfoType", "dect.afield.tail.Pt.RFPI", FT_NONE, BASE_NONE, NULL,
2494                         0x0, NULL, HFILL}},
2495
2496                 { &hf_dect_A_Tail_Pt_BsData,
2497                 {"Bs Data", "dect.afield.tail.Pt.BsData", FT_NONE, BASE_NONE, NULL,
2498                         0x0, NULL, HFILL}},
2499
2500                 { &hf_dect_A_Tail_Pt_InfoType,
2501                 {"InfoType", "dect.afield.tail.Pt.InfoType", FT_UINT8, BASE_DEC, VALS(PTInfoType_vals),
2502                         0xF0, NULL, HFILL}},
2503
2504                 { &hf_dect_A_Tail_Pt_Fillbits,
2505                 {"FillBits", "dect.afield.tail.Pt.FillBits", FT_NONE, BASE_NONE, NULL,
2506                         0x0, NULL, HFILL}},
2507
2508                 { &hf_dect_A_Tail_Pt_SlotPairs,
2509                 {"SlotPairs", "dect.afield.tail.Pt.SlotPairs", FT_NONE, BASE_NONE, NULL,
2510                         0x0, NULL, HFILL}},
2511
2512                 { &hf_dect_A_Tail_Pt_Bearer_Sn,
2513                 {"SN", "dect.afield.tail.Pt.SN", FT_UINT8, BASE_DEC, VALS(QTSlotNumber_vals),
2514                         0x0F, NULL, HFILL}},
2515
2516                 { &hf_dect_A_Tail_Pt_Bearer_Sp,
2517                 {"SP", "dect.afield.tail.Pt.SP", FT_UINT8, BASE_DEC, VALS(QTStartPosition_vals),
2518                         0xC0, NULL, HFILL}},
2519
2520                 { &hf_dect_A_Tail_Pt_Bearer_Cn,
2521                 {"CN", "dect.afield.tail.Pt.CN", FT_UINT8, BASE_DEC, VALS(QTCarrierNumber_vals),
2522                         0x3F, NULL, HFILL}},
2523
2524         /* ***** R-CRC ***** */
2525                 { &hf_dect_A_RCRC,
2526                 {"A-Field R-CRC", "dect.afield.rcrc", FT_UINT8, BASE_DEC, NULL,
2527                         0x0, NULL, HFILL}},
2528
2529         /* ***************** B-Field *************************** */
2530                 { &hf_dect_B,
2531                 {"B-Field", "dect.bfield", FT_BYTES, BASE_NONE,
2532                         0x0, 0x0, NULL, HFILL}},
2533
2534                 { &hf_dect_B_Data,
2535                 {"B-Field", "dect.bfield.data", FT_NONE, BASE_NONE, NULL,
2536                         0x0, NULL, HFILL}},
2537
2538                 { &hf_dect_B_DescrambledData,
2539                 {"Descrambled Data", "dect.bfield.descrdata", FT_NONE, BASE_NONE,
2540                         0x0, 0x0, NULL, HFILL}},
2541
2542                 { &hf_dect_B_fn,
2543                 {"B-Field", "dect.bfield.framenumber", FT_NONE, BASE_NONE, NULL,
2544                         0x0, NULL, HFILL}},
2545
2546         /* ***** X-CRC ***** */
2547                 { &hf_dect_B_XCRC,
2548                 {"B-Field X-CRC", "dect.bfield.xcrc", FT_UINT8, BASE_DEC, NULL,
2549                         0x0, NULL, HFILL}}
2550         };
2551
2552
2553         /* Setup protocol subtree array */
2554         static gint *ett[]=
2555         {
2556                 &ett_dect,
2557                 &ett_columns,
2558                 &ett_ahead,
2559                 &ett_afield,
2560                 &ett_atail,
2561                 &ett_aqt,
2562                 &ett_bfield,
2563                 &ett_bfdescrdata
2564         };
2565
2566         proto_dect=proto_register_protocol("DECT Protocol", "DECT", "dect");
2567         proto_register_field_array(proto_dect, hf, array_length(hf));
2568         proto_register_subtree_array(ett, array_length(ett));
2569 }
2570
2571 void
2572 proto_reg_handoff_dect(void)
2573 {
2574         dissector_handle_t dect_handle;
2575
2576         dect_handle = create_dissector_handle(dissect_dect, proto_dect);
2577         dissector_add_uint("ethertype", ETHERTYPE_DECT , dect_handle);
2578 }
2579