blob: a38ccdaf01ff935bfc4dc1f7838e958a1109708f [file] [log] [blame]
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00001/*
2 * Copyright (C) 2001 Francois Gouget
3 *
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.
8 *
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.
13 *
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
Jonathan Ernst360a3f92006-05-18 14:49:52 +020016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard0799c1a2002-03-09 23:29:33 +000017 */
18
Francois Gouget27202312001-11-14 21:26:23 +000019#ifndef __WS2TCPIP__
20#define __WS2TCPIP__
21
Rob Shearman1cef5dc2008-01-02 22:53:58 +000022#include <winsock2.h>
23/* FIXME: #include <ws2ipdef.h> */
24#include <limits.h>
25
Francois Gouget27202312001-11-14 21:26:23 +000026#ifdef USE_WS_PREFIX
27#define WS(x) WS_##x
28#else
29#define WS(x) x
30#endif
31
32/* FIXME: This gets defined by some Unix (Linux) header and messes things */
33#undef s6_addr
34
Vijay Kiran Kamuju67792892005-09-21 09:41:22 +000035/* for addrinfo calls */
36typedef struct WS(addrinfo)
37{
38 int ai_flags;
39 int ai_family;
40 int ai_socktype;
41 int ai_protocol;
42 size_t ai_addrlen;
43 char * ai_canonname;
44 struct WS(sockaddr)* ai_addr;
45 struct WS(addrinfo)* ai_next;
46} ADDRINFOA, *PADDRINFOA;
47
48typedef struct WS(addrinfoW)
49{
50 int ai_flags;
51 int ai_family;
52 int ai_socktype;
53 int ai_protocol;
54 size_t ai_addrlen;
55 PWSTR ai_canonname;
56 struct WS(sockaddr)* ai_addr;
57 struct WS(addrinfoW)* ai_next;
58} ADDRINFOW, *PADDRINFOW;
59
Robert Shearman264503d2006-07-13 13:06:30 +010060typedef int WS(socklen_t);
61
Francois Gouget482df922005-11-23 19:43:50 +010062typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
Vijay Kiran Kamuju67792892005-09-21 09:41:22 +000063
Francois Gougetff915d42004-03-31 19:58:46 +000064/*
65 * Multicast group information
66 */
67
68struct WS(ip_mreq)
69{
70 struct WS(in_addr) imr_multiaddr;
71 struct WS(in_addr) imr_interface;
72};
73
74struct WS(ip_mreq_source) {
75 struct WS(in_addr) imr_multiaddr;
76 struct WS(in_addr) imr_sourceaddr;
77 struct WS(in_addr) imr_interface;
78};
79
80struct WS(ip_msfilter) {
81 struct WS(in_addr) imsf_multiaddr;
82 struct WS(in_addr) imsf_interface;
Rob Shearmand82e36f2008-10-01 11:20:09 +010083 WS(u_long) imsf_fmode;
84 WS(u_long) imsf_numsrc;
Francois Gougetff915d42004-03-31 19:58:46 +000085 struct WS(in_addr) imsf_slist[1];
86};
87
Francois Gouget27202312001-11-14 21:26:23 +000088typedef struct WS(in_addr6)
89{
Rob Shearmand82e36f2008-10-01 11:20:09 +010090 WS(u_char) s6_addr[16]; /* IPv6 address */
Francois Gouget27202312001-11-14 21:26:23 +000091} IN6_ADDR, *PIN6_ADDR, *LPIN6_ADDR;
92
93typedef struct WS(sockaddr_in6)
94{
95 short sin6_family; /* AF_INET6 */
Rob Shearmand82e36f2008-10-01 11:20:09 +010096 WS(u_short) sin6_port; /* Transport level port number */
97 WS(u_long) sin6_flowinfo; /* IPv6 flow information */
Francois Gouget27202312001-11-14 21:26:23 +000098 struct WS(in_addr6) sin6_addr; /* IPv6 address */
Rob Shearmand82e36f2008-10-01 11:20:09 +010099 WS(u_long) sin6_scope_id; /* IPv6 scope id */
Francois Gouget27202312001-11-14 21:26:23 +0000100} SOCKADDR_IN6,*PSOCKADDR_IN6, *LPSOCKADDR_IN6;
101
Marcus Meissneraa730cc2005-11-16 11:21:57 +0000102typedef struct WS(sockaddr_in6_old)
103{
104 short sin6_family; /* AF_INET6 */
Rob Shearmand82e36f2008-10-01 11:20:09 +0100105 WS(u_short) sin6_port; /* Transport level port number */
106 WS(u_long) sin6_flowinfo; /* IPv6 flow information */
Marcus Meissneraa730cc2005-11-16 11:21:57 +0000107 struct WS(in_addr6) sin6_addr; /* IPv6 address */
108} SOCKADDR_IN6_OLD,*PSOCKADDR_IN6_OLD, *LPSOCKADDR_IN6_OLD;
109
Francois Gouget27202312001-11-14 21:26:23 +0000110typedef union sockaddr_gen
111{
112 struct WS(sockaddr) Address;
113 struct WS(sockaddr_in) AddressIn;
Marcus Meissneraa730cc2005-11-16 11:21:57 +0000114 struct WS(sockaddr_in6_old) AddressIn6;
Francois Gouget27202312001-11-14 21:26:23 +0000115} WS(sockaddr_gen);
116
117/* Structure to keep interface specific information */
118typedef struct _INTERFACE_INFO
119{
Rob Shearmand82e36f2008-10-01 11:20:09 +0100120 WS(u_long) iiFlags; /* Interface flags */
Francois Gouget27202312001-11-14 21:26:23 +0000121 WS(sockaddr_gen) iiAddress; /* Interface address */
122 WS(sockaddr_gen) iiBroadcastAddress; /* Broadcast address */
123 WS(sockaddr_gen) iiNetmask; /* Network mask */
124} INTERFACE_INFO, * LPINTERFACE_INFO;
125
126/* Possible flags for the iiFlags - bitmask */
127#ifndef USE_WS_PREFIX
128#define IFF_UP 0x00000001 /* Interface is up */
129#define IFF_BROADCAST 0x00000002 /* Broadcast is supported */
130#define IFF_LOOPBACK 0x00000004 /* this is loopback interface */
131#define IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
132#define IFF_MULTICAST 0x00000010 /* multicast is supported */
133#else
134#define WS_IFF_UP 0x00000001 /* Interface is up */
135#define WS_IFF_BROADCAST 0x00000002 /* Broadcast is supported */
136#define WS_IFF_LOOPBACK 0x00000004 /* this is loopback interface */
137#define WS_IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
138#define WS_IFF_MULTICAST 0x00000010 /* multicast is supported */
139#endif /* USE_WS_PREFIX */
140
Mike Hearnceb86a92003-04-04 22:04:47 +0000141#ifndef USE_WS_PREFIX
Francois Gouget482df922005-11-23 19:43:50 +0100142#define IP_OPTIONS 1
143#define IP_HDRINCL 2
144#define IP_TOS 3
145#define IP_TTL 4
146#define IP_MULTICAST_IF 9
147#define IP_MULTICAST_TTL 10
148#define IP_MULTICAST_LOOP 11
149#define IP_ADD_MEMBERSHIP 12
150#define IP_DROP_MEMBERSHIP 13
151#define IP_DONTFRAGMENT 14
152#define IP_ADD_SOURCE_MEMBERSHIP 15
153#define IP_DROP_SOURCE_MEMBERSHIP 16
154#define IP_BLOCK_SOURCE 17
155#define IP_UNBLOCK_SOURCE 18
156#define IP_PKTINFO 19
157#define IP_RECEIVE_BROADCAST 22
Mike Hearnceb86a92003-04-04 22:04:47 +0000158#else
Francois Gouget482df922005-11-23 19:43:50 +0100159#define WS_IP_OPTIONS 1
160#define WS_IP_HDRINCL 2
161#define WS_IP_TOS 3
162#define WS_IP_TTL 4
163#define WS_IP_MULTICAST_IF 9
164#define WS_IP_MULTICAST_TTL 10
165#define WS_IP_MULTICAST_LOOP 11
166#define WS_IP_ADD_MEMBERSHIP 12
167#define WS_IP_DROP_MEMBERSHIP 13
168#define WS_IP_DONTFRAGMENT 14
169#define WS_IP_ADD_SOURCE_MEMBERSHIP 15
170#define WS_IP_DROP_SOURCE_MEMBERSHIP 16
171#define WS_IP_BLOCK_SOURCE 17
172#define WS_IP_UNBLOCK_SOURCE 18
173#define WS_IP_PKTINFO 19
174#define WS_IP_RECEIVE_BROADCAST 22
Mike Hearnceb86a92003-04-04 22:04:47 +0000175#endif /* USE_WS_PREFIX */
176
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000177/* Possible Windows flags for getaddrinfo() */
178#ifndef USE_WS_PREFIX
179# define AI_PASSIVE 0x0001
180# define AI_CANONNAME 0x0002
181# define AI_NUMERICHOST 0x0004
182/* getaddrinfo error codes */
183# define EAI_AGAIN WSATRY_AGAIN
184# define EAI_BADFLAGS WSAEINVAL
185# define EAI_FAIL WSANO_RECOVERY
186# define EAI_FAMILY WSAEAFNOSUPPORT
187# define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
Marcus Meissner8e203742005-12-12 11:55:33 +0100188# define EAI_NODATA EAI_NONAME
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000189# define EAI_NONAME WSAHOST_NOT_FOUND
190# define EAI_SERVICE WSATYPE_NOT_FOUND
191# define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
192#else
193# define WS_AI_PASSIVE 0x0001
194# define WS_AI_CANONNAME 0x0002
195# define WS_AI_NUMERICHOST 0x0004
196/* getaddrinfo error codes */
197# define WS_EAI_AGAIN WSATRY_AGAIN
198# define WS_EAI_BADFLAGS WSAEINVAL
199# define WS_EAI_FAIL WSANO_RECOVERY
200# define WS_EAI_FAMILY WSAEAFNOSUPPORT
201# define WS_EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
Marcus Meissner8e203742005-12-12 11:55:33 +0100202# define WS_EAI_NODATA WS_EAI_NONAME
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000203# define WS_EAI_NONAME WSAHOST_NOT_FOUND
204# define WS_EAI_SERVICE WSATYPE_NOT_FOUND
205# define WS_EAI_SOCKTYPE WSAESOCKTNOSUPPORT
206#endif
207
Robert Shearman264503d2006-07-13 13:06:30 +0100208/* Possible Windows flags for getnameinfo() */
209#ifndef USE_WS_PREFIX
210# define NI_NOFQDN 0x01
211# define NI_NUMERICHOST 0x02
212# define NI_NAMEREQD 0x04
213# define NI_NUMERICSERV 0x08
214# define NI_DGRAM 0x10
215#else
216# define WS_NI_NOFQDN 0x01
217# define WS_NI_NUMERICHOST 0x02
218# define WS_NI_NAMEREQD 0x04
219# define WS_NI_NUMERICSERV 0x08
220# define WS_NI_DGRAM 0x10
221#endif
222
Francois Gouget482df922005-11-23 19:43:50 +0100223
224#ifdef __cplusplus
225extern "C" {
226#endif
227
228void WINAPI WS(freeaddrinfo)(LPADDRINFO);
229#define FreeAddrInfoA WS(freeaddrinfo)
230void WINAPI FreeAddrInfoW(PADDRINFOW);
231#define FreeAddrInfo WINELIB_NAME_AW(FreeAddrInfo)
232int WINAPI WS(getaddrinfo)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
233#define GetAddrInfoA WS(getaddrinfo)
234int WINAPI GetAddrInfoW(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
235#define GetAddrInfo WINELIB_NAME_AW(GetAddrInfo)
Robert Shearman264503d2006-07-13 13:06:30 +0100236int WINAPI WS(getnameinfo)(const SOCKADDR*,WS(socklen_t),PCHAR,DWORD,PCHAR,DWORD,INT);
Francois Gouget482df922005-11-23 19:43:50 +0100237#define GetNameInfoA WS(getnameinfo)
Robert Shearman264503d2006-07-13 13:06:30 +0100238INT WINAPI GetNameInfoW(const SOCKADDR*,WS(socklen_t),PWCHAR,DWORD,PWCHAR,DWORD,INT);
Francois Gouget482df922005-11-23 19:43:50 +0100239#define GetNameInfo WINELIB_NAME_AW(GetNameInfo)
Francois Gougetb092b902008-12-08 09:28:02 +0100240PCSTR WINAPI WS(inet_ntop)(INT,PVOID,PSTR,size_t);
241#define InetNtopA WS(inet_ntop)
242PCWSTR WINAPI InetNtopW(INT,PVOID,PWSTR,size_t);
243#define InetNtop WINELIB_NAME_AW(InetNtop)
244int WINAPI WS(inet_pton)(INT,PCSTR,PVOID);
245#define InetPtonA WS(inet_pton)
246int WINAPI InetPtonW(INT,PCWSTR,PVOID);
247#define InetPton WINELIB_NAME_AW(InetPton)
Francois Gouget482df922005-11-23 19:43:50 +0100248
249/*
250 * Ws2tcpip Function Typedefs
251 *
252 * Remember to keep this section in sync with the
253 * prototypes above.
254 */
255#if INCL_WINSOCK_API_TYPEDEFS
256
257typedef void (WINAPI *LPFN_FREEADDRINFO)(LPADDRINFO);
258#define LPFN_FREEADDRINFOA LPFN_FREEADDRINFO
259typedef void (WINAPI *LPFN_FREEADDRINFOW)(PADDRINFOW);
260#define LPFN_FREEADDRINFOT WINELIB_NAME_AW(LPFN_FREEADDRINFO)
261typedef int (WINAPI *LPFN_GETADDRINFO)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
262#define LPFN_GETADDRINFOA LPFN_GETADDRINFO
263typedef int (WINAPI *LPFN_GETADDRINFOW)(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
264#define LPFN_GETADDRINFOT WINELIB_NAME_AW(LPFN_GETADDRINFO)
265typedef int (WINAPI *LPFN_GETNAMEINFO)(const struct sockaddr*,socklen_t,char*,DWORD,char*,DWORD,int);
266#define LPFN_GETNAMEINFOA LPFN_GETNAMEINFO
267typedef int (WINAPI *LPFN_GETNAMEINFOW)(const SOCKADDR*,socklen_t,PWCHAR,DWORD,PWCHAR,DWORD,INT);
268#define LPFN_GETNAMEINFOT WINELIB_NAME_AW(LPFN_GETNAMEINFO)
269
270#endif
271
272#ifdef __cplusplus
273}
274#endif
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000275
Francois Gouget27202312001-11-14 21:26:23 +0000276#endif /* __WS2TCPIP__ */