ReactOS  0.4.13-dev-92-gf251225
ip.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  IP_ADDRESS
 
struct  IPv4_HEADER
 
struct  IPv6_HEADER
 
union  _IP_HEADER
 
struct  _IP_PACKET
 
struct  _PACKET_CONTEXT
 
struct  _LLIP_BIND_INFO
 
struct  _SEND_RECV_STATS
 
struct  _IP_INTERFACE
 
struct  _IP_SET_ADDRESS
 

Macros

#define FOURCC(a, b, c, d)   (((a)<<24)|((b)<<16)|((c)<<8)|(d))
 
#define IP_ADDRESS_V4   0x04 /* IPv4 style address */
 
#define IP_ADDRESS_V6   0x06 /* IPv6 style address */
 
#define IPv4_FRAGOFS_MASK   0x1FFF /* Fragment offset mask (host byte order) */
 
#define IPv4_MF_MASK   0x2000 /* More fragments (host byte order) */
 
#define IPv4_DF_MASK   0x4000 /* Don't fragment (host byte order) */
 
#define IPv4_MAX_HEADER_SIZE   60
 
#define IP_PACKET_FLAG_RAW   0x01 /* Raw IP packet */
 
#define PC(Packet)   ((PPACKET_CONTEXT)(&Packet->ProtocolReserved))
 
#define ADE_UNICAST   0x01
 
#define ADE_BROADCAST   0x02
 
#define ADE_ADDRMASK   0x04
 
#define ADE_POINTOPOINT   0x10
 
#define ADE_MULTICAST   0x8000
 
#define IP_PROTOCOL_TABLE_SIZE   0x100
 
#define LOOPBACK_ADDRESS_IPv4   ((IPv4_RAW_ADDRESS)DH2N(0x7F000001))
 
#define LOOPBACK_BCASTADDR_IPv4   ((IPv4_RAW_ADDRESS)DH2N(0x7FFFFFFF))
 
#define LOOPBACK_ADDRMASK_IPv4   ((IPv4_RAW_ADDRESS)DH2N(0xFF000000))
 
#define IPPROTO_RAW   0 /* Raw IP */
 
#define IPPROTO_ICMP   1 /* Internet Control Message Protocol */
 
#define IPPROTO_IGMP   2 /* Internet Group Management Protocol */
 
#define IPPROTO_TCP   6 /* Transmission Control Protocol */
 
#define IPPROTO_UDP   17 /* User Datagram Protocol */
 
#define IP_TIMEOUT   1000 /* Timeout in milliseconds */
 
#define IP_DEFAULT_LINK_SPEED   10000
 

Typedefs

typedef VOID(* OBJECT_FREE_ROUTINE) (PVOID Object)
 
typedef ULONG IPv4_RAW_ADDRESS
 
typedef IPv4_RAW_ADDRESSPIPv4_RAW_ADDRESS
 
typedef USHORT IPv6_RAW_ADDRESS[8]
 
typedef IPv6_RAW_ADDRESSPIPv6_RAW_ADDRESS
 
typedef struct IP_ADDRESS IP_ADDRESS
 
typedef struct IP_ADDRESSPIP_ADDRESS
 
typedef struct IPv4_HEADER IPv4_HEADER
 
typedef struct IPv4_HEADERPIPv4_HEADER
 
typedef struct IPv6_HEADER IPv6_HEADER
 
typedef struct IPv6_HEADERPIPv6_HEADER
 
typedef union _IP_HEADER IP_HEADER
 
typedef union _IP_HEADERPIP_HEADER
 
typedef VOID(* PACKET_COMPLETION_ROUTINE) (PVOID Context, PNDIS_PACKET NdisPacket, NDIS_STATUS NdisStatus)
 
typedef struct _IP_PACKET IP_PACKET
 
typedef struct _IP_PACKETPIP_PACKET
 
typedef struct _PACKET_CONTEXT PACKET_CONTEXT
 
typedef struct _PACKET_CONTEXTPPACKET_CONTEXT
 
typedef VOID(* LL_TRANSMIT_ROUTINE) (PVOID Context, PNDIS_PACKET NdisPacket, UINT Offset, PVOID LinkAddress, USHORT Type)
 
typedef struct _LLIP_BIND_INFO LLIP_BIND_INFO
 
typedef struct _LLIP_BIND_INFOPLLIP_BIND_INFO
 
