[YAROTOWS] Reintegrate the branch. For a brighter future.
[reactos.git] / reactos / drivers / network / 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
15 #pragma once
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_STRING ' RTS' /* string */
34
35 /* Define _NTTEST_ to make test version. Device names are prefixed with
36 'NT' to allow the driver to run side by side with MS TCP/IP driver */
37 //#define _NTTEST_
38
39 /* FIXME: The following should be moved to ntddk.h or tdi headers */
40 #ifndef _MSC_VER
41
42 #ifndef IO_NETWORK_INCREMENT
43 #define IO_NETWORK_INCREMENT 2
44 #endif
45
46 #endif
47
48 #ifdef _MSC_VER
49 /* EXPORTED is already defined ddk/defines.h */
50 #define EXPORTED __declspec(dllexport)
51
52 #endif
53
54 #include <titypes.h>
55 #include <ticonsts.h>
56
57 /* Macros */
58
59 #define MIN(value1, value2) \
60 ((value1 < value2)? value1 : value2)
61
62 #define MAX(value1, value2) \
63 ((value1 > value2)? value1 : value2)
64
65 #define NDIS_BUFFER_TAG FOURCC('n','b','u','f')
66 #define NDIS_PACKET_TAG FOURCC('n','p','k','t')
67
68 #ifdef i386
69
70 /* DWORD network to host byte order conversion for i386 */
71 #define DN2H(dw) \
72 ((((dw) & 0xFF000000L) >> 24) | \
73 (((dw) & 0x00FF0000L) >> 8) | \
74 (((dw) & 0x0000FF00L) << 8) | \
75 (((dw) & 0x000000FFL) << 24))
76
77 /* DWORD host to network byte order conversion for i386 */
78 #define DH2N(dw) \
79 ((((dw) & 0xFF000000L) >> 24) | \
80 (((dw) & 0x00FF0000L) >> 8) | \
81 (((dw) & 0x0000FF00L) << 8) | \
82 (((dw) & 0x000000FFL) << 24))
83
84 /* WORD network to host order conversion for i386 */
85 #define WN2H(w) \
86 ((((w) & 0xFF00) >> 8) | \
87 (((w) & 0x00FF) << 8))
88
89 /* WORD host to network byte order conversion for i386 */
90 #define WH2N(w) \
91 ((((w) & 0xFF00) >> 8) | \
92 (((w) & 0x00FF) << 8))
93
94 #else /* i386 */
95
96 /* DWORD network to host byte order conversion for other architectures */
97 #define DN2H(dw) \
98 (dw)
99
100 /* DWORD host to network byte order conversion for other architectures */
101 #define DH2N(dw) \
102 (dw)
103
104 /* WORD network to host order conversion for other architectures */
105 #define WN2H(w) \
106 (w)
107
108 /* WORD host to network byte order conversion for other architectures */
109 #define WH2N(w) \
110 (w)
111
112 #endif /* i386 */
113
114 /* AF_INET and other things Arty likes to use ;) */
115 #define AF_INET 2
116 #define SOCK_STREAM 1
117
118 /* Should use TDI structure, but Arty wants to keep BSD style */
119 typedef unsigned char u_char;
120 typedef unsigned short u_short;
121 typedef unsigned int u_int;
122 typedef unsigned long u_long;
123 struct in_addr
124 {
125 union
126 {
127 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
128 struct { u_short s_w1,s_w2; } S_un_w;
129 u_long S_addr;
130 } S_un;
131 #define s_addr S_un.S_addr
132 #define s_host S_un.S_un_b.s_b2
133 #define s_net S_un.S_un_b.s_b1
134 #define s_imp S_un.S_un_w.s_w2
135 #define s_impno S_un.S_un_b.s_b4
136 #define s_lh S_un.S_un_b.s_b3
137 };
138 struct sockaddr_in
139 {
140 short sin_family;
141 u_short sin_port;
142 struct in_addr sin_addr;
143 char sin_zero[8];
144 };
145 typedef struct sockaddr_in SOCKADDR_IN;
146 struct sockaddr
147 {
148 u_short sa_family;
149 char sa_data[14];
150 };
151
152 /* Sufficient information to manage the entity list */
153 typedef struct {
154 UINT tei_entity;
155 UINT tei_instance;
156 PVOID context;
157 UINT flags;
158 } TDIEntityInfo;
159
160 #ifndef htons
161 #define htons(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
162 #endif
163
164 /* Global variable */
165 extern PDEVICE_OBJECT TCPDeviceObject;
166 extern PDEVICE_OBJECT UDPDeviceObject;
167 extern PDEVICE_OBJECT IPDeviceObject;
168 extern PDEVICE_OBJECT RawIPDeviceObject;
169 extern LIST_ENTRY InterfaceListHead;
170 extern KSPIN_LOCK InterfaceListLock;
171 extern LIST_ENTRY AddressFileListHead;
172 extern KSPIN_LOCK AddressFileListLock;
173 extern NDIS_HANDLE GlobalPacketPool;
174 extern NDIS_HANDLE GlobalBufferPool;
175 extern KSPIN_LOCK EntityListLock;
176 extern TDIEntityInfo *EntityList;
177 extern ULONG EntityCount;
178 extern ULONG EntityMax;
179
180 extern NTSTATUS TiGetProtocolNumber( PUNICODE_STRING FileName,
181 PULONG Protocol );
182
183 /* EOF */