ReactOS 0.4.16-dev-297-gc569aee
neighbor.c File Reference
#include "precomp.h"
Include dependency graph for neighbor.c:

Go to the source code of this file.

Functions

VOID NBCompleteSend (PVOID Context, PNDIS_PACKET NdisPacket, NDIS_STATUS Status)
 
VOID NBSendPackets (PNEIGHBOR_CACHE_ENTRY NCE)
 
VOID NBFlushPacketQueue (PNEIGHBOR_CACHE_ENTRY NCE, NTSTATUS ErrorCode)
 
VOID NBTimeout (VOID)
 
VOID NBStartup (VOID)
 
VOID NBShutdown (VOID)
 
VOID NBSendSolicit (PNEIGHBOR_CACHE_ENTRY NCE)
 
VOID NBDestroyNeighborsForInterface (PIP_INTERFACE Interface)
 
PNEIGHBOR_CACHE_ENTRY NBAddNeighbor (PIP_INTERFACE Interface, PIP_ADDRESS Address, PVOID LinkAddress, UINT LinkAddressLength, UCHAR State, UINT EventTimer)
 
VOID NBUpdateNeighbor (PNEIGHBOR_CACHE_ENTRY NCE, PVOID LinkAddress, UCHAR State)
 
VOID NBResetNeighborTimeout (PIP_ADDRESS Address)
 
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor (PIP_ADDRESS Address, PIP_INTERFACE Interface)
 
PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor (PIP_INTERFACE Interface, PIP_ADDRESS Address, BOOLEAN NoTimeout)
 
BOOLEAN NBQueuePacket (PNEIGHBOR_CACHE_ENTRY NCE, PNDIS_PACKET NdisPacket, PNEIGHBOR_PACKET_COMPLETE PacketComplete, PVOID PacketContext)
 
VOID NBRemoveNeighbor (PNEIGHBOR_CACHE_ENTRY NCE)
 
ULONG NBCopyNeighbors (PIP_INTERFACE Interface, PIPARP_ENTRY ArpTable)
 

Variables

NEIGHBOR_CACHE_TABLE NeighborCache [NB_HASHMASK+1]
 

Function Documentation

◆ NBAddNeighbor()

PNEIGHBOR_CACHE_ENTRY NBAddNeighbor ( PIP_INTERFACE  Interface,
PIP_ADDRESS  Address,
PVOID  LinkAddress,
UINT  LinkAddressLength,
UCHAR  State,
UINT  EventTimer 
)

Definition at line 273 of file neighbor.c.

295{
299
302 ("Called. Interface (0x%X) Address (0x%X) "
303 "LinkAddress (0x%X) LinkAddressLength (%d) State (0x%X)\n",
304 Interface, Address, LinkAddress, LinkAddressLength, State));
305
307 (NonPagedPool, sizeof(NEIGHBOR_CACHE_ENTRY) + LinkAddressLength,
308 NCE_TAG);
309 if (NCE == NULL)
310 {
311 TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
312 return NULL;
313 }
314
315 NCE->Interface = Interface;
316 NCE->Address = *Address;
317 NCE->LinkAddressLength = LinkAddressLength;
318 NCE->LinkAddress = (PVOID)&NCE[1];
319 if( LinkAddress )
320 RtlCopyMemory(NCE->LinkAddress, LinkAddress, LinkAddressLength);
321 else
322 memset(NCE->LinkAddress, 0xff, LinkAddressLength);
323 NCE->State = State;
324 NCE->EventTimer = EventTimer;
325 NCE->EventCount = 0;
327
328 TI_DbgPrint(MID_TRACE,("NCE: %x\n", NCE));
329
330 HashValue = *(PULONG)&Address->Address;
331 HashValue ^= HashValue >> 16;
332 HashValue ^= HashValue >> 8;
333 HashValue ^= HashValue >> 4;
335
337
340
342
343 return NCE;
344}
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
#define NULL
Definition: types.h:112
#define DEBUG_NCACHE
Definition: debug.h:32
#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
#define NCE_TAG
Definition: tags.h:25
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NEIGHBOR_CACHE_TABLE NeighborCache[NB_HASHMASK+1]
Definition: neighbor.c:13
#define NB_HASHMASK
Definition: neighbor.h:10
static WCHAR Address[46]
Definition: ping.c:68
#define memset(x, y, z)
Definition: compat.h:39
Definition: neighbor.h:28
PIP_INTERFACE Interface
Definition: neighbor.h:33
IP_ADDRESS Address
Definition: neighbor.h:36
PVOID LinkAddress
Definition: neighbor.h:35
struct NEIGHBOR_CACHE_ENTRY * Next
Definition: neighbor.h:29
UCHAR State
Definition: neighbor.h:30
UINT LinkAddressLength
Definition: neighbor.h:34
UINT EventTimer
Definition: neighbor.h:31
LIST_ENTRY PacketQueue
Definition: neighbor.h:37
UINT EventCount
Definition: neighbor.h:32
struct NEIGHBOR_CACHE_ENTRY * Cache
Definition: neighbor.h:23
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
_In_ BOOLEAN _In_ ULONG _Out_ PULONG HashValue
Definition: rtlfuncs.h:2056

