29 #ifndef INCLUDE_OLA_NETWORK_SOCKETADDRESS_H_ 30 #define INCLUDE_OLA_NETWORK_SOCKETADDRESS_H_ 37 #define WIN32_LEAN_AND_MEAN 38 #include <ola/win/CleanWinSock2.h> 40 #include <sys/socket.h> 62 virtual uint16_t Family()
const = 0;
63 virtual bool ToSockAddr(
struct sockaddr *addr,
unsigned int size)
const = 0;
64 virtual std::string ToString()
const = 0;
66 friend std::ostream& operator<<(std::ostream &out,
68 return out << address.ToString();
94 m_port(other.m_port) {
100 if (
this != &other) {
101 m_host = other.m_host;
102 m_port = other.m_port;
108 return m_host == other.m_host && m_port == other.m_port;
112 return !(*
this == other);
121 if (m_host == other.m_host)
122 return m_port < other.m_port;
124 return m_host < other.m_host;
133 if (m_host == other.m_host)
134 return m_port > other.m_port;
136 return m_host > other.m_host;
139 uint16_t Family()
const {
return AF_INET; }
141 void Host(
const IPV4Address &host) { m_host = host; }
142 uint16_t
Port()
const {
return m_port; }
143 void Port(uint16_t port) { m_port = port; }
145 std::string ToString()
const;
147 static bool FromString(
const std::string &str,
153 bool ToSockAddr(
struct sockaddr *addr,
unsigned int size)
const;
173 memset(reinterpret_cast<uint8_t*>(&m_addr), 0,
sizeof(m_addr));
177 memcpy(&m_addr, &(other.m_addr),
sizeof(m_addr));
180 bool IsValid()
const;
182 uint16_t Family()
const {
183 return m_addr.sa_family;
187 if (
this != &other) {
188 memcpy(&m_addr, &(other.m_addr),
sizeof(m_addr));
193 bool ToSockAddr(
struct sockaddr *addr,
199 std::string ToString()
const;
206 struct sockaddr m_addr;
213 #endif // INCLUDE_OLA_NETWORK_SOCKETADDRESS_H_ bool operator>(const IPV4SocketAddress &other) const
Greater than operator.
Definition: SocketAddress.h:132
Represents a IPv4 Address.
Definition: IPV4Address.h:55
#define OLA_UNUSED
Mark unused arguments & types.
Definition: Macro.h:62
bool operator<(const IPV4SocketAddress &other) const
Less than operator for partial ordering.
Definition: SocketAddress.h:120
Represents an IPv4 Address.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
The base SocketAddress.
Definition: SocketAddress.h:58
The base port class.
Definition: Port.h:49
An IPv4 SocketAddress.
Definition: SocketAddress.h:78
a Generic Socket Address
Definition: SocketAddress.h:166