- Implement ProtocolResetComplete
[reactos.git] / dll / win32 / ws2_32 / include / ws2_32.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 DLL
4 * FILE: include/ws2_32.h
5 * PURPOSE: WinSock 2 DLL header
6 */
7 #ifndef __WS2_32_H
8 #define __WS2_32_H
9
10 #define WIN32_NO_STATUS
11 #include <roscfg.h>
12 #include <winsock2.h>
13 #include <ws2spi.h>
14 #include <ws2tcpip.h>
15 #include <windows.h>
16 #define NTOS_MODE_USER
17 #include <ndk/ntndk.h>
18
19 #include <wsahelp.h>
20
21 #undef assert
22 #include <debug.h>
23 #include <windns.h> // DNS_A_DATA
24
25 /* Exported by ntdll.dll, but where is the prototype? */
26 unsigned long strtoul(const char *nptr, char **endptr, int base);
27
28
29 #define EXPORT STDCALL
30
31 extern HINSTANCE g_hInstDll;
32 extern HANDLE GlobalHeap;
33 extern BOOL WsaInitialized; /* TRUE if WSAStartup() has been successfully called */
34 extern WSPUPCALLTABLE UpcallTable;
35
36 #define WS2_INTERNAL_MAX_ALIAS 16
37
38 typedef struct _WINSOCK_GETSERVBYNAME_CACHE
39 {
40 UINT Size;
41 SERVENT ServerEntry;
42 PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS];
43 CHAR Data[1];
44 } WINSOCK_GETSERVBYNAME_CACHE, *PWINSOCK_GETSERVBYNAME_CACHE;
45
46 typedef struct _WINSOCK_GETSERVBYPORT_CACHE
47 {
48 UINT Size;
49 SERVENT ServerEntry;
50 PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS];
51 CHAR Data[1];
52 } WINSOCK_GETSERVBYPORT_CACHE, *PWINSOCK_GETSERVBYPORT_CACHE;
53
54 typedef struct _WINSOCK_THREAD_BLOCK
55 {
56 INT LastErrorValue; /* Error value from last function that failed */
57 CHAR Intoa[16]; /* Buffer for inet_ntoa() */
58 PWINSOCK_GETSERVBYNAME_CACHE
59 Getservbyname; /* Buffer used by getservbyname */
60 PWINSOCK_GETSERVBYPORT_CACHE
61 Getservbyport; /* Buffer used by getservbyname */
62 struct hostent* Hostent;
63 } WINSOCK_THREAD_BLOCK, *PWINSOCK_THREAD_BLOCK;
64
65
66 /* Macros */
67
68 #define WSAINITIALIZED (WsaInitialized)
69
70 #define WSASETINITIALIZED (WsaInitialized = TRUE)
71
72 /* ws2_32 internal Functions */
73 void check_hostent(struct hostent **he);
74 void populate_hostent(struct hostent *he, char* name, DNS_A_DATA addr);
75 void free_hostent(struct hostent *he);
76 void free_servent(struct servent* s);
77
78 #ifdef LE
79
80 /* DWORD network to host byte order conversion for little endian machines */
81 #define DN2H(dw) \
82 ((((dw) & 0xFF000000L) >> 24) | \
83 (((dw) & 0x00FF0000L) >> 8) | \
84 (((dw) & 0x0000FF00L) << 8) | \
85 (((dw) & 0x000000FFL) << 24))
86
87 /* DWORD host to network byte order conversion for little endian machines */
88 #define DH2N(dw) \
89 ((((dw) & 0xFF000000L) >> 24) | \
90 (((dw) & 0x00FF0000L) >> 8) | \
91 (((dw) & 0x0000FF00L) << 8) | \
92 (((dw) & 0x000000FFL) << 24))
93
94 /* WORD network to host order conversion for little endian machines */
95 #define WN2H(w) \
96 ((((w) & 0xFF00) >> 8) | \
97 (((w) & 0x00FF) << 8))
98
99 /* WORD host to network byte order conversion for little endian machines */
100 #define WH2N(w) \
101 ((((w) & 0xFF00) >> 8) | \
102 (((w) & 0x00FF) << 8))
103
104 #else /* LE */
105
106 /* DWORD network to host byte order conversion for big endian machines */
107 #define DN2H(dw) \
108 (dw)
109
110 /* DWORD host to network byte order conversion big endian machines */
111 #define DH2N(dw) \
112 (dw)
113
114 /* WORD network to host order conversion for big endian machines */
115 #define WN2H(w) \
116 (w)
117
118 /* WORD host to network byte order conversion for big endian machines */
119 #define WH2N(w) \
120 (w)
121
122 #endif /* LE */
123
124 #endif /* __WS2_32_H */
125
126 /* EOF */