2 * Copyright (C) 2009 Robert Shearman
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 typedef USHORT ADDRESS_FAMILY
;
32 typedef struct WS(sockaddr
)
34 unsigned short sa_family
;
36 } SOCKADDR
, *PSOCKADDR
, *LPSOCKADDR
;
57 #define AF_APPLETALK 16
59 #define AF_VOICEVIEW 18
61 #define AF_UNKNOWN1 20
69 #else /* USE_WS_PREFIX */
70 #define WS_AF_UNSPEC 0
73 #define WS_AF_IMPLINK 3
77 #define WS_AF_IPX WS_AF_NS
79 #define WS_AF_OSI WS_AF_ISO
81 #define WS_AF_DATAKIT 9
82 #define WS_AF_CCITT 10
84 #define WS_AF_DECnet 12
87 #define WS_AF_HYLINK 15
88 #define WS_AF_APPLETALK 16
89 #define WS_AF_NETBIOS 17
90 #define WS_AF_VOICEVIEW 18
91 #define WS_AF_FIREFOX 19
92 #define WS_AF_UNKNOWN1 20
95 #define WS_AF_INET6 23
96 #define WS_AF_CLUSTER 24
97 #define WS_AF_12844 25
100 #endif /* USE_WS_PREFIX */
102 #ifndef USE_WS_PREFIX
105 #define WS_IPPROTO_IP 0
110 WS(IPPROTO_ICMP
) = 1,
111 WS(IPPROTO_IGMP
) = 2,
113 WS(IPPROTO_IPV4
) = 4,
115 WS(IPPROTO_UDP
) = 17,
116 WS(IPPROTO_IDP
) = 22,
117 WS(IPPROTO_IPV6
) = 41,
118 WS(IPPROTO_ICMPV6
) = 58,
120 WS(IPPROTO_RAW
) = 255,
121 WS(IPPROTO_MAX
) = 256,
124 #ifndef USE_WS_PREFIX
125 #define INADDR_ANY ((ULONG)0x00000000)
126 #define INADDR_LOOPBACK 0x7f000001
127 #define INADDR_BROADCAST ((ULONG)0xffffffff)
128 #define INADDR_NONE 0xffffffff
130 #define WS_INADDR_ANY ((ULONG)0x00000000)
131 #define WS_INADDR_LOOPBACK 0x7f000001
132 #define WS_INADDR_BROADCAST ((ULONG)0xffffffff)
133 #define WS_INADDR_NONE 0xffffffff
136 #ifndef USE_WS_PREFIX
137 #define IN_CLASSA_NSHIFT 24
138 #define IN_CLASSA_MAX 128
139 #define IN_CLASSA_NET 0xff000000
140 #define IN_CLASSA_HOST 0x00ffffff
141 #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
142 #define IN_CLASSB_NSHIFT 16
143 #define IN_CLASSB_MAX 65536
144 #define IN_CLASSB_NET 0xffff0000
145 #define IN_CLASSB_HOST 0x0000ffff
146 #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
147 #define IN_CLASSC_NSHIFT 8
148 #define IN_CLASSC_NET 0xffffff00
149 #define IN_CLASSC_HOST 0x000000ff
150 #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
152 #define WS_IN_CLASSA_NSHIFT 24
153 #define WS_IN_CLASSA_MAX 128
154 #define WS_IN_CLASSA_NET 0xff000000
155 #define WS_IN_CLASSA_HOST 0x00ffffff
156 #define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
157 #define WS_IN_CLASSB_NSHIFT 16
158 #define WS_IN_CLASSB_MAX 65536
159 #define WS_IN_CLASSB_NET 0xffff0000
160 #define WS_IN_CLASSB_HOST 0x0000ffff
161 #define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
162 #define WS_IN_CLASSC_NSHIFT 8
163 #define WS_IN_CLASSC_NET 0xffffff00
164 #define WS_IN_CLASSC_HOST 0x000000ff
165 #define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
166 #endif /* USE_WS_PREFIX */
168 #ifndef USE_WS_PREFIX
169 #define SO_BSP_STATE 0x1009
170 #define SO_RANDOMIZE_PORT 0x3005
171 #define SO_PORT_SCALABILITY 0x3006
172 #define SO_REUSE_UNICASTPORT 0x3007
173 #define SO_REUSE_MULTICASTPORT 0x3008
174 #define TCP_NODELAY 0x0001
176 #define WS_SO_BSP_STATE 0x1009
177 #define WS_SO_RANDOMIZE_PORT 0x3005
178 #define WS_SO_PORT_SCALABILITY 0x3006
179 #define WS_SO_REUSE_UNICASTPORT 0x3007
180 #define WS_SO_REUSE_MULTICASTPORT 0x3008
181 #define WS_TCP_NODELAY 0x0001
184 typedef struct WS(sockaddr_in
)
187 unsigned short sin_port
;
188 struct WS(in_addr
) sin_addr
;
190 } SOCKADDR_IN
, *PSOCKADDR_IN
, *LPSOCKADDR_IN
;
192 #ifndef __CSADDR_DEFINED__
193 #define __CSADDR_DEFINED__
195 typedef struct _SOCKET_ADDRESS
{
196 LPSOCKADDR lpSockaddr
;
198 } SOCKET_ADDRESS
, *PSOCKET_ADDRESS
, *LPSOCKET_ADDRESS
;
200 typedef struct _CSADDR_INFO
{
201 SOCKET_ADDRESS LocalAddr
;
202 SOCKET_ADDRESS RemoteAddr
;
205 } CSADDR_INFO
, *PCSADDR_INFO
, *LPCSADDR_INFO
;
209 #define WS__SS_MAXSIZE 128
210 #define WS__SS_ALIGNSIZE (sizeof(__int64))
211 #define WS__SS_PAD1SIZE (WS__SS_ALIGNSIZE - sizeof(short))
212 #define WS__SS_PAD2SIZE (WS__SS_MAXSIZE - 2 * WS__SS_ALIGNSIZE)
214 #define _SS_MAXSIZE 128
215 #define _SS_ALIGNSIZE (sizeof(__int64))
216 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(short))
217 #define _SS_PAD2SIZE (_SS_MAXSIZE - 2 * _SS_ALIGNSIZE)
220 typedef struct WS(sockaddr_storage
) {
222 char __ss_pad1
[WS(_SS_PAD1SIZE
)];
223 __int64
DECLSPEC_ALIGN(8) __ss_align
;
224 char __ss_pad2
[WS(_SS_PAD2SIZE
)];
225 } SOCKADDR_STORAGE
, *PSOCKADDR_STORAGE
, *LPSOCKADDR_STORAGE
;
227 /*socket address list */
228 typedef struct _SOCKET_ADDRESS_LIST
{
230 SOCKET_ADDRESS Address
[1];
231 } SOCKET_ADDRESS_LIST
, *LPSOCKET_ADDRESS_LIST
;
234 ScopeLevelInterface
= 1,
236 ScopeLevelSubnet
= 3,
239 ScopeLevelOrganization
= 8,
240 ScopeLevelGlobal
= 14,
241 ScopeLevelCount
= 16,
253 } SCOPE_ID
, *PSCOPE_ID
;
255 typedef struct _WSABUF
261 typedef struct _WSAMSG
{
268 } WSAMSG
, *PWSAMSG
, *LPWSAMSG
;
271 * Macros for retrieving control message data returned by WSARecvMsg()
273 #define WSA_CMSG_DATA(cmsg) ((UCHAR*)((WSACMSGHDR*)(cmsg)+1))
274 #define WSA_CMSG_FIRSTHDR(mhdr) ((mhdr)->Control.len >= sizeof(WSACMSGHDR) ? (WSACMSGHDR *) (mhdr)->Control.buf : (WSACMSGHDR *) 0)
275 #define WSA_CMSG_ALIGN(len) (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))
277 * Next Header: If the response is too short (or the next message in the response
278 * is too short) then return NULL, otherwise return the next control message.
280 #define WSA_CMSG_NXTHDR(mhdr,cmsg) \
281 (!(cmsg) ? WSA_CMSG_FIRSTHDR(mhdr) : \
282 ((mhdr)->Control.len < sizeof(WSACMSGHDR) ? NULL : \
283 (((unsigned char*)(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))+1) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
284 (((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)+WSA_CMSG_ALIGN(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))->cmsg_len) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
285 (WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len))))))
287 #ifndef USE_WS_PREFIX
288 #define AI_DNS_ONLY 0x00000010
290 #define WS_AI_DNS_ONLY 0x00000010
293 typedef struct addrinfoexA
{
300 struct WS(sockaddr
) *ai_addr
;
304 struct addrinfoexA
*ai_next
;
305 } ADDRINFOEXA
, *PADDRINFOEXA
, *LPADDRINFOEXA
;
307 typedef struct addrinfoexW
{
314 struct WS(sockaddr
) *ai_addr
;
318 struct addrinfoexW
*ai_next
;
319 } ADDRINFOEXW
, *PADDRINFOEXW
, *LPADDRINFOEXW
;
321 #endif /* _WS2DEF_ */