/* Read http://z0b.kapsi.fi/snippets.php before using this code. Thank you. */ void getAddresses(const uint32_t address, const uint32_t mask, uint32_t &network, uint32_t &broadcast, uint32_t &first, uint32_t &last) { network = address & mask; broadcast = network | (((~mask) << 1) - 1); first = network + 1; last = broadcast - 1; }