2002-03-10 00:29:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 Francois Gouget
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
|
|
|
|
2001-11-14 22:26:23 +01:00
|
|
|
#ifndef __WS2TCPIP__
|
|
|
|
#define __WS2TCPIP__
|
|
|
|
|
2008-01-02 23:53:58 +01:00
|
|
|
#include <winsock2.h>
|
2009-03-31 14:37:49 +02:00
|
|
|
#include <ws2ipdef.h>
|
2008-01-02 23:53:58 +01:00
|
|
|
#include <limits.h>
|
|
|
|
|
2001-11-14 22:26:23 +01:00
|
|
|
#ifdef USE_WS_PREFIX
|
|
|
|
#define WS(x) WS_##x
|
|
|
|
#else
|
|
|
|
#define WS(x) x
|
|
|
|
#endif
|
|
|
|
|
2005-09-21 11:41:22 +02:00
|
|
|
/* for addrinfo calls */
|
|
|
|
typedef struct WS(addrinfo)
|
|
|
|
{
|
|
|
|
int ai_flags;
|
|
|
|
int ai_family;
|
|
|
|
int ai_socktype;
|
|
|
|
int ai_protocol;
|
2013-12-11 09:02:42 +01:00
|
|
|
SIZE_T ai_addrlen;
|
2005-09-21 11:41:22 +02:00
|
|
|
char * ai_canonname;
|
|
|
|
struct WS(sockaddr)* ai_addr;
|
|
|
|
struct WS(addrinfo)* ai_next;
|
|
|
|
} ADDRINFOA, *PADDRINFOA;
|
|
|
|
|
|
|
|
typedef struct WS(addrinfoW)
|
|
|
|
{
|
|
|
|
int ai_flags;
|
|
|
|
int ai_family;
|
|
|
|
int ai_socktype;
|
|
|
|
int ai_protocol;
|
2013-12-11 09:02:42 +01:00
|
|
|
SIZE_T ai_addrlen;
|
2005-09-21 11:41:22 +02:00
|
|
|
PWSTR ai_canonname;
|
|
|
|
struct WS(sockaddr)* ai_addr;
|
|
|
|
struct WS(addrinfoW)* ai_next;
|
|
|
|
} ADDRINFOW, *PADDRINFOW;
|
|
|
|
|
2019-08-13 01:24:14 +02:00
|
|
|
#ifndef WINE_NO_UNICODE_MACROS
|
|
|
|
typedef WINELIB_NAME_AW(ADDRINFO) ADDRINFOT, *PADDRINFOT;
|
|
|
|
#endif
|
2019-08-02 04:20:33 +02:00
|
|
|
|
2017-06-16 13:46:22 +02:00
|
|
|
#ifdef USE_WS_PREFIX
|
|
|
|
typedef int WS_socklen_t;
|
|
|
|
#else
|
|
|
|
#define socklen_t int /* avoid conflicts with the system's socklen_t typedef */
|
|
|
|
#endif
|
2006-07-13 14:06:30 +02:00
|
|
|
|
2005-11-23 19:43:50 +01:00
|
|
|
typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
|
2005-09-21 11:41:22 +02:00
|
|
|
|
2005-11-17 13:58:35 +01:00
|
|
|
/* Possible Windows flags for getaddrinfo() */
|
|
|
|
#ifndef USE_WS_PREFIX
|
2010-11-18 20:46:49 +01:00
|
|
|
# define AI_PASSIVE 0x00000001
|
|
|
|
# define AI_CANONNAME 0x00000002
|
|
|
|
# define AI_NUMERICHOST 0x00000004
|
2014-02-13 00:29:31 +01:00
|
|
|
# define AI_NUMERICSERV 0x00000008
|
2010-11-18 20:46:49 +01:00
|
|
|
# define AI_ADDRCONFIG 0x00000400
|
2013-12-11 09:01:52 +01:00
|
|
|
# define AI_V4MAPPED 0x00000800
|
2010-11-18 20:46:49 +01:00
|
|
|
# define AI_NON_AUTHORITATIVE 0x00004000
|
|
|
|
# define AI_SECURE 0x00008000
|
|
|
|
# define AI_RETURN_PREFERRED_NAMES 0x00010000
|
2016-11-29 18:23:14 +01:00
|
|
|
# define AI_DISABLE_IDN_ENCODING 0x00080000
|
2005-11-17 13:58:35 +01:00
|
|
|
/* getaddrinfo error codes */
|
|
|
|
# define EAI_AGAIN WSATRY_AGAIN
|
|
|
|
# define EAI_BADFLAGS WSAEINVAL
|
|
|
|
# define EAI_FAIL WSANO_RECOVERY
|
|
|
|
# define EAI_FAMILY WSAEAFNOSUPPORT
|
|
|
|
# define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
|
2005-12-12 11:55:33 +01:00
|
|
|
# define EAI_NODATA EAI_NONAME
|
2005-11-17 13:58:35 +01:00
|
|
|
# define EAI_NONAME WSAHOST_NOT_FOUND
|
|
|
|
# define EAI_SERVICE WSATYPE_NOT_FOUND
|
|
|
|
# define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
|
|
|
|
#else
|
2010-11-18 20:46:49 +01:00
|
|
|
# define WS_AI_PASSIVE 0x00000001
|
|
|
|
# define WS_AI_CANONNAME 0x00000002
|
|
|
|
# define WS_AI_NUMERICHOST 0x00000004
|
2014-02-13 00:29:31 +01:00
|
|
|
# define WS_AI_NUMERICSERV 0x00000008
|
2010-11-18 20:46:49 +01:00
|
|
|
# define WS_AI_ADDRCONFIG 0x00000400
|
2013-12-11 09:01:52 +01:00
|
|
|
# define WS_AI_V4MAPPED 0x00000800
|
2010-11-18 20:46:49 +01:00
|
|
|
# define WS_AI_NON_AUTHORITATIVE 0x00004000
|
|
|
|
# define WS_AI_SECURE 0x00008000
|
|
|
|
# define WS_AI_RETURN_PREFERRED_NAMES 0x00010000
|
2016-11-29 18:23:14 +01:00
|
|
|
# define WS_AI_DISABLE_IDN_ENCODING 0x00080000
|
2005-11-17 13:58:35 +01:00
|
|
|
/* getaddrinfo error codes */
|
|
|
|
# define WS_EAI_AGAIN WSATRY_AGAIN
|
|
|
|
# define WS_EAI_BADFLAGS WSAEINVAL
|
|
|
|
# define WS_EAI_FAIL WSANO_RECOVERY
|
|
|
|
# define WS_EAI_FAMILY WSAEAFNOSUPPORT
|
|
|
|
# define WS_EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
|
2005-12-12 11:55:33 +01:00
|
|
|
# define WS_EAI_NODATA WS_EAI_NONAME
|
2005-11-17 13:58:35 +01:00
|
|
|
# define WS_EAI_NONAME WSAHOST_NOT_FOUND
|
|
|
|
# define WS_EAI_SERVICE WSATYPE_NOT_FOUND
|
|
|
|
# define WS_EAI_SOCKTYPE WSAESOCKTNOSUPPORT
|
|
|
|
#endif
|
|
|
|
|
2009-04-01 18:13:38 +02:00
|
|
|
#ifndef USE_WS_PREFIX
|
|
|
|
# define NI_MAXHOST 1025
|
|
|
|
# define NI_MAXSERV 32
|
|
|
|
#else
|
|
|
|
# define WS_NI_MAXHOST 1025
|
|
|
|
# define WS_NI_MAXSERV 32
|
|
|
|
#endif
|
|
|
|
|
2006-07-13 14:06:30 +02:00
|
|
|
/* Possible Windows flags for getnameinfo() */
|
|
|
|
#ifndef USE_WS_PREFIX
|
|
|
|
# define NI_NOFQDN 0x01
|
|
|
|
# define NI_NUMERICHOST 0x02
|
|
|
|
# define NI_NAMEREQD 0x04
|
|
|
|
# define NI_NUMERICSERV 0x08
|
|
|
|
# define NI_DGRAM 0x10
|
|
|
|
#else
|
|
|
|
# define WS_NI_NOFQDN 0x01
|
|
|
|
# define WS_NI_NUMERICHOST 0x02
|
|
|
|
# define WS_NI_NAMEREQD 0x04
|
|
|
|
# define WS_NI_NUMERICSERV 0x08
|
|
|
|
# define WS_NI_DGRAM 0x10
|
|
|
|
#endif
|
|
|
|
|
2005-11-23 19:43:50 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-03-31 14:38:04 +02:00
|
|
|
#define GAI_STRERROR_BUFFER_SIZE 1024
|
|
|
|
|
|
|
|
static inline char *gai_strerrorA(int errcode)
|
|
|
|
{
|
|
|
|
static char buffer[GAI_STRERROR_BUFFER_SIZE + 1];
|
|
|
|
|
|
|
|
/* FIXME: should format message from system, ignoring inserts in neutral
|
|
|
|
* language */
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline WCHAR *gai_strerrorW(int errcode)
|
|
|
|
{
|
|
|
|
static WCHAR buffer[GAI_STRERROR_BUFFER_SIZE + 1];
|
|
|
|
|
|
|
|
/* FIXME: should format message from system, ignoring inserts in neutral
|
|
|
|
* language */
|
|
|
|
buffer[0] = '\0';
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_WS_PREFIX
|
|
|
|
# define WS_gai_strerror WINELIB_NAME_AW(gai_strerror)
|
|
|
|
#elif defined(WINE_NO_UNICODE_MACROS)
|
|
|
|
# define gai_strerror gai_strerrorA
|
|
|
|
#else
|
|
|
|
# define gai_strerror WINELIB_NAME_AW(gai_strerror)
|
|
|
|
#endif
|
|
|
|
|
2015-10-13 15:50:56 +02:00
|
|
|
typedef void (CALLBACK *LPLOOKUPSERVICE_COMPLETION_ROUTINE)(DWORD,DWORD,WSAOVERLAPPED*);
|
|
|
|
|
2005-11-23 19:43:50 +01:00
|
|
|
void WINAPI WS(freeaddrinfo)(LPADDRINFO);
|
|
|
|
#define FreeAddrInfoA WS(freeaddrinfo)
|
|
|
|
void WINAPI FreeAddrInfoW(PADDRINFOW);
|
|
|
|
#define FreeAddrInfo WINELIB_NAME_AW(FreeAddrInfo)
|
2020-06-17 00:43:22 +02:00
|
|
|
void WINAPI FreeAddrInfoEx(ADDRINFOEXA*);
|
2017-08-01 18:29:31 +02:00
|
|
|
void WINAPI FreeAddrInfoExW(ADDRINFOEXW*);
|
2020-06-17 00:43:22 +02:00
|
|
|
#ifdef UNICODE
|
|
|
|
#define FreeAddrInfoEx FreeAddrInfoExW
|
|
|
|
#endif
|
2005-11-23 19:43:50 +01:00
|
|
|
int WINAPI WS(getaddrinfo)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
|
|
|
|
#define GetAddrInfoA WS(getaddrinfo)
|
|
|
|
int WINAPI GetAddrInfoW(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
|
|
|
|
#define GetAddrInfo WINELIB_NAME_AW(GetAddrInfo)
|
2019-06-26 18:26:45 +02:00
|
|
|
int WINAPI GetAddrInfoExA(const char*,const char*,DWORD,GUID*,const ADDRINFOEXA*,ADDRINFOEXA**,struct WS(timeval)*,
|
2015-10-13 15:50:56 +02:00
|
|
|
OVERLAPPED*,LPLOOKUPSERVICE_COMPLETION_ROUTINE,HANDLE*);
|
2019-06-26 18:26:45 +02:00
|
|
|
int WINAPI GetAddrInfoExW(const WCHAR*,const WCHAR*,DWORD,GUID*, const ADDRINFOEXW*,ADDRINFOEXW**,struct WS(timeval)*,
|
2015-10-13 15:50:56 +02:00
|
|
|
OVERLAPPED*,LPLOOKUPSERVICE_COMPLETION_ROUTINE,HANDLE*);
|
|
|
|
#define GetAddrInfoEx WINELIB_NAME_AW(GetAddrInfoExW)
|
2017-07-31 18:04:21 +02:00
|
|
|
int WINAPI GetAddrInfoExOverlappedResult(OVERLAPPED*);
|
2017-05-24 21:01:47 +02:00
|
|
|
int WINAPI GetAddrInfoExCancel(HANDLE*);
|
2006-07-13 14:06:30 +02:00
|
|
|
int WINAPI WS(getnameinfo)(const SOCKADDR*,WS(socklen_t),PCHAR,DWORD,PCHAR,DWORD,INT);
|
2005-11-23 19:43:50 +01:00
|
|
|
#define GetNameInfoA WS(getnameinfo)
|
2006-07-13 14:06:30 +02:00
|
|
|
INT WINAPI GetNameInfoW(const SOCKADDR*,WS(socklen_t),PWCHAR,DWORD,PWCHAR,DWORD,INT);
|
2005-11-23 19:43:50 +01:00
|
|
|
#define GetNameInfo WINELIB_NAME_AW(GetNameInfo)
|
2009-04-29 15:52:29 +02:00
|
|
|
PCSTR WINAPI WS(inet_ntop)(INT,PVOID,PSTR,SIZE_T);
|
2008-12-08 09:28:02 +01:00
|
|
|
#define InetNtopA WS(inet_ntop)
|
2009-04-29 15:52:29 +02:00
|
|
|
PCWSTR WINAPI InetNtopW(INT,PVOID,PWSTR,SIZE_T);
|
2008-12-08 09:28:02 +01:00
|
|
|
#define InetNtop WINELIB_NAME_AW(InetNtop)
|
|
|
|
int WINAPI WS(inet_pton)(INT,PCSTR,PVOID);
|
|
|
|
#define InetPtonA WS(inet_pton)
|
|
|
|
int WINAPI InetPtonW(INT,PCWSTR,PVOID);
|
|
|
|
#define InetPton WINELIB_NAME_AW(InetPton)
|
2005-11-23 19:43:50 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ws2tcpip Function Typedefs
|
|
|
|
*
|
|
|
|
* Remember to keep this section in sync with the
|
|
|
|
* prototypes above.
|
|
|
|
*/
|
|
|
|
#if INCL_WINSOCK_API_TYPEDEFS
|
|
|
|
|
|
|
|
typedef void (WINAPI *LPFN_FREEADDRINFO)(LPADDRINFO);
|
|
|
|
#define LPFN_FREEADDRINFOA LPFN_FREEADDRINFO
|
|
|
|
typedef void (WINAPI *LPFN_FREEADDRINFOW)(PADDRINFOW);
|
|
|
|
#define LPFN_FREEADDRINFOT WINELIB_NAME_AW(LPFN_FREEADDRINFO)
|
|
|
|
typedef int (WINAPI *LPFN_GETADDRINFO)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
|
|
|
|
#define LPFN_GETADDRINFOA LPFN_GETADDRINFO
|
|
|
|
typedef int (WINAPI *LPFN_GETADDRINFOW)(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
|
|
|
|
#define LPFN_GETADDRINFOT WINELIB_NAME_AW(LPFN_GETADDRINFO)
|
|
|
|
typedef int (WINAPI *LPFN_GETNAMEINFO)(const struct sockaddr*,socklen_t,char*,DWORD,char*,DWORD,int);
|
|
|
|
#define LPFN_GETNAMEINFOA LPFN_GETNAMEINFO
|
|
|
|
typedef int (WINAPI *LPFN_GETNAMEINFOW)(const SOCKADDR*,socklen_t,PWCHAR,DWORD,PWCHAR,DWORD,INT);
|
|
|
|
#define LPFN_GETNAMEINFOT WINELIB_NAME_AW(LPFN_GETNAMEINFO)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2005-11-17 13:58:35 +01:00
|
|
|
|
2001-11-14 22:26:23 +01:00
|
|
|
#endif /* __WS2TCPIP__ */
|