typedef struct _SEND_RECV_STATS SEND_RECV_STATS
 
typedef struct _SEND_RECV_STATSPSEND_RECV_STATS
 
typedef struct _IP_INTERFACE IP_INTERFACE
 
typedef struct _IP_INTERFACEPIP_INTERFACE
 
typedef struct _IP_SET_ADDRESS IP_SET_ADDRESS
 
typedef struct _IP_SET_ADDRESSPIP_SET_ADDRESS
 
typedef VOID(* IP_PROTOCOL_HANDLER) (PIP_INTERFACE Interface, PIP_PACKET IPPacket)
 

Functions

PIP_PACKET IPCreatePacket (ULONG Type)
 
PIP_PACKET IPInitializePacket (PIP_PACKET IPPacket, ULONG Type)
 
PIP_INTERFACE IPCreateInterface (PLLIP_BIND_INFO BindInfo)
 
VOID IPAddInterfaceRoute (PIP_INTERFACE IF)
 
VOID IPRemoveInterfaceRoute (PIP_INTERFACE IF)
 
VOID IPDestroyInterface (PIP_INTERFACE IF)
 
BOOLEAN IPRegisterInterface (PIP_INTERFACE IF)
 
VOID IPUnregisterInterface (PIP_INTERFACE IF)
 
VOID NTAPI IPTimeoutDpcFn (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
VOID IPDispatchProtocol (PIP_INTERFACE Interface, PIP_PACKET IPPacket)
 
VOID IPRegisterProtocol (UINT ProtocolNumber, IP_PROTOCOL_HANDLER Handler)
 
NTSTATUS IPStartup (PUNICODE_STRING RegistryPath)
 
NTSTATUS IPShutdown (VOID)
 

Variables

LIST_ENTRY InterfaceListHead
 
KSPIN_LOCK InterfaceListLock
 
LIST_ENTRY NetTableListHead
 
KSPIN_LOCK NetTableListLock
 

Macro Definition Documentation

◆ ADE_ADDRMASK

#define ADE_ADDRMASK   0x04

Definition at line 112 of file ip.h.

◆ ADE_BROADCAST

#define ADE_BROADCAST   0x02

Definition at line 111 of file ip.h.

◆ ADE_MULTICAST

#define ADE_MULTICAST   0x8000

Definition at line 114 of file ip.h.

◆ ADE_POINTOPOINT

#define ADE_POINTOPOINT   0x10

Definition at line 113 of file ip.h.

◆ ADE_UNICAST

#define ADE_UNICAST   0x01

Definition at line 110 of file ip.h.

◆ FOURCC

#define FOURCC (   a,
  b,
  c,
  d 
)    (((a)<<24)|((b)<<16)|((c)<<8)|(d))

Definition at line 12 of file ip.h.

◆ IP_ADDRESS_V4

#define IP_ADDRESS_V4   0x04 /* IPv4 style address */

Definition at line 32 of file ip.h.

◆ IP_ADDRESS_V6

#define IP_ADDRESS_V6   0x06 /* IPv6 style address */

Definition at line 33 of file ip.h.

◆ IP_DEFAULT_LINK_SPEED

#define IP_DEFAULT_LINK_SPEED   10000

Definition at line 201 of file ip.h.

◆ IP_PACKET_FLAG_RAW

#define IP_PACKET_FLAG_RAW   0x01 /* Raw IP packet */

Definition at line 93 of file ip.h.

◆ IP_PROTOCOL_TABLE_SIZE

#define IP_PROTOCOL_TABLE_SIZE   0x100

Definition at line 179 of file ip.h.

◆ IP_TIMEOUT

#define IP_TIMEOUT   1000 /* Timeout in milliseconds */

Definition at line 200 of file ip.h.

◆ IPPROTO_ICMP

#define IPPROTO_ICMP   1 /* Internet Control Message Protocol */

Definition at line 194 of file ip.h.

◆ IPPROTO_IGMP

#define IPPROTO_IGMP   2 /* Internet Group Management Protocol */

Definition at line 195 of file ip.h.

◆ IPPROTO_RAW

#define IPPROTO_RAW   0 /* Raw IP */

Definition at line 192 of file ip.h.

◆ IPPROTO_TCP

#define IPPROTO_TCP   6 /* Transmission Control Protocol */

Definition at line 196 of file ip.h.

◆ IPPROTO_UDP

#define IPPROTO_UDP   17 /* User Datagram Protocol */

