From cd1df65dc36ac35d526de195284d5ebf18e1f92b Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 17 Dec 2021 18:52:36 +0000 Subject: test: Add ctests for generation functions. This commit also enforces error code checking on functions inside of the generation functions, such as for `libwifi_quick_add_tag`. --- utils/src/helpers.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 utils/src/helpers.h (limited to 'utils/src/helpers.h') 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 @@ +#include +#include + +#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] +#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" + +static const uint8_t radiotap_data[] = { + 0x00, + 0x00, // <-- radiotap version (ignore this) + 0x18, + 0x00, // <-- number of bytes in our header (count the number of "0x"s) + + /** + * The next field is a bitmap of which options we are including. + * The full list of which field is which option is in ieee80211_radiotap.h, + * but I've chosen to include: + * 0x00 0x01: timestamp + * 0x00 0x02: flags + * 0x00 0x03: rate + * 0x00 0x04: channel + * 0x80 0x00: tx flags (seems silly to have this AND flags, but oh well) + */ + 0x0f, + 0x80, + 0x00, + 0x00, + + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, // <-- timestamp + + /** + * This is the first set of flags, and we've set the bit corresponding to + * IEEE80211_RADIOTAP_F_FCS, meaning we want the card to add a FCS at the + * end of our buffer for us. + */ + 0x10, + + 0x00, // <-- rate + 0x00, + 0x00, + 0x00, + 0x00, // <-- channel + + /** + * This is the second set of flags, specifically related to transmissions. + * The bit we've set is IEEE80211_RADIOTAP_F_TX_NOACK, which means the card + * won't wait for an ACK for this frame, and that it won't retry if it + * doesn't get one. + */ + 0x08, + 0x00, +}; + +void hexdump(void *data, size_t size); -- cgit 1.4.1