Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

619 lines
18 KiB

  1. /*
  2. ** WS2TCPIP.H - WinSock2 Extension for TCP/IP protocols
  3. **
  4. ** This file contains TCP/IP specific information for use
  5. ** by WinSock2 compatible applications.
  6. **
  7. ** Copyright (c) Microsoft Corporation. All rights reserved.
  8. **
  9. ** To provide the backward compatibility, all the TCP/IP
  10. ** specific definitions that were included in the WINSOCK.H
  11. ** file are now included in WINSOCK2.H file. WS2TCPIP.H
  12. ** file includes only the definitions introduced in the
  13. ** "WinSock 2 Protocol-Specific Annex" document.
  14. **
  15. ** Rev 0.3 Nov 13, 1995
  16. ** Rev 0.4 Dec 15, 1996
  17. */
  18. #ifndef _WS2TCPIP_H_
  19. #define _WS2TCPIP_H_
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif
  23. /* Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP */
  24. struct ip_mreq {
  25. struct in_addr imr_multiaddr; /* IP multicast address of group */
  26. struct in_addr imr_interface; /* local IP address of interface */
  27. };
  28. /* Argument structure for IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP,
  29. * IP_BLOCK_SOURCE, and IP_UNBLOCK_SOURCE
  30. */
  31. struct ip_mreq_source {
  32. struct in_addr imr_multiaddr; /* IP multicast address of group */
  33. struct in_addr imr_sourceaddr; /* IP address of source */
  34. struct in_addr imr_interface; /* local IP address of interface */
  35. };
  36. /* Argument structure for SIO_{GET,SET}_MULTICAST_FILTER */
  37. struct ip_msfilter {
  38. struct in_addr imsf_multiaddr; /* IP multicast address of group */
  39. struct in_addr imsf_interface; /* local IP address of interface */
  40. u_long imsf_fmode; /* filter mode - INCLUDE or EXCLUDE */
  41. u_long imsf_numsrc; /* number of sources in src_list */
  42. struct in_addr imsf_slist[1];
  43. };
  44. #define IP_MSFILTER_SIZE(numsrc) \
  45. (sizeof(struct ip_msfilter)-sizeof(struct in_addr) + (numsrc)*sizeof(struct in_addr))
  46. #define MCAST_INCLUDE 0
  47. #define MCAST_EXCLUDE 1
  48. /* TCP/IP specific Ioctl codes */
  49. #define SIO_GET_INTERFACE_LIST _IOR('t', 127, u_long)
  50. /* New IOCTL with address size independent address array */
  51. #define SIO_GET_INTERFACE_LIST_EX _IOR('t', 126, u_long)
  52. #define SIO_SET_MULTICAST_FILTER _IOW('t', 125, u_long)
  53. #define SIO_GET_MULTICAST_FILTER _IOW('t', 124 | IOC_IN, u_long)
  54. /* Option to use with [gs]etsockopt at the IPPROTO_IP level */
  55. #define IP_OPTIONS 1 /* set/get IP options */
  56. #define IP_HDRINCL 2 /* header is included with data */
  57. #define IP_TOS 3 /* IP type of service and preced*/
  58. #define IP_TTL 4 /* IP time to live */
  59. #define IP_MULTICAST_IF 9 /* set/get IP multicast i/f */
  60. #define IP_MULTICAST_TTL 10 /* set/get IP multicast ttl */
  61. #define IP_MULTICAST_LOOP 11 /*set/get IP multicast loopback */
  62. #define IP_ADD_MEMBERSHIP 12 /* add an IP group membership */
  63. #define IP_DROP_MEMBERSHIP 13/* drop an IP group membership */
  64. #define IP_DONTFRAGMENT 14 /* don't fragment IP datagrams */
  65. #define IP_ADD_SOURCE_MEMBERSHIP 15 /* join IP group/source */
  66. #define IP_DROP_SOURCE_MEMBERSHIP 16 /* leave IP group/source */
  67. #define IP_BLOCK_SOURCE 17 /* block IP group/source */
  68. #define IP_UNBLOCK_SOURCE 18 /* unblock IP group/source */
  69. #define IP_PKTINFO 19 /* receive packet information for ipv4*/
  70. /* Option to use with [gs]etsockopt at the IPPROTO_IPV6 level */
  71. #define IPV6_HDRINCL 2 /* Header is included with data */
  72. #define IPV6_UNICAST_HOPS 4 /* Set/get IP unicast hop limit */
  73. #define IPV6_MULTICAST_IF 9 /* Set/get IP multicast interface */
  74. #define IPV6_MULTICAST_HOPS 10 /* Set/get IP multicast ttl */
  75. #define IPV6_MULTICAST_LOOP 11 /* Set/get IP multicast loopback */
  76. #define IPV6_ADD_MEMBERSHIP 12 /* Add an IP group membership */
  77. #define IPV6_DROP_MEMBERSHIP 13 /* Drop an IP group membership */
  78. #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
  79. #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
  80. #define IPV6_PKTINFO 19 /* Receive packet information for ipv6 */
  81. #define IPV6_HOPLIMIT 21 /* Receive packet hop limit */
  82. /* Option to use with [gs]etsockopt at the IPPROTO_UDP level */
  83. #define UDP_NOCHECKSUM 1
  84. #define UDP_CHECKSUM_COVERAGE 20 /* Set/get UDP-Lite checksum coverage */
  85. /* Option to use with [gs]etsockopt at the IPPROTO_TCP level */
  86. #define TCP_EXPEDITED_1122 0x0002
  87. /* IPv6 definitions */
  88. #ifndef s6_addr
  89. struct in6_addr {
  90. union {
  91. u_char Byte[16];
  92. u_short Word[8];
  93. } u;
  94. };
  95. #define in_addr6 in6_addr
  96. /*
  97. ** Defines to match RFC 2553.
  98. */
  99. #define _S6_un u
  100. #define _S6_u8 Byte
  101. #define s6_addr _S6_un._S6_u8
  102. /*
  103. ** Defines for our implementation.
  104. */
  105. #define s6_bytes u.Byte
  106. #define s6_words u.Word
  107. #endif
  108. /* Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP */
  109. typedef struct ipv6_mreq {
  110. struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address */
  111. unsigned int ipv6mr_interface; /* Interface index */
  112. } IPV6_MREQ;
  113. /* Old IPv6 socket address structure (retained for sockaddr_gen definition below) */
  114. struct sockaddr_in6_old {
  115. short sin6_family; /* AF_INET6 */
  116. u_short sin6_port; /* Transport level port number */
  117. u_long sin6_flowinfo; /* IPv6 flow information */
  118. struct in6_addr sin6_addr; /* IPv6 address */
  119. };
  120. /* IPv6 socket address structure, RFC 2553 */
  121. struct sockaddr_in6 {
  122. short sin6_family; /* AF_INET6 */
  123. u_short sin6_port; /* Transport level port number */
  124. u_long sin6_flowinfo; /* IPv6 flow information */
  125. struct in6_addr sin6_addr; /* IPv6 address */
  126. u_long sin6_scope_id; /* set of interfaces for a scope */
  127. };
  128. typedef struct in6_addr IN6_ADDR;
  129. typedef struct in6_addr *PIN6_ADDR;
  130. typedef struct in6_addr FAR *LPIN6_ADDR;
  131. typedef struct sockaddr_in6 SOCKADDR_IN6;
  132. typedef struct sockaddr_in6 *PSOCKADDR_IN6;
  133. typedef struct sockaddr_in6 FAR *LPSOCKADDR_IN6;
  134. /* Macro that works for both IPv4 and IPv6 */
  135. #define SS_PORT(ssp) (((struct sockaddr_in*)(ssp))->sin_port)
  136. #define IN6ADDR_ANY_INIT { 0 }
  137. #define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
  138. #ifdef __cplusplus
  139. extern "C" {
  140. #endif
  141. extern const struct in6_addr in6addr_any;
  142. extern const struct in6_addr in6addr_loopback;
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #ifdef _MSC_VER
  147. #define WS2TCPIP_INLINE __inline
  148. #else
  149. #define WS2TCPIP_INLINE extern inline /* GNU style */
  150. #endif
  151. WS2TCPIP_INLINE int
  152. IN6_ADDR_EQUAL(const struct in6_addr *a, const struct in6_addr *b)
  153. {
  154. return (memcmp(a, b, sizeof(struct in6_addr)) == 0);
  155. }
  156. WS2TCPIP_INLINE int
  157. IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *a)
  158. {
  159. return ((a->s6_words[0] == 0) &&
  160. (a->s6_words[1] == 0) &&
  161. (a->s6_words[2] == 0) &&
  162. (a->s6_words[3] == 0) &&
  163. (a->s6_words[4] == 0) &&
  164. (a->s6_words[5] == 0) &&
  165. (a->s6_words[6] == 0) &&
  166. (a->s6_words[7] == 0));
  167. }
  168. WS2TCPIP_INLINE int
  169. IN6_IS_ADDR_LOOPBACK(const struct in6_addr *a)
  170. {
  171. return ((a->s6_words[0] == 0) &&
  172. (a->s6_words[1] == 0) &&
  173. (a->s6_words[2] == 0) &&
  174. (a->s6_words[3] == 0) &&
  175. (a->s6_words[4] == 0) &&
  176. (a->s6_words[5] == 0) &&
  177. (a->s6_words[6] == 0) &&
  178. (a->s6_words[7] == 0x0100));
  179. }
  180. WS2TCPIP_INLINE int
  181. IN6_IS_ADDR_MULTICAST(const struct in6_addr *a)
  182. {
  183. return (a->s6_bytes[0] == 0xff);
  184. }
  185. WS2TCPIP_INLINE int
  186. IN6_IS_ADDR_LINKLOCAL(const struct in6_addr *a)
  187. {
  188. return ((a->s6_bytes[0] == 0xfe) &&
  189. ((a->s6_bytes[1] & 0xc0) == 0x80));
  190. }
  191. WS2TCPIP_INLINE int
  192. IN6_IS_ADDR_SITELOCAL(const struct in6_addr *a)
  193. {
  194. return ((a->s6_bytes[0] == 0xfe) &&
  195. ((a->s6_bytes[1] & 0xc0) == 0xc0));
  196. }
  197. WS2TCPIP_INLINE int
  198. IN6_IS_ADDR_V4MAPPED(const struct in6_addr *a)
  199. {
  200. return ((a->s6_words[0] == 0) &&
  201. (a->s6_words[1] == 0) &&
  202. (a->s6_words[2] == 0) &&
  203. (a->s6_words[3] == 0) &&
  204. (a->s6_words[4] == 0) &&
  205. (a->s6_words[5] == 0xffff));
  206. }
  207. WS2TCPIP_INLINE int
  208. IN6_IS_ADDR_V4COMPAT(const struct in6_addr *a)
  209. {
  210. return ((a->s6_words[0] == 0) &&
  211. (a->s6_words[1] == 0) &&
  212. (a->s6_words[2] == 0) &&
  213. (a->s6_words[3] == 0) &&
  214. (a->s6_words[4] == 0) &&
  215. (a->s6_words[5] == 0) &&
  216. !((a->s6_words[6] == 0) &&
  217. (a->s6_addr[14] == 0) &&
  218. ((a->s6_addr[15] == 0) || (a->s6_addr[15] == 1))));
  219. }
  220. WS2TCPIP_INLINE int
  221. IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr *a)
  222. {
  223. return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf) == 1);
  224. }
  225. WS2TCPIP_INLINE int
  226. IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr *a)
  227. {
  228. return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf) == 2);
  229. }
  230. WS2TCPIP_INLINE int
  231. IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr *a)
  232. {
  233. return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf) == 5);
  234. }
  235. WS2TCPIP_INLINE int
  236. IN6_IS_ADDR_MC_ORGLOCAL(const struct in6_addr *a)
  237. {
  238. return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf) == 8);
  239. }
  240. WS2TCPIP_INLINE int
  241. IN6_IS_ADDR_MC_GLOBAL(const struct in6_addr *a)
  242. {
  243. return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf) == 0xe);
  244. }
  245. WS2TCPIP_INLINE int
  246. IN6ADDR_ISANY(const struct sockaddr_in6 *a)
  247. {
  248. return ((a->sin6_family == AF_INET6) &&
  249. IN6_IS_ADDR_UNSPECIFIED(&a->sin6_addr));
  250. }
  251. WS2TCPIP_INLINE int
  252. IN6ADDR_ISLOOPBACK(const struct sockaddr_in6 *a)
  253. {
  254. return ((a->sin6_family == AF_INET6) &&
  255. IN6_IS_ADDR_LOOPBACK(&a->sin6_addr));
  256. }
  257. WS2TCPIP_INLINE void
  258. IN6_SET_ADDR_UNSPECIFIED(struct in6_addr *a)
  259. {
  260. memset(a->s6_bytes, 0, sizeof(struct in6_addr));
  261. }
  262. WS2TCPIP_INLINE void
  263. IN6_SET_ADDR_LOOPBACK(struct in6_addr *a)
  264. {
  265. memset(a->s6_bytes, 0, sizeof(struct in6_addr));
  266. a->s6_bytes[15] = 1;
  267. }
  268. WS2TCPIP_INLINE void
  269. IN6ADDR_SETANY(struct sockaddr_in6 *a)
  270. {
  271. a->sin6_family = AF_INET6;
  272. a->sin6_port = 0;
  273. a->sin6_flowinfo = 0;
  274. IN6_SET_ADDR_UNSPECIFIED(&a->sin6_addr);
  275. a->sin6_scope_id = 0;
  276. }
  277. WS2TCPIP_INLINE void
  278. IN6ADDR_SETLOOPBACK(struct sockaddr_in6 *a)
  279. {
  280. a->sin6_family = AF_INET6;
  281. a->sin6_port = 0;
  282. a->sin6_flowinfo = 0;
  283. IN6_SET_ADDR_LOOPBACK(&a->sin6_addr);
  284. a->sin6_scope_id = 0;
  285. }
  286. typedef union sockaddr_gen{
  287. struct sockaddr Address;
  288. struct sockaddr_in AddressIn;
  289. struct sockaddr_in6_old AddressIn6;
  290. } sockaddr_gen;
  291. /* Structure to keep interface specific information */
  292. typedef struct _INTERFACE_INFO
  293. {
  294. u_long iiFlags; /* Interface flags */
  295. sockaddr_gen iiAddress; /* Interface address */
  296. sockaddr_gen iiBroadcastAddress; /* Broadcast address */
  297. sockaddr_gen iiNetmask; /* Network mask */
  298. } INTERFACE_INFO, FAR * LPINTERFACE_INFO;
  299. /* New structure that does not have dependency on the address size */
  300. typedef struct _INTERFACE_INFO_EX
  301. {
  302. u_long iiFlags; /* Interface flags */
  303. SOCKET_ADDRESS iiAddress; /* Interface address */
  304. SOCKET_ADDRESS iiBroadcastAddress; /* Broadcast address */
  305. SOCKET_ADDRESS iiNetmask; /* Network mask */
  306. } INTERFACE_INFO_EX, FAR * LPINTERFACE_INFO_EX;
  307. /* Possible flags for the iiFlags - bitmask */
  308. #define IFF_UP 0x00000001 /* Interface is up */
  309. #define IFF_BROADCAST 0x00000002 /* Broadcast is supported */
  310. #define IFF_LOOPBACK 0x00000004 /* this is loopback interface */
  311. #define IFF_POINTTOPOINT 0x00000008 /*this is point-to-point interface*/
  312. #define IFF_MULTICAST 0x00000010 /* multicast is supported */
  313. // structure for IP_PKTINFO option
  314. //
  315. typedef struct in_pktinfo {
  316. IN_ADDR ipi_addr; // destination IPv4 address
  317. UINT ipi_ifindex; // received interface index
  318. } IN_PKTINFO;
  319. C_ASSERT(sizeof(IN_PKTINFO) == 8);
  320. // structure for IPV6_PKTINFO option
  321. //
  322. typedef struct in6_pktinfo {
  323. IN6_ADDR ipi6_addr; // destination IPv6 address
  324. UINT ipi6_ifindex; // received interface index
  325. } IN6_PKTINFO;
  326. C_ASSERT(sizeof(IN6_PKTINFO) == 20);
  327. /* Error codes from getaddrinfo() */
  328. #define EAI_AGAIN WSATRY_AGAIN
  329. #define EAI_BADFLAGS WSAEINVAL
  330. #define EAI_FAIL WSANO_RECOVERY
  331. #define EAI_FAMILY WSAEAFNOSUPPORT
  332. #define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
  333. //#define EAI_NODATA WSANO_DATA
  334. #define EAI_NONAME WSAHOST_NOT_FOUND
  335. #define EAI_SERVICE WSATYPE_NOT_FOUND
  336. #define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
  337. //
  338. // DCR_FIX: EAI_NODATA remove or fix
  339. //
  340. // EAI_NODATA was removed from rfc2553bis
  341. // need to find out from the authors why and
  342. // determine the error for "no records of this type"
  343. // temporarily, we'll keep #define to avoid changing
  344. // code that could change back; use NONAME
  345. //
  346. #define EAI_NODATA EAI_NONAME
  347. /* Structure used in getaddrinfo() call */
  348. typedef struct addrinfo {
  349. int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
  350. int ai_family; /* PF_xxx */
  351. int ai_socktype; /* SOCK_xxx */
  352. int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
  353. size_t ai_addrlen; /* Length of ai_addr */
  354. char *ai_canonname; /* Canonical name for nodename */
  355. struct sockaddr *ai_addr; /* Binary address */
  356. struct addrinfo *ai_next; /* Next structure in linked list */
  357. } ADDRINFO, FAR * LPADDRINFO;
  358. /* Flags used in "hints" argument to getaddrinfo() */
  359. #define AI_PASSIVE 0x1 /* Socket address will be used in bind() call */
  360. #define AI_CANONNAME 0x2 /* Return canonical name in first ai_canonname */
  361. #define AI_NUMERICHOST 0x4 /* Nodename must be a numeric address string */
  362. #ifdef __cplusplus
  363. extern "C" {
  364. #endif
  365. WINSOCK_API_LINKAGE
  366. int
  367. WSAAPI
  368. getaddrinfo(
  369. IN const char FAR * nodename,
  370. IN const char FAR * servname,
  371. IN const struct addrinfo FAR * hints,
  372. OUT struct addrinfo FAR * FAR * res
  373. );
  374. #if INCL_WINSOCK_API_TYPEDEFS
  375. typedef
  376. int
  377. (WSAAPI * LPFN_GETADDRINFO)(
  378. IN const char FAR * nodename,
  379. IN const char FAR * servname,
  380. IN const struct addrinfo FAR * hints,
  381. OUT struct addrinfo FAR * FAR * res
  382. );
  383. #endif
  384. WINSOCK_API_LINKAGE
  385. void
  386. WSAAPI
  387. freeaddrinfo(
  388. IN struct addrinfo FAR * ai
  389. );
  390. #if INCL_WINSOCK_API_TYPEDEFS
  391. typedef
  392. void
  393. (WSAAPI * LPFN_FREEADDRINFO)(
  394. IN struct addrinfo FAR * ai
  395. );
  396. #endif
  397. #if INCL_WINSOCK_API_PROTOTYPES
  398. #ifdef UNICODE
  399. #define gai_strerror gai_strerrorW
  400. #else
  401. #define gai_strerror gai_strerrorA
  402. #endif /* UNICODE */
  403. // WARNING: The gai_strerror inline functions below use static buffers,
  404. // and hence are not thread-safe. We'll use buffers long enough to hold
  405. // 1k characters. Any system error messages longer than this will be
  406. // returned as empty strings. However 1k should work for the error codes
  407. // used by getaddrinfo().
  408. #define GAI_STRERROR_BUFFER_SIZE 1024
  409. WS2TCPIP_INLINE
  410. char *
  411. gai_strerrorA(
  412. IN int ecode)
  413. {
  414. DWORD dwMsgLen;
  415. static char buff[GAI_STRERROR_BUFFER_SIZE + 1];
  416. dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
  417. |FORMAT_MESSAGE_IGNORE_INSERTS
  418. |FORMAT_MESSAGE_MAX_WIDTH_MASK,
  419. NULL,
  420. ecode,
  421. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  422. (LPSTR)buff,
  423. GAI_STRERROR_BUFFER_SIZE,
  424. NULL);
  425. return buff;
  426. }
  427. WS2TCPIP_INLINE
  428. WCHAR *
  429. gai_strerrorW(
  430. IN int ecode
  431. )
  432. {
  433. DWORD dwMsgLen;
  434. static WCHAR buff[GAI_STRERROR_BUFFER_SIZE + 1];
  435. dwMsgLen = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
  436. |FORMAT_MESSAGE_IGNORE_INSERTS
  437. |FORMAT_MESSAGE_MAX_WIDTH_MASK,
  438. NULL,
  439. ecode,
  440. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  441. (LPWSTR)buff,
  442. GAI_STRERROR_BUFFER_SIZE,
  443. NULL);
  444. return buff;
  445. }
  446. #endif /* INCL_WINSOCK_API_PROTOTYPES */
  447. typedef int socklen_t;
  448. WINSOCK_API_LINKAGE
  449. int
  450. WSAAPI
  451. getnameinfo(
  452. IN const struct sockaddr FAR * sa,
  453. IN socklen_t salen,
  454. OUT char FAR * host,
  455. IN DWORD hostlen,
  456. OUT char FAR * serv,
  457. IN DWORD servlen,
  458. IN int flags
  459. );
  460. #if INCL_WINSOCK_API_TYPEDEFS
  461. typedef
  462. int
  463. (WSAAPI * LPFN_GETNAMEINFO)(
  464. IN const struct sockaddr FAR * sa,
  465. IN socklen_t salen,
  466. OUT char FAR * host,
  467. IN DWORD hostlen,
  468. OUT char FAR * serv,
  469. IN DWORD servlen,
  470. IN int flags
  471. );
  472. #endif
  473. #define NI_MAXHOST 1025 /* Max size of a fully-qualified domain name */
  474. #define NI_MAXSERV 32 /* Max size of a service name */
  475. //
  476. // Maximum length of address literals (potentially including a port number)
  477. // generated by any address-to-string conversion routine. This length can
  478. // be used when declaring buffers used with getnameinfo, WSAAddressToString,
  479. // inet_ntoa, etc. We just provide one define, rather than one per api,
  480. // to avoid confusion.
  481. //
  482. // The totals are derived from the following data:
  483. // 15: IPv4 address
  484. // 45: IPv6 address including embedded IPv4 address
  485. // 11: Scope Id
  486. // 2: Brackets around IPv6 address when port is present
  487. // 6: Port (including colon)
  488. // 1: Terminating null byte
  489. //
  490. #define INET_ADDRSTRLEN 22
  491. #define INET6_ADDRSTRLEN 65
  492. /* Flags for getnameinfo() */
  493. #define NI_NOFQDN 0x01 /* Only return nodename portion for local hosts */
  494. #define NI_NUMERICHOST 0x02 /* Return numeric form of the host's address */
  495. #define NI_NAMEREQD 0x04 /* Error if the host's name not in DNS */
  496. #define NI_NUMERICSERV 0x08 /* Return numeric form of the service (port #) */
  497. #define NI_DGRAM 0x10 /* Service is a datagram service */
  498. #ifdef __cplusplus
  499. }
  500. #endif
  501. //
  502. // Unless the build environment is explicitly targeting only
  503. // platforms that include built-in getaddrinfo() support, include
  504. // the backwards-compatibility version of the relevant APIs.
  505. //
  506. #if !defined(_WIN32_WINNT) || (_WIN32_WINNT <= 0x0500)
  507. #include <wspiapi.h>
  508. #endif
  509. #endif /* _WS2TCPIP_H_ */