Define most everything as static (fcns & global variables);
[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 <krater (A) badterrorist.com>
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   - Don't use structs to access the elements in the datastream.
34   - Use tvb_..._item wherever possible
35   - Add references to documentation (ETSI EN 300 175 parts 1-8)
36   - Make things stateful
37   - Once the capture format has stabilized, get rid of the Ethernet
38     hack and use a proper capture type.
39  */
40
41 #ifdef HAVE_CONFIG_H
42 # include "config.h"
43 #endif
44
45 #include <epan/packet.h>
46 #include <epan/etypes.h>
47 #include <string.h>
48
49 #define ETHERTYPE_DECT 0x2323                           /* move to epan/etypes.h */
50
51 /* scramble table with corrections by Jakub Hruska */
52 static guint8 scrt[8][31]=
53 {
54         {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},
55         {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},
56         {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},
57         {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},
58         {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},
59         {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},
60         {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},
61         {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}
62 };
63
64 struct dect_afield
65 {
66         guint8  Header;
67         guint8  Tail[5];
68         guint16 RCRC;
69 };
70
71 struct dect_bfield
72 {
73         guint8  Data[128];
74         guint8  Length;
75 };
76
77 static int proto_dect = -1;
78
79 #if 0
80 static int proto_dect2 = -1;
81 #endif
82
83
84 static gint ett_dect                            = -1;
85 static gint ett_afield                          = -1;
86 static gint ett_ahead                           = -1;
87 static gint ett_atail                           = -1;
88 static gint ett_aqt                             = -1;
89 static gint ett_bfield                          = -1;
90
91 static int hf_dect_transceivermode              = -1;
92 static int hf_dect_preamble                     = -1;
93 static int hf_dect_type                         = -1;
94 static int hf_dect_channel                      = -1;
95 static int hf_dect_framenumber                  = -1;
96 static int hf_dect_rssi                         = -1;
97 static int hf_dect_slot                         = -1;
98 static int hf_dect_A                            = -1;
99 static int hf_dect_A_Head                       = -1;
100 static int hf_dect_A_Head_TA                    = -1;
101 static int hf_dect_A_Head_Q1                    = -1;
102 static int hf_dect_A_Head_BA                    = -1;
103 static int hf_dect_A_Head_Q2                    = -1;
104 static int hf_dect_A_Tail                       = -1;
105 static int hf_dect_A_Tail_Nt                    = -1;
106 static int hf_dect_A_Tail_Qt_Qh                 = -1;
107 static int hf_dect_A_Tail_Qt_0_Sn               = -1;
108 static int hf_dect_A_Tail_Qt_0_Nr               = -1;
109 static int hf_dect_A_Tail_Qt_0_Sp               = -1;
110 static int hf_dect_A_Tail_Qt_0_Esc              = -1;
111 static int hf_dect_A_Tail_Qt_0_Txs              = -1;
112 static int hf_dect_A_Tail_Qt_0_Mc               = -1;
113 static int hf_dect_A_Tail_Qt_0_Spr1             = -1;
114 static int hf_dect_A_Tail_Qt_0_Cn               = -1;
115 static int hf_dect_A_Tail_Qt_0_Spr2             = -1;
116 static int hf_dect_A_Tail_Qt_0_PSCN             = -1;
117 static int hf_dect_A_Tail_Qt_3_A12              = -1;
118 static int hf_dect_A_Tail_Qt_3_A13              = -1;
119 static int hf_dect_A_Tail_Qt_3_A14              = -1;
120 static int hf_dect_A_Tail_Qt_3_A15              = -1;
121 static int hf_dect_A_Tail_Qt_3_A16              = -1;
122 static int hf_dect_A_Tail_Qt_3_A17              = -1;
123 static int hf_dect_A_Tail_Qt_3_A18              = -1;
124 static int hf_dect_A_Tail_Qt_3_A19              = -1;
125 static int hf_dect_A_Tail_Qt_3_A20              = -1;
126 static int hf_dect_A_Tail_Qt_3_A21              = -1;
127 static int hf_dect_A_Tail_Qt_3_A22              = -1;
128 static int hf_dect_A_Tail_Qt_3_A23              = -1;
129 static int hf_dect_A_Tail_Qt_3_A24              = -1;
130 static int hf_dect_A_Tail_Qt_3_A25              = -1;
131 static int hf_dect_A_Tail_Qt_3_A26              = -1;
132 static int hf_dect_A_Tail_Qt_3_A27              = -1;
133 static int hf_dect_A_Tail_Qt_3_A28              = -1;
134 static int hf_dect_A_Tail_Qt_3_A29              = -1;
135 static int hf_dect_A_Tail_Qt_3_A30              = -1;
136 static int hf_dect_A_Tail_Qt_3_A31              = -1;
137 static int hf_dect_A_Tail_Mt_Mh                 = -1;
138 static int hf_dect_A_Tail_Mt_BasicConCtrl       = -1;
139 static int hf_dect_A_Tail_Mt_Encr_Cmd1          = -1;
140 static int hf_dect_A_Tail_Mt_Encr_Cmd2          = -1;
141 static int hf_dect_A_Tail_Pt_ExtFlag            = -1;
142 static int hf_dect_A_Tail_Pt_SDU                = -1;
143 static int hf_dect_A_Tail_Pt_InfoType           = -1;
144 static int hf_dect_A_Tail_Pt_Fill_Fillbits      = -1;
145 static int hf_dect_A_Tail_Pt_Bearer_Sn          = -1;
146 static int hf_dect_A_Tail_Pt_Bearer_Cn          = -1;
147 static int hf_dect_A_Tail_Pt_Bearer_Sp          = -1;
148 static int hf_dect_A_RCRC                       = -1;
149 static int hf_dect_B                            = -1;
150 static int hf_dect_B_Data                       = -1;
151 static int hf_dect_B_XCRC                       = -1;
152
153 static const value_string tranceiver_mode[]=
154 {
155         {0,"Receive"},
156         {1,"Send"},
157         {0,NULL}
158 };
159
160 static const value_string TA_vals[]=
161 {
162         {0,"Ct Next Data Packet"},
163         {1,"Ct First Data Packet"},
164         {2,"Nt Identities Information on Connectionless Bearer"},
165         {3,"Nt Identities Information"},
166         {4,"Qt Multiframe Synchronisation and System Information"},
167         {5,"Escape"},
168         {6,"Mt MAC Layer Control"},
169         {7,"Pt Paging Tail"},
170         {0,NULL}
171 };
172
173 static const value_string BA_vals[]=
174 {
175         {0,"U-Type, In, SIn or Ip Packet No. 0 or No Valid Ip_error_detect Channel Data"},
176         {1,"U-Type, Ip_error_detect or Ip Packet No. 1 or SIn or No Valid In Channel Data"},
177         {2,"Double-Slot Required / E-Type, all Cf or CLf, Packet No. 0"},
178         {3,"E-Type, All Cf, Packet No. 1"},
179         {4,"Half-Slot Required / E-Type, not all Cf or CLf, Cf Packet No. 0"},
180         {5,"E-Type, not all Cf, Cf Packet No. 1"},
181         {6,"E-Type, All MAC control (unnumbered)"},
182         {7,"No B-Field"},
183         {0,NULL}
184 };
185
186 static const value_string QTHead_vals[]=
187 {
188         {0,"Static System Info"},
189         {1,"Static System Info"},
190         {2,"Extended RF Carriers Part 1"},
191         {3,"Fixed Part Capabilities"},
192         {4,"Extended Fixed Part Capabilities"},
193         {5,"SARI List Contents"},
194         {6,"Multi-Frame No."},
195         {7,"Escape"},
196         {8,"Obsolete"},
197         {9,"Extended RF Carriers Part 2"},
198         {10,"Reserved(?)"},
199         {11,"Transmit Information(?)"},
200         {12,"Reserved"},
201         {13,"Reserved"},
202         {14,"Reserved"},
203         {15,"Reserved"},
204         {0,NULL}
205 };
206
207 static const value_string QTNormalReverse_vals[]=
208 {
209         {0,"Normal RFP Transmit Half-Frame"},
210         {1,"Normal PP Transmit Half-Frame"},
211         {0,NULL}
212 };
213
214 static const value_string QTSlotNumber_vals[]=
215 {
216         {0,"Slot Pair 0/12"},
217         {1,"Slot Pair 1/13"},
218         {2,"Slot Pair 2/14"},
219         {3,"Slot Pair 3/15"},
220         {4,"Slot Pair 4/16"},
221         {5,"Slot Pair 5/17"},
222         {6,"Slot Pair 6/18"},
223         {7,"Slot Pair 7/19"},
224         {8,"Slot Pair 8/20"},
225         {9,"Slot Pair 9/21"},
226         {10,"Slot Pair 10/22"},
227         {11,"Slot Pair 11/23"},
228         {12,"Reserved"},
229         {13,"Reserved"},
230         {14,"Reserved"},
231         {15,"Reserved"},
232         {0,NULL}
233 };
234
235 static const value_string QTStartPosition_vals[]=
236 {
237         {0,"S-Field starts at Bit F0"},
238         {1,"Reserved for Future Use"},
239         {2,"S-Field starts at Bit F240"},
240         {3,"Reserved for Future Use"},
241         {0,NULL}
242 };
243
244 static const value_string QTEscape_vals[]=
245 {
246         {0,"No QT Escape is broadcast"},
247         {1,"The QT Escape is broadcast"},
248         {0,NULL}
249 };
250
251 static const value_string QTTranceiver_vals[]=
252 {
253         {0,"RFP has 1 Transceiver"},
254         {1,"RFP has 2 Transceiver"},
255         {2,"RFP has 3 Transceiver"},
256         {3,"RFP has 4 or more Transceiver"},
257         {0,NULL}
258 };
259
260 static const value_string QTExtendedCarrier_vals[]=
261 {
262         {0,"No Extended RF Carrier Information Message"},
263         {1,"Extended RF Carrier Information Message shall be transmitted in the next Multiframe"},
264         {0,NULL}
265 };
266
267 static const value_string QTSpr_vals[]=
268 {
269         {0,"OK"},
270         {1,"Reserved"},
271         {2,"Reserved"},
272         {3,"Reserved"},
273         {0,NULL}
274 };
275
276 static const value_string QTCarrierNumber_vals[]=
277 {
278         {0,"RF Carrier 0"},
279         {1,"RF Carrier 1"},
280         {2,"RF Carrier 2"},
281         {3,"RF Carrier 3"},
282         {4,"RF Carrier 4"},
283         {5,"RF Carrier 5"},
284         {6,"RF Carrier 6"},
285         {7,"RF Carrier 7"},
286         {8,"RF Carrier 8"},
287         {9,"RF Carrier 9"},
288         {10,"RF Carrier 10"},
289         {11,"RF Carrier 11"},
290         {12,"RF Carrier 12"},
291         {13,"RF Carrier 13"},
292         {14,"RF Carrier 14"},
293         {15,"RF Carrier 15"},
294         {16,"RF Carrier 16"},
295         {17,"RF Carrier 17"},
296         {18,"RF Carrier 18"},
297         {19,"RF Carrier 19"},
298         {20,"RF Carrier 20"},
299         {21,"RF Carrier 21"},
300         {22,"RF Carrier 22"},
301         {23,"RF Carrier 23"},
302         {24,"RF Carrier 24"},
303         {25,"RF Carrier 25"},
304         {26,"RF Carrier 26"},
305         {27,"RF Carrier 27"},
306         {28,"RF Carrier 28"},
307         {29,"RF Carrier 29"},
308         {30,"RF Carrier 30"},
309         {31,"RF Carrier 31"},
310         {32,"RF Carrier 32"},
311         {33,"RF Carrier 33"},
312         {34,"RF Carrier 34"},
313         {35,"RF Carrier 35"},
314         {36,"RF Carrier 36"},
315         {37,"RF Carrier 37"},
316         {38,"RF Carrier 38"},
317         {39,"RF Carrier 39"},
318         {40,"RF Carrier 40"},
319         {41,"RF Carrier 41"},
320         {42,"RF Carrier 42"},
321         {43,"RF Carrier 43"},
322         {44,"RF Carrier 44"},
323         {45,"RF Carrier 45"},
324         {46,"RF Carrier 46"},
325         {47,"RF Carrier 47"},
326         {48,"RF Carrier 48"},
327         {49,"RF Carrier 49"},
328         {50,"RF Carrier 50"},
329         {51,"RF Carrier 51"},
330         {52,"RF Carrier 52"},
331         {53,"RF Carrier 53"},
332         {54,"RF Carrier 54"},
333         {55,"RF Carrier 55"},
334         {56,"RF Carrier 56"},
335         {57,"RF Carrier 57"},
336         {58,"RF Carrier 58"},
337         {59,"RF Carrier 59"},
338         {60,"RF Carrier 60"},
339         {61,"RF Carrier 61"},
340         {62,"RF Carrier 62"},
341         {63,"RF Carrier 63"},
342         {0,NULL}
343 };
344
345 static const value_string QTScanCarrierNum_vals[]=
346 {
347         {0,"Primary Scan next on RF Carrier 0"},
348         {1,"Primary Scan next on RF Carrier 1"},
349         {2,"Primary Scan next on RF Carrier 2"},
350         {3,"Primary Scan next on RF Carrier 3"},
351         {4,"Primary Scan next on RF Carrier 4"},
352         {5,"Primary Scan next on RF Carrier 5"},
353         {6,"Primary Scan next on RF Carrier 6"},
354         {7,"Primary Scan next on RF Carrier 7"},
355         {8,"Primary Scan next on RF Carrier 8"},
356         {9,"Primary Scan next on RF Carrier 9"},
357         {10,"Primary Scan next on RF Carrier 10"},
358         {11,"Primary Scan next on RF Carrier 11"},
359         {12,"Primary Scan next on RF Carrier 12"},
360         {13,"Primary Scan next on RF Carrier 13"},
361         {14,"Primary Scan next on RF Carrier 14"},
362         {15,"Primary Scan next on RF Carrier 15"},
363         {16,"Primary Scan next on RF Carrier 16"},
364         {17,"Primary Scan next on RF Carrier 17"},
365         {18,"Primary Scan next on RF Carrier 18"},
366         {19,"Primary Scan next on RF Carrier 19"},
367         {20,"Primary Scan next on RF Carrier 20"},
368         {21,"Primary Scan next on RF Carrier 21"},
369         {22,"Primary Scan next on RF Carrier 22"},
370         {23,"Primary Scan next on RF Carrier 23"},
371         {24,"Primary Scan next on RF Carrier 24"},
372         {25,"Primary Scan next on RF Carrier 25"},
373         {26,"Primary Scan next on RF Carrier 26"},
374         {27,"Primary Scan next on RF Carrier 27"},
375         {28,"Primary Scan next on RF Carrier 28"},
376         {29,"Primary Scan next on RF Carrier 29"},
377         {30,"Primary Scan next on RF Carrier 30"},
378         {31,"Primary Scan next on RF Carrier 31"},
379         {32,"Primary Scan next on RF Carrier 32"},
380         {33,"Primary Scan next on RF Carrier 33"},
381         {34,"Primary Scan next on RF Carrier 34"},
382         {35,"Primary Scan next on RF Carrier 35"},
383         {36,"Primary Scan next on RF Carrier 36"},
384         {37,"Primary Scan next on RF Carrier 37"},
385         {38,"Primary Scan next on RF Carrier 38"},
386         {39,"Primary Scan next on RF Carrier 39"},
387         {40,"Primary Scan next on RF Carrier 40"},
388         {41,"Primary Scan next on RF Carrier 41"},
389         {42,"Primary Scan next on RF Carrier 42"},
390         {43,"Primary Scan next on RF Carrier 43"},
391         {44,"Primary Scan next on RF Carrier 44"},
392         {45,"Primary Scan next on RF Carrier 45"},
393         {46,"Primary Scan next on RF Carrier 46"},
394         {47,"Primary Scan next on RF Carrier 47"},
395         {48,"Primary Scan next on RF Carrier 48"},
396         {49,"Primary Scan next on RF Carrier 49"},
397         {50,"Primary Scan next on RF Carrier 50"},
398         {51,"Primary Scan next on RF Carrier 51"},
399         {52,"Primary Scan next on RF Carrier 52"},
400         {53,"Primary Scan next on RF Carrier 53"},
401         {54,"Primary Scan next on RF Carrier 54"},
402         {55,"Primary Scan next on RF Carrier 55"},
403         {56,"Primary Scan next on RF Carrier 56"},
404         {57,"Primary Scan next on RF Carrier 57"},
405         {58,"Primary Scan next on RF Carrier 58"},
406         {59,"Primary Scan next on RF Carrier 59"},
407         {60,"Primary Scan next on RF Carrier 60"},
408         {61,"Primary Scan next on RF Carrier 61"},
409         {62,"Primary Scan next on RF Carrier 62"},
410         {63,"Primary Scan next on RF Carrier 63"},
411         {0,NULL}
412 };
413
414 static const value_string Qt_A12_vals[]=
415 {
416         {0,""},
417         {1,"Extended FP Info"},
418         {0,NULL}
419 };
420
421 static const value_string Qt_A13_vals[]=
422 {
423         {0,""},
424         {1,"Double Duplex Bearer Connections"},
425         {0,NULL}
426 };
427
428 static const value_string Qt_A14_vals[]=
429 {
430         {0,""},
431         {1,"Reserved"},
432         {0,NULL}
433 };
434
435 static const value_string Qt_A15_vals[]=
436 {
437         {0,""},
438         {1,"Double Slot"},
439         {0,NULL}
440 };
441
442 static const value_string Qt_A16_vals[]=
443 {
444         {0,""},
445         {1,"Half Slot"},
446         {0,NULL}
447 };
448
449 static const value_string Qt_A17_vals[]=
450 {
451         {0,""},
452         {1,"Full Slot"},
453         {0,NULL}
454 };
455
456 static const value_string Qt_A18_vals[]=
457 {
458         {0,""},
459         {1,"Frequency Control"},
460         {0,NULL}
461 };
462
463 static const value_string Qt_A19_vals[]=
464 {
465         {0,""},
466         {1,"Page Repetition"},
467         {0,NULL}
468 };
469
470 static const value_string Qt_A20_vals[]=
471 {
472         {0,""},
473         {1,"C/O Setup on Dummy allowed"},
474         {0,NULL}
475 };
476
477 static const value_string Qt_A21_vals[]=
478 {
479         {0,""},
480         {1,"C/L Uplink"},
481         {0,NULL}
482 };
483
484 static const value_string Qt_A22_vals[]=
485 {
486         {0,""},
487         {1,"C/L Downlink"},
488         {0,NULL}
489 };
490
491 static const value_string Qt_A23_vals[]=
492 {
493         {0,""},
494         {1,"Basic A-Field Set-Up"},
495         {0,NULL}
496 };
497
498 static const value_string Qt_A24_vals[]=
499 {
500         {0,""},
501         {1,"Advanced A-Field Set-Up"},
502         {0,NULL}
503 };
504
505 static const value_string Qt_A25_vals[]=
506 {
507         {0,""},
508         {1,"B-field Set-Up"},
509         {0,NULL}
510 };
511
512 static const value_string Qt_A26_vals[]=
513 {
514         {0,""},
515         {1,"Cf Messages"},
516         {0,NULL}
517 };
518
519 static const value_string Qt_A27_vals[]=
520 {
521         {0,""},
522         {1,"In Minimum Delay"},
523         {0,NULL}
524 };
525
526 static const value_string Qt_A28_vals[]=
527 {
528         {0,""},
529         {1,"In Normal Delay"},
530         {0,NULL}
531 };
532
533 static const value_string Qt_A29_vals[]=
534 {
535         {0,""},
536         {1,"Ip Error Detection"},
537         {0,NULL}
538 };
539
540 static const value_string Qt_A30_vals[]=
541 {
542         {0,""},
543         {1,"Ip Error Correction"},
544         {0,NULL}
545 };
546
547 static const value_string Qt_A31_vals[]=
548 {
549         {0,""},
550         {1,"Multibearer Connections"},
551         {0,NULL}
552 };
553
554 static const value_string MTHead_vals[]=
555 {
556         {0,"Basic Connection Control"},
557         {1,"Advanced Connection Control"},
558         {2,"MAC Layer Test Messages"},
559         {3,"Quality Control"},
560         {4,"Broadcast and Connectionless Services"},
561         {5,"Encryption Control"},
562         {6,"Tail for use with the first Transmission of a B-Field \"bearer request\" Message"},
563         {7,"Escape"},
564         {8,"TARI Message"},
565         {9,"REP Connection Control"},
566         {10,"Reserved"},
567         {11,"Reserved"},
568         {12,"Reserved"},
569         {13,"Reserved"},
570         {14,"Reserved"},
571         {15,"Reserved"},
572         {0,NULL}
573 };
574
575 static const value_string MTBasicConCtrl_vals[]=
576 {
577         {0,"Access Request"},
578         {1,"Bearer Handover Request"},
579         {2,"Connection Handover Request"},
580         {3,"Unconfirmed Access Request"},
581         {4,"Bearer Confirm"},
582         {5,"Wait"},
583         {6,"Attributes T Request"},
584         {7,"Attributes T Confirm"},
585         {8,"Reserved"},
586         {9,"Reserved"},
587         {10,"Reserved"},
588         {11,"Reserved"},
589         {12,"Reserved"},
590         {13,"Reserved"},
591         {14,"Reserved"},
592         {15,"Release"},
593         {0,NULL}
594 };
595
596 static const value_string MTEncrCmd1_vals[]=
597 {
598         {0,"Start Encryption"},
599         {1,"Stop Encryption"},
600         {2,"reserved"},
601         {3,"reserved"},
602         {0,NULL}
603 };
604
605 static const value_string MTEncrCmd2_vals[]=
606 {
607         {0,"Request"},
608         {1,"Confirm"},
609         {2,"Grant"},
610         {3,"Reserved"},
611         {0,NULL}
612 };
613
614 static const value_string PTExtFlag_vals[]=
615 {
616         {0,"bla1"},
617         {1,"bla2"},
618         {0,NULL}
619 };
620
621 static const value_string PTSDU_vals[]=
622 {
623         {0,"Zero Length Page"},
624         {1,"Short Page"},
625         {2,"Full Page"},
626         {3,"MAC resume page"},
627         {4,"Not the last 36 Bits of a Long Page"},
628         {5,"The first 36 Bits of a Long Page"},
629         {6,"The last 36 Bits of a Long Page"},
630         {7,"All of a Long Page (first and last)"},
631         {0,NULL}
632 };
633
634 static const value_string PTInfoType_vals[]=
635 {
636         {0,"Fill Bits"},
637         {1,"Blind Full Slot Information for Circuit Mode Service"},
638         {2,"Other Bearer"},
639         {3,"Recommended Other Bearer"},
640         {4,"Good RFP Bearer"},
641         {5,"Dummy or connectionless Bearer Position"},
642         {6,"Extended Modulation Types"},
643         {7,"Escape"},
644         {8,"Dummy or connectionless Bearer Marker"},
645         {9,"Bearer Handover/Replacement Information"},
646         {10,"RFP Status and Modulation Types"},
647         {11,"Active Carriers"},
648         {12,"Connectionless Bearer Position"},
649         {13,"RFP Power Level"},
650         {14,"Blind Double Slot/RFP-FP Interface Resource Information"},
651         {15,"Blind Full Slot Information for Packet Mode Service"},
652         {0,NULL}
653 };
654
655 static const value_string PTRFPPower_vals[]=
656 {
657         {0,"0 dBm"},
658         {1,"2 dBm"},
659         {2,"4 dBm"},
660         {3,"6 dBm"},
661         {4,"8 dBm"},
662         {5,"10 dBm"},
663         {6,"12 dBm"},
664         {7,"14 dBm"},
665         {8,"16 dBm"},
666         {9,"18 dBm"},
667         {10,"20 dBm"},
668         {11,"22 dBm"},
669         {12,"24 dBm"},
670         {13,"26 dBm"},
671         {14,"28 dBm"},
672         {15,"30 dBm"},
673         {0, NULL}
674 };
675
676 static unsigned char
677 getbit(guint8 *data,int bit)
678 {
679         guint8 c;
680         guint8 byte=data[bit/8];
681
682         c=1;
683         c<<=bit%8;
684
685         return (byte&c)>>bit%8;
686 }
687
688 static void
689 setbit(guint8 *data,int bit,guint8 value)
690 {
691         if(!value)
692                 data[bit/8]&=~(1<<(bit%8));
693         else
694                 data[bit/8]|=(1<<(bit%8));
695 }
696
697 static guint8
698 calc_xcrc(guint8* data,guint8 length)
699 {
700         guint8 bits[21];
701         guint8 gp=0x1;
702         guint8 div;
703         guint8 next;
704         int y,x;
705
706         for(y=0;y<80;y++)
707         {
708                 setbit(bits,y,getbit(data,y+48*(1+(int)(y/16))));
709         }
710         length=10;
711         div=bits[0];
712         y=0;
713         while(y<length)
714         {
715                 if(y<(length-1))
716                         next=bits[y+1];
717                 else
718                         next=0;
719                 y++;
720                 x=0;
721                 while(x<8)
722                 {
723                         while(!(div&0x80))
724                         {
725                                 div<<=1;
726                                 div|=!!(next&0x80);
727                                 next<<=1;
728                                 x++;
729                                 if(x>7)
730                                         break;
731                         }
732                         if(x>7)
733                                 break;
734                         div<<=1;
735                         div|=!!(next&0x80);
736                         next<<=1;
737                         x++;
738                         div^=(gp<<4);
739                 }
740         }
741 /*      div^=0x10; */
742         return div;
743 }
744
745 static guint16
746 calc_rcrc(guint8* data)
747 {
748         guint16 gp=0x0589;              /* 10000010110001001 without the leading 1 */
749
750         guint16 div;
751         guint8 next;
752         int y,x;
753
754         div=data[0]<<8|data[1];
755         y=0;
756         while(y<6)
757         {
758                 next=data[2+y];
759                 y++;
760                 x=0;
761                 while(x<8)
762                 {
763                         while(!(div&0x8000))
764                         {
765                                 div<<=1;
766                                 div|=!!(next&0x80);
767                                 next<<=1;
768                                 x++;
769                                 if(x>7)
770                                         break;
771                         }
772                         if(x>7)
773                                 break;
774                         div<<=1;
775                         div|=!!(next&0x80);
776                         next<<=1;
777                         x++;
778                         div^=gp;
779                 }
780         }
781         div^=1;
782         return div;
783 }
784
785 static gint
786 dissect_bfield(gboolean type _U_, struct dect_afield *pkt_afield,
787         struct dect_bfield *pkt_bfield, packet_info *pinfo, guint8 *pkt_ptr _U_,
788         tvbuff_t *tvb,proto_item *ti _U_, proto_tree *DectTree, gint offset)
789 {
790         guint8 xcrc,xcrclen;
791         guint16 blen;
792         gint oldoffset,fn;
793         proto_item *bfieldti    =NULL;
794 #if 0
795         proto_item *bxcrc       =NULL;
796 #endif
797         proto_tree *BField      =NULL;
798
799         /* B-Feld */
800         switch((pkt_afield->Header&0x0E)>>1)
801         {
802         case 0:
803         case 1:
804         case 3:
805         case 5:
806         case 6:
807                 blen=40;
808                 xcrclen=4;
809
810                 if(check_col(pinfo->cinfo,COL_DEF_NET_DST))
811                 {
812                         col_append_str(pinfo->cinfo,COL_DEF_NET_DST,"Full Slot");
813                 }
814                 break;
815         case 2:
816                 blen=100;
817                 xcrclen=4;
818
819                 if(check_col(pinfo->cinfo,COL_DEF_NET_DST))
820                 {
821                         col_append_str(pinfo->cinfo,COL_DEF_NET_DST,"Double Slot");
822                 }
823                 break;
824         case 4:
825                 blen=10;
826                 xcrclen=4;
827
828                 if(check_col(pinfo->cinfo,COL_DEF_NET_DST))
829                 {
830                         col_append_str(pinfo->cinfo,COL_DEF_NET_DST,"Half Slot");
831                 }
832                 break;
833         case 7:
834                 blen=0;
835                 xcrclen=0;
836
837                 if(check_col(pinfo->cinfo,COL_DEF_NET_DST))
838                 {
839                         col_append_str(pinfo->cinfo,COL_DEF_NET_DST,"No B-Field");
840                 }
841                 break;
842         default:
843                 /* can't happen but makes gcc happy */
844                 blen=0;
845                 xcrclen=0;
846                 break;
847         }
848         if(blen)
849         {
850                 bfieldti        = proto_tree_add_uint_format(DectTree,hf_dect_B,tvb,offset,40,0/*0x2323*/,"B-Field");
851                 BField          = proto_item_add_subtree(bfieldti,ett_bfield);
852         }
853
854         oldoffset=offset;
855
856         if((blen+(xcrclen/8)+1)<=pkt_bfield->Length)
857         {
858                 guint16 x,y;
859                 for(x=0;x<blen;x+=16)
860                 {
861                         gchar string[60];
862                         string[0]='\0';
863                         for(y=0;y<16;y++)
864                         {
865                                 if((x+y)>=blen)
866                                         break;
867
868                                 sprintf(string,"%s%.2x ",string,pkt_bfield->Data[x+y]);
869                         }
870                         proto_tree_add_uint_format(BField,hf_dect_B_Data,tvb,offset,y,0x2323,"Data: %s",string);
871                         if(y==16)
872                                 offset+=16;
873                         else
874                                 offset+=16-y;
875                 }
876                 for(fn=0;fn<8;fn++)
877                 {
878                         guint16 bytecount=0;
879
880                         proto_tree_add_uint_format(BField,hf_dect_B_Data,tvb,offset,y,0x2323,"\n");
881                         offset=oldoffset;
882
883                         proto_tree_add_uint_format(BField,hf_dect_B_Data,tvb,offset,y,0x2323,"Framenumber %u/%u",fn,fn+8);
884                         for(x=0;x<blen;x+=16)
885                         {
886                                 gchar string[60];
887                                 string[0]='\0';
888                                 for(y=0;y<16;y++)
889                                 {
890                                         if((x+y)>=blen)
891                                                 break;
892
893                                         sprintf(string,"%s%.2x ",string,pkt_bfield->Data[x+y]^scrt[fn][bytecount%31]);
894                                         bytecount++;
895                                 }
896                                 proto_tree_add_uint_format(BField,hf_dect_B_Data,tvb,offset,y,0x2323,"Data: %s",string);
897                                 if(y==16)
898                                         offset+=16;
899                                 else
900                                         offset+=16-y;
901                         }
902                 }
903                 xcrc=calc_xcrc(pkt_bfield->Data,83);
904
905                 if(xcrc!=(pkt_bfield->Data[40]&0xf0))
906                         proto_tree_add_uint_format(bfieldti,hf_dect_B_XCRC,tvb,offset,1,0,"X-CRC Error (Calc:%.2x,Recv:%.2x)",xcrc,pkt_bfield->Data[40]&0xf0);
907                 else
908                         proto_tree_add_uint_format(bfieldti,hf_dect_B_XCRC,tvb,offset,1,1,"X-CRC Match (Calc:%.2x,Recv:%.2x)",xcrc,pkt_bfield->Data[40]&0xf0);
909         }
910         else
911                 proto_tree_add_uint_format(BField,hf_dect_B_Data,tvb,offset,0,0x2323,"Data too Short");
912         return offset;
913 }
914
915 static void
916 dissect_decttype(gboolean type, struct dect_afield *pkt_afield,
917         struct dect_bfield *pkt_bfield, packet_info *pinfo, guint8 *pkt_ptr,
918         tvbuff_t *tvb, proto_item *ti, proto_tree *DectTree)
919 {
920         gchar *str_p;
921         guint16 rcrc;
922         guint8 rcrcdat[8];
923         gint offset             =11;
924         proto_item *afieldti    =NULL;
925         proto_item *aheadti     =NULL;
926         proto_item *atailti     =NULL;
927 #if 0
928         proto_item *arcrc       =NULL;
929         proto_item *aqtti       =NULL;
930 #endif
931         proto_tree *AField      =NULL;
932         proto_tree *AHead       =NULL;
933         proto_tree *ATail       =NULL;
934 #if 0
935         proto_tree *AQT         =NULL;
936 #endif
937
938         /**************************  A-Field  ***********************************/
939
940         /* A-Feld */
941         afieldti        = proto_tree_add_uint_format(DectTree,hf_dect_A,tvb,offset,8,0/*0x2323*/,"A-Field");
942         AField          = proto_item_add_subtree(afieldti,ett_afield);
943
944         /* Header  */
945         aheadti         = proto_tree_add_uint_format(afieldti,hf_dect_A_Head,tvb,offset,1,0x2323,"Header");
946         AHead           = proto_item_add_subtree(aheadti,ett_ahead);
947
948         proto_tree_add_uint(AHead,hf_dect_A_Head_TA,tvb,offset,1,pkt_afield->Header);
949         proto_tree_add_uint(AHead,hf_dect_A_Head_Q1,tvb,offset,1,pkt_afield->Header);
950         proto_tree_add_uint(AHead,hf_dect_A_Head_BA,tvb,offset,1,pkt_afield->Header);
951         proto_tree_add_uint(AHead,hf_dect_A_Head_Q2,tvb,offset,1,pkt_afield->Header);
952         offset++;
953
954         /* Tail */
955         atailti         = proto_tree_add_uint_format(afieldti,hf_dect_A_Tail,tvb,offset,5,0x2323,"Tail: %s",TA_vals[(pkt_afield->Header&0xE0)>>5].strptr);
956         ATail           = proto_item_add_subtree(atailti,ett_atail);
957
958         switch((pkt_afield->Header&0xE0)>>5)
959         {
960         case 0:         /* Ct */
961         case 1:
962                 if(check_col(pinfo->cinfo,COL_HPUX_SUBSYS))
963                         col_set_str(pinfo->cinfo,COL_HPUX_SUBSYS,"[Ct]");
964                 break;
965         case 2:         /* Nt */
966         case 3:         /* Nt connectionless bearer */
967                 if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
968                 {
969                         str_p = ep_strdup_printf("RFPI:%.2x%.2x%.2x%.2x%.2x"
970                                         ,pkt_afield->Tail[0],pkt_afield->Tail[1],pkt_afield->Tail[2]
971                                         ,pkt_afield->Tail[3],pkt_afield->Tail[4]);
972
973                         col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,str_p);
974                         offset+=5;
975
976                         /* due to addition further down */
977                         offset-=5;
978                 }
979                 if(check_col(pinfo->cinfo,COL_HPUX_SUBSYS))
980                         col_set_str(pinfo->cinfo,COL_HPUX_SUBSYS,"[Nt]");
981
982                 proto_tree_add_uint_format(atailti,hf_dect_A_Tail_Nt,tvb,offset,5,0x2323,"RFPI:%.2x%.2x%.2x%.2x%.2x"
983                         ,pkt_afield->Tail[0],pkt_afield->Tail[1],pkt_afield->Tail[2],pkt_afield->Tail[3]
984                         ,pkt_afield->Tail[4]);
985                 break;
986         case 4:         /* Qt */
987                 if(check_col(pinfo->cinfo,COL_HPUX_SUBSYS))
988                         col_set_str(pinfo->cinfo,COL_HPUX_SUBSYS,"[Qt]");
989
990                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_Qh,tvb,offset,1,(pkt_afield->Tail[0]));
991
992                 switch(pkt_afield->Tail[0]>>4)
993                 {
994                 case 0:         /* Static System Info */
995                 case 1:
996                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
997                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Static System Info");
998
999                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Nr,tvb,offset,1,(pkt_afield->Tail[0]));
1000                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Sn,tvb,offset,1,(pkt_afield->Tail[0]));
1001                         offset++;
1002
1003                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Sp,tvb,offset,1,(pkt_afield->Tail[1]));
1004                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Esc,tvb,offset,1,(pkt_afield->Tail[1]));
1005                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Txs,tvb,offset,1,(pkt_afield->Tail[1]));
1006                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Mc,tvb,offset,1,(pkt_afield->Tail[1]));
1007                         offset++;
1008
1009                         proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Mt_Mh,tvb,offset,2,0x2323,"            Carrier%s%s%s%s%s%s%s%s%s%s available",
1010                                 (pkt_afield->Tail[1]&0x02)?" 0":"",(pkt_afield->Tail[1]&0x01)?" 1":"",(pkt_afield->Tail[2]&0x80)?" 2":"",
1011                                 (pkt_afield->Tail[2]&0x40)?" 3":"",(pkt_afield->Tail[2]&0x20)?" 4":"",(pkt_afield->Tail[2]&0x10)?" 5":"",
1012                                 (pkt_afield->Tail[2]&0x08)?" 6":"",(pkt_afield->Tail[2]&0x04)?" 7":"",(pkt_afield->Tail[2]&0x02)?" 8":"",
1013                                 (pkt_afield->Tail[2]&0x01)?" 9":"");
1014                         offset++;
1015
1016                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Spr1,tvb,offset,1,(pkt_afield->Tail[3]));
1017                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Cn,tvb,offset,1,(pkt_afield->Tail[3]));
1018                         offset++;
1019
1020                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_Spr2,tvb,offset,1,(pkt_afield->Tail[4]));
1021                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_0_PSCN,tvb,offset,1,(pkt_afield->Tail[4]));
1022                         offset++;
1023                         /* due to addition further down */
1024                         offset-=5;
1025                         break;
1026                 case 2:         /* Extended RF Carriers Part 1 */
1027                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1028                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Extended RF Carriers Part 1");
1029                         break;
1030                 case 3:         /* Fixed Part Capabilities */
1031                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1032                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Fixed Part Capabilities");
1033
1034                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A12,tvb,offset,1,(pkt_afield->Tail[0]));
1035                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A13,tvb,offset,1,(pkt_afield->Tail[0]));
1036                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A14,tvb,offset,1,(pkt_afield->Tail[0]));
1037                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A15,tvb,offset,1,(pkt_afield->Tail[0]));
1038                         offset++;
1039
1040                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A16,tvb,offset,1,(pkt_afield->Tail[1]));
1041                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A17,tvb,offset,1,(pkt_afield->Tail[1]));
1042                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A18,tvb,offset,1,(pkt_afield->Tail[1]));
1043                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A19,tvb,offset,1,(pkt_afield->Tail[1]));
1044                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A20,tvb,offset,1,(pkt_afield->Tail[1]));
1045                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A21,tvb,offset,1,(pkt_afield->Tail[1]));
1046                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A22,tvb,offset,1,(pkt_afield->Tail[1]));
1047                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A23,tvb,offset,1,(pkt_afield->Tail[1]));
1048                         offset++;
1049
1050                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A24,tvb,offset,1,(pkt_afield->Tail[2]));
1051                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A25,tvb,offset,1,(pkt_afield->Tail[2]));
1052                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A26,tvb,offset,1,(pkt_afield->Tail[2]));
1053                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A27,tvb,offset,1,(pkt_afield->Tail[2]));
1054                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A28,tvb,offset,1,(pkt_afield->Tail[2]));
1055                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A29,tvb,offset,1,(pkt_afield->Tail[2]));
1056                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A30,tvb,offset,1,(pkt_afield->Tail[2]));
1057                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Qt_3_A31,tvb,offset,1,(pkt_afield->Tail[2]));
1058                         offset+=3;
1059
1060                         /* due to addition further down */
1061                         offset-=5;
1062                         break;
1063                 case 4:         /* Extended Fixed Part Capabilities */
1064                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1065                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Extended Fixed Part Capabilities");
1066                         break;
1067                 case 5:         /* SARI List Contents */
1068                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1069                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"SARI List Contents");
1070                         break;
1071                 case 6:         /* Multi-Frame No. */
1072                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1073                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Multi-Frame No.");
1074                         break;
1075                 case 7:         /* Escape */
1076                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1077                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Escape");
1078                         break;
1079                 case 8:         /* Obsolete */
1080                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1081                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Obsolete");
1082                         break;
1083                 case 9:         /* Extended RF Carriers Part 2 */
1084                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1085                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Extended RF Carriers Part 2");
1086                         break;
1087                 case 10:        /* Reserved(?) */
1088                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1089                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Reserved(?)");
1090                         break;
1091                 case 11:        /* Transmit Information(?) */
1092                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1093                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Transmit Information(?)");
1094                         break;
1095                 case 12:        /* Reserved */
1096                 case 13:
1097                 case 14:
1098                 case 15:
1099                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1100                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Reserved");
1101                         break;
1102                 }
1103                 break;
1104         case 5:         /* Escape */
1105                 break;
1106         case 6:         /* Mt */
1107                 if(check_col(pinfo->cinfo,COL_HPUX_SUBSYS))
1108                         col_set_str(pinfo->cinfo,COL_HPUX_SUBSYS,"[Mt]");
1109
1110                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Mt_Mh,tvb,offset,1,(pkt_afield->Tail[0]));
1111
1112                 switch(pkt_afield->Tail[0]>>4)
1113                 {
1114                 case 0:         /* Basic Connection Control */
1115                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1116                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Basic Connection Control");
1117                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Mt_BasicConCtrl,tvb,offset,1,(pkt_afield->Tail[0]));
1118                         offset++;
1119
1120                         if(((pkt_afield->Tail[0]&&0x0f)==6)||((pkt_afield->Tail[0]&&0x0f)==7))
1121                         {
1122                                 proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Mt_Mh,tvb,offset,5,0x2323,"hier sollten attribute stehn...");
1123                         }
1124                         else
1125                         {
1126                                 proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Mt_Mh,tvb,offset,2,0x2323,"FMID:%.3x",(pkt_afield->Tail[1]<<4)|(pkt_afield->Tail[2]>>4));
1127                                 offset++;
1128
1129                                 proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Mt_Mh,tvb,offset,3,0x2323,"PMID:%.5x",((pkt_afield->Tail[2]&0x0f)<<16)|(pkt_afield->Tail[3]<<8)|pkt_afield->Tail[4]);
1130                                 offset+=3;
1131                         }
1132
1133                         /* due to addition further down */
1134                         offset-=5;
1135                         break;
1136                 case 1:         /* Advanced Connection Control */
1137                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1138                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Advanced Connection Control");
1139                         break;
1140                 case 2:         /* MAC Layer Test Messages */
1141                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1142                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"MAC Layer Test Messages");
1143                         break;
1144                 case 3:         /* Quality Control */
1145                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1146                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Quality Control");
1147                         break;
1148                 case 4:         /* Broadcast and Connectionless Services */
1149                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1150                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Broadcast and Connectionless Services");
1151                         break;
1152                 case 5:         /* Encryption Control */
1153                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1154                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Encryption Control");
1155
1156                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Mt_Encr_Cmd1,tvb,offset,1,(pkt_afield->Tail[0]));
1157                         proto_tree_add_uint(ATail,hf_dect_A_Tail_Mt_Encr_Cmd2,tvb,offset,1,(pkt_afield->Tail[0]));
1158                         offset++;
1159
1160                         proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Mt_Mh,tvb,offset,2,0x2323,"FMID:%.3x",(pkt_afield->Tail[1]<<4)|(pkt_afield->Tail[2]>>4));
1161                         offset++;
1162
1163                         proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Mt_Mh,tvb,offset,3,0x2323,"PMID:%.5x",((pkt_afield->Tail[2]&0x0f)<<16)|(pkt_afield->Tail[3]<<8)|pkt_afield->Tail[4]);
1164                         offset+=3;
1165
1166                         /* wegen addition weiter unten */
1167                         offset-=5;
1168                         break;
1169                 case 6:         /* Tail for use with the first Transmission of a B-Field \"bearer request\" Message */
1170                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1171                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Tail for use with the first Transmission of a B-Field \"bearer request\" Message");
1172                         break;
1173                 case 7:         /* Escape */
1174                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1175                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Escape");
1176                         break;
1177                 case 8:         /* TARI Message */
1178                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1179                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"TARI Message");
1180                         break;
1181                 case 9:         /* REP Connection Control */
1182                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1183                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"REP Connection Control");
1184                         break;
1185                 case 10:        /* Reserved */
1186                 case 11:
1187                 case 12:
1188                 case 13:
1189                 case 14:
1190                 case 15:
1191                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1192                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Reserved");
1193                         break;
1194                 }
1195                 break;
1196         case 7:         /* Pt */
1197                 if(check_col(pinfo->cinfo,COL_HPUX_SUBSYS))
1198                         col_set_str(pinfo->cinfo,COL_HPUX_SUBSYS,"[Pt]");
1199
1200                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Pt_ExtFlag,tvb,offset,1,(pkt_afield->Tail[0]));
1201                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Pt_SDU,tvb,offset,1,(pkt_afield->Tail[0]));
1202                 switch((pkt_afield->Tail[0]&0x70)>>4)
1203                 {
1204                 case 0:         /* Zero Length Page */
1205                 case 1:         /* Short Page */
1206                         if(((pkt_afield->Tail[0]&0x70)>>4)==0)
1207                         {
1208                                 if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1209                                         col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Zero Length Page: ");
1210                                 proto_tree_add_uint_format(atailti,hf_dect_A_Tail_Pt_InfoType,tvb,offset,3,0x2323,"RFPI:xxxxx%.1x%.2x%.2x",(pkt_afield->Tail[0]&0x0f),pkt_afield->Tail[1],pkt_afield->Tail[2]);
1211                                 offset+=3;
1212
1213                                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Pt_InfoType,tvb,offset,1,(pkt_afield->Tail[3]));
1214                         }
1215                         else
1216                         {
1217                                 if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1218                                         col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Short Page: ");
1219                                 proto_tree_add_uint_format(atailti,hf_dect_A_Tail_Pt_InfoType,tvb,offset,3,0x2323,"Bs Data:%.1x%.2x%.2x",(pkt_afield->Tail[0]&0x0f),pkt_afield->Tail[1],pkt_afield->Tail[2]);
1220                                 offset+=3;
1221
1222                                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Pt_InfoType,tvb,offset,1,(pkt_afield->Tail[3]));
1223                         }
1224                         switch(pkt_afield->Tail[3]>>4)
1225                         {
1226                         case 0: /* Fill Bits */
1227                                 proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Pt_Fill_Fillbits,tvb,offset,2,0x2323,"Fillbits:%.1x%.2x",pkt_afield->Tail[3]&0x0f,pkt_afield->Tail[4]);
1228                                 offset+=2;
1229                                 break;
1230                         case 1: /* Blind Full Slot Information for Circuit Mode Service */
1231                         case 7: /* Escape */
1232                         case 8: /* Dummy or connectionless Bearer Marker */
1233                                 proto_tree_add_uint_format(ATail,hf_dect_A_Tail_Pt_InfoType,tvb,offset,2,0x2323,"            Slot-Pairs:%s%s%s%s%s%s%s%s%s%s%s%s available",
1234                                         (pkt_afield->Tail[3]&0x08)?" 0/12":"",(pkt_afield->Tail[3]&0x04)?" 1/13":"",(pkt_afield->Tail[3]&0x02)?" 2/14":"",
1235                                         (pkt_afield->Tail[3]&0x01)?" 3/15":"",(pkt_afield->Tail[4]&0x80)?" 4/16":"",(pkt_afield->Tail[4]&0x40)?" 5/17":"",
1236                                         (pkt_afield->Tail[4]&0x20)?" 6/18":"",(pkt_afield->Tail[4]&0x10)?" 7/19":"",(pkt_afield->Tail[4]&0x08)?" 8/20":"",
1237                                         (pkt_afield->Tail[4]&0x04)?" 9/21":"",(pkt_afield->Tail[4]&0x02)?" 10/22":"",(pkt_afield->Tail[4]&0x01)?" 11/23":"");
1238
1239                                 offset+=2;
1240                                 break;
1241                         case 2: /* Other Bearer */
1242                         case 3: /* Recommended Other Bearer */
1243                         case 4: /* Good RFP Bearer */
1244                         case 5: /* Dummy or connectionless Bearer Position */
1245                         case 12: /* Connectionless Bearer Position */
1246                                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Pt_Bearer_Sn,tvb,offset,1,(pkt_afield->Tail[3]));
1247                                 offset++;
1248
1249                                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Pt_Bearer_Sp,tvb,offset,1,(pkt_afield->Tail[4]));
1250                                 proto_tree_add_uint(ATail,hf_dect_A_Tail_Pt_Bearer_Cn,tvb,offset,1,(pkt_afield->Tail[4]));
1251                                 offset++;
1252                                 break;
1253                         case 6: /* Extended Modulation Types */
1254                                 offset+=2;
1255                                 break;
1256
1257                         case 9: /* Bearer Handover/Replacement Information */
1258                                 offset+=2;
1259                                 break;
1260                         case 10: /* RFP Status and Modulation Types */
1261                                 offset+=2;
1262                                 break;
1263                         case 11: /* Active Carriers */
1264                                 offset+=2;
1265                                 break;
1266                         case 13: /* RFP Power Level */
1267                                 offset+=2;
1268                                 break;
1269                         case 14: /* Blind Double Slot/RFP-FP Interface Resource Information */
1270                                 offset+=2;
1271                                 break;
1272                         case 15: /* Blind Full Slot Information for Packet Mode Service */
1273                                 offset+=2;
1274                                 break;
1275                         }
1276                         /* due to addition further down */
1277                         offset-=5;
1278                         break;
1279                 case 2:         /* Full Page */
1280                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1281                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Full Page: ");
1282                         break;
1283                 case 3:         /* MAC Resume Page */
1284                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1285                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"MAC Resume Page: ");
1286                         break;
1287                 case 4:         /* Not the Last 36 Bits of a Long Page */
1288                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1289                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"Not the Last 36 Bits: ");
1290                         break;
1291                 case 5:         /* The First 36 Bits of a Long Page */
1292                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1293                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"The First 36 Bits: ");
1294                         break;
1295                 case 6:         /* The Last 36 Bits of a Long Page */
1296                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1297                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"The Last 36 Bits: ");
1298                         break;
1299                 case 7:         /* All of a Long Page */
1300                         if(check_col(pinfo->cinfo,COL_DEF_NET_SRC))
1301                                 col_append_str(pinfo->cinfo,COL_DEF_NET_SRC,"All of a Long Page: ");
1302                         break;
1303                 }
1304                 break;
1305         }
1306         offset+=5;
1307
1308         /* R-CRC */
1309
1310         memcpy(rcrcdat,pkt_ptr,6);
1311         rcrcdat[6]=0;
1312         rcrcdat[7]=0;
1313         rcrc=calc_rcrc(rcrcdat);
1314         if(rcrc!=pkt_afield->RCRC)
1315                 proto_tree_add_uint_format(afieldti,hf_dect_A_RCRC,tvb,offset,2,0,"R-CRC Error (Calc:%.4x,Recv:%.4x)",rcrc,pkt_afield->RCRC);
1316         else
1317                 proto_tree_add_uint_format(afieldti,hf_dect_A_RCRC,tvb,offset,2,1,"R-CRC Match (Calc:%.4x,Recv:%.4x)",rcrc,pkt_afield->RCRC);
1318
1319         offset+=2;
1320
1321         /* ****************  B-Field  ************************************/
1322         offset=dissect_bfield(type,pkt_afield,pkt_bfield,pinfo,pkt_ptr,tvb,ti,DectTree,offset);
1323 }
1324
1325 static void
1326 dissect_dect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1327 {
1328         guint16                 type;
1329         guint16                 pkt_len;
1330         guint8                  *pkt_ptr;
1331         struct dect_afield      pkt_afield;
1332         struct dect_bfield      pkt_bfield;
1333
1334         /* Packet pointer holen */
1335         pkt_len=tvb_length(tvb);
1336
1337         if(pkt_len>140)
1338                         pkt_len=140;
1339
1340         if(pkt_len<13)
1341         {
1342                 if(check_col(pinfo->cinfo,COL_PROTOCOL))
1343                 {
1344                         col_set_str(pinfo->cinfo,COL_PROTOCOL,"No Data");
1345                 }
1346                 return;
1347         }
1348
1349         pkt_ptr=(guint8*)tvb_get_ptr(tvb,11,pkt_len-11);
1350
1351         /* fill A-Field  */
1352         pkt_afield.Header=pkt_ptr[0];
1353         memcpy((char*)(&(pkt_afield.Tail)),(char*)(pkt_ptr+1),5);
1354         pkt_afield.RCRC=(((guint16)pkt_ptr[6])<<8)|pkt_ptr[7];
1355
1356
1357         /* fill B-Field  */
1358         if(pkt_len>13)
1359                 memcpy((char*)(&(pkt_bfield.Data)),(char*)(pkt_ptr+8),pkt_len-5-8);
1360         else
1361                 memset((char*)(&(pkt_bfield.Data)),0,128);
1362         pkt_bfield.Length=pkt_len-13;
1363
1364         if(check_col(pinfo->cinfo,COL_PROTOCOL))
1365                 col_set_str(pinfo->cinfo, COL_PROTOCOL,"DECT");
1366
1367         /* Clear out stuff in the info column */
1368         if(check_col(pinfo->cinfo,COL_INFO))
1369         {
1370                 col_clear(pinfo->cinfo,COL_INFO);
1371         }
1372         if(tree)
1373         {
1374                 proto_item *ti          =NULL;
1375                 proto_item *typeti      =NULL;
1376                 proto_tree *DectTree    =NULL;
1377                 gint offset             =0;
1378
1379                 ti=proto_tree_add_item(tree,proto_dect,tvb,0,-1,FALSE);
1380
1381                 DectTree=proto_item_add_subtree(ti,ett_dect);
1382                 proto_tree_add_item(DectTree,hf_dect_transceivermode,tvb,offset,1,FALSE);
1383                 offset++;
1384
1385                 proto_tree_add_item(DectTree,hf_dect_channel,tvb,offset,1,FALSE);
1386                 offset++;
1387
1388                 proto_tree_add_item(DectTree,hf_dect_slot,tvb,offset,2,FALSE);
1389                 offset+=2;
1390
1391                 proto_tree_add_item(DectTree,hf_dect_framenumber,tvb,offset,1,FALSE);
1392                 offset++;
1393
1394                 proto_tree_add_item(DectTree,hf_dect_rssi,tvb,offset,1,FALSE);
1395                 offset++;
1396
1397                 proto_tree_add_item(DectTree,hf_dect_preamble,tvb,offset,3,FALSE);
1398                 offset+=3;
1399
1400                 typeti=proto_tree_add_item(DectTree,hf_dect_type,tvb,offset,2,FALSE);
1401
1402                 type=tvb_get_ntohs(tvb, offset);
1403                 offset+=2;
1404
1405                 switch(type) {
1406                 case 0x1675:
1407                         if(check_col(pinfo->cinfo,COL_PROTOCOL))
1408                         {
1409                                 col_set_str(pinfo->cinfo,COL_PROTOCOL,"DECT PP");
1410                         }
1411                         proto_item_append_text(typeti,"  Phone Packet");
1412                         dissect_decttype(0,&pkt_afield,&pkt_bfield,pinfo,pkt_ptr,tvb,ti,DectTree);
1413                         break;
1414                 case 0xe98a:
1415                         if(check_col(pinfo->cinfo,COL_PROTOCOL))
1416                         {
1417                                 col_set_str(pinfo->cinfo,COL_PROTOCOL,"DECT RFP");
1418                         }
1419                         proto_item_append_text(typeti,"  Station Packet");
1420                         dissect_decttype(1,&pkt_afield,&pkt_bfield,pinfo,pkt_ptr,tvb,ti,DectTree);
1421                         break;
1422                 default:
1423                         if(check_col(pinfo->cinfo,COL_PROTOCOL))
1424                         {
1425                                 col_set_str(pinfo->cinfo,COL_PROTOCOL,"DECT Unk");
1426                         }
1427                         proto_item_append_text(typeti,"  Unknown Packet");
1428                         break;
1429                 }
1430         }
1431 }
1432
1433 void
1434 proto_register_dect(void)
1435 {
1436         static hf_register_info hf[]=
1437         {
1438                 { &hf_dect_transceivermode,
1439                 {"Tranceiver-Mode","dect.tranceivermode",FT_UINT8,BASE_HEX,VALS(tranceiver_mode),
1440                         0x0,NULL,HFILL}},
1441
1442                 { &hf_dect_channel,
1443                 {"Channel","dect.channel",FT_UINT8,BASE_DEC,NULL,
1444                         0x0,NULL,HFILL}},
1445
1446                 { &hf_dect_framenumber,
1447                 {"Frame#","dect.framenumber",FT_UINT16,BASE_DEC,NULL,
1448                         0x0,NULL,HFILL}},
1449
1450                 { &hf_dect_rssi,
1451                 {"RSSI","dect.rssi",FT_UINT8,BASE_DEC,NULL,
1452                         0x0,NULL,HFILL}},
1453
1454                 { &hf_dect_slot,
1455                 {"Slot","dect.slot",FT_UINT16,BASE_DEC,NULL,
1456                         0x0,NULL,HFILL}},
1457
1458                 { &hf_dect_preamble,
1459                 {"Preamble","dect.preamble",FT_BYTES,BASE_NONE,NULL,
1460                         0x0,NULL,HFILL}},
1461
1462                 { &hf_dect_type,
1463                 {"Packet-Type","dect.type",FT_BYTES,BASE_NONE,NULL,
1464                         0x0,NULL,HFILL}},
1465
1466         /* **************** A-Field ******************************/
1467         /* *****  Header  ***** */
1468                 { &hf_dect_A,
1469                 {"A-Field","dect.afield", FT_UINT8, BASE_DEC, NULL,
1470                         0x0,NULL, HFILL}},
1471
1472                 { &hf_dect_A_Head,
1473                 {"A-Field Header","dect.afield.head",FT_UINT8,BASE_DEC, NULL,
1474                         0x0,NULL,HFILL}},
1475
1476                 { &hf_dect_A_Head_TA,
1477                 {"TA","dect.afield.head.TA",FT_UINT8,BASE_DEC,VALS(TA_vals),
1478                         0xE0,NULL,HFILL}},
1479
1480                 { &hf_dect_A_Head_Q1,
1481                 {"Q1","dect.afield.head.Q1",FT_UINT8,BASE_DEC,NULL,
1482                         0x10,NULL,HFILL}},
1483
1484                 { &hf_dect_A_Head_BA,
1485                 {"BA","dect.afield.head.BA",FT_UINT8,BASE_DEC,VALS(BA_vals),
1486                         0x0E,NULL,HFILL}},
1487
1488                 { &hf_dect_A_Head_Q2,
1489                 {"Q2","dect.afield.head.Q2",FT_UINT8,BASE_DEC,NULL,
1490                         0x01,NULL,HFILL}},
1491
1492         /* *****   Tail   ***** */
1493                 { &hf_dect_A_Tail,
1494                 {"A-Field Tail","dect.afield.tail",FT_UINT8,BASE_DEC, NULL,
1495                         0x0,NULL,HFILL}},
1496
1497         /* Nt */
1498                 { &hf_dect_A_Tail_Nt,
1499                 {"A-Field Header","dect.afield.tail.Nt",FT_UINT8,BASE_DEC, NULL,
1500                         0x0,NULL,HFILL}},
1501
1502         /* Qt */
1503                 { &hf_dect_A_Tail_Qt_Qh,
1504                 {"Qh","dect.afield.tail.Qt.Qh",FT_UINT8,BASE_DEC,VALS(QTHead_vals),
1505                         0xF0,NULL,HFILL}},
1506
1507         /* Qt Static System Information */
1508         /* Byte 0 */
1509                 { &hf_dect_A_Tail_Qt_0_Nr,
1510                 {"NR","dect.afield.tail.Qt.NR",FT_UINT8,BASE_DEC,VALS(QTNormalReverse_vals),
1511                         0x10,NULL,HFILL}},
1512
1513                 { &hf_dect_A_Tail_Qt_0_Sn,
1514                 {"SN","dect.afield.tail.Qt.SN",FT_UINT8,BASE_DEC,VALS(QTSlotNumber_vals),
1515                         0x0F,NULL,HFILL}},
1516
1517         /* Byte 1 */
1518                 { &hf_dect_A_Tail_Qt_0_Sp,
1519                 {"SP","dect.afield.tail.Qt.SP",FT_UINT8,BASE_DEC,VALS(QTStartPosition_vals),
1520                         0xC0,NULL,HFILL}},
1521
1522                 { &hf_dect_A_Tail_Qt_0_Esc,
1523                 {"Esc","dect.afield.tail.Qt.Esc",FT_UINT8,BASE_DEC,VALS(QTEscape_vals),
1524                         0x20,NULL,HFILL}},
1525
1526                 { &hf_dect_A_Tail_Qt_0_Txs,
1527                 {"Txs","dect.afield.tail.Qt.Txs",FT_UINT8,BASE_DEC,VALS(QTTranceiver_vals),
1528                         0x18,NULL,HFILL}},
1529
1530                 { &hf_dect_A_Tail_Qt_0_Mc,
1531                 {"Mc","dect.afield.tail.Qt.Mc",FT_UINT8,BASE_DEC,VALS(QTExtendedCarrier_vals),
1532                         0x04,NULL,HFILL}},
1533
1534         /* Byte 3 */
1535                 { &hf_dect_A_Tail_Qt_0_Spr1,
1536                 {"Spr","dect.afield.tail.Qt.Spr1",FT_UINT8,BASE_DEC,VALS(QTSpr_vals),
1537                         0xC0,NULL,HFILL}},
1538
1539                 { &hf_dect_A_Tail_Qt_0_Cn,
1540                 {"CN","dect.afield.tail.Qt.CN",FT_UINT8,BASE_DEC,VALS(QTCarrierNumber_vals),
1541                         0x3F,NULL,HFILL}},
1542
1543         /* Byte 4 */
1544                 { &hf_dect_A_Tail_Qt_0_Spr2,
1545                 {"Spr","dect.afield.tail.Qt.Spr2",FT_UINT8,BASE_DEC,VALS(QTSpr_vals),
1546                         0xC0,NULL,HFILL}},
1547
1548                 { &hf_dect_A_Tail_Qt_0_PSCN,
1549                 {"PSCN","dect.afield.tail.Qt.PSCN",FT_UINT8,BASE_DEC,VALS(QTScanCarrierNum_vals),
1550                         0x3F,NULL,HFILL}},
1551
1552         /* Qt Fixed Part Capabilities */
1553                 { &hf_dect_A_Tail_Qt_3_A12,
1554                 {"A12","dect.afield.tail.Qt.Fp.A12",FT_UINT8,BASE_DEC,VALS(Qt_A12_vals),
1555                         0x08,NULL,HFILL}},
1556
1557                 { &hf_dect_A_Tail_Qt_3_A13,
1558                 {"A13","dect.afield.tail.Qt.Fp.A13",FT_UINT8,BASE_DEC,VALS(Qt_A13_vals),
1559                         0x04,NULL,HFILL}},
1560
1561                 { &hf_dect_A_Tail_Qt_3_A14,
1562                 {"A14","dect.afield.tail.Qt.Fp.A14",FT_UINT8,BASE_DEC,VALS(Qt_A14_vals),
1563                         0x02,NULL,HFILL}},
1564
1565                 { &hf_dect_A_Tail_Qt_3_A15,
1566                 {"A15","dect.afield.tail.Qt.Fp.A15",FT_UINT8,BASE_DEC,VALS(Qt_A15_vals),
1567                         0x01,NULL,HFILL}},
1568
1569                 { &hf_dect_A_Tail_Qt_3_A16,
1570                 {"A16","dect.afield.tail.Qt.Fp.A16",FT_UINT8,BASE_DEC,VALS(Qt_A16_vals),
1571                         0x80,NULL,HFILL}},
1572
1573                 { &hf_dect_A_Tail_Qt_3_A17,
1574                 {"A17","dect.afield.tail.Qt.Fp.A17",FT_UINT8,BASE_DEC,VALS(Qt_A17_vals),
1575                         0x40,NULL,HFILL}},
1576
1577                 { &hf_dect_A_Tail_Qt_3_A18,
1578                 {"A18","dect.afield.tail.Qt.Fp.A18",FT_UINT8,BASE_DEC,VALS(Qt_A18_vals),
1579                         0x20,NULL,HFILL}},
1580
1581                 { &hf_dect_A_Tail_Qt_3_A19,
1582                 {"A19","dect.afield.tail.Qt.Fp.A19",FT_UINT8,BASE_DEC,VALS(Qt_A19_vals),
1583                         0x10,NULL,HFILL}},
1584
1585                 { &hf_dect_A_Tail_Qt_3_A20,
1586                 {"A20","dect.afield.tail.Qt.Fp.A20",FT_UINT8,BASE_DEC,VALS(Qt_A20_vals),
1587                         0x08,NULL,HFILL}},
1588
1589                 { &hf_dect_A_Tail_Qt_3_A21,
1590                 {"A21","dect.afield.tail.Qt.Fp.A21",FT_UINT8,BASE_DEC,VALS(Qt_A21_vals),
1591                         0x04,NULL,HFILL}},
1592
1593                 { &hf_dect_A_Tail_Qt_3_A22,
1594                 {"A22","dect.afield.tail.Qt.Fp.A22",FT_UINT8,BASE_DEC,VALS(Qt_A22_vals),
1595                         0x02,NULL,HFILL}},
1596
1597                 { &hf_dect_A_Tail_Qt_3_A23,
1598                 {"A23","dect.afield.tail.Qt.Fp.A23",FT_UINT8,BASE_DEC,VALS(Qt_A23_vals),
1599                         0x01,NULL,HFILL}},
1600
1601                 { &hf_dect_A_Tail_Qt_3_A24,
1602                 {"A24","dect.afield.tail.Qt.Fp.A24",FT_UINT8,BASE_DEC,VALS(Qt_A24_vals),
1603                         0x80,NULL,HFILL}},
1604
1605                 { &hf_dect_A_Tail_Qt_3_A25,
1606                 {"A25","dect.afield.tail.Qt.Fp.A25",FT_UINT8,BASE_DEC,VALS(Qt_A25_vals),
1607                         0x40,NULL,HFILL}},
1608
1609                 { &hf_dect_A_Tail_Qt_3_A26,
1610                 {"A26","dect.afield.tail.Qt.Fp.A26",FT_UINT8,BASE_DEC,VALS(Qt_A26_vals),
1611                         0x20,NULL,HFILL}},
1612
1613                 { &hf_dect_A_Tail_Qt_3_A27,
1614                 {"A27","dect.afield.tail.Qt.Fp.A27",FT_UINT8,BASE_DEC,VALS(Qt_A27_vals),
1615                         0x10,NULL,HFILL}},
1616
1617                 { &hf_dect_A_Tail_Qt_3_A28,
1618                 {"A28","dect.afield.tail.Qt.Fp.A28",FT_UINT8,BASE_DEC,VALS(Qt_A28_vals),
1619                         0x08,NULL,HFILL}},
1620
1621                 { &hf_dect_A_Tail_Qt_3_A29,
1622                 {"A29","dect.afield.tail.Qt.Fp.A29",FT_UINT8,BASE_DEC,VALS(Qt_A29_vals),
1623                         0x04,NULL,HFILL}},
1624
1625                 { &hf_dect_A_Tail_Qt_3_A30,
1626                 {"A30","dect.afield.tail.Qt.Fp.A30",FT_UINT8,BASE_DEC,VALS(Qt_A30_vals),
1627                         0x02,NULL,HFILL}},
1628
1629                 { &hf_dect_A_Tail_Qt_3_A31,
1630                 {"A31","dect.afield.tail.Qt.Fp.A31",FT_UINT8,BASE_DEC,VALS(Qt_A31_vals),
1631                         0x01,NULL,HFILL}},
1632
1633         /* Mt */
1634                 { &hf_dect_A_Tail_Mt_Mh,
1635                 {"Mh","dect.afield.tail.Mt.Mh",FT_UINT8,BASE_DEC,VALS(MTHead_vals),
1636                         0xF0,NULL,HFILL}},
1637
1638         /* Mt Basic Connection Control */
1639                 { &hf_dect_A_Tail_Mt_BasicConCtrl,
1640                 {"Cmd","dect.afield.tail.Mt.BasicConCtrl",FT_UINT8,BASE_DEC,VALS(MTBasicConCtrl_vals),
1641                         0x0F,NULL,HFILL}},
1642
1643         /* Mt Encryption Control */
1644                 { &hf_dect_A_Tail_Mt_Encr_Cmd1,
1645                 {"Cmd1","dect.afield.tail.Mt.Encr.Cmd1",FT_UINT8,BASE_DEC,VALS(MTEncrCmd1_vals),
1646                         0x0C,NULL,HFILL}},
1647
1648                 { &hf_dect_A_Tail_Mt_Encr_Cmd2,
1649                 {"Cmd2","dect.afield.tail.Mt.Encr.Cmd2",FT_UINT8,BASE_DEC,VALS(MTEncrCmd2_vals),
1650                         0x03, NULL, HFILL}},
1651
1652         /* Pt */
1653                 { &hf_dect_A_Tail_Pt_ExtFlag,
1654                 {"ExtFlag","dect.afield.tail.Pt.ExtFlag",FT_UINT8,BASE_DEC,VALS(PTExtFlag_vals),
1655                         0x80, NULL, HFILL}},
1656
1657                 { &hf_dect_A_Tail_Pt_SDU,
1658                 {"SDU","dect.afield.tail.Pt.SDU",FT_UINT8,BASE_DEC,VALS(PTSDU_vals),
1659                         0x70, NULL, HFILL}},
1660
1661                 { &hf_dect_A_Tail_Pt_InfoType,
1662                 {"InfoType","dect.afield.tail.Pt.InfoType",FT_UINT8,BASE_DEC,VALS(PTInfoType_vals),
1663                         0xF0, NULL, HFILL}},
1664
1665                 { &hf_dect_A_Tail_Pt_Fill_Fillbits,
1666                 {"FillBits","dect.afield.tail.Pt.InfoType.FillBits",FT_UINT8,BASE_DEC,NULL,
1667                         0x0, NULL, HFILL}},
1668
1669                 { &hf_dect_A_Tail_Pt_Bearer_Sn,
1670                 {"SN","dect.afield.tail.Pt.SN",FT_UINT8,BASE_DEC,VALS(QTSlotNumber_vals),
1671                         0x0F,NULL,HFILL}},
1672
1673                 { &hf_dect_A_Tail_Pt_Bearer_Sp,
1674                 {"SP","dect.afield.tail.Pt.SP",FT_UINT8,BASE_DEC,VALS(QTStartPosition_vals),
1675                         0xC0, NULL, HFILL}},
1676
1677                 { &hf_dect_A_Tail_Pt_Bearer_Cn,
1678                 {"CN", "dect.afield.tail.Pt.CN", FT_UINT8,BASE_DEC,VALS(QTCarrierNumber_vals),
1679                         0x3F, NULL, HFILL}},
1680
1681         /* *****   R-CRC  ***** */
1682                 { &hf_dect_A_RCRC,
1683                 {"A-Field R-CRC", "dect.afield.rcrc", FT_UINT8, BASE_DEC, NULL,
1684                         0x0, NULL, HFILL}}, 
1685
1686         /* ***************** B-Field *************************** */
1687                 { &hf_dect_B,
1688                 {"B-Field", "dect.bfield", FT_UINT8, BASE_DEC,
1689                         NULL, 0x0,NULL, HFILL}},
1690
1691                 { &hf_dect_B_Data,
1692                 {"B-Field","dect.bfield.data", FT_UINT8, BASE_DEC, NULL,
1693                         0x0, NULL, HFILL}},
1694
1695         /* *****   X-CRC  ***** */
1696                 { &hf_dect_B_XCRC,
1697                 {"B-Field X-CRC", "dect.bfield.xcrc", FT_UINT8,BASE_DEC, NULL,
1698                         0x0, NULL, HFILL}}
1699         };
1700
1701
1702         /* Setup protocol subtree array */
1703         static gint *ett[]=
1704         {
1705                 &ett_dect,
1706                 &ett_ahead,
1707                 &ett_afield,
1708                 &ett_atail,
1709                 &ett_aqt,
1710                 &ett_bfield
1711         };
1712
1713         proto_dect=proto_register_protocol("DECT Protocol","DECT","dect");
1714         proto_register_field_array(proto_dect,hf,array_length(hf));
1715         proto_register_subtree_array(ett,array_length(ett));
1716 }
1717
1718 void
1719 proto_reg_handoff_dect(void)
1720 {
1721         dissector_handle_t dect_handle;
1722
1723         dect_handle = create_dissector_handle(dissect_dect,proto_dect);
1724         dissector_add("ethertype",ETHERTYPE_DECT ,dect_handle);
1725 }
1726