proto_80211_mac_hdr.c: add element ibss_dfs, quit and measurement report
[netsniff-ng.git] / src / proto_80211_mac_hdr.c
blob2ab9fd6c94ac27ffc9f34bf74c96c8e0bbf32e80
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 #include <stdio.h>
9 #include <stdint.h>
10 #include <netinet/in.h> /* for ntohs() */
11 #include <asm/byteorder.h>
12 #include <arpa/inet.h> /* for inet_ntop() */
14 #include "proto.h"
15 #include "protos.h"
16 #include "dissector_80211.h"
17 #include "built_in.h"
18 #include "pkt_buff.h"
19 #include "oui.h"
21 #define TU 0.001024
23 /* Note: Fields are encoded in little-endian! */
24 struct ieee80211_frm_ctrl {
25 union {
26 u16 frame_control;
27 struct {
28 #if defined(__LITTLE_ENDIAN_BITFIELD)
29 /* Correct order here ... */
30 __extension__ u16 proto_version:2,
31 type:2,
32 subtype:4,
33 to_ds:1,
34 from_ds:1,
35 more_frags:1,
36 retry:1,
37 power_mgmt:1,
38 more_data:1,
39 wep:1,
40 order:1;
41 #elif defined(__BIG_ENDIAN_BITFIELD)
42 __extension__ u16 subtype:4,
43 type:2,
44 proto_version:2,
45 order:1,
46 wep:1,
47 more_data:1,
48 power_mgmt:1,
49 retry:1,
50 more_frags:1,
51 from_ds:1,
52 to_ds:1;
53 #else
54 # error "Adjust your <asm/byteorder.h> defines"
55 #endif
58 } __packed;
60 /* Management Frame start */
61 /* Note: Fields are encoded in little-endian! */
62 struct ieee80211_mgmt {
63 u16 duration;
64 u8 da[6];
65 u8 sa[6];
66 u8 bssid[6];
67 u16 seq_ctrl;
68 } __packed;
70 struct ieee80211_mgmt_auth {
71 u16 auth_alg;
72 u16 auth_transaction;
73 u16 status_code;
74 /* possibly followed by Challenge text */
75 u8 variable[0];
76 } __packed;
78 struct ieee80211_mgmt_deauth {
79 u16 reason_code;
80 } __packed;
82 struct ieee80211_mgmt_assoc_req {
83 u16 capab_info;
84 u16 listen_interval;
85 /* followed by SSID and Supported rates */
86 u8 variable[0];
87 } __packed;
89 struct ieee80211_mgmt_assoc_resp {
90 u16 capab_info;
91 u16 status_code;
92 u16 aid;
93 /* followed by Supported rates */
94 u8 variable[0];
95 } __packed;
97 struct ieee80211_mgmt_reassoc_resp {
98 u16 capab_info;
99 u16 status_code;
100 u16 aid;
101 /* followed by Supported rates */
102 u8 variable[0];
103 } __packed;
105 struct ieee80211_mgmt_reassoc_req {
106 u16 capab_info;
107 u16 listen_interval;
108 u8 current_ap[6];
109 /* followed by SSID and Supported rates */
110 u8 variable[0];
111 } __packed;
113 struct ieee80211_mgmt_disassoc {
114 u16 reason_code;
115 } __packed;
117 struct ieee80211_mgmt_probe_req {
118 } __packed;
120 struct ieee80211_mgmt_beacon {
121 u64 timestamp;
122 u16 beacon_int;
123 u16 capab_info;
124 /* followed by some of SSID, Supported rates,
125 * FH Params, DS Params, CF Params, IBSS Params, TIM */
126 u8 variable[0];
127 } __packed;
129 struct ieee80211_mgmt_probe_resp {
130 u8 timestamp[8];
131 u16 beacon_int;
132 u16 capab_info;
133 /* followed by some of SSID, Supported rates,
134 * FH Params, DS Params, CF Params, IBSS Params, TIM */
135 u8 variable[0];
136 } __packed;
137 /* Management Frame end */
139 /* Control Frame start */
140 /* Note: Fields are encoded in little-endian! */
141 struct ieee80211_ctrl {
142 } __packed;
144 struct ieee80211_ctrl_rts {
145 u16 duration;
146 u8 da[6];
147 u8 sa[6];
148 } __packed;
150 struct ieee80211_ctrl_cts {
151 u16 duration;
152 u8 da[6];
153 } __packed;
155 struct ieee80211_ctrl_ack {
156 u16 duration;
157 u8 da[6];
158 } __packed;
160 struct ieee80211_ctrl_ps_poll {
161 u16 aid;
162 u8 bssid[6];
163 u8 sa[6];
164 } __packed;
166 struct ieee80211_ctrl_cf_end {
167 u16 duration;
168 u8 bssid[6];
169 u8 sa[6];
170 } __packed;
172 struct ieee80211_ctrl_cf_end_ack {
173 u16 duration;
174 u8 bssid[6];
175 u8 sa[6];
176 } __packed;
177 /* Control Frame end */
179 /* Data Frame start */
180 /* Note: Fields are encoded in little-endian! */
181 struct ieee80211_data {
182 } __packed;
184 /* TODO: Extend */
185 /* Data Frame end */
187 /* http://www.sss-mag.com/pdf/802_11tut.pdf
188 * http://www.scribd.com/doc/78443651/111/Management-Frames
189 * http://www.wildpackets.com/resources/compendium/wireless_lan/wlan_packets
190 * http://www.rhyshaden.com/wireless.htm
193 struct element_reserved {
194 u8 len;
195 } __packed;
197 struct element_ssid {
198 u8 len;
199 u8 SSID[0];
200 } __packed;
202 struct element_supp_rates {
203 u8 len;
204 u8 SSID[0];
205 } __packed;
207 struct element_fh_ps {
208 u8 len;
209 u16 dwell_time;
210 u8 hop_set;
211 u8 hop_pattern;
212 u8 hop_index;
213 } __packed;
215 struct element_dsss_ps {
216 u8 len;
217 u8 curr_ch;
218 } __packed;
220 struct element_cf_ps {
221 u8 len;
222 u8 cfp_cnt;
223 u8 cfp_period;
224 u16 cfp_max_dur;
225 u16 cfp_dur_rem;
226 } __packed;
228 struct element_tim {
229 u8 len;
230 u8 dtim_cnt;
231 u8 dtim_period;
232 u8 bmp_cntrl;
233 u8 part_virt_bmp[0];
234 } __packed;
236 struct element_ibss_ps {
237 u8 len;
238 u16 atim_win;
239 } __packed;
241 struct element_country_tripled {
242 u8 frst_ch;
243 u8 nr_ch;
244 u8 max_trans;
245 } __packed;
247 struct element_country {
248 u8 len;
249 #if defined(__LITTLE_ENDIAN_BITFIELD)
250 /* Correct order here ... */
251 u8 country_first;
252 u8 country_sec;
253 u8 country_third;
254 #elif defined(__BIG_ENDIAN_BITFIELD)
255 u8 country_third;
256 u8 country_sec;
257 u8 country_first;
258 #else
259 # error "Adjust your <asm/byteorder.h> defines"
260 #endif
261 /* triplet may repeat */
262 struct element_country_tripled tripled [0];
263 /* end triplet */
264 u8 pad[0];
265 } __packed;
267 struct element_hop_pp {
268 u8 len;
269 u8 prime_radix;
270 u8 nr_ch;
271 } __packed;
273 struct element_hop_pt {
274 u8 len;
275 u8 flag;
276 u8 nr_sets;
277 u8 modules;
278 u8 offs;
279 u8 rand_tabl[0];
280 } __packed;
282 struct element_req {
283 u8 len;
284 u8 req_elem_idl[0];
285 } __packed;
287 struct element_bss_load {
288 u8 len;
289 u16 station_cnt;
290 u8 ch_util;
291 u16 avlb_adm_cap;
292 } __packed;
294 struct element_edca_ps {
295 u8 len;
296 u8 qos_inf;
297 u8 res;
298 u32 ac_be;
299 u32 ac_bk;
300 u32 ac_vi;
301 u32 ac_vo;
302 } __packed;
304 struct element_tspec {
305 union {
306 u32 len_ts_info;
307 struct {
308 #if defined(__LITTLE_ENDIAN_BITFIELD)
309 /* Correct order here ... */
310 __extension__ u32 len:8,
311 traffic_type:1,
312 tsid:4,
313 direction:2,
314 access_policy:2,
315 aggr:1,
316 apsid:1,
317 user_prior:3,
318 tsinfo_ack_pol:2,
319 schedule:1,
320 res:7;
321 #elif defined(__BIG_ENDIAN_BITFIELD)
322 __extension__ u32 len:8,
323 res:7,
324 schedule:1,
325 tsinfo_ack_pol:2,
326 user_prior:3,
327 apsid:1,
328 aggr:1,
329 access_policy:2,
330 direction:2,
331 tsid:4,
332 traffic_type:1;
333 #else
334 # error "Adjust your <asm/byteorder.h> defines"
335 #endif
338 u16 nom_msdu_size;
339 u16 max_msdu_size;
340 u32 min_srv_intv;
341 u32 max_srv_intv;
342 u32 inactive_intv;
343 u32 susp_intv;
344 u32 srv_start_time;
345 u32 min_data_rate;
346 u32 mean_data_rate;
347 u32 peak_data_rate;
348 u32 burst_size;
349 u32 delay_bound;
350 u32 min_phy_rate;
351 u16 surplus_bandw_allow;
352 u16 med_time;
353 } __packed;
355 struct element_tclas {
356 u8 len;
357 u8 user_priority;
358 u8 frm_class[0];
359 } __packed;
361 struct element_tclas_frm_class {
362 u8 type;
363 u8 mask;
364 u8 param[0];
365 } __packed;
367 struct element_tclas_type0 {
368 u8 sa[6];
369 u8 da[6];
370 u16 type;
371 } __packed;
373 struct element_tclas_type1 {
374 u8 version;
375 u8 subparam[0];
376 } __packed;
378 struct element_tclas_type1_ip4 {
379 u32 sa;
380 u32 da;
381 u16 sp;
382 u16 dp;
383 u8 dscp;
384 u8 proto;
385 u8 reserved;
386 } __packed;
388 struct element_tclas_type1_ip6 {
389 struct in6_addr sa;
390 struct in6_addr da;
391 u16 sp;
392 u16 dp;
393 union {
394 u8 flow_label[3];
395 struct {
396 #if defined(__LITTLE_ENDIAN_BITFIELD)
397 __extension__ u8 flow_label3:8;
398 __extension__ u8 flow_label2:8;
399 __extension__ u8 flow_label1:8;
400 #elif defined(__BIG_ENDIAN_BITFIELD)
401 __extension__ u8 flow_label1:8;
402 __extension__ u8 flow_label2:8;
403 __extension__ u8 flow_label3:8;
405 # error "Adjust your <asm/byteorder.h> defines"
406 #endif
409 } __packed;
411 struct element_tclas_type2 {
412 u16 vlan_tci;
413 } __packed;
415 struct element_tclas_type3 {
416 u16 offs;
417 u8 value[0];
418 u8 mask[0];
419 } __packed;
421 struct element_tclas_type4 {
422 u8 version;
423 u8 subparam[0];
424 } __packed;
426 struct element_tclas_type4_ip4 {
427 u32 sa;
428 u32 da;
429 u16 sp;
430 u16 dp;
431 u8 dscp;
432 u8 proto;
433 u8 reserved;
434 } __packed;
436 struct element_tclas_type4_ip6 {
437 struct in6_addr sa;
438 struct in6_addr da;
439 u16 sp;
440 u16 dp;
441 u8 dscp;
442 u8 nxt_hdr;
443 union {
444 u8 flow_label[3];
445 struct {
446 #if defined(__LITTLE_ENDIAN_BITFIELD)
447 __extension__ u8 flow_label3:8;
448 __extension__ u8 flow_label2:8;
449 __extension__ u8 flow_label1:8;
450 #elif defined(__BIG_ENDIAN_BITFIELD)
451 __extension__ u8 flow_label1:8;
452 __extension__ u8 flow_label2:8;
453 __extension__ u8 flow_label3:8;
455 # error "Adjust your <asm/byteorder.h> defines"
456 #endif
459 } __packed;
461 struct element_tclas_type5 {
462 u8 pcp;
463 u8 cfi;
464 u8 vid;
465 } __packed;
467 struct element_schedule {
468 u8 len;
469 u16 inf;
470 u32 start;
471 u32 serv_intv;
472 u16 spec_intv;
473 } __packed;
475 struct element_chall_txt {
476 u8 len;
477 u8 chall_txt[0];
478 } __packed;
480 struct element_pwr_constr {
481 u8 len;
482 u8 local_pwr_constr;
483 } __packed;
485 struct element_pwr_cap {
486 u8 len;
487 u8 min_pwr_cap;
488 u8 max_pwr_cap;
489 } __packed;
491 struct element_tpc_req {
492 u8 len;
493 } __packed;
495 struct element_tpc_rep {
496 u8 len;
497 u8 trans_pwr;
498 u8 link_marg;
499 } __packed;
501 struct element_supp_ch {
502 u8 len;
503 u8 first_ch_nr[0];
504 u8 nr_ch[0];
505 } __packed;
507 struct element_supp_ch_tuple {
508 u8 first_ch_nr;
509 u8 nr_ch;
510 } __packed;
512 struct element_ch_sw_ann {
513 u8 len;
514 u8 switch_mode;
515 u8 new_nr;
516 u8 switch_cnt;
517 } __packed;
519 struct element_meas_basic {
520 u8 ch_nr;
521 u64 start;
522 u16 dur;
523 } __packed;
525 struct element_meas_cca {
526 u8 ch_nr;
527 u64 start;
528 u16 dur;
529 } __packed;
531 struct element_meas_rpi {
532 u8 ch_nr;
533 u64 start;
534 u16 dur;
535 } __packed;
537 struct element_meas_ch_load {
538 u8 op_class;
539 u8 ch_nr;
540 u16 rand_intv;
541 u16 dur;
542 u8 sub[0];
543 } __packed;
545 struct element_meas_noise {
546 u8 op_class;
547 u8 ch_nr;
548 u16 rand_intv;
549 u16 dur;
550 u8 sub[0];
551 } __packed;
553 struct element_meas_beacon {
554 u8 op_class;
555 u8 ch_nr;
556 u16 rand_intv;
557 u16 dur;
558 u8 mode;
559 u8 bssid[6];
560 u8 sub[0];
561 } __packed;
563 struct element_meas_frame {
564 u8 op_class;
565 u8 ch_nr;
566 u16 rand_intv;
567 u16 dur;
568 u8 frame;
569 u8 mac[6];
570 u8 sub[0];
571 } __packed;
573 struct element_meas_sta {
574 u8 peer_mac[6];
575 u16 rand_intv;
576 u16 dur;
577 u8 group_id;
578 u8 sub[0];
579 } __packed;
581 struct element_meas_lci {
582 u8 loc_subj;
583 u8 latitude_req_res;
584 u8 longitude_req_res;
585 u8 altitude_req_res;
586 u8 sub[0];
587 } __packed;
589 struct element_meas_trans_str_cat {
590 u16 rand_intv;
591 u16 dur;
592 u8 peer_sta_addr[6];
593 u8 traffic_id;
594 u8 bin_0_range;
595 u8 sub[0];
596 } __packed;
598 struct element_meas_mcast_diag {
599 u16 rand_intv;
600 u16 dur;
601 u8 group_mac[6];
602 u8 mcast_triggered[0];
603 u8 sub[0];
604 } __packed;
606 struct element_meas_loc_civic {
607 u8 loc_subj;
608 u8 civic_loc;
609 u8 loc_srv_intv_unit;
610 u16 loc_srv_intv;
611 u8 sub[0];
612 } __packed;
614 struct element_meas_loc_id {
615 u8 loc_subj;
616 u8 loc_srv_intv_unit;
617 u16 loc_srv_intv;
618 u8 sub[0];
619 } __packed;
621 struct element_meas_pause {
622 u8 time;
623 u8 sub[0];
624 } __packed;
626 struct element_meas_req {
627 u8 len;
628 u8 token;
629 u8 req_mode;
630 u8 type;
631 u8 req[0];
632 } __packed;
634 struct element_meas_rep {
635 u8 len;
636 u8 token;
637 u8 rep_mode;
638 u8 type;
639 u8 rep[0];
640 } __packed;
642 struct element_quiet {
643 u8 len;
644 u8 cnt;
645 u8 period;
646 u16 dur;
647 u16 offs;
648 } __packed;
650 struct element_ibss_dfs {
651 u8 len;
652 u8 owner[6];
653 u8 rec_intv;
654 u8 ch_map[0];
655 } __packed;
657 struct element_ibss_dfs_tuple {
658 u8 ch_nr;
659 u8 map;
660 } __packed;
662 struct element_erp {
663 u8 len;
664 u8 param;
665 } __packed;
667 struct element_ext_supp_rates {
668 u8 len;
669 u8 rates[0];
670 } __packed;
672 struct element_vend_spec {
673 u8 len;
674 u8 oui[0];
675 u8 specific[0];
676 } __packed;
678 static int8_t len_neq_error(u8 len, u8 intended)
680 if(intended != len) {
681 tprintf("Length should be %u Bytes", intended);
682 return 1;
685 return 0;
688 static int8_t len_lt_error(u8 len, u8 intended)
690 if(len < intended) {
691 tprintf("Length should be greater %u Bytes", intended);
692 return 1;
695 return 0;
698 static float data_rates(u8 id)
700 /* XXX Why not (id / 2.f)? */
701 switch (id) {
702 case 2: return 1.0f;
703 case 3: return 1.5f;
704 case 4: return 2.0f;
705 case 5: return 2.5f;
706 case 6: return 3.0f;
707 case 9: return 4.5f;
708 case 11: return 5.5f;
709 case 12: return 6.0f;
710 case 18: return 9.0f;
711 case 22: return 11.0f;
712 case 24: return 12.0f;
713 case 27: return 13.5f;
714 case 36: return 18.0f;
715 case 44: return 22.0f;
716 case 48: return 24.0f;
717 case 54: return 27.0f;
718 case 66: return 33.0f;
719 case 72: return 36.0f;
720 case 96: return 48.0f;
721 case 108: return 54.0f;
724 return 0.f;
727 struct subelement {
728 u8 id;
729 u8 len;
730 u8 data[0];
731 } __packed;
734 static int8_t subelements(struct pkt_buff *pkt, u8 len)
736 u8 i, j;
737 u8 *data;
739 for (i=0; i<len;) {
740 struct subelement *sub;
742 sub = (struct subelement *) pkt_pull(pkt, sizeof(*sub));
743 if (sub == NULL)
744 return 0;
746 tprintf(", Subelement ID %u, ", sub->id);
747 tprintf("Length %u, ", sub->len);
749 data = pkt_pull(pkt, sub->len);
750 if (data == NULL)
751 return 0;
753 tprintf("Data: 0x");
754 for(j=0; j < sub->len; j++)
755 tprintf("%.2x ", data[j]);
757 i += sub->len + 1;
760 if (i != len) {
761 tprintf("Length error");
762 return 0;
765 return 1;
768 static int8_t inf_reserved(struct pkt_buff *pkt, u8 *id)
770 u8 i;
771 u8 *data;
772 struct element_reserved *reserved;
774 reserved = (struct element_reserved *) pkt_pull(pkt, sizeof(*reserved));
775 if (reserved == NULL)
776 return 0;
778 tprintf("Reserved (%u, Len (%u)): ", *id, reserved->len);
780 data = pkt_pull(pkt, reserved->len);
781 if (data == NULL)
782 return 0;
784 tprintf("Data 0x");
785 for (i = 0; i < reserved->len; i++)
786 tprintf("%.2x", data[i]);
788 return 1;
791 static int8_t inf_ssid(struct pkt_buff *pkt, u8 *id)
793 u8 i;
794 struct element_ssid *ssid;
795 char *ssid_name;
797 ssid = (struct element_ssid *) pkt_pull(pkt, sizeof(*ssid));
798 if (ssid == NULL)
799 return 0;
801 tprintf(" SSID (%u, Len (%u)): ", *id, ssid->len);
803 if ((ssid->len - sizeof(*ssid) + 1) > 0) {
804 ssid_name = (char *) pkt_pull(pkt, ssid->len);
805 if (ssid_name == NULL)
806 return 0;
808 for (i = 0; i < ssid->len; i++)
809 tprintf("%c",ssid_name[i]);
810 } else {
811 tprintf("Wildcard SSID");
814 return 1;
817 static int8_t inf_supp_rates(struct pkt_buff *pkt, u8 *id)
819 u8 i;
820 u8 *rates;
821 struct element_supp_rates *supp_rates;
823 supp_rates = (struct element_supp_rates *)
824 pkt_pull(pkt, sizeof(*supp_rates));
825 if (supp_rates == NULL)
826 return 0;
828 tprintf("Rates (%u, Len (%u)): ", *id, supp_rates->len);
829 if (len_lt_error(supp_rates->len, 1))
830 return 0;
832 if ((supp_rates->len - sizeof(*supp_rates) + 1) > 0) {
833 rates = pkt_pull(pkt, supp_rates->len);
834 if (rates == NULL)
835 return 0;
837 for (i = 0; i < supp_rates->len; i++)
838 tprintf("%g ", (rates[i] & 0x80) ?
839 ((rates[i] & 0x3f) * 0.5) :
840 data_rates(rates[i]));
841 return 1;
844 return 0;
847 static int8_t inf_fh_ps(struct pkt_buff *pkt, u8 *id)
849 struct element_fh_ps *fh_ps;
851 fh_ps = (struct element_fh_ps *) pkt_pull(pkt, sizeof(*fh_ps));
852 if (fh_ps == NULL)
853 return 0;
855 tprintf("FH Param Set (%u, Len(%u)): ", *id, fh_ps->len);
856 if (len_neq_error(fh_ps->len, 5))
857 return 0;
858 tprintf("Dwell Time: %fs, ", le16_to_cpu(fh_ps->dwell_time) * TU);
859 tprintf("HopSet: %u, ", fh_ps->hop_set);
860 tprintf("HopPattern: %u, ", fh_ps->hop_pattern);
861 tprintf("HopIndex: %u", fh_ps->hop_index);
863 return 1;
866 static int8_t inf_dsss_ps(struct pkt_buff *pkt, u8 *id)
868 struct element_dsss_ps *dsss_ps;
870 dsss_ps = (struct element_dsss_ps *) pkt_pull(pkt, sizeof(*dsss_ps));
871 if (dsss_ps == NULL)
872 return 0;
874 tprintf("DSSS Param Set (%u, Len(%u)): ", *id, dsss_ps->len);
875 if (len_neq_error(dsss_ps->len, 1))
876 return 0;
877 tprintf("Current Channel: %u", dsss_ps->curr_ch);
879 return 1;
882 static int8_t inf_cf_ps(struct pkt_buff *pkt, u8 *id)
884 struct element_cf_ps *cf_ps;
886 cf_ps = (struct element_cf_ps *) pkt_pull(pkt, sizeof(*cf_ps));
887 if (cf_ps == NULL)
888 return 0;
890 tprintf("CF Param Set (%u, Len(%u)): ", *id, cf_ps->len);
891 if (len_neq_error(cf_ps->len, 6))
892 return 0;
893 tprintf("CFP Count: %u, ", cf_ps->cfp_cnt);
894 tprintf("CFP Period: %u, ", cf_ps->cfp_period);
895 tprintf("CFP MaxDur: %fs, ", le16_to_cpu(cf_ps->cfp_max_dur) * TU);
896 tprintf("CFP DurRem: %fs", le16_to_cpu(cf_ps->cfp_dur_rem) * TU);
898 return 1;
901 static int8_t inf_tim(struct pkt_buff *pkt, u8 *id)
903 struct element_tim *tim;
905 tim = (struct element_tim *) pkt_pull(pkt, sizeof(*tim));
906 if (tim == NULL)
907 return 0;
909 tprintf("TIM (%u, Len(%u)): ", *id, tim->len);
910 if (len_lt_error(tim->len, 3))
911 return 0;
912 tprintf("DTIM Count: %u, ", tim->dtim_cnt);
913 tprintf("DTIM Period: %u, ", tim->dtim_period);
914 tprintf("Bitmap Control: %u, ", tim->bmp_cntrl);
915 if ((tim->len - sizeof(*tim) + 1) > 0) {
916 u8 *bmp = pkt_pull(pkt, (tim->len - sizeof(*tim) + 1));
917 if (bmp == NULL)
918 return 0;
920 tprintf("Partial Virtual Bitmap: 0x");
921 for(u8 i=0; i < (tim->len - sizeof(*tim) + 1); i++)
922 tprintf("%.2x ", bmp[i]);
925 return 1;
928 static int8_t inf_ibss_ps(struct pkt_buff *pkt, u8 *id)
930 struct element_ibss_ps *ibss_ps;
932 ibss_ps = (struct element_ibss_ps *) pkt_pull(pkt, sizeof(*ibss_ps));
933 if (ibss_ps == NULL)
934 return 0;
936 tprintf("IBSS Param Set (%u, Len(%u)): ", *id, ibss_ps->len);
937 if (len_neq_error(ibss_ps->len, 2))
938 return 0;
939 tprintf("ATIM Window: %fs", le16_to_cpu(ibss_ps->atim_win) * TU);
941 return 1;
944 static int8_t inf_country(struct pkt_buff *pkt, u8 *id)
946 u8 i;
947 u8 *pad;
948 struct element_country *country;
950 country = (struct element_country *) pkt_pull(pkt, sizeof(*country));
951 if (country == NULL)
952 return 0;
954 tprintf("Country (%u, Len(%u)): ", *id, country->len);
955 if (len_lt_error(country->len, 6))
956 return 0;
957 tprintf("Country String: %c%c%c", country->country_first,
958 country->country_sec, country->country_third);
960 for (i = 0; i < (country->len - 3); i += 3) {
961 struct element_country_tripled *country_tripled;
963 country_tripled = (struct element_country_tripled *)
964 pkt_pull(pkt, sizeof(*country_tripled));
965 if (country_tripled == NULL)
966 return 0;
968 if(country_tripled->frst_ch >= 201) {
969 tprintf("Oper Ext ID: %u, ", country_tripled->frst_ch);
970 tprintf("Operating Class: %u, ", country_tripled->nr_ch);
971 tprintf("Coverage Class: %u", country_tripled->max_trans);
972 } else {
973 tprintf("First Ch Nr: %u, ", country_tripled->frst_ch);
974 tprintf("Nr of Ch: %u, ", country_tripled->nr_ch);
975 tprintf("Max Transmit Pwr Lvl: %u", country_tripled->max_trans);
979 if(country->len % 2) {
980 pad = pkt_pull(pkt, 1);
981 if (pad == NULL)
982 return 0;
984 tprintf(", Pad: 0x%x", *pad);
987 return 1;
990 static int8_t inf_hop_pp(struct pkt_buff *pkt, u8 *id)
992 struct element_hop_pp *hop_pp;
994 hop_pp = (struct element_hop_pp *) pkt_pull(pkt, sizeof(*hop_pp));
995 if (hop_pp == NULL)
996 return 0;
998 tprintf("Hopping Pattern Param (%u, Len(%u)): ", *id, hop_pp->len);
999 if (len_neq_error(hop_pp->len, 2))
1000 return 0;
1001 tprintf("Nr of Ch: %u", hop_pp->nr_ch);
1003 return 1;
1006 static int8_t inf_hop_pt(struct pkt_buff *pkt, u8 *id)
1008 int i;
1009 u8 *rand_tabl;
1010 struct element_hop_pt *hop_pt;
1012 hop_pt = (struct element_hop_pt *) pkt_pull(pkt, sizeof(*hop_pt));
1013 if (hop_pt == NULL)
1014 return 0;
1016 tprintf("Hopping Pattern Table (%u, Len(%u)): ", *id, hop_pt->len);
1017 if (len_lt_error(hop_pt->len, 4))
1018 return 0;
1019 tprintf("Flag: %u, ", hop_pt->flag);
1020 tprintf("Nr of Sets: %u, ", hop_pt->nr_sets);
1021 tprintf("Modules: %u, ", hop_pt->modules);
1022 tprintf("Offs: %u", hop_pt->offs);
1024 if ((hop_pt->len - sizeof(*hop_pt) + 1) > 0) {
1025 rand_tabl = pkt_pull(pkt, (hop_pt->len - sizeof(*hop_pt) + 1));
1026 if (rand_tabl == NULL)
1027 return 0;
1029 tprintf(", Rand table: 0x");
1030 for (i = 0; i < (hop_pt->len - sizeof(*hop_pt) + 1); i++)
1031 tprintf("%.2x ", rand_tabl[i]);
1034 return 1;
1037 static int8_t inf_req(struct pkt_buff *pkt, u8 *id)
1039 int i;
1040 struct element_req *req;
1041 u8 *req_ids;
1043 req = (struct element_req *) pkt_pull(pkt, sizeof(*req));
1044 if (req == NULL)
1045 return 0;
1047 tprintf("Request Element (%u, Len(%u)): ", *id, req->len);
1048 if ((req->len - sizeof(*req) + 1) > 0) {
1049 req_ids = pkt_pull(pkt, (req->len - sizeof(*req) + 1));
1050 if (req_ids == NULL)
1051 return 0;
1053 tprintf(", Requested Element IDs: ");
1054 for (i = 0; i < (req->len - sizeof(*req) + 1); i++)
1055 tprintf("%u ", req_ids[i]);
1058 return 1;
1061 static int8_t inf_bss_load(struct pkt_buff *pkt, u8 *id)
1063 struct element_bss_load *bss_load;
1065 bss_load = (struct element_bss_load *) pkt_pull(pkt, sizeof(*bss_load));
1066 if (bss_load == NULL)
1067 return 0;
1069 tprintf("BSS Load element (%u, Len(%u)): ", *id, bss_load->len);
1070 if (len_neq_error(bss_load->len, 5))
1071 return 0;
1072 tprintf("Station Count: %u, ", le16_to_cpu(bss_load->station_cnt));
1073 tprintf("Channel Utilization: %u, ", bss_load->ch_util);
1074 tprintf("Available Admission Capacity: %uus",
1075 bss_load->avlb_adm_cap * 32);
1077 return 1;
1080 static int8_t inf_edca_ps(struct pkt_buff *pkt, u8 *id)
1082 u32 ac_be, ac_bk, ac_vi, ac_vo;
1083 struct element_edca_ps *edca_ps;
1085 edca_ps = (struct element_edca_ps *) pkt_pull(pkt, sizeof(*edca_ps));
1086 if (edca_ps == NULL)
1087 return 0;
1089 ac_be = le32_to_cpu(edca_ps->ac_be);
1090 ac_bk = le32_to_cpu(edca_ps->ac_bk);
1091 ac_vi = le32_to_cpu(edca_ps->ac_vi);
1092 ac_vo = le32_to_cpu(edca_ps->ac_vo);
1094 tprintf("EDCA Param Set (%u, Len(%u)): ", *id, edca_ps->len);
1095 if (len_neq_error(edca_ps->len, 18))
1096 return 0;
1097 tprintf("QoS Info: 0x%x (-> EDCA Param Set Update Count (%u),"
1098 "Q-Ack (%u), Queue Re (%u), TXOP Req(%u), Res(%u)), ",
1099 edca_ps->qos_inf, edca_ps->qos_inf >> 4,
1100 (edca_ps->qos_inf >> 3) & 1, (edca_ps->qos_inf >> 2) & 1,
1101 (edca_ps->qos_inf >> 1) & 1, edca_ps->qos_inf & 1);
1102 tprintf("Reserved: 0x%x, ", edca_ps->res);
1103 tprintf("AC_BE Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1104 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)), ", ac_be,
1105 ac_be >> 28, (ac_be >> 27) & 1, (ac_be >> 25) & 3,
1106 (ac_be >> 24) & 1, (ac_be >> 20) & 15, (ac_be >> 16) & 15,
1107 bswap_16(ac_be & 0xFFFF) * 32);
1108 tprintf("AC_BK Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1109 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)), ", ac_bk,
1110 ac_bk >> 28, (ac_bk >> 27) & 1, (ac_bk >> 25) & 3,
1111 (ac_bk >> 24) & 1, (ac_bk >> 20) & 15, (ac_bk >> 16) & 15,
1112 bswap_16(ac_bk & 0xFFFF) * 32);
1113 tprintf("AC_VI Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1114 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)), ", ac_vi,
1115 ac_vi >> 28, (ac_vi >> 27) & 1, (ac_vi >> 25) & 3,
1116 (ac_vi >> 24) & 1, (ac_vi >> 20) & 15, (ac_vi >> 16) & 15,
1117 bswap_16(ac_vi & 0xFFFF) * 32);
1118 tprintf("AC_VO Param Rec: 0x%x (-> AIFSN (%u), ACM (%u), ACI (%u),"
1119 "Res (%u), ECWmin (%u), ECWmax(%u)), TXOP Limit (%uus)", ac_vo,
1120 ac_vo >> 28, (ac_vo >> 27) & 1, (ac_vo >> 25) & 3,
1121 (ac_vo >> 24) & 1, (ac_vo >> 20) & 15, (ac_vo >> 16) & 15,
1122 bswap_16(ac_vo & 0xFFFF) * 32);
1124 return 1;
1127 static int8_t inf_tspec(struct pkt_buff *pkt, u8 *id)
1129 u16 nom_msdu_size, surplus_bandw_allow;
1130 struct element_tspec *tspec;
1132 tspec = (struct element_tspec *) pkt_pull(pkt, sizeof(*tspec));
1133 if (tspec == NULL)
1134 return 0;
1136 nom_msdu_size = le16_to_cpu(tspec->nom_msdu_size);
1137 surplus_bandw_allow = le16_to_cpu(tspec->surplus_bandw_allow);
1139 tprintf("TSPEC (%u, Len(%u)): ", *id, tspec->len);
1140 if (len_neq_error(tspec->len, 55))
1141 return 0;
1142 tprintf("Traffic Type: %u, ", tspec->traffic_type);
1143 tprintf("TSID: %u, ", tspec->tsid);
1144 tprintf("Direction: %u, ", tspec->direction);
1145 tprintf("Access Policy: %u, ", tspec->access_policy);
1146 tprintf("Aggregation: %u, ", tspec->aggr);
1147 tprintf("User Priority: %u, ", tspec->user_prior);
1148 tprintf("TSinfo Ack Policy: %u, ", tspec->tsinfo_ack_pol);
1149 tprintf("Schedule: %u, ", tspec->schedule);
1150 tprintf("Reserved: 0x%x, ", tspec->res);
1151 tprintf("Nominal MSDU Size: %uB (Fixed (%u)), ",
1152 nom_msdu_size >> 1, nom_msdu_size & 1);
1153 tprintf("Maximum MSDU Size: %uB, ", le16_to_cpu(tspec->max_msdu_size));
1154 tprintf("Minimum Service Interval: %uus, ",
1155 le32_to_cpu(tspec->min_srv_intv));
1156 tprintf("Maximum Service Interval: %uus, ",
1157 le32_to_cpu(tspec->max_srv_intv));
1158 tprintf("Inactivity Interval: %uus, ",
1159 le32_to_cpu(tspec->inactive_intv));
1160 tprintf("Suspension Interval: %uus, ", le32_to_cpu(tspec->susp_intv));
1161 tprintf("Service Start Time: %uus, ",
1162 le32_to_cpu(tspec->srv_start_time));
1163 tprintf("Minimum Data Rate: %ub/s, ",le32_to_cpu(tspec->min_data_rate));
1164 tprintf("Mean Data Rate: %ub/s, ", le32_to_cpu(tspec->mean_data_rate));
1165 tprintf("Peak Data Rate: %ub/s, ",le32_to_cpu(tspec->peak_data_rate));
1166 tprintf("Burst Size: %uB, ", le32_to_cpu(tspec->burst_size));
1167 tprintf("Delay Bound: %uus, ", le32_to_cpu(tspec->delay_bound));
1168 tprintf("Minimum PHY Rate: %ub/s, ", le32_to_cpu(tspec->min_phy_rate));
1169 tprintf("Surplus Bandwidth: %u.%u, ", surplus_bandw_allow >> 13,
1170 surplus_bandw_allow & 0x1FFF);
1171 tprintf("Medium Time: %uus", le16_to_cpu(tspec->med_time) * 32);
1173 return 1;
1176 static const char *class_type(u8 type)
1178 switch (type) {
1179 case 0: return "Ethernet parameters";
1180 case 1: return "TCP/UDP IP parameters";
1181 case 2: return "IEEE 802.1Q parameters";
1182 case 3: return "Filter Offset parameters";
1183 case 4: return "IP and higher layer parameters";
1184 case 5: return "IEEE 802.1D/Q parameters";
1185 default: return "Reserved";
1189 static int8_t inf_tclas(struct pkt_buff *pkt, u8 *id)
1191 struct element_tclas *tclas;
1192 struct element_tclas_frm_class *frm_class;
1194 tclas = (struct element_tclas *) pkt_pull(pkt, sizeof(*tclas));
1195 if (tclas == NULL)
1196 return 0;
1198 frm_class = (struct element_tclas_frm_class *)
1199 pkt_pull(pkt, sizeof(*frm_class));
1200 if (frm_class == NULL)
1201 return 0;
1203 tprintf("TCLAS (%u, Len(%u)): ", *id, tclas->len);
1204 if (len_lt_error(tclas->len, 3))
1205 return 0;
1206 tprintf("User Priority: %u, ", tclas->user_priority);
1207 tprintf("Classifier Type: %s (%u), ", class_type(frm_class->type),
1208 frm_class->type);
1209 tprintf("Classifier Mask: 0x%x, ", frm_class->mask);
1211 if(frm_class->type == 0) {
1212 struct element_tclas_type0 *type0;
1214 type0 = (struct element_tclas_type0 *)
1215 pkt_pull(pkt, sizeof(*type0));
1216 if (type0 == NULL)
1217 return 0;
1219 /* I think little endian, like the rest */
1220 tprintf("Src Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
1221 type0->sa[5], type0->sa[4], type0->sa[3],
1222 type0->sa[2], type0->sa[1], type0->sa[0]);
1223 tprintf("Dst Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
1224 type0->da[5], type0->da[4], type0->da[3],
1225 type0->da[2], type0->da[1], type0->da[0]);
1226 tprintf("Type: 0x%x", le16_to_cpu(type0->type));
1228 else if(frm_class->type == 1) {
1229 struct element_tclas_type1 *type1;
1231 type1 = (struct element_tclas_type1 *)
1232 pkt_pull(pkt, sizeof(*type1));
1233 if (type1 == NULL)
1234 return 0;
1236 tprintf("Version: %u, ", type1->version);
1237 /* big endian format follows */
1238 if(type1->version == 4) {
1239 struct element_tclas_type1_ip4 *type1_ip4;
1240 char src_ip[INET_ADDRSTRLEN];
1241 char dst_ip[INET_ADDRSTRLEN];
1243 type1_ip4 = (struct element_tclas_type1_ip4 *)
1244 pkt_pull(pkt, sizeof(*type1_ip4));
1245 if (type1_ip4 == NULL)
1246 return 0;
1248 inet_ntop(AF_INET, &type1_ip4->sa, src_ip, sizeof(src_ip));
1249 inet_ntop(AF_INET, &type1_ip4->da, dst_ip, sizeof(dst_ip));
1251 tprintf("Src IP: %s, ", src_ip);
1252 tprintf("Dst IP: %s, ", dst_ip);
1253 tprintf("Src Port: %u, ", ntohs(type1_ip4->sp));
1254 tprintf("Dst Port: %u, ", ntohs(type1_ip4->dp));
1255 tprintf("DSCP: 0x%x, ", type1_ip4->dscp);
1256 tprintf("Proto: %u, ", type1_ip4->proto);
1257 tprintf("Res: 0x%x", type1_ip4->reserved);
1259 else if(type1->version == 6) {
1260 struct element_tclas_type1_ip6 *type1_ip6;
1261 char src_ip[INET6_ADDRSTRLEN];
1262 char dst_ip[INET6_ADDRSTRLEN];
1264 type1_ip6 = (struct element_tclas_type1_ip6 *)
1265 pkt_pull(pkt, sizeof(*type1_ip6));
1266 if (type1_ip6 == NULL)
1267 return 0;
1269 inet_ntop(AF_INET6, &type1_ip6->sa,
1270 src_ip, sizeof(src_ip));
1271 inet_ntop(AF_INET6, &type1_ip6->da,
1272 dst_ip, sizeof(dst_ip));
1274 tprintf("Src IP: %s, ", src_ip);
1275 tprintf("Dst IP: %s, ", dst_ip);
1276 tprintf("Src Port: %u, ", ntohs(type1_ip6->sp));
1277 tprintf("Dst Port: %u, ", ntohs(type1_ip6->dp));
1278 tprintf("Flow Label: 0x%x%x%x", type1_ip6->flow_label1,
1279 type1_ip6->flow_label2, type1_ip6->flow_label3);
1281 else {
1282 tprintf("Version (%u) not supported", type1->version);
1283 return 0;
1287 else if(frm_class->type == 2) {
1288 struct element_tclas_type2 *type2;
1290 type2 = (struct element_tclas_type2 *)
1291 pkt_pull(pkt, sizeof(*type2));
1292 if (type2 == NULL)
1293 return 0;
1295 tprintf("802.1Q VLAN TCI: 0x%x", ntohs(type2->vlan_tci));
1297 else if(frm_class->type == 3) {
1298 struct element_tclas_type3 *type3;
1299 u8 len, i;
1300 u8 *val;
1302 type3 = (struct element_tclas_type3 *)
1303 pkt_pull(pkt, sizeof(*type3));
1304 if (type3 == NULL)
1305 return 0;
1307 len = (tclas->len - 5) / 2;
1309 tprintf("Filter Offset: %u, ", type3->offs);
1311 if((len & 1) || (len_lt_error(tclas->len, 5))) {
1312 tprintf("Length of TCLAS (%u) not correct", tclas->len);
1313 return 0;
1315 else {
1316 val = pkt_pull(pkt, len);
1317 if (val == NULL)
1318 return 0;
1320 tprintf("Filter Value: 0x");
1321 for (i = 0; i < len / 2; i++)
1322 tprintf("%x ", val[i]);
1323 tprintf(", ");
1324 tprintf("Filter Mask: 0x");
1325 for (i = len / 2; i < len; i++)
1326 tprintf("%x ", val[i]);
1330 else if(frm_class->type == 4) {
1331 struct element_tclas_type4 *type4;
1333 type4 = (struct element_tclas_type4 *)
1334 pkt_pull(pkt, sizeof(*type4));
1335 if (type4 == NULL)
1336 return 0;
1338 tprintf("Version: %u, ", type4->version);
1339 /* big endian format follows */
1340 if(type4->version == 4) {
1341 struct element_tclas_type4_ip4 *type4_ip4;
1342 char src_ip[INET_ADDRSTRLEN];
1343 char dst_ip[INET_ADDRSTRLEN];
1345 type4_ip4 = (struct element_tclas_type4_ip4 *)
1346 pkt_pull(pkt, sizeof(*type4_ip4));
1347 if (type4_ip4 == NULL)
1348 return 0;
1350 inet_ntop(AF_INET, &type4_ip4->sa, src_ip, sizeof(src_ip));
1351 inet_ntop(AF_INET, &type4_ip4->da, dst_ip, sizeof(dst_ip));
1353 tprintf("Src IP: %s, ", src_ip);
1354 tprintf("Dst IP: %s, ", dst_ip);
1355 tprintf("Src Port: %u, ", ntohs(type4_ip4->sp));
1356 tprintf("Dst Port: %u, ", ntohs(type4_ip4->dp));
1357 tprintf("DSCP: 0x%x, ", type4_ip4->dscp);
1358 tprintf("Proto: %u, ", type4_ip4->proto);
1359 tprintf("Res: 0x%x", type4_ip4->reserved);
1361 else if(type4->version == 6) {
1362 struct element_tclas_type4_ip6 *type4_ip6;
1363 char src_ip[INET6_ADDRSTRLEN];
1364 char dst_ip[INET6_ADDRSTRLEN];
1366 type4_ip6 = (struct element_tclas_type4_ip6 *)
1367 pkt_pull(pkt, sizeof(*type4_ip6));
1368 if (type4_ip6 == NULL)
1369 return 0;
1371 inet_ntop(AF_INET6, &type4_ip6->sa,
1372 src_ip, sizeof(src_ip));
1373 inet_ntop(AF_INET6, &type4_ip6->da,
1374 dst_ip, sizeof(dst_ip));
1376 tprintf("Src IP: %s, ", src_ip);
1377 tprintf("Dst IP: %s, ", dst_ip);
1378 tprintf("Src Port: %u, ", ntohs(type4_ip6->sp));
1379 tprintf("Dst Port: %u, ", ntohs(type4_ip6->dp));
1380 tprintf("DSCP: 0x%x, ", type4_ip6->dscp);
1381 tprintf("Nxt Hdr: %u, ", type4_ip6->nxt_hdr);
1382 tprintf("Flow Label: 0x%x%x%x", type4_ip6->flow_label1,
1383 type4_ip6->flow_label2, type4_ip6->flow_label3);
1385 else {
1386 tprintf("Version (%u) not supported", type4->version);
1387 return 0;
1390 else if(frm_class->type == 5) {
1391 struct element_tclas_type5 *type5;
1393 type5 = (struct element_tclas_type5 *)
1394 pkt_pull(pkt, sizeof(*type5));
1395 if (type5 == NULL)
1396 return 0;
1398 tprintf("802.1Q PCP: 0x%x, ", type5->pcp);
1399 tprintf("802.1Q CFI: 0x%x, ", type5->cfi);
1400 tprintf("802.1Q VID: 0x%x", type5->vid);
1402 else {
1403 tprintf("Classifier Type (%u) not supported", frm_class->type);
1404 return 0;
1407 return 1;
1410 static int8_t inf_sched(struct pkt_buff *pkt, u8 *id)
1412 struct element_schedule *schedule;
1413 u16 info;
1415 schedule = (struct element_schedule *) pkt_pull(pkt, sizeof(*schedule));
1416 if (schedule == NULL)
1417 return 0;
1419 info = le16_to_cpu(schedule->inf);
1421 tprintf("Schedule (%u, Len(%u)): ", *id, schedule->len);
1422 if (len_neq_error(schedule->len, 12))
1423 return 0;
1425 tprintf("Aggregation: %u, ", info >> 15);
1426 tprintf("TSID: %u, ", (info >> 11) & 0xF);
1427 tprintf("Direction: %u, ", (info >> 9) & 0x3);
1428 tprintf("Res: %u, ", info & 0x1FF);
1429 tprintf("Serv Start Time: %uus, ", le32_to_cpu(schedule->start));
1430 tprintf("Serv Interval: %uus, ", le32_to_cpu(schedule->serv_intv));
1431 tprintf("Spec Interval: %fs", le32_to_cpu(schedule->spec_intv) * TU);
1433 return 1;
1436 static int8_t inf_chall_txt(struct pkt_buff *pkt, u8 *id)
1438 struct element_chall_txt *chall_txt;
1439 u8 i;
1440 u8 *txt;
1442 chall_txt = (struct element_chall_txt *)
1443 pkt_pull(pkt, sizeof(*chall_txt));
1444 if (chall_txt == NULL)
1445 return 0;
1447 tprintf("Challenge Text (%u, Len(%u)): ", *id, chall_txt->len);
1448 if ((chall_txt->len - sizeof(*chall_txt) + 1) > 0) {
1449 txt = pkt_pull(pkt, (chall_txt->len - sizeof(*chall_txt) + 1));
1450 if (txt == NULL)
1451 return 0;
1453 tprintf("0x");
1454 for (i = 0; i < (chall_txt->len - sizeof(*chall_txt) + 1); i++)
1455 tprintf("%x ", txt[i]);
1458 return 1;
1461 static int8_t inf_pwr_constr(struct pkt_buff *pkt, u8 *id)
1463 struct element_pwr_constr *pwr_constr;
1465 pwr_constr = (struct element_pwr_constr *) pkt_pull(pkt, sizeof(*pwr_constr));
1466 if (pwr_constr == NULL)
1467 return 0;
1469 tprintf("Power Constraint (%u, Len(%u)): ", *id, pwr_constr->len);
1470 if (len_neq_error(pwr_constr->len, 1))
1471 return 0;
1473 tprintf("Local Power Constraint: %udB", pwr_constr->local_pwr_constr);
1475 return 1;
1478 static int8_t inf_pwr_cap(struct pkt_buff *pkt, u8 *id)
1480 struct element_pwr_cap *pwr_cap;
1482 pwr_cap = (struct element_pwr_cap *) pkt_pull(pkt, sizeof(*pwr_cap));
1483 if (pwr_cap == NULL)
1484 return 0;
1486 tprintf("Power Capability (%u, Len(%u)): ", *id, pwr_cap->len);
1487 if (len_neq_error(pwr_cap->len, 2))
1488 return 0;
1490 tprintf("Min. Transm. Pwr Cap.: %ddBm, ", (int8_t)pwr_cap->min_pwr_cap);
1491 tprintf("Max. Transm. Pwr Cap.: %ddBm", (int8_t)pwr_cap->max_pwr_cap);
1493 return 1;
1496 static int8_t inf_tpc_req(struct pkt_buff *pkt, u8 *id)
1498 struct element_tpc_req *tpc_req;
1500 tpc_req = (struct element_tpc_req *) pkt_pull(pkt, sizeof(*tpc_req));
1501 if (tpc_req == NULL)
1502 return 0;
1504 tprintf("TPC Request (%u, Len(%u))", *id, tpc_req->len);
1505 if (len_neq_error(tpc_req->len, 0))
1506 return 0;
1508 return 1;
1511 static int8_t inf_tpc_rep(struct pkt_buff *pkt, u8 *id)
1513 struct element_tpc_rep *tpc_rep;
1515 tpc_rep = (struct element_tpc_rep *) pkt_pull(pkt, sizeof(*tpc_rep));
1516 if (tpc_rep == NULL)
1517 return 0;
1519 tprintf("TPC Report (%u, Len(%u)): ", *id, tpc_rep->len);
1520 if (len_neq_error(tpc_rep->len, 2))
1521 return 0;
1523 tprintf("Transmit Power: %udBm, ", (int8_t)tpc_rep->trans_pwr);
1524 tprintf("Link Margin: %udB", (int8_t)tpc_rep->trans_pwr);
1526 return 1;
1529 static int8_t inf_supp_ch(struct pkt_buff *pkt, u8 *id)
1531 struct element_supp_ch *supp_ch;
1532 u8 i;
1534 supp_ch = (struct element_supp_ch *) pkt_pull(pkt, sizeof(*supp_ch));
1535 if (supp_ch == NULL)
1536 return 0;
1538 tprintf("Supp Channels (%u, Len(%u)): ", *id, supp_ch->len);
1539 if (len_lt_error(supp_ch->len, 2))
1540 return 0;
1542 if(supp_ch->len & 1) {
1543 tprintf("Length should be modulo 2");
1544 return 0;
1547 for (i = 0; i < supp_ch->len; i += 2) {
1548 struct element_supp_ch_tuple *supp_ch_tuple;
1550 supp_ch_tuple = (struct element_supp_ch_tuple *)
1551 pkt_pull(pkt, sizeof(*supp_ch_tuple));
1552 if (supp_ch_tuple == NULL)
1553 return 0;
1555 tprintf("First Channel Nr: %u, ", supp_ch_tuple->first_ch_nr);
1556 tprintf("Nr of Channels: %u, ", supp_ch_tuple->nr_ch);
1559 return 1;
1562 static int8_t inf_ch_sw_ann(struct pkt_buff *pkt, u8 *id)
1564 struct element_ch_sw_ann *ch_sw_ann;
1566 ch_sw_ann = (struct element_ch_sw_ann *)
1567 pkt_pull(pkt, sizeof(*ch_sw_ann));
1568 if (ch_sw_ann == NULL)
1569 return 0;
1571 tprintf("Channel Switch Announc (%u, Len(%u)): ", *id, ch_sw_ann->len);
1572 if (len_neq_error(ch_sw_ann->len, 3))
1573 return 0;
1575 tprintf("Switch Mode: %u, ", ch_sw_ann->switch_mode);
1576 tprintf("New Nr: %u, ", ch_sw_ann->new_nr);
1577 tprintf("Switch Count: %u", ch_sw_ann->switch_cnt);
1579 return 1;
1582 static const char *meas_type(u8 type)
1584 switch (type) {
1585 case 0: return "Basic";
1586 case 1: return "Clear Channel assesment (CCA)";
1587 case 2: return "Receive power indication (RPI) histogram";
1588 case 3: return "Channel load";
1589 case 4: return "Noise histogram";
1590 case 5: return "Beacon";
1591 case 6: return "Frame";
1592 case 7: return "STA statistics";
1593 case 8: return "LCI";
1594 case 9: return "Transmit stream/category measurement";
1595 case 10: return "Multicast diagnostics";
1596 case 11: return "Location Civic";
1597 case 12: return "Location Identifier";
1598 case 13 ... 255: return "Reserved";
1602 static int8_t inf_meas_req(struct pkt_buff *pkt, u8 *id)
1604 struct element_meas_req *meas_req;
1606 meas_req = (struct element_meas_req *) pkt_pull(pkt, sizeof(*meas_req));
1607 if (meas_req == NULL)
1608 return 0;
1610 tprintf("Measurement Req (%u, Len(%u)): ", *id, meas_req->len);
1611 if (len_lt_error(meas_req->len, 3))
1612 return 0;
1614 tprintf("Token: %u, ", meas_req->token);
1615 tprintf("Req Mode: 0x%x (Parallel (%u), Enable(%u), Request(%u), "
1616 "Report(%u), Dur Mand(%u)), ", meas_req->req_mode,
1617 meas_req->req_mode >> 7, (meas_req->req_mode >> 6) & 0x1,
1618 (meas_req->req_mode >> 5) & 0x1, (meas_req->req_mode >> 4) & 0x1,
1619 (meas_req->req_mode >> 3) & 0x1);
1620 tprintf("Type: %s (%u), ", meas_type(meas_req->type), meas_req->type);
1622 if(meas_req->len > 3) {
1623 if(meas_req->type == 0) {
1624 struct element_meas_basic *basic;
1626 basic = (struct element_meas_basic *)
1627 pkt_pull(pkt, sizeof(*basic));
1628 if (basic == NULL)
1629 return 0;
1631 if (!(meas_req->len - 3 - sizeof(*basic))) {
1632 tprintf("Length of Req matchs not Type %u",
1633 meas_req->type);
1634 return 0;
1637 tprintf("Ch Nr: %uus, ", basic->ch_nr);
1638 tprintf("Meas Start Time: %lu, ",
1639 le64_to_cpu(basic->start));
1640 tprintf("Meas Duration: %fs",
1641 le16_to_cpu(basic->dur) * TU);
1644 else if(meas_req->type == 1) {
1645 struct element_meas_cca *cca;
1647 cca = (struct element_meas_cca *)
1648 pkt_pull(pkt, sizeof(*cca));
1649 if (cca == NULL)
1650 return 0;
1652 if (!(meas_req->len - 3 - sizeof(*cca))) {
1653 tprintf("Length of Req matchs not Type %u",
1654 meas_req->type);
1655 return 0;
1658 tprintf("Ch Nr: %uus, ", cca->ch_nr);
1659 tprintf("Meas Start Time: %lu, ",
1660 le64_to_cpu(cca->start));
1661 tprintf("Meas Duration: %fs",
1662 le16_to_cpu(cca->dur) * TU);
1664 else if(meas_req->type == 2) {
1665 struct element_meas_rpi *rpi;
1667 rpi = (struct element_meas_rpi *)
1668 pkt_pull(pkt, sizeof(*rpi));
1669 if (rpi == NULL)
1670 return 0;
1672 if (!(meas_req->len - 3 - sizeof(*rpi))) {
1673 tprintf("Length of Req matchs not Type %u",
1674 meas_req->type);
1675 return 0;
1678 tprintf("Ch Nr: %uus, ", rpi->ch_nr);
1679 tprintf("Meas Start Time: %lu, ",
1680 le64_to_cpu(rpi->start));
1681 tprintf("Meas Duration: %fs",
1682 le16_to_cpu(rpi->dur) * TU);
1684 else if(meas_req->type == 3) {
1685 struct element_meas_ch_load *ch_load;
1687 ch_load = (struct element_meas_ch_load *)
1688 pkt_pull(pkt, sizeof(*ch_load));
1689 if (ch_load == NULL)
1690 return 0;
1692 if ((meas_req->len - 3 - sizeof(*ch_load)) >= 0) {
1693 tprintf("Length of Req matchs not Type %u",
1694 meas_req->type);
1695 return 0;
1698 tprintf("OP Class: %u, ", ch_load->op_class);
1699 tprintf("Ch Nr: %u, ", ch_load->ch_nr);
1700 tprintf("Rand Intv: %fs, ",
1701 le16_to_cpu(ch_load->rand_intv) * TU);
1702 tprintf("Meas Duration: %fs",
1703 le16_to_cpu(ch_load->dur) * TU);
1705 if(!subelements(pkt,
1706 meas_req->len - 3 - sizeof(*ch_load)))
1707 return 0;
1709 else if(meas_req->type == 4) {
1710 struct element_meas_noise *noise;
1712 noise = (struct element_meas_noise *)
1713 pkt_pull(pkt, sizeof(*noise));
1714 if (noise == NULL)
1715 return 0;
1717 if ((meas_req->len - 3 - sizeof(*noise)) >= 0) {
1718 tprintf("Length of Req matchs not Type %u",
1719 meas_req->type);
1720 return 0;
1723 tprintf("OP Class: %u, ", noise->op_class);
1724 tprintf("Ch Nr: %u, ", noise->ch_nr);
1725 tprintf("Rand Intv: %fs, ",
1726 le16_to_cpu(noise->rand_intv) * TU);
1727 tprintf("Meas Duration: %fs",
1728 le16_to_cpu(noise->dur) * TU);
1730 if(!subelements(pkt,
1731 meas_req->len - 3 - sizeof(*noise)))
1732 return 0;
1734 else if(meas_req->type == 5) {
1735 struct element_meas_beacon *beacon;
1737 beacon = (struct element_meas_beacon *)
1738 pkt_pull(pkt, sizeof(*beacon));
1739 if (beacon == NULL)
1740 return 0;
1742 if ((meas_req->len - 3 - sizeof(*beacon)) >= 0) {
1743 tprintf("Length of Req matchs not Type %u",
1744 meas_req->type);
1745 return 0;
1748 tprintf("OP Class: %u, ", beacon->op_class);
1749 tprintf("Ch Nr: %u, ", beacon->ch_nr);
1750 tprintf("Rand Intv: %fs, ",
1751 le16_to_cpu(beacon->rand_intv) * TU);
1752 tprintf("Meas Duration: %fs",
1753 le16_to_cpu(beacon->dur) * TU);
1754 tprintf("Mode: %u, ", beacon->mode);
1755 tprintf("BSSID: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1756 beacon->bssid[0], beacon->bssid[1],
1757 beacon->bssid[2], beacon->bssid[3],
1758 beacon->bssid[4], beacon->bssid[5]);
1760 if(!subelements(pkt,
1761 meas_req->len - 3 - sizeof(*beacon)))
1762 return 0;
1764 else if(meas_req->type == 6) {
1765 struct element_meas_frame *frame;
1767 frame = (struct element_meas_frame *)
1768 pkt_pull(pkt, sizeof(*frame));
1769 if (frame == NULL)
1770 return 0;
1772 if ((meas_req->len - 3 - sizeof(*frame)) >= 0) {
1773 tprintf("Length of Req matchs not Type %u",
1774 meas_req->type);
1775 return 0;
1778 tprintf("OP Class: %u, ", frame->op_class);
1779 tprintf("Ch Nr: %u, ", frame->ch_nr);
1780 tprintf("Rand Intv: %fs, ",
1781 le16_to_cpu(frame->rand_intv) * TU);
1782 tprintf("Meas Duration: %fs",
1783 le16_to_cpu(frame->dur) * TU);
1784 tprintf("Request Type: %u, ", frame->frame);
1785 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1786 frame->mac[0], frame->mac[1],
1787 frame->mac[2], frame->mac[3],
1788 frame->mac[4], frame->mac[5]);
1790 if(!subelements(pkt,
1791 meas_req->len - 3 - sizeof(*frame)))
1792 return 0;
1794 else if(meas_req->type == 7) {
1795 struct element_meas_sta *sta;
1797 sta = (struct element_meas_sta *)
1798 pkt_pull(pkt, sizeof(*sta));
1799 if (sta == NULL)
1800 return 0;
1802 if ((meas_req->len - 3 - sizeof(*sta)) >= 0) {
1803 tprintf("Length of Req matchs not Type %u",
1804 meas_req->type);
1805 return 0;
1808 tprintf("Peer MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1809 sta->peer_mac[0], sta->peer_mac[1],
1810 sta->peer_mac[2], sta->peer_mac[3],
1811 sta->peer_mac[4], sta->peer_mac[5]);
1812 tprintf("Rand Intv: %fs, ",
1813 le16_to_cpu(sta->rand_intv) * TU);
1814 tprintf("Meas Duration: %fs",
1815 le16_to_cpu(sta->dur) * TU);
1816 tprintf("Group ID: %u, ", sta->group_id);
1818 if(!subelements(pkt,
1819 meas_req->len - 3 - sizeof(*sta)))
1820 return 0;
1822 else if(meas_req->type == 8) {
1823 struct element_meas_lci *lci;
1825 lci = (struct element_meas_lci *)
1826 pkt_pull(pkt, sizeof(*lci));
1827 if (lci == NULL)
1828 return 0;
1830 if ((meas_req->len - 3 - sizeof(*lci)) >= 0) {
1831 tprintf("Length of Req matchs not Type %u",
1832 meas_req->type);
1833 return 0;
1836 tprintf("Location Subj: %u, ", lci->loc_subj);
1837 tprintf("Latitude Req Res: %udeg",
1838 lci->latitude_req_res);
1839 tprintf("Longitude Req Res: %udeg",
1840 lci->longitude_req_res);
1841 tprintf("Altitude Req Res: %udeg",
1842 lci->altitude_req_res);
1844 if(!subelements(pkt,
1845 meas_req->len - 3 - sizeof(*lci)))
1846 return 0;
1848 else if(meas_req->type == 9) {
1849 struct element_meas_trans_str_cat *trans;
1851 trans = (struct element_meas_trans_str_cat *)
1852 pkt_pull(pkt, sizeof(*trans));
1853 if (trans == NULL)
1854 return 0;
1856 if ((meas_req->len - 3 - sizeof(*trans)) >= 0) {
1857 tprintf("Length of Req matchs not Type %u",
1858 meas_req->type);
1859 return 0;
1862 tprintf("Rand Intv: %fs, ",
1863 le16_to_cpu(trans->rand_intv) * TU);
1864 tprintf("Meas Duration: %fs",
1865 le16_to_cpu(trans->dur) * TU);
1866 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1867 trans->peer_sta_addr[0], trans->peer_sta_addr[1],
1868 trans->peer_sta_addr[2], trans->peer_sta_addr[3],
1869 trans->peer_sta_addr[4], trans->peer_sta_addr[5]);
1870 tprintf("Traffic ID: %u, ", trans->traffic_id);
1871 tprintf("Bin 0 Range: %u, ", trans->bin_0_range);
1873 if(!subelements(pkt,
1874 meas_req->len - 3 - sizeof(*trans)))
1875 return 0;
1877 else if(meas_req->type == 10) {
1878 struct element_meas_mcast_diag *mcast;
1880 mcast = (struct element_meas_mcast_diag *)
1881 pkt_pull(pkt, sizeof(*mcast));
1882 if (mcast == NULL)
1883 return 0;
1885 if ((meas_req->len - 3 - sizeof(*mcast)) >= 0) {
1886 tprintf("Length of Req matchs not Type %u",
1887 meas_req->type);
1888 return 0;
1891 tprintf("Rand Intv: %fs, ",
1892 le16_to_cpu(mcast->rand_intv) * TU);
1893 tprintf("Meas Duration: %fs",
1894 le16_to_cpu(mcast->dur) * TU);
1895 tprintf("Group MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
1896 mcast->group_mac[0], mcast->group_mac[1],
1897 mcast->group_mac[2], mcast->group_mac[3],
1898 mcast->group_mac[4], mcast->group_mac[5]);
1900 if(!subelements(pkt,
1901 meas_req->len - 3 - sizeof(*mcast)))
1902 return 0;
1904 else if(meas_req->type == 11) {
1905 struct element_meas_loc_civic *civic;
1907 civic = (struct element_meas_loc_civic *)
1908 pkt_pull(pkt, sizeof(*civic));
1909 if (civic == NULL)
1910 return 0;
1912 if ((meas_req->len - 3 - sizeof(*civic)) >= 0) {
1913 tprintf("Length of Req matchs not Type %u",
1914 meas_req->type);
1915 return 0;
1918 tprintf("Location Subj: %u, ", civic->loc_subj);
1919 tprintf("Type: %u, ", civic->civic_loc);
1920 tprintf("Srv Intv Units: %u, ",
1921 le16_to_cpu(civic->loc_srv_intv_unit));
1922 tprintf("Srv Intv: %u, ", civic->loc_srv_intv);
1924 if(!subelements(pkt,
1925 meas_req->len - 3 - sizeof(*civic)))
1926 return 0;
1928 else if(meas_req->type == 12) {
1929 struct element_meas_loc_id *id;
1931 id = (struct element_meas_loc_id *)
1932 pkt_pull(pkt, sizeof(*id));
1933 if (id == NULL)
1934 return 0;
1936 if ((meas_req->len - 3 - sizeof(*id)) >= 0) {
1937 tprintf("Length of Req matchs not Type %u",
1938 meas_req->type);
1939 return 0;
1942 tprintf("Location Subj: %u, ", id->loc_subj);
1943 tprintf("Srv Intv Units: %u, ",
1944 le16_to_cpu(id->loc_srv_intv_unit));
1945 tprintf("Srv Intv: %u", id->loc_srv_intv);
1947 if(!subelements(pkt,
1948 meas_req->len - 3 - sizeof(*id)))
1949 return 0;
1951 else if(meas_req->type == 255) {
1952 struct element_meas_pause *pause;
1954 pause = (struct element_meas_pause *)
1955 pkt_pull(pkt, sizeof(*pause));
1956 if (pause == NULL)
1957 return 0;
1959 if ((meas_req->len - 3 - sizeof(*pause)) >= 0) {
1960 tprintf("Length of Req matchs not Type %u",
1961 meas_req->type);
1962 return 0;
1965 tprintf("Pause Time: %fs, ", pause->time * 10 * TU);
1967 if(!subelements(pkt,
1968 meas_req->len - 3 - sizeof(*pause)))
1969 return 0;
1971 else {
1972 tprintf("Length field indicates data,"
1973 " but could not interpreted");
1974 return 0;
1978 return 1;
1981 static int8_t inf_meas_rep(struct pkt_buff *pkt, u8 *id)
1983 struct element_meas_rep *meas_rep;
1985 meas_rep = (struct element_meas_rep *) pkt_pull(pkt, sizeof(*meas_rep));
1986 if (meas_rep == NULL)
1987 return 0;
1989 tprintf("Measurement Rep (%u, Len(%u)): ", *id, meas_rep->len);
1990 if (len_lt_error(meas_rep->len, 3))
1991 return 0;
1993 tprintf("Token: %u, ", meas_rep->token);
1994 tprintf("Rep Mode: 0x%x (Late (%u), Incapable(%u), Refused(%u), ",
1995 meas_rep->rep_mode, meas_rep->rep_mode >> 7,
1996 (meas_rep->rep_mode >> 6) & 0x1,
1997 (meas_rep->rep_mode >> 5) & 0x1);
1998 tprintf("Type: %s (%u), ", meas_type(meas_rep->type), meas_rep->type);
2000 if(meas_rep->len > 3) {
2001 if(meas_rep->type == 0) {
2002 struct element_meas_basic *basic;
2004 basic = (struct element_meas_basic *)
2005 pkt_pull(pkt, sizeof(*basic));
2006 if (basic == NULL)
2007 return 0;
2009 if (!(meas_rep->len - 3 - sizeof(*basic))) {
2010 tprintf("Length of Req matchs not Type %u",
2011 meas_rep->type);
2012 return 0;
2015 tprintf("Ch Nr: %uus, ", basic->ch_nr);
2016 tprintf("Meas Start Time: %lu, ",
2017 le64_to_cpu(basic->start));
2018 tprintf("Meas Duration: %fs",
2019 le16_to_cpu(basic->dur) * TU);
2022 else if(meas_rep->type == 1) {
2023 struct element_meas_cca *cca;
2025 cca = (struct element_meas_cca *)
2026 pkt_pull(pkt, sizeof(*cca));
2027 if (cca == NULL)
2028 return 0;
2030 if (!(meas_rep->len - 3 - sizeof(*cca))) {
2031 tprintf("Length of Req matchs not Type %u",
2032 meas_rep->type);
2033 return 0;
2036 tprintf("Ch Nr: %uus, ", cca->ch_nr);
2037 tprintf("Meas Start Time: %lu, ",
2038 le64_to_cpu(cca->start));
2039 tprintf("Meas Duration: %fs",
2040 le16_to_cpu(cca->dur) * TU);
2042 else if(meas_rep->type == 2) {
2043 struct element_meas_rpi *rpi;
2045 rpi = (struct element_meas_rpi *)
2046 pkt_pull(pkt, sizeof(*rpi));
2047 if (rpi == NULL)
2048 return 0;
2050 if (!(meas_rep->len - 3 - sizeof(*rpi))) {
2051 tprintf("Length of Req matchs not Type %u",
2052 meas_rep->type);
2053 return 0;
2056 tprintf("Ch Nr: %uus, ", rpi->ch_nr);
2057 tprintf("Meas Start Time: %lu, ",
2058 le64_to_cpu(rpi->start));
2059 tprintf("Meas Duration: %fs",
2060 le16_to_cpu(rpi->dur) * TU);
2062 else if(meas_rep->type == 3) {
2063 struct element_meas_ch_load *ch_load;
2065 ch_load = (struct element_meas_ch_load *)
2066 pkt_pull(pkt, sizeof(*ch_load));
2067 if (ch_load == NULL)
2068 return 0;
2070 if ((meas_rep->len - 3 - sizeof(*ch_load)) >= 0) {
2071 tprintf("Length of Req matchs not Type %u",
2072 meas_rep->type);
2073 return 0;
2076 tprintf("OP Class: %u, ", ch_load->op_class);
2077 tprintf("Ch Nr: %u, ", ch_load->ch_nr);
2078 tprintf("Rand Intv: %fs, ",
2079 le16_to_cpu(ch_load->rand_intv) * TU);
2080 tprintf("Meas Duration: %fs",
2081 le16_to_cpu(ch_load->dur) * TU);
2083 if(!subelements(pkt,
2084 meas_rep->len - 3 - sizeof(*ch_load)))
2085 return 0;
2087 else if(meas_rep->type == 4) {
2088 struct element_meas_noise *noise;
2090 noise = (struct element_meas_noise *)
2091 pkt_pull(pkt, sizeof(*noise));
2092 if (noise == NULL)
2093 return 0;
2095 if ((meas_rep->len - 3 - sizeof(*noise)) >= 0) {
2096 tprintf("Length of Req matchs not Type %u",
2097 meas_rep->type);
2098 return 0;
2101 tprintf("OP Class: %u, ", noise->op_class);
2102 tprintf("Ch Nr: %u, ", noise->ch_nr);
2103 tprintf("Rand Intv: %fs, ",
2104 le16_to_cpu(noise->rand_intv) * TU);
2105 tprintf("Meas Duration: %fs",
2106 le16_to_cpu(noise->dur) * TU);
2108 if(!subelements(pkt,
2109 meas_rep->len - 3 - sizeof(*noise)))
2110 return 0;
2112 else if(meas_rep->type == 5) {
2113 struct element_meas_beacon *beacon;
2115 beacon = (struct element_meas_beacon *)
2116 pkt_pull(pkt, sizeof(*beacon));
2117 if (beacon == NULL)
2118 return 0;
2120 if ((meas_rep->len - 3 - sizeof(*beacon)) >= 0) {
2121 tprintf("Length of Req matchs not Type %u",
2122 meas_rep->type);
2123 return 0;
2126 tprintf("OP Class: %u, ", beacon->op_class);
2127 tprintf("Ch Nr: %u, ", beacon->ch_nr);
2128 tprintf("Rand Intv: %fs, ",
2129 le16_to_cpu(beacon->rand_intv) * TU);
2130 tprintf("Meas Duration: %fs",
2131 le16_to_cpu(beacon->dur) * TU);
2132 tprintf("Mode: %u, ", beacon->mode);
2133 tprintf("BSSID: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
2134 beacon->bssid[0], beacon->bssid[1],
2135 beacon->bssid[2], beacon->bssid[3],
2136 beacon->bssid[4], beacon->bssid[5]);
2138 if(!subelements(pkt,
2139 meas_rep->len - 3 - sizeof(*beacon)))
2140 return 0;
2142 else if(meas_rep->type == 6) {
2143 struct element_meas_frame *frame;
2145 frame = (struct element_meas_frame *)
2146 pkt_pull(pkt, sizeof(*frame));
2147 if (frame == NULL)
2148 return 0;
2150 if ((meas_rep->len - 3 - sizeof(*frame)) >= 0) {
2151 tprintf("Length of Req matchs not Type %u",
2152 meas_rep->type);
2153 return 0;
2156 tprintf("OP Class: %u, ", frame->op_class);
2157 tprintf("Ch Nr: %u, ", frame->ch_nr);
2158 tprintf("Rand Intv: %fs, ",
2159 le16_to_cpu(frame->rand_intv) * TU);
2160 tprintf("Meas Duration: %fs",
2161 le16_to_cpu(frame->dur) * TU);
2162 tprintf("Request Type: %u, ", frame->frame);
2163 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
2164 frame->mac[0], frame->mac[1],
2165 frame->mac[2], frame->mac[3],
2166 frame->mac[4], frame->mac[5]);
2168 if(!subelements(pkt,
2169 meas_rep->len - 3 - sizeof(*frame)))
2170 return 0;
2172 else if(meas_rep->type == 7) {
2173 struct element_meas_sta *sta;
2175 sta = (struct element_meas_sta *)
2176 pkt_pull(pkt, sizeof(*sta));
2177 if (sta == NULL)
2178 return 0;
2180 if ((meas_rep->len - 3 - sizeof(*sta)) >= 0) {
2181 tprintf("Length of Req matchs not Type %u",
2182 meas_rep->type);
2183 return 0;
2186 tprintf("Peer MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
2187 sta->peer_mac[0], sta->peer_mac[1],
2188 sta->peer_mac[2], sta->peer_mac[3],
2189 sta->peer_mac[4], sta->peer_mac[5]);
2190 tprintf("Rand Intv: %fs, ",
2191 le16_to_cpu(sta->rand_intv) * TU);
2192 tprintf("Meas Duration: %fs",
2193 le16_to_cpu(sta->dur) * TU);
2194 tprintf("Group ID: %u, ", sta->group_id);
2196 if(!subelements(pkt,
2197 meas_rep->len - 3 - sizeof(*sta)))
2198 return 0;
2200 else if(meas_rep->type == 8) {
2201 struct element_meas_lci *lci;
2203 lci = (struct element_meas_lci *)
2204 pkt_pull(pkt, sizeof(*lci));
2205 if (lci == NULL)
2206 return 0;
2208 if ((meas_rep->len - 3 - sizeof(*lci)) >= 0) {
2209 tprintf("Length of Req matchs not Type %u",
2210 meas_rep->type);
2211 return 0;
2214 tprintf("Location Subj: %u, ", lci->loc_subj);
2215 tprintf("Latitude Req Res: %udeg",
2216 lci->latitude_req_res);
2217 tprintf("Longitude Req Res: %udeg",
2218 lci->longitude_req_res);
2219 tprintf("Altitude Req Res: %udeg",
2220 lci->altitude_req_res);
2222 if(!subelements(pkt,
2223 meas_rep->len - 3 - sizeof(*lci)))
2224 return 0;
2226 else if(meas_rep->type == 9) {
2227 struct element_meas_trans_str_cat *trans;
2229 trans = (struct element_meas_trans_str_cat *)
2230 pkt_pull(pkt, sizeof(*trans));
2231 if (trans == NULL)
2232 return 0;
2234 if ((meas_rep->len - 3 - sizeof(*trans)) >= 0) {
2235 tprintf("Length of Req matchs not Type %u",
2236 meas_rep->type);
2237 return 0;
2240 tprintf("Rand Intv: %fs, ",
2241 le16_to_cpu(trans->rand_intv) * TU);
2242 tprintf("Meas Duration: %fs",
2243 le16_to_cpu(trans->dur) * TU);
2244 tprintf("MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
2245 trans->peer_sta_addr[0], trans->peer_sta_addr[1],
2246 trans->peer_sta_addr[2], trans->peer_sta_addr[3],
2247 trans->peer_sta_addr[4], trans->peer_sta_addr[5]);
2248 tprintf("Traffic ID: %u, ", trans->traffic_id);
2249 tprintf("Bin 0 Range: %u, ", trans->bin_0_range);
2251 if(!subelements(pkt,
2252 meas_rep->len - 3 - sizeof(*trans)))
2253 return 0;
2255 else if(meas_rep->type == 10) {
2256 struct element_meas_mcast_diag *mcast;
2258 mcast = (struct element_meas_mcast_diag *)
2259 pkt_pull(pkt, sizeof(*mcast));
2260 if (mcast == NULL)
2261 return 0;
2263 if ((meas_rep->len - 3 - sizeof(*mcast)) >= 0) {
2264 tprintf("Length of Req matchs not Type %u",
2265 meas_rep->type);
2266 return 0;
2269 tprintf("Rand Intv: %fs, ",
2270 le16_to_cpu(mcast->rand_intv) * TU);
2271 tprintf("Meas Duration: %fs",
2272 le16_to_cpu(mcast->dur) * TU);
2273 tprintf("Group MAC Addr: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
2274 mcast->group_mac[0], mcast->group_mac[1],
2275 mcast->group_mac[2], mcast->group_mac[3],
2276 mcast->group_mac[4], mcast->group_mac[5]);
2278 if(!subelements(pkt,
2279 meas_rep->len - 3 - sizeof(*mcast)))
2280 return 0;
2282 else if(meas_rep->type == 11) {
2283 struct element_meas_loc_civic *civic;
2285 civic = (struct element_meas_loc_civic *)
2286 pkt_pull(pkt, sizeof(*civic));
2287 if (civic == NULL)
2288 return 0;
2290 if ((meas_rep->len - 3 - sizeof(*civic)) >= 0) {
2291 tprintf("Length of Req matchs not Type %u",
2292 meas_rep->type);
2293 return 0;
2296 tprintf("Location Subj: %u, ", civic->loc_subj);
2297 tprintf("Type: %u, ", civic->civic_loc);
2298 tprintf("Srv Intv Units: %u, ",
2299 le16_to_cpu(civic->loc_srv_intv_unit));
2300 tprintf("Srv Intv: %u, ", civic->loc_srv_intv);
2302 if(!subelements(pkt,
2303 meas_rep->len - 3 - sizeof(*civic)))
2304 return 0;
2306 else if(meas_rep->type == 12) {
2307 struct element_meas_loc_id *id;
2309 id = (struct element_meas_loc_id *)
2310 pkt_pull(pkt, sizeof(*id));
2311 if (id == NULL)
2312 return 0;
2314 if ((meas_rep->len - 3 - sizeof(*id)) >= 0) {
2315 tprintf("Length of Req matchs not Type %u",
2316 meas_rep->type);
2317 return 0;
2320 tprintf("Location Subj: %u, ", id->loc_subj);
2321 tprintf("Srv Intv Units: %u, ",
2322 le16_to_cpu(id->loc_srv_intv_unit));
2323 tprintf("Srv Intv: %u", id->loc_srv_intv);
2325 if(!subelements(pkt,
2326 meas_rep->len - 3 - sizeof(*id)))
2327 return 0;
2329 else {
2330 tprintf("Length field indicates data,"
2331 " but could not interpreted");
2332 return 0;
2336 return 1;
2339 static int8_t inf_quiet(struct pkt_buff *pkt, u8 *id)
2341 struct element_quiet *quiet;
2343 quiet = (struct element_quiet *) pkt_pull(pkt, sizeof(*quiet));
2344 if (quiet == NULL)
2345 return 0;
2347 tprintf("Quit (%u, Len(%u)): ", *id, quiet->len);
2348 if (len_neq_error(quiet->len, 6))
2349 return 0;
2351 tprintf("Count: %ud, ", quiet->cnt);
2352 tprintf("Period: %u, ", quiet->period);
2353 tprintf("Duration: %fs, ", le16_to_cpu(quiet->dur) * TU);
2354 tprintf("Offs: %fs", le16_to_cpu(quiet->offs) * TU);
2357 return 1;
2360 static int8_t inf_ibss_dfs(struct pkt_buff *pkt, u8 *id)
2362 struct element_ibss_dfs *ibss_dfs;
2363 u8 i;
2365 ibss_dfs = (struct element_ibss_dfs *) pkt_pull(pkt, sizeof(*ibss_dfs));
2366 if (ibss_dfs == NULL)
2367 return 0;
2369 tprintf("IBSS DFS (%u, Len(%u)): ", *id, ibss_dfs->len);
2370 if (len_lt_error(ibss_dfs->len, 7))
2371 return 0;
2373 tprintf("Owner: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, ",
2374 ibss_dfs->owner[0], ibss_dfs->owner[1],
2375 ibss_dfs->owner[2], ibss_dfs->owner[3],
2376 ibss_dfs->owner[4], ibss_dfs->owner[5]);
2377 tprintf("Recovery Intv: %u, ", ibss_dfs->rec_intv);
2379 if((ibss_dfs->len - sizeof(*ibss_dfs) + 1) & 1) {
2380 tprintf("Length of Channel Map should be modulo 2");
2381 return 0;
2384 for (i = 0; i < ibss_dfs->len; i += 2) {
2385 struct element_ibss_dfs_tuple *ibss_dfs_tuple;
2387 ibss_dfs_tuple = (struct element_ibss_dfs_tuple *)
2388 pkt_pull(pkt, sizeof(*ibss_dfs_tuple));
2389 if (ibss_dfs_tuple == NULL)
2390 return 0;
2392 tprintf("Channel Nr: %u, ", ibss_dfs_tuple->ch_nr);
2393 tprintf("Map: %u, ", ibss_dfs_tuple->map);
2396 return 1;
2399 static int8_t inf_erp(struct pkt_buff *pkt, u8 *id)
2401 struct element_erp *erp;
2403 erp = (struct element_erp *) pkt_pull(pkt, sizeof(*erp));
2404 if (erp == NULL)
2405 return 0;
2407 tprintf("ERP (%u, Len(%u)): ", *id, erp->len);
2408 if (len_neq_error(erp->len, 1))
2409 return 0;
2410 tprintf("Non ERP Present (%u), ", erp->param & 0x1);
2411 tprintf("Use Protection (%u), ", (erp->param >> 1) & 0x1);
2412 tprintf("Barker Preamble Mode (%u), ", (erp->param >> 2) & 0x1);
2413 tprintf("Reserved (0x%.5x)", erp->param >> 3);
2415 return 1;
2418 static int8_t inf_ts_del(struct pkt_buff *pkt, u8 *id)
2420 return 0;
2423 static int8_t inf_tclas_proc(struct pkt_buff *pkt, u8 *id)
2425 return 0;
2428 static int8_t inf_ht_cap(struct pkt_buff *pkt, u8 *id)
2430 return 0;
2433 static int8_t inf_qos_cap(struct pkt_buff *pkt, u8 *id)
2435 return 0;
2438 static int8_t inf_rsn(struct pkt_buff *pkt, u8 *id)
2440 return 0;
2443 static int8_t inf_ext_supp_rates(struct pkt_buff *pkt, u8 *id)
2445 u8 i;
2446 u8 *rates;
2447 struct element_ext_supp_rates *ext_supp_rates;
2449 ext_supp_rates = (struct element_ext_supp_rates *)
2450 pkt_pull(pkt, sizeof(*ext_supp_rates));
2451 if (ext_supp_rates == NULL)
2452 return 0;
2454 tprintf("Ext Support Rates (%u, Len(%u)): ", *id, ext_supp_rates->len);
2456 if ((ext_supp_rates->len - sizeof(*ext_supp_rates) + 1) > 0) {
2457 rates = pkt_pull(pkt, ext_supp_rates->len);
2458 if (rates == NULL)
2459 return 0;
2461 for (i = 0; i < ext_supp_rates->len; i++)
2462 tprintf("%g ", (rates[i] & 0x80) ?
2463 ((rates[i] & 0x3f) * 0.5) :
2464 data_rates(rates[i]));
2465 return 1;
2468 return 0;
2471 static int8_t inf_ap_ch_exp(struct pkt_buff *pkt, u8 *id) {
2472 return 0;
2475 static int8_t inf_neighb_rep(struct pkt_buff *pkt, u8 *id) {
2476 return 0;
2479 static int8_t inf_rcpi(struct pkt_buff *pkt, u8 *id) {
2480 return 0;
2483 static int8_t inf_mde(struct pkt_buff *pkt, u8 *id) {
2484 return 0;
2487 static int8_t inf_fte(struct pkt_buff *pkt, u8 *id) {
2488 return 0;
2491 static int8_t inf_time_out_int(struct pkt_buff *pkt, u8 *id) {
2492 return 0;
2495 static int8_t inf_rde(struct pkt_buff *pkt, u8 *id) {
2496 return 0;
2499 static int8_t inf_dse_reg_loc(struct pkt_buff *pkt, u8 *id) {
2500 return 0;
2503 static int8_t inf_supp_op_class(struct pkt_buff *pkt, u8 *id) {
2504 return 0;
2507 static int8_t inf_ext_ch_sw_ann(struct pkt_buff *pkt, u8 *id) {
2508 return 0;
2511 static int8_t inf_ht_op(struct pkt_buff *pkt, u8 *id) {
2512 return 0;
2515 static int8_t inf_sec_ch_offs(struct pkt_buff *pkt, u8 *id) {
2516 return 0;
2519 static int8_t inf_bss_avg_acc_del(struct pkt_buff *pkt, u8 *id) {
2520 return 0;
2523 static int8_t inf_ant(struct pkt_buff *pkt, u8 *id) {
2524 return 0;
2527 static int8_t inf_rsni(struct pkt_buff *pkt, u8 *id) {
2528 return 0;
2531 static int8_t inf_meas_pilot_trans(struct pkt_buff *pkt, u8 *id) {
2532 return 0;
2535 static int8_t inf_bss_avl_adm_cap(struct pkt_buff *pkt, u8 *id) {
2536 return 0;
2539 static int8_t inf_bss_ac_acc_del(struct pkt_buff *pkt, u8 *id) {
2540 return 0;
2543 static int8_t inf_time_adv(struct pkt_buff *pkt, u8 *id) {
2544 return 0;
2547 static int8_t inf_rm_ena_cap(struct pkt_buff *pkt, u8 *id) {
2548 return 0;
2551 static int8_t inf_mult_bssid(struct pkt_buff *pkt, u8 *id) {
2552 return 0;
2555 static int8_t inf_20_40_bss_coex(struct pkt_buff *pkt, u8 *id) {
2556 return 0;
2559 static int8_t inf_20_40_bss_int_ch_rep(struct pkt_buff *pkt, u8 *id) {
2560 return 0;
2563 static int8_t inf_overl_bss_scan_para(struct pkt_buff *pkt, u8 *id) {
2564 return 0;
2567 static int8_t inf_ric_desc(struct pkt_buff *pkt, u8 *id) {
2568 return 0;
2571 static int8_t inf_mgmt_mic(struct pkt_buff *pkt, u8 *id) {
2572 return 0;
2575 static int8_t inf_ev_req(struct pkt_buff *pkt, u8 *id) {
2576 return 0;
2579 static int8_t inf_ev_rep(struct pkt_buff *pkt, u8 *id) {
2580 return 0;
2583 static int8_t inf_diagn_req(struct pkt_buff *pkt, u8 *id) {
2584 return 0;
2587 static int8_t inf_diagn_rep(struct pkt_buff *pkt, u8 *id) {
2588 return 0;
2591 static int8_t inf_loc_para(struct pkt_buff *pkt, u8 *id) {
2592 return 0;
2595 static int8_t inf_nontr_bssid_cap(struct pkt_buff *pkt, u8 *id) {
2596 return 0;
2599 static int8_t inf_ssid_list(struct pkt_buff *pkt, u8 *id) {
2600 return 0;
2603 static int8_t inf_mult_bssid_index(struct pkt_buff *pkt, u8 *id) {
2604 return 0;
2607 static int8_t inf_fms_desc(struct pkt_buff *pkt, u8 *id) {
2608 return 0;
2611 static int8_t inf_fms_req(struct pkt_buff *pkt, u8 *id) {
2612 return 0;
2615 static int8_t inf_fms_resp(struct pkt_buff *pkt, u8 *id) {
2616 return 0;
2619 static int8_t inf_qos_tfc_cap(struct pkt_buff *pkt, u8 *id) {
2620 return 0;
2623 static int8_t inf_bss_max_idle_per(struct pkt_buff *pkt, u8 *id) {
2624 return 0;
2627 static int8_t inf_tfs_req(struct pkt_buff *pkt, u8 *id) {
2628 return 0;
2631 static int8_t inf_tfs_resp(struct pkt_buff *pkt, u8 *id) {
2632 return 0;
2635 static int8_t inf_wnm_sleep_mod(struct pkt_buff *pkt, u8 *id) {
2636 return 0;
2639 static int8_t inf_tim_bcst_req(struct pkt_buff *pkt, u8 *id) {
2640 return 0;
2643 static int8_t inf_tim_bcst_resp(struct pkt_buff *pkt, u8 *id) {
2644 return 0;
2647 static int8_t inf_coll_interf_rep(struct pkt_buff *pkt, u8 *id) {
2648 return 0;
2651 static int8_t inf_ch_usage(struct pkt_buff *pkt, u8 *id) {
2652 return 0;
2655 static int8_t inf_time_zone(struct pkt_buff *pkt, u8 *id) {
2656 return 0;
2659 static int8_t inf_dms_req(struct pkt_buff *pkt, u8 *id) {
2660 return 0;
2663 static int8_t inf_dms_resp(struct pkt_buff *pkt, u8 *id) {
2664 return 0;
2667 static int8_t inf_link_id(struct pkt_buff *pkt, u8 *id) {
2668 return 0;
2671 static int8_t inf_wakeup_sched(struct pkt_buff *pkt, u8 *id) {
2672 return 0;
2675 static int8_t inf_ch_sw_timing(struct pkt_buff *pkt, u8 *id) {
2676 return 0;
2679 static int8_t inf_pti_ctrl(struct pkt_buff *pkt, u8 *id) {
2680 return 0;
2683 static int8_t inf_tpu_buff_status(struct pkt_buff *pkt, u8 *id) {
2684 return 0;
2687 static int8_t inf_interw(struct pkt_buff *pkt, u8 *id) {
2688 return 0;
2691 static int8_t inf_adv_proto(struct pkt_buff *pkt, u8 *id) {
2692 return 0;
2695 static int8_t inf_exp_bandw_req(struct pkt_buff *pkt, u8 *id) {
2696 return 0;
2699 static int8_t inf_qos_map_set(struct pkt_buff *pkt, u8 *id) {
2700 return 0;
2703 static int8_t inf_roam_cons(struct pkt_buff *pkt, u8 *id) {
2704 return 0;
2707 static int8_t inf_emer_alert_id(struct pkt_buff *pkt, u8 *id) {
2708 return 0;
2711 static int8_t inf_mesh_conf(struct pkt_buff *pkt, u8 *id) {
2712 return 0;
2715 static int8_t inf_mesh_id(struct pkt_buff *pkt, u8 *id) {
2716 return 0;
2719 static int8_t inf_mesh_link_metr_rep(struct pkt_buff *pkt, u8 *id) {
2720 return 0;
2723 static int8_t inf_cong_notif(struct pkt_buff *pkt, u8 *id) {
2724 return 0;
2727 static int8_t inf_mesh_peer_mgmt(struct pkt_buff *pkt, u8 *id) {
2728 return 0;
2731 static int8_t inf_mesh_ch_sw_para(struct pkt_buff *pkt, u8 *id) {
2732 return 0;
2735 static int8_t inf_mesh_awake_win(struct pkt_buff *pkt, u8 *id) {
2736 return 0;
2739 static int8_t inf_beacon_timing(struct pkt_buff *pkt, u8 *id) {
2740 return 0;
2743 static int8_t inf_mccaop_setup_req(struct pkt_buff *pkt, u8 *id) {
2744 return 0;
2747 static int8_t inf_mccaop_setup_rep(struct pkt_buff *pkt, u8 *id) {
2748 return 0;
2751 static int8_t inf_mccaop_adv(struct pkt_buff *pkt, u8 *id) {
2752 return 0;
2755 static int8_t inf_mccaop_teardwn(struct pkt_buff *pkt, u8 *id) {
2756 return 0;
2759 static int8_t inf_gann(struct pkt_buff *pkt, u8 *id) {
2760 return 0;
2763 static int8_t inf_rann(struct pkt_buff *pkt, u8 *id) {
2764 return 0;
2767 static int8_t inf_ext_cap(struct pkt_buff *pkt, u8 *id) {
2768 return 0;
2771 static int8_t inf_preq(struct pkt_buff *pkt, u8 *id) {
2772 return 0;
2775 static int8_t inf_prep(struct pkt_buff *pkt, u8 *id) {
2776 return 0;
2779 static int8_t inf_perr(struct pkt_buff *pkt, u8 *id) {
2780 return 0;
2783 static int8_t inf_pxu(struct pkt_buff *pkt, u8 *id) {
2784 return 0;
2787 static int8_t inf_pxuc(struct pkt_buff *pkt, u8 *id) {
2788 return 0;
2791 static int8_t inf_auth_mesh_peer_exch(struct pkt_buff *pkt, u8 *id) {
2792 return 0;
2795 static int8_t inf_mic(struct pkt_buff *pkt, u8 *id) {
2796 return 0;
2799 static int8_t inf_dest_uri(struct pkt_buff *pkt, u8 *id) {
2800 return 0;
2803 static int8_t inf_u_apsd_coex(struct pkt_buff *pkt, u8 *id) {
2804 return 0;
2807 static int8_t inf_mccaop_adv_overv(struct pkt_buff *pkt, u8 *id) {
2808 return 0;
2811 static int8_t inf_vend_spec(struct pkt_buff *pkt, u8 *id)
2813 u8 i;
2814 u8 *data;
2815 struct element_vend_spec *vend_spec;
2817 vend_spec = (struct element_vend_spec *)
2818 pkt_pull(pkt, sizeof(*vend_spec));
2819 if (vend_spec == NULL)
2820 return 0;
2822 tprintf("Vendor Specific (%u, Len (%u)): ", *id, vend_spec->len);
2824 data = pkt_pull(pkt, vend_spec->len);
2825 if (data == NULL)
2826 return 0;
2828 tprintf("Data 0x");
2829 for (i = 0; i < vend_spec->len; i++)
2830 tprintf("%.2x", data[i]);
2832 return 1;
2835 static int8_t inf_elements(struct pkt_buff *pkt)
2837 u8 *id = pkt_pull(pkt, 1);
2838 if (id == NULL)
2839 return 0;
2841 switch (*id) {
2842 case 0: return inf_ssid(pkt, id);
2843 case 1: return inf_supp_rates(pkt, id);
2844 case 2: return inf_fh_ps(pkt, id);
2845 case 3: return inf_dsss_ps(pkt, id);
2846 case 4: return inf_cf_ps(pkt, id);
2847 case 5: return inf_tim(pkt, id);
2848 case 6: return inf_ibss_ps(pkt, id);
2849 case 7: return inf_country(pkt, id);
2850 case 8: return inf_hop_pp(pkt, id);
2851 case 9: return inf_hop_pt(pkt, id);
2852 case 10: return inf_req(pkt, id);
2853 case 11: return inf_bss_load(pkt, id);
2854 case 12: return inf_edca_ps(pkt, id);
2855 case 13: return inf_tspec(pkt, id);
2856 case 14: return inf_tclas(pkt, id);
2857 case 15: return inf_sched(pkt, id);
2858 case 16: return inf_chall_txt(pkt, id);
2859 case 17 ... 31: return inf_reserved(pkt, id);
2860 case 32: return inf_pwr_constr(pkt, id);
2861 case 33: return inf_pwr_cap(pkt, id);
2862 case 34: return inf_tpc_req(pkt, id);
2863 case 35: return inf_tpc_rep(pkt, id);
2864 case 36: return inf_supp_ch(pkt, id);
2865 case 37: return inf_ch_sw_ann(pkt, id);
2866 case 38: return inf_meas_req(pkt, id);
2867 case 39: return inf_meas_rep(pkt, id);
2868 case 40: return inf_quiet(pkt, id);
2869 case 41: return inf_ibss_dfs(pkt, id);
2870 case 42: return inf_erp(pkt, id);
2871 case 43: return inf_ts_del(pkt, id);
2872 case 44: return inf_tclas_proc(pkt, id);
2873 case 45: return inf_ht_cap(pkt, id);
2874 case 46: return inf_qos_cap(pkt, id);
2875 case 47: return inf_reserved(pkt, id);
2876 case 48: return inf_rsn(pkt, id);
2877 case 49: return inf_rsn(pkt, id);
2878 case 50: return inf_ext_supp_rates(pkt, id);
2879 case 51: return inf_ap_ch_exp(pkt, id);
2880 case 52: return inf_neighb_rep(pkt, id);
2881 case 53: return inf_rcpi(pkt, id);
2882 case 54: return inf_mde(pkt, id);
2883 case 55: return inf_fte(pkt, id);
2884 case 56: return inf_time_out_int(pkt, id);
2885 case 57: return inf_rde(pkt, id);
2886 case 58: return inf_dse_reg_loc(pkt, id);
2887 case 59: return inf_supp_op_class(pkt, id);
2888 case 60: return inf_ext_ch_sw_ann(pkt, id);
2889 case 61: return inf_ht_op(pkt, id);
2890 case 62: return inf_sec_ch_offs(pkt, id);
2891 case 63: return inf_bss_avg_acc_del(pkt, id);
2892 case 64: return inf_ant(pkt, id);
2893 case 65: return inf_rsni(pkt, id);
2894 case 66: return inf_meas_pilot_trans(pkt, id);
2895 case 67: return inf_bss_avl_adm_cap(pkt, id);
2896 case 68: return inf_bss_ac_acc_del(pkt, id);
2897 case 69: return inf_time_adv(pkt, id);
2898 case 70: return inf_rm_ena_cap(pkt, id);
2899 case 71: return inf_mult_bssid(pkt, id);
2900 case 72: return inf_20_40_bss_coex(pkt, id);
2901 case 73: return inf_20_40_bss_int_ch_rep(pkt, id);
2902 case 74: return inf_overl_bss_scan_para(pkt, id);
2903 case 75: return inf_ric_desc(pkt, id);
2904 case 76: return inf_mgmt_mic(pkt, id);
2905 case 78: return inf_ev_req(pkt, id);
2906 case 79: return inf_ev_rep(pkt, id);
2907 case 80: return inf_diagn_req(pkt, id);
2908 case 81: return inf_diagn_rep(pkt, id);
2909 case 82: return inf_loc_para(pkt, id);
2910 case 83: return inf_nontr_bssid_cap(pkt, id);
2911 case 84: return inf_ssid_list(pkt, id);
2912 case 85: return inf_mult_bssid_index(pkt, id);
2913 case 86: return inf_fms_desc(pkt, id);
2914 case 87: return inf_fms_req(pkt, id);
2915 case 88: return inf_fms_resp(pkt, id);
2916 case 89: return inf_qos_tfc_cap(pkt, id);
2917 case 90: return inf_bss_max_idle_per(pkt, id);
2918 case 91: return inf_tfs_req(pkt, id);
2919 case 92: return inf_tfs_resp(pkt, id);
2920 case 93: return inf_wnm_sleep_mod(pkt, id);
2921 case 94: return inf_tim_bcst_req(pkt, id);
2922 case 95: return inf_tim_bcst_resp(pkt, id);
2923 case 96: return inf_coll_interf_rep(pkt, id);
2924 case 97: return inf_ch_usage(pkt, id);
2925 case 98: return inf_time_zone(pkt, id);
2926 case 99: return inf_dms_req(pkt, id);
2927 case 100: return inf_dms_resp(pkt, id);
2928 case 101: return inf_link_id(pkt, id);
2929 case 102: return inf_wakeup_sched(pkt, id);
2930 case 104: return inf_ch_sw_timing(pkt, id);
2931 case 105: return inf_pti_ctrl(pkt, id);
2932 case 106: return inf_tpu_buff_status(pkt, id);
2933 case 107: return inf_interw(pkt, id);
2934 case 108: return inf_adv_proto(pkt, id);
2935 case 109: return inf_exp_bandw_req(pkt, id);
2936 case 110: return inf_qos_map_set(pkt, id);
2937 case 111: return inf_roam_cons(pkt, id);
2938 case 112: return inf_emer_alert_id(pkt, id);
2939 case 113: return inf_mesh_conf(pkt, id);
2940 case 114: return inf_mesh_id(pkt, id);
2941 case 115: return inf_mesh_link_metr_rep(pkt, id);
2942 case 116: return inf_cong_notif(pkt, id);
2943 case 117: return inf_mesh_peer_mgmt(pkt, id);
2944 case 118: return inf_mesh_ch_sw_para(pkt, id);
2945 case 119: return inf_mesh_awake_win(pkt, id);
2946 case 120: return inf_beacon_timing(pkt, id);
2947 case 121: return inf_mccaop_setup_req(pkt, id);
2948 case 122: return inf_mccaop_setup_rep(pkt, id);
2949 case 123: return inf_mccaop_adv(pkt, id);
2950 case 124: return inf_mccaop_teardwn(pkt, id);
2951 case 125: return inf_gann(pkt, id);
2952 case 126: return inf_rann(pkt, id);
2953 case 127: return inf_ext_cap(pkt, id);
2954 case 128: return inf_reserved(pkt, id);
2955 case 129: return inf_reserved(pkt, id);
2956 case 130: return inf_preq(pkt, id);
2957 case 131: return inf_prep(pkt, id);
2958 case 132: return inf_perr(pkt, id);
2959 case 133: return inf_reserved(pkt, id);
2960 case 134: return inf_reserved(pkt, id);
2961 case 135: return inf_reserved(pkt, id);
2962 case 136: return inf_reserved(pkt, id);
2963 case 137: return inf_pxu(pkt, id);
2964 case 138: return inf_pxuc(pkt, id);
2965 case 139: return inf_auth_mesh_peer_exch(pkt, id);
2966 case 140: return inf_mic(pkt, id);
2967 case 141: return inf_dest_uri(pkt, id);
2968 case 142: return inf_u_apsd_coex(pkt, id);
2969 case 143 ... 173: return inf_reserved(pkt, id);
2970 case 174: return inf_mccaop_adv_overv(pkt, id);
2971 case 221: return inf_vend_spec(pkt, id);
2974 return 0;
2977 #define ESS 0b0000000000000001
2978 #define IBSS 0b0000000000000010
2979 #define CF_Pollable 0b0000000000000100
2980 #define CF_Poll_Req 0b0000000000001000
2981 #define Privacy 0b0000000000010000
2982 #define Short_Pre 0b0000000000100000
2983 #define PBCC 0b0000000001000000
2984 #define Ch_Agility 0b0000000010000000
2985 #define Spec_Mgmt 0b0000000100000000
2986 #define QoS 0b0000001000000000
2987 #define Short_Slot_t 0b0000010000000000
2988 #define APSD 0b0000100000000000
2989 #define Radio_Meas 0b0001000000000000
2990 #define DSSS_OFDM 0b0010000000000000
2991 #define Del_Block_ACK 0b0100000000000000
2992 #define Imm_Block_ACK 0b1000000000000000
2994 static int8_t cap_field(u16 cap_inf)
2996 if (ESS & cap_inf)
2997 tprintf(" ESS;");
2998 if (IBSS & cap_inf)
2999 tprintf(" IBSS;");
3000 if (CF_Pollable & cap_inf)
3001 tprintf(" CF Pollable;");
3002 if (CF_Poll_Req & cap_inf)
3003 tprintf(" CF-Poll Request;");
3004 if (Privacy & cap_inf)
3005 tprintf(" Privacy;");
3006 if (Short_Pre & cap_inf)
3007 tprintf(" Short Preamble;");
3008 if (PBCC & cap_inf)
3009 tprintf(" PBCC;");
3010 if (Ch_Agility & cap_inf)
3011 tprintf(" Channel Agility;");
3012 if (Spec_Mgmt & cap_inf)
3013 tprintf(" Spectrum Management;");
3014 if (QoS & cap_inf)
3015 tprintf(" QoS;");
3016 if (Short_Slot_t & cap_inf)
3017 tprintf(" Short Slot Time;");
3018 if (APSD & cap_inf)
3019 tprintf(" APSD;");
3020 if (Radio_Meas & cap_inf)
3021 tprintf(" Radio Measurement;");
3022 if (DSSS_OFDM & cap_inf)
3023 tprintf(" DSSS-OFDM;");
3024 if (Del_Block_ACK & cap_inf)
3025 tprintf(" Delayed Block Ack;");
3026 if (Imm_Block_ACK & cap_inf)
3027 tprintf(" Immediate Block Ack;");
3029 return 1;
3032 /* Management Dissectors */
3033 static int8_t assoc_req(struct pkt_buff *pkt) {
3034 return 0;
3037 static int8_t assoc_resp(struct pkt_buff *pkt) {
3038 return 0;
3041 static int8_t reassoc_req(struct pkt_buff *pkt) {
3042 return 0;
3045 static int8_t reassoc_resp(struct pkt_buff *pkt) {
3046 return 0;
3049 static int8_t probe_req(struct pkt_buff *pkt) {
3050 return 0;
3053 static int8_t probe_resp(struct pkt_buff *pkt) {
3054 return 0;
3057 static int8_t beacon(struct pkt_buff *pkt)
3059 struct ieee80211_mgmt_beacon *beacon;
3061 beacon = (struct ieee80211_mgmt_beacon *)
3062 pkt_pull(pkt, sizeof(*beacon));
3063 if (beacon == NULL)
3064 return 0;
3066 tprintf("Timestamp 0x%.16lx, ", le64_to_cpu(beacon->timestamp));
3067 tprintf("Beacon Interval (%fs), ", le16_to_cpu(beacon->beacon_int)*TU);
3068 tprintf("Capabilities (0x%x <->", le16_to_cpu(beacon->capab_info));
3069 cap_field(le16_to_cpu(beacon->capab_info));
3070 tprintf(")");
3072 if(pkt_len(pkt)) {
3073 tprintf("\n\tParameters:");
3074 while (inf_elements(pkt)) {
3075 tprintf("\n\t");
3079 if(pkt_len(pkt))
3080 return 0;
3081 return 1;
3084 static int8_t atim(struct pkt_buff *pkt) {
3085 return 0;
3088 static int8_t disassoc(struct pkt_buff *pkt) {
3089 return 0;
3092 static int8_t auth(struct pkt_buff *pkt) {
3093 return 0;
3096 static int8_t deauth(struct pkt_buff *pkt) {
3097 return 0;
3099 /* End Management Dissectors */
3101 /* Control Dissectors */
3102 static int8_t ps_poll(struct pkt_buff *pkt) {
3103 return 0;
3106 static int8_t rts(struct pkt_buff *pkt) {
3107 return 0;
3110 static int8_t cts(struct pkt_buff *pkt) {
3111 return 0;
3114 static int8_t ack(struct pkt_buff *pkt) {
3115 return 0;
3118 static int8_t cf_end(struct pkt_buff *pkt) {
3119 return 0;
3122 static int8_t cf_end_ack(struct pkt_buff *pkt) {
3123 return 0;
3125 /* End Control Dissectors */
3127 /* Data Dissectors */
3128 static int8_t data(struct pkt_buff *pkt) {
3129 return 0;
3132 static int8_t data_cf_ack(struct pkt_buff *pkt) {
3133 return 0;
3136 static int8_t data_cf_poll(struct pkt_buff *pkt) {
3137 return 0;
3140 static int8_t data_cf_ack_poll(struct pkt_buff *pkt) {
3141 return 0;
3144 static int8_t null(struct pkt_buff *pkt) {
3145 return 0;
3148 static int8_t cf_ack(struct pkt_buff *pkt) {
3149 return 0;
3152 static int8_t cf_poll(struct pkt_buff *pkt) {
3153 return 0;
3156 static int8_t cf_ack_poll(struct pkt_buff *pkt) {
3157 return 0;
3159 /* End Data Dissectors */
3161 static const char *mgt_sub(u8 subtype, struct pkt_buff *pkt,
3162 int8_t (**get_content)(struct pkt_buff *pkt))
3164 u16 seq_ctrl;
3165 struct ieee80211_mgmt *mgmt;
3166 const char *dst, *src, *bssid;
3168 mgmt = (struct ieee80211_mgmt *) pkt_pull(pkt, sizeof(*mgmt));
3169 if (mgmt == NULL)
3170 return 0;
3172 dst = lookup_vendor((mgmt->da[0] << 16) |
3173 (mgmt->da[1] << 8) |
3174 mgmt->da[2]);
3175 src = lookup_vendor((mgmt->sa[0] << 16) |
3176 (mgmt->sa[1] << 8) |
3177 mgmt->sa[2]);
3179 bssid = lookup_vendor((mgmt->bssid[0] << 16) |
3180 (mgmt->bssid[1] << 8) |
3181 mgmt->bssid[2]);
3182 seq_ctrl = le16_to_cpu(mgmt->seq_ctrl);
3184 tprintf("Duration (%u),", le16_to_cpu(mgmt->duration));
3185 tprintf("\n\tDestination (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x) ",
3186 mgmt->da[0], mgmt->da[1], mgmt->da[2],
3187 mgmt->da[3], mgmt->da[4], mgmt->da[5]);
3188 if (dst) {
3189 tprintf("=> (%s:%.2x:%.2x:%.2x)", dst,
3190 mgmt->da[3], mgmt->da[4], mgmt->da[5]);
3193 tprintf("\n\tSource (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x) ",
3194 mgmt->sa[0], mgmt->sa[1], mgmt->sa[2],
3195 mgmt->sa[3], mgmt->sa[4], mgmt->sa[5]);
3196 if (src) {
3197 tprintf("=> (%s:%.2x:%.2x:%.2x)", src,
3198 mgmt->sa[3], mgmt->sa[4], mgmt->sa[5]);
3201 tprintf("\n\tBSSID (%.2x:%.2x:%.2x:%.2x:%.2x:%.2x) ",
3202 mgmt->bssid[0], mgmt->bssid[1], mgmt->bssid[2],
3203 mgmt->bssid[3], mgmt->bssid[4], mgmt->bssid[5]);
3204 if(bssid) {
3205 tprintf("=> (%s:%.2x:%.2x:%.2x)", bssid,
3206 mgmt->bssid[3], mgmt->bssid[4], mgmt->bssid[5]);
3209 tprintf("\n\tFragmentnr. (%u), Seqnr. (%u). ",
3210 seq_ctrl & 0xf, seq_ctrl >> 4);
3212 switch (subtype) {
3213 case 0b0000:
3214 *get_content = assoc_req;
3215 return "Association Request";
3216 case 0b0001:
3217 *get_content = assoc_resp;
3218 return "Association Response";
3219 case 0b0010:
3220 *get_content = reassoc_req;
3221 return "Reassociation Request";
3222 case 0b0011:
3223 *get_content = reassoc_resp;
3224 return "Reassociation Response";
3225 case 0b0100:
3226 *get_content = probe_req;
3227 return "Probe Request";
3228 case 0b0101:
3229 *get_content = probe_resp;
3230 return "Probe Response";
3231 case 0b1000:
3232 *get_content = beacon;
3233 return "Beacon";
3234 case 0b1001:
3235 *get_content = atim;
3236 return "ATIM";
3237 case 0b1010:
3238 *get_content = disassoc;
3239 return "Disassociation";
3240 case 0b1011:
3241 *get_content = auth;
3242 return "Authentication";
3243 case 0b1100:
3244 *get_content = deauth;
3245 return "Deauthentication";
3246 case 0b0110 ... 0b0111:
3247 case 0b1101 ... 0b1111:
3248 *get_content = NULL;
3249 return "Reserved";
3250 default:
3251 *get_content = NULL;
3252 return "Management SubType unknown";
3256 static const char *ctrl_sub(u8 subtype, struct pkt_buff *pkt,
3257 int8_t (**get_content)(struct pkt_buff *pkt))
3259 switch (subtype) {
3260 case 0b1010:
3261 *get_content = ps_poll;
3262 return "PS-Poll";
3263 case 0b1011:
3264 *get_content = rts;
3265 return "RTS";
3266 case 0b1100:
3267 *get_content = cts;
3268 return "CTS";
3269 case 0b1101:
3270 *get_content = ack;
3271 return "ACK";
3272 case 0b1110:
3273 *get_content = cf_end;
3274 return "CF End";
3275 case 0b1111:
3276 *get_content = cf_end_ack;
3277 return "CF End + CF-ACK";
3278 case 0b0000 ... 0b1001:
3279 *get_content = NULL;
3280 return "Reserved";
3281 default:
3282 return "Control SubType unkown";
3286 static const char *data_sub(u8 subtype, struct pkt_buff *pkt,
3287 int8_t (**get_content)(struct pkt_buff *pkt))
3289 switch (subtype) {
3290 case 0b0000:
3291 *get_content = data;
3292 return "Data";
3293 case 0b0001:
3294 *get_content = data_cf_ack;
3295 return "Data + CF-ACK";
3296 case 0b0010:
3297 *get_content = data_cf_poll;
3298 return "Data + CF-Poll";
3299 case 0b0011:
3300 *get_content = data_cf_ack_poll;
3301 return "Data + CF-ACK + CF-Poll";
3302 case 0b0100:
3303 *get_content = null;
3304 return "Null";
3305 case 0b0101:
3306 *get_content = cf_ack;
3307 return "CF-ACK";
3308 case 0b0110:
3309 *get_content = cf_poll;
3310 return "CF-Poll";
3311 case 0b0111:
3312 *get_content = cf_ack_poll;
3313 return "CF-ACK + CF-Poll";
3314 case 0b1000 ... 0b1111:
3315 *get_content = NULL;
3316 return "Reserved";
3317 default:
3318 *get_content = NULL;
3319 return "Data SubType unkown";
3323 static const char *
3324 frame_control_type(u8 type, const char *(**get_subtype)(u8 subtype,
3325 struct pkt_buff *pkt, int8_t (**get_content)(struct pkt_buff *pkt)))
3327 switch (type) {
3328 case 0b00:
3329 *get_subtype = mgt_sub;
3330 return "Management";
3331 case 0b01:
3332 *get_subtype = ctrl_sub;
3333 return "Control";
3334 case 0b10:
3335 *get_subtype = data_sub;
3336 return "Data";
3337 case 0b11:
3338 *get_subtype = NULL;
3339 return "Reserved";
3340 default:
3341 *get_subtype = NULL;
3342 return "Control Type unkown";
3346 static void ieee80211(struct pkt_buff *pkt)
3348 int8_t (*get_content)(struct pkt_buff *pkt) = NULL;
3349 const char *(*get_subtype)(u8 subtype, struct pkt_buff *pkt,
3350 int8_t (**get_content)(struct pkt_buff *pkt)) = NULL;
3351 const char *subtype = NULL;
3352 struct ieee80211_frm_ctrl *frm_ctrl;
3354 frm_ctrl = (struct ieee80211_frm_ctrl *)
3355 pkt_pull(pkt, sizeof(*frm_ctrl));
3356 if (frm_ctrl == NULL)
3357 return;
3359 tprintf(" [ 802.11 Frame Control (0x%04x)]\n",
3360 le16_to_cpu(frm_ctrl->frame_control));
3362 tprintf(" [ Proto Version (%u), ", frm_ctrl->proto_version);
3363 tprintf("Type (%u, %s), ", frm_ctrl->type,
3364 frame_control_type(frm_ctrl->type, &get_subtype));
3365 if (get_subtype) {
3366 subtype = (*get_subtype)(frm_ctrl->subtype, pkt, &get_content);
3367 tprintf("Subtype (%u, %s)", frm_ctrl->subtype, subtype);
3368 } else {
3369 tprintf("%s%s%s", colorize_start_full(black, red),
3370 "No SubType Data available", colorize_end());
3373 tprintf("%s%s", frm_ctrl->to_ds ? ", Frame goes to DS" : "",
3374 frm_ctrl->from_ds ? ", Frame comes from DS" : "");
3375 tprintf("%s", frm_ctrl->more_frags ? ", More Fragments" : "");
3376 tprintf("%s", frm_ctrl->retry ? ", Frame is retransmitted" : "");
3377 tprintf("%s", frm_ctrl->power_mgmt ? ", In Power Saving Mode" : "");
3378 tprintf("%s", frm_ctrl->more_data ? ", More Data" : "");
3379 tprintf("%s", frm_ctrl->wep ? ", Needs WEP" : "");
3380 tprintf("%s", frm_ctrl->order ? ", Order" : "");
3381 tprintf(" ]\n");
3383 if (get_content) {
3384 tprintf(" [ Subtype %s: ", subtype);
3385 if (!((*get_content) (pkt)))
3386 tprintf("%s%s%s", colorize_start_full(black, red),
3387 "Failed to dissect Subtype", colorize_end());
3388 tprintf(" ]");
3389 } else {
3390 tprintf("%s%s%s", colorize_start_full(black, red),
3391 "No SubType Data available", colorize_end());
3394 tprintf("\n");
3396 // pkt_set_proto(pkt, &ieee802_lay2, ntohs(eth->h_proto));
3399 static void ieee80211_less(struct pkt_buff *pkt)
3401 tprintf("802.11 frame (more on todo)");
3404 struct protocol ieee80211_ops = {
3405 .key = 0,
3406 .print_full = ieee80211,
3407 .print_less = ieee80211_less,
3410 EXPORT_SYMBOL(ieee80211_ops);