xmllite: Add __WINE_ALLOC_SIZE attributes to heap_xxx() functions.
[wine.git] / include / ws2def.h
blobfa21c06b50378fde2f56821efbe942eb7d2160cd
1 /*
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
19 #ifndef _WS2DEF_
20 #define _WS2DEF_
22 #include <inaddr.h>
24 #ifdef USE_WS_PREFIX
25 #define WS(x) WS_##x
26 #else
27 #define WS(x) x
28 #endif
30 typedef USHORT ADDRESS_FAMILY;
32 #ifndef __CSADDR_DEFINED__
33 #define __CSADDR_DEFINED__
35 typedef struct _SOCKET_ADDRESS {
36 LPSOCKADDR lpSockaddr;
37 INT iSockaddrLength;
38 } SOCKET_ADDRESS, *PSOCKET_ADDRESS, *LPSOCKET_ADDRESS;
40 typedef struct _CSADDR_INFO {
41 SOCKET_ADDRESS LocalAddr;
42 SOCKET_ADDRESS RemoteAddr;
43 INT iSocketType;
44 INT iProtocol;
45 } CSADDR_INFO, *PCSADDR_INFO, *LPCSADDR_INFO;
46 #endif
48 #ifdef USE_WS_PREFIX
49 #define WS__SS_MAXSIZE 128
50 #define WS__SS_ALIGNSIZE (sizeof(__int64))
51 #define WS__SS_PAD1SIZE (WS__SS_ALIGNSIZE - sizeof(short))
52 #define WS__SS_PAD2SIZE (WS__SS_MAXSIZE - 2 * WS__SS_ALIGNSIZE)
53 #else
54 #define _SS_MAXSIZE 128
55 #define _SS_ALIGNSIZE (sizeof(__int64))
56 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(short))
57 #define _SS_PAD2SIZE (_SS_MAXSIZE - 2 * _SS_ALIGNSIZE)
58 #endif
60 typedef struct WS(sockaddr_storage) {
61 short ss_family;
62 char __ss_pad1[WS(_SS_PAD1SIZE)];
63 __int64 DECLSPEC_ALIGN(8) __ss_align;
64 char __ss_pad2[WS(_SS_PAD2SIZE)];
65 } SOCKADDR_STORAGE, *PSOCKADDR_STORAGE, *LPSOCKADDR_STORAGE;
67 /*socket address list */
68 typedef struct _SOCKET_ADDRESS_LIST {
69 INT iAddressCount;
70 SOCKET_ADDRESS Address[1];
71 } SOCKET_ADDRESS_LIST, *LPSOCKET_ADDRESS_LIST;
73 typedef enum {
74 ScopeLevelInterface = 1,
75 ScopeLevelLink = 2,
76 ScopeLevelSubnet = 3,
77 ScopeLevelAdmin = 4,
78 ScopeLevelSite = 5,
79 ScopeLevelOrganization = 8,
80 ScopeLevelGlobal = 14
81 } SCOPE_LEVEL;
83 typedef struct
85 union {
86 struct {
87 ULONG Zone : 28;
88 ULONG Level : 4;
89 } DUMMYSTRUCTNAME;
90 ULONG Value;
91 } DUMMYUNIONNAME;
92 } SCOPE_ID, *PSCOPE_ID;
94 typedef struct _WSABUF
96 ULONG len;
97 CHAR* buf;
98 } WSABUF, *LPWSABUF;
100 typedef struct _WSAMSG {
101 LPSOCKADDR name;
102 INT namelen;
103 LPWSABUF lpBuffers;
104 DWORD dwBufferCount;
105 WSABUF Control;
106 DWORD dwFlags;
107 } WSAMSG, *PWSAMSG, *LPWSAMSG;
110 * Macros for retrieving control message data returned by WSARecvMsg()
112 #define WSA_CMSG_DATA(cmsg) ((UCHAR*)((WSACMSGHDR*)(cmsg)+1))
113 #define WSA_CMSG_FIRSTHDR(mhdr) ((mhdr)->Control.len >= sizeof(WSACMSGHDR) ? (WSACMSGHDR *) (mhdr)->Control.buf : (WSACMSGHDR *) 0)
114 #define WSA_CMSG_ALIGN(len) (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))
116 * Next Header: If the response is too short (or the next message in the response
117 * is too short) then return NULL, otherwise return the next control message.
119 #define WSA_CMSG_NXTHDR(mhdr,cmsg) \
120 (!(cmsg) ? WSA_CMSG_FIRSTHDR(mhdr) : \
121 ((mhdr)->Control.len < sizeof(WSACMSGHDR) ? NULL : \
122 (((unsigned char*)(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))+1) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
123 (((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 : \
124 (WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len))))))
126 typedef struct addrinfoexA {
127 int ai_flags;
128 int ai_family;
129 int ai_socktype;
130 int ai_protocol;
131 SIZE_T ai_addrlen;
132 char *ai_canonname;
133 struct WS(sockaddr) *ai_addr;
134 void *ai_blob;
135 SIZE_T ai_bloblen;
136 GUID *ai_provider;
137 struct addrinfoexA *ai_next;
138 } ADDRINFOEXA, *PADDRINFOEXA, *LPADDRINFOEXA;
140 typedef struct addrinfoexW {
141 int ai_flags;
142 int ai_family;
143 int ai_socktype;
144 int ai_protocol;
145 SIZE_T ai_addrlen;
146 WCHAR *ai_canonname;
147 struct WS(sockaddr) *ai_addr;
148 void *ai_blob;
149 SIZE_T ai_bloblen;
150 GUID *ai_provider;
151 struct addrinfoexW *ai_next;
152 } ADDRINFOEXW, *PADDRINFOEXW, *LPADDRINFOEXW;
154 #endif /* _WS2DEF_ */