| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef __PJ_COMPAT_SOCKET_H__ |
| 20 |
#define __PJ_COMPAT_SOCKET_H__ |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#if defined(PJ_HAS_WINSOCK2_H) && PJ_HAS_WINSOCK2_H != 0 |
| 28 |
# include <winsock2.h> |
| 29 |
#elif defined(PJ_HAS_WINSOCK_H) && PJ_HAS_WINSOCK_H != 0 |
| 30 |
# include <winsock.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
#if defined(PJ_HAS_WS2TCPIP_H) && PJ_HAS_WS2TCPIP_H != 0 |
| 34 |
# include <ws2tcpip.h> |
| 35 |
#endif |
| 36 |
|
| 37 |
#if (defined(PJ_WIN32_UWP) && PJ_WIN32_UWP!=0) |
| 38 |
# include <in6addr.h> |
| 39 |
#endif |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
#if defined(_MSC_VER) && defined(PJ_HAS_IPV6) && PJ_HAS_IPV6!=0 |
| 63 |
# ifndef s_addr |
| 64 |
# define s_addr S_un.S_addr |
| 65 |
# endif |
| 66 |
|
| 67 |
# if !defined(IPPROTO_IPV6) && (_WIN32_WINNT == 0x0500) |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
# include <tpipv6.h> |
| 72 |
# endif |
| 73 |
|
| 74 |
# define PJ_SOCK_HAS_GETADDRINFO 1 |
| 75 |
#endif |
| 76 |
|
| 77 |
#if defined(PJ_HAS_SYS_TYPES_H) && PJ_HAS_SYS_TYPES_H != 0 |
| 78 |
# include <sys/types.h> |
| 79 |
#endif |
| 80 |
|
| 81 |
#if defined(PJ_HAS_SYS_SOCKET_H) && PJ_HAS_SYS_SOCKET_H != 0 |
| 82 |
# include <sys/socket.h> |
| 83 |
#endif |
| 84 |
|
| 85 |
#if defined(PJ_HAS_LINUX_SOCKET_H) && PJ_HAS_LINUX_SOCKET_H != 0 |
| 86 |
# include <linux/socket.h> |
| 87 |
#endif |
| 88 |
|
| 89 |
#if defined(PJ_HAS_SYS_SELECT_H) && PJ_HAS_SYS_SELECT_H != 0 |
| 90 |
# include <sys/select.h> |
| 91 |
#endif |
| 92 |
|
| 93 |
#if defined(PJ_HAS_NETINET_IN_H) && PJ_HAS_NETINET_IN_H != 0 |
| 94 |
# include <netinet/in.h> |
| 95 |
#endif |
| 96 |
|
| 97 |
#if defined(PJ_HAS_NETINET_IN_SYSTM_H) && PJ_HAS_NETINET_IN_SYSTM_H != 0 |
| 98 |
|
| 99 |
# include <netinet/in_systm.h> |
| 100 |
#endif |
| 101 |
|
| 102 |
#if defined(PJ_HAS_NETINET_IP_H) && PJ_HAS_NETINET_IP_H != 0 |
| 103 |
|
| 104 |
# include <netinet/ip.h> |
| 105 |
#endif |
| 106 |
|
| 107 |
#if defined(PJ_HAS_NETINET_TCP_H) && PJ_HAS_NETINET_TCP_H != 0 |
| 108 |
|
| 109 |
# include <netinet/tcp.h> |
| 110 |
#endif |
| 111 |
|
| 112 |
#if defined(PJ_HAS_NET_IF_H) && PJ_HAS_NET_IF_H != 0 |
| 113 |
|
| 114 |
# include <net/if.h> |
| 115 |
#endif |
| 116 |
|
| 117 |
#if defined(PJ_HAS_IFADDRS_H) && PJ_HAS_IFADDRS_H != 0 |
| 118 |
|
| 119 |
# include <ifaddrs.h> |
| 120 |
#endif |
| 121 |
|
| 122 |
#if defined(PJ_HAS_ARPA_INET_H) && PJ_HAS_ARPA_INET_H != 0 |
| 123 |
# include <arpa/inet.h> |
| 124 |
#endif |
| 125 |
|
| 126 |
#if defined(PJ_HAS_SYS_IOCTL_H) && PJ_HAS_SYS_IOCTL_H != 0 |
| 127 |
# include <sys/ioctl.h> |
| 128 |
#endif |
| 129 |
|
| 130 |
#if defined(PJ_HAS_ERRNO_H) && PJ_HAS_ERRNO_H != 0 |
| 131 |
# include <errno.h> |
| 132 |
#endif |
| 133 |
|
| 134 |
#if defined(PJ_HAS_NETDB_H) && PJ_HAS_NETDB_H != 0 |
| 135 |
# include <netdb.h> |
| 136 |
#endif |
| 137 |
|
| 138 |
#if defined(PJ_HAS_UNISTD_H) && PJ_HAS_UNISTD_H != 0 |
| 139 |
# include <unistd.h> |
| 140 |
#endif |
| 141 |
|
| 142 |
#if defined(PJ_HAS_SYS_FILIO_H) && PJ_HAS_SYS_FILIO_H != 0 |
| 143 |
# include <sys/filio.h> |
| 144 |
#endif |
| 145 |
|
| 146 |
#if defined(PJ_HAS_SYS_SOCKIO_H) && PJ_HAS_SYS_SOCKIO_H != 0 |
| 147 |
# include <sys/sockio.h> |
| 148 |
#endif |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
#if (defined(PJ_WIN32) && PJ_WIN32!=0) || \ |
| 155 |
(defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0) || \ |
| 156 |
(defined(PJ_WIN64) && PJ_WIN64!=0) |
| 157 |
# define OSERR_EWOULDBLOCK WSAEWOULDBLOCK |
| 158 |
# define OSERR_EINPROGRESS WSAEINPROGRESS |
| 159 |
# define OSERR_ECONNRESET WSAECONNRESET |
| 160 |
# define OSERR_ENOTCONN WSAENOTCONN |
| 161 |
# define OSERR_EAFNOSUPPORT WSAEAFNOSUPPORT |
| 162 |
# define OSERR_ENOPROTOOPT WSAENOPROTOOPT |
| 163 |
#elif defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 |
| 164 |
# define OSERR_EWOULDBLOCK -1 |
| 165 |
# define OSERR_EINPROGRESS -1 |
| 166 |
# define OSERR_ECONNRESET -1 |
| 167 |
# define OSERR_ENOTCONN -1 |
| 168 |
# define OSERR_EAFNOSUPPORT -1 |
| 169 |
# define OSERR_ENOPROTOOPT -1 |
| 170 |
#else |
| 171 |
# define OSERR_EWOULDBLOCK EWOULDBLOCK |
| 172 |
# define OSERR_EINPROGRESS EINPROGRESS |
| 173 |
# define OSERR_ECONNRESET ECONNRESET |
| 174 |
# define OSERR_ENOTCONN ENOTCONN |
| 175 |
# define OSERR_EAFNOSUPPORT EAFNOSUPPORT |
| 176 |
# define OSERR_ENOPROTOOPT ENOPROTOOPT |
| 177 |
#endif |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
#if !defined(PJ_HAS_SOCKLEN_T) || PJ_HAS_SOCKLEN_T==0 |
| 194 |
typedef int socklen_t; |
| 195 |
#endif |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 |
| 213 |
# define PJ_SOCKADDR_SET_LEN(addr,len) (((pj_addr_hdr*)(addr))->sa_zero_len=(len)) |
| 214 |
# define PJ_SOCKADDR_RESET_LEN(addr) (((pj_addr_hdr*)(addr))->sa_zero_len=0) |
| 215 |
#else |
| 216 |
# define PJ_SOCKADDR_SET_LEN(addr,len) |
| 217 |
# define PJ_SOCKADDR_RESET_LEN(addr) |
| 218 |
#endif |
| 219 |
|
| 220 |
#endif |
| 221 |
|