2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 * Neighbour Adjacency sub-type. These adjs represent an L3 peer on a
24 #include <vnet/vnet.h>
25 #include <vnet/adj/adj_types.h>
26 #include <vnet/fib/fib_node.h>
27 #include <vnet/dpo/dpo.h>
31 * Add (and lock) a new or lock an existing neighbour adjacency
34 * The protocol for the next-hop address (v4 or v6)
37 * A description of the protocol of the packets that will forward
38 * through this adj. On an ethernet interface this is the MAC header's
42 * The address of the next-hop/peer to send the packet to
45 * The interface on which the peer resides
47 extern adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto,
48 vnet_link_t link_type,
49 const ip46_address_t *nh_addr,
54 * Add (and lock) a new or lock an existing neighbour adjacency
57 * The protocol for the next-hop address (v4 or v6)
60 * A description of the protocol of the packets that will forward
61 * through this adj. On an ethernet interface this is the MAC header's
65 * The address of the next-hop/peer to send the packet to
68 * The interface on which the peer resides
71 * The rewrite to prepend to packets
73 extern adj_index_t adj_nbr_add_or_lock_w_rewrite(fib_protocol_t nh_proto,
74 vnet_link_t link_type,
75 const ip46_address_t *nh_addr,
80 * Set the MTU on an adjacency
83 extern void adj_nbr_set_mtu(adj_index_t ai, u16 mtu);
86 * @brief When adding a rewrite to an adjacency these are flags that
87 * apply to that rewrite
89 typedef enum adj_nbr_rewrite_flag_t_
91 ADJ_NBR_REWRITE_FLAG_NONE,
94 * An indication that the rewrite is incomplete, i.e. that it describes the
95 * ARP/ND rewrite when probing.
97 ADJ_NBR_REWRITE_FLAG_INCOMPLETE = ADJ_NBR_REWRITE_FLAG_NONE,
100 * An indication that the rewrite is complete, i.e. that it fully describes
101 * the link-layer addressing for the destintation.
102 * The opposite of this is an incomplete rewrite that describes the ARP/ND
103 * rewrite when probing.
105 ADJ_NBR_REWRITE_FLAG_COMPLETE = (1 << 0),
106 } adj_nbr_rewrite_flag_t;
110 * Update the rewrite string for an existing adjacecny.
113 * The index of the adj to update
118 extern void adj_nbr_update_rewrite(adj_index_t adj_index,
119 adj_nbr_rewrite_flag_t flags,
124 * Format aa incomplete neigbour (ARP) adjacency
126 extern u8* format_adj_nbr_incomplete(u8* s, va_list *ap);
130 * Format a neigbour (REWRITE) adjacency
132 extern u8* format_adj_nbr(u8* s, va_list *ap);
135 * @brief Walk the neighbour Adjacencies on a given interface
137 extern void adj_nbr_walk (u32 sw_if_index,
138 fib_protocol_t adj_nh_proto,
142 * @brief Walk the neighbour Adjacencies on a given interface with a given next-hop
145 adj_nbr_walk_nh (u32 sw_if_index,
146 fib_protocol_t adj_nh_proto,
147 const ip46_address_t *nh,
152 * @brief Walk adjacencies on a link with a given v4 next-hop.
153 * that is visit the adjacencies with different link types.
156 adj_nbr_walk_nh4 (u32 sw_if_index,
157 const ip4_address_t *addr,
162 * @brief Walk adjacencies on a link with a given v6 next-hop.
163 * that is visit the adjacencies with different link types.
166 adj_nbr_walk_nh6 (u32 sw_if_index,
167 const ip6_address_t *addr,
172 * @brief Lookup neighbor adjancency.
175 adj_nbr_find (fib_protocol_t nh_proto,
176 vnet_link_t link_type,
177 const ip46_address_t *nh_addr,
181 * Module initialisation
183 extern void adj_nbr_module_init(void);
187 * Return the size of the adjacency database. for testing purposes
189 extern u32 adj_nbr_db_size(void);