Function liberate::net::parse_addresses

Function Documentation

bool liberate::net::parse_addresses(socket_address &source, socket_address &dest, ::liberate::types::byte const *buffer, size_t bufsize)

Given an byte buffer representing an IP packet, parses a socket_address from the buffer. Returns true if an address could be parsed, false otherwise.

This function does not verify that the packet is in fact a valid IP packet. It merely treats it as such - it distinguishes between IPv4 and IPv6 protocols to determine which part of the buffer to read, but that is it.

Consequently, if you feed it bad data, it will return a bad socket address.

Parameters
  • source[out] The parsed source address.

  • dest[out] The parsed destination address.

  • buffer[in] The buffer to read from; this is expected to be a valid IP packet (header).

  • bufsize[in] The size of the input buffer.

Returns

true if parsing succeeded, false otherwise.