cybersecurity · intermediate · ~15 min · safe pentest lab

802.11 frame subtype

Extract the upper nibble.

Challenge

Extract the 4-bit frame SUBTYPE (the upper nibble) from an 802.11 Frame Control byte.

Task

Implement int frame_subtype(unsigned char fc0) that returns bits 4-7 of fc0, i.e. (fc0 >> 4) & 0xF.

Input

  • fc0: the first byte of the Frame Control field. The grader passes fixed bytes.

Output

Returns int: the 4-bit subtype (0..15). For example, within a management frame, 8 is a beacon and 12 is a deauth.

Example

frame_subtype(0x80)   ->   8    (beacon)
frame_subtype(0xC0)   ->   12   (deauth)

Edge cases

  • The lower nibble (type + protocol version) is masked out.

Rules

  • One shift and one mask.

Input format

The Frame Control first byte fc0.

Output format

An int: the 4-bit subtype (fc0 >> 4) & 0xF.

Constraints

Shift right 4, mask 0xF.

Starter code

int frame_subtype(unsigned char fc0) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.