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

Last change on this file since 7022 was 7022, checked in by sandervl, 24 years ago

get/setsockopt updates

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