FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
adj_internal.h
Go to the documentation of this file.
1 /*
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:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #ifndef __ADJ_INTERNAL_H__
17 #define __ADJ_INTERNAL_H__
18 
19 #include <vnet/adj/adj.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/mpls/mpls.h>
22 #include <vnet/adj/adj_l2.h>
23 
24 
25 /**
26  * big switch to turn on Adjacency debugging
27  */
28 #undef ADJ_DEBUG
29 
30 /*
31  * Debug macro
32  */
33 #ifdef ADJ_DEBUG
34 #define ADJ_DBG(_adj, _fmt, _args...) \
35 { \
36  clib_warning("adj:[%d:%p]:" _fmt, \
37  _adj - adj_pool, _adj, \
38  ##_args); \
39 }
40 #else
41 #define ADJ_DBG(_e, _fmt, _args...)
42 #endif
43 
44 static inline u32
46 {
47  switch (linkt) {
48  case VNET_LINK_IP4:
49  return (ip4_rewrite_node.index);
50  case VNET_LINK_IP6:
51  return (ip6_rewrite_node.index);
52  case VNET_LINK_MPLS:
53  return (mpls_output_node.index);
54  case VNET_LINK_ETHERNET:
55  return (adj_l2_rewrite_node.index);
56  case VNET_LINK_ARP:
57  break;
58  }
59  ASSERT(0);
60  return (0);
61 }
62 
63 static inline vnet_link_t
65 {
66  switch (fp)
67  {
68  case FIB_PROTOCOL_IP4:
69  return (VNET_LINK_ARP);
70  case FIB_PROTOCOL_IP6:
71  return (VNET_LINK_IP6);
72  case FIB_PROTOCOL_MPLS:
73  return (VNET_LINK_MPLS);
74  }
75  return (0);
76 }
77 
78 /**
79  * @brief
80  * Get a pointer to an adjacency object from its index
81  */
82 static inline adj_index_t
84 {
85  return (adj - adj_pool);
86 }
87 
90  u32 complete_next_index,
91  u32 next_index,
92  u8 *rewrite);
93 
95 
96 extern void adj_nbr_remove(fib_protocol_t nh_proto,
97  vnet_link_t link_type,
98  const ip46_address_t *nh_addr,
99  u32 sw_if_index);
100 extern void adj_glean_remove(fib_protocol_t proto,
101  u32 sw_if_index);
102 
103 #endif
ip_adjacency_t * adj_pool
The global adjacnecy pool.
Definition: adj.c:35
void adj_glean_remove(fib_protocol_t proto, u32 sw_if_index)
Definition: adj_glean.c:92
IP unicast adjacency.
Definition: lookup.h:174
vlib_node_registration_t ip6_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_node)
Definition: ip6_forward.c:2188
void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj, adj_nbr_rewrite_flag_t flags, u32 complete_next_index, u32 next_index, u8 *rewrite)
ip_adjacency_t * adj_alloc(fib_protocol_t proto)
Definition: adj.c:47
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
void adj_nbr_remove(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Definition: adj_nbr.c:79
static adj_index_t adj_get_index(ip_adjacency_t *adj)
Get a pointer to an adjacency object from its index.
Definition: adj_internal.h:83
vlib_node_registration_t ip4_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip4_rewrite_node)
Definition: ip4_forward.c:2657
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static u32 adj_get_rewrite_node(vnet_link_t linkt)
Definition: adj_internal.h:45
unsigned char u8
Definition: types.h:56
enum adj_nbr_rewrite_flag_t_ adj_nbr_rewrite_flag_t
When adding a rewrite to an adjacency these are flags that apply to that rewrite. ...
static vnet_link_t adj_fib_proto_2_nd(fib_protocol_t fp)
Definition: adj_internal.h:64
vlib_node_registration_t adj_l2_rewrite_node
(constructor) VLIB_REGISTER_NODE (adj_l2_rewrite_node)
Definition: adj_l2.c:171
u32 flags
Definition: vhost-user.h:75
vlib_node_registration_t mpls_output_node
(constructor) VLIB_REGISTER_NODE (mpls_output_node)
Definition: mpls_output.c:178