- Forgot to commit these for MSVC build...
[reactos.git] / reactos / drivers / net / 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 struct NEIGHBOR_CACHE_TABLE *Table; /* Pointer to table */
33 UCHAR State; /* State of NCE */
34 UINT EventTimer; /* Ticks since last event */
35 UINT EventCount; /* Number of events */
36 PIP_INTERFACE Interface; /* Pointer to interface */
37 UINT LinkAddressLength; /* Length of link address */
38 PVOID LinkAddress; /* Pointer to link address */
39 IP_ADDRESS Address; /* IP address of neighbor */
40 LIST_ENTRY PacketQueue; /* Packet queue */
41 } NEIGHBOR_CACHE_ENTRY, *PNEIGHBOR_CACHE_ENTRY;
42
43 /* NCE states */
44 #define NUD_NONE 0x00
45 #define NUD_INCOMPLETE 0x01
46 #define NUD_REACHABLE 0x02
47 #define NUD_STALE 0x04
48 #define NUD_DELAY 0x08
49 #define NUD_PROBE 0x10
50 #define NUD_FAILED 0x20
51 #define NUD_NOARP 0x40
52 #define NUD_PERMANENT 0x80
53
54 #define NUD_IN_TIMER (NUD_INCOMPLETE | NUD_DELAY | NUD_PROBE)
55 #define NUD_VALID (NUD_REACHABLE | NUD_NOARP | NUD_STALE | NUD_DELAY | \
56 NUD_PROBE | NUD_PERMANENT)
57 #define NUD_CONNECTED (NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE)
58
59
60 /* Maximum number of retransmissions of multicast solicits */
61 #define MAX_MULTICAST_SOLICIT 3 /* 3 transmissions */
62
63 /* Number of ticks between address resolution messages */
64 #define RETRANS_TIMER IP_TICKS_SECOND /* One second */
65
66
67 extern NEIGHBOR_CACHE_TABLE NeighborCache[NB_HASHMASK + 1];
68
69
70 VOID NBTimeout(
71 VOID);
72
73 VOID NBStartup(
74 VOID);
75
76 VOID NBShutdown(
77 VOID);
78
79 VOID NBSendSolicit(
80 PNEIGHBOR_CACHE_ENTRY NCE);
81
82 PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(
83 PIP_INTERFACE Interface,
84 PIP_ADDRESS Address,
85 PVOID LinkAddress,
86 UINT LinkAddressLength,
87 UCHAR Type);
88
89 VOID NBUpdateNeighbor(
90 PNEIGHBOR_CACHE_ENTRY NCE,
91 PVOID LinkAddress,
92 UCHAR State);
93
94 PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
95 PIP_ADDRESS Address);
96
97 PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
98 PIP_INTERFACE Interface,
99 PIP_ADDRESS Address);
100
101 BOOLEAN NBQueuePacket(
102 PNEIGHBOR_CACHE_ENTRY NCE,
103 PNDIS_PACKET NdisPacket,
104 PNEIGHBOR_PACKET_COMPLETE PacketComplete,
105 PVOID PacketContext);
106
107 VOID NBRemoveNeighbor(
108 PNEIGHBOR_CACHE_ENTRY NCE);
109
110 #endif /* __NEIGHBOR_H */
111
112 /* EOF */