Referenced by ARPReceive(), InfoTdiSetArptableMIB(), IPAddInterfaceRoute(), and NBFindOrCreateNeighbor().

◆ NBCompleteSend()

VOID NBCompleteSend ( PVOID  Context,
PNDIS_PACKET  NdisPacket,
NDIS_STATUS  Status 
)

Definition at line 15 of file neighbor.c.

17 {
19 TI_DbgPrint(MID_TRACE, ("Called\n"));
21 ASSERT_KM_POINTER(Packet->Complete);
22 Packet->Complete( Packet->Context, Packet->Packet, Status );
23 TI_DbgPrint(MID_TRACE, ("Completed\n"));
25 TI_DbgPrint(MID_TRACE, ("Freed\n"));
26}
#define ASSERT_KM_POINTER(_x)
Definition: debug.h:74
#define NEIGHBOR_PACKET_TAG
Definition: tags.h:24
Status
Definition: gdiplustypes.h:25
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
struct _NEIGHBOR_PACKET * PNEIGHBOR_PACKET

Referenced by NBSendPackets().

◆ NBCopyNeighbors()

ULONG NBCopyNeighbors ( PIP_INTERFACE  Interface,
PIPARP_ENTRY  ArpTable 
)

Definition at line 635 of file neighbor.c.

638{
641 UINT Size = 0, i;
642
643 for (i = 0; i <= NB_HASHMASK; i++) {
645 for( CurNCE = NeighborCache[i].Cache;
646 CurNCE;
647 CurNCE = CurNCE->Next ) {
648 if( CurNCE->Interface == Interface &&
649 !AddrIsEqual( &CurNCE->Address, &CurNCE->Interface->Unicast ) ) {
650 if( ArpTable ) {
651 ArpTable[Size].Index = Interface->Index;
652 ArpTable[Size].AddrSize = CurNCE->LinkAddressLength;
654 (ArpTable[Size].PhysAddr,
655 CurNCE->LinkAddress,
656 CurNCE->LinkAddressLength);
657 ArpTable[Size].LogAddr = CurNCE->Address.Address.IPv4Address;
658 if( CurNCE->State & NUD_PERMANENT )
659 ArpTable[Size].Type = ARP_ENTRY_STATIC;
660 else if( CurNCE->State & NUD_INCOMPLETE )
661 ArpTable[Size].Type = ARP_ENTRY_INVALID;
662 else
663 ArpTable[Size].Type = ARP_ENTRY_DYNAMIC;
664 }
665 Size++;
666 }
667 }
669 }
670
671 return Size;
672}
BOOLEAN AddrIsEqual(PIP_ADDRESS Address1, PIP_ADDRESS Address2)
Definition: address.c:221
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
#define ARP_ENTRY_STATIC
Definition: info.h:30
#define ARP_ENTRY_INVALID
Definition: info.h:32
#define ARP_ENTRY_DYNAMIC
Definition: info.h:31
unsigned int UINT
Definition: ndis.h:50
#define NUD_INCOMPLETE
Definition: neighbor.h:41
#define NUD_PERMANENT
Definition: neighbor.h:42
Definition: fatfs.h:173
ULONG Index
Definition: info.h:36
ULONG Type
Definition: info.h:40
ULONG LogAddr
Definition: info.h:39
ULONG AddrSize
Definition: info.h:37
union IP_ADDRESS::@1014 Address
IPv4_RAW_ADDRESS IPv4Address
Definition: ip.h:26
IP_ADDRESS Unicast
Definition: ip.h:159
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by InfoTdiQueryGetArptableMIB().

