FD.io VPP  v18.01-8-g0eacf49
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 intereseted 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 intereseted 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 vlib_main_t Vlib main of the graph node which is interseted in
95  * getting IP-Fix packet.
96  * @param ipfix_client_add_del_t 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  */
u16 del
Add(0) or del(1) operation.
vnet_main_t * vnet_main
Pointer to vnet main for convenience.
u16 ipfix_setid
Setid of IPFix for which client is intereseted in getting packets.
ipfix_client * client_reg_pool
Pool of Client node information for the IP-FIX SetID.
IP-FIX collector internal client structure to store SetID to client node ID.
u32 client_next_node
ipfix-collector next index where packets have to be redirected.
uword * client_reg_table
Hash table to map IP-FIX setid to a client registration pool.
Fixed length block allocator.
#define NULL
Definition: clib.h:55
static ipfix_client * ipfix_collector_get_client(u16 set_id)
struct _vlib_node_registration vlib_node_registration_t
u16 set_id
Setid of IPFix for which client is intereseted in getting packets.
ipfix_collector_main_t ipfix_collector_main
int ipfix_collector_reg_setid(vlib_main_t *vm, ipfix_client_add_del_t *info)
IP-FIX SetID registration function.
vlib_main_t * vlib_main
Pointer to VLib main for the node - ipfix-collector.
#define always_inline
Definition: clib.h:92
u8 * client_name
String containing name of the client interested in getting ip-fix packets.
u32 client_node
Node index where packets have to be redirected.
vlib_node_registration_t ipfix_collector_node
(constructor) VLIB_REGISTER_NODE (ipfix_collector_node)
Definition: node.c:276
#define hash_get(h, key)
Definition: hash.h:248
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:459
vlib_main_t * vm
Definition: buffer.c:283
unsigned int u32
Definition: types.h:88
u8 * client_name
String containing name of the client interested in getting ip-fix packets.
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
IP-FIX collector main structure to SetID to client node ID mapping.
Structure other nodes to use for registering with IP-FIX collector.
u32 client_node
Node index where packets have to be redirected.