networking · intermediate · ~15 min
Test a single flag bit in a header byte.
The QR bit (bit 7 of byte 2) is 0 for a query and 1 for a response. Implement int dns_is_response(const unsigned char *hdr) returning 1 if the QR bit is set.
int dns_is_response(const unsigned char *hdr) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.