proto_80211_mac_hdr: fix compilation on powerpc
[netsniff-ng.git] / src / proto_80211_mac_hdr.c
blob024f0dad2d7c3afeb8ebf7fb787b08e8ea7e25be
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>
4 * Copyright 2012 Daniel Borkmann <daniel@netsniff-ng.org>
5 * Subject to the GPL, version 2.
6 */
8 /* TODO
9 * check all possible frame combinations for their behavior
10 * with respect to endianess (little / big)
13 #include <stdio.h>
14 #include <stdint.h>
15 #include <netinet/in.h> /* for ntohs() */
16 #include <asm/byteorder.h>
17 #include <arpa/inet.h> /* for inet_ntop() */
19 #include "proto.h"
20 #include "protos.h"
21 #include "dissector_80211.h"
22 #include "built_in.h"
23 #include "pkt_buff.h"
24 #include "oui.h"
26 #define TU 0.001024
28 /* Note: Fields are encoded in little-endian! */
29 struct ieee80211_frm_ctrl {
30 union {
31 u16 frame_control;
32 struct {
33 #if defined(__LITTLE_ENDIAN_BITFIELD)
34 /* Correct order here ... */
35 __extension__ u16 proto_version:2,
36 type:2,
37 subtype:4,
38 to_ds:1,
39 from_ds:1,
40 more_frags:1,
41 retry:1,
42 power_mgmt:1,
43 more_data:1,
44 wep:1,
45 order:1;
46 #elif defined(__BIG_ENDIAN_BITFIELD)
47 __extension__ u16 subtype:4,
48 type:2,
49 proto_version:2,
50 order:1,
51 wep:1,
52 more_data:1,
53 power_mgmt:1,
54 retry:1,
55 more_frags:1,
56 from_ds:1,
57 to_ds:1;
58 #else
59 # error "Adjust your <asm/byteorder.h> defines"
60 #endif
63 } __packed;
65 /* Management Frame start */
66 /* Note: Fields are encoded in little-endian! */
67 struct ieee80211_mgmt {
68 u16 duration;
69 u8 da[6];
70 u8 sa[6];
71 u8 bssid[6];
72 u16 seq_ctrl;
73 } __packed;
75 struct ieee80211_mgmt_auth {
76 u16 auth_alg;
77 u16 auth_transaction;
78 u16 status_code;
79 /* possibly followed by Challenge text */
80 u8 variable[0];
81 } __packed;
83 struct ieee80211_mgmt_deauth {
84 u16 reason_code;
85 } __packed;
87 struct ieee80211_mgmt_assoc_req {
88 u16 capab_info;
89 u16 listen_interval;
90 /* followed by SSID and Supported rates */
91 u8 variable[0];
92 } __packed;
94 struct ieee80211_mgmt_assoc_resp {
95 u16 capab_info;
96 u16 status_code;
97 u16 aid;
98 /* followed by Supported rates */
99 u8 variable[0];
100 } __packed;
102 struct ieee80211_mgmt_reassoc_resp {
103 u16 capab_info;
104 u16 status_code;
105 u16 aid;
106 /* followed by Supported rates */
107 u8 variable[0];
108 } __packed;
110 struct ieee80211_mgmt_reassoc_req {
111 u16 capab_info;
112 u16 listen_interval;
113 u8 current_ap[6];
114 /* followed by SSID and Supported rates */
115 u8 variable[0];
116 } __packed;
118 struct ieee80211_mgmt_disassoc {
119 u16 reason_code;
120 } __packed;
122 struct ieee80211_mgmt_probe_req {
123 } __packed;
125 struct ieee80211_mgmt_beacon {
126 u64 timestamp;
127 u16 beacon_int;
128 u16 capab_info;
129 /* followed by some of SSID, Supported rates,
130 * FH Params, DS Params, CF Params, IBSS Params, TIM */
131 u8 variable[0];
132 } __packed;
134 struct ieee80211_mgmt_probe_resp {
135 u8 timestamp[8];
136 u16 beacon_int;
137 u16 capab_info;
138 /* followed by some of SSID, Supported rates,
139 * FH Params, DS Params, CF Params, IBSS Params, TIM */
140 u8 variable[0];
141 } __packed;
142 /* Management Frame end */
144 /* Control Frame start */
145 /* Note: Fields are encoded in little-endian! */
146 struct ieee80211_ctrl {
147 } __packed;
149 struct ieee80211_ctrl_rts {
150 u16 duration;
151 u8 da[6];
152 u8 sa[6];
153 } __packed;
155 struct ieee80211_ctrl_cts {
156 u16 duration;
157 u8 da[6];
158 } __packed;
160 struct ieee80211_ctrl_ack {
161 u16 duration;
162 u8 da[6];
163 } __packed;
165 struct ieee80211_ctrl_ps_poll {
166 u16 aid;
167 u8 bssid[6];
168 u8 sa[6];
169 } __packed;
171 struct ieee80211_ctrl_cf_end {
172 u16 duration;
173 u8 bssid[6];
174 u8 sa[6];
175 } __packed;
177 struct ieee80211_ctrl_cf_end_ack {
178 u16 duration;
179 u8 bssid[6];
180 u8 sa[6];
181 } __packed;
182 /* Control Frame end */
184 /* Data Frame start */
185 /* Note: Fields are encoded in little-endian! */
186 struct ieee80211_data {
187 } __packed;
189 /* TODO: Extend */
190 /* Data Frame end */
192 struct element_reserved {
193 u8 len;
194 } __packed;
196 struct element_ssid {
197 u8 len;
198 u8 SSID[0];
199 } __packed;
201 struct element_supp_rates {
202 u8 len;
203 u8 SSID[0];
204 } __packed;
206 struct element_fh_ps {
207 u8 len;
208 u16 dwell_time;
209 u8 hop_set;
210 u8 hop_pattern;
211 u8 hop_index;
212 } __packed;
214 struct element_dsss_ps {
215 u8 len;
216 u8 curr_ch;
217 } __packed;
219 struct element_cf_ps {
220 u8 len;
221 u8 cfp_cnt;
222 u8 cfp_period;
223 u16 cfp_max_dur;
224 u16 cfp_dur_rem;
225 } __packed;
227 struct element_tim {
228 u8 len;
229 u8 dtim_cnt;
230 u8 dtim_period;
231 u8 bmp_cntrl;
232 u8 part_virt_bmp[0];
233 } __packed;
235 struct element_ibss_ps {
236 u8 len;
237 u16 atim_win;
238 } __packed;
240 struct element_country_tripled {
241 u8 frst_ch;
242 u8 nr_ch;
243 u8 max_trans;
244 } __packed;
246 struct element_country {
247 u8 len;
248 #if defined(__LITTLE_ENDIAN_BITFIELD)
249 /* Correct order here ... */
250 u8 country_first;
251 u8 country_sec;
252 u8 country_third;
253 #elif defined(__BIG_ENDIAN_BITFIELD)
254 u8 country_third;
255 u8 country_sec;
256 u8 country_first;
257 #else
258 # error "Adjust your <asm/byteorder.h> defines"
259 #endif
260 /* triplet may repeat */
261 struct element_country_tripled tripled [0];
262 /* end triplet */
263 u8 pad[0];
264 } __packed;
266 struct element_hop_pp {
267 u8 len;
268 u8 prime_radix;
269 u8 nr_ch;
270 } __packed;
272 struct element_hop_pt {
273 u8 len;
274 u8 flag;
275 u8 nr_sets;
276 u8 modules;
277 u8 offs;
278 u8 rand_tabl[0];
279 } __packed;
281 struct element_req {
282 u8 len;
283 u8 req_elem_idl[0];
284 } __packed;
286 struct element_bss_load {
287 u8 len;
288 u16 station_cnt;
289 u8 ch_util;
290 u16 avlb_adm_cap;
291 } __packed;
293 struct element_edca_ps {
294 u8 len;
295 u8 qos_inf;
296 u8 res;
297 u32 ac_be;
298 u32 ac_bk;
299 u32 ac_vi;
300 u32 ac_vo;
301 } __packed;
303 struct element_tspec {
304 union {
305 u32 len_ts_info;
306 struct {
307 #if defined(__LITTLE_ENDIAN_BITFIELD)
308 /* Correct order here ... */
309 __extension__ u32 len:8,
310 traffic_type:1,
311 tsid:4,
312 direction:2,
313 access_policy:2,
314 aggr:1,
315 apsid:1,
316 user_prior:3,
317 tsinfo_ack_pol:2,
318 schedule:1,
319 res:7;
320 #elif defined(__BIG_ENDIAN_BITFIELD)
321 __extension__ u32 len:8,
322 res:7,
323 schedule:1,
324 tsinfo_ack_pol:2,
325 user_prior:3,
326 apsid:1,
327 aggr:1,
328 access_policy:2,
329 direction:2,
330 tsid:4,
331 traffic_type:1;
332 #else
333 # error "Adjust your <asm/byteorder.h> defines"
334 #endif
337 u16 nom_msdu_size;
338 u16 max_msdu_size;
339 u32 min_srv_intv;
340 u32 max_srv_intv;
341 u32 inactive_intv;
342 u32 susp_intv;
343 u32 srv_start_time;
344 u32 min_data_rate;
345 u32 mean_data_rate;
346 u32 peak_data_rate;
347 u32 burst_size;
348 u32 delay_bound;
349 u32 min_phy_rate;
350 u16 surplus_bandw_allow;
351 u16 med_time;
352 } __packed;
354 struct element_tclas {
355 u8 len;
356 u8 user_priority;
357 u8 frm_class[0];
358 } __packed;
360 struct element_tclas_frm_class {
361 u8 type;
362 u8 mask;
363 u8 param[0];
364 } __packed;
366 struct element_tclas_type0 {
367 u8 sa[6];
368 u8 da[6];
369 u16 type;
370 } __packed;
372 struct element_tclas_type1 {
373 u8 version;
374 u8 subparam[0];
375 } __packed;
377 struct element_tclas_type1_ip4 {
378 u32 sa;
379 u32 da;
380 u16 sp;
381 u16 dp;
382 u8 dscp;
383 u8 proto;
384 u8 reserved;
385 } __packed;
387 struct element_tclas_type1_ip6 {
388 struct in6_addr sa;
389 struct in6_addr da;
390 u16 sp;
391 u16 dp;
392 union {
393 u8 flow_label[3];
394 struct {
395 #if defined(__LITTLE_ENDIAN_BITFIELD)
396 __extension__ u8 flow_label3:8;
397 __extension__ u8 flow_label2:8;
398 __extension__ u8 flow_label1:8;
399 #elif defined(__BIG_ENDIAN_BITFIELD)
400 __extension__ u8 flow_label1:8;
401 __extension__ u8 flow_label2:8;
402 __extension__ u8 flow_label3:8;
403 #else
404 # error "Adjust your <asm/byteorder.h> defines"
405 #endif
408 } __packed;
410 struct element_tclas_type2 {
411 u16 vlan_tci;
412 } __packed;
414 struct element_tclas_type3 {
415 u16 offs;
416 u8 value[0];
417 u8 mask[0];
418 } __packed;
420 struct element_tclas_type4 {
421 u8 version;
422 u8 subparam[0];
423 } __packed;
425 struct element_tclas_type4_ip4 {
426 u32 sa;
427 u32 da;
428 u16 sp;
429 u16 dp;
430 u8 dscp;
431 u8 proto;
432 u8 reserved;
433 } __packed;
435 struct element_tclas_type4_ip6 {
436 struct in6_addr sa;
437 struct in6_addr da;
438 u16 sp;
439 u16 dp;
440 u8 dscp;
441 u8 nxt_hdr;
442 union {
443 u8 flow_label[3];
444 struct {
445 #if defined(__LITTLE_ENDIAN_BITFIELD)
446 __extension__ u8 flow_label3:8;
447 __extension__ u8 flow_label2:8;
448 __extension__ u8 flow_label1:8;
449 #elif defined(__BIG_ENDIAN_BITFIELD)
450 __extension__ u8 flow_label1:8;
451 __extension__ u8 flow_label2:8;
452 __extension__ u8 flow_label3:8;
453 #else
454 # error "Adjust your <asm/byteorder.h> defines"
455 #endif
458 } __packed;
460 struct element_tclas_type5 {
461 u8 pcp;
462 u8 cfi;
463 u8 vid;
464 } __packed;
466 struct element_schedule {
467 u8 len;
468 u16 inf;
469 u32 start;
470 u32 serv_intv;
471 u16 spec_intv;
472 } __packed;
474 struct element_chall_txt {
475 u8 len;
476 u8 chall_txt[0];
477 } __packed;
479 struct element_pwr_constr {
480 u8 len;
481 u8 local_pwr_constr;
482 } __packed;
484 struct element_pwr_cap {
485 u8 len;
486 u8 min_pwr_cap;
487 u8 max_pwr_cap;
488 } __packed;
490 struct element_tpc_req {
491 u8 len;
492 } __packed;
494 struct element_tpc_rep {
495 u8 len;
496 u8 trans_pwr;
497 u8 link_marg;
498 } __packed;
500 struct element_supp_ch {
501 u8 len;
502 u8 first_ch_nr[0];
503 u8 nr_ch[0];
504 } __packed;
506 struct element_supp_ch_tuple {
507 u8 first_ch_nr;
508 u8 nr_ch;
509 } __packed;
511 struct element_ch_sw_ann {
512 u8 len;
513 u8 switch_mode;
514 u8 new_nr;
515 u8 switch_cnt;
516 } __packed;
518 struct element_meas_basic {
519 u8 ch_nr;
520 u64 start;
521 u16 dur;
522 } __packed;
524 struct element_meas_cca {
525 u8 ch_nr;
526 u64 start;
527 u16 dur;
528 } __packed;
530 struct element_meas_rpi {
531 u8 ch_nr;
532 u64 start;
533 u16 dur;
534 } __packed;
536 struct element_meas_ch_load {
537 u8 op_class;
538 u8 ch_nr;
539 u16 rand_intv;
540 u16 dur;
541 u8 sub[0];
542 } __packed;
544 struct element_meas_noise {
545 u8 op_class;
546 u8 ch_nr;
547 u16 rand_intv;
548 u16 dur;
549 u8 sub[0];
550 } __packed;
552 struct element_meas_beacon {
553 u8 op_class;
554 u8 ch_nr;
555 u16 rand_intv;
556 u16 dur;
557 u8 mode;
558 u8 bssid[6];
559 u8 sub[0];
560 } __packed;
562 struct element_meas_frame {
563 u8 op_class;
564 u8 ch_nr;
565 u16 rand_intv;
566 u16 dur;
567 u8 frame;
568 u8 mac[6];
569 u8 sub[0];
570 } __packed;
572 struct element_meas_sta {
573 u8 peer_mac[6];
574 u16 rand_intv;
575 u16 dur;
576 u8 group_id;
577 u8 sub[0];
578 } __packed;
580 struct element_meas_lci {
581 u8 loc_subj;
582 u8 latitude_req_res;
583 u8 longitude_req_res;
584 u8 altitude_req_res;
585 u8 sub[0];
586 } __packed;
588 struct element_meas_trans_str_cat {
589 u16 rand_intv;
590 u16 dur;
591 u8 peer_sta_addr[6];
592 u8 traffic_id;
593 u8 bin_0_range;
594 u8 sub[0];
595 } __packed;
597 struct element_meas_mcast_diag {
598 u16 rand_intv;
599 u16 dur;
600 u8 group_mac[6];
601 u8 mcast_triggered[0];
602 u8 sub[0];
603 } __packed;
605 struct element_meas_loc_civic {
606 u8 loc_subj;
607 u8 civic_loc;
608 u8 loc_srv_intv_unit;
609 u16 loc_srv_intv;
610 u8 sub[0];
611 } __packed;
613 struct element_meas_loc_id {
614 u8 loc_subj;
615 u8 loc_srv_intv_unit;
616 u16 loc_srv_intv;
617 u8 sub[0];
618 } __packed;
620 struct element_meas_pause {
621 u8 time;
622 u8 sub[0];
623 } __packed;
625 struct element_meas_req {
626 u8 len;
627 u8 token;
628 u8 req_mode;
629 u8 type;
630 u8 req[0];
631 } __packed;
633 struct element_meas_rep {
634 u8 len;
635 u8 token;
636 u8 rep_mode;
637 u8 type;
638 u8 rep[0];
639 } __packed;
641 struct element_quiet {
642 u8 len;
643 u8 cnt;
644 u8 period;
645 u16 dur;
646 u16 offs;
647 } __packed;
649 struct element_ibss_dfs {
650 u8 len;
651 u8 owner[6];
652 u8 rec_intv;
653 u8 ch_map[0];
654 } __packed;
656 struct element_ibss_dfs_tuple {
657 u8 ch_nr;
658 u8 map;
659 } __packed;
661 struct element_erp {
662 u8 len;
663 u8 param;
664 } __packed;
666 struct element_ts_del {
667 u8 len;
668 u32 delay;
669 } __packed;
671 struct element_tclas_proc {
672 u8 len;
673 u8 proc;
674 } __packed;
676 struct element_ht_cap {
677 u8 len;
678 union {
679 u16 info;
680 struct {
681 #if defined(__LITTLE_ENDIAN_BITFIELD)
682 /* Correct order here ... */
683 __extension__ u16 ldpc:1,
684 supp_width:1,
685 sm_pwr:2,
686 ht_green:1,
687 gi_20mhz:1,
688 gi_40mhz:1,
689 tx_stbc:1,
690 rx_stbc:2,
691 ht_ack:1,
692 max_msdu_length:1,
693 dsss_ck_mode:1,
694 res:1,
695 forty_int:1,
696 prot_supp:1;
697 #elif defined(__BIG_ENDIAN_BITFIELD)
698 __extension__ u16 rx_stbc:2,
699 ht_ack:1,
700 max_msdu_length:1,
701 dsss_ck_mode:1,
702 res:1,
703 forty_int:1,
704 prot_supp:1,
705 ldpc:1,
706 supp_width:1,
707 sm_pwr:2,
708 ht_green:1,
709 gi_20mhz:1,
710 gi_40mhz:1,
711 tx_stbc:1;
712 #else
713 # error "Adjust your <asm/byteorder.h> defines"
714 #endif
717 u8 param;
718 union {
719 u8 mcs_set[16];
720 struct {
721 #if defined(__LITTLE_ENDIAN_BITFIELD)
722 /* Correct order here ... */
723 __extension__ u8 bitmask1:8;
724 __extension__ u8 bitmask2:8;
725 __extension__ u8 bitmask3:8;
726 __extension__ u8 bitmask4:8;
727 __extension__ u8 bitmask5:8;
728 __extension__ u8 bitmask6:8;
729 __extension__ u8 bitmask7:8;
730 __extension__ u8 bitmask8:8;
731 __extension__ u8 bitmask9:8;
732 __extension__ u8 bitmask10_res:8;
733 __extension__ u16 supp_rate_res:16;
734 __extension__ u32 tx_param_res:32;
736 #elif defined(__BIG_ENDIAN_BITFIELD)
737 __extension__ u32 tx_param_res:32;
738 __extension__ u16 supp_rate_res:16;
739 __extension__ u8 bitmask10_res:8;
740 __extension__ u8 bitmask9:8;
741 __extension__ u8 bitmask8:8;
742 __extension__ u8 bitmask7:8;
743 __extension__ u8 bitmask6:8;
744 __extension__ u8 bitmask5:8;
745 __extension__ u8 bitmask4:8;
746 __extension__ u8 bitmask3:8;
747 __extension__ u8 bitmask2:8;
748 __extension__ u8 bitmask1:8;
749 #else
750 # error "Adjust your <asm/byteorder.h> defines"
751 #endif
754 u16 ext_cap;
755 u32 beam_cap;
756 u8 asel_cap;
757 } __packed;
759 struct element_qos_cap {
760 u8 len;
761 u8 info;
762 } __packed;
764 struct element_ext_supp_rates {
765 u8 len;
766 u8 rates[0];
767 } __packed;
769 struct element_vend_spec {
770 u8 len;
771 u8 oui[0];
772 u8 specific[0];
773 } __packed;
775 static int8_t len_neq_error(u8 len, u8 intended)
777 if(intended != len) {
778 tprintf("Length should be %u Bytes", intended);
779 return 1;
782 return 0;
785 static int8_t len_lt_error(u8 len, u8 intended)
787 if(len < intended) {
788 tprintf("Length should be greater %u Bytes", intended);
789 return 1;
792 return 0;
795 static float data_rates(u8 id)
797 /* XXX Why not (id / 2.f)? */
798 switch (id) {
799 case 2: return 1.0f;
800 case 3: return 1.5f;
801 case 4: return 2.0f;
802 case 5: return 2.5f;
803 case 6: return 3.0f;
804 case 9: return 4.5f;
805 case 11: return 5.5f;
806 case 12: return 6.0f;
807 case 18: return 9.0f;
808 case 22: return 11.0f;
809 case 24: return 12.0f;
810 case 27: return 13.5f;
811 case 36: return 18.0f;
812 case 44: return 22.0f;
813 case 48: return 24.0f;
814 case 54: return 27.0f;
815 case 66: return 33.0f;
816 case 72: return 36.0f;
817 case 96: return 48.0f;
818 case 108: return 54.0f;
821 return 0.f;
824 struct subelement {
825 u8 id;
826 u8 len;
827 u8 data[0];
828 } __packed;
831 static int8_t subelements(struct pkt_buff *pkt, u8 len)
833 u8 i, j;
834 u8 *data;
836 for (i=0; i<len;) {
837 struct subelement *sub;
839 sub = (struct subelement *) pkt_pull(pkt, sizeof(*sub));
840 if (sub == NULL)
841 return 0;
843 tprintf(", Subelement ID %u, ", sub->id);
844 tprintf("Length %u, ", sub->len);
846 data = pkt_pull(pkt, sub->len);
847 if (data == NULL)
848 return 0;
850 tprintf("Data: 0x");
851 for(j=0; j < sub->len; j++)
852 tprintf("%.2x ", data[j]);
854 i += sub->len + 1;
857 if (i != len) {
858 tprintf("Length error");
859 return 0;
862 return 1;
865 static int8_t inf_reserved(struct pkt_buff *pkt, u8 *id)
867 u8 i;
868 u8 *data;
869 struct element_reserved *reserved;
871 reserved = (struct element_reserved *) pkt_pull(pkt, sizeof(*reserved));
872 if (reserved == NULL)
873 return 0;
875 tprintf("Reserved (%u, Len (%u)): ", *id, reserved->len);
877 data = pkt_pull(pkt, reserved->len);
878 if (data == NULL)
879 return 0;
881 tprintf("Data 0x");
882 for (i = 0; i < reserved->len; i++)
883 tprintf("%.2x", data[i]);
885 return 1;
888 static int8_t inf_ssid(struct pkt_buff *pkt, u8 *id)
890 u8 i;
891 struct element_ssid *ssid;
892 char *ssid_name;
894 ssid = (struct element_ssid *) pkt_pull(pkt, sizeof(*ssid));
895 if (ssid == NULL)
896 return 0;
898 tprintf(" SSID (%u, Len (%u)): ", *id, ssid->len);
900 if ((ssid->len - sizeof(*ssid) + 1) > 0) {
901 ssid_name = (char *) pkt_pull(pkt, ssid->len);
902 if (ssid_name == NULL)
903 return 0;
905 for (i = 0; i < ssid->len; i++)
906 tprintf("%c",ssid_name[i]);
907 } else {
908 tprintf("Wildcard SSID");
911 return 1;
914 static int8_t inf_supp_rates(struct pkt_buff *pkt, u8 *id)
916 u8 i;
917 u8 *rates;
918 struct element_supp_rates *supp_rates;
920 supp_rates = (struct element_supp_rates *)
921 pkt_pull(pkt, sizeof(*supp_rates));
922 if (supp_rates == NULL)
923 return 0;
925 tprintf("Rates (%u, Len (%u)): ", *id, supp_rates->len);
926 if (len_lt_error(supp_rates->len, 1))
927 return 0;
929 if ((supp_rates->len - sizeof(*supp_rates) + 1) > 0) {
930 rates = pkt_pull(pkt, supp_rates->len);
931 if (rates == NULL)
932 return 0;
934 for (i = 0; i < supp_rates->len; i++)
935 tprintf("%g ", (rates[i] & 0x80) ?
936 ((rates[i] & 0x3f) * 0.5) :
937 data_rates(rates[i]));
938 return 1;
941 return 0;
944 static int8_t inf_fh_ps(struct pkt_buff *pkt, u8 *id)
946 struct element_fh_ps *fh_ps;
948 fh_ps = (struct element_fh_ps *) pkt_pull(pkt, sizeof(*fh_ps));
949 if (fh_ps == NULL)
950 return 0;
952 tprintf("FH Param Set (%u, Len(%u)): ", *id, fh_ps->len);
953 if (len_neq_error(fh_ps->len, 5))
954 return 0;
955 tprintf("Dwell Time: %fs, ", le16_to_cpu(fh_ps->dwell_time) * TU);
956 tprintf("HopSet: %u, ", fh_ps->hop_set);
957 tprintf("HopPattern: %u, ", fh_ps->hop_pattern);
958 tprintf("HopIndex: %u", fh_ps->hop_index);
960 return 1;
963 static int8_t inf_dsss_ps(struct pkt_buff *pkt, u8 *id)
965 struct element_dsss_ps *dsss_ps;
967 dsss_ps = (struct element_dsss_ps *) pkt_pull(pkt, sizeof(*dsss_ps));
968 if (dsss_ps == NULL)
969 return 0;
971 tprintf("DSSS Param Set (%u, Len(%u)): ", *id, dsss_ps->len);
972 if (len_neq_error(dsss_ps->len, 1))
973 return 0;
974 tprintf("Current Channel: %u", dsss_ps->curr_ch);
976 return 1;
979 static int8_t inf_cf_ps(struct pkt_buff *pkt, u8 *id)
981 struct element_cf_ps *cf_ps;
983 cf_ps = (struct element_cf_ps *) pkt_pull(pkt, sizeof(*cf_ps));
984 if (cf_ps == NULL)
985 return 0;
987 tprintf("CF Param Set (%u, Len(%u)): ", *id, cf_ps->len);
988 if (len_neq_error(cf_ps->len, 6))
989 return 0;
990 tprintf("CFP Count: %u, ", cf_ps->cfp_cnt);
991 tprintf("CFP Period: %u, ", cf_ps->cfp_period);
992 tprintf("CFP MaxDur: %fs, ", le16_to_cpu(cf_ps->cfp_max_dur) * TU);
993 tprintf("CFP DurRem: %fs", le16_to_cpu(cf_ps->cfp_dur_rem) * TU);
995 return 1;
998 static int8_t inf_tim(struct pkt_buff *pkt, u8 *id)
1000 struct element_tim *tim;
1002 tim = (struct element_tim *) pkt_pull(pkt, sizeof(*tim));
1003 if (tim == NULL)
1004 return 0;
1006 tprintf("TIM (%u, Len(%u)): ", *id, tim->len);
1007 if (len_lt_error(tim->len, 3))
1008 return 0;
1009 tprintf("DTIM Count: %u, ", tim->dtim_cnt);
1010 tprintf("DTIM Period: %u, ", tim->dtim_period);
1011 tprintf("Bitmap Control: %u, ", tim->bmp_cntrl);
1012 if ((tim->len - sizeof(*tim) + 1) > 0) {
1013 u8 *bmp = pkt_pull(pkt, (tim->len - sizeof(*tim) + 1));
1014 if (bmp == NULL)
1015 return 0;
1017 tprintf("Partial Virtual Bitmap: 0x");
1018 for(u8 i=0; i < (tim->len - sizeof(*tim) + 1); i++)
1019 tprintf("%.2x ", bmp[i]);
1022 return 1;
1025 static int8_t inf_ibss_ps(struct pkt_buff *pkt, u8 *id)
1027 struct element_ibss_ps *ibss_ps;
1029 ibss_ps = (struct element_ibss_ps *) pkt_pull(pkt, sizeof(*ibss_ps));
1030 if (ibss_ps == NULL)
1031 return 0;
1033 tprintf("IBSS Param Set (%u, Len(%u)): ", *id, ibss_ps->len);
1034 if (len_neq_error(ibss_ps->len, 2))
1035 return 0;
1036 tprintf("ATIM Window: %fs", le16_to_cpu(ibss_ps->atim_win) * TU);
1038 return 1;
1041 static int8_t inf_country(struct pkt_buff *pkt, u8 *id)
1043 u8 i;
1044 u8 *pad;
1045 struct element_country *country;
1047 country = (struct element_country *) pkt_pull(pkt, sizeof(*country));
1048 if (country == NULL)
1049 return 0;
1051 tprintf("Country (%u, Len(%u)): ", *id, country->len);
1052 if (len_lt_error(country->len, 6))
1053 return 0;
1054 tprintf("Country String: %c%c%c", country->country_first,
1055 country->country_sec, country->country_third);
1057 for (i = 0; i < (country->len - 3); i += 3) {
1058 struct element_country_tripled *country_tripled;
1060 country_tripled = (struct element_country_tripled *)
1061 pkt_pull(pkt, sizeof(*country_tripled));
1062 if (country_tripled == NULL)
1063 return 0;
1065 if(country_tripled->frst_ch >= 201) {
1066 tprintf("Oper Ext ID: %u, ", country_tripled->frst_ch);
1067 tprintf("Operating Class: %u, ", country_tripled->nr_ch);
1068 tprintf("Coverage Class: %u", country_tripled->max_trans);
1069 } else {
1070 tprintf("First Ch Nr: %u, ", country_tripled->frst_ch);
1071 tprintf("Nr of Ch: %u, ", country_tripled->nr_ch);
1072 tprintf("Max Transmit Pwr Lvl: %u", country_tripled->max_trans);
1076 if(country->len % 2) {
1077 pad = pkt_pull(pkt, 1);
1078 if (pad == NULL)
1079 return 0;
1081 tprintf(", Pad: 0x%x", *pad);
1084 return 1;
1087 static int8_t inf_hop_pp(struct pkt_buff *pkt, u8 *id)
1089 struct element_hop_pp *hop_pp;
1091 hop_pp = (struct element_hop_pp *) pkt_pull(pkt, sizeof(*hop_pp));
1092 if (hop_pp == NULL)
1093 return 0;
1095 tprintf("Hopping Pattern Param (%u, Len(%u)): ", *id, hop_pp->len);
1096 if (len_neq_error(hop_pp->len, 2))
1097 return 0;
1098 tprintf("Nr of Ch: %u", hop_pp->nr_ch);
1100 return 1;
1103 static int8_t inf_hop_pt(struct pkt_buff *pkt, u8 *id)
1105 int i;
1106 u8 *rand_tabl;
1107 struct element_hop_pt *hop_pt;
1109 hop_pt = (struct element_hop_pt *) pkt_pull(pkt, sizeof(*hop_pt));
1110 if (hop_pt == NULL)
1111 return 0;
1113 tprintf("Hopping Pattern Table (%u, Len(%u)): ", *id, hop_pt->len);
1114 if (len_lt_error(hop_pt->len, 4))
1115 return 0;
1116 tprintf("Flag: %u, ", hop_pt->flag);
1117 tprintf("Nr of Sets: %u, ", hop_pt->nr_sets);
1118 tprintf("Modules: %u, ", hop_pt->modules);
1119 tprintf("Offs: %u", hop_pt->offs);
1121 if ((hop_pt->len - sizeof(*hop_pt) + 1) > 0) {
1122 rand_tabl = pkt_pull(pkt, (hop_pt->len - sizeof(*hop_pt) + 1));
1123 if (rand_tabl == NULL)
1124 return 0;
1126 tprintf(", Rand table: 0x");
1127 for (i = 0; i < (hop_pt->len - sizeof(*hop_pt) + 1); i++)
1128 tprintf("%.2x ", rand_tabl[i]);
1131 return 1;
1134 static int8_t inf_req(struct pkt_buff *pkt, u8 *id)
1136 int i;
1137 struct element_req *req;
1138 u8 *req_ids;
1140 req = (struct element_req *) pkt_pull(pkt, sizeof(*req));
1141 if (req == NULL)
1142 return 0;
1144 tprintf("Request Element (%u, Len(%u)): ", *id, req->len);
1145 if ((req->len - sizeof(*req) + 1) > 0) {
1146 req_ids = pkt_pull(pkt, (req->len - sizeof(*req) + 1));
1147 if (req_ids == NULL)
1148 return 0;
1150 tprintf(", Requested Element IDs: ");
1151 for (i = 0; i < (req->len - sizeof(*req) + 1); i++)
1152 tprintf("%u ", req_ids[i]);
1155 return 1;
1158 static int8_t inf_bss_load(struct pkt_buff *pkt, u8 *id)
1160 struct element_bss_load *bss_load;
1162 bss_load = (struct element_bss_load *) pkt_pull(pkt, sizeof(*bss_load));
1163 if (bss_load == NULL)
1164 return 0;
1166 tprintf("BSS Load element (%u, Len(%u)): ", *id, bss_load->len);
1167 if (len_neq_error(bss_load->len, 5))
1168 return 0;
1169 tprintf("Station Count: %u, ", le16_to_cpu(bss_load->station_cnt));
1170 tprintf("Channel Utilization: %u, ", bss_load->ch_util);
1171 tprintf("Available Admission Capacity: %uus",
1172 bss_load->avlb_adm_cap * 32);
1174 return 1;
1177 static int8_t inf_edca_ps(struct pkt_buff *pkt, u8 *id)
1179 u32 ac_be, ac_bk, ac_vi, ac_vo;
1180 struct element_edca_ps *edca_ps;
1182 edca_ps = (struct element_edca_ps *) pkt_pull(pkt, sizeof(*edca_ps));
1183 if (edca_ps == NULL)
1184 return 0;
1186 ac_be = le32_to_cpu(edca_ps->ac_be);
1187 ac_bk = le32_to_cpu(edca_ps->ac_bk);
1188 ac_vi = le32_to_cpu(edca_ps->ac_vi);
1189 ac_vo = le32_to_cpu(edca_ps->ac_vo);
1191 tprintf("EDCA Param Set (%u, Len(%u)): ", *id, edca_ps->len);
1192 if (len_neq_error(edca_ps->len, 18))
1193 return 0;
1194 tprintf("QoS Info: 0x%x (-> EDCA Param Set Update Count (%u),"
1195 "Q-Ack (%u), Queue Re (%u), TXOP Req(%u), Res(%u)), ",
1196 edca_ps->qos_inf, edca_ps->qos_inf >> 4,
1197 (edca_ps->qos_inf >> 3) & 1, (edca_ps->qos_inf >> 2) & 1,
1198 (edca_ps->qos_inf >> 1) & 1, edca_ps->qos_inf & 1);
1199 tprintf("Reserved: 0x%x, ", edca_ps->res);
1200 tprintf("AC_BE Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1201 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)), ", ac_be,
1202 ac_be >> 28, (ac_be >> 27) & 1, (ac_be >> 25) & 3,
1203 (ac_be >> 24) & 1, (ac_be >> 20) & 15, (ac_be >> 16) & 15,
1204 bswap_16(ac_be & 0xFFFF) * 32);
1205 tprintf("AC_BK Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1206 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)), ", ac_bk,
1207 ac_bk >> 28, (ac_bk >> 27) & 1, (ac_bk >> 25) & 3,
1208 (ac_bk >> 24) & 1, (ac_bk >> 20) & 15, (ac_bk >> 16) & 15,
1209 bswap_16(ac_bk & 0xFFFF) * 32);
1210 tprintf("AC_VI Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1211 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)), ", ac_vi,
1212 ac_vi >> 28, (ac_vi >> 27) & 1, (ac_vi >> 25) & 3,
1213 (ac_vi >> 24) & 1, (ac_vi >> 20) & 15, (ac_vi >> 16) & 15,
1214 bswap_16(ac_vi & 0xFFFF) * 32);
1215 tprintf("AC_VO Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1216 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)", ac_vo,
1217 ac_vo >> 28, (ac_vo >> 27) & 1, (ac_vo >> 25) & 3,
1218 (ac_vo >> 24) & 1, (ac_vo >> 20) & 15, (ac_vo >> 16) & 15,
1219 bswap_16(ac_vo & 0xFFFF) * 32);
1221 return 1;
1224 static int8_t inf_tspec(struct pkt_buff *pkt, u8 *id)
1226 u16 nom_msdu_size, surplus_bandw_allow;
1227 struct element_tspec *tspec;
1229 tspec = (struct element_tspec *) pkt_pull(pkt, sizeof(*tspec));
1230 if (tspec == NULL)
1231 return 0;
1233 nom_msdu_size = le16_to_cpu(tspec->nom_msdu_size);
1234 surplus_bandw_allow = le16_to_cpu(tspec->surplus_bandw_allow);
1236 tprintf("TSPEC (%u, Len(%u)): ", *id, tspec->len);
1237 if (len_neq_error(tspec->len, 55))
1238 return 0;
1239 tprintf("Traffic Type: %u, ", tspec->traffic_type);
1240 tprintf("TSID: %u, ", tspec->tsid);
1241 tprintf("Direction: %u, ", tspec->direction);
1242 tprintf("Access Policy: %u, ", tspec->access_policy);
1243 tprintf("Aggregation: %u, ", tspec->aggr);
1244 tprintf("User Priority: %u, ", tspec->user_prior);
1245 tprintf("TSinfo Ack Policy: %u, ", tspec->tsinfo_ack_pol);
1246 tprintf("Schedule: %u, ", tspec->schedule);
1247 tprintf("Reserved: 0x%x, ", tspec->res);
1248 tprintf("Nominal MSDU Size: %uB (Fixed (%u)), ",
1249 nom_msdu_size >> 1, nom_msdu_size & 1);
1250 tprintf("Maximum MSDU Size: %uB, ", le16_to_cpu(tspec->max_msdu_size));
1251 tprintf("Minimum Service Interval: %uus, ",
1252 le32_to_cpu(tspec->min_srv_intv));
1253 tprintf("Maximum Service Interval: %uus, ",
1254 le32_to_cpu(tspec->max_srv_intv));
1255 tprintf("Inactivity Interval: %uus, ",
1256 le32_to_cpu(tspec->inactive_intv));
1257 tprintf("Suspension Interval: %uus, ", le32_to_cpu(tspec->susp_intv));
1258 tprintf("Service Start Time: %uus, ",
1259 le32_to_cpu(tspec->srv_start_time));
1260 tprintf("Minimum Data Rate: %ub/s, ",le32_to_cpu(tspec->min_data_rate));
1261 tprintf("Mean Data Rate: %ub/s, ", le32_to_cpu(tspec->mean_data_rate));
1262 tprintf("Peak Data Rate: %ub/s, ",le32_to_cpu(tspec->peak_data_rate));
1263 tprintf("Burst Size: %uB, ", le32_to_cpu(tspec->burst_size));
1264 tprintf("Delay Bound: %uus, ", le32_to_cpu(tspec->delay_bound));
1265 tprintf("Minimum PHY Rate: %ub/s, ", le32_to_cpu(tspec->min_phy_rate));
1266 tprintf("Surplus Bandwidth: %u.%u, ", surplus_bandw_allow >> 13,
1267 surplus_bandw_allow & 0x1FFF);
1268 tprintf("Medium Time: %uus", le16_to_cpu(tspec->med_time) * 32);
1270 return 1;
1273 static const char *class_type(u8 type)
1275 switch (type) {
1276 case 0: return "Ethernet parameters";
1277 case 1: return "TCP/UDP IP parameters";
1278 case 2: return "IEEE 802.1Q parameters";
1279 case 3: return "Filter Offset parameters";
1280 case 4: return "IP and higher layer parameters";
1281 case 5: return "IEEE 802.1D/Q parameters";
1282 default: return "Reserved";
1286 static int8_t inf_tclas(struct pkt_buff *pkt, u8 *id)
1288 struct element_tclas *tclas;
1289 struct element_tclas_frm_class *frm_class;
1291 tclas = (struct element_tclas *) pkt_pull(pkt, sizeof(*tclas));
1292 if (tclas == NULL)
1293 return 0;
1295 frm_class = (struct element_tclas_frm_class *)
1296 pkt_pull(pkt, sizeof(*frm_class));
1297 if (frm_class == NULL)
1298 return 0;
1300 tprintf("TCLAS (%u, Len(%u)): ", *id, tclas->len);
1301 if (len_lt_error(tclas->len, 3))
1302 return 0;
1303 tprintf("User Priority: %u, ", tclas->user_priority);
1304 tprintf("Classifier Type: %s (%u), ", class_type(frm_class->type),
1305 frm_class->type);
1306 tprintf("Classifier Mask: 0x%x, ", frm_class->mask);
1308 if(frm_class->type == 0) {
1309 struct element_tclas_type0 *type0;
1311 type0 = (struct element_tclas_type0 *)
1312 pkt_pull(pkt, sizeof(*type0));
1313 if (type0 == NULL)
1314 return 0;
1316 /* I think little endian, like the rest */
1317 tprintf("Src Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
1318 type0->sa[5], type0->sa[4], type0->sa[3],
1319 type0->sa[2], type0->sa[1], type0->sa[0]);
1320 tprintf("Dst Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
1321 type0->da[5], type0->da[4], type0->da[3],
1322 type0->da[2], type0->da[1], type0->da[0]);
1323 tprintf("Type: 0x%x", le16_to_cpu(type0->type));
1325 else if(frm_class->type == 1) {
1326 struct element_tclas_type1 *type1;
1328 type1 = (struct element_tclas_type1 *)
1329 pkt_pull(pkt, sizeof(*type1));
1330 if (type1 == NULL)
1331 return 0;
1333 tprintf("Version: %u, ", type1->version);
1334 /* big endian format follows */
1335 if(type1->version == 4) {
1336 struct element_tclas_type1_ip4 *type1_ip4;
1337 char src_ip[INET_ADDRSTRLEN];
1338 char dst_ip[INET_ADDRSTRLEN];
1340 type1_ip4 = (struct element_tclas_type1_ip4 *)
1341 pkt_pull(pkt, sizeof(*type1_ip4));
1342 if (type1_ip4 == NULL)
1343 return 0;
1345 inet_ntop(AF_INET, &type1_ip4->sa, src_ip, sizeof(src_ip));
1346 inet_ntop(AF_INET, &type1_ip4->da, dst_ip, sizeof(dst_ip));
1348 tprintf("Src IP: %s, ", src_ip);
1349 tprintf("Dst IP: %s, ", dst_ip);
1350 tprintf("Src Port: %u, ", ntohs(type1_ip4->sp));
1351 tprintf("Dst Port: %u, ", ntohs(type1_ip4->dp));
1352 tprintf("DSCP: 0x%x, ", type1_ip4->dscp);
1353 tprintf("Proto: %u, ", type1_ip4->proto);
1354 tprintf("Res: 0x%x", type1_ip4->reserved);
1356 else if(type1->version == 6) {
1357 struct element_tclas_type1_ip6 *type1_ip6;
1358 char src_ip[INET6_ADDRSTRLEN];
1359 char dst_ip[INET6_ADDRSTRLEN];
1361 type1_ip6 = (struct element_tclas_type1_ip6 *)
1362 pkt_pull(pkt, sizeof(*type1_ip6));
1363 if (type1_ip6 == NULL)
1364 return 0;
1366 inet_ntop(AF_INET6, &type1_ip6->sa,
1367 src_ip, sizeof(src_ip));
1368 inet_ntop(AF_INET6, &type1_ip6->da,
1369 dst_ip, sizeof(dst_ip));
1371 tprintf("Src IP: %s, ", src_ip);
1372 tprintf("Dst IP: %s, ", dst_ip);
1373 tprintf("Src Port: %u, ", ntohs(type1_ip6->sp));
1374 tprintf("Dst Port: %u, ", ntohs(type1_ip6->dp));
1375 tprintf("Flow Label: 0x%x%x%x", type1_ip6->flow_label1,
1376 type1_ip6->flow_label2, type1_ip6->flow_label3);
1378 else {
1379 tprintf("Version (%u) not supported", type1->version);
1380 return 0;
1384 else if(frm_class->type == 2) {
1385 struct element_tclas_type2 *type2;
1387 type2 = (struct element_tclas_type2 *)
1388 pkt_pull(pkt, sizeof(*type2));
1389 if (type2 == NULL)
1390 return 0;
1392 tprintf("802.1Q VLAN TCI: 0x%x", ntohs(type2->vlan_tci));
1394 else if(frm_class->type == 3) {
1395 struct element_tclas_type3 *type3;
1396 u8 len, i;
1397 u8 *val;
1399 type3 = (struct element_tclas_type3 *)
1400 pkt_pull(pkt, sizeof(*type3));
1401 if (type3 == NULL)
1402 return 0;
1404 len = (tclas->len - 5) / 2;
1406 tprintf("Filter Offset: %u, ", type3->offs);
1408 if((len & 1) || (len_lt_error(tclas->len, 5))) {
1409 tprintf("Length of TCLAS (%u) not correct", tclas->len);
1410 return 0;
1412 else {
1413 val = pkt_pull(pkt, len);
1414 if (val == NULL)
1415 return 0;
1417 tprintf("Filter Value: 0x");
1418 for (i = 0; i < len / 2; i++)
1419 tprintf("%x ", val[i]);
1420 tprintf(", ");
1421 tprintf("Filter Mask: 0x");
1422 for (i = len / 2; i < len; i++)
1423 tprintf("%x ", val[i]);
1427 else if(frm_class->type == 4) {
1428 struct element_tclas_type4 *type4;
1430 type4 = (struct element_tclas_type4 *)
1431 pkt_pull(pkt, sizeof(*type4));
1432 if (type4 == NULL)
1433 return 0;
1435 tprintf("Version: %u, ", type4->version);
1436 /* big endian format follows */
1437 if(type4->version == 4) {
1438 struct element_tclas_type4_ip4 *type4_ip4;
1439 char src_ip[INET_ADDRSTRLEN];
1440 char dst_ip[INET_ADDRSTRLEN];
1442 type4_ip4 = (struct element_tclas_type4_ip4 *)
1443 pkt_pull(pkt, sizeof(*type4_ip4));
1444 if (type4_ip4 == NULL)
1445 return 0;
1447 inet_ntop(AF_INET, &type4_ip4->sa, src_ip, sizeof(src_ip));
1448 inet_ntop(AF_INET, &type4_ip4->da, dst_ip, sizeof(dst_ip));
1450 tprintf("Src IP: %s, ", src_ip);
1451 tprintf("Dst IP: %s, ", dst_ip);
1452 tprintf("Src Port: %u, ", ntohs(type4_ip4->sp));
1453 tprintf("Dst Port: %u, ", ntohs(type4_ip4->dp));
1454 tprintf("DSCP: 0x%x, ", type4_ip4->dscp);
1455 tprintf("Proto: %u, ", type4_ip4->proto);
1456 tprintf("Res: 0x%x", type4_ip4->reserved);
1458 else if(type4->version == 6) {
1459 struct element_tclas_type4_ip6 *type4_ip6;
1460 char src_ip[INET6_ADDRSTRLEN];
1461 char dst_ip[INET6_ADDRSTRLEN];
1463 type4_ip6 = (struct element_tclas_type4_ip6 *)
1464 pkt_pull(pkt, sizeof(*type4_ip6));
1465 if (type4_ip6 == NULL)
1466 return 0;
1468 inet_ntop(AF_INET6, &type4_ip6->sa,
1469 src_ip, sizeof(src_ip));
1470 inet_ntop(AF_INET6, &type4_ip6->da,
1471 dst_ip, sizeof(dst_ip));
1473 tprintf("Src IP: %s, ", src_ip);
1474 tprintf("Dst IP: %s, ", dst_ip);
1475 tprintf("Src Port: %u, ", ntohs(type4_ip6->sp));
1476 tprintf("Dst Port: %u, ", ntohs(type4_ip6->dp));
1477 tprintf("DSCP: 0x%x, ", type4_ip6->dscp);
1478 tprintf("Nxt Hdr: %u, ", type4_ip6->nxt_hdr);
1479 tprintf("Flow Label: 0x%x%x%x", type4_ip6->flow_label1,
1480 type4_ip6->flow_label2, type4_ip6->flow_label3);
1482 else {
1483 tprintf("Version (%u) not supported", type4->version);
1484 return 0;
1487 else if(frm_class->type == 5) {
1488 struct element_tclas_type5 *type5;
1490 type5 = (struct element_tclas_type5 *)
1491 pkt_pull(pkt, sizeof(*type5));
1492 if (type5 == NULL)
1493 return 0;
1495 tprintf("802.1Q PCP: 0x%x, ", type5->pcp);
1496 tprintf("802.1Q CFI: 0x%x, ", type5->cfi);
1497 tprintf("802.1Q VID: 0x%x", type5->vid);
1499 else {
1500 tprintf("Classifier Type (%u) not supported", frm_class->type);
1501 return 0;
1504 return 1;
1507 static int8_t inf_sched(struct pkt_buff *pkt, u8 *id)
1509 struct element_schedule *schedule;
1510 u16 info;
1512 schedule = (struct element_schedule *) pkt_pull(pkt, sizeof(*schedule));
1513 if (schedule == NULL)
1514 return 0;
1516 info = le16_to_cpu(schedule->inf);
1518 tprintf("Schedule (%u, Len(%u)): ", *id, schedule->len);
1519 if (len_neq_error(schedule->len, 12))
1520 return 0;
1522 tprintf("Aggregation: %u, ", info >> 15);
1523 tprintf("TSID: %u, ", (info >> 11) & 0xF);
1524 tprintf("Direction: %u, ", (info >> 9) & 0x3);
1525 tprintf("Res: %u, ", info & 0x1FF);
1526 tprintf("Serv Start Time: %uus, ", le32_to_cpu(schedule->start));
1527 tprintf("Serv Interval: %uus, ", le32_to_cpu(schedule->serv_intv));
1528 tprintf("Spec Interval: %fs", le32_to_cpu(schedule->spec_intv) * TU);
1530 return 1;
1533 static int8_t inf_chall_txt(struct pkt_buff *pkt, u8 *id)
1535 struct element_chall_txt *chall_txt;
1536 u8 i;
1537 u8 *txt;
1539 chall_txt = (struct element_chall_txt *)
1540 pkt_pull(pkt, sizeof(*chall_txt));
1541 if (chall_txt == NULL)
1542 return 0;
1544 tprintf("Challenge Text (%u, Len(%u)): ", *id, chall_txt->len);
1545 if ((chall_txt->len - sizeof(*chall_txt) + 1) > 0) {
1546 txt = pkt_pull(pkt, (chall_txt->len - sizeof(*chall_txt) + 1));
1547 if (txt == NULL)
1548 return 0;
1550 tprintf("0x");
1551 for (i = 0; i < (chall_txt->len - sizeof(*chall_txt) + 1); i++)
1552 tprintf("%x ", txt[i]);
1555 return 1;
1558 static int8_t inf_pwr_constr(struct pkt_buff *pkt, u8 *id)
1560 struct element_pwr_constr *pwr_constr;
1562 pwr_constr = (struct element_pwr_constr *) pkt_pull(pkt, sizeof(*pwr_constr));
1563 if (pwr_constr == NULL)
1564 return 0;
1566 tprintf("Power Constraint (%u, Len(%u)): ", *id, pwr_constr->len);
1567 if (len_neq_error(pwr_constr->len, 1))
1568 return 0;
1570 tprintf("Local Power Constraint: %udB", pwr_constr->local_pwr_constr);
1572 return 1;
1575 static int8_t inf_pwr_cap(struct pkt_buff *pkt, u8 *id)
1577 struct element_pwr_cap *pwr_cap;
1579 pwr_cap = (struct element_pwr_cap *) pkt_pull(pkt, sizeof(*pwr_cap));
1580 if (pwr_cap == NULL)
1581 return 0;
1583 tprintf("Power Capability (%u, Len(%u)): ", *id, pwr_cap->len);
1584 if (len_neq_error(pwr_cap->len, 2))
1585 return 0;
1587 tprintf("Min. Transm. Pwr Cap.: %ddBm, ", (int8_t)pwr_cap->min_pwr_cap);
1588 tprintf("Max. Transm. Pwr Cap.: %ddBm", (int8_t)pwr_cap->max_pwr_cap);
1590 return 1;
1593 static int8_t inf_tpc_req(struct pkt_buff *pkt, u8 *id)
1595 struct element_tpc_req *tpc_req;
1597 tpc_req = (struct element_tpc_req *) pkt_pull(pkt, sizeof(*tpc_req));
1598 if (tpc_req == NULL)
1599 return 0;
1601 tprintf("TPC Request (%u, Len(%u))", *id, tpc_req->len);
1602 if (len_neq_error(tpc_req->len, 0))
1603 return 0;
1605 return 1;
1608 static int8_t inf_tpc_rep(struct pkt_buff *pkt, u8 *id)
1610 struct element_tpc_rep *tpc_rep;
1612 tpc_rep = (struct element_tpc_rep *) pkt_pull(pkt, sizeof(*tpc_rep));
1613 if (tpc_rep == NULL)
1614 return 0;
1616 tprintf("TPC Report (%u, Len(%u)): ", *id, tpc_rep->len);
1617 if (len_neq_error(tpc_rep->len, 2))
1618 return 0;
1620 tprintf("Transmit Power: %udBm, ", (int8_t)tpc_rep->trans_pwr);
1621 tprintf("Link Margin: %udB", (int8_t)tpc_rep->trans_pwr);
1623 return 1;
1626 static int8_t inf_supp_ch(struct pkt_buff *pkt, u8 *id)
1628 struct element_supp_ch *supp_ch;
1629 u8 i;
1631 supp_ch = (struct element_supp_ch *) pkt_pull(pkt, sizeof(*supp_ch));
1632 if (supp_ch == NULL)
1633 return 0;
1635 tprintf("Supp Channels (%u, Len(%u)): ", *id, supp_ch->len);
1636 if (len_lt_error(supp_ch->len, 2))
1637 return 0;
1639 if(supp_ch->len & 1) {
1640 tprintf("Length should be modulo 2");
1641 return 0;
1644 for (i = 0; i < supp_ch->len; i += 2) {
1645 struct element_supp_ch_tuple *supp_ch_tuple;
1647 supp_ch_tuple = (struct element_supp_ch_tuple *)
1648 pkt_pull(pkt, sizeof(*supp_ch_tuple));
1649 if (supp_ch_tuple == NULL)
1650 return 0;
1652 tprintf("First Channel Nr: %u, ", supp_ch_tuple->first_ch_nr);
1653 tprintf("Nr of Channels: %u, ", supp_ch_tuple->nr_ch);
1656 return 1;
1659 static int8_t inf_ch_sw_ann(struct pkt_buff *pkt, u8 *id)
1661 struct element_ch_sw_ann *ch_sw_ann;
1663 ch_sw_ann = (struct element_ch_sw_ann *)
1664 pkt_pull(pkt, sizeof(*ch_sw_ann));
1665 if (ch_sw_ann == NULL)
1666 return 0;
1668 tprintf("Channel Switch Announc (%u, Len(%u)): ", *id, ch_sw_ann->len);
1669 if (len_neq_error(ch_sw_ann->len, 3))
1670 return 0;
1672 tprintf("Switch Mode: %u, ", ch_sw_ann->switch_mode);
1673 tprintf("New Nr: %u, ", ch_sw_ann->new_nr);
1674 tprintf("Switch Count: %u", ch_sw_ann->switch_cnt);
1676 return 1;
1679 static const char *meas_type(u8 type)
1681 switch (type) {
1682 case 0: return "Basic";
1683 case 1: return "Clear Channel assesment (CCA)";
1684 case 2: return "Receive power indication (RPI) histogram";
1685 case 3: return "Channel load";
1686 case 4: return "Noise histogram";
1687 case 5: return "Beacon";
1688 case 6: return "Frame";
1689 case 7: return "STA statistics";
1690 case 8: return "LCI";
1691 case 9: return "Transmit stream/category measurement";
1692 case 10: return "Multicast diagnostics";
1693 case 11: return "Location Civic";
1694 case 12: return "Location Identifier";
1695 case 13 ... 255: return "Reserved";
1699 static int8_t inf_meas_req(struct pkt_buff *pkt, u8 *id)
1701 struct element_meas_req *meas_req;
1703 meas_req = (struct element_meas_req *) pkt_pull(pkt, sizeof(*meas_req));
1704 if (meas_req == NULL)
1705 return 0;
1707 tprintf("Measurement Req (%u, Len(%u)): ", *id, meas_req->len);
1708 if (len_lt_error(meas_req->len, 3))
1709 return 0;
1711 tprintf("Token: %u, ", meas_req->token);
1712 tprintf("Req Mode: 0x%x (Parallel (%u), Enable(%u), Request(%u), "
1713 "Report(%u), Dur Mand(%u)), ", meas_req->req_mode,
1714 meas_req->req_mode >> 7, (meas_req->req_mode >> 6) & 0x1,
1715 (meas_req->req_mode >> 5) & 0x1, (meas_req->req_mode >> 4) & 0x1,
1716 (meas_req->req_mode >> 3) & 0x1);
1717 tprintf("Type: %s (%u), ", meas_type(meas_req->type), meas_req->type);
1719 if(meas_req->len > 3) {
1720 if(meas_req->type == 0) {
1721 struct element_meas_basic *basic;
1723 basic = (struct element_meas_basic *)
1724 pkt_pull(pkt, sizeof(*basic));
1725 if (basic == NULL)
1726 return 0;
1728 if (!(meas_req->len - 3 - sizeof(*basic))) {
1729 tprintf("Length of Req matchs not Type %u",
1730 meas_req->type);
1731 return 0;
1734 tprintf("Ch Nr: %uus, ", basic->ch_nr);
1735 tprintf("Meas Start Time: %lu, ",
1736 le64_to_cpu(basic->start));
1737 tprintf("Meas Duration: %fs",
1738 le16_to_cpu(basic->dur) * TU);
1741 else if(meas_req->type == 1) {
1742 struct element_meas_cca *cca;
1744 cca = (struct element_meas_cca *)
1745 pkt_pull(pkt, sizeof(*cca));
1746 if (cca == NULL)
1747 return 0;
1749 if (!(meas_req->len - 3 - sizeof(*cca))) {
1750 tprintf("Length of Req matchs not Type %u",
1751 meas_req->type);
1752 return 0;
1755 tprintf("Ch Nr: %uus, ", cca->ch_nr);
1756 tprintf("Meas Start Time: %lu, ",
1757 le64_to_cpu(cca->start));
1758 tprintf("Meas Duration: %fs",
1759 le16_to_cpu(cca->dur) * TU);
1761 else if(meas_req->type == 2) {
1762 struct element_meas_rpi *rpi;
1764 rpi = (struct element_meas_rpi *)
1765 pkt_pull(pkt, sizeof(*rpi));
1766 if (rpi == NULL)
1767 return 0;
1769 if (!(meas_req->len - 3 - sizeof(*rpi))) {
1770 tprintf("Length of Req matchs not Type %u",
1771 meas_req->type);
1772 return 0;
1775 tprintf("Ch Nr: %uus, ", rpi->ch_nr);
1776 tprintf("Meas Start Time: %lu, ",
1777 le64_to_cpu(rpi->start));
1778 tprintf("Meas Duration: %fs",
1779 le16_to_cpu(rpi->dur) * TU);
1781 else if(meas_req->type == 3) {
1782 struct element_meas_ch_load *ch_load;
1784 ch_load = (struct element_meas_ch_load *)
1785 pkt_pull(pkt, sizeof(*ch_load));
1786 if (ch_load == NULL)
1787 return 0;
1789 if ((meas_req->len - 3 - sizeof(*ch_load)) >= 0) {
1790 tprintf("Length of Req matchs not Type %u",
1791 meas_req->type);
1792 return 0;
1795 tprintf("OP Class: %u, ", ch_load->op_class);
1796 tprintf("Ch Nr: %u, ", ch_load->ch_nr);
1797 tprintf("Rand Intv: %fs, ",
1798 le16_to_cpu(ch_load->rand_intv) * TU);
1799 tprintf("Meas Duration: %fs",
1800 le16_to_cpu(ch_load->dur) * TU);
1802 if(!subelements(pkt,
1803 meas_req->len - 3 - sizeof(*ch_load)))
1804 return 0;
1806 else if(meas_req->type == 4) {
1807 struct element_meas_noise *noise;
1809 noise = (struct element_meas_noise *)
1810 pkt_pull(pkt, sizeof(*noise));
1811 if (noise == NULL)
1812 return 0;
1814 if ((meas_req->len - 3 - sizeof(*noise)) >= 0) {
1815 tprintf("Length of Req matchs not Type %u",
1816 meas_req->type);
1817 return 0;
1820 tprintf("OP Class: %u, ", noise->op_class);
1821 tprintf("Ch Nr: %u, ", noise->ch_nr);
1822 tprintf("Rand Intv: %fs, ",
1823 le16_to_cpu(noise->rand_intv) * TU);
1824 tprintf("Meas Duration: %fs",
1825 le16_to_cpu(noise->dur) * TU);
1827 if(!subelements(pkt,
1828 meas_req->len - 3 - sizeof(*noise)))
1829 return 0;
1831 else if(meas_req->type == 5) {
1832 struct element_meas_beacon *beacon;
1834 beacon = (struct element_meas_beacon *)
1835 pkt_pull(pkt, sizeof(*beacon));
1836 if (beacon == NULL)
1837 return 0;
1839 if ((meas_req->len - 3 - sizeof(*beacon)) >= 0) {
1840 tprintf("Length of Req matchs not Type %u",
1841 meas_req->type);
1842 return 0;
1845 tprintf("OP Class: %u, ", beacon->op_class);
1846 tprintf("Ch Nr: %u, ", beacon->ch_nr);
1847 tprintf("Rand Intv: %fs, ",
1848 le16_to_cpu(beacon->rand_intv) * TU);
1849 tprintf("Meas Duration: %fs",
1850 le16_to_cpu(beacon->dur) * TU);
1851 tprintf("Mode: %u, ", beacon->mode);
1852 tprintf("BSSID: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1853 beacon->bssid[0], beacon->bssid[1],
1854 beacon->bssid[2], beacon->bssid[3],
1855 beacon->bssid[4], beacon->bssid[5]);
1857 if(!subelements(pkt,
1858 meas_req->len - 3 - sizeof(*beacon)))
1859 return 0;
1861 else if(meas_req->type == 6) {
1862 struct element_meas_frame *frame;
1864 frame = (struct element_meas_frame *)
1865 pkt_pull(pkt, sizeof(*frame));
1866 if (frame == NULL)
1867 return 0;
1869 if ((meas_req->len - 3 - sizeof(*frame)) >= 0) {
1870 tprintf("Length of Req matchs not Type %u",
1871 meas_req->type);
1872 return 0;
1875 tprintf("OP Class: %u, ", frame->op_class);
1876 tprintf("Ch Nr: %u, ", frame->ch_nr);
1877 tprintf("Rand Intv: %fs, ",
1878 le16_to_cpu(frame->rand_intv) * TU);
1879 tprintf("Meas Duration: %fs",
1880 le16_to_cpu(frame->dur) * TU);
1881 tprintf("Request Type: %u, ", frame->frame);
1882 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1883 frame->mac[0], frame->mac[1],
1884 frame->mac[2], frame->mac[3],
1885 frame->mac[4], frame->mac[5]);
1887 if(!subelements(pkt,
1888 meas_req->len - 3 - sizeof(*frame)))
1889 return 0;
1891 else if(meas_req->type == 7) {
1892 struct element_meas_sta *sta;
1894 sta = (struct element_meas_sta *)
1895 pkt_pull(pkt, sizeof(*sta));
1896 if (sta == NULL)
1897 return 0;
1899 if ((meas_req->len - 3 - sizeof(*sta)) >= 0) {
1900 tprintf("Length of Req matchs not Type %u",
1901 meas_req->type);
1902 return 0;
1905 tprintf("Peer MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1906 sta->peer_mac[0], sta->peer_mac[1],
1907 sta->peer_mac[2], sta->peer_mac[3],
1908 sta->peer_mac[4], sta->peer_mac[5]);
1909 tprintf("Rand Intv: %fs, ",
1910 le16_to_cpu(sta->rand_intv) * TU);
1911 tprintf("Meas Duration: %fs",
1912 le16_to_cpu(sta->dur) * TU);
1913 tprintf("Group ID: %u, ", sta->group_id);
1915 if(!subelements(pkt,
1916 meas_req->len - 3 - sizeof(*sta)))
1917 return 0;
1919 else if(meas_req->type == 8) {
1920 struct element_meas_lci *lci;
1922 lci = (struct element_meas_lci *)
1923 pkt_pull(pkt, sizeof(*lci));
1924 if (lci == NULL)
1925 return 0;
1927 if ((meas_req->len - 3 - sizeof(*lci)) >= 0) {
1928 tprintf("Length of Req matchs not Type %u",
1929 meas_req->type);
1930 return 0;
1933 tprintf("Location Subj: %u, ", lci->loc_subj);
1934 tprintf("Latitude Req Res: %udeg",
1935 lci->latitude_req_res);
1936 tprintf("Longitude Req Res: %udeg",
1937 lci->longitude_req_res);
1938 tprintf("Altitude Req Res: %udeg",
1939 lci->altitude_req_res);
1941 if(!subelements(pkt,
1942 meas_req->len - 3 - sizeof(*lci)))
1943 return 0;
1945 else if(meas_req->type == 9) {
1946 struct element_meas_trans_str_cat *trans;
1948 trans = (struct element_meas_trans_str_cat *)
1949 pkt_pull(pkt, sizeof(*trans));
1950 if (trans == NULL)
1951 return 0;
1953 if ((meas_req->len - 3 - sizeof(*trans)) >= 0) {
1954 tprintf("Length of Req matchs not Type %u",
1955 meas_req->type);
1956 return 0;
1959 tprintf("Rand Intv: %fs, ",
1960 le16_to_cpu(trans->rand_intv) * TU);
1961 tprintf("Meas Duration: %fs",
1962 le16_to_cpu(trans->dur) * TU);
1963 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1964 trans->peer_sta_addr[0], trans->peer_sta_addr[1],
1965 trans->peer_sta_addr[2], trans->peer_sta_addr[3],
1966 trans->peer_sta_addr[4], trans->peer_sta_addr[5]);
1967 tprintf("Traffic ID: %u, ", trans->traffic_id);
1968 tprintf("Bin 0 Range: %u, ", trans->bin_0_range);
1970 if(!subelements(pkt,
1971 meas_req->len - 3 - sizeof(*trans)))
1972 return 0;
1974 else if(meas_req->type == 10) {
1975 struct element_meas_mcast_diag *mcast;
1977 mcast = (struct element_meas_mcast_diag *)
1978 pkt_pull(pkt, sizeof(*mcast));
1979 if (mcast == NULL)
1980 return 0;
1982 if ((meas_req->len - 3 - sizeof(*mcast)) >= 0) {
1983 tprintf("Length of Req matchs not Type %u",
1984 meas_req->type);
1985 return 0;
1988 tprintf("Rand Intv: %fs, ",
1989 le16_to_cpu(mcast->rand_intv) * TU);
1990 tprintf("Meas Duration: %fs",
1991 le16_to_cpu(mcast->dur) * TU);
1992 tprintf("Group MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1993 mcast->group_mac[0], mcast->group_mac[1],
1994 mcast->group_mac[2], mcast->group_mac[3],
1995 mcast->group_mac[4], mcast->group_mac[5]);
1997 if(!subelements(pkt,
1998 meas_req->len - 3 - sizeof(*mcast)))
1999 return 0;
2001 else if(meas_req->type == 11) {
2002 struct element_meas_loc_civic *civic;
2004 civic = (struct element_meas_loc_civic *)
2005 pkt_pull(pkt, sizeof(*civic));
2006 if (civic == NULL)
2007 return 0;
2009 if ((meas_req->len - 3 - sizeof(*civic)) >= 0) {
2010 tprintf("Length of Req matchs not Type %u",
2011 meas_req->type);
2012 return 0;
2015 tprintf("Location Subj: %u, ", civic->loc_subj);
2016 tprintf("Type: %u, ", civic->civic_loc);
2017 tprintf("Srv Intv Units: %u, ",
2018 le16_to_cpu(civic->loc_srv_intv_unit));
2019 tprintf("Srv Intv: %u, ", civic->loc_srv_intv);
2021 if(!subelements(pkt,
2022 meas_req->len - 3 - sizeof(*civic)))
2023 return 0;
2025 else if(meas_req->type == 12) {
2026 struct element_meas_loc_id *id;
2028 id = (struct element_meas_loc_id *)
2029 pkt_pull(pkt, sizeof(*id));
2030 if (id == NULL)
2031 return 0;
2033 if ((meas_req->len - 3 - sizeof(*id)) >= 0) {
2034 tprintf("Length of Req matchs not Type %u",
2035 meas_req->type);
2036 return 0;
2039 tprintf("Location Subj: %u, ", id->loc_subj);
2040 tprintf("Srv Intv Units: %u, ",
2041 le16_to_cpu(id->loc_srv_intv_unit));
2042 tprintf("Srv Intv: %u", id->loc_srv_intv);
2044 if(!subelements(pkt,
2045 meas_req->len - 3 - sizeof(*id)))
2046 return 0;
2048 else if(meas_req->type == 255) {
2049 struct element_meas_pause *pause;
2051 pause = (struct element_meas_pause *)
2052 pkt_pull(pkt, sizeof(*pause));
2053 if (pause == NULL)
2054 return 0;
2056 if ((meas_req->len - 3 - sizeof(*pause)) >= 0) {
2057 tprintf("Length of Req matchs not Type %u",
2058 meas_req->type);
2059 return 0;
2062 tprintf("Pause Time: %fs, ", pause->time * 10 * TU);
2064 if(!subelements(pkt,
2065 meas_req->len - 3 - sizeof(*pause)))
2066 return 0;
2068 else {
2069 tprintf("Length field indicates data,"
2070 " but could not interpreted");
2071 return 0;
2075 return 1;
2078 static int8_t inf_meas_rep(struct pkt_buff *pkt, u8 *id)
2080 struct element_meas_rep *meas_rep;
2082 meas_rep = (struct element_meas_rep *) pkt_pull(pkt, sizeof(*meas_rep));
2083 if (meas_rep == NULL)
2084 return 0;
2086 tprintf("Measurement Rep (%u, Len(%u)): ", *id, meas_rep->len);
2087 if (len_lt_error(meas_rep->len, 3))
2088 return 0;
2090 tprintf("Token: %u, ", meas_rep->token);
2091 tprintf("Rep Mode: 0x%x (Late (%u), Incapable(%u), Refused(%u), ",
2092 meas_rep->rep_mode, meas_rep->rep_mode >> 7,
2093 (meas_rep->rep_mode >> 6) & 0x1,
2094 (meas_rep->rep_mode >> 5) & 0x1);
2095 tprintf("Type: %s (%u), ", meas_type(meas_rep->type), meas_rep->type);
2097 if(meas_rep->len > 3) {
2098 if(meas_rep->type == 0) {
2099 struct element_meas_basic *basic;
2101 basic = (struct element_meas_basic *)
2102 pkt_pull(pkt, sizeof(*basic));
2103 if (basic == NULL)
2104 return 0;
2106 if (!(meas_rep->len - 3 - sizeof(*basic))) {
2107 tprintf("Length of Req matchs not Type %u",
2108 meas_rep->type);
2109 return 0;
2112 tprintf("Ch Nr: %uus, ", basic->ch_nr);
2113 tprintf("Meas Start Time: %lu, ",
2114 le64_to_cpu(basic->start));
2115 tprintf("Meas Duration: %fs",
2116 le16_to_cpu(basic->dur) * TU);
2119 else if(meas_rep->type == 1) {
2120 struct element_meas_cca *cca;
2122 cca = (struct element_meas_cca *)
2123 pkt_pull(pkt, sizeof(*cca));
2124 if (cca == NULL)
2125 return 0;
2127 if (!(meas_rep->len - 3 - sizeof(*cca))) {
2128 tprintf("Length of Req matchs not Type %u",
2129 meas_rep->type);
2130 return 0;
2133 tprintf("Ch Nr: %uus, ", cca->ch_nr);
2134 tprintf("Meas Start Time: %lu, ",
2135 le64_to_cpu(cca->start));
2136 tprintf("Meas Duration: %fs",
2137 le16_to_cpu(cca->dur) * TU);
2139 else if(meas_rep->type == 2) {
2140 struct element_meas_rpi *rpi;
2142 rpi = (struct element_meas_rpi *)
2143 pkt_pull(pkt, sizeof(*rpi));
2144 if (rpi == NULL)
2145 return 0;
2147 if (!(meas_rep->len - 3 - sizeof(*rpi))) {
2148 tprintf("Length of Req matchs not Type %u",
2149 meas_rep->type);
2150 return 0;
2153 tprintf("Ch Nr: %uus, ", rpi->ch_nr);
2154 tprintf("Meas Start Time: %lu, ",
2155 le64_to_cpu(rpi->start));
2156 tprintf("Meas Duration: %fs",
2157 le16_to_cpu(rpi->dur) * TU);
2159 else if(meas_rep->type == 3) {
2160 struct element_meas_ch_load *ch_load;
2162 ch_load = (struct element_meas_ch_load *)
2163 pkt_pull(pkt, sizeof(*ch_load));
2164 if (ch_load == NULL)
2165 return 0;
2167 if ((meas_rep->len - 3 - sizeof(*ch_load)) >= 0) {
2168 tprintf("Length of Req matchs not Type %u",
2169 meas_rep->type);
2170 return 0;
2173 tprintf("OP Class: %u, ", ch_load->op_class);
2174 tprintf("Ch Nr: %u, ", ch_load->ch_nr);
2175 tprintf("Rand Intv: %fs, ",
2176 le16_to_cpu(ch_load->rand_intv) * TU);
2177 tprintf("Meas Duration: %fs",
2178 le16_to_cpu(ch_load->dur) * TU);
2180 if(!subelements(pkt,
2181 meas_rep->len - 3 - sizeof(*ch_load)))
2182 return 0;
2184 else if(meas_rep->type == 4) {
2185 struct element_meas_noise *noise;
2187 noise = (struct element_meas_noise *)
2188 pkt_pull(pkt, sizeof(*noise));
2189 if (noise == NULL)
2190 return 0;
2192 if ((meas_rep->len - 3 - sizeof(*noise)) >= 0) {
2193 tprintf("Length of Req matchs not Type %u",
2194 meas_rep->type);
2195 return 0;
2198 tprintf("OP Class: %u, ", noise->op_class);
2199 tprintf("Ch Nr: %u, ", noise->ch_nr);
2200 tprintf("Rand Intv: %fs, ",
2201 le16_to_cpu(noise->rand_intv) * TU);
2202 tprintf("Meas Duration: %fs",
2203 le16_to_cpu(noise->dur) * TU);
2205 if(!subelements(pkt,
2206 meas_rep->len - 3 - sizeof(*noise)))
2207 return 0;
2209 else if(meas_rep->type == 5) {
2210 struct element_meas_beacon *beacon;
2212 beacon = (struct element_meas_beacon *)
2213 pkt_pull(pkt, sizeof(*beacon));
2214 if (beacon == NULL)
2215 return 0;
2217 if ((meas_rep->len - 3 - sizeof(*beacon)) >= 0) {
2218 tprintf("Length of Req matchs not Type %u",
2219 meas_rep->type);
2220 return 0;
2223 tprintf("OP Class: %u, ", beacon->op_class);
2224 tprintf("Ch Nr: %u, ", beacon->ch_nr);
2225 tprintf("Rand Intv: %fs, ",
2226 le16_to_cpu(beacon->rand_intv) * TU);
2227 tprintf("Meas Duration: %fs",
2228 le16_to_cpu(beacon->dur) * TU);
2229 tprintf("Mode: %u, ", beacon->mode);
2230 tprintf("BSSID: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
2231 beacon->bssid[0], beacon->bssid[1],
2232 beacon->bssid[2], beacon->bssid[3],
2233 beacon->bssid[4], beacon->bssid[5]);
2235 if(!subelements(pkt,
2236 meas_rep->len - 3 - sizeof(*beacon)))
2237 return 0;
2239 else if(meas_rep->type == 6) {
2240 struct element_meas_frame *frame;
2242 frame = (struct element_meas_frame *)
2243 pkt_pull(pkt, sizeof(*frame));
2244 if (frame == NULL)
2245 return 0;
2247 if ((meas_rep->len - 3 - sizeof(*frame)) >= 0) {
2248 tprintf("Length of Req matchs not Type %u",
2249 meas_rep->type);
2250 return 0;
2253 tprintf("OP Class: %u, ", frame->op_class);
2254 tprintf("Ch Nr: %u, ", frame->ch_nr);
2255 tprintf("Rand Intv: %fs, ",
2256 le16_to_cpu(frame->rand_intv) * TU);
2257 tprintf("Meas Duration: %fs",
2258 le16_to_cpu(frame->dur) * TU);
2259 tprintf("Request Type: %u, ", frame->frame);
2260 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
2261 frame->mac[0], frame->mac[1],
2262 frame->mac[2], frame->mac[3],
2263 frame->mac[4], frame->mac[5]);
2265 if(!subelements(pkt,
2266 meas_rep->len - 3 - sizeof(*frame)))
2267 return 0;
2269 else if(meas_rep->type == 7) {
2270 struct element_meas_sta *sta;
2272 sta = (struct element_meas_sta *)
2273 pkt_pull(pkt, sizeof(*sta));
2274 if (sta == NULL)
2275 return 0;
2277 if ((meas_rep->len - 3 - sizeof(*sta)) >= 0) {
2278 tprintf("Length of Req matchs not Type %u",
2279 meas_rep->type);
2280 return 0;
2283 tprintf("Peer MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
2284 sta->peer_mac[0], sta->peer_mac[1],
2285 sta->peer_mac[2], sta->peer_mac[3],
2286 sta->peer_mac[4], sta->peer_mac[5]);
2287 tprintf("Rand Intv: %fs, ",
2288 le16_to_cpu(sta->rand_intv) * TU);
2289 tprintf("Meas Duration: %fs",
2290 le16_to_cpu(sta->dur) * TU);
2291 tprintf("Group ID: %u, ", sta->group_id);
2293 if(!subelements(pkt,
2294 meas_rep->len - 3 - sizeof(*sta)))
2295 return 0;
2297 else if(meas_rep->type == 8) {
2298 struct element_meas_lci *lci;
2300 lci = (struct element_meas_lci *)
2301 pkt_pull(pkt, sizeof(*lci));
2302 if (lci == NULL)
2303 return 0;
2305 if ((meas_rep->len - 3 - sizeof(*lci)) >= 0) {
2306 tprintf("Length of Req matchs not Type %u",
2307 meas_rep->type);
2308 return 0;
2311 tprintf("Location Subj: %u, ", lci->loc_subj);
2312 tprintf("Latitude Req Res: %udeg",
2313 lci->latitude_req_res);
2314 tprintf("Longitude Req Res: %udeg",
2315 lci->longitude_req_res);
2316 tprintf("Altitude Req Res: %udeg",
2317 lci->altitude_req_res);
2319 if(!subelements(pkt,
2320 meas_rep->len - 3 - sizeof(*lci)))
2321 return 0;
2323 else if(meas_rep->type == 9) {
2324 struct element_meas_trans_str_cat *trans;
2326 trans = (struct element_meas_trans_str_cat *)
2327 pkt_pull(pkt, sizeof(*trans));
2328 if (trans == NULL)
2329 return 0;
2331 if ((meas_rep->len - 3 - sizeof(*trans)) >= 0) {
2332 tprintf("Length of Req matchs not Type %u",
2333 meas_rep->type);
2334 return 0;
2337 tprintf("Rand Intv: %fs, ",
2338 le16_to_cpu(trans->rand_intv) * TU);
2339 tprintf("Meas Duration: %fs",
2340 le16_to_cpu(trans->dur) * TU);
2341 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
2342 trans->peer_sta_addr[0], trans->peer_sta_addr[1],
2343 trans->peer_sta_addr[2], trans->peer_sta_addr[3],
2344 trans->peer_sta_addr[4], trans->peer_sta_addr[5]);
2345 tprintf("Traffic ID: %u, ", trans->traffic_id);
2346 tprintf("Bin 0 Range: %u, ", trans->bin_0_range);
2348 if(!subelements(pkt,
2349 meas_rep->len - 3 - sizeof(*trans)))
2350 return 0;
2352 else if(meas_rep->type == 10) {
2353 struct element_meas_mcast_diag *mcast;
2355 mcast = (struct element_meas_mcast_diag *)
2356 pkt_pull(pkt, sizeof(*mcast));
2357 if (mcast == NULL)
2358 return 0;
2360 if ((meas_rep->len - 3 - sizeof(*mcast)) >= 0) {
2361 tprintf("Length of Req matchs not Type %u",
2362 meas_rep->type);
2363 return 0;
2366 tprintf("Rand Intv: %fs, ",
2367 le16_to_cpu(mcast->rand_intv) * TU);
2368 tprintf("Meas Duration: %fs",
2369 le16_to_cpu(mcast->dur) * TU);
2370 tprintf("Group MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
2371 mcast->group_mac[0], mcast->group_mac[1],
2372 mcast->group_mac[2], mcast->group_mac[3],
2373 mcast->group_mac[4], mcast->group_mac[5]);
2375 if(!subelements(pkt,
2376 meas_rep->len - 3 - sizeof(*mcast)))
2377 return 0;
2379 else if(meas_rep->type == 11) {
2380 struct element_meas_loc_civic *civic;
2382 civic = (struct element_meas_loc_civic *)
2383 pkt_pull(pkt, sizeof(*civic));
2384 if (civic == NULL)
2385 return 0;
2387 if ((meas_rep->len - 3 - sizeof(*civic)) >= 0) {
2388 tprintf("Length of Req matchs not Type %u",
2389 meas_rep->type);
2390 return 0;
2393 tprintf("Location Subj: %u, ", civic->loc_subj);
2394 tprintf("Type: %u, ", civic->civic_loc);
2395 tprintf("Srv Intv Units: %u, ",
2396 le16_to_cpu(civic->loc_srv_intv_unit));
2397 tprintf("Srv Intv: %u, ", civic->loc_srv_intv);
2399 if(!subelements(pkt,
2400 meas_rep->len - 3 - sizeof(*civic)))
2401 return 0;
2403 else if(meas_rep->type == 12) {
2404 struct element_meas_loc_id *id;
2406 id = (struct element_meas_loc_id *)
2407 pkt_pull(pkt, sizeof(*id));
2408 if (id == NULL)
2409 return 0;
2411 if ((meas_rep->len - 3 - sizeof(*id)) >= 0) {
2412 tprintf("Length of Req matchs not Type %u",
2413 meas_rep->type);
2414 return 0;
2417 tprintf("Location Subj: %u, ", id->loc_subj);
2418 tprintf("Srv Intv Units: %u, ",
2419 le16_to_cpu(id->loc_srv_intv_unit));
2420 tprintf("Srv Intv: %u", id->loc_srv_intv);
2422 if(!subelements(pkt,
2423 meas_rep->len - 3 - sizeof(*id)))
2424 return 0;
2426 else {
2427 tprintf("Length field indicates data,"
2428 " but could not interpreted");
2429 return 0;
2433 return 1;
2436 static int8_t inf_quiet(struct pkt_buff *pkt, u8 *id)
2438 struct element_quiet *quiet;
2440 quiet = (struct element_quiet *) pkt_pull(pkt, sizeof(*quiet));
2441 if (quiet == NULL)
2442 return 0;
2444 tprintf("Quit (%u, Len(%u)): ", *id, quiet->len);
2445 if (len_neq_error(quiet->len, 6))
2446 return 0;
2448 tprintf("Count: %ud, ", quiet->cnt);
2449 tprintf("Period: %u, ", quiet->period);
2450 tprintf("Duration: %fs, ", le16_to_cpu(quiet->dur) * TU);
2451 tprintf("Offs: %fs", le16_to_cpu(quiet->offs) * TU);
2454 return 1;
2457 static int8_t inf_ibss_dfs(struct pkt_buff *pkt, u8 *id)
2459 struct element_ibss_dfs *ibss_dfs;
2460 u8 i;
2462 ibss_dfs = (struct element_ibss_dfs *) pkt_pull(pkt, sizeof(*ibss_dfs));
2463 if (ibss_dfs == NULL)
2464 return 0;
2466 tprintf("IBSS DFS (%u, Len(%u)): ", *id, ibss_dfs->len);
2467 if (len_lt_error(ibss_dfs->len, 7))
2468 return 0;
2470 tprintf("Owner: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
2471 ibss_dfs->owner[0], ibss_dfs->owner[1],
2472 ibss_dfs->owner[2], ibss_dfs->owner[3],
2473 ibss_dfs->owner[4], ibss_dfs->owner[5]);
2474 tprintf("Recovery Intv: %u, ", ibss_dfs->rec_intv);
2476 if((ibss_dfs->len - sizeof(*ibss_dfs) + 1) & 1) {
2477 tprintf("Length of Channel Map should be modulo 2");
2478 return 0;
2481 for (i = 0; i < ibss_dfs->len; i += 2) {
2482 struct element_ibss_dfs_tuple *ibss_dfs_tuple;
2484 ibss_dfs_tuple = (struct element_ibss_dfs_tuple *)
2485 pkt_pull(pkt, sizeof(*ibss_dfs_tuple));
2486 if (ibss_dfs_tuple == NULL)
2487 return 0;
2489 tprintf("Channel Nr: %u, ", ibss_dfs_tuple->ch_nr);
2490 tprintf("Map: %u, ", ibss_dfs_tuple->map);
2493 return 1;
2496 static int8_t inf_erp(struct pkt_buff *pkt, u8 *id)
2498 struct element_erp *erp;
2500 erp = (struct element_erp *) pkt_pull(pkt, sizeof(*erp));
2501 if (erp == NULL)
2502 return 0;
2504 tprintf("ERP (%u, Len(%u)): ", *id, erp->len);
2505 if (len_neq_error(erp->len, 1))
2506 return 0;
2507 tprintf("Non ERP Present (%u), ", erp->param & 0x1);
2508 tprintf("Use Protection (%u), ", (erp->param >> 1) & 0x1);
2509 tprintf("Barker Preamble Mode (%u), ", (erp->param >> 2) & 0x1);
2510 tprintf("Reserved (0x%.5x)", erp->param >> 3);
2512 return 1;
2515 static int8_t inf_ts_del(struct pkt_buff *pkt, u8 *id)
2517 struct element_ts_del *ts_del;
2519 ts_del = (struct element_ts_del *) pkt_pull(pkt, sizeof(*ts_del));
2520 if (ts_del == NULL)
2521 return 0;
2523 tprintf("TS Delay (%u, Len(%u)): ", *id, ts_del->len);
2524 if (len_neq_error(ts_del->len, 4))
2525 return 0;
2526 tprintf("Delay (%fs)", le32_to_cpu(ts_del->delay) * TU);
2528 return 1;
2531 static int8_t inf_tclas_proc(struct pkt_buff *pkt, u8 *id)
2533 struct element_tclas_proc *tclas_proc;
2535 tclas_proc = (struct element_tclas_proc *)
2536 pkt_pull(pkt, sizeof(*tclas_proc));
2537 if (tclas_proc == NULL)
2538 return 0;
2540 tprintf("TCLAS Procesing (%u, Len(%u)): ", *id, tclas_proc->len);
2541 if (len_neq_error(tclas_proc->len, 1))
2542 return 0;
2543 tprintf("Processing (%u)", tclas_proc->proc);
2545 return 1;
2548 static int8_t inf_ht_cap(struct pkt_buff *pkt, u8 *id)
2550 struct element_ht_cap *ht_cap;
2551 u32 tx_param_res, beam_cap;
2552 u16 ext_cap;
2554 ht_cap = (struct element_ht_cap *)
2555 pkt_pull(pkt, sizeof(*ht_cap));
2556 if (ht_cap == NULL)
2557 return 0;
2559 tx_param_res = le32_to_cpu(ht_cap->tx_param_res);
2560 beam_cap = le32_to_cpu(ht_cap->beam_cap);
2561 ext_cap = le16_to_cpu(ht_cap->ext_cap);
2563 tprintf("HT Capabilities (%u, Len(%u)): ", *id, ht_cap->len);
2564 if (len_neq_error(ht_cap->len, 26))
2565 return 0;
2566 tprintf("Info (LDCP Cod Cap (%u), Supp Ch Width Set (%u),"
2567 " SM Pwr Save(%u), HT-Greenfield (%u), Short GI for 20/40 MHz"
2568 " (%u/%u), Tx/Rx STBC (%u/%u), HT-Delayed Block Ack (%u),"
2569 " Max A-MSDU Len (%u), DSSS/CCK Mode in 40 MHz (%u),"
2570 " Res (0x%x), Forty MHz Intol (%u), L-SIG TXOP Protection Supp"
2571 " (%u)), ", ht_cap->ldpc, ht_cap->supp_width,
2572 ht_cap->sm_pwr, ht_cap->ht_green, ht_cap->gi_20mhz,
2573 ht_cap->gi_40mhz, ht_cap->tx_stbc, ht_cap->rx_stbc,
2574 ht_cap->ht_ack, ht_cap->max_msdu_length, ht_cap->dsss_ck_mode,
2575 ht_cap->res, ht_cap->forty_int, ht_cap->prot_supp);
2576 tprintf("A-MPDU Params (Max Len Exp (%u), Min Start Spacing (%u),"
2577 " Res (0x%x)), ", ht_cap->param >> 6, (ht_cap->param >> 3) & 0x7,
2578 ht_cap->param & 0x07);
2579 tprintf("Supp MCS Set (Rx MCS Bitmask (0x%x%x%x%x%x%x%x%x%x%x),"
2580 " Res (0x%x), Rx High Supp Data Rate (%u), Res (0x%x),"
2581 " Tx MCS Set Def (%u), Tx Rx MCS Set Not Eq (%u),"
2582 " Tx Max Number Spat Str Supp (%u),"
2583 " Tx Uneq Mod Supp (%u), Res (0x%x)), ",
2584 ht_cap->bitmask1, ht_cap->bitmask2, ht_cap->bitmask3,
2585 ht_cap->bitmask4, ht_cap->bitmask5, ht_cap->bitmask6,
2586 ht_cap->bitmask7, ht_cap->bitmask8, ht_cap->bitmask9,
2587 ht_cap->bitmask10_res >> 3, ht_cap->bitmask10_res & 0x7,
2588 le16_to_cpu(ht_cap->supp_rate_res) >> 6,
2589 le16_to_cpu(ht_cap->supp_rate_res) & 0x3F,
2590 tx_param_res >> 31, (tx_param_res >> 30) & 1,
2591 (tx_param_res >> 28) & 3, (tx_param_res >> 27) & 1,
2592 tx_param_res & 0x7FFFFFF);
2593 tprintf("Ext Cap (PCO (%u), PCO Trans Time (%u), Res (0x%x),"
2594 " MCS Feedb (%u), +HTC Supp (%u), RD Resp (%u), Res (0x%x)), ",
2595 ext_cap >> 15, (ext_cap >> 13) & 3, (ext_cap >> 8) & 0x1F,
2596 (ext_cap >> 6) & 3, (ext_cap >> 5) & 1, (ext_cap >> 4) & 1,
2597 ext_cap & 0xF);
2598 tprintf("Transm Beamf (Impl Transm Beamf Rec Cap (%u),"
2599 " Rec/Transm Stagg Sound Cap (%u/%u),"
2600 " Rec/Trans NDP Cap (%u/%u), Impl Transm Beamf Cap (%u),"
2601 " Cal (%u), Expl CSI Transm Beamf Cap (%u),"
2602 " Expl Noncmpr/Compr Steering Cap (%u/%u),"
2603 " Expl Trans Beamf CSI Feedb (%u),"
2604 " Expl Noncmpr/Cmpr Feedb Cap (%u/%u),"
2605 " Min Grpg (%u), CSI Num Beamf Ant Supp (%u),"
2606 " Noncmpr/Cmpr Steering Nr Beamf Ant Supp (%u/%u),"
2607 " CSI Max Nr Rows Beamf Supp (%u),"
2608 " Ch Estim Cap (%u), Res (0x%x)), ",
2609 beam_cap >> 31, (beam_cap >> 30) & 1, (beam_cap >> 29) & 1,
2610 (beam_cap >> 28) & 1, (beam_cap >> 27) & 1, (beam_cap >> 26) & 1,
2611 (beam_cap >> 24) & 3, (beam_cap >> 23) & 1, (beam_cap >> 22) & 1,
2612 (beam_cap >> 21) & 1, (beam_cap >> 19) & 3, (beam_cap >> 17) & 3,
2613 (beam_cap >> 15) & 3, (beam_cap >> 13) & 3, (beam_cap >> 11) & 3,
2614 (beam_cap >> 9) & 3, (beam_cap >> 7) & 3, (beam_cap >> 5) & 3,
2615 (beam_cap >> 3) & 3, beam_cap & 7);
2616 tprintf("ASEL (Ant Select Cap (%u),"
2617 " Expl CSI Feedb Based Transm ASEL Cap (%u),"
2618 " Ant Indic Feedb Based Transm ASEL Cap (%u),"
2619 " Expl CSI Feedb Cap (%u), Ant Indic Feedb Cap (%u),"
2620 " Rec ASEL Cap (%u), Transm Sound PPDUs Cap (%u), Res (0x%x))",
2621 ht_cap->asel_cap >> 7, (ht_cap->asel_cap >> 6) & 1,
2622 (ht_cap->asel_cap >> 5) & 1, (ht_cap->asel_cap >> 4) & 1,
2623 (ht_cap->asel_cap >> 3) & 1, (ht_cap->asel_cap >> 2) & 1,
2624 (ht_cap->asel_cap >> 1) & 1, ht_cap->asel_cap & 1);
2626 return 1;
2629 static int8_t inf_qos_cap(struct pkt_buff *pkt, u8 *id)
2631 struct element_qos_cap *qos_cap;
2633 qos_cap = (struct element_qos_cap *)
2634 pkt_pull(pkt, sizeof(*qos_cap));
2635 if (qos_cap == NULL)
2636 return 0;
2638 tprintf("QoS Capabilities (%u, Len(%u)): ", *id, qos_cap->len);
2639 if (len_neq_error(qos_cap->len, 1))
2640 return 0;
2642 tprintf("Info (0x%x)", qos_cap->info);
2644 return 1;
2647 static int8_t inf_rsn(struct pkt_buff *pkt, u8 *id)
2649 return 0;
2652 static int8_t inf_ext_supp_rates(struct pkt_buff *pkt, u8 *id)
2654 u8 i;
2655 u8 *rates;
2656 struct element_ext_supp_rates *ext_supp_rates;
2658 ext_supp_rates = (struct element_ext_supp_rates *)
2659 pkt_pull(pkt, sizeof(*ext_supp_rates));
2660 if (ext_supp_rates == NULL)
2661 return 0;
2663 tprintf("Ext Support Rates (%u, Len(%u)): ", *id, ext_supp_rates->len);
2665 if ((ext_supp_rates->len - sizeof(*ext_supp_rates) + 1) > 0) {
2666 rates = pkt_pull(pkt, ext_supp_rates->len);
2667 if (rates == NULL)
2668 return 0;
2670 for (i = 0; i < ext_supp_rates->len; i++)
2671 tprintf("%g ", (rates[i] & 0x80) ?
2672 ((rates[i] & 0x3f) * 0.5) :
2673 data_rates(rates[i]));
2674 return 1;
2677 return 0;
2680 static int8_t inf_ap_ch_exp(struct pkt_buff *pkt, u8 *id) {
2681 return 0;
2684 static int8_t inf_neighb_rep(struct pkt_buff *pkt, u8 *id) {
2685 return 0;
2688 static int8_t inf_rcpi(struct pkt_buff *pkt, u8 *id) {
2689 return 0;
2692 static int8_t inf_mde(struct pkt_buff *pkt, u8 *id) {
2693 return 0;
2696 static int8_t inf_fte(struct pkt_buff *pkt, u8 *id) {
2697 return 0;
2700 static int8_t inf_time_out_int(struct pkt_buff *pkt, u8 *id) {
2701 return 0;
2704 static int8_t inf_rde(struct pkt_buff *pkt, u8 *id) {
2705 return 0;
2708 static int8_t inf_dse_reg_loc(struct pkt_buff *pkt, u8 *id) {
2709 return 0;
2712 static int8_t inf_supp_op_class(struct pkt_buff *pkt, u8 *id) {
2713 return 0;
2716 static int8_t inf_ext_ch_sw_ann(struct pkt_buff *pkt, u8 *id) {
2717 return 0;
2720 static int8_t inf_ht_op(struct pkt_buff *pkt, u8 *id) {
2721 return 0;
2724 static int8_t inf_sec_ch_offs(struct pkt_buff *pkt, u8 *id) {
2725 return 0;
2728 static int8_t inf_bss_avg_acc_del(struct pkt_buff *pkt, u8 *id) {
2729 return 0;
2732 static int8_t inf_ant(struct pkt_buff *pkt, u8 *id) {
2733 return 0;
2736 static int8_t inf_rsni(struct pkt_buff *pkt, u8 *id) {
2737 return 0;
2740 static int8_t inf_meas_pilot_trans(struct pkt_buff *pkt, u8 *id) {
2741 return 0;
2744 static int8_t inf_bss_avl_adm_cap(struct pkt_buff *pkt, u8 *id) {
2745 return 0;
2748 static int8_t inf_bss_ac_acc_del(struct pkt_buff *pkt, u8 *id) {
2749 return 0;
2752 static int8_t inf_time_adv(struct pkt_buff *pkt, u8 *id) {
2753 return 0;
2756 static int8_t inf_rm_ena_cap(struct pkt_buff *pkt, u8 *id) {
2757 return 0;
2760 static int8_t inf_mult_bssid(struct pkt_buff *pkt, u8 *id) {
2761 return 0;
2764 static int8_t inf_20_40_bss_coex(struct pkt_buff *pkt, u8 *id) {
2765 return 0;
2768 static int8_t inf_20_40_bss_int_ch_rep(struct pkt_buff *pkt, u8 *id) {
2769 return 0;
2772 static int8_t inf_overl_bss_scan_para(struct pkt_buff *pkt, u8 *id) {
2773 return 0;
2776 static int8_t inf_ric_desc(struct pkt_buff *pkt, u8 *id) {
2777 return 0;
2780 static int8_t inf_mgmt_mic(struct pkt_buff *pkt, u8 *id) {
2781 return 0;
2784 static int8_t inf_ev_req(struct pkt_buff *pkt, u8 *id) {
2785 return 0;
2788 static int8_t inf_ev_rep(struct pkt_buff *pkt, u8 *id) {
2789 return 0;
2792 static int8_t inf_diagn_req(struct pkt_buff *pkt, u8 *id) {
2793 return 0;
2796 static int8_t inf_diagn_rep(struct pkt_buff *pkt, u8 *id) {
2797 return 0;
2800 static int8_t inf_loc_para(struct pkt_buff *pkt, u8 *id) {
2801 return 0;
2804 static int8_t inf_nontr_bssid_cap(struct pkt_buff *pkt, u8 *id) {
2805 return 0;
2808 static int8_t inf_ssid_list(struct pkt_buff *pkt, u8 *id) {
2809 return 0;
2812 static int8_t inf_mult_bssid_index(struct pkt_buff *pkt, u8 *id) {
2813 return 0;
2816 static int8_t inf_fms_desc(struct pkt_buff *pkt, u8 *id) {
2817 return 0;
2820 static int8_t inf_fms_req(struct pkt_buff *pkt, u8 *id) {
2821 return 0;
2824 static int8_t inf_fms_resp(struct pkt_buff *pkt, u8 *id) {
2825 return 0;
2828 static int8_t inf_qos_tfc_cap(struct pkt_buff *pkt, u8 *id) {
2829 return 0;
2832 static int8_t inf_bss_max_idle_per(struct pkt_buff *pkt, u8 *id) {
2833 return 0;
2836 static int8_t inf_tfs_req(struct pkt_buff *pkt, u8 *id) {
2837 return 0;
2840 static int8_t inf_tfs_resp(struct pkt_buff *pkt, u8 *id) {
2841 return 0;
2844 static int8_t inf_wnm_sleep_mod(struct pkt_buff *pkt, u8 *id) {
2845 return 0;
2848 static int8_t inf_tim_bcst_req(struct pkt_buff *pkt, u8 *id) {
2849 return 0;
2852 static int8_t inf_tim_bcst_resp(struct pkt_buff *pkt, u8 *id) {
2853 return 0;
2856 static int8_t inf_coll_interf_rep(struct pkt_buff *pkt, u8 *id) {
2857 return 0;
2860 static int8_t inf_ch_usage(struct pkt_buff *pkt, u8 *id) {
2861 return 0;
2864 static int8_t inf_time_zone(struct pkt_buff *pkt, u8 *id) {
2865 return 0;
2868 static int8_t inf_dms_req(struct pkt_buff *pkt, u8 *id) {
2869 return 0;
2872 static int8_t inf_dms_resp(struct pkt_buff *pkt, u8 *id) {
2873 return 0;
2876 static int8_t inf_link_id(struct pkt_buff *pkt, u8 *id) {
2877 return 0;
2880 static int8_t inf_wakeup_sched(struct pkt_buff *pkt, u8 *id) {
2881 return 0;
2884 static int8_t inf_ch_sw_timing(struct pkt_buff *pkt, u8 *id) {
2885 return 0;
2888 static int8_t inf_pti_ctrl(struct pkt_buff *pkt, u8 *id) {
2889 return 0;
2892 static int8_t inf_tpu_buff_status(struct pkt_buff *pkt, u8 *id) {
2893 return 0;
2896 static int8_t inf_interw(struct pkt_buff *pkt, u8 *id) {
2897 return 0;
2900 static int8_t inf_adv_proto(struct pkt_buff *pkt, u8 *id) {
2901 return 0;
2904 static int8_t inf_exp_bandw_req(struct pkt_buff *pkt, u8 *id) {
2905 return 0;
2908 static int8_t inf_qos_map_set(struct pkt_buff *pkt, u8 *id) {
2909 return 0;
2912 static int8_t inf_roam_cons(struct pkt_buff *pkt, u8 *id) {
2913 return 0;
2916 static int8_t inf_emer_alert_id(struct pkt_buff *pkt, u8 *id) {
2917 return 0;
2920 static int8_t inf_mesh_conf(struct pkt_buff *pkt, u8 *id) {
2921 return 0;
2924 static int8_t inf_mesh_id(struct pkt_buff *pkt, u8 *id) {
2925 return 0;
2928 static int8_t inf_mesh_link_metr_rep(struct pkt_buff *pkt, u8 *id) {
2929 return 0;
2932 static int8_t inf_cong_notif(struct pkt_buff *pkt, u8 *id) {
2933 return 0;
2936 static int8_t inf_mesh_peer_mgmt(struct pkt_buff *pkt, u8 *id) {
2937 return 0;
2940 static int8_t inf_mesh_ch_sw_para(struct pkt_buff *pkt, u8 *id) {
2941 return 0;
2944 static int8_t inf_mesh_awake_win(struct pkt_buff *pkt, u8 *id) {
2945 return 0;
2948 static int8_t inf_beacon_timing(struct pkt_buff *pkt, u8 *id) {
2949 return 0;
2952 static int8_t inf_mccaop_setup_req(struct pkt_buff *pkt, u8 *id) {
2953 return 0;
2956 static int8_t inf_mccaop_setup_rep(struct pkt_buff *pkt, u8 *id) {
2957 return 0;
2960 static int8_t inf_mccaop_adv(struct pkt_buff *pkt, u8 *id) {
2961 return 0;
2964 static int8_t inf_mccaop_teardwn(struct pkt_buff *pkt, u8 *id) {
2965 return 0;
2968 static int8_t inf_gann(struct pkt_buff *pkt, u8 *id) {
2969 return 0;
2972 static int8_t inf_rann(struct pkt_buff *pkt, u8 *id) {
2973 return 0;
2976 static int8_t inf_ext_cap(struct pkt_buff *pkt, u8 *id) {
2977 return 0;
2980 static int8_t inf_preq(struct pkt_buff *pkt, u8 *id) {
2981 return 0;
2984 static int8_t inf_prep(struct pkt_buff *pkt, u8 *id) {
2985 return 0;
2988 static int8_t inf_perr(struct pkt_buff *pkt, u8 *id) {
2989 return 0;
2992 static int8_t inf_pxu(struct pkt_buff *pkt, u8 *id) {
2993 return 0;
2996 static int8_t inf_pxuc(struct pkt_buff *pkt, u8 *id) {
2997 return 0;
3000 static int8_t inf_auth_mesh_peer_exch(struct pkt_buff *pkt, u8 *id) {
3001 return 0;
3004 static int8_t inf_mic(struct pkt_buff *pkt, u8 *id) {
3005 return 0;
3008 static int8_t inf_dest_uri(struct pkt_buff *pkt, u8 *id) {
3009 return 0;
3012 static int8_t inf_u_apsd_coex(struct pkt_buff *pkt, u8 *id) {
3013 return 0;
3016 static int8_t inf_mccaop_adv_overv(struct pkt_buff *pkt, u8 *id) {
3017 return 0;
3020 static int8_t inf_vend_spec(struct pkt_buff *pkt, u8 *id)
3022 u8 i;
3023 u8 *data;
3024 struct element_vend_spec *vend_spec;
3026 vend_spec = (struct element_vend_spec *)
3027 pkt_pull(pkt, sizeof(*vend_spec));
3028 if (vend_spec == NULL)
3029 return 0;
3031 tprintf("Vendor Specific (%u, Len (%u)): ", *id, vend_spec->len);
3033 data = pkt_pull(pkt, vend_spec->len);
3034 if (data == NULL)
3035 return 0;
3037 tprintf("Data 0x");
3038 for (i = 0; i < vend_spec->len; i++)
3039 tprintf("%.2x", data[i]);
3041 return 1;
3044 static int8_t inf_elements(struct pkt_buff *pkt)
3046 u8 *id = pkt_pull(pkt, 1);
3047 if (id == NULL)
3048 return 0;
3050 switch (*id) {
3051 case 0: return inf_ssid(pkt, id);
3052 case 1: return inf_supp_rates(pkt, id);
3053 case 2: return inf_fh_ps(pkt, id);
3054 case 3: return inf_dsss_ps(pkt, id);
3055 case 4: return inf_cf_ps(pkt, id);
3056 case 5: return inf_tim(pkt, id);
3057 case 6: return inf_ibss_ps(pkt, id);
3058 case 7: return inf_country(pkt, id);
3059 case 8: return inf_hop_pp(pkt, id);
3060 case 9: return inf_hop_pt(pkt, id);
3061 case 10: return inf_req(pkt, id);
3062 case 11: return inf_bss_load(pkt, id);
3063 case 12: return inf_edca_ps(pkt, id);
3064 case 13: return inf_tspec(pkt, id);
3065 case 14: return inf_tclas(pkt, id);
3066 case 15: return inf_sched(pkt, id);
3067 case 16: return inf_chall_txt(pkt, id);
3068 case 17 ... 31: return inf_reserved(pkt, id);
3069 case 32: return inf_pwr_constr(pkt, id);
3070 case 33: return inf_pwr_cap(pkt, id);
3071 case 34: return inf_tpc_req(pkt, id);
3072 case 35: return inf_tpc_rep(pkt, id);
3073 case 36: return inf_supp_ch(pkt, id);
3074 case 37: return inf_ch_sw_ann(pkt, id);
3075 case 38: return inf_meas_req(pkt, id);
3076 case 39: return inf_meas_rep(pkt, id);
3077 case 40: return inf_quiet(pkt, id);
3078 case 41: return inf_ibss_dfs(pkt, id);
3079 case 42: return inf_erp(pkt, id);
3080 case 43: return inf_ts_del(pkt, id);
3081 case 44: return inf_tclas_proc(pkt, id);
3082 case 45: return inf_ht_cap(pkt, id);
3083 case 46: return inf_qos_cap(pkt, id);
3084 case 47: return inf_reserved(pkt, id);
3085 case 48: return inf_rsn(pkt, id);
3086 case 49: return inf_rsn(pkt, id);
3087 case 50: return inf_ext_supp_rates(pkt, id);
3088 case 51: return inf_ap_ch_exp(pkt, id);
3089 case 52: return inf_neighb_rep(pkt, id);
3090 case 53: return inf_rcpi(pkt, id);
3091 case 54: return inf_mde(pkt, id);
3092 case 55: return inf_fte(pkt, id);
3093 case 56: return inf_time_out_int(pkt, id);
3094 case 57: return inf_rde(pkt, id);
3095 case 58: return inf_dse_reg_loc(pkt, id);
3096 case 59: return inf_supp_op_class(pkt, id);
3097 case 60: return inf_ext_ch_sw_ann(pkt, id);
3098 case 61: return inf_ht_op(pkt, id);
3099 case 62: return inf_sec_ch_offs(pkt, id);
3100 case 63: return inf_bss_avg_acc_del(pkt, id);
3101 case 64: return inf_ant(pkt, id);
3102 case 65: return inf_rsni(pkt, id);
3103 case 66: return inf_meas_pilot_trans(pkt, id);
3104 case 67: return inf_bss_avl_adm_cap(pkt, id);
3105 case 68: return inf_bss_ac_acc_del(pkt, id);
3106 case 69: return inf_time_adv(pkt, id);
3107 case 70: return inf_rm_ena_cap(pkt, id);
3108 case 71: return inf_mult_bssid(pkt, id);
3109 case 72: return inf_20_40_bss_coex(pkt, id);
3110 case 73: return inf_20_40_bss_int_ch_rep(pkt, id);
3111 case 74: return inf_overl_bss_scan_para(pkt, id);
3112 case 75: return inf_ric_desc(pkt, id);
3113 case 76: return inf_mgmt_mic(pkt, id);
3114 case 78: return inf_ev_req(pkt, id);
3115 case 79: return inf_ev_rep(pkt, id);
3116 case 80: return inf_diagn_req(pkt, id);
3117 case 81: return inf_diagn_rep(pkt, id);
3118 case 82: return inf_loc_para(pkt, id);
3119 case 83: return inf_nontr_bssid_cap(pkt, id);
3120 case 84: return inf_ssid_list(pkt, id);
3121 case 85: return inf_mult_bssid_index(pkt, id);
3122 case 86: return inf_fms_desc(pkt, id);
3123 case 87: return inf_fms_req(pkt, id);
3124 case 88: return inf_fms_resp(pkt, id);
3125 case 89: return inf_qos_tfc_cap(pkt, id);
3126 case 90: return inf_bss_max_idle_per(pkt, id);
3127 case 91: return inf_tfs_req(pkt, id);
3128 case 92: return inf_tfs_resp(pkt, id);
3129 case 93: return inf_wnm_sleep_mod(pkt, id);
3130 case 94: return inf_tim_bcst_req(pkt, id);
3131 case 95: return inf_tim_bcst_resp(pkt, id);
3132 case 96: return inf_coll_interf_rep(pkt, id);
3133 case 97: return inf_ch_usage(pkt, id);
3134 case 98: return inf_time_zone(pkt, id);
3135 case 99: return inf_dms_req(pkt, id);
3136 case 100: return inf_dms_resp(pkt, id);
3137 case 101: return inf_link_id(pkt, id);
3138 case 102: return inf_wakeup_sched(pkt, id);
3139 case 104: return inf_ch_sw_timing(pkt, id);
3140 case 105: return inf_pti_ctrl(pkt, id);
3141 case 106: return inf_tpu_buff_status(pkt, id);
3142 case 107: return inf_interw(pkt, id);
3143 case 108: return inf_adv_proto(pkt, id);
3144 case 109: return inf_exp_bandw_req(pkt, id);
3145 case 110: return inf_qos_map_set(pkt, id);
3146 case 111: return inf_roam_cons(pkt, id);
3147 case 112: return inf_emer_alert_id(pkt, id);
3148 case 113: return inf_mesh_conf(pkt, id);
3149 case 114: return inf_mesh_id(pkt, id);
3150 case 115: return inf_mesh_link_metr_rep(pkt, id);
3151 case 116: return inf_cong_notif(pkt, id);
3152 case 117: return inf_mesh_peer_mgmt(pkt, id);
3153 case 118: return inf_mesh_ch_sw_para(pkt, id);
3154 case 119: return inf_mesh_awake_win(pkt, id);
3155 case 120: return inf_beacon_timing(pkt, id);
3156 case 121: return inf_mccaop_setup_req(pkt, id);
3157 case 122: return inf_mccaop_setup_rep(pkt, id);
3158 case 123: return inf_mccaop_adv(pkt, id);
3159 case 124: return inf_mccaop_teardwn(pkt, id);
3160 case 125: return inf_gann(pkt, id);
3161 case 126: return inf_rann(pkt, id);
3162 case 127: return inf_ext_cap(pkt, id);
3163 case 128: return inf_reserved(pkt, id);
3164 case 129: return inf_reserved(pkt, id);
3165 case 130: return inf_preq(pkt, id);
3166 case 131: return inf_prep(pkt, id);
3167 case 132: return inf_perr(pkt, id);
3168 case 133: return inf_reserved(pkt, id);
3169 case 134: return inf_reserved(pkt, id);
3170 case 135: return inf_reserved(pkt, id);
3171 case 136: return inf_reserved(pkt, id);
3172 case 137: return inf_pxu(pkt, id);
3173 case 138: return inf_pxuc(pkt, id);
3174 case 139: return inf_auth_mesh_peer_exch(pkt, id);
3175 case 140: return inf_mic(pkt, id);
3176 case 141: return inf_dest_uri(pkt, id);
3177 case 142: return inf_u_apsd_coex(pkt, id);
3178 case 143 ... 173: return inf_reserved(pkt, id);
3179 case 174: return inf_mccaop_adv_overv(pkt, id);
3180 case 221: return inf_vend_spec(pkt, id);
3183 return 0;
3186 #define ESS 0b0000000000000001
3187 #define IBSS 0b0000000000000010
3188 #define CF_Pollable 0b0000000000000100
3189 #define CF_Poll_Req 0b0000000000001000
3190 #define Privacy 0b0000000000010000
3191 #define Short_Pre 0b0000000000100000
3192 #define PBCC 0b0000000001000000
3193 #define Ch_Agility 0b0000000010000000
3194 #define Spec_Mgmt 0b0000000100000000
3195 #define QoS 0b0000001000000000
3196 #define Short_Slot_t 0b0000010000000000
3197 #define APSD 0b0000100000000000
3198 #define Radio_Meas 0b0001000000000000
3199 #define DSSS_OFDM 0b0010000000000000
3200 #define Del_Block_ACK 0b0100000000000000
3201 #define Imm_Block_ACK 0b1000000000000000
3203 static int8_t cap_field(u16 cap_inf)
3205 if (ESS & cap_inf)
3206 tprintf(" ESS;");
3207 if (IBSS & cap_inf)
3208 tprintf(" IBSS;");
3209 if (CF_Pollable & cap_inf)
3210 tprintf(" CF Pollable;");
3211 if (CF_Poll_Req & cap_inf)
3212 tprintf(" CF-Poll Request;");
3213 if (Privacy & cap_inf)
3214 tprintf(" Privacy;");
3215 if (Short_Pre & cap_inf)
3216 tprintf(" Short Preamble;");
3217 if (PBCC & cap_inf)
3218 tprintf(" PBCC;");
3219 if (Ch_Agility & cap_inf)
3220 tprintf(" Channel Agility;");
3221 if (Spec_Mgmt & cap_inf)
3222 tprintf(" Spectrum Management;");
3223 if (QoS & cap_inf)
3224 tprintf(" QoS;");
3225 if (Short_Slot_t & cap_inf)
3226 tprintf(" Short Slot Time;");
3227 if (APSD & cap_inf)
3228 tprintf(" APSD;");
3229 if (Radio_Meas & cap_inf)
3230 tprintf(" Radio Measurement;");
3231 if (DSSS_OFDM & cap_inf)
3232 tprintf(" DSSS-OFDM;");
3233 if (Del_Block_ACK & cap_inf)
3234 tprintf(" Delayed Block Ack;");
3235 if (Imm_Block_ACK & cap_inf)
3236 tprintf(" Immediate Block Ack;");
3238 return 1;
3241 /* Management Dissectors */
3242 static int8_t assoc_req(struct pkt_buff *pkt) {
3243 return 0;
3246 static int8_t assoc_resp(struct pkt_buff *pkt) {
3247 return 0;
3250 static int8_t reassoc_req(struct pkt_buff *pkt) {
3251 return 0;
3254 static int8_t reassoc_resp(struct pkt_buff *pkt) {
3255 return 0;
3258 static int8_t probe_req(struct pkt_buff *pkt) {
3259 return 0;
3262 static int8_t probe_resp(struct pkt_buff *pkt) {
3263 return 0;
3266 static int8_t beacon(struct pkt_buff *pkt)
3268 struct ieee80211_mgmt_beacon *beacon;
3270 beacon = (struct ieee80211_mgmt_beacon *)
3271 pkt_pull(pkt, sizeof(*beacon));
3272 if (beacon == NULL)
3273 return 0;
3275 tprintf("Timestamp 0x%.16lx, ", le64_to_cpu(beacon->timestamp));
3276 tprintf("Beacon Interval (%fs), ", le16_to_cpu(beacon->beacon_int)*TU);
3277 tprintf("Capabilities (0x%x <->", le16_to_cpu(beacon->capab_info));
3278 cap_field(le16_to_cpu(beacon->capab_info));
3279 tprintf(")");
3281 if(pkt_len(pkt)) {
3282 tprintf("\n\tParameters:");
3283 while (inf_elements(pkt)) {
3284 tprintf("\n\t");
3288 if(pkt_len(pkt))
3289 return 0;
3290 return 1;
3293 static int8_t atim(struct pkt_buff *pkt) {
3294 return 0;
3297 static int8_t disassoc(struct pkt_buff *pkt) {
3298 return 0;
3301 static int8_t auth(struct pkt_buff *pkt) {
3302 return 0;
3305 static int8_t deauth(struct pkt_buff *pkt) {
3306 return 0;
3308 /* End Management Dissectors */
3310 /* Control Dissectors */
3311 static int8_t ps_poll(struct pkt_buff *pkt) {
3312 return 0;
3315 static int8_t rts(struct pkt_buff *pkt) {
3316 return 0;
3319 static int8_t cts(struct pkt_buff *pkt) {
3320 return 0;
3323 static int8_t ack(struct pkt_buff *pkt) {
3324 return 0;
3327 static int8_t cf_end(struct pkt_buff *pkt) {
3328 return 0;
3331 static int8_t cf_end_ack(struct pkt_buff *pkt) {
3332 return 0;
3334 /* End Control Dissectors */
3336 /* Data Dissectors */
3337 static int8_t data(struct pkt_buff *pkt) {
3338 return 0;
3341 static int8_t data_cf_ack(struct pkt_buff *pkt) {
3342 return 0;
3345 static int8_t data_cf_poll(struct pkt_buff *pkt) {
3346 return 0;
3349 static int8_t data_cf_ack_poll(struct pkt_buff *pkt) {
3350 return 0;
3353 static int8_t null(struct pkt_buff *pkt) {
3354 return 0;
3357 static int8_t cf_ack(struct pkt_buff *pkt) {
3358 return 0;
3361 static int8_t cf_poll(struct pkt_buff *pkt) {
3362 return 0;
3365 static int8_t cf_ack_poll(struct pkt_buff *pkt) {
3366 return 0;
3368 /* End Data Dissectors */
3370 static const char *mgt_sub(u8 subtype, struct pkt_buff *pkt,
3371 int8_t (**get_content)(struct pkt_buff *pkt))
3373 u16 seq_ctrl;
3374 struct ieee80211_mgmt *mgmt;
3375 const char *dst, *src, *bssid;
3377 mgmt = (struct ieee80211_mgmt *) pkt_pull(pkt, sizeof(*mgmt));
3378 if (mgmt == NULL)
3379 return 0;
3381 dst = lookup_vendor((mgmt->da[0] << 16) |
3382 (mgmt->da[1] << 8) |
3383 mgmt->da[2]);
3384 src = lookup_vendor((mgmt->sa[0] << 16) |
3385 (mgmt->sa[1] << 8) |
3386 mgmt->sa[2]);
3388 bssid = lookup_vendor((mgmt->bssid[0] << 16) |
3389 (mgmt->bssid[1] << 8) |
3390 mgmt->bssid[2]);
3391 seq_ctrl = le16_to_cpu(mgmt->seq_ctrl);
3393 tprintf("Duration (%u),", le16_to_cpu(mgmt->duration));
3394 tprintf("\n\tDestination (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x) ",
3395 mgmt->da[0], mgmt->da[1], mgmt->da[2],
3396 mgmt->da[3], mgmt->da[4], mgmt->da[5]);
3397 if (dst) {
3398 tprintf("=> (%s:%.2x:%.2x:%.2x)", dst,
3399 mgmt->da[3], mgmt->da[4], mgmt->da[5]);
3402 tprintf("\n\tSource (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x) ",
3403 mgmt->sa[0], mgmt->sa[1], mgmt->sa[2],
3404 mgmt->sa[3], mgmt->sa[4], mgmt->sa[5]);
3405 if (src) {
3406 tprintf("=> (%s:%.2x:%.2x:%.2x)", src,
3407 mgmt->sa[3], mgmt->sa[4], mgmt->sa[5]);
3410 tprintf("\n\tBSSID (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x) ",
3411 mgmt->bssid[0], mgmt->bssid[1], mgmt->bssid[2],
3412 mgmt->bssid[3], mgmt->bssid[4], mgmt->bssid[5]);
3413 if(bssid) {
3414 tprintf("=> (%s:%.2x:%.2x:%.2x)", bssid,
3415 mgmt->bssid[3], mgmt->bssid[4], mgmt->bssid[5]);
3418 tprintf("\n\tFragmentnr. (%u), Seqnr. (%u). ",
3419 seq_ctrl & 0xf, seq_ctrl >> 4);
3421 switch (subtype) {
3422 case 0b0000:
3423 *get_content = assoc_req;
3424 return "Association Request";
3425 case 0b0001:
3426 *get_content = assoc_resp;
3427 return "Association Response";
3428 case 0b0010:
3429 *get_content = reassoc_req;
3430 return "Reassociation Request";
3431 case 0b0011:
3432 *get_content = reassoc_resp;
3433 return "Reassociation Response";
3434 case 0b0100:
3435 *get_content = probe_req;
3436 return "Probe Request";
3437 case 0b0101:
3438 *get_content = probe_resp;
3439 return "Probe Response";
3440 case 0b1000:
3441 *get_content = beacon;
3442 return "Beacon";
3443 case 0b1001:
3444 *get_content = atim;
3445 return "ATIM";
3446 case 0b1010:
3447 *get_content = disassoc;
3448 return "Disassociation";
3449 case 0b1011:
3450 *get_content = auth;
3451 return "Authentication";
3452 case 0b1100:
3453 *get_content = deauth;
3454 return "Deauthentication";
3455 case 0b0110 ... 0b0111:
3456 case 0b1101 ... 0b1111:
3457 *get_content = NULL;
3458 return "Reserved";
3459 default:
3460 *get_content = NULL;
3461 return "Management SubType unknown";
3465 static const char *ctrl_sub(u8 subtype, struct pkt_buff *pkt,
3466 int8_t (**get_content)(struct pkt_buff *pkt))
3468 switch (subtype) {
3469 case 0b1010:
3470 *get_content = ps_poll;
3471 return "PS-Poll";
3472 case 0b1011:
3473 *get_content = rts;
3474 return "RTS";
3475 case 0b1100:
3476 *get_content = cts;
3477 return "CTS";
3478 case 0b1101:
3479 *get_content = ack;
3480 return "ACK";
3481 case 0b1110:
3482 *get_content = cf_end;
3483 return "CF End";
3484 case 0b1111:
3485 *get_content = cf_end_ack;
3486 return "CF End + CF-ACK";
3487 case 0b0000 ... 0b1001:
3488 *get_content = NULL;
3489 return "Reserved";
3490 default:
3491 return "Control SubType unkown";
3495 static const char *data_sub(u8 subtype, struct pkt_buff *pkt,
3496 int8_t (**get_content)(struct pkt_buff *pkt))
3498 switch (subtype) {
3499 case 0b0000:
3500 *get_content = data;
3501 return "Data";
3502 case 0b0001:
3503 *get_content = data_cf_ack;
3504 return "Data + CF-ACK";
3505 case 0b0010:
3506 *get_content = data_cf_poll;
3507 return "Data + CF-Poll";
3508 case 0b0011:
3509 *get_content = data_cf_ack_poll;
3510 return "Data + CF-ACK + CF-Poll";
3511 case 0b0100:
3512 *get_content = null;
3513 return "Null";
3514 case 0b0101:
3515 *get_content = cf_ack;
3516 return "CF-ACK";
3517 case 0b0110:
3518 *get_content = cf_poll;
3519 return "CF-Poll";
3520 case 0b0111:
3521 *get_content = cf_ack_poll;
3522 return "CF-ACK + CF-Poll";
3523 case 0b1000 ... 0b1111:
3524 *get_content = NULL;
3525 return "Reserved";
3526 default:
3527 *get_content = NULL;
3528 return "Data SubType unkown";
3532 static const char *
3533 frame_control_type(u8 type, const char *(**get_subtype)(u8 subtype,
3534 struct pkt_buff *pkt, int8_t (**get_content)(struct pkt_buff *pkt)))
3536 switch (type) {
3537 case 0b00:
3538 *get_subtype = mgt_sub;
3539 return "Management";
3540 case 0b01:
3541 *get_subtype = ctrl_sub;
3542 return "Control";
3543 case 0b10:
3544 *get_subtype = data_sub;
3545 return "Data";
3546 case 0b11:
3547 *get_subtype = NULL;
3548 return "Reserved";
3549 default:
3550 *get_subtype = NULL;
3551 return "Control Type unkown";
3555 static void ieee80211(struct pkt_buff *pkt)
3557 int8_t (*get_content)(struct pkt_buff *pkt) = NULL;
3558 const char *(*get_subtype)(u8 subtype, struct pkt_buff *pkt,
3559 int8_t (**get_content)(struct pkt_buff *pkt)) = NULL;
3560 const char *subtype = NULL;
3561 struct ieee80211_frm_ctrl *frm_ctrl;
3563 frm_ctrl = (struct ieee80211_frm_ctrl *)
3564 pkt_pull(pkt, sizeof(*frm_ctrl));
3565 if (frm_ctrl == NULL)
3566 return;
3568 tprintf(" [ 802.11 Frame Control (0x%04x)]\n",
3569 le16_to_cpu(frm_ctrl->frame_control));
3571 tprintf(" [ Proto Version (%u), ", frm_ctrl->proto_version);
3572 tprintf("Type (%u, %s), ", frm_ctrl->type,
3573 frame_control_type(frm_ctrl->type, &get_subtype));
3574 if (get_subtype) {
3575 subtype = (*get_subtype)(frm_ctrl->subtype, pkt, &get_content);
3576 tprintf("Subtype (%u, %s)", frm_ctrl->subtype, subtype);
3577 } else {
3578 tprintf("%s%s%s", colorize_start_full(black, red),
3579 "No SubType Data available", colorize_end());
3582 tprintf("%s%s", frm_ctrl->to_ds ? ", Frame goes to DS" : "",
3583 frm_ctrl->from_ds ? ", Frame comes from DS" : "");
3584 tprintf("%s", frm_ctrl->more_frags ? ", More Fragments" : "");
3585 tprintf("%s", frm_ctrl->retry ? ", Frame is retransmitted" : "");
3586 tprintf("%s", frm_ctrl->power_mgmt ? ", In Power Saving Mode" : "");
3587 tprintf("%s", frm_ctrl->more_data ? ", More Data" : "");
3588 tprintf("%s", frm_ctrl->wep ? ", Needs WEP" : "");
3589 tprintf("%s", frm_ctrl->order ? ", Order" : "");
3590 tprintf(" ]\n");
3592 if (get_content) {
3593 tprintf(" [ Subtype %s: ", subtype);
3594 if (!((*get_content) (pkt)))
3595 tprintf("%s%s%s", colorize_start_full(black, red),
3596 "Failed to dissect Subtype", colorize_end());
3597 tprintf(" ]");
3598 } else {
3599 tprintf("%s%s%s", colorize_start_full(black, red),
3600 "No SubType Data available", colorize_end());
3603 tprintf("\n");
3605 // pkt_set_proto(pkt, &ieee802_lay2, ntohs(eth->h_proto));
3608 static void ieee80211_less(struct pkt_buff *pkt)
3610 tprintf("802.11 frame (more on todo)");
3613 struct protocol ieee80211_ops = {
3614 .key = 0,
3615 .print_full = ieee80211,
3616 .print_less = ieee80211_less,
3619 EXPORT_SYMBOL(ieee80211_ops);