FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ipfixcollector.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 PLUGINS_IPFIXCOLLECTOR_PLUGIN_IPFIXCOLLECTOR_IPFIXCOLLECTOR_H_
17 #define PLUGINS_IPFIXCOLLECTOR_PLUGIN_IPFIXCOLLECTOR_IPFIXCOLLECTOR_H_
18 
19 #include <vppinfra/pool.h>
20 #include <vppinfra/hash.h>
21 #include <vppinfra/error.h>
22 
23 #define IPFIX_COLLECTOR_CLIENT_NAME_MAX 64
24 
25 #define IPFIX_COLLECTOR_ERR_INVALID_PARAM -1
26 #define IPFIX_COLLECTOR_ERR_REG_EXISTS -2
27 
28 /** @brief Structure other nodes to use for registering with IP-FIX collector.
29 */
30 typedef struct
31 {
32  /** String containing name of the client interested in getting
33  ip-fix packets. */
35 
36  /** Node index where packets have to be redirected. */
38 
39  /** Setid of IPFix for which client is interested in getting packets. */
41 
42  /** Add(0) or del(1) operation. */
45 
46 /** @brief IP-FIX collector internal client structure to store SetID to
47  client node ID.
48 */
49 typedef struct
50 {
51  /** String containing name of the client interested in getting
52  ip-fix packets. */
54 
55  /** Node index where packets have to be redirected. */
57 
58  /** ipfix-collector next index where packets have to be redirected. */
60 
61  /** Setid of IPFix for which client is interested in getting packets. */
63 } ipfix_client;
64 
65 /** @brief IP-FIX collector main structure to SetID to client node ID mapping.
66  @note cache aligned.
67 */
68 typedef struct
69 {
70  /** Hash table to map IP-FIX setid to a client registration pool. SetId is
71  key to hash map. */
73 
74  /** Pool of Client node information for the IP-FIX SetID. */
76 
77  /** Pointer to VLib main for the node - ipfix-collector. */
79 
80  /** Pointer to vnet main for convenience. */
83 
85 
87 
88 /**
89  * @brief IP-FIX SetID registration function.
90  *
91  * This function can be used by other VPP graph nodes to receive IP-FIX packets
92  * with a particular setid.
93  *
94  * @param vm Vlib main of the graph node which is interested in
95  * getting IP-Fix packet.
96  * @param info Structure describing the client node which
97  * is interested in getting the IP-Fix packets for
98  * a SetID.
99  *
100  * @returns 0 on success.
101  * @returns Error codes(<0) otherwise.
102  */
103 int
105 
108 {
110  uword *p;
111 
112  p = hash_get (cm->client_reg_table, set_id);
113  return (p ? pool_elt_at_index (cm->client_reg_pool, (*p)) : NULL);
114 }
115 
116 #endif /* PLUGINS_IPFIXCOLLECTOR_PLUGIN_IPFIXCOLLECTOR_IPFIXCOLLECTOR_H_ */
117 
118 /*
119  * fd.io coding-style-patch-verification: ON
120  *
121  * Local Variables:
122  * eval: (c-set-style "gnu")
123  * End:
124  */
ipfix_collector_main_t::vlib_main
vlib_main_t * vlib_main
Pointer to VLib main for the node - ipfix-collector.
Definition: ipfixcollector.h:78
ipfix_collector_get_client
static ipfix_client * ipfix_collector_get_client(u16 set_id)
Definition: ipfixcollector.h:107
ipfix_collector_node
vlib_node_registration_t ipfix_collector_node
(constructor) VLIB_REGISTER_NODE (ipfix_collector_node)
Definition: node.c:275
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
u16
unsigned short u16
Definition: types.h:57
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
ipfix_client_add_del_t
Structure other nodes to use for registering with IP-FIX collector.
Definition: ipfixcollector.h:30
ipfix_collector_reg_setid
int ipfix_collector_reg_setid(vlib_main_t *vm, ipfix_client_add_del_t *info)
IP-FIX SetID registration function.
Definition: ipfixcollector.c:39
ipfix_client::client_name
u8 * client_name
String containing name of the client interested in getting ip-fix packets.
Definition: ipfixcollector.h:53
ipfix_client_add_del_t::client_node
u32 client_node
Node index where packets have to be redirected.
Definition: ipfixcollector.h:37
ipfix_client_add_del_t::client_name
u8 * client_name
String containing name of the client interested in getting ip-fix packets.
Definition: ipfixcollector.h:34
ipfix_client::set_id
u16 set_id
Setid of IPFix for which client is interested in getting packets.
Definition: ipfixcollector.h:62
hash.h
ipfix_collector_main_t
IP-FIX collector main structure to SetID to client node ID mapping.
Definition: ipfixcollector.h:68
error.h
ipfix_collector_main_t::vnet_main
vnet_main_t * vnet_main
Pointer to vnet main for convenience.
Definition: ipfixcollector.h:81
hash_get
#define hash_get(h, key)
Definition: hash.h:249
ipfix_client::client_next_node
u32 client_next_node
ipfix-collector next index where packets have to be redirected.
Definition: ipfixcollector.h:59
uword
u64 uword
Definition: types.h:112
pool.h
Fixed length block allocator. Pools are built from clib vectors and bitmaps. Use pools when repeatedl...
ipfix_client
IP-FIX collector internal client structure to store SetID to client node ID.
Definition: ipfixcollector.h:49
ipfix_collector_main_t::client_reg_pool
ipfix_client * client_reg_pool
Pool of Client node information for the IP-FIX SetID.
Definition: ipfixcollector.h:75
cm
vnet_feature_config_main_t * cm
Definition: nat44_ei_hairpinning.c:594
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vnet_main_t
Definition: vnet.h:76
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
ipfix_collector_main_t::client_reg_table
uword * client_reg_table
Hash table to map IP-FIX setid to a client registration pool.
Definition: ipfixcollector.h:72
u32
unsigned int u32
Definition: types.h:88
ipfix_client_add_del_t::del
u16 del
Add(0) or del(1) operation.
Definition: ipfixcollector.h:43
ipfix_collector_main
ipfix_collector_main_t ipfix_collector_main
Definition: ipfixcollector.c:21
vlib_main_t
Definition: main.h:102
u8
unsigned char u8
Definition: types.h:56
ipfix_client::client_node
u32 client_node
Node index where packets have to be redirected.
Definition: ipfixcollector.h:56
ipfix_client_add_del_t::ipfix_setid
u16 ipfix_setid
Setid of IPFix for which client is interested in getting packets.
Definition: ipfixcollector.h:40