Definition at line 197 of file ip.h.

◆ IPv4_DF_MASK

#define IPv4_DF_MASK   0x4000 /* Don't fragment (host byte order) */

Definition at line 67 of file ip.h.

◆ IPv4_FRAGOFS_MASK

#define IPv4_FRAGOFS_MASK   0x1FFF /* Fragment offset mask (host byte order) */

Definition at line 65 of file ip.h.

◆ IPv4_MAX_HEADER_SIZE

#define IPv4_MAX_HEADER_SIZE   60

Definition at line 68 of file ip.h.

◆ IPv4_MF_MASK

#define IPv4_MF_MASK   0x2000 /* More fragments (host byte order) */

Definition at line 66 of file ip.h.

◆ LOOPBACK_ADDRESS_IPv4

#define LOOPBACK_ADDRESS_IPv4   ((IPv4_RAW_ADDRESS)DH2N(0x7F000001))

Definition at line 186 of file ip.h.

◆ LOOPBACK_ADDRMASK_IPv4

#define LOOPBACK_ADDRMASK_IPv4   ((IPv4_RAW_ADDRESS)DH2N(0xFF000000))

Definition at line 188 of file ip.h.

◆ LOOPBACK_BCASTADDR_IPv4

#define LOOPBACK_BCASTADDR_IPv4   ((IPv4_RAW_ADDRESS)DH2N(0x7FFFFFFF))

Definition at line 187 of file ip.h.

◆ PC

#define PC (   Packet)    ((PPACKET_CONTEXT)(&Packet->ProtocolReserved))

Definition at line 106 of file ip.h.

Typedef Documentation

◆ IP_ADDRESS

◆ IP_HEADER

typedef union _IP_HEADER IP_HEADER

◆ IP_INTERFACE

◆ IP_PACKET

◆ IP_PROTOCOL_HANDLER

typedef VOID(* IP_PROTOCOL_HANDLER) (PIP_INTERFACE Interface, PIP_PACKET IPPacket)

Definition at line 181 of file ip.h.

◆ IP_SET_ADDRESS

◆ IPv4_HEADER

◆ IPv4_RAW_ADDRESS

Definition at line 15 of file ip.h.

◆ IPv6_HEADER

◆ IPv6_RAW_ADDRESS

typedef USHORT IPv6_RAW_ADDRESS[8]

Definition at line 19 of file ip.h.

◆ LL_TRANSMIT_ROUTINE

typedef VOID(* LL_TRANSMIT_ROUTINE) (PVOID Context, PNDIS_PACKET NdisPacket, UINT Offset, PVOID LinkAddress, USHORT Type)

Definition at line 118 of file ip.h.

◆ LLIP_BIND_INFO

◆ OBJECT_FREE_ROUTINE

typedef VOID(* OBJECT_FREE_ROUTINE) (PVOID Object)

Definition at line 10 of file ip.h.

◆ PACKET_COMPLETION_ROUTINE

typedef VOID(* PACKET_COMPLETION_ROUTINE) (PVOID Context, PNDIS_PACKET NdisPacket, NDIS_STATUS NdisStatus)

Definition at line 71 of file ip.h.

◆ PACKET_CONTEXT

◆ PIP_ADDRESS

◆ PIP_HEADER

typedef union _IP_HEADER * PIP_HEADER

◆ PIP_INTERFACE

◆ PIP_PACKET

◆ PIP_SET_ADDRESS

◆ PIPv4_HEADER

◆ PIPv4_RAW_ADDRESS

Definition at line 16 of file ip.h.

◆ PIPv6_HEADER

◆ PIPv6_RAW_ADDRESS

Definition at line 20 of file ip.h.

◆ PLLIP_BIND_INFO

◆ PPACKET_CONTEXT

◆ PSEND_RECV_STATS

◆ SEND_RECV_STATS

Function Documentation

◆ IPAddInterfaceRoute()

VOID IPAddInterfaceRoute ( PIP_INTERFACE  IF)

Definition at line 266 of file ip.c.

