LCOV - code coverage report
Current view: top level - plugins/ioam/ipfixcollector - ipfixcollector.h (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 4 0.0 %
Date: 2023-10-26 01:39:38 Functions: 0 1 0.0 %

          Line data    Source code
       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. */
      34             :   u8 *client_name;
      35             : 
      36             :   /** Node index where packets have to be redirected. */
      37             :   u32 client_node;
      38             : 
      39             :   /** Setid of IPFix for which client is interested in getting packets. */
      40             :   u16 ipfix_setid;
      41             : 
      42             :   /** Add(0) or del(1) operation. */
      43             :   u16 del;
      44             : } ipfix_client_add_del_t;
      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. */
      53             :   u8 *client_name;
      54             : 
      55             :   /** Node index where packets have to be redirected. */
      56             :   u32 client_node;
      57             : 
      58             :   /** ipfix-collector next index where packets have to be redirected. */
      59             :   u32 client_next_node;
      60             : 
      61             :   /** Setid of IPFix for which client is interested in getting packets. */
      62             :   u16 set_id;
      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. */
      72             :   uword *client_reg_table;
      73             : 
      74             :   /** Pool of Client node information for the IP-FIX SetID. */
      75             :   ipfix_client *client_reg_pool;
      76             : 
      77             :   /** Pointer to VLib main for the node - ipfix-collector. */
      78             :   vlib_main_t *vlib_main;
      79             : 
      80             :   /** Pointer to vnet main for convenience. */
      81             :   vnet_main_t *vnet_main;
      82             : } ipfix_collector_main_t;
      83             : 
      84             : extern vlib_node_registration_t ipfix_collector_node;
      85             : 
      86             : extern ipfix_collector_main_t ipfix_collector_main;
      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
     104             : ipfix_collector_reg_setid (vlib_main_t * vm, ipfix_client_add_del_t * info);
     105             : 
     106             : always_inline ipfix_client *
     107           0 : ipfix_collector_get_client (u16 set_id)
     108             : {
     109           0 :   ipfix_collector_main_t *cm = &ipfix_collector_main;
     110             :   uword *p;
     111             : 
     112           0 :   p = hash_get (cm->client_reg_table, set_id);
     113           0 :   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             :  */

Generated by: LCOV version 1.14