-typedef struct sockaddr_in insp_sockaddr;
-typedef struct in_addr insp_inaddr;
-#define AF_FAMILY AF_INET
-#define PF_PROTOCOL PF_INET
+/* Contains irc-specific definitions */
+namespace irc
+{
+ /** This namespace contains various protocol-independent helper classes.
+ * It also contains some types which are often used by the core and modules
+ * in place of inet_* functions and types.
+ */
+ namespace sockets
+ {
+ union CoreExport sockaddrs
+ {
+ struct sockaddr sa;
+ struct sockaddr_in in4;
+ struct sockaddr_in6 in6;
+ /** Return the size of the structure for syscall passing */
+ int sa_size() const;
+ /** Return port number or -1 if invalid */
+ int port() const;
+ /** Return IP only */
+ std::string addr() const;
+ /** Return human-readable IP/port pair */
+ std::string str() const;
+ bool operator==(const sockaddrs& other) const;
+ inline bool operator!=(const sockaddrs& other) const { return !(*this == other); }
+ };