back to topotato report
topotato coverage report
Current view: top level - zebra - zebra_nhg_private.h (source / functions) Hit Total Coverage
Test: test_pim6_basic.py::PIM6Basic Lines: 3 3 100.0 %
Date: 2023-02-24 18:38:38 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Nexthop Group Private Functions.
       3             :  * Copyright (C) 2019 Cumulus Networks, Inc.
       4             :  *                    Stephen Worley
       5             :  *
       6             :  * This program is free software; you can redistribute it and/or modify it
       7             :  * under the terms of the GNU General Public License as published by the Free
       8             :  * Software Foundation; either version 2 of the License, or (at your option)
       9             :  * any later version.
      10             :  *
      11             :  * This program is distributed in the hope that it will be useful, but WITHOUT
      12             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             :  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
      14             :  * more details.
      15             :  *
      16             :  * You should have received a copy of the GNU General Public License along
      17             :  * with this program; see the file COPYING; if not, write to the Free Software
      18             :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
      19             :  */
      20             : 
      21             : /**
      22             :  * These functions should only be used internally for nhg_hash_entry
      23             :  * manipulation and in certain special cases.
      24             :  *
      25             :  * Please use `zebra/zebra_nhg.h` for any general nhg_hash_entry api needs.
      26             :  */
      27             : 
      28             : #ifndef __ZEBRA_NHG_PRIVATE_H__
      29             : #define __ZEBRA_NHG_PRIVATE_H__
      30             : 
      31             : #include "zebra/zebra_nhg.h"
      32             : 
      33             : #ifdef __cplusplus
      34             : extern "C" {
      35             : #endif
      36             : 
      37             : /* Abstraction for connected trees */
      38             : struct nhg_connected {
      39             :         struct nhg_connected_tree_item tree_item;
      40             :         struct nhg_hash_entry *nhe;
      41             : };
      42             : 
      43         111 : static int nhg_connected_cmp(const struct nhg_connected *con1,
      44             :                              const struct nhg_connected *con2)
      45             : {
      46         111 :         return (con1->nhe->id - con2->nhe->id);
      47             : }
      48             : 
      49        1340 : DECLARE_RBTREE_UNIQ(nhg_connected_tree, struct nhg_connected, tree_item,
      50             :                     nhg_connected_cmp);
      51             : 
      52             : /* nhg connected tree direct access functions */
      53             : extern void nhg_connected_tree_init(struct nhg_connected_tree_head *head);
      54             : extern void nhg_connected_tree_free(struct nhg_connected_tree_head *head);
      55             : extern bool
      56             : nhg_connected_tree_is_empty(const struct nhg_connected_tree_head *head);
      57             : extern struct nhg_connected *
      58             : nhg_connected_tree_root(struct nhg_connected_tree_head *head);
      59             : 
      60             : /* I realize _add/_del returns are backwords.
      61             :  *
      62             :  * Currently the list APIs are not standardized for what happens in
      63             :  * the _del() function when the item isn't present.
      64             :  *
      65             :  * We are choosing to return NULL if not found in the _del case for now.
      66             :  */
      67             : 
      68             : /* Delete NHE from the tree. On success, return the NHE, otherwise NULL. */
      69             : extern struct nhg_hash_entry *
      70             : nhg_connected_tree_del_nhe(struct nhg_connected_tree_head *head,
      71             :                            struct nhg_hash_entry *nhe);
      72             : /* ADD NHE to the tree. On success, return NULL, otherwise return the NHE. */
      73             : extern struct nhg_hash_entry *
      74             : nhg_connected_tree_add_nhe(struct nhg_connected_tree_head *head,
      75             :                            struct nhg_hash_entry *nhe);
      76             : 
      77             : #ifdef __cplusplus
      78             : }
      79             : #endif
      80             : 
      81             : #endif /* __ZEBRA_NHG_PRIVATE_H__ */

Generated by: LCOV version v1.16-topotato