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

Last change on this file since 21308 was 21308, checked in by ydario, 16 years ago

Minor updates, backout imm changes.

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