:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / 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 struct NEIGHBOR_CACHE_TABLE {
14     struct NEIGHBOR_CACHE_ENTRY *Cache; /* Pointer to cache */
15     KSPIN_LOCK Lock;                    /* Protecting lock */
16 } NEIGHBOR_CACHE_TABLE, *PNEIGHBOR_CACHE_TABLE;
17
18 /* Information about a neighbor */
19 typedef struct NEIGHBOR_CACHE_ENTRY {
20     DEFINE_TAG
21     struct NEIGHBOR_CACHE_ENTRY *Next;  /* Pointer to next entry */
22     struct NEIGHBOR_CACHE_TABLE *Table; /* Pointer to table */
23     ULONG RefCount;                     /* Number of references */
24     OBJECT_FREE_ROUTINE Free;           /* Routine to free resources for the object */
25     UCHAR State;                        /* State of NCE */
26     UINT EventTimer;                    /* Ticks since last event */
27     UINT EventCount;                    /* Number of events */
28     PIP_INTERFACE Interface;            /* Pointer to interface */
29     PIP_ADDRESS Address;                /* IP address of neighbor */
30     UINT LinkAddressLength;             /* Length of link address */
31     PVOID LinkAddress;                  /* Pointer to link address */
32     PNDIS_PACKET WaitQueue;             /* Pointer to NDIS packets
33                                            waiting to be sent */
34 } NEIGHBOR_CACHE_ENTRY, *PNEIGHBOR_CACHE_ENTRY;
35
36 /* NCE states */
37 #define NUD_NONE       0x00
38 #define NUD_INCOMPLETE 0x01
39 #define NUD_REACHABLE  0x02
40 #define NUD_STALE      0x04
41 #define NUD_DELAY      0x08
42 #define NUD_PROBE      0x10
43 #define NUD_FAILED     0x20
44 #define NUD_NOARP      0x40
45 #define NUD_PERMANENT  0x80
46
47 #define NUD_IN_TIMER  (NUD_INCOMPLETE | NUD_DELAY | NUD_PROBE)
48 #define NUD_VALID     (NUD_REACHABLE | NUD_NOARP | NUD_STALE | NUD_DELAY | \
49                        NUD_PROBE | NUD_PERMANENT)
50 #define NUD_CONNECTED (NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE)
51
52
53 /* Maximum number of retransmissions of multicast solicits */
54 #define MAX_MULTICAST_SOLICIT 3 /* 3 transmissions */
55
56 /* Number of ticks between address resolution messages */
57 #define RETRANS_TIMER IP_TICKS_SECOND /* One second */
58
59
60 extern NEIGHBOR_CACHE_TABLE NeighborCache[NB_HASHMASK + 1];
61
62
63 VOID NBTimeout(
64     VOID);
65
66 VOID NBStartup(
67     VOID);
68
69 VOID NBShutdown(
70     VOID);
71
72 VOID NBSendSolicit(
73     PNEIGHBOR_CACHE_ENTRY NCE);
74
75 PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(
76     PIP_INTERFACE Interface,
77     PIP_ADDRESS Address,
78     PVOID LinkAddress,
79     UINT LinkAddressLength,
80     UCHAR Type);
81
82 VOID NBUpdateNeighbor(
83     PNEIGHBOR_CACHE_ENTRY NCE,
84     PVOID LinkAddress,
85     UCHAR State);
86
87 PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
88     PIP_ADDRESS Address);
89
90 PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
91     PIP_INTERFACE Interface,
92     PIP_ADDRESS Address);
93
94 BOOLEAN NBQueuePacket(
95     PNEIGHBOR_CACHE_ENTRY NCE,
96     PNDIS_PACKET NdisPacket);
97
98 VOID NBRemoveNeighbor(
99     PNEIGHBOR_CACHE_ENTRY NCE);
100
101 #endif /* __NEIGHBOR_H */
102
103 /* EOF */