int main(void) { const unsigned int FrameLen = 36; unsigned char *macframe = malloc(FrameLen); // alloc MAC header until frame body // fill header with junk, to make this more interesting for (unsigned int i = 0; i < FrameLen; i++) { macframe[i] = 0xde; } set_proto_version(macframe, 0); set_type(macframe, 1); set_subtype(macframe, 1); set_to_ds(macframe, 1); set_from_ds(macframe, 0); set_retry(macframe, 0); set_more_data(macframe, 0); print_header(macframe); printf("Protocol version: %d\n", get_proto_version(macframe)); printf("Type: %d\n", get_type(macframe)); printf("Subtype: %d\n", get_subtype(macframe)); printf("Flags: To DS: %d From DS: %d Retry: %d More Data: %d\n", get_to_ds(macframe) != 0, get_from_ds(macframe) != 0, get_retry(macframe) != 0, get_more_data(macframe) != 0); free(macframe); }
static inline void get_BSSID(u8 *data, u8 *bssid) { if (get_from_ds(data) == 1) get_address2(data, bssid); else if (get_to_ds(data) == 1) get_address1(data, bssid); else get_address3(data, bssid); }