source: trunk/src/wsock32/wsock32.h@ 22012

Last change on this file since 22012 was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 8.9 KB
Line 
1/* $Id: wsock32.h,v 1.21 2002-02-20 15:07:14 sandervl Exp $ */
2
3/* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
4 * Unused/unneeded Microsoft declarations removed.
5 *
6 * This header file corresponds to version 1.1 of the Windows Sockets specification.
7 *
8 * This file includes parts which are Copyright (c) 1982-1986 Regents
9 * of the University of California. All rights reserved. The
10 * Berkeley Software License Agreement specifies the terms and
11 * conditions for redistribution.
12 *
13 */
14
15#ifndef _WINSOCK32CONST_
16#define _WINSOCK32CONST_
17
18#include "socketwrap.h"
19#include <sys/time.h>
20
21#include <odinwrap.h>
22
23#ifdef __EMX__
24// EMX 0.6.4 and before lacks this
25#ifndef SOCBASEERR
26#define SOCBASEERR 0
27#endif
28#endif
29
30#ifndef IP_TTL
31#define IP_TTL 7
32#define IP_TOS 8
33#define IP_DONTFRAGMENT 9
34#endif
35
36/*
37 * Socket state bits.
38 */
39#define SS_NOFDREF 0x0001 /* no file table ref any more */
40#define SS_ISCONNECTED 0x0002 /* socket connected to a peer */
41#define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */
42#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
43#define SS_CANTSENDMORE 0x0010 /* can't send more data to peer */
44#define SS_CANTRCVMORE 0x0020 /* can't receive more data from peer */
45#define SS_RCVATMARK 0x0040 /* at mark on input */
46
47#define SS_NBIO 0x0100 /* non-blocking ops */
48#define SS_ASYNC 0x0200 /* async i/o notify */
49#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
50
51#define SS_INCOMP 0x0800 /* unaccepted, incomplete connection */
52#define SS_COMP 0x1000 /* unaccepted, complete connection */
53#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
54
55//socketopt options
56#define SO_DONTLINGER (u_int)(~SO_LINGER)
57
58#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
59
60// WSAAsyncSelect flags
61// also apply to Winsock 2.0 WSAEventSelect
62#define FD_MAX_EVENTS 10
63#define FD_READ 0x01
64#define FD_WRITE 0x02
65#define FD_OOB 0x04
66#define FD_ACCEPT 0x08
67#define FD_CONNECT 0x10
68#define FD_CLOSE 0x20
69// Winsock 2.0 only
70#define FD_QOS 0x40
71#define FD_GROUP_QOS 0x80
72#define FD_ROUTING_INTERFACE_CHANGE 0x100
73#define FD_ADDRESS_LIST_CHANGE 0x200
74
75#define SOCKET_ERROR -1
76#define NO_ERROR 0
77
78#define WSABASEERR 10000
79
80#define WSAEINTR (WSABASEERR+4)
81#define WSAEBADF (WSABASEERR+9)
82#define WSAEACCES (WSABASEERR+13)
83#define WSAEFAULT (WSABASEERR+14)
84#define WSAEINVAL (WSABASEERR+22)
85#define WSAEMFILE (WSABASEERR+24)
86
87#define WSAEWOULDBLOCK (WSABASEERR+35)
88#define WSAEINPROGRESS (WSABASEERR+36)
89#define WSAEALREADY (WSABASEERR+37)
90#define WSAENOTSOCK (WSABASEERR+38)
91#define WSAEDESTADDRREQ (WSABASEERR+39)
92#define WSAEMSGSIZE (WSABASEERR+40)
93#define WSAEPROTOTYPE (WSABASEERR+41)
94#define WSAENOPROTOOPT (WSABASEERR+42)
95#define WSAEPROTONOSUPPORT (WSABASEERR+43)
96#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
97#define WSAEOPNOTSUPP (WSABASEERR+45)
98#define WSAEPFNOSUPPORT (WSABASEERR+46)
99#define WSAEAFNOSUPPORT (WSABASEERR+47)
100#define WSAEADDRINUSE (WSABASEERR+48)
101#define WSAEADDRNOTAVAIL (WSABASEERR+49)
102#define WSAENETDOWN (WSABASEERR+50)
103#define WSAENETUNREACH (WSABASEERR+51)
104#define WSAENETRESET (WSABASEERR+52)
105#define WSAECONNABORTED (WSABASEERR+53)
106#define WSAECONNRESET (WSABASEERR+54)
107#define WSAENOBUFS (WSABASEERR+55)
108#define WSAEISCONN (WSABASEERR+56)
109#define WSAENOTCONN (WSABASEERR+57)
110#define WSAESHUTDOWN (WSABASEERR+58)
111#define WSAETOOMANYREFS (WSABASEERR+59)
112#define WSAETIMEDOUT (WSABASEERR+60)
113#define WSAECONNREFUSED (WSABASEERR+61)
114#define WSAELOOP (WSABASEERR+62)
115#define WSAENAMETOOLONG (WSABASEERR+63)
116#define WSAEHOSTDOWN (WSABASEERR+64)
117#define WSAEHOSTUNREACH (WSABASEERR+65)
118#define WSAENOTEMPTY (WSABASEERR+66)
119#define WSAEPROCLIM (WSABASEERR+67)
120#define WSAEUSERS (WSABASEERR+68)
121#define WSAEDQUOT (WSABASEERR+69)
122#define WSAESTALE (WSABASEERR+70)
123#define WSAEREMOTE (WSABASEERR+71)
124#define WSASYSNOTREADY (WSABASEERR+91)
125#define WSAVERNOTSUPPORTED (WSABASEERR+92)
126#define WSANOTINITIALISED (WSABASEERR+93)
127#define WSAEDISCON (WSABASEERR+101)
128#define WSATYPE_NOT_FOUND (WSABASEERR+109)
129#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
130#define WSATRY_AGAIN (WSABASEERR+1002)
131#define WSANO_RECOVERY (WSABASEERR+1003)
132#define WSANO_DATA (WSABASEERR+1004)
133#define WSANO_ADDRESS WSANO_DATA
134
135typedef u_int SOCKET;
136
137#ifndef FD_SETSIZE
138#define FD_SETSIZE 64
139#endif
140
141#pragma pack(1)
142
143#define WSADESCRIPTION_LEN 256
144#define WSASYS_STATUS_LEN 128
145
146typedef struct WSAData {
147 USHORT wVersion;
148 USHORT wHighVersion;
149 char szDescription[WSADESCRIPTION_LEN+1];
150 char szSystemStatus[WSASYS_STATUS_LEN+1];
151 unsigned short iMaxSockets;
152 unsigned short iMaxUdpDg;
153 char * lpVendorInfo;
154} WSADATA;
155typedef WSADATA *PWSADATA;
156typedef WSADATA *LPWSADATA;
157
158typedef struct ws_fd_set {
159 u_int fd_count;
160 SOCKET fd_array[FD_SETSIZE];
161} _ws_fd_set;
162
163/*
164 * Structure used for manipulating linger option.
165 */
166typedef struct ws_linger {
167 u_short l_onoff; /* option on/off */
168 u_short l_linger; /* linger time */
169} _ws_linger;
170
171/*
172 * Structures returned by network data base library, taken from the
173 * BSD file netdb.h. All addresses are supplied in host order, and
174 * returned in network order (suitable for use in system calls).
175 */
176
177typedef struct ws_hostent
178{
179 char * h_name; /* official name of host */
180 char ** h_aliases; /* alias list */
181 INT16 h_addrtype; /* host address type */
182 INT16 h_length; /* length of address */
183 char ** h_addr_list; /* list of addresses from name server */
184} _ws_hostent;
185
186typedef struct ws_protoent
187{
188 char * p_name; /* official protocol name */
189 char ** p_aliases; /* alias list */
190 INT16 p_proto; /* protocol # */
191} _ws_protoent;
192
193typedef struct ws_servent
194{
195 char * s_name; /* official service name */
196 char ** s_aliases; /* alias list */
197 INT16 s_port; /* port # */
198 char * s_proto; /* protocol to use */
199} _ws_servent;
200
201typedef struct ws_netent
202{
203 char * n_name; /* official name of net */
204 char ** n_aliases; /* alias list */
205 INT16 n_addrtype; /* net address type */
206 INT n_net; /* network # */
207} _ws_netent;
208
209#pragma pack()
210
211#define WS_MAX_SOCKETS_PER_PROCESS 2048
212#define WS_MAX_UDP_DATAGRAM 32767
213
214#define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
215#define WSI_BLOCKINGHOOK 0x00000002 /* 32-bit callback */
216
217typedef struct _WSINFO
218{
219 DWORD dwThisThread;
220 struct _WSINFO *lpNextIData;
221
222 unsigned flags;
223 INT16 num_startup; /* reference counter */
224 INT16 num_async_rq;
225 INT16 last_free; /* entry in the socket table */
226 USHORT buflen;
227 char* buffer; /* allocated from char * heap */
228 struct ws_hostent *he;
229 int helen;
230 struct ws_servent *se;
231 int selen;
232 struct ws_protoent *pe;
233 int pelen;
234 char* dbuffer; /* buffer for dummies (32 bytes) */
235
236 DWORD blocking_hook;
237} WSINFO, *LPWSINFO;
238
239void WIN32API WSASetLastError(int iError);
240int WIN32API WSAGetLastError(void);
241int WIN32API WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
242BOOL WIN32API WSAIsBlocking(void);
243
244extern BOOL fWSAInitialized;
245
246UINT wsaErrno();
247UINT wsaHerrno();
248
249#define CURRENT_THREAD -1
250void WSASetBlocking(BOOL fBlock, HANDLE tid = CURRENT_THREAD);
251
252void WINSOCK_DeleteIData(void);
253BOOL WINSOCK_CreateIData(void);
254LPWSINFO WINSOCK_GetIData(HANDLE tid = CURRENT_THREAD);
255
256typedef HANDLE WSAEVENT;
257
258// modes for the async select worker
259#define WSA_SELECT_HWND 1
260#define WSA_SELECT_HEVENT 2
261// async select worker routine
262int WSAAsyncSelectWorker(SOCKET s, int mode, DWORD notifyHandle, DWORD notifyData, DWORD lEventMask);
263
264typedef struct _WSANETWORKEVENTS
265{
266 long lNetworkEvents;
267 int iErrorCode[FD_MAX_EVENTS];
268} WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
269int WSAEnumNetworkEventsWorker(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lpEvent);
270
271#endif /* _WINSOCK32CONST_ */
272
273
Note: See TracBrowser for help on using the repository browser.