2 * Nexthop Group Private Functions.
3 * Copyright (C) 2019 Cumulus Networks, Inc.
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)
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
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
22 * These functions should only be used internally for nhg_hash_entry
23 * manipulation and in certain special cases.
25 * Please use `zebra/zebra_nhg.h` for any general nhg_hash_entry api needs.
28 #ifndef __ZEBRA_NHG_PRIVATE_H__
29 #define __ZEBRA_NHG_PRIVATE_H__
31 #include "zebra/zebra_nhg.h"
37 /* Abstraction for connected trees */
38 struct nhg_connected
{
39 struct nhg_connected_tree_item tree_item
;
40 struct nhg_hash_entry
*nhe
;
43 static int nhg_connected_cmp(const struct nhg_connected
*con1
,
44 const struct nhg_connected
*con2
)
46 return (con1
->nhe
->id
- con2
->nhe
->id
);
49 DECLARE_RBTREE_UNIQ(nhg_connected_tree
, struct nhg_connected
, tree_item
,
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
);
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
);
60 /* I realize _add/_del returns are backwords.
62 * Currently the list APIs are not standardized for what happens in
63 * the _del() function when the item isn't present.
65 * We are choosing to return NULL if not found in the _del case for now.
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
);
81 #endif /* __ZEBRA_NHG_PRIVATE_H__ */