9b077841cfd31eb5f6df07f207f5eef77d06f51d
[reactos.git] / 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
139 #define __LWIP_INET_H__
140 #include "lwip/sockets.h"
141
142 /* Sufficient information to manage the entity list */
143 typedef struct {
144 UINT tei_entity;
145 UINT tei_instance;
146 PVOID context;
147 UINT flags;
148 } TDIEntityInfo;
149
150 #ifndef htons
151 #define htons(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
152 #endif
153
154 /* Global variable */
155 extern PDEVICE_OBJECT TCPDeviceObject;
156 extern PDEVICE_OBJECT UDPDeviceObject;
157 extern PDEVICE_OBJECT IPDeviceObject;
158 extern PDEVICE_OBJECT RawIPDeviceObject;
159 extern LIST_ENTRY InterfaceListHead;
160 extern KSPIN_LOCK InterfaceListLock;
161 extern LIST_ENTRY AddressFileListHead;
162 extern KSPIN_LOCK AddressFileListLock;
163 extern NDIS_HANDLE GlobalPacketPool;
164 extern NDIS_HANDLE GlobalBufferPool;
165 extern KSPIN_LOCK EntityListLock;
166 extern TDIEntityInfo *EntityList;
167 extern ULONG EntityCount;
168 extern ULONG EntityMax;
169
170 extern NTSTATUS TiGetProtocolNumber( PUNICODE_STRING FileName,
171 PULONG Protocol );
172
173 /* EOF */