266  {
269 
270  /* Add a permanent neighbor for this NTE */
271  NCE = NBAddNeighbor(IF, &IF->Unicast,
272  IF->Address, IF->AddressLength,
273  NUD_PERMANENT, 0);
274  if (!NCE) {
275  TI_DbgPrint(MIN_TRACE, ("Could not create NCE.\n"));
276  return;
277  }
278 
280 
281  if (!RouterAddRoute(&NetworkAddress, &IF->Netmask, NCE, 1)) {
282  TI_DbgPrint(MIN_TRACE, ("Could not add route due to insufficient resources.\n"));
283  }
284 
285  /* Send a gratuitous ARP packet to update the route caches of
286  * other computers */
287  if (IF != Loopback)
288  ARPTransmit(NULL, NULL, IF);
289 
291 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
Definition: neighbor.h:28
#define NUD_PERMANENT
Definition: neighbor.h:42
UINT AddressLength
Definition: ip.h:166
PIP_INTERFACE Loopback
Definition: loopback.c:13
Definition: ip.h:23
BOOLEAN ARPTransmit(PIP_ADDRESS Address, PVOID LinkAddress, PIP_INTERFACE Interface)
Definition: arp.c:111
smooth NULL
Definition: ftsmooth.c:416
IP_ADDRESS Unicast
Definition: ip.h:159
PUCHAR Address
Definition: ip.h:165
VOID AddrWidenAddress(PIP_ADDRESS Network, PIP_ADDRESS Source, PIP_ADDRESS Netmask)
Definition: address.c:86
_Must_inspect_result_ _Out_ PNDIS_STATUS _Outptr_result_bytebuffer_to_ NetworkAddressLength PVOID * NetworkAddress
Definition: ndis.h:3938
PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(PIP_INTERFACE Interface, PIP_ADDRESS Address, PVOID LinkAddress, UINT LinkAddressLength, UCHAR Type, UINT EventTimer)
Definition: neighbor.c:273
IP_ADDRESS Netmask
Definition: ip.h:161
#define MIN_TRACE
Definition: debug.h:14
PFIB_ENTRY RouterAddRoute(PIP_ADDRESS NetworkAddress, PIP_ADDRESS Netmask, PNEIGHBOR_CACHE_ENTRY Router, UINT Metric)
Definition: router.c:189
VOID TCPUpdateInterfaceIPInformation(PIP_INTERFACE IF)
Definition: if.c:145

Referenced by DispTdiSetIPAddress(), LoopRegisterAdapter(), and ReadIpConfiguration().

◆ IPCreateInterface()

PIP_INTERFACE IPCreateInterface ( PLLIP_BIND_INFO  BindInfo)

Definition at line 182 of file ip.c.

192 {
193  PIP_INTERFACE IF;
194 
195  TI_DbgPrint(DEBUG_IP, ("Called. BindInfo (0x%X).\n", BindInfo));
196 
197 #if DBG
198  if (BindInfo->Address) {
199  PUCHAR A = BindInfo->Address;
200  TI_DbgPrint(DEBUG_IP, ("Interface address (%02X %02X %02X %02X %02X %02X).\n",
201  A[0], A[1], A[2], A[3], A[4], A[5]));
202  }
203 #endif
204 
207  if (!IF) {
208  TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
209  return NULL;
210  }
211 
212  RtlZeroMemory(IF, sizeof(IP_INTERFACE));
213 
214  IF->Free = FreeIF;
215  IF->Context = BindInfo->Context;
216  IF->HeaderSize = BindInfo->HeaderSize;
217  IF->MinFrameSize = BindInfo->MinFrameSize;
218  IF->Address = BindInfo->Address;
219  IF->AddressLength = BindInfo->AddressLength;
220  IF->Transmit = BindInfo->Transmit;
221 
222  IF->Unicast.Type = IP_ADDRESS_V4;
224  IF->Netmask.Type = IP_ADDRESS_V4;
226 
228 
230  ( NonPagedPool, sizeof(struct netif));
231  if (!IF->TCPContext) {
233  return NULL;
234  }
235 
237 
238 #ifdef __NTDRIVER__
240 #endif
241 
242  return IF;
243 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
IP_ADDRESS Broadcast
Definition: ip.h:162
UINT AddressLength
Definition: ip.h:131
#define IP_INTERFACE_TAG
Definition: tags.h:19
UINT MinFrameSize
Definition: ip.h:129
unsigned char * PUCHAR
Definition: retypes.h:3
PVOID Context
Definition: ip.h:127
PVOID TCPContext
Definition: ip.h:169
UINT MinFrameSize
Definition: ip.h:156
PUCHAR Address
Definition: ip.h:130
UINT AddressLength
Definition: ip.h:166
VOID FreeIF(PVOID Object)
Definition: ip.c:81
LL_TRANSMIT_ROUTINE Transmit
Definition: ip.h:132
OBJECT_FREE_ROUTINE Free
Definition: ip.h:152
#define IP_ADDRESS_V4
Definition: ip.h:32
VOID TCPRegisterInterface(PIP_INTERFACE IF)
Definition: if.c:119
smooth NULL
Definition: ftsmooth.c:416
IP_ADDRESS Unicast
Definition: ip.h:159
#define DEBUG_IP
Definition: debug.h:26
PUCHAR Address
Definition: ip.h:165
LL_TRANSMIT_ROUTINE Transmit
Definition: ip.h:168
UINT HeaderSize
Definition: ip.h:128
Definition: netif.h:136
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: ttei1.cpp:12
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PVOID Context
Definition: ip.h:154
IP_ADDRESS Netmask
Definition: ip.h:161
KSPIN_LOCK Lock
Definition: ip.h:153
UCHAR Type
Definition: ip.h:24
VOID InsertTDIInterfaceEntity(PIP_INTERFACE Interface)
Definition: iinfo.c:158
UINT HeaderSize
Definition: ip.h:155
VOID TcpipInitializeSpinLock(PKSPIN_LOCK SpinLock)
Definition: lock.c:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
IP_ADDRESS PointToPoint
Definition: ip.h:160
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by BindAdapter(), LoopRegisterAdapter(), and main().

◆ IPCreatePacket()

PIP_PACKET IPCreatePacket ( ULONG  Type)

◆ IPDestroyInterface()

VOID IPDestroyInterface ( PIP_INTERFACE  IF)

Definition at line 246 of file ip.c.

253 {
254  TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
255 
256 #ifdef __NTDRIVER__
258 #endif
259 
261 
262  ExFreePool(IF->TCPContext);
264 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define IP_INTERFACE_TAG
Definition: tags.h:19
VOID TCPUnregisterInterface(PIP_INTERFACE IF)
Definition: if.c:139
PVOID TCPContext
Definition: ip.h:169
#define DEBUG_IP
Definition: debug.h:26
VOID RemoveTDIInterfaceEntity(PIP_INTERFACE Interface)
Definition: iinfo.c:168
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by BindAdapter(), LoopUnregisterAdapter(), and UnbindAdapter().

◆ IPDispatchProtocol()

VOID IPDispatchProtocol ( PIP_INTERFACE  Interface,
PIP_PACKET  IPPacket 
)

Definition at line 142 of file ip.c.

154 {
155  UINT Protocol;
156  IP_ADDRESS SrcAddress;
157 
158  switch (IPPacket->Type) {
159  case IP_ADDRESS_V4:
160  Protocol = ((PIPv4_HEADER)(IPPacket->Header))->Protocol;
161  AddrInitIPv4(&SrcAddress, ((PIPv4_HEADER)(IPPacket->Header))->SrcAddr);
162  break;
163  case IP_ADDRESS_V6:
164  /* FIXME: IPv6 adresses not supported */
165  TI_DbgPrint(MIN_TRACE, ("IPv6 datagram discarded.\n"));
166  return;
167  default:
168  TI_DbgPrint(MIN_TRACE, ("Unrecognized datagram discarded.\n"));
169  return;
170  }
171 
172  NBResetNeighborTimeout(&SrcAddress);
173 
175  {
176  /* Call the appropriate protocol handler */
177  (*ProtocolTable[Protocol])(Interface, IPPacket);
178  }
179 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define IP_PROTOCOL_TABLE_SIZE
Definition: ip.h:179
_In_ USHORT _In_ ULONG Protocol
Definition: wsk.h:182
VOID NBResetNeighborTimeout(PIP_ADDRESS Address)
Definition: neighbor.c:387
Definition: ip.h:23
#define IP_ADDRESS_V4
Definition: ip.h:32
PVOID Header
Definition: ip.h:83
#define IP_ADDRESS_V6
Definition: ip.h:33
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define AddrInitIPv4(IPAddress, RawAddress)
Definition: address.h:16
UCHAR Type
Definition: ip.h:79
IP_PROTOCOL_HANDLER ProtocolTable[IP_PROTOCOL_TABLE_SIZE]
Definition: ip.c:25
unsigned int UINT
Definition: ndis.h:50
Definition: ip.h:37
#define MIN_TRACE
Definition: debug.h:14
struct IPv4_HEADER * PIPv4_HEADER

Referenced by ProcessFragment().

◆ IPInitializePacket()

PIP_PACKET IPInitializePacket ( PIP_PACKET  IPPacket,
ULONG  Type 
)

Definition at line 92 of file ip.c.

102 {
103  RtlZeroMemory(IPPacket, sizeof(IP_PACKET));
104 
105  IPPacket->Free = DeinitializePacket;
106  IPPacket->Type = Type;
107 
108  return IPPacket;
109 }
Type
Definition: Type.h:6
OBJECT_FREE_ROUTINE Free
Definition: ip.h:78
VOID DeinitializePacket(PVOID Object)
Definition: ip.c:35
UCHAR Type
Definition: ip.h:79
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
Definition: ip.h:77

Referenced by BuildRawIpPacket(), BuildUDPPacket(), LanReceiveWorker(), LoopTransmit(), PrepareICMPPacket(), ProcessFragment(), and TCPSendDataCallback().

◆ IPRegisterInterface()

BOOLEAN IPRegisterInterface ( PIP_INTERFACE  IF)

Definition at line 293 of file ip.c.

302 {
303  KIRQL OldIrql;
304  UINT ChosenIndex = 0;
305  BOOLEAN IndexHasBeenChosen;
307 
308  TI_DbgPrint(MID_TRACE, ("Called. IF (0x%X).\n", IF));
309 
311 
312  /* Choose an index */
313  do {
314  IndexHasBeenChosen = TRUE;
316  if( Interface->Index == ChosenIndex ) {
317  ChosenIndex++;
318  IndexHasBeenChosen = FALSE;
319  }
320  } EndFor(Interface);
321  } while( !IndexHasBeenChosen );
322 
323  IF->Index = ChosenIndex;
324 
325  /* Add interface to the global interface list */
327  &IF->ListEntry,
329 
331 
332  return TRUE;
333 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define TRUE
Definition: types.h:120
#define MID_TRACE
Definition: debug.h:15
#define IF_LIST_ITER(n)
Definition: tilists.h:5
VOID TcpipReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL Irql)
Definition: lock.c:26
VOID TcpipAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL Irql)
Definition: lock.c:18
UCHAR KIRQL
Definition: env_spec_w32.h:591
LIST_ENTRY ListEntry
Definition: ip.h:151
unsigned char BOOLEAN
#define ForEachInterface(n)
Definition: tilists.h:9
LIST_ENTRY InterfaceListHead
Definition: ip.c:17
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
UINT Index
Definition: ip.h:167
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID TcpipInterlockedInsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY Item, PKSPIN_LOCK Lock)
Definition: lock.c:34
KSPIN_LOCK InterfaceListLock
Definition: ip.c:18
KSPIN_LOCK Lock
Definition: ip.h:153
#define EndFor(n)
Definition: tilists.h:20
unsigned int UINT
Definition: ndis.h:50

Referenced by BindAdapter(), and LoopRegisterAdapter().

◆ IPRegisterProtocol()

VOID IPRegisterProtocol ( UINT  ProtocolNumber,
IP_PROTOCOL_HANDLER  Handler 
)

Definition at line 390 of file ip.c.

401 {
402  if (ProtocolNumber >= IP_PROTOCOL_TABLE_SIZE) {
403  TI_DbgPrint(MIN_TRACE, ("Protocol number is out of range (%d).\n", ProtocolNumber));
404  return;
405  }
406 
407  ProtocolTable[ProtocolNumber] = Handler ? Handler : DefaultProtocolHandler;
408 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
VOID DefaultProtocolHandler(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
Definition: ip.c:373
#define IP_PROTOCOL_TABLE_SIZE
Definition: ip.h:179
IP_PROTOCOL_HANDLER ProtocolTable[IP_PROTOCOL_TABLE_SIZE]
Definition: ip.c:25
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
#define MIN_TRACE
Definition: debug.h:14

Referenced by ICMPShutdown(), ICMPStartup(), IPStartup(), RawIPShutdown(), RawIPStartup(), TCPShutdown(), TCPStartup(), UDPShutdown(), and UDPStartup().

◆ IPRemoveInterfaceRoute()

VOID IPRemoveInterfaceRoute ( PIP_INTERFACE  IF)

Definition at line 335 of file ip.c.

335  {
337  IP_ADDRESS GeneralRoute;
338 
339  NCE = NBLocateNeighbor(&IF->Unicast, IF);
340  if (NCE)
341  {
342  TI_DbgPrint(DEBUG_IP,("Removing interface Addr %s\n", A2S(&IF->Unicast)));
343  TI_DbgPrint(DEBUG_IP,(" Mask %s\n", A2S(&IF->Netmask)));
344 
345  AddrWidenAddress(&GeneralRoute,&IF->Unicast,&IF->Netmask);
346 
347  RouterRemoveRoute(&GeneralRoute, &IF->Unicast);
348 
349  NBRemoveNeighbor(NCE);
350  }
351 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
Definition: neighbor.h:28
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(PIP_ADDRESS Address, PIP_INTERFACE Interface)
Definition: neighbor.c:417
Definition: ip.h:23
IP_ADDRESS Unicast
Definition: ip.h:159
#define DEBUG_IP
Definition: debug.h:26
VOID NBRemoveNeighbor(PNEIGHBOR_CACHE_ENTRY NCE)
Definition: neighbor.c:590
VOID AddrWidenAddress(PIP_ADDRESS Network, PIP_ADDRESS Source, PIP_ADDRESS Netmask)
Definition: address.c:86
NTSTATUS RouterRemoveRoute(PIP_ADDRESS Target, PIP_ADDRESS Router)
Definition: router.c:364
IP_ADDRESS Netmask
Definition: ip.h:161
PCHAR A2S(PIP_ADDRESS Address)
Definition: address.c:17

Referenced by DispTdiDeleteIPAddress(), DispTdiSetIPAddress(), and IPUnregisterInterface().

◆ IPShutdown()

NTSTATUS IPShutdown ( VOID  )

Definition at line 477 of file ip.c.

484 {
485  TI_DbgPrint(MAX_TRACE, ("Called.\n"));
486 
487  if (!IPInitialized)
488  return STATUS_SUCCESS;
489 
490  /* Shutdown neighbor cache subsystem */
491  NBShutdown();
492 
493  /* Shutdown routing subsystem */
494  RouterShutdown();
495 
497 
498  /* Destroy lookaside lists */
502 
504 
505  return STATUS_SUCCESS;
506 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
NTSTATUS RouterShutdown(VOID)
Definition: router.c:500
BOOLEAN IPInitialized
Definition: ip.c:21
VOID IPFreeReassemblyList(VOID)
Definition: receive.c:485
NPAGED_LOOKASIDE_LIST IPHoleList
Definition: receive.c:19
NPAGED_LOOKASIDE_LIST IPDRList
Definition: receive.c:17
VOID NBShutdown(VOID)
Definition: neighbor.c:184
#define MAX_TRACE
Definition: debug.h:16
NPAGED_LOOKASIDE_LIST IPFragmentList
Definition: receive.c:18
return STATUS_SUCCESS
Definition: btrfs.c:2725
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:174

Referenced by TiUnload().

◆ IPStartup()

NTSTATUS IPStartup ( PUNICODE_STRING  RegistryPath)

Definition at line 411 of file ip.c.

419 {
420  UINT i;
421 
422  TI_DbgPrint(MAX_TRACE, ("Called.\n"));
423 
424  /* Initialize lookaside lists */
426  &IPDRList, /* Lookaside list */
427  NULL, /* Allocate routine */
428  NULL, /* Free routine */
429  0, /* Flags */
430  sizeof(IPDATAGRAM_REASSEMBLY), /* Size of each entry */
431  DATAGRAM_REASSEMBLY_TAG, /* Tag */
432  0); /* Depth */
433 
435  &IPFragmentList, /* Lookaside list */
436  NULL, /* Allocate routine */
437  NULL, /* Free routine */
438  0, /* Flags */
439  sizeof(IP_FRAGMENT), /* Size of each entry */
440  DATAGRAM_FRAGMENT_TAG, /* Tag */
441  0); /* Depth */
442 
444  &IPHoleList, /* Lookaside list */
445  NULL, /* Allocate routine */
446  NULL, /* Free routine */
447  0, /* Flags */
448  sizeof(IPDATAGRAM_HOLE), /* Size of each entry */
449  DATAGRAM_HOLE_TAG, /* Tag */
450  0); /* Depth */
451 
452  /* Start routing subsystem */
453  RouterStartup();
454 
455  /* Start neighbor cache subsystem */
456  NBStartup();
457 
458  /* Fill the protocol dispatch table with pointers
459  to the default protocol handler */
460  for (i = 0; i < IP_PROTOCOL_TABLE_SIZE; i++)
462 
463  /* Initialize NTE list and protecting lock */
466 
467  /* Initialize reassembly list and protecting lock */
470 
472 
473  return STATUS_SUCCESS;
474 }
KSPIN_LOCK ReassemblyListLock
Definition: receive.c:16
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define TRUE
Definition: types.h:120
VOID DefaultProtocolHandler(PIP_INTERFACE Interface, PIP_PACKET IPPacket)
Definition: ip.c:373
#define DATAGRAM_REASSEMBLY_TAG
Definition: tags.h:20
#define IP_PROTOCOL_TABLE_SIZE
Definition: ip.h:179
VOID IPRegisterProtocol(UINT ProtocolNumber, IP_PROTOCOL_HANDLER Handler)
Definition: ip.c:390
KSPIN_LOCK NetTableListLock
Definition: ip.c:20
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOLEAN IPInitialized
Definition: ip.c:21
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS RouterStartup(VOID)
Definition: router.c:482
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:222
#define DATAGRAM_FRAGMENT_TAG
Definition: tags.h:21
NPAGED_LOOKASIDE_LIST IPHoleList
Definition: receive.c:19
NPAGED_LOOKASIDE_LIST IPDRList
Definition: receive.c:17
#define DATAGRAM_HOLE_TAG
Definition: tags.h:22
#define MAX_TRACE
Definition: debug.h:16
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VOID TcpipInitializeSpinLock(PKSPIN_LOCK SpinLock)
Definition: lock.c:14
unsigned int UINT
Definition: ndis.h:50
LIST_ENTRY NetTableListHead
Definition: ip.c:19
NPAGED_LOOKASIDE_LIST IPFragmentList
Definition: receive.c:18
return STATUS_SUCCESS
Definition: btrfs.c:2725
VOID NBStartup(VOID)
Definition: neighbor.c:169
LIST_ENTRY ReassemblyListHead
Definition: receive.c:15

Referenced by DriverEntry(), and main().

◆ IPTimeoutDpcFn()

VOID NTAPI IPTimeoutDpcFn ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

Definition at line 112 of file ip.c.

126 {
128 
129  if ((IpTimerExpirations % 10) == 0)
130  {
132  }
133 
134  /* Check if datagram fragments have taken too long to assemble */
136 
137  /* Clean possible outdated cached neighbor addresses */
138  NBTimeout();
139 }
VOID IPDatagramReassemblyTimeout(VOID)
Definition: receive.c:515
ULONG IpTimerExpirations
Definition: ip.c:27
VOID LogActiveObjects(VOID)
Definition: fileobjs.c:109
VOID NBTimeout(VOID)
Definition: neighbor.c:91

Referenced by DriverEntry().

◆ IPUnregisterInterface()

VOID IPUnregisterInterface ( PIP_INTERFACE  IF)

Definition at line 353 of file ip.c.

360 {
361  KIRQL OldIrql3;
362 
363  TI_DbgPrint(DEBUG_IP, ("Called. IF (0x%X).\n", IF));
364 
366 
370 }
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
VOID TcpipReleaseSpinLock(PKSPIN_LOCK SpinLock, KIRQL Irql)
Definition: lock.c:26
VOID TcpipAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL Irql)
Definition: lock.c:18
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
LIST_ENTRY ListEntry
Definition: ip.h:151
#define DEBUG_IP
Definition: debug.h:26
VOID IPRemoveInterfaceRoute(PIP_INTERFACE IF)
Definition: ip.c:335
KSPIN_LOCK InterfaceListLock
Definition: ip.c:18

Referenced by BindAdapter(), LoopUnregisterAdapter(), and UnbindAdapter().

Variable Documentation

◆ InterfaceListHead

LIST_ENTRY InterfaceListHead

Definition at line 17 of file ip.c.

Referenced by DriverEntry().

◆ InterfaceListLock

KSPIN_LOCK InterfaceListLock

◆ NetTableListHead

LIST_ENTRY NetTableListHead

Definition at line 19 of file ip.c.

Referenced by IPStartup().

◆ NetTableListLock

KSPIN_LOCK NetTableListLock

Definition at line 20 of file ip.c.

Referenced by IPStartup().