/* */ #ifndef D_A2NETCOMPAT_H #define D_A2NETCOMPAT_H #include "a2io.h" #ifdef __MINGW32__ # ifdef HAVE_WS2TCPIP_H # include # endif // HAVE_WS2TCPIP_H #endif // __MINGW32__ #ifdef __MINGW32__ # define a2_sockopt_t char* # ifndef HAVE_GETADDRINFO # define HAVE_GETADDRINFO # endif // !HAVE_GETADDRINFO # undef HAVE_GAI_STRERROR # undef gai_strerror #else # define a2_sockopt_t void* #endif // __MINGW32__ #ifdef HAVE_NETDB_H # include #endif // HAVE_NETDB_H #ifdef HAVE_SYS_SOCKET_H # include #endif // HAVE_SYS_SOCKET_H #ifdef HAVE_NETINET_IN_H # include #endif // HAVE_NETINET_IN_H #ifdef HAVE_NETINET_TCP_H # include #endif // HAVE_NETINET_TCP_H #ifdef HAVE_ARPA_INET_H # include #endif // HAVE_ARPA_INET_H #ifdef HAVE_NETINET_IN_H # include #endif // HAVE_NETINET_IN_H #ifdef HAVE_SYS_UIO_H # include #endif // HAVE_SYS_UIO_H #ifndef HAVE_GETADDRINFO # include "getaddrinfo.h" # define HAVE_GAI_STRERROR #endif // HAVE_GETADDRINFO #ifndef HAVE_GAI_STRERROR # include "gai_strerror.h" #endif // HAVE_GAI_STRERROR #include #ifdef HAVE_WINSOCK2_H # define sock_t SOCKET #else # define sock_t int #endif #ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 #endif // !AI_ADDRCONFIG #define DEFAULT_AI_FLAGS AI_ADDRCONFIG #ifdef __MINGW32__ # ifndef SHUT_WR # define SHUT_WR SD_SEND # endif // !SHUT_WR #endif // __MINGW32__ union sockaddr_union { sockaddr sa; sockaddr_storage storage; sockaddr_in6 in6; sockaddr_in in; }; struct SockAddr { sockaddr_union su; socklen_t suLength; }; // Human readable address, family and port. In other words, addr is // text name, usually obtained from getnameinfo(3). The family field // is the protocol family if it is known when generating this object. // If it is unknown, this is AF_UNSPEC. struct Endpoint { std::string addr; int family; uint16_t port; }; #define A2_DEFAULT_IOV_MAX 128 #if defined(IOV_MAX) && IOV_MAX < A2_DEFAULT_IOV_MAX # define A2_IOV_MAX IOV_MAX #else # define A2_IOV_MAX A2_DEFAULT_IOV_MAX #endif #ifdef __MINGW32__ typedef WSABUF a2iovec; # define A2IOVEC_BASE buf # define A2IOVEC_LEN len #else // !__MINGW32__ typedef struct iovec a2iovec; # define A2IOVEC_BASE iov_base # define A2IOVEC_LEN iov_len #endif // !__MINGW32__ #endif // D_A2NETCOMPAT_H