* Sync to recent trunk (r52563).
[reactos.git] / drivers / network / tcpip / include / neighbor.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: include/neighbor.h
5 * PURPOSE: Neighbor definitions
6 */
7
8 #pragma once
9
10 #define NB_HASHMASK 0xF /* Hash mask for neighbor cache */
11
12 typedef VOID (*PNEIGHBOR_PACKET_COMPLETE)
13 ( PVOID Context, PNDIS_PACKET Packet, NDIS_STATUS Status );
14
15 typedef struct _NEIGHBOR_PACKET {
16 LIST_ENTRY Next;
17 PNDIS_PACKET Packet;
18 PNEIGHBOR_PACKET_COMPLETE Complete;
19 PVOID Context;
20 } NEIGHBOR_PACKET, *PNEIGHBOR_PACKET;
21
22 typedef struct NEIGHBOR_CACHE_TABLE {
23 struct NEIGHBOR_CACHE_ENTRY *Cache; /* Pointer to cache */
24 KSPIN_LOCK Lock; /* Protecting lock */
25 } NEIGHBOR_CACHE_TABLE, *PNEIGHBOR_CACHE_TABLE;
26
27 /* Information about a neighbor */
28 typedef struct NEIGHBOR_CACHE_ENTRY {
29 struct NEIGHBOR_CACHE_ENTRY *Next; /* Pointer to next entry */
30 UCHAR State; /* State of NCE */
31 UINT EventTimer; /* Ticks since last event */
32 UINT EventCount; /* Number of events */
33 PIP_INTERFACE Interface; /* Pointer to interface */
34 UINT LinkAddressLength; /* Length of link address */
35 PVOID LinkAddress; /* Pointer to link address */
36 IP_ADDRESS Address; /* IP address of neighbor */
37 LIST_ENTRY PacketQueue; /* Packet queue */
38 } NEIGHBOR_CACHE_ENTRY, *PNEIGHBOR_CACHE_ENTRY;
39
40 /* NCE states */
41 #define NUD_INCOMPLETE 0x01
42 #define NUD_PERMANENT 0x02
43 #define NUD_STALE 0x04
44
45 /* Number of seconds between ARP transmissions */
46 #define ARP_RATE 900
47
48 /* Number of seconds before the NCE times out */
49 #define ARP_TIMEOUT ARP_RATE + 15
50
51 /* Number of seconds before retransmission */
52 #define ARP_TIMEOUT_RETRANSMISSION 5
53
54 extern NEIGHBOR_CACHE_TABLE NeighborCache[NB_HASHMASK + 1];
55
56
57 VOID NBTimeout(
58 VOID);
59
60 VOID NBStartup(
61 VOID);
62
63 VOID NBShutdown(
64 VOID);
65
66 VOID NBSendSolicit(
67 PNEIGHBOR_CACHE_ENTRY NCE);
68
69 PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(
70 PIP_INTERFACE Interface,
71 PIP_ADDRESS Address,
72 PVOID LinkAddress,
73 UINT LinkAddressLength,
74 UCHAR Type,
75 UINT EventTimer);
76
77 VOID NBUpdateNeighbor(
78 PNEIGHBOR_CACHE_ENTRY NCE,
79 PVOID LinkAddress,
80 UCHAR State);
81
82 PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
83 PIP_ADDRESS Address);
84
85 PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
86 PIP_INTERFACE Interface,
87 PIP_ADDRESS Address);
88
89 BOOLEAN NBQueuePacket(
90 PNEIGHBOR_CACHE_ENTRY NCE,
91 PNDIS_PACKET NdisPacket,
92 PNEIGHBOR_PACKET_COMPLETE PacketComplete,
93 PVOID PacketContext);
94
95 VOID NBRemoveNeighbor(
96 PNEIGHBOR_CACHE_ENTRY NCE);
97
98 ULONG NBCopyNeighbors(
99 PIP_INTERFACE Interface,
100 PIPARP_ENTRY ArpTable);
101
102 VOID NBResetNeighborTimeout(
103 PIP_ADDRESS Address);
104
105 /* EOF */