ws2ipdef.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /**
  2. * This file is part of the mingw-w64 runtime package.
  3. * No warranty is given; refer to the file DISCLAIMER within this package.
  4. */
  5. #ifndef _WS2IPDEF_
  6. #define _WS2IPDEF_
  7. #include <_mingw_unicode.h>
  8. #include <winapifamily.h>
  9. #ifdef __LP64__
  10. #pragma push_macro("u_long")
  11. #undef u_long
  12. #define u_long __ms_u_long
  13. #endif
  14. #include <in6addr.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /* options at IPPROTO_IP level */
  19. #define IP_OPTIONS 1
  20. #define IP_HDRINCL 2
  21. #define IP_TOS 3
  22. #define IP_TTL 4
  23. #define IP_MULTICAST_IF 9
  24. #define IP_MULTICAST_TTL 10
  25. #define IP_MULTICAST_LOOP 11
  26. #define IP_ADD_MEMBERSHIP 12
  27. #define IP_DROP_MEMBERSHIP 13
  28. #define IP_DONTFRAGMENT 14
  29. #define IP_ADD_SOURCE_MEMBERSHIP 15
  30. #define IP_DROP_SOURCE_MEMBERSHIP 16
  31. #define IP_BLOCK_SOURCE 17
  32. #define IP_UNBLOCK_SOURCE 18
  33. #define IP_PKTINFO 19
  34. #define IP_HOPLIMIT 21
  35. #define IP_RECVTTL 21
  36. #define IP_RECEIVE_BROADCAST 22
  37. #define IP_RECVIF 24
  38. #define IP_RECVDSTADDR 25
  39. #define IP_IFLIST 28
  40. #define IP_ADD_IFLIST 29
  41. #define IP_DEL_IFLIST 30
  42. #define IP_UNICAST_IF 31
  43. #define IP_RTHDR 32
  44. #define IP_GET_IFLIST 33
  45. #define IP_RECVRTHDR 38
  46. #define IP_TCLASS 39
  47. #define IP_RECVTCLASS 40
  48. #define IP_RECVTOS 40
  49. #define IP_ORIGINAL_ARRIVAL_IF 47
  50. #define IP_ECN 50
  51. #define IP_PKTINFO_EX 51
  52. #define IP_WFP_REDIRECT_RECORDS 60
  53. #define IP_WFP_REDIRECT_CONTEXT 70
  54. #define IP_MTU_DISCOVER 71
  55. #define IP_MTU 73
  56. #define IP_NRT_INTERFACE 74
  57. #define IP_RECVERR 75
  58. #define IP_USER_MTU 76
  59. #define IP_UNSPECIFIED_TYPE_OF_SERVICE -1
  60. #define IP_UNSPECIFIED_USER_MTU MAXULONG
  61. #define IPV6_ADDRESS_BITS RTL_BITS_OF(IN6_ADDR)
  62. /* options at IPPROTO_IPV6 level */
  63. #define IPV6_HOPOPTS 1
  64. #define IPV6_HDRINCL 2
  65. #define IPV6_UNICAST_HOPS 4
  66. #define IPV6_MULTICAST_IF 9
  67. #define IPV6_MULTICAST_HOPS 10
  68. #define IPV6_MULTICAST_LOOP 11
  69. #define IPV6_ADD_MEMBERSHIP 12
  70. #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
  71. #define IPV6_DROP_MEMBERSHIP 13
  72. #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
  73. #define IPV6_DONTFRAG 14
  74. #define IPV6_PKTINFO 19
  75. #define IPV6_HOPLIMIT 21
  76. #define IPV6_PROTECTION_LEVEL 23
  77. #define IPV6_RECVIF 24
  78. #define IPV6_RECVDSTADDR 25
  79. #define IPV6_CHECKSUM 26
  80. #define IPV6_V6ONLY 27
  81. #define IPV6_IFLIST 28
  82. #define IPV6_ADD_IFLIST 29
  83. #define IPV6_DEL_IFLIST 30
  84. #define IPV6_UNICAST_IF 31
  85. #define IPV6_RTHDR 32
  86. #define IPV6_GET_IFLIST 33
  87. #define IPV6_RECVRTHDR 38
  88. #define IPV6_TCLASS 39
  89. #define IPV6_RECVTCLASS 40
  90. #define IPV6_ECN 50
  91. #define IPV6_PKTINFO_EX 51
  92. #define IPV6_WFP_REDIRECT_RECORDS 60
  93. #define IPV6_WFP_REDIRECT_CONTEXT 70
  94. #define IPV6_MTU_DISCOVER 71
  95. #define IPV6_MTU 72
  96. #define IPV6_NRT_INTERFACE 74
  97. #define IPV6_RECVERR 75
  98. #define IPV6_USER_MTU 76
  99. #define IP_UNSPECIFIED_HOP_LIMIT -1
  100. #define IP_PROTECTION_LEVEL IPV6_PROTECTION_LEVEL
  101. #define PROTECTION_LEVEL_UNRESTRICTED 10
  102. #define PROTECTION_LEVEL_EDGERESTRICTED 20
  103. #define PROTECTION_LEVEL_RESTRICTED 30
  104. #if NTDDI_VERSION < NTDDI_VISTA
  105. #define PROTECTION_LEVEL_DEFAULT PROTECTION_LEVEL_EDGERESTRICTED
  106. #else
  107. #define PROTECTION_LEVEL_DEFAULT ((UINT)-1)
  108. #endif
  109. typedef struct ipv6_mreq {
  110. struct in6_addr ipv6mr_multiaddr;
  111. unsigned int ipv6mr_interface;
  112. } IPV6_MREQ;
  113. struct sockaddr_in6_old {
  114. short sin6_family;
  115. u_short sin6_port;
  116. u_long sin6_flowinfo;
  117. struct in6_addr sin6_addr;
  118. };
  119. typedef union sockaddr_gen {
  120. struct sockaddr Address;
  121. struct sockaddr_in AddressIn;
  122. struct sockaddr_in6_old AddressIn6;
  123. } sockaddr_gen;
  124. struct sockaddr_in6 {
  125. short sin6_family;
  126. u_short sin6_port;
  127. u_long sin6_flowinfo;
  128. struct in6_addr sin6_addr;
  129. __C89_NAMELESS union {
  130. u_long sin6_scope_id;
  131. SCOPE_ID sin6_scope_struct;
  132. };
  133. };
  134. typedef struct sockaddr_in6 SOCKADDR_IN6;
  135. typedef struct sockaddr_in6 *PSOCKADDR_IN6;
  136. typedef struct sockaddr_in6 *LPSOCKADDR_IN6;
  137. typedef struct _INTERFACE_INFO {
  138. u_long iiFlags;
  139. sockaddr_gen iiAddress;
  140. sockaddr_gen iiBroadcastAddress;
  141. sockaddr_gen iiNetmask;
  142. } INTERFACE_INFO,*LPINTERFACE_INFO;
  143. typedef struct _INTERFACE_INFO_EX {
  144. u_long iiFlags;
  145. SOCKET_ADDRESS iiAddress;
  146. SOCKET_ADDRESS iiBroadcastAddress;
  147. SOCKET_ADDRESS iiNetmask;
  148. } INTERFACE_INFO_EX, *LPINTERFACE_INFO_EX;
  149. #define IFF_UP 0x00000001
  150. #define IFF_BROADCAST 0x00000002
  151. #define IFF_LOOPBACK 0x00000004
  152. #define IFF_POINTTOPOINT 0x00000008
  153. #define IFF_MULTICAST 0x00000010
  154. typedef enum _PMTUD_STATE {
  155. IP_PMTUDISC_NOT_SET,
  156. IP_PMTUDISC_DO,
  157. IP_PMTUDISC_DONT,
  158. IP_PMTUDISC_PROBE,
  159. IP_PMTUDISC_MAX
  160. } PMTUD_STATE, *PPMTUD_STATE;
  161. #define MCAST_JOIN_GROUP 41
  162. #define MCAST_LEAVE_GROUP 42
  163. #define MCAST_BLOCK_SOURCE 43
  164. #define MCAST_UNBLOCK_SOURCE 44
  165. #define MCAST_JOIN_SOURCE_GROUP 45
  166. #define MCAST_LEAVE_SOURCE_GROUP 46
  167. typedef enum _MULTICAST_MODE_TYPE {
  168. MCAST_INCLUDE = 0,
  169. MCAST_EXCLUDE
  170. } MULTICAST_MODE_TYPE;
  171. typedef struct ip_mreq_source {
  172. IN_ADDR imr_multiaddr;
  173. IN_ADDR imr_sourceaddr;
  174. IN_ADDR imr_interface;
  175. } IP_MREQ_SOURCE, *PIP_MREQ_SOURCE;
  176. typedef struct ip_msfilter {
  177. IN_ADDR imsf_multiaddr;
  178. IN_ADDR imsf_interface;
  179. MULTICAST_MODE_TYPE imsf_fmode;
  180. ULONG imsf_numsrc;
  181. IN_ADDR imsf_slist[1];
  182. } IP_MSFILTER, *PIP_MSFILTER;
  183. #define IP_MSFILTER_SIZE(NumSources) (sizeof(IP_MSFILTER) - sizeof(IN_ADDR) + (NumSources) * sizeof(IN_ADDR))
  184. typedef struct _sockaddr_in6_pair {
  185. PSOCKADDR_IN6 SourceAddress;
  186. PSOCKADDR_IN6 DestinationAddress;
  187. } SOCKADDR_IN6_PAIR, *PSOCKADDR_IN6_PAIR;
  188. typedef union _SOCKADDR_INET {
  189. SOCKADDR_IN Ipv4;
  190. SOCKADDR_IN6 Ipv6;
  191. ADDRESS_FAMILY si_family;
  192. } SOCKADDR_INET, *PSOCKADDR_INET;
  193. typedef struct group_filter {
  194. ULONG gf_interface;
  195. SOCKADDR_STORAGE gf_group;
  196. MULTICAST_MODE_TYPE gf_fmode;
  197. ULONG gf_numsrc;
  198. SOCKADDR_STORAGE gf_slist[1];
  199. } GROUP_FILTER, *PGROUP_FILTER;
  200. typedef struct group_req {
  201. ULONG gr_interface;
  202. SOCKADDR_STORAGE gr_group;
  203. } GROUP_REQ, *PGROUP_REQ;
  204. typedef struct group_source_req {
  205. ULONG gsr_interface;
  206. SOCKADDR_STORAGE gsr_group;
  207. SOCKADDR_STORAGE gsr_source;
  208. } GROUP_SOURCE_REQ, *PGROUP_SOURCE_REQ;
  209. #define WS2TCPIP_INLINE __CRT_INLINE
  210. int IN6_ADDR_EQUAL(const struct in6_addr *,const struct in6_addr *);
  211. WS2TCPIP_INLINE int IN6_ADDR_EQUAL(const struct in6_addr *a, const struct in6_addr *b) {
  212. return !memcmp(a, b, sizeof(struct in6_addr));
  213. }
  214. #define IN6_ARE_ADDR_EQUAL IN6_ADDR_EQUAL
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218. #ifdef __LP64__
  219. #pragma pop_macro("u_long")
  220. #endif
  221. #endif /*_WS2IPDEF_ */