]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_nhg_private.h
Merge pull request #5706 from mjstapp/fix_nh_debug_show
[mirror_frr.git] / zebra / zebra_nhg_private.h
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 /* Abstraction for connected trees */
34 struct nhg_connected {
35 struct nhg_connected_tree_item tree_item;
36 struct nhg_hash_entry *nhe;
37 };
38
39 static int nhg_connected_cmp(const struct nhg_connected *con1,
40 const struct nhg_connected *con2)
41 {
42 return (con1->nhe->id - con2->nhe->id);
43 }
44
45 DECLARE_RBTREE_UNIQ(nhg_connected_tree, struct nhg_connected, tree_item,
46 nhg_connected_cmp);
47
48 /* nhg connected tree direct access functions */
49 extern void nhg_connected_tree_init(struct nhg_connected_tree_head *head);
50 extern void nhg_connected_tree_free(struct nhg_connected_tree_head *head);
51 extern bool
52 nhg_connected_tree_is_empty(const struct nhg_connected_tree_head *head);
53 extern struct nhg_connected *
54 nhg_connected_tree_root(struct nhg_connected_tree_head *head);
55 extern void nhg_connected_tree_del_nhe(struct nhg_connected_tree_head *head,
56 struct nhg_hash_entry *nhe);
57 extern void nhg_connected_tree_add_nhe(struct nhg_connected_tree_head *head,
58 struct nhg_hash_entry *nhe);
59
60 #endif /* __ZEBRA_NHG_PRIVATE_H__ */