cybersecurity · beginner · ~15 min · safe pentest lab
Read the AD length byte.
Read the length byte of a BLE advertising-data structure — the first step in walking a Length-Type-Value record.
Implement int ad_length(const unsigned char *ad) that returns the length byte at offset 0. This length covers the type plus the value bytes.
ad: a byte buffer holding one BLE AD structure ([length][type][value...]). The grader passes a fixed buffer.Returns int: ad[0], the length of the type+value portion.
ad = 0x02 0x01 0x06
ad_length(ad) -> 2
A byte buffer ad holding one BLE AD structure.
An int: the length byte ad[0].
The length is byte 0 and covers type+value.
int ad_length(const unsigned char *ad) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.