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:
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 PLUGINS_IPFIXCOLLECTOR_PLUGIN_IPFIXCOLLECTOR_IPFIXCOLLECTOR_H_
17 #define PLUGINS_IPFIXCOLLECTOR_PLUGIN_IPFIXCOLLECTOR_IPFIXCOLLECTOR_H_
19 #include <vppinfra/pool.h>
20 #include <vppinfra/hash.h>
21 #include <vppinfra/error.h>
23 #define IPFIX_COLLECTOR_CLIENT_NAME_MAX 64
25 #define IPFIX_COLLECTOR_ERR_INVALID_PARAM -1
26 #define IPFIX_COLLECTOR_ERR_REG_EXISTS -2
28 /** @brief Structure other nodes to use for registering with IP-FIX collector.
32 /** String containing name of the client interested in getting
36 /** Node index where packets have to be redirected. */
39 /** Setid of IPFix for which client is interested in getting packets. */
42 /** Add(0) or del(1) operation. */
44 } ipfix_client_add_del_t;
46 /** @brief IP-FIX collector internal client structure to store SetID to
51 /** String containing name of the client interested in getting
55 /** Node index where packets have to be redirected. */
58 /** ipfix-collector next index where packets have to be redirected. */
61 /** Setid of IPFix for which client is interested in getting packets. */
65 /** @brief IP-FIX collector main structure to SetID to client node ID mapping.
70 /** Hash table to map IP-FIX setid to a client registration pool. SetId is
72 uword *client_reg_table;
74 /** Pool of Client node information for the IP-FIX SetID. */
75 ipfix_client *client_reg_pool;
77 /** Pointer to VLib main for the node - ipfix-collector. */
78 vlib_main_t *vlib_main;
80 /** Pointer to vnet main for convenience. */
81 vnet_main_t *vnet_main;
82 } ipfix_collector_main_t;
84 extern vlib_node_registration_t ipfix_collector_node;
86 extern ipfix_collector_main_t ipfix_collector_main;
89 * @brief IP-FIX SetID registration function.
91 * This function can be used by other VPP graph nodes to receive IP-FIX packets
92 * with a particular setid.
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
100 * @returns 0 on success.
101 * @returns Error codes(<0) otherwise.
104 ipfix_collector_reg_setid (vlib_main_t * vm, ipfix_client_add_del_t * info);
106 always_inline ipfix_client *
107 ipfix_collector_get_client (u16 set_id)
109 ipfix_collector_main_t *cm = &ipfix_collector_main;
112 p = hash_get (cm->client_reg_table, set_id);
113 return (p ? pool_elt_at_index (cm->client_reg_pool, (*p)) : NULL);
116 #endif /* PLUGINS_IPFIXCOLLECTOR_PLUGIN_IPFIXCOLLECTOR_IPFIXCOLLECTOR_H_ */
119 * fd.io coding-style-patch-verification: ON
122 * eval: (c-set-style "gnu")