3 * Fortress Technologies, Inc. All rights reserved.
4 * Charlie Lenahan (clenahan@fortresstech.com)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that: (1) source code distributions
8 * retain the above copyright notice and this paragraph in its entirety, (2)
9 * distributions including binary code include the above copyright notice and
10 * this paragraph in its entirety in the documentation or other materials
11 * provided with the distribution, and (3) all advertising materials mentioning
12 * features or use of this software display the following acknowledgement:
13 * ``This product includes software developed by the University of California,
14 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 * the University nor the names of its contributors may be used to endorse
16 * or promote products derived from this software without specific prior
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24 static const char rcsid
[] _U_
=
25 "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp $ (LBL)";
32 #include <tcpdump-stdinc.h>
38 #include "interface.h"
39 #include "addrtoname.h"
40 #include "ethertype.h"
46 #include "ieee802_11.h"
47 #include "ieee802_11_radio.h"
49 #define PRINT_SSID(p) \
50 switch (p.ssid_status) { \
55 fn_print(p.ssid.ssid, NULL); \
62 #define PRINT_RATE(_sep, _r, _suf) \
63 printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)
64 #define PRINT_RATES(p) \
65 switch (p.rates_status) { \
71 const char *sep = " ["; \
72 for (z = 0; z < p.rates.length ; z++) { \
73 PRINT_RATE(sep, p.rates.rate[z], \
74 (p.rates.rate[z] & 0x80 ? "*" : "")); \
77 if (p.rates.length != 0) \
85 #define PRINT_DS_CHANNEL(p) \
86 switch (p.ds_status) { \
90 printf(" CH: %u", p.ds.channel); \
96 CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" );
98 static const int ieee80211_htrates
[16] = {
99 13, /* IFM_IEEE80211_MCS0 */
100 26, /* IFM_IEEE80211_MCS1 */
101 39, /* IFM_IEEE80211_MCS2 */
102 52, /* IFM_IEEE80211_MCS3 */
103 78, /* IFM_IEEE80211_MCS4 */
104 104, /* IFM_IEEE80211_MCS5 */
105 117, /* IFM_IEEE80211_MCS6 */
106 130, /* IFM_IEEE80211_MCS7 */
107 26, /* IFM_IEEE80211_MCS8 */
108 52, /* IFM_IEEE80211_MCS9 */
109 78, /* IFM_IEEE80211_MCS10 */
110 104, /* IFM_IEEE80211_MCS11 */
111 156, /* IFM_IEEE80211_MCS12 */
112 208, /* IFM_IEEE80211_MCS13 */
113 234, /* IFM_IEEE80211_MCS14 */
114 260, /* IFM_IEEE80211_MCS15 */
116 #define PRINT_HT_RATE(_sep, _r, _suf) \
117 printf("%s%.1f%s", _sep, (.5 * ieee80211_htrates[(_r) & 0xf]), _suf)
119 static const char *auth_alg_text
[]={"Open System","Shared Key","EAP"};
120 #define NUM_AUTH_ALGS (sizeof auth_alg_text / sizeof auth_alg_text[0])
122 static const char *status_text
[] = {
124 "Unspecified failure", /* 1 */
133 "Cannot Support all requested capabilities in the Capability "
134 "Information field", /* 10 */
135 "Reassociation denied due to inability to confirm that association "
137 "Association denied due to reason outside the scope of the "
139 "Responding station does not support the specified authentication "
140 "algorithm ", /* 13 */
141 "Received an Authentication frame with authentication transaction "
142 "sequence number out of expected sequence", /* 14 */
143 "Authentication rejected because of challenge failure", /* 15 */
144 "Authentication rejected due to timeout waiting for next frame in "
146 "Association denied because AP is unable to handle additional"
147 "associated stations", /* 17 */
148 "Association denied due to requesting station not supporting all of "
149 "the data rates in BSSBasicRateSet parameter", /* 18 */
150 "Association denied due to requesting station not supporting "
151 "short preamble operation", /* 19 */
152 "Association denied due to requesting station not supporting "
153 "PBCC encoding", /* 20 */
154 "Association denied due to requesting station not supporting "
155 "channel agility", /* 21 */
156 "Association request rejected because Spectrum Management "
157 "capability is required", /* 22 */
158 "Association request rejected because the information in the "
159 "Power Capability element is unacceptable", /* 23 */
160 "Association request rejected because the information in the "
161 "Supported Channels element is unacceptable", /* 24 */
162 "Association denied due to requesting station not supporting "
163 "short slot operation", /* 25 */
164 "Association denied due to requesting station not supporting "
165 "DSSS-OFDM operation", /* 26 */
166 "Association denied because the requested STA does not support HT "
169 "Association denied because the requested STA does not support "
170 "the PCO transition time required by the AP", /* 29 */
173 "Unspecified, QoS-related failure", /* 32 */
174 "Association denied due to QAP having insufficient bandwidth "
175 "to handle another QSTA", /* 33 */
176 "Association denied due to excessive frame loss rates and/or "
177 "poor conditions on current operating channel", /* 34 */
178 "Association (with QBSS) denied due to requesting station not "
179 "supporting the QoS facility", /* 35 */
180 "Association denied due to requesting station not supporting "
181 "Block Ack", /* 36 */
182 "The request has been declined", /* 37 */
183 "The request has not been successful as one or more parameters "
184 "have invalid values", /* 38 */
185 "The TS has not been created because the request cannot be honored. "
186 "However, a suggested TSPEC is provided so that the initiating QSTA"
187 "may attempt to set another TS with the suggested changes to the "
189 "Invalid Information Element", /* 40 */
190 "Group Cipher is not valid", /* 41 */
191 "Pairwise Cipher is not valid", /* 42 */
192 "AKMP is not valid", /* 43 */
193 "Unsupported RSN IE version", /* 44 */
194 "Invalid RSN IE Capabilities", /* 45 */
195 "Cipher suite is rejected per security policy", /* 46 */
196 "The TS has not been created. However, the HC may be capable of "
197 "creating a TS, in response to a request, after the time indicated "
198 "in the TS Delay element", /* 47 */
199 "Direct Link is not allowed in the BSS by policy", /* 48 */
200 "Destination STA is not present within this QBSS.", /* 49 */
201 "The Destination STA is not a QSTA.", /* 50 */
204 #define NUM_STATUSES (sizeof status_text / sizeof status_text[0])
206 static const char *reason_text
[] = {
208 "Unspecified reason", /* 1 */
209 "Previous authentication no longer valid", /* 2 */
210 "Deauthenticated because sending station is leaving (or has left) "
211 "IBSS or ESS", /* 3 */
212 "Disassociated due to inactivity", /* 4 */
213 "Disassociated because AP is unable to handle all currently "
214 " associated stations", /* 5 */
215 "Class 2 frame received from nonauthenticated station", /* 6 */
216 "Class 3 frame received from nonassociated station", /* 7 */
217 "Disassociated because sending station is leaving "
218 "(or has left) BSS", /* 8 */
219 "Station requesting (re)association is not authenticated with "
220 "responding station", /* 9 */
221 "Disassociated because the information in the Power Capability "
222 "element is unacceptable", /* 10 */
223 "Disassociated because the information in the SupportedChannels "
224 "element is unacceptable", /* 11 */
225 "Invalid Information Element", /* 12 */
227 "Michael MIC failure", /* 14 */
228 "4-Way Handshake timeout", /* 15 */
229 "Group key update timeout", /* 16 */
230 "Information element in 4-Way Handshake different from (Re)Association"
231 "Request/Probe Response/Beacon", /* 17 */
232 "Group Cipher is not valid", /* 18 */
233 "AKMP is not valid", /* 20 */
234 "Unsupported RSN IE version", /* 21 */
235 "Invalid RSN IE Capabilities", /* 22 */
236 "IEEE 802.1X Authentication failed", /* 23 */
237 "Cipher suite is rejected per security policy", /* 24 */
244 "TS deleted because QoS AP lacks sufficient bandwidth for this "
245 "QoS STA due to a change in BSS service characteristics or "
246 "operational mode (e.g. an HT BSS change from 40 MHz channel "
247 "to 20 MHz channel)", /* 31 */
248 "Disassociated for unspecified, QoS-related reason", /* 32 */
249 "Disassociated because QoS AP lacks sufficient bandwidth for this "
251 "Disassociated because of excessive number of frames that need to be "
252 "acknowledged, but are not acknowledged for AP transmissions "
253 "and/or poor channel conditions", /* 34 */
254 "Disassociated because STA is transmitting outside the limits "
255 "of its TXOPs", /* 35 */
256 "Requested from peer STA as the STA is leaving the BSS "
257 "(or resetting)", /* 36 */
258 "Requested from peer STA as it does not want to use the "
259 "mechanism", /* 37 */
260 "Requested from peer STA as the STA received frames using the "
261 "mechanism for which a set up is required", /* 38 */
262 "Requested from peer STA due to time out", /* 39 */
268 "Peer STA does not support the requested cipher suite", /* 45 */
269 "Association denied due to requesting STA not supporting HT "
272 #define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
275 wep_print(const u_char
*p
)
279 if (!TTEST2(*p
, IEEE802_11_IV_LEN
+ IEEE802_11_KID_LEN
))
281 iv
= EXTRACT_LE_32BITS(p
);
283 printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv
), IV_PAD(iv
),
290 parse_elements(struct mgmt_body_t
*pbody
, const u_char
*p
, int offset
)
293 * We haven't seen any elements yet.
295 pbody
->challenge_status
= NOT_PRESENT
;
296 pbody
->ssid_status
= NOT_PRESENT
;
297 pbody
->rates_status
= NOT_PRESENT
;
298 pbody
->ds_status
= NOT_PRESENT
;
299 pbody
->cf_status
= NOT_PRESENT
;
300 pbody
->tim_status
= NOT_PRESENT
;
303 if (!TTEST2(*(p
+ offset
), 1))
305 switch (*(p
+ offset
)) {
307 /* Present, possibly truncated */
308 pbody
->ssid_status
= TRUNCATED
;
309 if (!TTEST2(*(p
+ offset
), 2))
311 memcpy(&pbody
->ssid
, p
+ offset
, 2);
313 if (pbody
->ssid
.length
!= 0) {
314 if (pbody
->ssid
.length
>
315 sizeof(pbody
->ssid
.ssid
) - 1)
317 if (!TTEST2(*(p
+ offset
), pbody
->ssid
.length
))
319 memcpy(&pbody
->ssid
.ssid
, p
+ offset
,
321 offset
+= pbody
->ssid
.length
;
323 pbody
->ssid
.ssid
[pbody
->ssid
.length
] = '\0';
324 /* Present and not truncated */
325 pbody
->ssid_status
= PRESENT
;
328 /* Present, possibly truncated */
329 pbody
->challenge_status
= TRUNCATED
;
330 if (!TTEST2(*(p
+ offset
), 2))
332 memcpy(&pbody
->challenge
, p
+ offset
, 2);
334 if (pbody
->challenge
.length
!= 0) {
335 if (pbody
->challenge
.length
>
336 sizeof(pbody
->challenge
.text
) - 1)
338 if (!TTEST2(*(p
+ offset
), pbody
->challenge
.length
))
340 memcpy(&pbody
->challenge
.text
, p
+ offset
,
341 pbody
->challenge
.length
);
342 offset
+= pbody
->challenge
.length
;
344 pbody
->challenge
.text
[pbody
->challenge
.length
] = '\0';
345 /* Present and not truncated */
346 pbody
->challenge_status
= PRESENT
;
349 /* Present, possibly truncated */
350 pbody
->rates_status
= TRUNCATED
;
351 if (!TTEST2(*(p
+ offset
), 2))
353 memcpy(&(pbody
->rates
), p
+ offset
, 2);
355 if (pbody
->rates
.length
!= 0) {
356 if (pbody
->rates
.length
> sizeof pbody
->rates
.rate
)
358 if (!TTEST2(*(p
+ offset
), pbody
->rates
.length
))
360 memcpy(&pbody
->rates
.rate
, p
+ offset
,
361 pbody
->rates
.length
);
362 offset
+= pbody
->rates
.length
;
364 /* Present and not truncated */
365 pbody
->rates_status
= PRESENT
;
368 /* Present, possibly truncated */
369 pbody
->ds_status
= TRUNCATED
;
370 if (!TTEST2(*(p
+ offset
), 3))
372 memcpy(&pbody
->ds
, p
+ offset
, 3);
374 /* Present and not truncated */
375 pbody
->ds_status
= PRESENT
;
378 /* Present, possibly truncated */
379 pbody
->cf_status
= TRUNCATED
;
380 if (!TTEST2(*(p
+ offset
), 8))
382 memcpy(&pbody
->cf
, p
+ offset
, 8);
384 /* Present and not truncated */
385 pbody
->cf_status
= PRESENT
;
388 /* Present, possibly truncated */
389 pbody
->tim_status
= TRUNCATED
;
390 if (!TTEST2(*(p
+ offset
), 2))
392 memcpy(&pbody
->tim
, p
+ offset
, 2);
394 if (!TTEST2(*(p
+ offset
), 3))
396 memcpy(&pbody
->tim
.count
, p
+ offset
, 3);
399 if (pbody
->tim
.length
<= 3)
401 if (pbody
->tim
.length
- 3 > (int)sizeof pbody
->tim
.bitmap
)
403 if (!TTEST2(*(p
+ offset
), pbody
->tim
.length
- 3))
405 memcpy(pbody
->tim
.bitmap
, p
+ (pbody
->tim
.length
- 3),
406 (pbody
->tim
.length
- 3));
407 offset
+= pbody
->tim
.length
- 3;
408 /* Present and not truncated */
409 pbody
->tim_status
= PRESENT
;
413 printf("(1) unhandled element_id (%d) ",
416 if (!TTEST2(*(p
+ offset
), 2))
418 if (!TTEST2(*(p
+ offset
+ 2), *(p
+ offset
+ 1)))
420 offset
+= *(p
+ offset
+ 1) + 2;
426 /*********************************************************************************
427 * Print Handle functions for the management frame types
428 *********************************************************************************/
431 handle_beacon(const u_char
*p
)
433 struct mgmt_body_t pbody
;
436 memset(&pbody
, 0, sizeof(pbody
));
438 if (!TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
439 IEEE802_11_CAPINFO_LEN
))
441 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
442 offset
+= IEEE802_11_TSTAMP_LEN
;
443 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
444 offset
+= IEEE802_11_BCNINT_LEN
;
445 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
446 offset
+= IEEE802_11_CAPINFO_LEN
;
448 parse_elements(&pbody
, p
, offset
);
453 CAPABILITY_ESS(pbody
.capability_info
) ? "ESS" : "IBSS");
454 PRINT_DS_CHANNEL(pbody
);
460 handle_assoc_request(const u_char
*p
)
462 struct mgmt_body_t pbody
;
465 memset(&pbody
, 0, sizeof(pbody
));
467 if (!TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
))
469 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
470 offset
+= IEEE802_11_CAPINFO_LEN
;
471 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
472 offset
+= IEEE802_11_LISTENINT_LEN
;
474 parse_elements(&pbody
, p
, offset
);
482 handle_assoc_response(const u_char
*p
)
484 struct mgmt_body_t pbody
;
487 memset(&pbody
, 0, sizeof(pbody
));
489 if (!TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_STATUS_LEN
+
492 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
493 offset
+= IEEE802_11_CAPINFO_LEN
;
494 pbody
.status_code
= EXTRACT_LE_16BITS(p
+offset
);
495 offset
+= IEEE802_11_STATUS_LEN
;
496 pbody
.aid
= EXTRACT_LE_16BITS(p
+offset
);
497 offset
+= IEEE802_11_AID_LEN
;
499 parse_elements(&pbody
, p
, offset
);
501 printf(" AID(%x) :%s: %s", ((u_int16_t
)(pbody
.aid
<< 2 )) >> 2 ,
502 CAPABILITY_PRIVACY(pbody
.capability_info
) ? " PRIVACY " : "",
503 (pbody
.status_code
< NUM_STATUSES
504 ? status_text
[pbody
.status_code
]
511 handle_reassoc_request(const u_char
*p
)
513 struct mgmt_body_t pbody
;
516 memset(&pbody
, 0, sizeof(pbody
));
518 if (!TTEST2(*p
, IEEE802_11_CAPINFO_LEN
+ IEEE802_11_LISTENINT_LEN
+
521 pbody
.capability_info
= EXTRACT_LE_16BITS(p
);
522 offset
+= IEEE802_11_CAPINFO_LEN
;
523 pbody
.listen_interval
= EXTRACT_LE_16BITS(p
+offset
);
524 offset
+= IEEE802_11_LISTENINT_LEN
;
525 memcpy(&pbody
.ap
, p
+offset
, IEEE802_11_AP_LEN
);
526 offset
+= IEEE802_11_AP_LEN
;
528 parse_elements(&pbody
, p
, offset
);
531 printf(" AP : %s", etheraddr_string( pbody
.ap
));
537 handle_reassoc_response(const u_char
*p
)
539 /* Same as a Association Reponse */
540 return handle_assoc_response(p
);
544 handle_probe_request(const u_char
*p
)
546 struct mgmt_body_t pbody
;
549 memset(&pbody
, 0, sizeof(pbody
));
551 parse_elements(&pbody
, p
, offset
);
560 handle_probe_response(const u_char
*p
)
562 struct mgmt_body_t pbody
;
565 memset(&pbody
, 0, sizeof(pbody
));
567 if (!TTEST2(*p
, IEEE802_11_TSTAMP_LEN
+ IEEE802_11_BCNINT_LEN
+
568 IEEE802_11_CAPINFO_LEN
))
571 memcpy(&pbody
.timestamp
, p
, IEEE802_11_TSTAMP_LEN
);
572 offset
+= IEEE802_11_TSTAMP_LEN
;
573 pbody
.beacon_interval
= EXTRACT_LE_16BITS(p
+offset
);
574 offset
+= IEEE802_11_BCNINT_LEN
;
575 pbody
.capability_info
= EXTRACT_LE_16BITS(p
+offset
);
576 offset
+= IEEE802_11_CAPINFO_LEN
;
578 parse_elements(&pbody
, p
, offset
);
582 PRINT_DS_CHANNEL(pbody
);
590 /* the frame body for ATIM is null. */
595 handle_disassoc(const u_char
*p
)
597 struct mgmt_body_t pbody
;
599 memset(&pbody
, 0, sizeof(pbody
));
601 if (!TTEST2(*p
, IEEE802_11_REASON_LEN
))
603 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
606 (pbody
.reason_code
< NUM_REASONS
)
607 ? reason_text
[pbody
.reason_code
]
614 handle_auth(const u_char
*p
)
616 struct mgmt_body_t pbody
;
619 memset(&pbody
, 0, sizeof(pbody
));
623 pbody
.auth_alg
= EXTRACT_LE_16BITS(p
);
625 pbody
.auth_trans_seq_num
= EXTRACT_LE_16BITS(p
+ offset
);
627 pbody
.status_code
= EXTRACT_LE_16BITS(p
+ offset
);
630 parse_elements(&pbody
, p
, offset
);
632 if ((pbody
.auth_alg
== 1) &&
633 ((pbody
.auth_trans_seq_num
== 2) ||
634 (pbody
.auth_trans_seq_num
== 3))) {
635 printf(" (%s)-%x [Challenge Text] %s",
636 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
637 ? auth_alg_text
[pbody
.auth_alg
]
639 pbody
.auth_trans_seq_num
,
640 ((pbody
.auth_trans_seq_num
% 2)
641 ? ((pbody
.status_code
< NUM_STATUSES
)
642 ? status_text
[pbody
.status_code
]
646 printf(" (%s)-%x: %s",
647 (pbody
.auth_alg
< NUM_AUTH_ALGS
)
648 ? auth_alg_text
[pbody
.auth_alg
]
650 pbody
.auth_trans_seq_num
,
651 (pbody
.auth_trans_seq_num
% 2)
652 ? ((pbody
.status_code
< NUM_STATUSES
)
653 ? status_text
[pbody
.status_code
]
661 handle_deauth(const struct mgmt_header_t
*pmh
, const u_char
*p
)
663 struct mgmt_body_t pbody
;
665 const char *reason
= NULL
;
667 memset(&pbody
, 0, sizeof(pbody
));
669 if (!TTEST2(*p
, IEEE802_11_REASON_LEN
))
671 pbody
.reason_code
= EXTRACT_LE_16BITS(p
);
672 offset
+= IEEE802_11_REASON_LEN
;
674 reason
= (pbody
.reason_code
< NUM_REASONS
)
675 ? reason_text
[pbody
.reason_code
]
679 printf(": %s", reason
);
681 printf(" (%s): %s", etheraddr_string(pmh
->sa
), reason
);
686 #define PRINT_HT_ACTION(v) (\
687 (v) == 0 ? printf("TxChWidth") : \
688 (v) == 1 ? printf("MIMOPwrSave") : \
689 printf("Act#%d", (v)) \
691 #define PRINT_BA_ACTION(v) (\
692 (v) == 0 ? printf("ADDBA Request") : \
693 (v) == 1 ? printf("ADDBA Response") : \
694 (v) == 2 ? printf("DELBA") : \
695 printf("Act#%d", (v)) \
697 #define PRINT_MESHLINK_ACTION(v) (\
698 (v) == 0 ? printf("Request") : \
699 (v) == 1 ? printf("Report") : \
700 printf("Act#%d", (v)) \
702 #define PRINT_MESHPEERING_ACTION(v) (\
703 (v) == 0 ? printf("Open") : \
704 (v) == 1 ? printf("Confirm") : \
705 (v) == 2 ? printf("Close") : \
706 printf("Act#%d", (v)) \
708 #define PRINT_MESHPATH_ACTION(v) (\
709 (v) == 0 ? printf("Request") : \
710 (v) == 1 ? printf("Report") : \
711 (v) == 2 ? printf("Error") : \
712 (v) == 3 ? printf("RootAnnouncement") : \
713 printf("Act#%d", (v)) \
717 handle_action(const struct mgmt_header_t
*pmh
, const u_char
*p
)
724 printf(" (%s): ", etheraddr_string(pmh
->sa
));
727 case 0: printf("Spectrum Management Act#%d", p
[1]); break;
728 case 1: printf("QoS Act#%d", p
[1]); break;
729 case 2: printf("DLS Act#%d", p
[1]); break;
730 case 3: printf("BA "); PRINT_BA_ACTION(p
[1]); break;
731 case 7: printf("HT "); PRINT_HT_ACTION(p
[1]); break;
732 case 13: printf("MeshLMetric "); PRINT_MESHLINK_ACTION(p
[1]); break;
733 case 15: printf("Interwork Act#%d", p
[1]); break;
734 case 16: printf("Resource Act#%d", p
[1]); break;
735 case 17: printf("Proxy Act#%d", p
[1]); break;
736 case 30: printf("MeshPeering "); PRINT_MESHPEERING_ACTION(p
[1]); break;
737 case 32: printf("MeshPath "); PRINT_MESHPATH_ACTION(p
[1]); break;
738 case 127: printf("Vendor Act#%d", p
[1]); break;
740 printf("Reserved(%d) Act#%d", p
[0], p
[1]);
747 /*********************************************************************************
749 *********************************************************************************/
753 mgmt_body_print(u_int16_t fc
, const struct mgmt_header_t
*pmh
,
756 switch (FC_SUBTYPE(fc
)) {
757 case ST_ASSOC_REQUEST
:
758 printf("Assoc Request");
759 return handle_assoc_request(p
);
760 case ST_ASSOC_RESPONSE
:
761 printf("Assoc Response");
762 return handle_assoc_response(p
);
763 case ST_REASSOC_REQUEST
:
764 printf("ReAssoc Request");
765 return handle_reassoc_request(p
);
766 case ST_REASSOC_RESPONSE
:
767 printf("ReAssoc Response");
768 return handle_reassoc_response(p
);
769 case ST_PROBE_REQUEST
:
770 printf("Probe Request");
771 return handle_probe_request(p
);
772 case ST_PROBE_RESPONSE
:
773 printf("Probe Response");
774 return handle_probe_response(p
);
777 return handle_beacon(p
);
780 return handle_atim();
782 printf("Disassociation");
783 return handle_disassoc(p
);
785 printf("Authentication");
788 if ((p
[0] == 0 ) && (p
[1] == 0) && (p
[2] == 0)) {
789 printf("Authentication (Shared-Key)-3 ");
792 return handle_auth(p
);
794 printf("DeAuthentication");
795 return handle_deauth(pmh
, p
);
799 return handle_action(pmh
, p
);
802 printf("Unhandled Management subtype(%x)",
809 /*********************************************************************************
810 * Handles printing all the control frame types
811 *********************************************************************************/
814 ctrl_body_print(u_int16_t fc
, const u_char
*p
)
816 switch (FC_SUBTYPE(fc
)) {
817 case CTRL_CONTROL_WRAPPER
:
818 printf("Control Wrapper");
819 /* XXX - requires special handling */
823 if (!TTEST2(*p
, CTRL_BAR_HDRLEN
))
826 printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
827 etheraddr_string(((const struct ctrl_bar_t
*)p
)->ra
),
828 etheraddr_string(((const struct ctrl_bar_t
*)p
)->ta
),
829 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->ctl
)),
830 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->seq
)));
834 if (!TTEST2(*p
, CTRL_BA_HDRLEN
))
838 etheraddr_string(((const struct ctrl_ba_t
*)p
)->ra
));
841 printf("Power Save-Poll");
842 if (!TTEST2(*p
, CTRL_PS_POLL_HDRLEN
))
845 EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t
*)p
)->aid
)));
848 printf("Request-To-Send");
849 if (!TTEST2(*p
, CTRL_RTS_HDRLEN
))
853 etheraddr_string(((const struct ctrl_rts_t
*)p
)->ta
));
856 printf("Clear-To-Send");
857 if (!TTEST2(*p
, CTRL_CTS_HDRLEN
))
861 etheraddr_string(((const struct ctrl_cts_t
*)p
)->ra
));
864 printf("Acknowledgment");
865 if (!TTEST2(*p
, CTRL_ACK_HDRLEN
))
869 etheraddr_string(((const struct ctrl_ack_t
*)p
)->ra
));
873 if (!TTEST2(*p
, CTRL_END_HDRLEN
))
877 etheraddr_string(((const struct ctrl_end_t
*)p
)->ra
));
880 printf("CF-End+CF-Ack");
881 if (!TTEST2(*p
, CTRL_END_ACK_HDRLEN
))
885 etheraddr_string(((const struct ctrl_end_ack_t
*)p
)->ra
));
888 printf("Unknown Ctrl Subtype");
898 * Data Frame - Address field contents
900 * To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
901 * 0 | 0 | DA | SA | BSSID | n/a
902 * 0 | 1 | DA | BSSID | SA | n/a
903 * 1 | 0 | BSSID | SA | DA | n/a
904 * 1 | 1 | RA | TA | DA | SA
908 data_header_print(u_int16_t fc
, const u_char
*p
, const u_int8_t
**srcp
,
909 const u_int8_t
**dstp
)
911 u_int subtype
= FC_SUBTYPE(fc
);
913 if (DATA_FRAME_IS_CF_ACK(subtype
) || DATA_FRAME_IS_CF_POLL(subtype
) ||
914 DATA_FRAME_IS_QOS(subtype
)) {
916 if (DATA_FRAME_IS_CF_ACK(subtype
)) {
917 if (DATA_FRAME_IS_CF_POLL(subtype
))
922 if (DATA_FRAME_IS_CF_POLL(subtype
))
925 if (DATA_FRAME_IS_QOS(subtype
))
930 #define ADDR1 (p + 4)
931 #define ADDR2 (p + 10)
932 #define ADDR3 (p + 16)
933 #define ADDR4 (p + 24)
935 if (!FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
942 printf("DA:%s SA:%s BSSID:%s ",
943 etheraddr_string(ADDR1
), etheraddr_string(ADDR2
),
944 etheraddr_string(ADDR3
));
945 } else if (!FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
952 printf("DA:%s BSSID:%s SA:%s ",
953 etheraddr_string(ADDR1
), etheraddr_string(ADDR2
),
954 etheraddr_string(ADDR3
));
955 } else if (FC_TO_DS(fc
) && !FC_FROM_DS(fc
)) {
962 printf("BSSID:%s SA:%s DA:%s ",
963 etheraddr_string(ADDR1
), etheraddr_string(ADDR2
),
964 etheraddr_string(ADDR3
));
965 } else if (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) {
972 printf("RA:%s TA:%s DA:%s SA:%s ",
973 etheraddr_string(ADDR1
), etheraddr_string(ADDR2
),
974 etheraddr_string(ADDR3
), etheraddr_string(ADDR4
));
984 mgmt_header_print(const u_char
*p
, const u_int8_t
**srcp
,
985 const u_int8_t
**dstp
)
987 const struct mgmt_header_t
*hp
= (const struct mgmt_header_t
*) p
;
996 printf("BSSID:%s DA:%s SA:%s ",
997 etheraddr_string((hp
)->bssid
), etheraddr_string((hp
)->da
),
998 etheraddr_string((hp
)->sa
));
1002 ctrl_header_print(u_int16_t fc
, const u_char
*p
, const u_int8_t
**srcp
,
1003 const u_int8_t
**dstp
)
1012 switch (FC_SUBTYPE(fc
)) {
1014 printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
1015 etheraddr_string(((const struct ctrl_bar_t
*)p
)->ra
),
1016 etheraddr_string(((const struct ctrl_bar_t
*)p
)->ta
),
1017 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->ctl
)),
1018 EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t
*)p
)->seq
)));
1022 etheraddr_string(((const struct ctrl_ba_t
*)p
)->ra
));
1025 printf("BSSID:%s TA:%s ",
1026 etheraddr_string(((const struct ctrl_ps_poll_t
*)p
)->bssid
),
1027 etheraddr_string(((const struct ctrl_ps_poll_t
*)p
)->ta
));
1030 printf("RA:%s TA:%s ",
1031 etheraddr_string(((const struct ctrl_rts_t
*)p
)->ra
),
1032 etheraddr_string(((const struct ctrl_rts_t
*)p
)->ta
));
1036 etheraddr_string(((const struct ctrl_cts_t
*)p
)->ra
));
1040 etheraddr_string(((const struct ctrl_ack_t
*)p
)->ra
));
1043 printf("RA:%s BSSID:%s ",
1044 etheraddr_string(((const struct ctrl_end_t
*)p
)->ra
),
1045 etheraddr_string(((const struct ctrl_end_t
*)p
)->bssid
));
1048 printf("RA:%s BSSID:%s ",
1049 etheraddr_string(((const struct ctrl_end_ack_t
*)p
)->ra
),
1050 etheraddr_string(((const struct ctrl_end_ack_t
*)p
)->bssid
));
1053 printf("(H) Unknown Ctrl Subtype");
1059 extract_header_length(u_int16_t fc
)
1063 switch (FC_TYPE(fc
)) {
1067 switch (FC_SUBTYPE(fc
)) {
1069 return CTRL_BAR_HDRLEN
;
1071 return CTRL_PS_POLL_HDRLEN
;
1073 return CTRL_RTS_HDRLEN
;
1075 return CTRL_CTS_HDRLEN
;
1077 return CTRL_ACK_HDRLEN
;
1079 return CTRL_END_HDRLEN
;
1081 return CTRL_END_ACK_HDRLEN
;
1086 len
= (FC_TO_DS(fc
) && FC_FROM_DS(fc
)) ? 30 : 24;
1087 if (DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
)))
1091 printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc
));
1097 extract_mesh_header_length(const u_char
*p
)
1099 return (p
[0] &~ 3) ? 0 : 6*(1 + (p
[0] & 3));
1103 * Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
1104 * to point to the source and destination MAC addresses in any case if
1105 * "srcp" and "dstp" aren't null.
1108 ieee_802_11_hdr_print(u_int16_t fc
, const u_char
*p
, u_int hdrlen
,
1109 u_int meshdrlen
, const u_int8_t
**srcp
, const u_int8_t
**dstp
)
1112 if (FC_MORE_DATA(fc
))
1113 printf("More Data ");
1114 if (FC_MORE_FLAG(fc
))
1115 printf("More Fragments ");
1116 if (FC_POWER_MGMT(fc
))
1117 printf("Pwr Mgmt ");
1121 printf("Strictly Ordered ");
1123 printf("WEP Encrypted ");
1124 if (FC_TYPE(fc
) != T_CTRL
|| FC_SUBTYPE(fc
) != CTRL_PS_POLL
)
1127 &((const struct mgmt_header_t
*)p
)->duration
));
1129 if (meshdrlen
!= 0) {
1130 const struct meshcntl_t
*mc
=
1131 (const struct meshcntl_t
*)&p
[hdrlen
- meshdrlen
];
1132 int ae
= mc
->flags
& 3;
1134 printf("MeshData (AE %d TTL %u seq %u", ae
, mc
->ttl
,
1135 EXTRACT_LE_32BITS(mc
->seq
));
1137 printf(" A4:%s", etheraddr_string(mc
->addr4
));
1139 printf(" A5:%s", etheraddr_string(mc
->addr5
));
1141 printf(" A6:%s", etheraddr_string(mc
->addr6
));
1145 switch (FC_TYPE(fc
)) {
1147 mgmt_header_print(p
, srcp
, dstp
);
1150 ctrl_header_print(fc
, p
, srcp
, dstp
);
1153 data_header_print(fc
, p
, srcp
, dstp
);
1156 printf("(header) unknown IEEE802.11 frame type (%d)",
1165 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
1169 ieee802_11_print(const u_char
*p
, u_int length
, u_int orig_caplen
, int pad
,
1173 u_int caplen
, hdrlen
, meshdrlen
;
1174 const u_int8_t
*src
, *dst
;
1175 u_short extracted_ethertype
;
1177 caplen
= orig_caplen
;
1178 /* Remove FCS, if present */
1179 if (length
< fcslen
) {
1180 printf("[|802.11]");
1184 if (caplen
> length
) {
1185 /* Amount of FCS in actual packet data, if any */
1186 fcslen
= caplen
- length
;
1191 if (caplen
< IEEE802_11_FC_LEN
) {
1192 printf("[|802.11]");
1196 fc
= EXTRACT_LE_16BITS(p
);
1197 hdrlen
= extract_header_length(fc
);
1199 hdrlen
= roundup2(hdrlen
, 4);
1200 if (FC_TYPE(fc
) == T_DATA
&& DATA_FRAME_IS_QOS(FC_SUBTYPE(fc
))) {
1201 meshdrlen
= extract_mesh_header_length(p
+hdrlen
);
1202 hdrlen
+= meshdrlen
;
1207 if (caplen
< hdrlen
) {
1208 printf("[|802.11]");
1212 ieee_802_11_hdr_print(fc
, p
, hdrlen
, meshdrlen
, &src
, &dst
);
1215 * Go past the 802.11 header.
1221 switch (FC_TYPE(fc
)) {
1223 if (!mgmt_body_print(fc
,
1224 (const struct mgmt_header_t
*)(p
- hdrlen
), p
)) {
1225 printf("[|802.11]");
1230 if (!ctrl_body_print(fc
, p
- hdrlen
)) {
1231 printf("[|802.11]");
1236 if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc
)))
1237 return hdrlen
; /* no-data frame */
1238 /* There may be a problem w/ AP not having this bit set */
1240 if (!wep_print(p
)) {
1241 printf("[|802.11]");
1244 } else if (llc_print(p
, length
, caplen
, dst
, src
,
1245 &extracted_ethertype
) == 0) {
1247 * Some kinds of LLC packet we cannot
1248 * handle intelligently
1251 ieee_802_11_hdr_print(fc
, p
- hdrlen
, hdrlen
,
1252 meshdrlen
, NULL
, NULL
);
1253 if (extracted_ethertype
)
1256 htons(extracted_ethertype
)));
1257 if (!suppress_default_print
)
1258 default_print(p
, caplen
);
1262 printf("unknown 802.11 frame type (%d)", FC_TYPE(fc
));
1270 * This is the top level routine of the printer. 'p' points
1271 * to the 802.11 header of the packet, 'h->ts' is the timestamp,
1272 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
1273 * is the number of bytes actually captured.
1276 ieee802_11_if_print(const struct pcap_pkthdr
*h
, const u_char
*p
)
1278 return ieee802_11_print(p
, h
->len
, h
->caplen
, 0, 0);
1281 #define IEEE80211_CHAN_FHSS \
1282 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
1283 #define IEEE80211_CHAN_A \
1284 (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
1285 #define IEEE80211_CHAN_B \
1286 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
1287 #define IEEE80211_CHAN_PUREG \
1288 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_OFDM)
1289 #define IEEE80211_CHAN_G \
1290 (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
1292 #define IS_CHAN_FHSS(flags) \
1293 ((flags & IEEE80211_CHAN_FHSS) == IEEE80211_CHAN_FHSS)
1294 #define IS_CHAN_A(flags) \
1295 ((flags & IEEE80211_CHAN_A) == IEEE80211_CHAN_A)
1296 #define IS_CHAN_B(flags) \
1297 ((flags & IEEE80211_CHAN_B) == IEEE80211_CHAN_B)
1298 #define IS_CHAN_PUREG(flags) \
1299 ((flags & IEEE80211_CHAN_PUREG) == IEEE80211_CHAN_PUREG)
1300 #define IS_CHAN_G(flags) \
1301 ((flags & IEEE80211_CHAN_G) == IEEE80211_CHAN_G)
1302 #define IS_CHAN_ANYG(flags) \
1303 (IS_CHAN_PUREG(flags) || IS_CHAN_G(flags))
1306 print_chaninfo(int freq
, int flags
)
1308 printf("%u MHz", freq
);
1309 if (IS_CHAN_FHSS(flags
))
1311 if (IS_CHAN_A(flags
)) {
1312 if (flags
& IEEE80211_CHAN_HALF
)
1313 printf(" 11a/10Mhz");
1314 else if (flags
& IEEE80211_CHAN_QUARTER
)
1315 printf(" 11a/5Mhz");
1319 if (IS_CHAN_ANYG(flags
)) {
1320 if (flags
& IEEE80211_CHAN_HALF
)
1321 printf(" 11g/10Mhz");
1322 else if (flags
& IEEE80211_CHAN_QUARTER
)
1323 printf(" 11g/5Mhz");
1326 } else if (IS_CHAN_B(flags
))
1328 if (flags
& IEEE80211_CHAN_TURBO
)
1330 if (flags
& IEEE80211_CHAN_HT20
)
1332 else if (flags
& IEEE80211_CHAN_HT40D
)
1334 else if (flags
& IEEE80211_CHAN_HT40U
)
1340 print_radiotap_field(struct cpack_state
*s
, u_int32_t bit
, u_int8_t
*flags
)
1353 case IEEE80211_RADIOTAP_FLAGS
:
1354 rc
= cpack_uint8(s
, &u
.u8
);
1357 case IEEE80211_RADIOTAP_RATE
:
1358 case IEEE80211_RADIOTAP_DB_ANTSIGNAL
:
1359 case IEEE80211_RADIOTAP_DB_ANTNOISE
:
1360 case IEEE80211_RADIOTAP_ANTENNA
:
1361 rc
= cpack_uint8(s
, &u
.u8
);
1363 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL
:
1364 case IEEE80211_RADIOTAP_DBM_ANTNOISE
:
1365 rc
= cpack_int8(s
, &u
.i8
);
1367 case IEEE80211_RADIOTAP_CHANNEL
:
1368 rc
= cpack_uint16(s
, &u
.u16
);
1371 rc
= cpack_uint16(s
, &u2
.u16
);
1373 case IEEE80211_RADIOTAP_FHSS
:
1374 case IEEE80211_RADIOTAP_LOCK_QUALITY
:
1375 case IEEE80211_RADIOTAP_TX_ATTENUATION
:
1376 rc
= cpack_uint16(s
, &u
.u16
);
1378 case IEEE80211_RADIOTAP_DB_TX_ATTENUATION
:
1379 rc
= cpack_uint8(s
, &u
.u8
);
1381 case IEEE80211_RADIOTAP_DBM_TX_POWER
:
1382 rc
= cpack_int8(s
, &u
.i8
);
1384 case IEEE80211_RADIOTAP_TSFT
:
1385 rc
= cpack_uint64(s
, &u
.u64
);
1387 case IEEE80211_RADIOTAP_XCHANNEL
:
1388 rc
= cpack_uint32(s
, &u
.u32
);
1391 rc
= cpack_uint16(s
, &u2
.u16
);
1394 rc
= cpack_uint8(s
, &u3
.u8
);
1397 rc
= cpack_uint8(s
, &u4
.u8
);
1400 /* this bit indicates a field whose
1401 * size we do not know, so we cannot
1404 printf("[0x%08x] ", bit
);
1409 printf("[|802.11]");
1414 case IEEE80211_RADIOTAP_CHANNEL
:
1415 print_chaninfo(u
.u16
, u2
.u16
);
1417 case IEEE80211_RADIOTAP_FHSS
:
1418 printf("fhset %d fhpat %d ", u
.u16
& 0xff, (u
.u16
>> 8) & 0xff);
1420 case IEEE80211_RADIOTAP_RATE
:
1422 PRINT_HT_RATE("", u
.u8
, " Mb/s ");
1424 PRINT_RATE("", u
.u8
, " Mb/s ");
1426 case IEEE80211_RADIOTAP_DBM_ANTSIGNAL
:
1427 printf("%ddB signal ", u
.i8
);
1429 case IEEE80211_RADIOTAP_DBM_ANTNOISE
:
1430 printf("%ddB noise ", u
.i8
);
1432 case IEEE80211_RADIOTAP_DB_ANTSIGNAL
:
1433 printf("%ddB signal ", u
.u8
);
1435 case IEEE80211_RADIOTAP_DB_ANTNOISE
:
1436 printf("%ddB noise ", u
.u8
);
1438 case IEEE80211_RADIOTAP_LOCK_QUALITY
:
1439 printf("%u sq ", u
.u16
);
1441 case IEEE80211_RADIOTAP_TX_ATTENUATION
:
1442 printf("%d tx power ", -(int)u
.u16
);
1444 case IEEE80211_RADIOTAP_DB_TX_ATTENUATION
:
1445 printf("%ddB tx power ", -(int)u
.u8
);
1447 case IEEE80211_RADIOTAP_DBM_TX_POWER
:
1448 printf("%ddBm tx power ", u
.i8
);
1450 case IEEE80211_RADIOTAP_FLAGS
:
1451 if (u
.u8
& IEEE80211_RADIOTAP_F_CFP
)
1453 if (u
.u8
& IEEE80211_RADIOTAP_F_SHORTPRE
)
1454 printf("short preamble ");
1455 if (u
.u8
& IEEE80211_RADIOTAP_F_WEP
)
1457 if (u
.u8
& IEEE80211_RADIOTAP_F_FRAG
)
1458 printf("fragmented ");
1459 if (u
.u8
& IEEE80211_RADIOTAP_F_BADFCS
)
1462 case IEEE80211_RADIOTAP_ANTENNA
:
1463 printf("antenna %d ", u
.u8
);
1465 case IEEE80211_RADIOTAP_TSFT
:
1466 printf("%" PRIu64
"us tsft ", u
.u64
);
1468 case IEEE80211_RADIOTAP_XCHANNEL
:
1469 print_chaninfo(u2
.u16
, u
.u32
);
1476 ieee802_11_radio_print(const u_char
*p
, u_int length
, u_int caplen
)
1478 #define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
1479 #define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
1480 #define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
1481 #define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
1482 #define BITNO_2(x) (((x) & 2) ? 1 : 0)
1483 #define BIT(n) (1U << n)
1484 #define IS_EXTENDED(__p) \
1485 (EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0
1487 struct cpack_state cpacker
;
1488 struct ieee80211_radiotap_header
*hdr
;
1489 u_int32_t present
, next_present
;
1490 u_int32_t
*presentp
, *last_presentp
;
1491 enum ieee80211_radiotap_type bit
;
1499 if (caplen
< sizeof(*hdr
)) {
1500 printf("[|802.11]");
1504 hdr
= (struct ieee80211_radiotap_header
*)p
;
1506 len
= EXTRACT_LE_16BITS(&hdr
->it_len
);
1509 printf("[|802.11]");
1512 for (last_presentp
= &hdr
->it_present
;
1513 IS_EXTENDED(last_presentp
) &&
1514 (u_char
*)(last_presentp
+ 1) <= p
+ len
;
1517 /* are there more bitmap extensions than bytes in header? */
1518 if (IS_EXTENDED(last_presentp
)) {
1519 printf("[|802.11]");
1523 iter
= (u_char
*)(last_presentp
+ 1);
1525 if (cpack_init(&cpacker
, (u_int8_t
*)iter
, len
- (iter
- p
)) != 0) {
1527 printf("[|802.11]");
1531 /* Assume no flags */
1533 /* Assume no Atheros padding between 802.11 header and body */
1535 /* Assume no FCS at end of frame */
1537 for (bit0
= 0, presentp
= &hdr
->it_present
; presentp
<= last_presentp
;
1538 presentp
++, bit0
+= 32) {
1539 for (present
= EXTRACT_LE_32BITS(presentp
); present
;
1540 present
= next_present
) {
1541 /* clear the least significant bit that is set */
1542 next_present
= present
& (present
- 1);
1544 /* extract the least significant bit that is set */
1545 bit
= (enum ieee80211_radiotap_type
)
1546 (bit0
+ BITNO_32(present
^ next_present
));
1548 if (print_radiotap_field(&cpacker
, bit
, &flags
) != 0)
1553 if (flags
& IEEE80211_RADIOTAP_F_DATAPAD
)
1554 pad
= 1; /* Atheros padding */
1555 if (flags
& IEEE80211_RADIOTAP_F_FCS
)
1556 fcslen
= 4; /* FCS at end of packet */
1558 return len
+ ieee802_11_print(p
+ len
, length
- len
, caplen
- len
, pad
,
1569 ieee802_11_avs_radio_print(const u_char
*p
, u_int length
, u_int caplen
)
1571 u_int32_t caphdr_len
;
1574 printf("[|802.11]");
1578 caphdr_len
= EXTRACT_32BITS(p
+ 4);
1579 if (caphdr_len
< 8) {
1581 * Yow! The capture header length is claimed not
1582 * to be large enough to include even the version
1583 * cookie or capture header length!
1585 printf("[|802.11]");
1589 if (caplen
< caphdr_len
) {
1590 printf("[|802.11]");
1594 return caphdr_len
+ ieee802_11_print(p
+ caphdr_len
,
1595 length
- caphdr_len
, caplen
- caphdr_len
, 0, 0);
1598 #define PRISM_HDR_LEN 144
1600 #define WLANCAP_MAGIC_COOKIE_BASE 0x80211000
1601 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001
1602 #define WLANCAP_MAGIC_COOKIE_V2 0x80211002
1605 * For DLT_PRISM_HEADER; like DLT_IEEE802_11, but with an extra header,
1606 * containing information such as radio information, which we
1609 * If, however, the packet begins with WLANCAP_MAGIC_COOKIE_V1 or
1610 * WLANCAP_MAGIC_COOKIE_V2, it's really DLT_IEEE802_11_RADIO_AVS
1611 * (currently, on Linux, there's no ARPHRD_ type for
1612 * DLT_IEEE802_11_RADIO_AVS, as there is a ARPHRD_IEEE80211_PRISM
1613 * for DLT_PRISM_HEADER, so ARPHRD_IEEE80211_PRISM is used for
1614 * the AVS header, and the first 4 bytes of the header are used to
1615 * indicate whether it's a Prism header or an AVS header).
1618 prism_if_print(const struct pcap_pkthdr
*h
, const u_char
*p
)
1620 u_int caplen
= h
->caplen
;
1621 u_int length
= h
->len
;
1625 printf("[|802.11]");
1629 msgcode
= EXTRACT_32BITS(p
);
1630 if (msgcode
== WLANCAP_MAGIC_COOKIE_V1
||
1631 msgcode
== WLANCAP_MAGIC_COOKIE_V2
)
1632 return ieee802_11_avs_radio_print(p
, length
, caplen
);
1634 if (caplen
< PRISM_HDR_LEN
) {
1635 printf("[|802.11]");
1639 return PRISM_HDR_LEN
+ ieee802_11_print(p
+ PRISM_HDR_LEN
,
1640 length
- PRISM_HDR_LEN
, caplen
- PRISM_HDR_LEN
, 0, 0);
1644 * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra
1645 * header, containing information such as radio information.
1648 ieee802_11_radio_if_print(const struct pcap_pkthdr
*h
, const u_char
*p
)
1650 return ieee802_11_radio_print(p
, h
->len
, h
->caplen
);
1654 * For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an
1655 * extra header, containing information such as radio information,
1656 * which we currently ignore.
1659 ieee802_11_radio_avs_if_print(const struct pcap_pkthdr
*h
, const u_char
*p
)
1661 return ieee802_11_avs_radio_print(p
, h
->len
, h
->caplen
);