12#ifndef ROC_PACKET_ADDRESS_H_
13#define ROC_PACKET_ADDRESS_H_
15#include <netinet/in.h>
16#include <sys/socket.h>
60 bool get_ip(
char* buf,
size_t bufsz)
const;
69 static socklen_t sizeof_(sa_family_t family);
71 sa_family_t family_()
const;
bool set_ipv4(const char *ip, int port)
Set IPv4 address.
bool operator==(const Address &other) const
Compare addresses.
Address()
Construct invalid address.
bool set_ipv6(const char *ip, int port)
Set IPv6 address.
bool valid() const
Check if the address was properly initialized.
int port() const
Get address port.
bool operator!=(const Address &other) const
Compare addresses.
sockaddr * saddr()
Get sockaddr struct.
const sockaddr * saddr() const
Get sockaddr struct.
bool set_saddr(const sockaddr *sa)
Set address from sockaddr struct.
socklen_t slen() const
Get sockaddr struct length.
bool multicast() const
Check whether this is multicast address.
bool get_ip(char *buf, size_t bufsz) const
Get IP address.
int version() const
Get IP version (4 or 6).
Commonly used types and functions.