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