winsock.h revision a3133ef29cdf3656735d569fd64e54c9286effc0
/* WINSOCK.H--definitions to be used with the WINSOCK.DLL
*
* This header file corresponds to version 1.1 of the Windows Sockets
* specification.
*
* Copyright (C) the Wine project
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#ifdef __WINESRC__
# ifndef __WINE_WINSOCK2__
# endif
#endif
#ifndef __WINE_WINSOCKAPI_STDLIB_H
#define __WINE_WINSOCKAPI_STDLIB_H
/*
* This section defines the items that conflict with the Unix headers.
*/
#ifndef USE_WS_PREFIX
/* We are not using the WS_ prefix we risk getting conflicts for
* everything related to select.
*/
# ifdef FD_CLR
* This means select and all the related stuff is already defined and we
* cannot override types and function prototypes.
* All we can do is disable all these symbols so that they are not used
* inadvertently.
*/
# elif defined(RLIM_INFINITY)
/* On Darwin stdlib.h includes sys/resource.h which defines timeval but not the fd_set macros */
# define fd_set unix_fd_set
# include <time.h>
# include <stdlib.h>
# else /* FD_CLR */
/* stdlib.h has not been included yet so it's not too late. Include it now
* making sure that none of the select symbols is affected. Then we can
* define them with our own values.
*/
# define fd_set unix_fd_set
# define timeval unix_timeval
# define select unix_select
# define socklen_t unix_socklen_t
# include <time.h>
# include <stdlib.h>
# define WS_DEFINE_SELECT
# endif /* FD_CLR */
#else
# define WS_DEFINE_SELECT
# include <stdlib.h>
#endif /* !USE_WS_PREFIX */
#endif /* __WINE_WINSOCKAPI_STDLIB_H */
#ifndef __WINESRC__
# include <windows.h>
#else
# include <windef.h>
#endif
#ifndef _WINSOCKAPI_
#define _WINSOCKAPI_
#ifdef USE_WS_PREFIX
typedef unsigned char WS_u_char;
typedef unsigned short WS_u_short;
typedef unsigned int WS_u_int;
#ifdef _MSC_VER
typedef unsigned long WS_u_long;
#else
typedef unsigned int WS_u_long;
#endif
#elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
/* MinGW doesn't define the u_xxx types */
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
#ifdef _MSC_VER
typedef unsigned long u_long;
#else
typedef unsigned int u_long;
#endif
#define _BSDTYPES_DEFINED
#endif
#ifdef USE_WS_PREFIX
#else
# define WS(x) x
#endif
#ifdef __cplusplus
extern "C" {
#endif /* defined(__cplusplus) */
/*
* Address families
*/
#ifndef USE_WS_PREFIX
#define AF_UNSPEC 0
#define AF_UNIX 1
#define AF_INET 2
#define AF_IMPLINK 3
#define AF_PUP 4
#define AF_CHAOS 5
#define AF_NS 6
#define AF_ISO 7
#define AF_ECMA 8
#define AF_DATAKIT 9
#define AF_CCITT 10
#define AF_SNA 11
#define AF_DECnet 12
#define AF_DLI 13
#define AF_LAT 14
#define AF_HYLINK 15
#define AF_APPLETALK 16
#define AF_NETBIOS 17
#define AF_VOICEVIEW 18
#define AF_FIREFOX 19
#define AF_UNKNOWN1 20
#define AF_BAN 21
#define AF_ATM 22
#define AF_INET6 23
#define AF_CLUSTER 24
#define AF_12844 25
#define AF_IRDA 26
#define AF_MAX 27
#define PF_IMPLINK AF_IMPLINK
#define PF_DATAKIT AF_DATAKIT
#define PF_APPLETALK AF_APPLETALK
#define PF_VOICEVIEW AF_VOICEVIEW
#define PF_FIREFOX AF_FIREFOX
#define PF_UNKNOWN1 AF_UNKNOWN1
#else /* USE_WS_PREFIX */
#define WS_AF_UNSPEC 0
#define WS_AF_UNIX 1
#define WS_AF_INET 2
#define WS_AF_IMPLINK 3
#define WS_AF_PUP 4
#define WS_AF_CHAOS 5
#define WS_AF_NS 6
#define WS_AF_ISO 7
#define WS_AF_ECMA 8
#define WS_AF_DATAKIT 9
#define WS_AF_CCITT 10
#define WS_AF_SNA 11
#define WS_AF_DECnet 12
#define WS_AF_DLI 13
#define WS_AF_LAT 14
#define WS_AF_HYLINK 15
#define WS_AF_APPLETALK 16
#define WS_AF_NETBIOS 17
#define WS_AF_VOICEVIEW 18
#define WS_AF_FIREFOX 19
#define WS_AF_UNKNOWN1 20
#define WS_AF_BAN 21
#define WS_AF_ATM 22
#define WS_AF_INET6 23
#define WS_AF_CLUSTER 24
#define WS_AF_12844 25
#define WS_AF_IRDA 26
#define WS_AF_MAX 27
#endif /* USE_WS_PREFIX */
/*
* Types
*/
#ifndef USE_WS_PREFIX
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define SOCK_RAW 3
#define SOCK_RDM 4
#define SOCK_SEQPACKET 5
#else /* USE_WS_PREFIX */
#define WS_SOCK_STREAM 1
#define WS_SOCK_DGRAM 2
#define WS_SOCK_RAW 3
#define WS_SOCK_RDM 4
#define WS_SOCK_SEQPACKET 5
#endif /* USE_WS_PREFIX */
/*
* Protocols
*/
#ifndef USE_WS_PREFIX
#define IPPROTO_IP 0
#define IPPROTO_ICMP 1
#define IPPROTO_IGMP 2
#define IPPROTO_GGP 3
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
#define IPPROTO_IDP 22
#define IPPROTO_IPV6 41
#define IPPROTO_ND 77
#define IPPROTO_RAW 255
#define IPPROTO_MAX 256
#else /* USE_WS_PREFIX */
#define WS_IPPROTO_IP 0
#define WS_IPPROTO_ICMP 1
#define WS_IPPROTO_IGMP 2
#define WS_IPPROTO_GGP 3
#define WS_IPPROTO_TCP 6
#define WS_IPPROTO_UDP 17
#define WS_IPPROTO_IDP 22
#define WS_IPPROTO_IPV6 41
#define WS_IPPROTO_ND 77
#define WS_IPPROTO_RAW 255
#define WS_IPPROTO_MAX 256
#endif /* USE_WS_PREFIX */
{
char* p_name;
char** p_aliases;
short p_proto;
/*
* Networks
*/
{
char* n_name; /* official name of net */
char** n_aliases; /* alias list */
short n_addrtype; /* net address type */
};
/*
* Services
*/
#ifndef USE_WS_PREFIX
#define IPPORT_ECHO 7
#define IPPORT_DISCARD 9
#define IPPORT_SYSTAT 11
#define IPPORT_DAYTIME 13
#define IPPORT_NETSTAT 15
#define IPPORT_FTP 21
#define IPPORT_TELNET 23
#define IPPORT_SMTP 25
#define IPPORT_TIMESERVER 37
#define IPPORT_NAMESERVER 42
#define IPPORT_WHOIS 43
#define IPPORT_MTP 57
#define IPPORT_TFTP 69
#define IPPORT_RJE 77
#define IPPORT_FINGER 79
#define IPPORT_TTYLINK 87
#define IPPORT_SUPDUP 95
#define IPPORT_EXECSERVER 512
#define IPPORT_LOGINSERVER 513
#define IPPORT_CMDSERVER 514
#define IPPORT_EFSSERVER 520
#define IPPORT_BIFFUDP 512
#define IPPORT_WHOSERVER 513
#define IPPORT_ROUTESERVER 520
#define IPPORT_RESERVED 1024
#else /* USE_WS_PREFIX */
#define WS_IPPORT_ECHO 7
#define WS_IPPORT_DISCARD 9
#define WS_IPPORT_SYSTAT 11
#define WS_IPPORT_DAYTIME 13
#define WS_IPPORT_NETSTAT 15
#define WS_IPPORT_FTP 21
#define WS_IPPORT_TELNET 23
#define WS_IPPORT_SMTP 25
#define WS_IPPORT_TIMESERVER 37
#define WS_IPPORT_NAMESERVER 42
#define WS_IPPORT_WHOIS 43
#define WS_IPPORT_MTP 57
#define WS_IPPORT_TFTP 69
#define WS_IPPORT_RJE 77
#define WS_IPPORT_FINGER 79
#define WS_IPPORT_TTYLINK 87
#define WS_IPPORT_SUPDUP 95
#define WS_IPPORT_EXECSERVER 512
#define WS_IPPORT_LOGINSERVER 513
#define WS_IPPORT_CMDSERVER 514
#define WS_IPPORT_EFSSERVER 520
#define WS_IPPORT_BIFFUDP 512
#define WS_IPPORT_WHOSERVER 513
#define WS_IPPORT_ROUTESERVER 520
#define WS_IPPORT_RESERVED 1024
#endif /* USE_WS_PREFIX */
{
char* s_name; /* official service name */
char** s_aliases; /* alias list */
#ifdef _WIN64
char* s_proto; /* protocol to use */
short s_port; /* port # */
#else
short s_port; /* port # */
char* s_proto; /* protocol to use */
#endif
/*
* Hosts
*/
{
char* h_name; /* official name of host */
char** h_aliases; /* alias list */
short h_addrtype; /* host address type */
short h_length; /* length of address */
char** h_addr_list; /* list of addresses from name server */
/*
* Sockets
*/
/*
* This is used instead of -1, since the
* SOCKET type is unsigned.
*/
#define INVALID_SOCKET (SOCKET)(~0)
#define SOCKET_ERROR (-1)
{
char sa_data[14];
{
/*
* Select
*/
#ifdef WS_DEFINE_SELECT
/* Define our own version of select and the associated types and macros */
# ifndef USE_WS_PREFIX
# ifndef FD_SETSIZE
# define FD_SETSIZE 64
# endif
# else
# ifndef WS_FD_SETSIZE
# define WS_FD_SETSIZE 64
# endif
# endif
{
# ifndef USE_WS_PREFIX
# else
# endif
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
{
#endif
unsigned int __i; \
{ \
{ \
{ \
__i++; \
} \
break; \
} \
} \
} while(0)
} while(0)
/* This version checks if the filedesc is already in the list, and appends it
* only if it's not the case
*/
unsigned int __i; \
{ \
break; \
} \
{ \
} \
} while(0)
#ifndef __WINE_WINSOCK2__
#else
#endif
#ifndef USE_WS_PREFIX
#else
#endif
#endif /* WS_DEFINE_SELECT */
#ifndef USE_WS_PREFIX
#ifdef WORDS_BIGENDIAN
#else /* WORDS_BIGENDIAN */
{
return (s >> 8) | (s << 8);
}
{
}
#define htonl(l) __wine_ulong_swap(l)
#define htons(s) __wine_ushort_swap(s)
#define ntohl(l) __wine_ulong_swap(l)
#define ntohs(s) __wine_ushort_swap(s)
#endif /* WORDS_BIGENDIAN */
#endif /* USE_WS_PREFIX */
/*
* Internet address (old style... should be updated)
*/
#ifndef USE_WS_PREFIX
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_MAX 128
#define IN_CLASSA_NET 0xff000000
#define IN_CLASSA_HOST 0x00ffffff
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_MAX 65536
#define IN_CLASSB_NET 0xffff0000
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_HOST 0x000000ff
#else
#define WS_IN_CLASSA_NSHIFT 24
#define WS_IN_CLASSA_MAX 128
#define WS_IN_CLASSA_NET 0xff000000
#define WS_IN_CLASSA_HOST 0x00ffffff
#define WS_IN_CLASSB_NSHIFT 16
#define WS_IN_CLASSB_MAX 65536
#define WS_IN_CLASSB_NET 0xffff0000
#define WS_IN_CLASSB_HOST 0x0000ffff
#define WS_IN_CLASSC_NSHIFT 8
#define WS_IN_CLASSC_NET 0xffffff00
#define WS_IN_CLASSC_HOST 0x000000ff
#endif /* USE_WS_PREFIX */
#ifndef USE_WS_PREFIX
#define INADDR_LOOPBACK 0x7f000001
#define INADDR_NONE 0xffffffff
#else
#define WS_INADDR_LOOPBACK 0x7f000001
#define WS_INADDR_NONE 0xffffffff
#endif /* USE_WS_PREFIX */
{
union {
struct {
} S_un_b;
struct {
} S_un_w;
} S_un;
#ifndef USE_WS_PREFIX
#else
#endif /* USE_WS_PREFIX */
typedef struct WS(sockaddr_in)
{
short sin_family;
char sin_zero[8];
/*
* Multicast group information
*/
#if !defined(__WINE_WINSOCK2__)
{
};
#endif
/*
* WSAStartup
*/
#define WSADESCRIPTION_LEN 256
#define WSASYS_STATUS_LEN 128
{
#ifdef _WIN64
char *lpVendorInfo;
#else
char *lpVendorInfo;
#endif
/*
* {get,set}sockopt
*/
#ifndef USE_WS_PREFIX
#define SOL_SOCKET 0xffff
#define SO_DEBUG 0x0001
#define SO_ACCEPTCONN 0x0002
#define SO_REUSEADDR 0x0004
#define SO_KEEPALIVE 0x0008
#define SO_DONTROUTE 0x0010
#define SO_BROADCAST 0x0020
#define SO_USELOOPBACK 0x0040
#define SO_LINGER 0x0080
#define SO_OOBINLINE 0x0100
#define SO_SNDBUF 0x1001
#define SO_RCVBUF 0x1002
#define SO_SNDLOWAT 0x1003
#define SO_RCVLOWAT 0x1004
#define SO_SNDTIMEO 0x1005
#define SO_RCVTIMEO 0x1006
#define SO_ERROR 0x1007
#define SO_TYPE 0x1008
#define IOCPARM_MASK 0x7f
#define IOC_VOID 0x20000000
#define IOC_OUT 0x40000000
#define IOC_IN 0x80000000
#else
#define WS_SOL_SOCKET 0xffff
#define WS_SO_DEBUG 0x0001
#define WS_SO_ACCEPTCONN 0x0002
#define WS_SO_REUSEADDR 0x0004
#define WS_SO_KEEPALIVE 0x0008
#define WS_SO_DONTROUTE 0x0010
#define WS_SO_BROADCAST 0x0020
#define WS_SO_USELOOPBACK 0x0040
#define WS_SO_LINGER 0x0080
#define WS_SO_OOBINLINE 0x0100
#define WS_SO_SNDBUF 0x1001
#define WS_SO_RCVBUF 0x1002
#define WS_SO_SNDLOWAT 0x1003
#define WS_SO_RCVLOWAT 0x1004
#define WS_SO_SNDTIMEO 0x1005
#define WS_SO_RCVTIMEO 0x1006
#define WS_SO_ERROR 0x1007
#define WS_SO_TYPE 0x1008
#define WS_IOCPARM_MASK 0x7f
#define WS_IOC_VOID 0x20000000
#define WS_IOC_OUT 0x40000000
#define WS_IOC_IN 0x80000000
#endif
/* IPPROTO_TCP options */
#ifndef USE_WS_PREFIX
#define TCP_NODELAY 1
#else
#define WS_TCP_NODELAY 1
#endif
/* IPPROTO_IP options */
#ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
# ifndef USE_WS_PREFIX
# define IP_OPTIONS 1
# define IP_MULTICAST_IF 2
# define IP_MULTICAST_TTL 3
# define IP_MULTICAST_LOOP 4
# define IP_ADD_MEMBERSHIP 5
# define IP_DROP_MEMBERSHIP 6
# define IP_TTL 7
# define IP_TOS 8
# define IP_DONTFRAGMENT 9
# else
# define WS_IP_OPTIONS 1
# define WS_IP_MULTICAST_IF 2
# define WS_IP_MULTICAST_TTL 3
# define WS_IP_MULTICAST_LOOP 4
# define WS_IP_ADD_MEMBERSHIP 5
# define WS_IP_DROP_MEMBERSHIP 6
# define WS_IP_TTL 7
# define WS_IP_TOS 8
# define WS_IP_DONTFRAGMENT 9
# endif
#endif
/*
* Socket I/O flags (supported by spec 1.1)
*/
#ifndef USE_WS_PREFIX
#else
#endif
/*
* Maximum queue length specifiable by listen.
*/
#ifndef USE_WS_PREFIX
#define SOMAXCONN 5
#define MSG_OOB 0x0001
#define MSG_PEEK 0x0002
#define MSG_DONTROUTE 0x0004
#define MSG_WAITALL 0x0008
#define MSG_INTERRUPT 0x0010
#define MSG_PARTIAL 0x8000
#define MSG_MAXIOVLEN 16
#else /* USE_WS_PREFIX */
#define WS_SOMAXCONN 5
#define WS_MSG_OOB 0x0001
#define WS_MSG_PEEK 0x0002
#define WS_MSG_DONTROUTE 0x0004
#define WS_MSG_WAITALL 0x0008
#define WS_MSG_INTERRUPT 0x0010
#define WS_MSG_PARTIAL 0x8000
#define WS_MSG_MAXIOVLEN 16
#endif /* USE_WS_PREFIX */
/*
* Define constant based on rfc883, used by gethostbyxxxx() calls.
*/
#ifndef USE_WS_PREFIX
#define MAXGETHOSTSTRUCT 1024
#else
#define MAXGETHOSTSTRUCT 1024
#endif
/*
* Define flags to be used with the WSAAsyncSelect() call.
*/
#define FD_READ 0x00000001
#define FD_WRITE 0x00000002
#define FD_OOB 0x00000004
#define FD_ACCEPT 0x00000008
#define FD_CONNECT 0x00000010
#define FD_CLOSE 0x00000020
/* internal per-socket flags */
#ifdef __WINESRC__
#define FD_WINE_LISTENING 0x10000000
#define FD_WINE_NONBLOCKING 0x20000000
#define FD_WINE_CONNECTED 0x40000000
#define FD_WINE_RAW 0x80000000
#define FD_WINE_INTERNAL 0xFFFF0000
#endif
/*
* All Windows Sockets error constants are biased by WSABASEERR from
* the "normal"
*/
#define WSABASEERR 10000
/*
* Windows Sockets definitions of regular Microsoft C error constants
*/
/*
* Windows Sockets definitions of regular Berkeley error constants
*/
/*
* Extended Windows Sockets error constant definitions
*/
/*
* Error return codes from gethostbyname() and gethostbyaddr()
* (when using the resolver). Note that these errors are
* retrieved via WSAGetLastError() and must therefore follow
* the rules for avoiding clashes with error numbers from
* specific implementations or language run-time systems.
* For this reason the codes are based at WSABASEERR+1001.
* Note also that [WSA]NO_ADDRESS is defined only for
* compatibility purposes.
*/
#ifndef USE_WS_PREFIX
#define h_errno WSAGetLastError()
#else
#define WS_h_errno WSAGetLastError()
#endif
/* Authoritative Answer: Host not found */
/* Non-Authoritative: Host not found, or SERVERFAIL */
/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
/* Valid name, no data record of requested type */
/* no address, look for MX record */
#define WSANO_ADDRESS WSANO_DATA
#ifndef USE_WS_PREFIX
#define HOST_NOT_FOUND WSAHOST_NOT_FOUND
#define TRY_AGAIN WSATRY_AGAIN
#define NO_RECOVERY WSANO_RECOVERY
#define NO_DATA WSANO_DATA
#define NO_ADDRESS WSANO_ADDRESS
#endif /* USE_WS_PREFIX */
/*
* Windows message parameter composition and decomposition
* macros.
*/
/*
* WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
* when constructing the response to a WSAAsyncGetXByY() routine.
*/
/*
* WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
* when constructing the response to WSAAsyncSelect().
*/
/*
* WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
* to extract the buffer length from the lParam in the response
* to a WSAGetXByY().
*/
/*
* WSAGETASYNCERROR is intended for use by the Windows Sockets application
* to extract the error code from the lParam in the response
* to a WSAGetXByY().
*/
/*
* WSAGETSELECTEVENT is intended for use by the Windows Sockets application
* to extract the event code from the lParam in the response
* to a WSAAsyncSelect().
*/
/*
* WSAGETSELECTERROR is intended for use by the Windows Sockets application
* to extract the error code from the lParam in the response
* to a WSAAsyncSelect().
*/
/*
* Prototypes
*
* Remember to keep this section in sync with the
* "Winsock Function Typedefs" section in winsock2.h.
*/
#if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
int WINAPI WSACancelBlockingCall(void);
int WINAPI WSACleanup(void);
int WINAPI WSAGetLastError(void);
void WINAPI WSASetLastError(int);
int WINAPI WSAUnhookBlockingHook(void);
/* gethostname not defined because of conflicts with unistd.h */
#ifdef WS_DEFINE_SELECT
#endif
#endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
#ifdef __cplusplus
}
#endif
#ifndef __WINE_WINSOCK2__
#endif
#endif /* _WINSOCKAPI_ */