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

Last change on this file since 21417 was 21417, checked in by dmik, 15 years ago

winsock.h: Added WSATYPE_NOT_FOUND.

File size: 8.7 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 WSAEDISCON (WSABASEERR+101)
121#define WSATYPE_NOT_FOUND (WSABASEERR+109)
122#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
123#define WSATRY_AGAIN (WSABASEERR+1002)
124#define WSANO_RECOVERY (WSABASEERR+1003)
125#define WSANO_DATA (WSABASEERR+1004)
126#define WSANO_ADDRESS WSANO_DATA
127
128typedef u_int SOCKET;
129
130#define FD_SETSIZE 64
131
132#pragma pack(1)
133
134#define WSADESCRIPTION_LEN 256
135#define WSASYS_STATUS_LEN 128
136
137typedef struct WSAData {
138 USHORT wVersion;
139 USHORT wHighVersion;
140 char szDescription[WSADESCRIPTION_LEN+1];
141 char szSystemStatus[WSASYS_STATUS_LEN+1];
142 unsigned short iMaxSockets;
143 unsigned short iMaxUdpDg;
144 char * lpVendorInfo;
145} WSADATA;
146typedef WSADATA *PWSADATA;
147typedef WSADATA *LPWSADATA;
148
149typedef struct ws_fd_set {
150 u_int fd_count;
151 SOCKET fd_array[FD_SETSIZE];
152} _ws_fd_set;
153
154/*
155 * Structure used for manipulating linger option.
156 */
157typedef struct ws_linger {
158 u_short l_onoff; /* option on/off */
159 u_short l_linger; /* linger time */
160} _ws_linger;
161
162/*
163 * Structures returned by network data base library, taken from the
164 * BSD file netdb.h. All addresses are supplied in host order, and
165 * returned in network order (suitable for use in system calls).
166 */
167
168typedef struct ws_hostent
169{
170 char * h_name; /* official name of host */
171 char ** h_aliases; /* alias list */
172 INT16 h_addrtype; /* host address type */
173 INT16 h_length; /* length of address */
174 char ** h_addr_list; /* list of addresses from name server */
175} _ws_hostent;
176
177typedef struct ws_protoent
178{
179 char * p_name; /* official protocol name */
180 char ** p_aliases; /* alias list */
181 INT16 p_proto; /* protocol # */
182} _ws_protoent;
183
184typedef struct ws_servent
185{
186 char * s_name; /* official service name */
187 char ** s_aliases; /* alias list */
188 INT16 s_port; /* port # */
189 char * s_proto; /* protocol to use */
190} _ws_servent;
191
192typedef struct ws_netent
193{
194 char * n_name; /* official name of net */
195 char ** n_aliases; /* alias list */
196 INT16 n_addrtype; /* net address type */
197 INT n_net; /* network # */
198} _ws_netent;
199
200#pragma pack()
201
202#define WS_MAX_SOCKETS_PER_PROCESS 2048
203#define WS_MAX_UDP_DATAGRAM 32767
204
205#define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
206#define WSI_BLOCKINGHOOK 0x00000002 /* 32-bit callback */
207
208typedef struct _WSINFO
209{
210 DWORD dwThisThread;
211 struct _WSINFO *lpNextIData;
212
213 unsigned flags;
214 INT16 num_startup; /* reference counter */
215 INT16 num_async_rq;
216 INT16 last_free; /* entry in the socket table */
217 USHORT buflen;
218 char* buffer; /* allocated from char * heap */
219 struct ws_hostent *he;
220 int helen;
221 struct ws_servent *se;
222 int selen;
223 struct ws_protoent *pe;
224 int pelen;
225 char* dbuffer; /* buffer for dummies (32 bytes) */
226
227 DWORD blocking_hook;
228} WSINFO, *LPWSINFO;
229
230void WIN32API WSASetLastError(int iError);
231int WIN32API WSAGetLastError(void);
232int WIN32API WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
233BOOL WIN32API WSAIsBlocking(void);
234
235extern BOOL fWSAInitialized;
236
237UINT wsaErrno();
238UINT wsaHerrno();
239
240#define CURRENT_THREAD -1
241void WSASetBlocking(BOOL fBlock, HANDLE tid = CURRENT_THREAD);
242
243void WINSOCK_DeleteIData(void);
244BOOL WINSOCK_CreateIData(void);
245LPWSINFO WINSOCK_GetIData(HANDLE tid = CURRENT_THREAD);
246
247typedef HANDLE WSAEVENT;
248
249// modes for the async select worker
250#define WSA_SELECT_HWND 1
251#define WSA_SELECT_HEVENT 2
252// async select worker routine
253int WSAAsyncSelectWorker(SOCKET s, int mode, DWORD notifyHandle, DWORD notifyData, DWORD lEventMask);
254
255typedef struct _WSANETWORKEVENTS
256{
257 long lNetworkEvents;
258 int iErrorCode[FD_MAX_EVENTS];
259} WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
260int WSAEnumNetworkEventsWorker(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lpEvent);
261
262#endif /* _WINSOCK32CONST_ */
263
264
Note: See TracBrowser for help on using the repository browser.