stop the abuse of having the ddk directory in the path when including a ddk header
[reactos.git] / reactos / drivers / net / tcpip / include / tcpip.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: include/tcpip.h
5 * PURPOSE: TCP/IP protocol driver definitions
6 * NOTES: Spin lock acquire order:
7 * - Net table list lock
8 * - Interface lock
9 * - Interface list lock
10 * - Prefix list lock
11 * - Neighbor cache lock
12 * - Route cache lock
13 */
14 #ifndef __TCPIP_H
15 #define __TCPIP_H
16
17 #ifdef _MSC_VER
18 #include <basetsd.h>
19 #include <ntddk.h>
20 #include <windef.h>
21 #include <ndis.h>
22 #include <tdikrnl.h>
23 #include <tdiinfo.h>
24 #else
25 #include <ntddk.h>
26 #include <ndis.h>
27 #include <tdikrnl.h>
28 #include <tdiinfo.h>
29 #endif
30
31 #include <debug.h>
32
33 #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
34 #define TAG_STRING TAG('S', 'T', 'R', ' ') /* string */
35
36 /* Define _NTTEST_ to make test version. Device names are prefixed with
37 'NT' to allow the driver to run side by side with MS TCP/IP driver */
38 //#define _NTTEST_
39
40 /* FIXME: The following should be moved to ntddk.h or tdi headers */
41 #ifndef _MSC_VER
42
43 #ifndef IO_NETWORK_INCREMENT
44 #define IO_NETWORK_INCREMENT 2
45 #endif
46
47 #endif
48
49 #ifdef _MSC_VER
50 /* EXPORTED is already defined ddk/defines.h */
51 #define EXPORTED __declspec(dllexport)
52
53 #endif
54
55 #include <titypes.h>
56 #include <ticonsts.h>
57
58 /* Macros */
59
60 #define MIN(value1, value2) \
61 ((value1 < value2)? value1 : value2)
62
63 #define MAX(value1, value2) \
64 ((value1 > value2)? value1 : value2)
65
66 #define NDIS_BUFFER_TAG FOURCC('n','b','u','f')
67 #define NDIS_PACKET_TAG FOURCC('n','p','k','t')
68
69 #ifdef i386
70
71 /* DWORD network to host byte order conversion for i386 */
72 #define DN2H(dw) \
73 ((((dw) & 0xFF000000L) >> 24) | \
74 (((dw) & 0x00FF0000L) >> 8) | \
75 (((dw) & 0x0000FF00L) << 8) | \
76 (((dw) & 0x000000FFL) << 24))
77
78 /* DWORD host to network byte order conversion for i386 */
79 #define DH2N(dw) \
80 ((((dw) & 0xFF000000L) >> 24) | \
81 (((dw) & 0x00FF0000L) >> 8) | \
82 (((dw) & 0x0000FF00L) << 8) | \
83 (((dw) & 0x000000FFL) << 24))
84
85 /* WORD network to host order conversion for i386 */
86 #define WN2H(w) \
87 ((((w) & 0xFF00) >> 8) | \
88 (((w) & 0x00FF) << 8))
89
90 /* WORD host to network byte order conversion for i386 */
91 #define WH2N(w) \
92 ((((w) & 0xFF00) >> 8) | \
93 (((w) & 0x00FF) << 8))
94
95 #else /* i386 */
96
97 /* DWORD network to host byte order conversion for other architectures */
98 #define DN2H(dw) \
99 (dw)
100
101 /* DWORD host to network byte order conversion for other architectures */
102 #define DH2N(dw) \
103 (dw)
104
105 /* WORD network to host order conversion for other architectures */
106 #define WN2H(w) \
107 (w)
108
109 /* WORD host to network byte order conversion for other architectures */
110 #define WH2N(w) \
111 (w)
112
113 #endif /* i386 */
114
115 /* AF_INET and other things Arty likes to use ;) */
116 #define AF_INET 2
117 #define SOCK_STREAM 1
118
119 /* Should use TDI structure, but Arty wants to keep BSD style */
120 typedef unsigned char u_char;
121 typedef unsigned short u_short;
122 typedef unsigned int u_int;
123 typedef unsigned long u_long;
124 struct in_addr
125 {
126 union
127 {
128 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
129 struct { u_short s_w1,s_w2; } S_un_w;
130 u_long S_addr;
131 } S_un;
132 #define s_addr S_un.S_addr
133 #define s_host S_un.S_un_b.s_b2
134 #define s_net S_un.S_un_b.s_b1
135 #define s_imp S_un.S_un_w.s_w2
136 #define s_impno S_un.S_un_b.s_b4
137 #define s_lh S_un.S_un_b.s_b3
138 };
139 struct sockaddr_in
140 {
141 short sin_family;
142 u_short sin_port;
143 struct in_addr sin_addr;
144 char sin_zero[8];
145 };
146 typedef struct sockaddr_in SOCKADDR_IN;
147 struct sockaddr
148 {
149 u_short sa_family;
150 char sa_data[14];
151 };
152
153 typedef TDI_STATUS (*InfoRequest_f)( UINT InfoClass,
154 UINT InfoType,
155 UINT InfoId,
156 PVOID Context,
157 TDIEntityID *id,
158 PNDIS_BUFFER Buffer,
159 PUINT BufferSize );
160
161 typedef TDI_STATUS (*InfoSet_f)( UINT InfoClass,
162 UINT InfoType,
163 UINT InfoId,
164 PVOID Context,
165 TDIEntityID *id,
166 PCHAR Buffer,
167 UINT BufferSize );
168
169 /* Sufficient information to manage the entity list */
170 typedef struct {
171 UINT tei_entity;
172 UINT tei_instance;
173 PVOID context;
174 InfoRequest_f info_req;
175 InfoSet_f info_set;
176 } TDIEntityInfo;
177
178 #ifndef htons
179 #define htons(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
180 #endif
181
182 /* Global variable */
183 extern PDEVICE_OBJECT TCPDeviceObject;
184 extern PDEVICE_OBJECT UDPDeviceObject;
185 extern PDEVICE_OBJECT IPDeviceObject;
186 extern PDEVICE_OBJECT RawIPDeviceObject;
187 extern LIST_ENTRY InterfaceListHead;
188 extern KSPIN_LOCK InterfaceListLock;
189 extern LIST_ENTRY AddressFileListHead;
190 extern KSPIN_LOCK AddressFileListLock;
191 extern NDIS_HANDLE GlobalPacketPool;
192 extern NDIS_HANDLE GlobalBufferPool;
193 extern KSPIN_LOCK EntityListLock;
194 extern TDIEntityInfo *EntityList;
195 extern ULONG EntityCount;
196 extern ULONG EntityMax;
197
198 extern NTSTATUS TiGetProtocolNumber( PUNICODE_STRING FileName,
199 PULONG Protocol );
200
201 #endif /* __TCPIP_H */
202
203 /* EOF */