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.
16 #ifndef __ADJ_INTERNAL_H__
17 #define __ADJ_INTERNAL_H__
19 #include <vnet/adj/adj.h>
20 #include <vnet/adj/adj_mcast.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/mpls/mpls.h>
23 #include <vnet/adj/adj_l2.h>
24 #include <vnet/adj/adj_nsh.h>
27 * big switch to turn on Adjacency debugging
34 extern vlib_log_class_t adj_logger;
35 #define ADJ_DBG(_adj, _fmt, _args...) \
37 vlib_log_debug(adj_logger, "adj:[%d:%p]:" _fmt, \
38 _adj - adj_pool, _adj, \
45 extern vlib_node_registration_t adj_nsh_midchain_node;
46 extern vlib_node_registration_t adj_nsh_rewrite_node;
47 extern vlib_node_registration_t adj_midchain_tx;
50 adj_get_rewrite_node (vnet_link_t linkt)
54 return (ip4_rewrite_node.index);
56 return (ip6_rewrite_node.index);
58 return (mpls_output_node.index);
59 case VNET_LINK_ETHERNET:
60 return (adj_l2_rewrite_node.index);
62 return (adj_nsh_rewrite_node.index);
70 static inline vnet_link_t
71 adj_fib_proto_2_nd (fib_protocol_t fp)
75 case FIB_PROTOCOL_IP4:
76 return (VNET_LINK_ARP);
77 case FIB_PROTOCOL_IP6:
78 return (VNET_LINK_IP6);
79 case FIB_PROTOCOL_MPLS:
80 return (VNET_LINK_MPLS);
85 static inline ip46_type_t
86 adj_proto_to_46 (fib_protocol_t proto)
90 case FIB_PROTOCOL_IP4:
91 return (IP46_TYPE_IP4);
92 case FIB_PROTOCOL_IP6:
93 return (IP46_TYPE_IP6);
95 return (IP46_TYPE_IP4);
97 return (IP46_TYPE_IP4);
102 * Get a pointer to an adjacency object from its index
104 static inline adj_index_t
105 adj_get_index (const ip_adjacency_t *adj)
107 return (adj - adj_pool);
110 extern void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj,
111 ip_lookup_next_t adj_next_index,
112 u32 complete_next_index,
115 extern void adj_midchain_setup(adj_index_t adj_index,
116 adj_midchain_fixup_t fixup,
120 extern ip_adjacency_t * adj_alloc(fib_protocol_t proto);
122 extern void adj_nbr_remove(adj_index_t ai,
123 fib_protocol_t nh_proto,
124 vnet_link_t link_type,
125 const ip46_address_t *nh_addr,
127 extern u32 adj_nbr_get_n_adjs(vnet_link_t link_type, u32 sw_if_index);
128 extern void adj_glean_remove(ip_adjacency_t *adj);
129 extern void adj_mcast_remove(fib_protocol_t proto,
131 extern void adj_midchain_teardown(ip_adjacency_t *adj);
133 extern u32 adj_dpo_get_urpf(const dpo_id_t *dpo);
134 extern u16 adj_dpo_get_mtu(const dpo_id_t *dpo);
139 extern int adj_bfd_is_up (adj_index_t ai);
144 extern void adj_delegate_adj_deleted(ip_adjacency_t *adj);
145 extern void adj_delegate_adj_created(ip_adjacency_t *adj);
146 extern void adj_delegate_adj_modified(ip_adjacency_t *adj);
147 extern u8* adj_delegate_format(u8* s, ip_adjacency_t *adj);