ip-neighbor: Replace feature for the ip-neighbor data-base
[vpp.git] / src / vnet / ip-neighbor / ip_neighbor_types.h
1 /*
2  * ip_neighbor.h: ip neighbor generic services
3  *
4  * Copyright (c) 2018 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef __INCLUDE_IP_NEIGHBOR_TYPES_H__
19 #define __INCLUDE_IP_NEIGHBOR_TYPES_H__
20
21 #include <vnet/ip/ip6_packet.h>
22 #include <vnet/ethernet/mac_address.h>
23 #include <vnet/fib/fib_types.h>
24
25 #define IP_SCAN_DISABLED        0
26 #define IP_SCAN_V4_NEIGHBORS    (1 << 0)
27 #define IP_SCAN_V6_NEIGHBORS    (1 << 1)
28 #define IP_SCAN_V46_NEIGHBORS   (IP_SCAN_V4_NEIGHBORS | IP_SCAN_V6_NEIGHBORS)
29
30 typedef struct
31 {
32   u8 mode;                      /* 0: disable, 1: ip4, 2: ip6, 3: both */
33   u8 scan_interval;             /* neighbor scan interval in minutes */
34   u8 max_proc_time;             /* max processing time per run, in usecs */
35   u8 max_update;                /* max probe/delete operations per run */
36   u8 scan_int_delay;            /* delay in msecs, to resume scan on max */
37   u8 stale_threshold;           /* Threshold in minutes to delete nei entry */
38 } ip_neighbor_scan_arg_t;
39
40 #define foreach_ip_neighbor_flag                 \
41   _(STATIC, 1 << 0, "static", "S")               \
42   _(DYNAMIC, 1 << 1, "dynamic", "D")             \
43   _(NO_FIB_ENTRY, 1 << 2, "no-fib-entry", "N")   \
44   _(PENDING, 1 << 3, "pending", "P")             \
45   _(STALE, 1 << 4, "stale", "A")                 \
46
47 typedef enum ip_neighbor_flags_t_
48 {
49   IP_NEIGHBOR_FLAG_NONE = 0,
50 #define _(a,b,c,d) IP_NEIGHBOR_FLAG_##a = b,
51   foreach_ip_neighbor_flag
52 #undef _
53 } __attribute__ ((packed)) ip_neighbor_flags_t;
54
55 typedef struct ip_neighbor_watcher_t_
56 {
57   u32 ipw_pid;
58   u32 ipw_client;
59 } ip_neighbor_watcher_t;
60
61 extern u8 *format_ip_neighbor_watcher (u8 * s, va_list * args);
62
63 typedef struct ip_neighbor_key_t_
64 {
65   ip46_address_t ipnk_ip;
66   ip46_type_t ipnk_type;
67   u32 ipnk_sw_if_index;
68 } ip_neighbor_key_t;
69
70 /**
71  * A representation of an IP neighbour/peer
72  */
73 typedef struct ip_neighbor_t_
74 {
75   /**
76    * The idempotent key
77    */
78   ip_neighbor_key_t *ipn_key;
79
80   /**
81    * The learned MAC address of the neighbour
82    */
83   mac_address_t ipn_mac;
84
85   /**
86    * Falgs for this object
87    */
88   ip_neighbor_flags_t ipn_flags;
89
90   /**
91    * Aging related data
92    *  - last time the neighbour was probed
93    *  - number of probes - 3 and it's dead
94    */
95   f64 ipn_time_last_updated;
96   u8 ipn_n_probes;
97   index_t ipn_elt;
98
99   /**
100    * The index of the adj fib created for this neighbour
101    */
102   fib_node_index_t ipn_fib_entry_index;
103 } ip_neighbor_t;
104
105 extern u8 *format_ip_neighbor_flags (u8 * s, va_list * args);
106 extern u8 *format_ip_neighbor_key (u8 * s, va_list * args);
107 extern u8 *format_ip_neighbor (u8 * s, va_list * args);
108
109 extern ip_neighbor_t *ip_neighbor_get (index_t ipni);
110
111 typedef struct ip_neighbor_learn_t_
112 {
113   ip46_address_t ip;
114   ip46_type_t type;
115   mac_address_t mac;
116   u32 sw_if_index;
117 } ip_neighbor_learn_t;
118
119 typedef struct ip_neighbor_event_t_
120 {
121   ip_neighbor_watcher_t ipne_watch;
122   index_t ipne_index;
123 } ip_neighbor_event_t;
124
125 #endif /* __INCLUDE_IP_NEIGHBOR_H__ */
126
127 /*
128  * fd.io coding-style-patch-verification: ON
129  *
130  * Local Variables:
131  * eval: (c-set-style "gnu")
132  * End:
133  */