ReactOS  0.4.13-dev-563-g0561610
ip.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/ip.h
5  * PURPOSE: Internet Protocol related definitions
6  */
7 
8 #pragma once
9 
11 
12 #define FOURCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
13 
14 /* Raw IPv4 style address */
17 
18 /* Raw IPv6 style address */
21 
22 /* IP style address */
23 typedef struct IP_ADDRESS {
24  UCHAR Type; /* Type of IP address */
25  union {
26  IPv4_RAW_ADDRESS IPv4Address;/* IPv4 address (in network byte order) */
27  IPv6_RAW_ADDRESS IPv6Address;/* IPv6 address (in network byte order) */
28  } Address;
30 
31 /* IP type constants */
32 #define IP_ADDRESS_V4 0x04 /* IPv4 style address */
33 #define IP_ADDRESS_V6 0x06 /* IPv6 style address */
34 
35 
36 /* IPv4 header format */
37 typedef struct IPv4_HEADER {
38  UCHAR VerIHL; /* 4-bit version, 4-bit Internet Header Length */
39  UCHAR Tos; /* Type of Service */
40  USHORT TotalLength; /* Total Length */
41  USHORT Id; /* Identification */
42  USHORT FlagsFragOfs; /* 3-bit Flags, 13-bit Fragment Offset */
43  UCHAR Ttl; /* Time to Live */
44  UCHAR Protocol; /* Protocol */
45  USHORT Checksum; /* Header Checksum */
46  IPv4_RAW_ADDRESS SrcAddr; /* Source Address */
47  IPv4_RAW_ADDRESS DstAddr; /* Destination Address */
49 
50 /* IPv6 header format */
51 typedef struct IPv6_HEADER {
52  ULONG VTF; /* Version, Traffic Class, Flow Label */
54  UCHAR NextHeader; /* Same as Protocol in IPv4 */
55  UCHAR HopLimit; /* Same as Ttl in IPv4 */
59 
60 typedef union _IP_HEADER {
64 
65 #define IPv4_FRAGOFS_MASK 0x1FFF /* Fragment offset mask (host byte order) */
66 #define IPv4_MF_MASK 0x2000 /* More fragments (host byte order) */
67 #define IPv4_DF_MASK 0x4000 /* Don't fragment (host byte order) */
68 #define IPv4_MAX_HEADER_SIZE 60
69 
70 /* Packet completion handler prototype */
72  PVOID Context,
73  PNDIS_PACKET NdisPacket,
74  NDIS_STATUS NdisStatus);
75 
76 /* Structure for an IP packet */
77 typedef struct _IP_PACKET {
78  OBJECT_FREE_ROUTINE Free; /* Routine used to free resources for the object */
79  UCHAR Type; /* Type of IP packet (see IP_ADDRESS_xx above) */
80  UCHAR Flags; /* Flags for packet (see IP_PACKET_FLAG_xx below)*/
81  BOOLEAN MappedHeader; /* States whether Header is from an MDL or allocated from pool */
82  BOOLEAN ReturnPacket; /* States whether NdisPacket should be passed to NdisReturnPackets */
83  PVOID Header; /* Pointer to IP header for this packet */
84  UINT HeaderSize; /* Size of IP header */
85  PVOID Data; /* Current pointer into packet data */
86  UINT TotalSize; /* Total amount of data in packet (IP header and data) */
87  UINT Position; /* Current logical offset into packet */
88  PNDIS_PACKET NdisPacket; /* Pointer to NDIS packet */
89  IP_ADDRESS SrcAddr; /* Source address */
90  IP_ADDRESS DstAddr; /* Destination address */
92 
93 #define IP_PACKET_FLAG_RAW 0x01 /* Raw IP packet */
94 
95 
96 /* Packet context */
97 typedef struct _PACKET_CONTEXT {
98  PACKET_COMPLETION_ROUTINE DLComplete; /* Data link level completion handler
99  * Also used to link to next packet
100  * in a queue */
101  PVOID Context; /* Context information for handler */
102  UINT PacketType; /* Type of packet */
104 
105 /* The ProtocolReserved field is structured as a PACKET_CONTEXT */
106 #define PC(Packet) ((PPACKET_CONTEXT)(&Packet->ProtocolReserved))
107 
108 /* Values for address type -- also the interface flags */
109 /* These values are mean to overlap meaningfully with the BSD ones */
110 #define ADE_UNICAST 0x01
111 #define ADE_BROADCAST 0x02
112 #define ADE_ADDRMASK 0x04
113 #define ADE_POINTOPOINT 0x10
114 #define ADE_MULTICAST 0x8000
115 
116 /* There is one NTE for each source (unicast) address assigned to an interface */
117 /* Link layer transmit prototype */
119  PVOID Context,
120  PNDIS_PACKET NdisPacket,
121  UINT Offset,
122  PVOID LinkAddress,
123  USHORT Type);
124 
125 /* Link layer to IP binding information */
126 typedef struct _LLIP_BIND_INFO {
127  PVOID Context; /* Pointer to link layer context information */
128  UINT HeaderSize; /* Size of link level header */
129  UINT MinFrameSize; /* Minimum frame size in bytes */
130  PUCHAR Address; /* Pointer to interface address */
131  UINT AddressLength; /* Length of address in bytes */
132  LL_TRANSMIT_ROUTINE Transmit; /* Transmit function for this interface */
134 
135 typedef struct _SEND_RECV_STATS {
148 
149 /* Information about an IP interface */
150 typedef struct _IP_INTERFACE {
151  LIST_ENTRY ListEntry; /* Entry on list */
152  OBJECT_FREE_ROUTINE Free; /* Routine used to free resources used by the object */
153  KSPIN_LOCK Lock; /* Spin lock for this object */
154  PVOID Context; /* Pointer to link layer context information */
155  UINT HeaderSize; /* Size of link level header */
156  UINT MinFrameSize; /* Minimum frame size in bytes */
157  UINT MTU; /* Maximum transmission unit */
158  UINT Speed; /* Link speed */
159  IP_ADDRESS Unicast; /* Unicast address */
160  IP_ADDRESS PointToPoint; /* Point to point address */
161  IP_ADDRESS Netmask; /* Netmask */
162  IP_ADDRESS Broadcast; /* Broadcast */
163  UNICODE_STRING Name; /* Adapter name (GUID) */
164  UNICODE_STRING Description; /* Adapter description (Human readable) */
165  PUCHAR Address; /* Pointer to interface address */
166  UINT AddressLength; /* Length of address in bytes */
167  UINT Index; /* Index of adapter (used to add ip addr) */
168  LL_TRANSMIT_ROUTINE Transmit; /* Pointer to transmit function */
169  PVOID TCPContext; /* TCP Content for this interface */
170  SEND_RECV_STATS Stats; /* Send/Receive statistics */
172 
173 typedef struct _IP_SET_ADDRESS {
178 
179 #define IP_PROTOCOL_TABLE_SIZE 0x100
180 
183  PIP_PACKET IPPacket);
184 
185 /* Loopback adapter address information (network byte order) */
186 #define LOOPBACK_ADDRESS_IPv4 ((IPv4_RAW_ADDRESS)DH2N(0x7F000001))
187 #define LOOPBACK_BCASTADDR_IPv4 ((IPv4_RAW_ADDRESS)DH2N(0x7FFFFFFF))
188 #define LOOPBACK_ADDRMASK_IPv4 ((IPv4_RAW_ADDRESS)DH2N(0xFF000000))
189 
190 /* Protocol definitions */
191 #ifndef IPPROTO_RAW
192 #define IPPROTO_RAW 0 /* Raw IP */
193 #endif
194 #define IPPROTO_ICMP 1 /* Internet Control Message Protocol */
195 #define IPPROTO_IGMP 2 /* Internet Group Management Protocol */
196 #define IPPROTO_TCP 6 /* Transmission Control Protocol */
197 #define IPPROTO_UDP 17 /* User Datagram Protocol */
198 
199 /* Timeout timer constants */
200 #define IP_TIMEOUT 1000 /* Timeout in milliseconds */
201 #define IP_DEFAULT_LINK_SPEED 10000
202 
207 
209  ULONG Type);
210 
212  PIP_PACKET IPPacket,
213  ULONG Type);
214 
216  PLLIP_BIND_INFO BindInfo);
217 
219  PIP_INTERFACE IF);
220 
222  PIP_INTERFACE IF);
223 
225  PIP_INTERFACE IF);
226 
228  PIP_INTERFACE IF);
229 
231  PIP_INTERFACE IF);
232 
237 
240  PIP_PACKET IPPacket);
241 
243  UINT ProtocolNumber,
245 
247 
249 
250 /* EOF */
PVOID Context
Definition: ip.h:101
VOID(* LL_TRANSMIT_ROUTINE)(PVOID Context, PNDIS_PACKET NdisPacket, UINT Offset, PVOID LinkAddress, USHORT Type)
Definition: ip.h:118
IP_ADDRESS Broadcast
Definition: ip.h:162
UINT AddressLength
Definition: ip.h:131
VOID IPDestroyInterface(PIP_INTERFACE IF)
Definition: ip.c:246
VOID NTAPI IPTimeoutDpcFn(PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
Definition: ip.c:112
struct _SEND_RECV_STATS * PSEND_RECV_STATS
VOID IPDispatchProtocol(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
Definition: ip.c:142
IPv4_HEADER v4
Definition: ip.h:61
IPv4_RAW_ADDRESS IPv4Address
Definition: ip.h:26
NTSTATUS IPShutdown(VOID)
Definition: ip.c:477
UINT OutBytes
Definition: ip.h:142
IPv4_RAW_ADDRESS Netmask
Definition: ip.h:176
ULONG IPv4_RAW_ADDRESS
Definition: ip.h:15
USHORT PayloadLength
Definition: ip.h:53
ULONG VTF
Definition: ip.h:52
struct _LLIP_BIND_INFO LLIP_BIND_INFO
LIST_ENTRY NetTableListHead
Definition: ip.c:19
UINT InDiscardedUnknownProto
Definition: ip.h:141
Type
Definition: Type.h:6
UCHAR Tos
Definition: ip.h:39
IPv6_RAW_ADDRESS DstAddr
Definition: ip.h:57
IPv6_RAW_ADDRESS IPv6Address
Definition: ip.h:27
UINT PacketType
Definition: ip.h:102
UNICODE_STRING Description
Definition: ip.h:164
struct IP_ADDRESS * PIP_ADDRESS
VOID IPUnregisterInterface(PIP_INTERFACE IF)
Definition: ip.c:353
UINT MinFrameSize
Definition: ip.h:129
unsigned char * PUCHAR
Definition: retypes.h:3
struct _IP_SET_ADDRESS * PIP_SET_ADDRESS
KSPIN_LOCK InterfaceListLock
Definition: ip.c:18
struct _IP_INTERFACE * PIP_INTERFACE
IP_ADDRESS SrcAddr
Definition: ip.h:89
PVOID Context
Definition: ip.h:127
LONG NTSTATUS
Definition: precomp.h:26
PIP_PACKET IPCreatePacket(ULONG Type)
UINT InDiscarded
Definition: ip.h:139
PVOID TCPContext
Definition: ip.h:169
USHORT TotalLength
Definition: ip.h:40
union _IP_HEADER IP_HEADER
PIP_INTERFACE IPCreateInterface(PLLIP_BIND_INFO BindInfo)
Definition: ip.c:182
UNICODE_STRING Name
Definition: ip.h:163
UINT OutErrors
Definition: ip.h:146
ULONG NteIndex
Definition: ip.h:174
OBJECT_FREE_ROUTINE Free
Definition: ip.h:78
UINT MinFrameSize
Definition: ip.h:156
PUCHAR Address
Definition: ip.h:130
VOID IPRegisterProtocol(UINT ProtocolNumber, IP_PROTOCOL_HANDLER Handler)
Definition: ip.c:390
UINT AddressLength
Definition: ip.h:166
LL_TRANSMIT_ROUTINE Transmit
Definition: ip.h:132
struct IPv6_HEADER * PIPv6_HEADER
int NDIS_STATUS
Definition: ntddndis.h:445
PVOID Data
Definition: ip.h:85
UINT OutUnicast
Definition: ip.h:143
Definition: ip.h:23
struct _PACKET_CONTEXT PACKET_CONTEXT
OBJECT_FREE_ROUTINE Free
Definition: ip.h:152
UCHAR NextHeader
Definition: ip.h:54
VOID(* IP_PROTOCOL_HANDLER)(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
Definition: ip.h:181
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
USHORT FlagsFragOfs
Definition: ip.h:42
VOID(* PACKET_COMPLETION_ROUTINE)(PVOID Context, PNDIS_PACKET NdisPacket, NDIS_STATUS NdisStatus)
Definition: ip.h:71
struct _IP_PACKET * PIP_PACKET
LIST_ENTRY ListEntry
Definition: ip.h:151
PIP_PACKET IPInitializePacket(PIP_PACKET IPPacket, ULONG Type)
Definition: ip.c:92
UINT InNUnicast
Definition: ip.h:138
UCHAR VerIHL
Definition: ip.h:38
PVOID Header
Definition: ip.h:83
unsigned char BOOLEAN
struct _IP_INTERFACE IP_INTERFACE
IP_ADDRESS Unicast
Definition: ip.h:159
BOOLEAN IPRegisterInterface(PIP_INTERFACE IF)
Definition: ip.c:293
UCHAR Ttl
Definition: ip.h:43
UINT MTU
Definition: ip.h:157
IPv6_RAW_ADDRESS SrcAddr
Definition: ip.h:56
struct IPv4_HEADER IPv4_HEADER
UINT OutNUnicast
Definition: ip.h:144
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:524
PACKET_COMPLETION_ROUTINE DLComplete
Definition: ip.h:98
PUCHAR Address
Definition: ip.h:165
LL_TRANSMIT_ROUTINE Transmit
Definition: ip.h:168
UINT Index
Definition: ip.h:167
IPv6_RAW_ADDRESS * PIPv6_RAW_ADDRESS
Definition: ip.h:20
UINT HeaderSize
Definition: ip.h:128
struct _SEND_RECV_STATS SEND_RECV_STATS
UINT Position
Definition: ip.h:87
UINT TotalSize
Definition: ip.h:86
UCHAR Type
Definition: ip.h:79
IPv4_RAW_ADDRESS DstAddr
Definition: ip.h:47
KSPIN_LOCK NetTableListLock
Definition: ip.c:20
UINT InUnicast
Definition: ip.h:137
UCHAR Flags
Definition: ip.h:80
UCHAR Protocol
Definition: ip.h:44
static IUnknown Object
Definition: main.c:512
VOID IPAddInterfaceRoute(PIP_INTERFACE IF)
Definition: ip.c:266
UINT InBytes
Definition: ip.h:136
unsigned char UCHAR
Definition: xmlstorage.h:181
UINT HeaderSize
Definition: ip.h:84
UCHAR HopLimit
Definition: ip.h:55
USHORT Checksum
Definition: ip.h:45
Definition: ketypes.h:687
struct _IP_SET_ADDRESS IP_SET_ADDRESS
#define VOID
Definition: acefi.h:82
UINT Speed
Definition: ip.h:158
Definition: typedefs.h:117
VOID(* OBJECT_FREE_ROUTINE)(PVOID Object)
Definition: ip.h:10
IPv4_RAW_ADDRESS Address
Definition: ip.h:175
struct IP_ADDRESS IP_ADDRESS
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:656
Definition: ip.h:60
PVOID Context
Definition: ip.h:154
UINT OutDiscarded
Definition: ip.h:145
IPv4_RAW_ADDRESS * PIPv4_RAW_ADDRESS
Definition: ip.h:16
IP_ADDRESS Netmask
Definition: ip.h:161
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
KSPIN_LOCK Lock
Definition: ip.h:153
LIST_ENTRY InterfaceListHead
Definition: ip.c:17
UCHAR Type
Definition: ip.h:24
IPv4_RAW_ADDRESS SrcAddr
Definition: ip.h:46
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
Definition: ip.c:411
struct _LLIP_BIND_INFO * PLLIP_BIND_INFO
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
VOID IPRemoveInterfaceRoute(PIP_INTERFACE IF)
Definition: ip.c:335
UINT HeaderSize
Definition: ip.h:155
union _IP_HEADER * PIP_HEADER
BOOLEAN ReturnPacket
Definition: ip.h:82
unsigned int UINT
Definition: ndis.h:50
PNDIS_PACKET NdisPacket
Definition: ip.h:88
Definition: ip.h:37
Definition: ip.h:51
USHORT IPv6_RAW_ADDRESS[8]
Definition: ip.h:19
struct _IP_PACKET IP_PACKET
BOOLEAN MappedHeader
Definition: ip.h:81
UINT InErrors
Definition: ip.h:140
struct tagContext Context
Definition: acpixf.h:1012
unsigned int ULONG
Definition: retypes.h:1
SEND_RECV_STATS Stats
Definition: ip.h:170
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
IP_ADDRESS PointToPoint
Definition: ip.h:160
IP_ADDRESS DstAddr
Definition: ip.h:90
Definition: ip.h:77
USHORT Id
Definition: ip.h:41
IPv6_HEADER v6
Definition: ip.h:62
struct _PACKET_CONTEXT * PPACKET_CONTEXT
struct IPv4_HEADER * PIPv4_HEADER
union IP_ADDRESS::@973 Address
struct IPv6_HEADER IPv6_HEADER
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675