Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / Documentation / networking / mac80211-injection.txt
blob84906ef3ed6e969404a9fac550f9973254f0039d
1 How to use packet injection with mac80211
2 =========================================
4 mac80211 now allows arbitrary packets to be injected down any Monitor Mode
5 interface from userland.  The packet you inject needs to be composed in the
6 following format:
8  [ radiotap header  ]
9  [ ieee80211 header ]
10  [ payload ]
12 The radiotap format is discussed in
13 ./Documentation/networking/radiotap-headers.txt.
15 Despite 13 radiotap argument types are currently defined, most only make sense
16 to appear on received packets.  The following information is parsed from the
17 radiotap headers and used to control injection:
19  * IEEE80211_RADIOTAP_RATE
21    rate in 500kbps units, automatic if invalid or not present
24  * IEEE80211_RADIOTAP_ANTENNA
26    antenna to use, automatic if not present
29  * IEEE80211_RADIOTAP_DBM_TX_POWER
31    transmit power in dBm, automatic if not present
34  * IEEE80211_RADIOTAP_FLAGS
36    IEEE80211_RADIOTAP_F_FCS: FCS will be removed and recalculated
37    IEEE80211_RADIOTAP_F_WEP: frame will be encrypted if key available
38    IEEE80211_RADIOTAP_F_FRAG: frame will be fragmented if longer than the
39                               current fragmentation threshold. Note that
40                               this flag is only reliable when software
41                               fragmentation is enabled)
43 The injection code can also skip all other currently defined radiotap fields
44 facilitating replay of captured radiotap headers directly.
46 Here is an example valid radiotap header defining these three parameters
48         0x00, 0x00, // <-- radiotap version
49         0x0b, 0x00, // <- radiotap header length
50         0x04, 0x0c, 0x00, 0x00, // <-- bitmap
51         0x6c, // <-- rate
52         0x0c, //<-- tx power
53         0x01 //<-- antenna
55 The ieee80211 header follows immediately afterwards, looking for example like
56 this:
58         0x08, 0x01, 0x00, 0x00,
59         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
60         0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
61         0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
62         0x10, 0x86
64 Then lastly there is the payload.
66 After composing the packet contents, it is sent by send()-ing it to a logical
67 mac80211 interface that is in Monitor mode.  Libpcap can also be used,
68 (which is easier than doing the work to bind the socket to the right
69 interface), along the following lines:
71         ppcap = pcap_open_live(szInterfaceName, 800, 1, 20, szErrbuf);
72 ...
73         r = pcap_inject(ppcap, u8aSendBuffer, nLength);
75 You can also find sources for a complete inject test applet here:
77 http://penumbra.warmcat.com/_twk/tiki-index.php?page=packetspammer
79 Andy Green <andy@warmcat.com>