cybersecurity · beginner · ~15 min · safe pentest lab
Read the AD type byte.
Read the type byte of a BLE advertising-data structure — it tells you how to interpret the value that follows.
Implement int ad_type(const unsigned char *ad) that returns the type byte at offset 1.
ad: a byte buffer holding one BLE AD structure ([length][type][value...]). The grader passes a fixed buffer.Returns int: ad[1], the AD type (e.g. 0x01 = flags, 0x09 = complete local name).
ad = 0x02 0x01 0x06 -> ad_type(ad) -> 1 (flags)
ad = 0x05 0x09 'a' 'b' 'c' -> ad_type(ad) -> 9 (complete local name)
A byte buffer ad holding one BLE AD structure.
An int: the type byte ad[1].
The type is byte 1.
int ad_type(const unsigned char *ad) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.