Created an initial Winsock 2 (ws2_32) DLL. Makes use of the Winsock 1
[wine] / include / winsock2.h
1 /*
2  * Winsock 2 definitions - used for ws2_32.dll
3  *
4  * FIXME: Still missing required Winsock 2 definitions.
5  */
6  
7 #ifndef __WINSOCK2API__
8 #define __WINSOCK2API__
9
10 #include "winsock.h"
11 #include "wtypes.h"
12
13 #define FD_MAX_EVENTS   10
14 #define FD_READ_BIT     0
15 #define FD_WRITE_BIT    1
16 #define FD_OOB_BIT      2
17 #define FD_ACCEPT_BIT   3
18 #define FD_CONNECT_BIT  4
19 #define FD_CLOSE_BIT    5
20
21 /*
22  * Constants for WSAIoctl()
23  */
24 #define IOC_UNIX                      0x00000000
25 #define IOC_WS2                       0x08000000
26 #define IOC_PROTOCOL                  0x10000000
27 #define IOC_VENDOR                    0x18000000
28 #define _WSAIO(x,y)                   (IOC_VOID|(x)|(y))
29 #define _WSAIOR(x,y)                  (IOC_OUT|(x)|(y))
30 #define _WSAIOW(x,y)                  (IOC_IN|(x)|(y))
31 #define _WSAIORW(x,y)                 (IOC_INOUT|(x)|(y))
32 #define SIO_ASSOCIATE_HANDLE          _WSAIOW(IOC_WS2,1)
33 #define SIO_ENABLE_CIRCULAR_QUEUEING  _WSAIO(IOC_WS2,2)
34 #define SIO_FIND_ROUTE                _WSAIOR(IOC_WS2,3)
35 #define SIO_FLUSH                     _WSAIO(IOC_WS2,4)
36 #define SIO_GET_BROADCAST_ADDRESS     _WSAIOR(IOC_WS2,5)
37 #define SIO_GET_EXTENSION_FUNCTION_POINTER  _WSAIORW(IOC_WS2,6)
38 #define SIO_GET_QOS                   _WSAIORW(IOC_WS2,7)
39 #define SIO_GET_GROUP_QOS             _WSAIORW(IOC_WS2,8)
40 #define SIO_MULTIPOINT_LOOPBACK       _WSAIOW(IOC_WS2,9)
41 #define SIO_MULTICAST_SCOPE           _WSAIOW(IOC_WS2,10)
42 #define SIO_SET_QOS                   _WSAIOW(IOC_WS2,11)
43 #define SIO_SET_GROUP_QOS             _WSAIOW(IOC_WS2,12)
44 #define SIO_TRANSLATE_HANDLE          _WSAIORW(IOC_WS2,13)
45 #define SIO_ROUTING_INTERFACE_QUERY   _WSAIORW(IOC_WS2,20)
46 #define SIO_ROUTING_INTERFACE_CHANGE  _WSAIOW(IOC_WS2,21)
47 #define SIO_ADDRESS_LIST_QUERY        _WSAIOR(IOC_WS2,22)
48 #define SIO_ADDRESS_LIST_CHANGE       _WSAIO(IOC_WS2,23)
49 #define SIO_QUERY_TARGET_PNP_HANDLE   _WSAIOR(IOC_W32,24)
50 #define SIO_GET_INTERFACE_LIST        WS_IOR ('t', 127, u_long)
51
52 /* Unfortunately the sockaddr_in6 structure doesn't
53    seem to be defined in a standard place, even across 
54    different Linux distributions.  Until IPv6 support settles
55    down, let's do our own here so the sockaddr_gen 
56    union is the correct size.*/
57 #ifdef s6_addr
58 #undef s6_addr
59 #endif
60 struct ws_in_addr6
61 {
62    unsigned char s6_addr[16];   /* IPv6 address */
63 };
64 struct ws_sockaddr_in6
65 {
66    short   sin6_family;            /* AF_INET6 */
67    u_short sin6_port;              /* Transport level port number */
68    u_long  sin6_flowinfo;          /* IPv6 flow information */
69    struct  ws_in_addr6 sin6_addr;  /* IPv6 address */
70 };
71
72 typedef union sockaddr_gen
73 {
74    struct sockaddr Address;
75    struct ws_sockaddr_in  AddressIn;
76    struct ws_sockaddr_in6 AddressIn6;
77 } sockaddr_gen;
78
79 /* Structure to keep interface specific information */
80 typedef struct _INTERFACE_INFO
81 {
82    u_long        iiFlags;             /* Interface flags */
83    sockaddr_gen  iiAddress;           /* Interface address */
84    sockaddr_gen  iiBroadcastAddress;  /* Broadcast address */
85    sockaddr_gen  iiNetmask;           /* Network mask */
86 } INTERFACE_INFO, * LPINTERFACE_INFO;
87
88 /* Possible flags for the  iiFlags - bitmask  */ 
89 #ifndef HAVE_NET_IF_H
90 #  define IFF_UP                0x00000001 /* Interface is up */
91 #  define IFF_BROADCAST         0x00000002 /* Broadcast is  supported */
92 #  define IFF_LOOPBACK          0x00000004 /* this is loopback interface */
93 #  define IFF_POINTTOPOINT      0x00000008 /* this is point-to-point interface */
94 #  define IFF_MULTICAST         0x00000010 /* multicast is supported */
95 #endif
96
97 #define MAX_PROTOCOL_CHAIN 7
98 #define BASE_PROTOCOL      1
99 #define LAYERED_PROTOCOL   0
100
101 typedef struct _WSAPROTOCOLCHAIN 
102 {
103     int ChainLen;                                 /* the length of the chain,     */
104                                                   /* length = 0 means layered protocol, */
105                                                   /* length = 1 means base protocol, */
106                                                   /* length > 1 means protocol chain */
107     DWORD ChainEntries[MAX_PROTOCOL_CHAIN];       /* a list of dwCatalogEntryIds */
108 } WSAPROTOCOLCHAIN, * LPWSAPROTOCOLCHAIN;
109 #define WSAPROTOCOL_LEN  255
110
111 typedef struct _WSAPROTOCOL_INFOA 
112 {
113     DWORD dwServiceFlags1;
114     DWORD dwServiceFlags2;
115     DWORD dwServiceFlags3;
116     DWORD dwServiceFlags4;
117     DWORD dwProviderFlags;
118     GUID ProviderId;
119     DWORD dwCatalogEntryId;
120     WSAPROTOCOLCHAIN ProtocolChain;
121     int iVersion;
122     int iAddressFamily;
123     int iMaxSockAddr;
124     int iMinSockAddr;
125     int iSocketType;
126     int iProtocol;
127     int iProtocolMaxOffset;
128     int iNetworkByteOrder;
129     int iSecurityScheme;
130     DWORD dwMessageSize;
131     DWORD dwProviderReserved;
132     CHAR   szProtocol[WSAPROTOCOL_LEN+1];
133 } WSAPROTOCOL_INFOA, * LPWSAPROTOCOL_INFOA;
134
135 typedef struct _WSANETWORKEVENTS 
136 {
137   long lNetworkEvents;
138   int iErrorCode[FD_MAX_EVENTS];
139 } WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
140
141 typedef struct _OVERLAPPED *  LPWSAOVERLAPPED;
142 typedef HANDLE WSAEVENT;
143 typedef unsigned int   GROUP;
144
145 typedef void 
146 (CALLBACK * LPWSAOVERLAPPED_COMPLETION_ROUTINE)
147 (
148      DWORD dwError,
149      DWORD cbTransferred,
150      LPWSAOVERLAPPED lpOverlapped,
151      DWORD dwFlags
152 );
153
154
155 /* Function declarations */
156 int WINAPI WSAEnumNetworkEvents(SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents);
157 int WINAPI WSAEventSelect(SOCKET s, WSAEVENT hEventObject, long lNetworkEvents);
158 WSAEVENT WINAPI WSACreateEvent(void);
159 BOOL WINAPI WSACloseEvent(WSAEVENT event);
160 SOCKET WINAPI WSASocketA(int af, int type, int protocol,
161                          LPWSAPROTOCOL_INFOA lpProtocolInfo,
162                          GROUP g, DWORD dwFlags);
163
164 #endif