◆ NBDestroyNeighborsForInterface()

VOID NBDestroyNeighborsForInterface ( PIP_INTERFACE  Interface)

Definition at line 237 of file neighbor.c.

238{
240 PNEIGHBOR_CACHE_ENTRY *PrevNCE;
242 ULONG i;
243
245 for (i = 0; i <= NB_HASHMASK; i++)
246 {
248
249 for (PrevNCE = &NeighborCache[i].Cache;
250 (NCE = *PrevNCE) != NULL;)
251 {
252 if (NCE->Interface == Interface)
253 {
254 /* Unlink and destroy the NCE */
255 *PrevNCE = NCE->Next;
256
259
260 continue;
261 }
262 else
263 {
264 PrevNCE = &NCE->Next;
265 }
266 }
267
269 }
271}
VOID TcpipAcquireSpinLockAtDpcLevel(PKSPIN_LOCK SpinLock)
Definition: lock.c:22
VOID TcpipReleaseSpinLockFromDpcLevel(PKSPIN_LOCK SpinLock)
Definition: lock.c:30
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NDIS_STATUS_REQUEST_ABORTED
Definition: ndis.h:476
VOID NBFlushPacketQueue(PNEIGHBOR_CACHE_ENTRY NCE, NTSTATUS ErrorCode)
Definition: neighbor.c:65

Referenced by ReconfigureAdapter().

◆ NBFindOrCreateNeighbor()

PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor ( PIP_INTERFACE  Interface,
PIP_ADDRESS  Address,
BOOLEAN  NoTimeout 
)

Definition at line 501 of file neighbor.c.

516{
518
519 TI_DbgPrint(DEBUG_NCACHE, ("Called. Interface (0x%X) Address (0x%X).\n", Interface, Address));
520
522 if (NCE == NULL)
523 {
524 TI_DbgPrint(MID_TRACE,("BCAST: %s\n", A2S(&Interface->Broadcast)));
525 if( AddrIsEqual(Address, &Interface->Broadcast) ||
527 TI_DbgPrint(MID_TRACE,("Packet targeted at broadcast addr\n"));
529 Interface->AddressLength, NUD_PERMANENT, 0);
530 } else {
532 Interface->AddressLength, NUD_INCOMPLETE, NoTimeout ? 0 : ARP_INCOMPLETE_TIMEOUT);
533 if (!NCE) return NULL;
534 NBSendSolicit(NCE);
535 }
536 }
537
538 return NCE;
539}
BOOLEAN AddrIsUnspecified(PIP_ADDRESS Address)
Definition: address.c:113
PCHAR A2S(PIP_ADDRESS Address)
Definition: address.c:17
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(PIP_ADDRESS Address, PIP_INTERFACE Interface)
Definition: neighbor.c:417
PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(PIP_INTERFACE Interface, PIP_ADDRESS Address, PVOID LinkAddress, UINT LinkAddressLength, UCHAR State, UINT EventTimer)
Definition: neighbor.c:273
VOID NBSendSolicit(PNEIGHBOR_CACHE_ENTRY NCE)
Definition: neighbor.c:221
#define ARP_INCOMPLETE_TIMEOUT
Definition: neighbor.h:46

Referenced by RouteGetRouteToDestination(), and RouterCreateRoute().

◆ NBFlushPacketQueue()

VOID NBFlushPacketQueue ( PNEIGHBOR_CACHE_ENTRY  NCE,
NTSTATUS  ErrorCode 
)

Definition at line 65 of file neighbor.c.

66 {
67 PLIST_ENTRY PacketEntry;
69
70 while( !IsListEmpty(&NCE->PacketQueue) ) {
71 PacketEntry = RemoveHeadList(&NCE->PacketQueue);
73 ( PacketEntry, NEIGHBOR_PACKET, Next );
74
76
78 (MID_TRACE,
79 ("PacketEntry: %x, NdisPacket %x\n",
80 PacketEntry, Packet->Packet));
81
82 ASSERT_KM_POINTER(Packet->Complete);
83 Packet->Complete( Packet->Context,
84 Packet->Packet,
85 ErrorCode );
86
88 }
89}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by NBDestroyNeighborsForInterface(), NBRemoveNeighbor(), NBShutdown(), and NBTimeout().

