diff options
author | Marc <foxtrot@malloc.me> | 2022-01-09 15:21:47 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-09 15:21:47 +0000 |
commit | 0bd924735125b34b74c893936b89cfae02e3379d (patch) | |
tree | c8140bf65c24791874fa9b0e194773178a34da83 /utils/src/helpers.h | |
parent | 8e09d29df19312583747a3de00fe4269c17e6586 (diff) | |
parent | 11c7393bebe4df6e2061f69787f4a7dd5c31f077 (diff) | |
download | libwifi-0bd924735125b34b74c893936b89cfae02e3379d.tar.gz libwifi-0bd924735125b34b74c893936b89cfae02e3379d.tar.bz2 libwifi-0bd924735125b34b74c893936b89cfae02e3379d.zip |
Merge pull request #3 from libwifi/test
test: Add ctests for parse and generate functions.
Diffstat (limited to 'utils/src/helpers.h')
-rw-r--r-- | utils/src/helpers.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/utils/src/helpers.h b/utils/src/helpers.h new file mode 100644 index 0000000..99a5329 --- /dev/null +++ b/utils/src/helpers.h | |||
@@ -0,0 +1,60 @@ | |||
1 | #include <stdint.h> | ||
2 | #include <sys/types.h> | ||
3 | |||
4 | #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] | ||
5 | #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" | ||
6 | |||
7 | static const uint8_t radiotap_data[] = { | ||
8 | 0x00, | ||
9 | 0x00, // <-- radiotap version (ignore this) | ||
10 | 0x18, | ||
11 | 0x00, // <-- number of bytes in our header (count the number of "0x"s) | ||
12 | |||
13 | /** | ||
14 | * The next field is a bitmap of which options we are including. | ||
15 | * The full list of which field is which option is in ieee80211_radiotap.h, | ||
16 | * but I've chosen to include: | ||
17 | * 0x00 0x01: timestamp | ||
18 | * 0x00 0x02: flags | ||
19 | * 0x00 0x03: rate | ||
20 | * 0x00 0x04: channel | ||
21 | * 0x80 0x00: tx flags (seems silly to have this AND flags, but oh well) | ||
22 | */ | ||
23 | 0x0f, | ||
24 | 0x80, | ||
25 | 0x00, | ||
26 | 0x00, | ||
27 | |||
28 | 0x00, | ||
29 | 0x00, | ||
30 | 0x00, | ||
31 | 0x00, | ||
32 | 0x00, | ||
33 | 0x00, | ||
34 | 0x00, | ||
35 | 0x00, // <-- timestamp | ||
36 | |||
37 | /** | ||
38 | * This is the first set of flags, and we've set the bit corresponding to | ||
39 | * IEEE80211_RADIOTAP_F_FCS, meaning we want the card to add a FCS at the | ||
40 | * end of our buffer for us. | ||
41 | */ | ||
42 | 0x10, | ||
43 | |||
44 | 0x00, // <-- rate | ||
45 | 0x00, | ||
46 | 0x00, | ||
47 | 0x00, | ||
48 | 0x00, // <-- channel | ||
49 | |||
50 | /** | ||
51 | * This is the second set of flags, specifically related to transmissions. | ||
52 | * The bit we've set is IEEE80211_RADIOTAP_F_TX_NOACK, which means the card | ||
53 | * won't wait for an ACK for this frame, and that it won't retry if it | ||
54 | * doesn't get one. | ||
55 | */ | ||
56 | 0x08, | ||
57 | 0x00, | ||
58 | }; | ||
59 | |||
60 | void hexdump(void *data, size_t size); | ||