msscript: Implement some connection point methods.
[wine.git] / include / ws2def.h
blobcbd6f741fce2c1f90e9fee1953dea666f030c8b0
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 #ifndef __CSADDR_DEFINED__
31 #define __CSADDR_DEFINED__
33 typedef struct _SOCKET_ADDRESS {
34 LPSOCKADDR lpSockaddr;
35 INT iSockaddrLength;
36 } SOCKET_ADDRESS, *PSOCKET_ADDRESS, *LPSOCKET_ADDRESS;
38 typedef struct _CSADDR_INFO {
39 SOCKET_ADDRESS LocalAddr;
40 SOCKET_ADDRESS RemoteAddr;
41 INT iSocketType;
42 INT iProtocol;
43 } CSADDR_INFO, *PCSADDR_INFO, *LPCSADDR_INFO;
44 #endif
46 #ifdef USE_WS_PREFIX
47 #define WS__SS_MAXSIZE 128
48 #define WS__SS_ALIGNSIZE (sizeof(__int64))
49 #define WS__SS_PAD1SIZE (WS__SS_ALIGNSIZE - sizeof(short))
50 #define WS__SS_PAD2SIZE (WS__SS_MAXSIZE - 2 * WS__SS_ALIGNSIZE)
51 #else
52 #define _SS_MAXSIZE 128
53 #define _SS_ALIGNSIZE (sizeof(__int64))
54 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(short))
55 #define _SS_PAD2SIZE (_SS_MAXSIZE - 2 * _SS_ALIGNSIZE)
56 #endif
58 typedef struct WS(sockaddr_storage) {
59 short ss_family;
60 char __ss_pad1[WS(_SS_PAD1SIZE)];
61 __int64 DECLSPEC_ALIGN(8) __ss_align;
62 char __ss_pad2[WS(_SS_PAD2SIZE)];
63 } SOCKADDR_STORAGE, *PSOCKADDR_STORAGE, *LPSOCKADDR_STORAGE;
65 /*socket address list */
66 typedef struct _SOCKET_ADDRESS_LIST {
67 INT iAddressCount;
68 SOCKET_ADDRESS Address[1];
69 } SOCKET_ADDRESS_LIST, *LPSOCKET_ADDRESS_LIST;
71 typedef enum {
72 ScopeLevelInterface = 1,
73 ScopeLevelLink = 2,
74 ScopeLevelSubnet = 3,
75 ScopeLevelAdmin = 4,
76 ScopeLevelSite = 5,
77 ScopeLevelOrganization = 8,
78 ScopeLevelGlobal = 14
79 } SCOPE_LEVEL;
81 typedef struct _WSABUF
83 ULONG len;
84 CHAR* buf;
85 } WSABUF, *LPWSABUF;
87 typedef struct _WSAMSG {
88 LPSOCKADDR name;
89 INT namelen;
90 LPWSABUF lpBuffers;
91 DWORD dwBufferCount;
92 WSABUF Control;
93 DWORD dwFlags;
94 } WSAMSG, *PWSAMSG, *LPWSAMSG;
97 * Macros for retrieving control message data returned by WSARecvMsg()
99 #define WSA_CMSG_DATA(cmsg) ((UCHAR*)((WSACMSGHDR*)(cmsg)+1))
100 #define WSA_CMSG_FIRSTHDR(mhdr) ((mhdr)->Control.len >= sizeof(WSACMSGHDR) ? (WSACMSGHDR *) (mhdr)->Control.buf : (WSACMSGHDR *) 0)
101 #define WSA_CMSG_ALIGN(len) (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))
103 * Next Header: If the response is too short (or the next message in the response
104 * is too short) then return NULL, otherwise return the next control message.
106 #define WSA_CMSG_NXTHDR(mhdr,cmsg) \
107 (!(cmsg) ? WSA_CMSG_FIRSTHDR(mhdr) : \
108 ((mhdr)->Control.len < sizeof(WSACMSGHDR) ? NULL : \
109 (((unsigned char*)(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))+1) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
110 (((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 : \
111 (WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len))))))
113 typedef struct addrinfoexA {
114 int ai_flags;
115 int ai_family;
116 int ai_socktype;
117 int ai_protocol;
118 SIZE_T ai_addrlen;
119 char *ai_canonname;
120 struct WS(sockaddr) *ai_addr;
121 void *ai_blob;
122 SIZE_T ai_bloblen;
123 GUID *ai_provider;
124 struct addrinfoexA *ai_next;
125 } ADDRINFOEXA, *PADDRINFOEXA, *LPADDRINFOEXA;
127 typedef struct addrinfoexW {
128 int ai_flags;
129 int ai_family;
130 int ai_socktype;
131 int ai_protocol;
132 SIZE_T ai_addrlen;
133 WCHAR *ai_canonname;
134 struct WS(sockaddr) *ai_addr;
135 void *ai_blob;
136 SIZE_T ai_bloblen;
137 GUID *ai_provider;
138 struct addrinfoexW *ai_next;
139 } ADDRINFOEXW, *PADDRINFOEXW, *LPADDRINFOEXW;
141 #endif /* _WS2DEF_ */