ReactOS  0.4.14-dev-114-gc8cbd56
tcpip.h
Go to the documentation of this file.
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 #if defined(i386) || defined(_AMD64_) || defined(_ARM_)
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 /* defined(i386) || defined(_AMD64_) || defined(_ARM_) */
95 
96 #error Unsupported architecture
97 
98 /* DWORD network to host byte order conversion for other architectures */
99 #define DN2H(dw) \
100  (dw)
101 
102 /* DWORD host to network byte order conversion for other architectures */
103 #define DH2N(dw) \
104  (dw)
105 
106 /* WORD network to host order conversion for other architectures */
107 #define WN2H(w) \
108  (w)
109 
110 /* WORD host to network byte order conversion for other architectures */
111 #define WH2N(w) \
112  (w)
113 
114 #endif /* defined(i386) || defined(_AMD64_) || defined(_ARM_) */
115 
116 /* AF_INET and other things Arty likes to use ;) */
117 #define AF_INET 2
118 #define SOCK_STREAM 1
119 
120 /* Should use TDI structure, but Arty wants to keep BSD style */
121 typedef unsigned char u_char;
122 typedef unsigned short u_short;
123 typedef unsigned int u_int;
124 typedef unsigned long u_long;
125 struct in_addr
126 {
127  union
128  {
130  struct { u_short s_w1,s_w2; } S_un_w;
132  } S_un;
133 #define s_addr S_un.S_addr
134 #define s_host S_un.S_un_b.s_b2
135 #define s_net S_un.S_un_b.s_b1
136 #define s_imp S_un.S_un_w.s_w2
137 #define s_impno S_un.S_un_b.s_b4
138 #define s_lh S_un.S_un_b.s_b3
139 };
140 
141 #define __LWIP_INET_H__
142 #include "lwip/sockets.h"
143 
144 /* Sufficient information to manage the entity list */
145 typedef struct {
150 } TDIEntityInfo;
151 
152 #ifndef htons
153 #define htons(x) WH2N(x)
154 #endif
155 
156 /* Global variable */
168 extern TDIEntityInfo *EntityList;
169 extern ULONG EntityCount;
170 extern ULONG EntityMax;
171 
173  PULONG Protocol );
174 
175 /* EOF */
KSPIN_LOCK AddressFileListLock
Definition: fileobjs.c:22
ULONG EntityMax
Definition: main.c:25
u_char s_b2
Definition: tcpip.h:129
LIST_ENTRY AddressFileListHead
Definition: fileobjs.c:21
ULONG EntityCount
Definition: main.c:24
u_short s_w1
Definition: tcpip.h:130
NDIS_HANDLE GlobalPacketPool
Definition: routines.c:3
KSPIN_LOCK EntityListLock
Definition: main.c:22
unsigned long u_long
Definition: linux.h:269
TDIEntityInfo * EntityList
Definition: main.c:23
LONG NTSTATUS
Definition: precomp.h:26
LIST_ENTRY InterfaceListHead
Definition: ip.c:17
PDEVICE_OBJECT TCPDeviceObject
Definition: main.c:16
UINT tei_entity
Definition: tcpip.h:146
unsigned char u_char
Definition: tcpip.h:121
u_char s_b1
Definition: tcpip.h:129
PDEVICE_OBJECT IPDeviceObject
Definition: main.c:18
PDEVICE_OBJECT RawIPDeviceObject
Definition: main.c:19
u_char s_b3
Definition: tcpip.h:129
unsigned int u_int
Definition: tcpip.h:123
PDEVICE_OBJECT UDPDeviceObject
Definition: main.c:17
NDIS_HANDLE GlobalBufferPool
Definition: routines.c:4
struct in_addr::@994::@996 S_un_w
struct in_addr::@994::@995 S_un_b
NTSTATUS TiGetProtocolNumber(PUNICODE_STRING FileName, PULONG Protocol)
Definition: proto.c:3
UINT tei_instance
Definition: tcpip.h:147
KSPIN_LOCK InterfaceListLock
Definition: ip.c:18
unsigned short u_short
Definition: tcpip.h:122
union in_addr::@994 S_un
Definition: tcpip.h:125
PVOID context
Definition: tcpip.h:148
unsigned short u_short
Definition: types.h:81
unsigned long u_long
Definition: tcpip.h:124
Definition: typedefs.h:117
u_long S_addr
Definition: tcpip.h:131
UINT flags
Definition: tcpip.h:149
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
u_char s_b4
Definition: tcpip.h:129
unsigned int * PULONG
Definition: retypes.h:1
unsigned int UINT
Definition: ndis.h:50
unsigned int ULONG
Definition: retypes.h:1
UCHAR u_char
Definition: types.h:80
u_short s_w2
Definition: tcpip.h:130