- Fix timeout values
[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 between ARP transmissions */
48 #define ARP_RATE 900
49
50 /* Number of seconds before the NCE times out */
51 #define ARP_TIMEOUT ARP_RATE + 15
52
53 /* Number of seconds before retransmission */
54 #define ARP_TIMEOUT_RETRANSMISSION 5
55
56 extern NEIGHBOR_CACHE_TABLE NeighborCache[NB_HASHMASK + 1];
57
58
59 VOID NBTimeout(
60 VOID);
61
62 VOID NBStartup(
63 VOID);
64
65 VOID NBShutdown(
66 VOID);
67
68 VOID NBSendSolicit(
69 PNEIGHBOR_CACHE_ENTRY NCE);
70
71 PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(
72 PIP_INTERFACE Interface,
73 PIP_ADDRESS Address,
74 PVOID LinkAddress,
75 UINT LinkAddressLength,
76 UCHAR Type,
77 UINT EventTimer);
78
79 VOID NBUpdateNeighbor(
80 PNEIGHBOR_CACHE_ENTRY NCE,
81 PVOID LinkAddress,
82 UCHAR State);
83
84 PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
85 PIP_ADDRESS Address);
86
87 PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
88 PIP_INTERFACE Interface,
89 PIP_ADDRESS Address);
90
91 BOOLEAN NBQueuePacket(
92 PNEIGHBOR_CACHE_ENTRY NCE,
93 PNDIS_PACKET NdisPacket,
94 PNEIGHBOR_PACKET_COMPLETE PacketComplete,
95 PVOID PacketContext);
96
97 VOID NBRemoveNeighbor(
98 PNEIGHBOR_CACHE_ENTRY NCE);
99
100 ULONG NBCopyNeighbors(
101 PIP_INTERFACE Interface,
102 PIPARP_ENTRY ArpTable);
103
104 VOID NBResetNeighborTimeout(
105 PIP_ADDRESS Address);
106
107 #endif /* __NEIGHBOR_H */
108
109 /* EOF */