ReactOS 0.4.15-dev-7788-g1ad9096
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 */
121typedef unsigned char u_char;
122typedef unsigned short u_short;
123typedef unsigned int u_int;
124typedef unsigned long u_long;
126{
127 union
128 {
130 struct { u_short s_w1,s_w2; } S_un_w;
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 */
145typedef struct {
151
152#ifndef htons
153#define htons(x) WH2N(x)
154#endif
155
156/* Global variable */
169extern ULONG EntityCount;
170extern ULONG EntityMax;
171
174
175/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
KSPIN_LOCK AddressFileListLock
Definition: fileobjs.c:22
NDIS_HANDLE GlobalBufferPool
Definition: routines.c:4
PDEVICE_OBJECT UDPDeviceObject
Definition: main.c:21
ULONG EntityMax
Definition: main.c:29
KSPIN_LOCK InterfaceListLock
Definition: ip.c:18
NDIS_HANDLE GlobalPacketPool
Definition: routines.c:3
PDEVICE_OBJECT TCPDeviceObject
Definition: main.c:20
NTSTATUS TiGetProtocolNumber(PUNICODE_STRING FileName, PULONG Protocol)
Definition: proto.c:3
unsigned long u_long
Definition: tcpip.h:124
LIST_ENTRY AddressFileListHead
Definition: fileobjs.c:21
LIST_ENTRY InterfaceListHead
Definition: ip.c:17
ULONG EntityCount
Definition: main.c:28
unsigned short u_short
Definition: tcpip.h:122
unsigned int u_int
Definition: tcpip.h:123
TDIEntityInfo * EntityList
Definition: main.c:27
KSPIN_LOCK EntityListLock
Definition: main.c:26
PDEVICE_OBJECT IPDeviceObject
Definition: main.c:22
unsigned char u_char
Definition: tcpip.h:121
PDEVICE_OBJECT RawIPDeviceObject
Definition: main.c:23
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
unsigned int UINT
Definition: ndis.h:50
UINT tei_instance
Definition: tcpip.h:147
PVOID context
Definition: tcpip.h:148
UINT flags
Definition: tcpip.h:149
UINT tei_entity
Definition: tcpip.h:146
Definition: typedefs.h:120
Definition: tcpip.h:126
struct in_addr::@1019::@1020 S_un_b
u_char s_b1
Definition: tcpip.h:129
u_long S_addr
Definition: tcpip.h:131
struct in_addr::@1019::@1021 S_un_w
u_short s_w1
Definition: tcpip.h:130
u_char s_b4
Definition: tcpip.h:129
union in_addr::@1019 S_un
u_char s_b2
Definition: tcpip.h:129
u_short s_w2
Definition: tcpip.h:130
u_char s_b3
Definition: tcpip.h:129
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
unsigned long u_long
Definition: winsock2.h:59
unsigned short u_short
Definition: winsock2.h:56
unsigned char u_char
Definition: winsock2.h:55