◆ NBLocateNeighbor()

PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor ( PIP_ADDRESS  Address,
PIP_INTERFACE  Interface 
)

Definition at line 417 of file neighbor.c.

431{
435 PIP_INTERFACE FirstInterface;
436
437 TI_DbgPrint(DEBUG_NCACHE, ("Called. Address (0x%X).\n", Address));
438
439 HashValue = *(PULONG)&Address->Address;
440 HashValue ^= HashValue >> 16;
441 HashValue ^= HashValue >> 8;
442 HashValue ^= HashValue >> 4;
444
446
447 /* If there's no adapter specified, we'll look for a match on
448 * each one. */
449 if (Interface == NULL)
450 {
451 FirstInterface = GetDefaultInterface();
452 Interface = FirstInterface;
453 }
454 else
455 {
456 FirstInterface = NULL;
457 }
458
459 do
460 {
462 while (NCE != NULL)
463 {
464 if (NCE->Interface == Interface &&
466 {
467 break;
468 }
469
470 NCE = NCE->Next;
471 }
472
473 if (NCE != NULL)
474 break;
475 }
476 while ((FirstInterface != NULL) &&
477 ((Interface = GetDefaultInterface()) != FirstInterface));
478
479 if ((NCE == NULL) && (FirstInterface != NULL))
480 {
481 /* This time we'll even match loopback NCEs */
483 while (NCE != NULL)
484 {
485 if (AddrIsEqual(Address, &NCE->Address))
486 {
487 break;
488 }
489
490 NCE = NCE->Next;
491 }
492 }
493
495
496 TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
497
498 return NCE;
499}
#define MAX_TRACE
Definition: debug.h:16
PIP_INTERFACE GetDefaultInterface(VOID)
Definition: interface.c:156

Referenced by ARPReceive(), DispTdiQueryIpHwAddress(), InfoTdiSetArptableMIB(), IPRemoveInterfaceRoute(), NBFindOrCreateNeighbor(), RawIPSendDatagram(), UDPSendDatagram(), and WaitForHwAddress().

◆ NBQueuePacket()

BOOLEAN NBQueuePacket ( PNEIGHBOR_CACHE_ENTRY  NCE,
PNDIS_PACKET  NdisPacket,
PNEIGHBOR_PACKET_COMPLETE  PacketComplete,
PVOID  PacketContext 
)

Definition at line 541 of file neighbor.c.

554{
558
561 ("Called. NCE (0x%X) NdisPacket (0x%X).\n", NCE, NdisPacket));
562
565 if( !Packet ) return FALSE;
566
567 /* FIXME: Should we limit the number of queued packets? */
568
569 HashValue = *(PULONG)(&NCE->Address.Address);
570 HashValue ^= HashValue >> 16;
571 HashValue ^= HashValue >> 8;
572 HashValue ^= HashValue >> 4;
574
576
577 Packet->Complete = PacketComplete;
578 Packet->Context = PacketContext;
579 Packet->Packet = NdisPacket;
580 InsertTailList( &NCE->PacketQueue, &Packet->Next );
581
583
584 if( !(NCE->State & NUD_INCOMPLETE) )
585 NBSendPackets( NCE );
586
587 return TRUE;
588}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define InsertTailList(ListHead, Entry)
VOID NBSendPackets(PNEIGHBOR_CACHE_ENTRY NCE)
Definition: neighbor.c:28

Referenced by IPSendFragment().

◆ NBRemoveNeighbor()

VOID NBRemoveNeighbor ( PNEIGHBOR_CACHE_ENTRY  NCE)

Definition at line 590 of file neighbor.c.

599{
600 PNEIGHBOR_CACHE_ENTRY *PrevNCE;
604
605 TI_DbgPrint(DEBUG_NCACHE, ("Called. NCE (0x%X).\n", NCE));
606
607 HashValue = *(PULONG)(&NCE->Address.Address);
608 HashValue ^= HashValue >> 16;
609 HashValue ^= HashValue >> 8;
610 HashValue ^= HashValue >> 4;
612
614
615 /* Search the list and remove the NCE from the list if found */
616 for (PrevNCE = &NeighborCache[HashValue].Cache;
617 (CurNCE = *PrevNCE) != NULL;
618 PrevNCE = &CurNCE->Next)
619 {
620 if (CurNCE == NCE)
621 {
622 /* Found it, now unlink it from the list */
623 *PrevNCE = CurNCE->Next;
624
626 ExFreePoolWithTag(CurNCE, NCE_TAG);
627
628 break;
629 }
630 }
631
633}

