2 * ip_neighbor.h: ip neighbor generic services
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __INCLUDE_IP_NEIGHBOR_TYPES_H__
19 #define __INCLUDE_IP_NEIGHBOR_TYPES_H__
21 #include <vnet/ip/ip_types.h>
22 #include <vnet/ethernet/mac_address.h>
23 #include <vnet/fib/fib_types.h>
25 #define foreach_ip_neighbor_flag \
26 _(STATIC, 1 << 0, "static", "S") \
27 _(DYNAMIC, 1 << 1, "dynamic", "D") \
28 _(NO_FIB_ENTRY, 1 << 2, "no-fib-entry", "N") \
29 _(PENDING, 1 << 3, "pending", "P") \
30 _(STALE, 1 << 4, "stale", "A") \
32 typedef enum ip_neighbor_flags_t_
34 IP_NEIGHBOR_FLAG_NONE = 0,
35 #define _(a,b,c,d) IP_NEIGHBOR_FLAG_##a = b,
36 foreach_ip_neighbor_flag
38 } __clib_packed ip_neighbor_flags_t;
40 typedef struct ip_neighbor_watcher_t_
45 } ip_neighbor_watcher_t;
47 extern u8 *format_ip_neighbor_watcher (u8 * s, va_list * args);
49 typedef struct ip_neighbor_key_t_
54 } __clib_packed ip_neighbor_key_t;
57 * A representation of an IP neighbour/peer
59 typedef struct ip_neighbor_t_
64 ip_neighbor_key_t *ipn_key;
67 * The learned MAC address of the neighbour
69 mac_address_t ipn_mac;
72 * Falgs for this object
74 ip_neighbor_flags_t ipn_flags;
78 * - last time the neighbour was probed
79 * - number of probes - 3 and it's dead
81 f64 ipn_time_last_updated;
86 * The index of the adj fib created for this neighbour
88 fib_node_index_t ipn_fib_entry_index;
91 extern u8 *format_ip_neighbor_flags (u8 * s, va_list * args);
92 extern u8 *format_ip_neighbor_key (u8 * s, va_list * args);
93 extern u8 *format_ip_neighbor (u8 * s, va_list * args);
95 extern ip_neighbor_t *ip_neighbor_get (index_t ipni);
97 typedef struct ip_neighbor_learn_t_
102 } ip_neighbor_learn_t;
105 typedef enum ip_neighbor_event_flags_t_
107 IP_NEIGHBOR_EVENT_ADDED = (1 << 0),
108 IP_NEIGHBOR_EVENT_REMOVED = (1 << 1),
109 } ip_neighbor_event_flags_t;
111 typedef struct ip_neighbor_event_t_
113 ip_neighbor_watcher_t ipne_watch;
114 ip_neighbor_event_flags_t ipne_flags;
115 ip_neighbor_t ipne_nbr;
116 } ip_neighbor_event_t;
118 extern void ip_neighbor_clone (const ip_neighbor_t * ipn,
119 ip_neighbor_t * clone);
121 extern void ip_neighbor_free (ip_neighbor_t * ipn);
124 * Keep RX and TX counts per-AF
126 #define foreach_ip_neighbor_counter_type \
128 _ (REQUEST, "request") \
129 _ (GRAT, "gratuitous")
131 typedef enum ip_neighbor_counter_type_t_
133 #define _(a, b) IP_NEIGHBOR_CTR_##a,
134 foreach_ip_neighbor_counter_type
136 } ip_neighbor_counter_type_t;
138 #define N_IP_NEIGHBOR_CTRS (IP_NEIGHBOR_CTR_GRAT + 1)
140 #define FOREACH_IP_NEIGHBOR_CTR(_type) \
141 for (_type = 0; _type < N_IP_NEIGHBOR_CTRS; _type++)
143 typedef struct ip_neighbor_counters_t_
145 vlib_simple_counter_main_t ipnc[VLIB_N_DIR][N_IP_NEIGHBOR_CTRS];
146 } ip_neighbor_counters_t;
148 extern u8 *format_ip_neighbor_counters (u8 *s, va_list *args);
150 extern void ip_neighbor_alloc_ctr (ip_neighbor_counters_t *ctr,
153 extern ip_neighbor_counters_t ip_neighbor_counters[N_AF];
155 #endif /* __INCLUDE_IP_NEIGHBOR_H__ */
158 * fd.io coding-style-patch-verification: ON
161 * eval: (c-set-style "gnu")