Change the callback declarations to a safer format.
[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
12 /* proper 4-byte packing */
13 #include "pshpack4.h"
14
15 #define WS_SO_GROUP_ID       0x2001
16 #define WS_SO_GROUP_PRIORITY 0x2002
17 #define WS_SO_MAX_MSG_SIZE   0x2003
18 #define WS_SO_PROTOCOL_INFOA 0x2004
19 #define WS_SO_PROTOCOL_INFOW 0x2005
20 #define WS_SO_PROTOCOL_INFO WINELIB_NAME_AW(WS_SO_PROTOCOL_INFO)
21
22 #define PVD_CONFIG            0x3001
23 #define SO_CONDITIONAL_ACCEPT 0x3002
24
25
26 /* option flags per socket */
27
28 #define FD_MAX_EVENTS   10
29 #define FD_READ_BIT     0
30 #define FD_WRITE_BIT    1
31 #define FD_OOB_BIT      2
32 #define FD_ACCEPT_BIT   3
33 #define FD_CONNECT_BIT  4
34 #define FD_CLOSE_BIT    5
35
36 /*
37  * Constants for WSAIoctl()
38  */
39 #define IOC_UNIX                      0x00000000
40 #define IOC_WS2                       0x08000000
41 #define IOC_PROTOCOL                  0x10000000
42 #define IOC_VENDOR                    0x18000000
43 #define _WSAIO(x,y)                   (IOC_VOID|(x)|(y))
44 #define _WSAIOR(x,y)                  (IOC_OUT|(x)|(y))
45 #define _WSAIOW(x,y)                  (IOC_IN|(x)|(y))
46 #define _WSAIORW(x,y)                 (IOC_INOUT|(x)|(y))
47 #define SIO_ASSOCIATE_HANDLE          _WSAIOW(IOC_WS2,1)
48 #define SIO_ENABLE_CIRCULAR_QUEUEING  _WSAIO(IOC_WS2,2)
49 #define SIO_FIND_ROUTE                _WSAIOR(IOC_WS2,3)
50 #define SIO_FLUSH                     _WSAIO(IOC_WS2,4)
51 #define SIO_GET_BROADCAST_ADDRESS     _WSAIOR(IOC_WS2,5)
52 #define SIO_GET_EXTENSION_FUNCTION_POINTER  _WSAIORW(IOC_WS2,6)
53 #define SIO_GET_QOS                   _WSAIORW(IOC_WS2,7)
54 #define SIO_GET_GROUP_QOS             _WSAIORW(IOC_WS2,8)
55 #define SIO_MULTIPOINT_LOOPBACK       _WSAIOW(IOC_WS2,9)
56 #define SIO_MULTICAST_SCOPE           _WSAIOW(IOC_WS2,10)
57 #define SIO_SET_QOS                   _WSAIOW(IOC_WS2,11)
58 #define SIO_SET_GROUP_QOS             _WSAIOW(IOC_WS2,12)
59 #define SIO_TRANSLATE_HANDLE          _WSAIORW(IOC_WS2,13)
60 #define SIO_ROUTING_INTERFACE_QUERY   _WSAIORW(IOC_WS2,20)
61 #define SIO_ROUTING_INTERFACE_CHANGE  _WSAIOW(IOC_WS2,21)
62 #define SIO_ADDRESS_LIST_QUERY        _WSAIOR(IOC_WS2,22)
63 #define SIO_ADDRESS_LIST_CHANGE       _WSAIO(IOC_WS2,23)
64 #define SIO_QUERY_TARGET_PNP_HANDLE   _WSAIOR(IOC_W32,24)
65 #define SIO_GET_INTERFACE_LIST        WS_IOR ('t', 127, u_long)
66
67 /* Unfortunately the sockaddr_in6 structure doesn't
68    seem to be defined in a standard place, even across 
69    different Linux distributions.  Until IPv6 support settles
70    down, let's do our own here so the sockaddr_gen 
71    union is the correct size.*/
72 #ifdef s6_addr
73 #undef s6_addr
74 #endif
75
76 struct ws_in_addr6
77 {
78    unsigned char s6_addr[16];   /* IPv6 address */
79 };
80 struct ws_sockaddr_in6
81 {
82    short   sin6_family;            /* AF_INET6 */
83    u_short sin6_port;              /* Transport level port number */
84    u_long  sin6_flowinfo;          /* IPv6 flow information */
85    struct  ws_in_addr6 sin6_addr;  /* IPv6 address */
86 };
87
88 typedef union sockaddr_gen
89 {
90    struct sockaddr Address;
91    struct ws_sockaddr_in  AddressIn;
92    struct ws_sockaddr_in6 AddressIn6;
93 } sockaddr_gen;
94
95 /* ws_hostent, ws_protoent, ws_servent, ws_netent are 4-byte aligned here ! */
96
97 typedef struct ws_hostent32
98 {
99         char    *h_name;        /* official name of host */
100         char    **h_aliases;    /* alias list */
101         short   h_addrtype;     /* host address type */
102         short   h_length;       /* length of address */
103         char    **h_addr_list;  /* list of addresses from name server */
104 } _ws_hostent32;
105
106 typedef struct ws_protoent32
107 {
108         char    *p_name;        /* official protocol name */
109         char    **p_aliases;    /* alias list */
110         short   p_proto;        /* protocol # */
111 } _ws_protoent32;
112
113 typedef struct ws_servent32
114 {
115         char    *s_name;        /* official service name */
116         char    **s_aliases;    /* alias list */
117         short   s_port;         /* port # */
118         char    *s_proto;       /* protocol to use */
119 } _ws_servent32;
120
121 typedef struct ws_netent32
122 {
123         char    *n_name;        /* official name of net */
124         char    **n_aliases;    /* alias list */
125         short   n_addrtype;     /* net address type */
126         u_long  n_net;          /* network # */
127 } _ws_netent32;
128
129 /* Structure to keep interface specific information */
130 typedef struct _INTERFACE_INFO
131 {
132    u_long        iiFlags;             /* Interface flags */
133    sockaddr_gen  iiAddress;           /* Interface address */
134    sockaddr_gen  iiBroadcastAddress;  /* Broadcast address */
135    sockaddr_gen  iiNetmask;           /* Network mask */
136 } INTERFACE_INFO, * LPINTERFACE_INFO;
137
138 /* Possible flags for the  iiFlags - bitmask  */ 
139 #ifndef HAVE_NET_IF_H
140 #  define IFF_UP                0x00000001 /* Interface is up */
141 #  define IFF_BROADCAST         0x00000002 /* Broadcast is  supported */
142 #  define IFF_LOOPBACK          0x00000004 /* this is loopback interface */
143 #  define IFF_POINTTOPOINT      0x00000008 /* this is point-to-point interface */
144 #  define IFF_MULTICAST         0x00000010 /* multicast is supported */
145 #endif
146
147 #ifndef GUID_DEFINED
148 #include "guiddef.h"
149 #endif
150
151 #define MAX_PROTOCOL_CHAIN 7
152 #define BASE_PROTOCOL      1
153 #define LAYERED_PROTOCOL   0
154
155 typedef struct _WSAPROTOCOLCHAIN 
156 {
157     int ChainLen;                                 /* the length of the chain,     */
158                                                   /* length = 0 means layered protocol, */
159                                                   /* length = 1 means base protocol, */
160                                                   /* length > 1 means protocol chain */
161     DWORD ChainEntries[MAX_PROTOCOL_CHAIN];       /* a list of dwCatalogEntryIds */
162 } WSAPROTOCOLCHAIN, * LPWSAPROTOCOLCHAIN;
163 #define WSAPROTOCOL_LEN  255
164
165 typedef struct _WSAPROTOCOL_INFOA 
166 {
167     DWORD dwServiceFlags1;
168     DWORD dwServiceFlags2;
169     DWORD dwServiceFlags3;
170     DWORD dwServiceFlags4;
171     DWORD dwProviderFlags;
172     GUID ProviderId;
173     DWORD dwCatalogEntryId;
174     WSAPROTOCOLCHAIN ProtocolChain;
175     int iVersion;
176     int iAddressFamily;
177     int iMaxSockAddr;
178     int iMinSockAddr;
179     int iSocketType;
180     int iProtocol;
181     int iProtocolMaxOffset;
182     int iNetworkByteOrder;
183     int iSecurityScheme;
184     DWORD dwMessageSize;
185     DWORD dwProviderReserved;
186     CHAR   szProtocol[WSAPROTOCOL_LEN+1];
187 } WSAPROTOCOL_INFOA, * LPWSAPROTOCOL_INFOA;
188
189 typedef struct _WSANETWORKEVENTS 
190 {
191   long lNetworkEvents;
192   int iErrorCode[FD_MAX_EVENTS];
193 } WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
194
195 typedef struct _OVERLAPPED *  LPWSAOVERLAPPED;
196 typedef HANDLE WSAEVENT;
197 typedef unsigned int   GROUP;
198
199 typedef void CALLBACK (*LPWSAOVERLAPPED_COMPLETION_ROUTINE)
200 (
201      DWORD dwError,
202      DWORD cbTransferred,
203      LPWSAOVERLAPPED lpOverlapped,
204      DWORD dwFlags
205 );
206
207
208 /* Function declarations */
209 int WINAPI WSAEnumNetworkEvents(SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents);
210 int WINAPI WSAEventSelect(SOCKET s, WSAEVENT hEventObject, long lNetworkEvents);
211 WSAEVENT WINAPI WSACreateEvent(void);
212 BOOL WINAPI WSACloseEvent(WSAEVENT event);
213 SOCKET WINAPI WSASocketA(int af, int type, int protocol,
214                          LPWSAPROTOCOL_INFOA lpProtocolInfo,
215                          GROUP g, DWORD dwFlags);
216 extern INT WINAPI ioctlsocket(SOCKET s, LONG cmd, ULONG *argp);
217
218 #include "poppack.h"
219
220 #endif