Referenced by InfoTdiSetArptableMIB(), and IPRemoveInterfaceRoute().

◆ NBResetNeighborTimeout()

VOID NBResetNeighborTimeout ( PIP_ADDRESS  Address)

Definition at line 387 of file neighbor.c.

388{
392
393 TI_DbgPrint(DEBUG_NCACHE, ("Resetting NCE timout for 0x%s\n", A2S(Address)));
394
395 HashValue = *(PULONG)(&Address->Address);
396 HashValue ^= HashValue >> 16;
397 HashValue ^= HashValue >> 8;
398 HashValue ^= HashValue >> 4;
400
402
403 for (NCE = NeighborCache[HashValue].Cache;
404 NCE != NULL;
405 NCE = NCE->Next)
406 {
407 if (AddrIsEqual(Address, &NCE->Address))
408 {
409 NCE->EventCount = 0;
410 break;
411 }
412 }
413
415}

Referenced by IPDispatchProtocol().

◆ NBSendPackets()

VOID NBSendPackets ( PNEIGHBOR_CACHE_ENTRY  NCE)

Definition at line 28 of file neighbor.c.

28 {
29 PLIST_ENTRY PacketEntry;
32
33 ASSERT(!(NCE->State & NUD_INCOMPLETE));
34
35 HashValue = *(PULONG)(&NCE->Address.Address);
36 HashValue ^= HashValue >> 16;
37 HashValue ^= HashValue >> 8;
38 HashValue ^= HashValue >> 4;
40
41 /* Send any waiting packets */
42 while ((PacketEntry = ExInterlockedRemoveHeadList(&NCE->PacketQueue,
44 {
45 Packet = CONTAINING_RECORD( PacketEntry, NEIGHBOR_PACKET, Next );
46
48 (MID_TRACE,
49 ("PacketEntry: %x, NdisPacket %x\n",
50 PacketEntry, Packet->Packet));
51
52 PC(Packet->Packet)->DLComplete = NBCompleteSend;
53 PC(Packet->Packet)->Context = Packet;
54
56 ( NCE->Interface->Context,
57 Packet->Packet,
58 0,
59 NCE->LinkAddress,
61 }
62}
#define PC(Packet)
Definition: ip.h:106
PLIST_ENTRY NTAPI ExInterlockedRemoveHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:166
#define LAN_PROTO_IPv4
Definition: lan.h:126
#define ASSERT(a)
Definition: mode.c:44
VOID NBCompleteSend(PVOID Context, PNDIS_PACKET NdisPacket, NDIS_STATUS Status)
Definition: neighbor.c:15
KSPIN_LOCK Lock
Definition: neighbor.h:24
LL_TRANSMIT_ROUTINE Transmit
Definition: ip.h:168
PVOID Context
Definition: ip.h:154

Referenced by NBQueuePacket(), and NBUpdateNeighbor().

◆ NBSendSolicit()

VOID NBSendSolicit ( PNEIGHBOR_CACHE_ENTRY  NCE)

Definition at line 221 of file neighbor.c.

229{
230 TI_DbgPrint(DEBUG_NCACHE, ("Called. NCE (0x%X).\n", NCE));
231
232 ARPTransmit(&NCE->Address,
233 (NCE->State & NUD_INCOMPLETE) ? NULL : NCE->LinkAddress,
234 NCE->Interface);
235}
BOOLEAN ARPTransmit(PIP_ADDRESS Address, PVOID LinkAddress, PIP_INTERFACE Interface)
Definition: arp.c:111

Referenced by NBFindOrCreateNeighbor(), and NBTimeout().

◆ NBShutdown()

VOID NBShutdown ( VOID  )

Definition at line 184 of file neighbor.c.

188{
189 PNEIGHBOR_CACHE_ENTRY NextNCE;
192 UINT i;
193
194 TI_DbgPrint(DEBUG_NCACHE, ("Called.\n"));
195
196 /* Remove possible entries from the cache */
197 for (i = 0; i <= NB_HASHMASK; i++)
198 {
200
201 CurNCE = NeighborCache[i].Cache;
202 while (CurNCE) {
203 NextNCE = CurNCE->Next;
204
205 /* Flush wait queue */
207
208 ExFreePoolWithTag(CurNCE, NCE_TAG);
209
210 CurNCE = NextNCE;
211 }
212
214
216 }
217
218 TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
219}
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350

Referenced by IPShutdown().

◆ NBStartup()

VOID NBStartup ( VOID  )

Definition at line 169 of file neighbor.c.

173{
174 UINT i;
175
176 TI_DbgPrint(DEBUG_NCACHE, ("Called.\n"));
177
178 for (i = 0; i <= NB_HASHMASK; i++) {
181 }
182}
VOID TcpipInitializeSpinLock(PKSPIN_LOCK SpinLock)
Definition: lock.c:14

Referenced by IPStartup().

◆ NBTimeout()

VOID NBTimeout ( VOID  )

Definition at line 91 of file neighbor.c.

98{
99 UINT i;
100 PNEIGHBOR_CACHE_ENTRY *PrevNCE;
103
104 for (i = 0; i <= NB_HASHMASK; i++) {
106
107 for (PrevNCE = &NeighborCache[i].Cache;
108 (NCE = *PrevNCE) != NULL;) {
109 if (NCE->State & NUD_INCOMPLETE)
110 {
111 /* Solicit for an address */
112 NBSendSolicit(NCE);
113 if (NCE->EventTimer == 0)
114 {
115 NCE->EventCount++;
117 {
119 NCE->EventCount = 0;
120 }
121 }
122 }
123
124 /* Check if event timer is running */
125 if (NCE->EventTimer > 0) {
126 ASSERT(!(NCE->State & NUD_PERMANENT));
127 NCE->EventCount++;
128
129 if ((NCE->EventCount > ARP_RATE &&
131 (NCE->EventCount == ARP_RATE))
132 {
133 /* We haven't gotten a packet from them in
134 * EventCount seconds so we mark them as stale
135 * and solicit now */
136 NCE->State |= NUD_STALE;
137 NBSendSolicit(NCE);
138 }
139 if (NCE->EventTimer - NCE->EventCount == 0) {
140 /* Unlink and destroy the NCE */
141 *PrevNCE = NCE->Next;
142
143 /* Choose the proper failure status */
144 if (NCE->State & NUD_INCOMPLETE)
145 {
146 /* We couldn't get an address to this IP at all */
148 }
149 else
150 {
151 /* This guy was stale for way too long */
153 }
154
156
158
159 continue;
160 }
161 }
162 PrevNCE = &NCE->Next;
163 }
164
166 }
167}
#define NDIS_STATUS_NETWORK_UNREACHABLE
Definition: ndis.h:511
#define NDIS_STATUS_HOST_UNREACHABLE
Definition: ndis.h:512
#define ARP_RATE
Definition: neighbor.h:49
#define ARP_TIMEOUT_RETRANSMISSION
Definition: neighbor.h:55
#define NUD_STALE
Definition: neighbor.h:43
int NDIS_STATUS
Definition: ntddndis.h:475

Referenced by IPTimeoutDpcFn().

◆ NBUpdateNeighbor()

VOID NBUpdateNeighbor ( PNEIGHBOR_CACHE_ENTRY  NCE,
PVOID  LinkAddress,
UCHAR  State 
)

Definition at line 346 of file neighbor.c.

359{
362
363 TI_DbgPrint(DEBUG_NCACHE, ("Called. NCE (0x%X) LinkAddress (0x%X) State (0x%X).\n", NCE, LinkAddress, State));
364
365 HashValue = *(PULONG)(&NCE->Address.Address);
366 HashValue ^= HashValue >> 16;
367 HashValue ^= HashValue >> 8;
368 HashValue ^= HashValue >> 4;
370
372
373 RtlCopyMemory(NCE->LinkAddress, LinkAddress, NCE->LinkAddressLength);
374 NCE->State = State;
375 NCE->EventCount = 0;
376
378
379 if( !(NCE->State & NUD_INCOMPLETE) )
380 {
382 NBSendPackets( NCE );
383 }
384}
#define ARP_COMPLETE_TIMEOUT
Definition: neighbor.h:52

Referenced by ARPReceive(), and DispTdiQueryIpHwAddress().

Variable Documentation

◆ NeighborCache