]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_nhg_private.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_nhg_private.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Nexthop Group Private Functions.
4 * Copyright (C) 2019 Cumulus Networks, Inc.
5 * Stephen Worley
6 */
7
8 /**
9 * These functions should only be used internally for nhg_hash_entry
10 * manipulation and in certain special cases.
11 *
12 * Please use `zebra/zebra_nhg.h` for any general nhg_hash_entry api needs.
13 */
14
15 #ifndef __ZEBRA_NHG_PRIVATE_H__
16 #define __ZEBRA_NHG_PRIVATE_H__
17
18 #include "zebra/zebra_nhg.h"
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /* Abstraction for connected trees */
25 struct nhg_connected {
26 struct nhg_connected_tree_item tree_item;
27 struct nhg_hash_entry *nhe;
28 };
29
30 static int nhg_connected_cmp(const struct nhg_connected *con1,
31 const struct nhg_connected *con2)
32 {
33 return (con1->nhe->id - con2->nhe->id);
34 }
35
36 DECLARE_RBTREE_UNIQ(nhg_connected_tree, struct nhg_connected, tree_item,
37 nhg_connected_cmp);
38
39 /* nhg connected tree direct access functions */
40 extern void nhg_connected_tree_init(struct nhg_connected_tree_head *head);
41 extern void nhg_connected_tree_free(struct nhg_connected_tree_head *head);
42 extern bool
43 nhg_connected_tree_is_empty(const struct nhg_connected_tree_head *head);
44 extern struct nhg_connected *
45 nhg_connected_tree_root(struct nhg_connected_tree_head *head);
46
47 /* I realize _add/_del returns are backwords.
48 *
49 * Currently the list APIs are not standardized for what happens in
50 * the _del() function when the item isn't present.
51 *
52 * We are choosing to return NULL if not found in the _del case for now.
53 */
54
55 /* Delete NHE from the tree. On success, return the NHE, otherwise NULL. */
56 extern struct nhg_hash_entry *
57 nhg_connected_tree_del_nhe(struct nhg_connected_tree_head *head,
58 struct nhg_hash_entry *nhe);
59 /* ADD NHE to the tree. On success, return NULL, otherwise return the NHE. */
60 extern struct nhg_hash_entry *
61 nhg_connected_tree_add_nhe(struct nhg_connected_tree_head *head,
62 struct nhg_hash_entry *nhe);
63
64 #ifdef __cplusplus
65 }
66 #endif
67
68 #endif /* __ZEBRA_NHG_PRIVATE_H__ */