networking · intermediate · ~15 min

Unpack a 32-bit address

Decode sin_addr back into octets.

Challenge

Implement void be32_to_ipv4(unsigned addr, int *a, int *b, int *c, int *d) extracting the four octets (a = most-significant byte).

Starter code

void be32_to_ipv4(unsigned addr, int *a, int *b, int *c, int *d) {
    /* TODO */
}

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