diff options
author | Sadie Powell <sadie@witchery.services> | 2022-12-15 13:07:22 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2022-12-17 11:50:38 +0000 |
commit | dfdcd3021a482182827ba00782acd5a53442d21a (patch) | |
tree | a1fc48af8de2c732a6222c7db9e1c9018de0b785 /include/sockets.h | |
parent | 5fa3d8f9297f50e25a7bad6a9bde91b9024330de (diff) |
Add support for linking over UNIX sockets.
Diffstat (limited to 'include/sockets.h')
-rw-r--r-- | include/sockets.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/include/sockets.h b/include/sockets.h index 24e580902..641800b6d 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -15,10 +15,16 @@ #include <netinet/in.h> #include <sys/types.h> #include <sys/socket.h> +#include <sys/un.h> #endif #include "anope.h" +// This has to be after anope.h +#ifdef _WIN32 +# include <afunix.h> +#endif + #define NET_BUFSIZE 65535 /** A sockaddr union used to combine IPv4 and IPv6 sockaddrs @@ -28,6 +34,7 @@ union CoreExport sockaddrs sockaddr sa; sockaddr_in sa4; sockaddr_in6 sa6; + sockaddr_un saun; /** Construct the object, sets everything to 0 */ @@ -203,8 +210,9 @@ class CoreExport Socket protected: /* Socket FD */ int sock; - /* Is this an IPv6 socket? */ - bool ipv6; + + /* The family of this socket FD */ + int family; public: std::bitset<SF_SIZE> flags; @@ -221,25 +229,25 @@ class CoreExport Socket /** Constructor, possibly creates the socket and adds it to the engine * @param sock The socket to use, -1 if we need to create our own - * @param ipv6 true if using ipv6 + * @param family The family of the socket * @param type The socket type, defaults to SOCK_STREAM */ - Socket(int sock, bool ipv6 = false, int type = SOCK_STREAM); + Socket(int sock, bool family = AF_INET, int type = SOCK_STREAM); /** Destructor, closes the socket and removes it from the engine */ virtual ~Socket(); + /** Get the socket family for this socket + * @return the family + */ + int GetFamily() const; + /** Get the socket FD for this socket * @return the fd */ int GetFD() const; - /** Check if this socket is IPv6 - * @return true or false - */ - bool IsIPv6() const; - /** Mark a socket as (non)blocking * @param state true to enable blocking, false to disable blocking * @return true if the socket is now blocking |