proto_ipv4: don't trim length of pkt_buff
[netsniff-ng.git] / src / proto_ieee80211.c
blob3adf3f7bb1a0d69154a0a997b9649944f47e37ab
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2012 Daniel Borkmann.
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>
13 #include "proto.h"
14 #include "protos.h"
15 #include "dissector_80211.h"
16 #include "built_in.h"
17 #include "pkt_buff.h"
18 #include "oui.h"
20 /* XXX: clarify which endianess */
22 struct ieee80211hdr {
23 // union {
24 // u16 frame_control;
25 #if defined(__BIG_ENDIAN_BITFIELD)
26 __extension__ u16 subtype:4,
27 type:2,
28 proto_version:2,
29 order:1,
30 wep:1,
31 more_data:1,
32 power_mgmt:1,
33 retry:1,
34 more_frags:1,
35 from_ds:1,
36 to_ds:1;
37 #elif defined(__LITTLE_ENDIAN_BITFIELD)
38 __extension__ u16 proto_version:2,
39 type:2,
40 subtype:4,
41 to_ds:1,
42 from_ds:1,
43 more_frags:1,
44 retry:1,
45 power_mgmt:1,
46 more_data:1,
47 wep:1,
48 order:1;
49 #else
50 # error "Adjust your <asm/byteorder.h> defines"
51 #endif
52 // };
53 u16 duration;
54 } __packed;
56 static void ieee80211(struct pkt_buff *pkt)
58 struct ieee80211hdr *hdr =
59 (struct ieee80211hdr *) pkt_pull(pkt, sizeof(*hdr));
60 if (hdr == NULL)
61 return;
63 tprintf(" [ 802.11 Frame Control (0x%x), Duration/ID (%u) ]\n",
64 0/*ntohs(hdr->frame_control)*/, /*ntohs(*/hdr->duration);
65 tprintf("\t [ Proto Version (%u), ", hdr->proto_version);
66 tprintf("Type (%u), ", hdr->type /*XXX*/);
67 tprintf("Subtype (%u)", hdr->subtype /*XXX*/);
68 tprintf("%s%s",
69 hdr->to_ds ? ", Frame goes to DS" : "",
70 hdr->from_ds ? ", Frame comes from DS" : "");
71 tprintf("%s", hdr->more_frags ? ", More Fragments" : "");
72 tprintf("%s", hdr->retry ? ", Frame is retransmitted" : "");
73 tprintf("%s", hdr->power_mgmt ? ", In Power Saving Mode" : "");
74 tprintf("%s", hdr->more_data ? ", More Data" : "");
75 tprintf("%s", hdr->wep ? ", Needs WEP" : "");
76 tprintf("%s", hdr->order ? ", Order" : "");
77 tprintf(" ]\n");
79 // pkt_set_proto(pkt, &ieee802_lay2, ntohs(eth->h_proto));
82 static void ieee80211_less(struct pkt_buff *pkt)
84 tprintf("802.11 frame (more on todo)");
87 struct protocol ieee80211_ops = {
88 .key = 0,
89 .print_full = ieee80211,
90 .print_less = ieee80211_less,
93 EXPORT_SYMBOL(ieee80211_ops);