cybersecurity · intermediate · ~15 min · safe pentest lab
Extract a bitfield from a control byte.
Extract the 2-bit frame TYPE from an 802.11 Frame Control byte.
Implement int frame_type(unsigned char fc0) that returns the type field: bits 2-3 of fc0, i.e. (fc0 >> 2) & 0x3.
fc0: the first byte of the Frame Control field. The grader passes fixed bytes.Returns int: the 2-bit type (0=management, 1=control, 2=data, 3=reserved).
frame_type(0x00) -> 0 (management)
frame_type(0x04) -> 1 (control)
frame_type(0x08) -> 2 (data)
& 0x3.The Frame Control first byte fc0.
An int: the 2-bit frame type (fc0 >> 2) & 0x3.
Shift right 2, mask 0x3.
int frame_type(unsigned char fc0) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.