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