[7977] | 1 | /* $Id: wsock32.h,v 1.21 2002-02-20 15:07:14 sandervl Exp $ */
|
---|
[92] | 2 |
|
---|
| 3 | /* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
|
---|
[4] | 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 |
|
---|
[2013] | 15 | #ifndef _WINSOCK32CONST_
|
---|
| 16 | #define _WINSOCK32CONST_
|
---|
[4] | 17 |
|
---|
[7368] | 18 | #include "socketwrap.h"
|
---|
[21916] | 19 | #include <sys/time.h>
|
---|
[4] | 20 |
|
---|
[3229] | 21 | #include <odinwrap.h>
|
---|
| 22 |
|
---|
[21916] | 23 | #ifdef __EMX__
|
---|
| 24 | // EMX 0.6.4 and before lacks this
|
---|
| 25 | #ifndef SOCBASEERR
|
---|
| 26 | #define SOCBASEERR 0
|
---|
| 27 | #endif
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
[7022] | 30 | #ifndef IP_TTL
|
---|
| 31 | #define IP_TTL 7
|
---|
| 32 | #define IP_TOS 8
|
---|
[21308] | 33 | #define IP_DONTFRAGMENT 9
|
---|
[7022] | 34 | #endif
|
---|
| 35 |
|
---|
[4] | 36 | /*
|
---|
[3229] | 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
|
---|
[6196] | 61 | // also apply to Winsock 2.0 WSAEventSelect
|
---|
[6201] | 62 | #define FD_MAX_EVENTS 10
|
---|
[6196] | 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
|
---|
[3229] | 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)
|
---|
[21417] | 127 | #define WSAEDISCON (WSABASEERR+101)
|
---|
| 128 | #define WSATYPE_NOT_FOUND (WSABASEERR+109)
|
---|
[3229] | 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 |
|
---|
| 135 | typedef u_int SOCKET;
|
---|
| 136 |
|
---|
[21916] | 137 | #ifndef FD_SETSIZE
|
---|
[3229] | 138 | #define FD_SETSIZE 64
|
---|
[21916] | 139 | #endif
|
---|
[3229] | 140 |
|
---|
| 141 | #pragma pack(1)
|
---|
| 142 |
|
---|
| 143 | #define WSADESCRIPTION_LEN 256
|
---|
| 144 | #define WSASYS_STATUS_LEN 128
|
---|
| 145 |
|
---|
| 146 | typedef 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;
|
---|
| 155 | typedef WSADATA *PWSADATA;
|
---|
| 156 | typedef WSADATA *LPWSADATA;
|
---|
| 157 |
|
---|
| 158 | typedef struct ws_fd_set {
|
---|
| 159 | u_int fd_count;
|
---|
| 160 | SOCKET fd_array[FD_SETSIZE];
|
---|
| 161 | } _ws_fd_set;
|
---|
| 162 |
|
---|
| 163 | /*
|
---|
[4] | 164 | * Structure used for manipulating linger option.
|
---|
| 165 | */
|
---|
[3229] | 166 | typedef struct ws_linger {
|
---|
[4] | 167 | u_short l_onoff; /* option on/off */
|
---|
| 168 | u_short l_linger; /* linger time */
|
---|
[3229] | 169 | } _ws_linger;
|
---|
[4] | 170 |
|
---|
| 171 | /*
|
---|
[2013] | 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).
|
---|
[4] | 175 | */
|
---|
| 176 |
|
---|
[3229] | 177 | typedef 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;
|
---|
[4] | 185 |
|
---|
[3229] | 186 | typedef 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;
|
---|
[4] | 192 |
|
---|
[21417] | 193 | typedef struct ws_servent
|
---|
[3229] | 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;
|
---|
[4] | 200 |
|
---|
[3229] | 201 | typedef 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;
|
---|
[4] | 208 |
|
---|
[3229] | 209 | #pragma pack()
|
---|
| 210 |
|
---|
[5279] | 211 | #define WS_MAX_SOCKETS_PER_PROCESS 2048
|
---|
| 212 | #define WS_MAX_UDP_DATAGRAM 32767
|
---|
[3229] | 213 |
|
---|
| 214 | #define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
|
---|
| 215 | #define WSI_BLOCKINGHOOK 0x00000002 /* 32-bit callback */
|
---|
| 216 |
|
---|
| 217 | typedef struct _WSINFO
|
---|
[2013] | 218 | {
|
---|
[3229] | 219 | DWORD dwThisThread;
|
---|
| 220 | struct _WSINFO *lpNextIData;
|
---|
[4] | 221 |
|
---|
[3229] | 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) */
|
---|
[4] | 235 |
|
---|
[3229] | 236 | DWORD blocking_hook;
|
---|
| 237 | } WSINFO, *LPWSINFO;
|
---|
[4] | 238 |
|
---|
[3229] | 239 | void WIN32API WSASetLastError(int iError);
|
---|
| 240 | int WIN32API WSAGetLastError(void);
|
---|
| 241 | int WIN32API WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
|
---|
| 242 | BOOL WIN32API WSAIsBlocking(void);
|
---|
| 243 |
|
---|
[3139] | 244 | extern BOOL fWSAInitialized;
|
---|
| 245 |
|
---|
[3229] | 246 | UINT wsaErrno();
|
---|
| 247 | UINT wsaHerrno();
|
---|
[3139] | 248 |
|
---|
[3229] | 249 | #define CURRENT_THREAD -1
|
---|
| 250 | void WSASetBlocking(BOOL fBlock, HANDLE tid = CURRENT_THREAD);
|
---|
[3139] | 251 |
|
---|
[3229] | 252 | void WINSOCK_DeleteIData(void);
|
---|
| 253 | BOOL WINSOCK_CreateIData(void);
|
---|
| 254 | LPWSINFO WINSOCK_GetIData(HANDLE tid = CURRENT_THREAD);
|
---|
[3139] | 255 |
|
---|
[6196] | 256 | typedef 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
|
---|
[7977] | 262 | int WSAAsyncSelectWorker(SOCKET s, int mode, DWORD notifyHandle, DWORD notifyData, DWORD lEventMask);
|
---|
[6196] | 263 |
|
---|
[21417] | 264 | typedef struct _WSANETWORKEVENTS
|
---|
[6201] | 265 | {
|
---|
| 266 | long lNetworkEvents;
|
---|
| 267 | int iErrorCode[FD_MAX_EVENTS];
|
---|
| 268 | } WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
|
---|
| 269 | int WSAEnumNetworkEventsWorker(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lpEvent);
|
---|
| 270 |
|
---|
[2013] | 271 | #endif /* _WINSOCK32CONST_ */
|
---|
[4] | 272 |
|
---|
[2013] | 273 |
|
---|