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