2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Daniel Borkmann <borkmann@iogearbox.net>
4 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>, Deutsche Flugsicherung GmbH
5 * Subject to the GPL, version 2.
10 #include <netinet/in.h> /* for ntohs() */
11 #include <asm/byteorder.h>
15 #include "dissector_80211.h"
20 /* Note: Fields are encoded in little-endian! */
21 struct ieee80211_frm_ctrl
{
24 #if defined(__LITTLE_ENDIAN_BITFIELD)
25 /* Correct order here ... */
26 __extension__ u16 proto_version
:2,
37 #elif defined(__BIG_ENDIAN_BITFIELD)
38 __extension__ u16 subtype
:4,
50 # error "Adjust your <asm/byteorder.h> defines"
53 /* TODO: delete if use structs below*/
57 /* Management Frame start */
58 /* Note: Fields are encoded in little-endian! */
59 struct ieee80211_mgmt
{
67 struct ieee80211_mgmt_auth
{
71 /* possibly followed by Challenge text */
75 struct ieee80211_mgmt_deauth
{
79 struct ieee80211_mgmt_assoc_req
{
82 /* followed by SSID and Supported rates */
86 struct ieee80211_mgmt_assoc_resp
{
90 /* followed by Supported rates */
94 struct ieee80211_mgmt_reassoc_resp
{
98 /* followed by Supported rates */
102 struct ieee80211_mgmt_reassoc_req
{
106 /* followed by SSID and Supported rates */
110 struct ieee80211_mgmt_disassoc
{
114 struct ieee80211_mgmt_probe_req
{
117 struct ieee80211_mgmt_beacon
{
121 /* followed by some of SSID, Supported rates,
122 * FH Params, DS Params, CF Params, IBSS Params, TIM */
126 struct ieee80211_mgmt_probe_resp
{
130 /* followed by some of SSID, Supported rates,
131 * FH Params, DS Params, CF Params, IBSS Params, TIM */
134 /* Management Frame end */
136 /* Control Frame start */
137 /* Note: Fields are encoded in little-endian! */
138 struct ieee80211_ctrl
{
141 struct ieee80211_ctrl_rts
{
147 struct ieee80211_ctrl_cts
{
152 struct ieee80211_ctrl_ack
{
157 struct ieee80211_ctrl_ps_poll
{
163 struct ieee80211_ctrl_cf_end
{
169 struct ieee80211_ctrl_cf_end_ack
{
174 /* Control Frame end */
176 /* Data Frame start */
177 /* Note: Fields are encoded in little-endian! */
178 struct ieee80211_data
{
182 /* Control Frame end */
184 static const char *frame_control_types
[] = {
185 "Management", /* 00 */
191 static void ieee80211(struct pkt_buff
*pkt
)
193 struct ieee80211_frm_ctrl
*frm_ctrl
=
194 (struct ieee80211_frm_ctrl
*) pkt_pull(pkt
, sizeof(*frm_ctrl
));
195 if (frm_ctrl
== NULL
)
198 tprintf(" [ 802.11 Frame Control (0x%04x), Duration/ID (%u) ]\n",
199 le16_to_cpu(frm_ctrl
->frame_control
), le16_to_cpu(frm_ctrl
->duration
));
200 tprintf("\t [ Proto Version (%u), ", frm_ctrl
->proto_version
);
201 tprintf("Type (%u, %s), ", frm_ctrl
->type
, frame_control_types
[frm_ctrl
->type
]);
202 tprintf("Subtype (%u)", frm_ctrl
->subtype
/*XXX*/);
204 frm_ctrl
->to_ds
? ", Frame goes to DS" : "",
205 frm_ctrl
->from_ds
? ", Frame comes from DS" : "");
206 tprintf("%s", frm_ctrl
->more_frags
? ", More Fragments" : "");
207 tprintf("%s", frm_ctrl
->retry
? ", Frame is retransmitted" : "");
208 tprintf("%s", frm_ctrl
->power_mgmt
? ", In Power Saving Mode" : "");
209 tprintf("%s", frm_ctrl
->more_data
? ", More Data" : "");
210 tprintf("%s", frm_ctrl
->wep
? ", Needs WEP" : "");
211 tprintf("%s", frm_ctrl
->order
? ", Order" : "");
214 // pkt_set_proto(pkt, &ieee802_lay2, ntohs(eth->h_proto));
217 static void ieee80211_less(struct pkt_buff
*pkt
)
219 tprintf("802.11 frame (more on todo)");
222 struct protocol ieee80211_ops
= {
224 .print_full
= ieee80211
,
225 .print_less
= ieee80211_less
,
228 EXPORT_SYMBOL(ieee80211_ops
);