blob: 90a224b6c94af92f68df6e2df2b8300511cf8803 [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
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
Francois Gouget27202312001-11-14 21:26:23 +000019#ifndef __WS2TCPIP__
20#define __WS2TCPIP__
21
22#ifdef USE_WS_PREFIX
23#define WS(x) WS_##x
24#else
25#define WS(x) x
26#endif
27
28/* FIXME: This gets defined by some Unix (Linux) header and messes things */
29#undef s6_addr
30
Vijay Kiran Kamuju67792892005-09-21 09:41:22 +000031/* for addrinfo calls */
32typedef struct WS(addrinfo)
33{
34 int ai_flags;
35 int ai_family;
36 int ai_socktype;
37 int ai_protocol;
38 size_t ai_addrlen;
39 char * ai_canonname;
40 struct WS(sockaddr)* ai_addr;
41 struct WS(addrinfo)* ai_next;
42} ADDRINFOA, *PADDRINFOA;
43
44typedef struct WS(addrinfoW)
45{
46 int ai_flags;
47 int ai_family;
48 int ai_socktype;
49 int ai_protocol;
50 size_t ai_addrlen;
51 PWSTR ai_canonname;
52 struct WS(sockaddr)* ai_addr;
53 struct WS(addrinfoW)* ai_next;
54} ADDRINFOW, *PADDRINFOW;
55
Francois Gouget482df922005-11-23 19:43:50 +010056typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
Vijay Kiran Kamuju67792892005-09-21 09:41:22 +000057
Francois Gougetff915d42004-03-31 19:58:46 +000058/*
59 * Multicast group information
60 */
61
62struct WS(ip_mreq)
63{
64 struct WS(in_addr) imr_multiaddr;
65 struct WS(in_addr) imr_interface;
66};
67
68struct WS(ip_mreq_source) {
69 struct WS(in_addr) imr_multiaddr;
70 struct WS(in_addr) imr_sourceaddr;
71 struct WS(in_addr) imr_interface;
72};
73
74struct WS(ip_msfilter) {
75 struct WS(in_addr) imsf_multiaddr;
76 struct WS(in_addr) imsf_interface;
77 u_long imsf_fmode;
78 u_long imsf_numsrc;
79 struct WS(in_addr) imsf_slist[1];
80};
81
Francois Gouget27202312001-11-14 21:26:23 +000082typedef struct WS(in_addr6)
83{
84 u_char s6_addr[16]; /* IPv6 address */
85} IN6_ADDR, *PIN6_ADDR, *LPIN6_ADDR;
86
Marcus Meissneraa730cc2005-11-16 11:21:57 +000087/* check for sockaddr_in6 / sockaddr_in6_old madness:
88 * http://msdn.microsoft.com/library/en-us/winsock/winsock/sockaddr_2.asp
89 */
Francois Gouget27202312001-11-14 21:26:23 +000090typedef struct WS(sockaddr_in6)
91{
92 short sin6_family; /* AF_INET6 */
93 u_short sin6_port; /* Transport level port number */
94 u_long sin6_flowinfo; /* IPv6 flow information */
95 struct WS(in_addr6) sin6_addr; /* IPv6 address */
Marcus Meissneraa730cc2005-11-16 11:21:57 +000096 u_long sin6_scope_id; /* IPv6 scope id */
Francois Gouget27202312001-11-14 21:26:23 +000097} SOCKADDR_IN6,*PSOCKADDR_IN6, *LPSOCKADDR_IN6;
98
Marcus Meissneraa730cc2005-11-16 11:21:57 +000099typedef struct WS(sockaddr_in6_old)
100{
101 short sin6_family; /* AF_INET6 */
102 u_short sin6_port; /* Transport level port number */
103 u_long sin6_flowinfo; /* IPv6 flow information */
104 struct WS(in_addr6) sin6_addr; /* IPv6 address */
105} SOCKADDR_IN6_OLD,*PSOCKADDR_IN6_OLD, *LPSOCKADDR_IN6_OLD;
106
Francois Gouget27202312001-11-14 21:26:23 +0000107typedef union sockaddr_gen
108{
109 struct WS(sockaddr) Address;
110 struct WS(sockaddr_in) AddressIn;
Marcus Meissneraa730cc2005-11-16 11:21:57 +0000111 struct WS(sockaddr_in6_old) AddressIn6;
Francois Gouget27202312001-11-14 21:26:23 +0000112} WS(sockaddr_gen);
113
114/* Structure to keep interface specific information */
115typedef struct _INTERFACE_INFO
116{
117 u_long iiFlags; /* Interface flags */
118 WS(sockaddr_gen) iiAddress; /* Interface address */
119 WS(sockaddr_gen) iiBroadcastAddress; /* Broadcast address */
120 WS(sockaddr_gen) iiNetmask; /* Network mask */
121} INTERFACE_INFO, * LPINTERFACE_INFO;
122
123/* Possible flags for the iiFlags - bitmask */
124#ifndef USE_WS_PREFIX
125#define IFF_UP 0x00000001 /* Interface is up */
126#define IFF_BROADCAST 0x00000002 /* Broadcast is supported */
127#define IFF_LOOPBACK 0x00000004 /* this is loopback interface */
128#define IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
129#define IFF_MULTICAST 0x00000010 /* multicast is supported */
130#else
131#define WS_IFF_UP 0x00000001 /* Interface is up */
132#define WS_IFF_BROADCAST 0x00000002 /* Broadcast is supported */
133#define WS_IFF_LOOPBACK 0x00000004 /* this is loopback interface */
134#define WS_IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */
135#define WS_IFF_MULTICAST 0x00000010 /* multicast is supported */
136#endif /* USE_WS_PREFIX */
137
Mike Hearnceb86a92003-04-04 22:04:47 +0000138#ifndef USE_WS_PREFIX
Francois Gouget482df922005-11-23 19:43:50 +0100139#define IP_OPTIONS 1
140#define IP_HDRINCL 2
141#define IP_TOS 3
142#define IP_TTL 4
143#define IP_MULTICAST_IF 9
144#define IP_MULTICAST_TTL 10
145#define IP_MULTICAST_LOOP 11
146#define IP_ADD_MEMBERSHIP 12
147#define IP_DROP_MEMBERSHIP 13
148#define IP_DONTFRAGMENT 14
149#define IP_ADD_SOURCE_MEMBERSHIP 15
150#define IP_DROP_SOURCE_MEMBERSHIP 16
151#define IP_BLOCK_SOURCE 17
152#define IP_UNBLOCK_SOURCE 18
153#define IP_PKTINFO 19
154#define IP_RECEIVE_BROADCAST 22
Mike Hearnceb86a92003-04-04 22:04:47 +0000155#else
Francois Gouget482df922005-11-23 19:43:50 +0100156#define WS_IP_OPTIONS 1
157#define WS_IP_HDRINCL 2
158#define WS_IP_TOS 3
159#define WS_IP_TTL 4
160#define WS_IP_MULTICAST_IF 9
161#define WS_IP_MULTICAST_TTL 10
162#define WS_IP_MULTICAST_LOOP 11
163#define WS_IP_ADD_MEMBERSHIP 12
164#define WS_IP_DROP_MEMBERSHIP 13
165#define WS_IP_DONTFRAGMENT 14
166#define WS_IP_ADD_SOURCE_MEMBERSHIP 15
167#define WS_IP_DROP_SOURCE_MEMBERSHIP 16
168#define WS_IP_BLOCK_SOURCE 17
169#define WS_IP_UNBLOCK_SOURCE 18
170#define WS_IP_PKTINFO 19
171#define WS_IP_RECEIVE_BROADCAST 22
Mike Hearnceb86a92003-04-04 22:04:47 +0000172#endif /* USE_WS_PREFIX */
173
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000174/* Possible Windows flags for getaddrinfo() */
175#ifndef USE_WS_PREFIX
176# define AI_PASSIVE 0x0001
177# define AI_CANONNAME 0x0002
178# define AI_NUMERICHOST 0x0004
179/* getaddrinfo error codes */
180# define EAI_AGAIN WSATRY_AGAIN
181# define EAI_BADFLAGS WSAEINVAL
182# define EAI_FAIL WSANO_RECOVERY
183# define EAI_FAMILY WSAEAFNOSUPPORT
184# define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
Marcus Meissner8e203742005-12-12 11:55:33 +0100185# define EAI_NODATA EAI_NONAME
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000186# define EAI_NONAME WSAHOST_NOT_FOUND
187# define EAI_SERVICE WSATYPE_NOT_FOUND
188# define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
189#else
190# define WS_AI_PASSIVE 0x0001
191# define WS_AI_CANONNAME 0x0002
192# define WS_AI_NUMERICHOST 0x0004
193/* getaddrinfo error codes */
194# define WS_EAI_AGAIN WSATRY_AGAIN
195# define WS_EAI_BADFLAGS WSAEINVAL
196# define WS_EAI_FAIL WSANO_RECOVERY
197# define WS_EAI_FAMILY WSAEAFNOSUPPORT
198# define WS_EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
Marcus Meissner8e203742005-12-12 11:55:33 +0100199# define WS_EAI_NODATA WS_EAI_NONAME
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000200# define WS_EAI_NONAME WSAHOST_NOT_FOUND
201# define WS_EAI_SERVICE WSATYPE_NOT_FOUND
202# define WS_EAI_SOCKTYPE WSAESOCKTNOSUPPORT
203#endif
204
Francois Gouget482df922005-11-23 19:43:50 +0100205
206#ifdef __cplusplus
207extern "C" {
208#endif
209
210void WINAPI WS(freeaddrinfo)(LPADDRINFO);
211#define FreeAddrInfoA WS(freeaddrinfo)
212void WINAPI FreeAddrInfoW(PADDRINFOW);
213#define FreeAddrInfo WINELIB_NAME_AW(FreeAddrInfo)
214int WINAPI WS(getaddrinfo)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
215#define GetAddrInfoA WS(getaddrinfo)
216int WINAPI GetAddrInfoW(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
217#define GetAddrInfo WINELIB_NAME_AW(GetAddrInfo)
218int WINAPI WS(getnameinfo)(const struct sockaddr*,socklen_t,char*,DWORD,char*,DWORD,int);
219#define GetNameInfoA WS(getnameinfo)
220INT WINAPI GetNameInfoW(const SOCKADDR*,socklen_t,PWCHAR,DWORD,PWCHAR,DWORD,INT);
221#define GetNameInfo WINELIB_NAME_AW(GetNameInfo)
222
223/*
224 * Ws2tcpip Function Typedefs
225 *
226 * Remember to keep this section in sync with the
227 * prototypes above.
228 */
229#if INCL_WINSOCK_API_TYPEDEFS
230
231typedef void (WINAPI *LPFN_FREEADDRINFO)(LPADDRINFO);
232#define LPFN_FREEADDRINFOA LPFN_FREEADDRINFO
233typedef void (WINAPI *LPFN_FREEADDRINFOW)(PADDRINFOW);
234#define LPFN_FREEADDRINFOT WINELIB_NAME_AW(LPFN_FREEADDRINFO)
235typedef int (WINAPI *LPFN_GETADDRINFO)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
236#define LPFN_GETADDRINFOA LPFN_GETADDRINFO
237typedef int (WINAPI *LPFN_GETADDRINFOW)(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
238#define LPFN_GETADDRINFOT WINELIB_NAME_AW(LPFN_GETADDRINFO)
239typedef int (WINAPI *LPFN_GETNAMEINFO)(const struct sockaddr*,socklen_t,char*,DWORD,char*,DWORD,int);
240#define LPFN_GETNAMEINFOA LPFN_GETNAMEINFO
241typedef int (WINAPI *LPFN_GETNAMEINFOW)(const SOCKADDR*,socklen_t,PWCHAR,DWORD,PWCHAR,DWORD,INT);
242#define LPFN_GETNAMEINFOT WINELIB_NAME_AW(LPFN_GETNAMEINFO)
243
244#endif
245
246#ifdef __cplusplus
247}
248#endif
Marcus Meissner7a6fdea2005-11-17 12:58:35 +0000249
Francois Gouget27202312001-11-14 21:26:23 +0000250#endif /* __WS2TCPIP__ */