FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
adj_delegate.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  * A Delagate is a means to implement the Delagation design pattern;
17  * the extension of an object's functionality through the composition of,
18  * and delgation to, other objects.
19  * These 'other' objects are delegates. Delagates are thus attached to
20  * ADJ objects to extend their functionality.
21  */
22 
23 #ifndef __ADJ_DELEGATE_T__
24 #define __ADJ_DELEGATE_T__
25 
26 #include <vnet/adj/adj.h>
27 
28 /**
29  * Built-in delegate types.
30  * When adding new types, if your code is within the vnet subsystem, then add a
31  * new type here. If not then use the adj_delegate_register_new_type API to
32  * register a new type.
33  */
34 typedef enum adj_delegate_type_t_ {
35  /**
36  * BFD session state
37  */
39  /**
40  * Stacking of a midchain's nexthop
41  */
44 
45 #define ADJ_DELEGATE_LAST (ADJ_DELEGATE_MIDCHAIN)
46 
47 /**
48  * Adj delegate. This object is attached to the adjacency.
49  */
50 typedef struct adj_delegate_t_
51 {
52  /**
53  * The ADJ entry object to which the delagate is attached
54  */
56 
57  /**
58  * The delagate type
59  */
61 
62  /**
63  * The index passed by the provider to identify its delegate instance.
64  * As with all things VPP this is a pool index.
65  */
68 
69 /**
70  * Indication that the adjacency has been deleted. The delegate provider should free
71  * the delegate.
72  */
74 
75 /**
76  * Format function for the delegate
77  */
78 typedef u8 * (*adj_delegate_format_t)(const adj_delegate_t *aed, u8 *s);
79 
80 /**
81  * Notification that an adjacency has been created
82  */
84 
85 /**
86  * Indication that the adjacency has been modified.
87  * the delegate.
88  */
90 
91 /**
92  * An ADJ delegate virtual function table
93  */
94 typedef struct adj_delegate_vft_t_ {
100 
101 /**
102  * @brief Remove a delegate from an adjacency
103  *
104  * @param ai The adjacency to remove the delegate from
105  * @param type The type of delegate being removed
106  */
107 extern void adj_delegate_remove(adj_index_t ai,
109 
110 /**
111  * @brief Add a delegate to an adjacency
112  *
113  * @param ai The adjacency to add the delegate to
114  * @param type The type of delegate being added
115  * @param adi The provider's [pool] index of its attached objet
116  */
117 extern int adj_delegate_add(ip_adjacency_t *adj,
119  index_t adi);
120 
121 /**
122  * @brief Get a delegate from an adjacency
123  *
124  * @param ai The adjacency to get the delegate from
125  * @param type The type of delegate being sought
126  */
129 
130 /**
131  * @brief Register a VFT for one of the built-in types
132  */
134  const adj_delegate_vft_t *vft);
135 
136 /**
137  * @brief create a new delegate type and register a new VFT
138  */
140  const adj_delegate_vft_t *vft);
141 
142 #endif
adj.h
adj_delegate_t_::ad_index
index_t ad_index
The index passed by the provider to identify its delegate instance.
Definition: adj_delegate.h:66
adj_delegate_remove
void adj_delegate_remove(adj_index_t ai, adj_delegate_type_t type)
Remove a delegate from an adjacency.
Definition: adj_delegate.c:65
adj_delegate_vft_t_
An ADJ delegate virtual function table.
Definition: adj_delegate.h:94
adj_delegate_type_t_
adj_delegate_type_t_
A Delagate is a means to implement the Delagation design pattern; the extension of an object's functi...
Definition: adj_delegate.h:34
adj_delegate_t_
Adj delegate.
Definition: adj_delegate.h:50
adj_delegate_t_::ad_type
adj_delegate_type_t ad_type
The delagate type.
Definition: adj_delegate.h:60
adj_delegate_t
struct adj_delegate_t_ adj_delegate_t
Adj delegate.
adj_delegate_adj_created_t
void(* adj_delegate_adj_created_t)(adj_index_t ai)
Notification that an adjacency has been created.
Definition: adj_delegate.h:83
adj_delegate_add
int adj_delegate_add(ip_adjacency_t *adj, adj_delegate_type_t fdt, index_t adi)
Add a delegate to an adjacency.
Definition: adj_delegate.c:107
adj_delegate_register_new_type
adj_delegate_type_t adj_delegate_register_new_type(const adj_delegate_vft_t *vft)
create a new delegate type and register a new VFT
Definition: adj_delegate.c:218
adj_delegate_type_t
enum adj_delegate_type_t_ adj_delegate_type_t
A Delagate is a means to implement the Delagation design pattern; the extension of an object's functi...
adj_delegate_t_::ad_adj_index
adj_index_t ad_adj_index
The ADJ entry object to which the delagate is attached.
Definition: adj_delegate.h:55
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
adj_delegate_adj_deleted_t
void(* adj_delegate_adj_deleted_t)(adj_delegate_t *aed)
Indication that the adjacency has been deleted.
Definition: adj_delegate.h:73
ADJ_DELEGATE_MIDCHAIN
@ ADJ_DELEGATE_MIDCHAIN
Stacking of a midchain's nexthop.
Definition: adj_delegate.h:42
ip_adjacency_t_
IP unicast adjacency.
Definition: adj.h:235
adj_delegate_get
adj_delegate_t * adj_delegate_get(const ip_adjacency_t *adj, adj_delegate_type_t type)
Get a delegate from an adjacency.
Definition: adj_delegate.c:58
adj_delegate_format_t
u8 *(* adj_delegate_format_t)(const adj_delegate_t *aed, u8 *s)
Format function for the delegate.
Definition: adj_delegate.h:78
adj_delegate_vft_t_::adv_adj_deleted
adj_delegate_adj_deleted_t adv_adj_deleted
Definition: adj_delegate.h:96
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
adj_delegate_adj_modified_t
void(* adj_delegate_adj_modified_t)(adj_delegate_t *aed)
Indication that the adjacency has been modified.
Definition: adj_delegate.h:89
u8
unsigned char u8
Definition: types.h:56
ADJ_DELEGATE_BFD
@ ADJ_DELEGATE_BFD
BFD session state.
Definition: adj_delegate.h:38
adj_delegate_vft_t_::adv_adj_modified
adj_delegate_adj_modified_t adv_adj_modified
Definition: adj_delegate.h:97
adj_delegate_register_type
void adj_delegate_register_type(adj_delegate_type_t type, const adj_delegate_vft_t *vft)
Register a VFT for one of the built-in types.
Definition: adj_delegate.c:199
adj_delegate_vft_t
struct adj_delegate_vft_t_ adj_delegate_vft_t
An ADJ delegate virtual function table.
adj_delegate_vft_t_::adv_format
adj_delegate_format_t adv_format
Definition: adj_delegate.h:95
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
adj_delegate_vft_t_::adv_adj_created
adj_delegate_adj_created_t adv_adj_created
Definition: adj_delegate.h:98