]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_nhg_private.h
Merge pull request #13451 from sri-mohan1/srib-ldpd
[mirror_frr.git] / zebra / zebra_nhg_private.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
5948f013
SW
2/*
3 * Nexthop Group Private Functions.
4 * Copyright (C) 2019 Cumulus Networks, Inc.
5 * Stephen Worley
5948f013
SW
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
17e38209
RW
20#ifdef __cplusplus
21extern "C" {
22#endif
23
5948f013
SW
24/* Abstraction for connected trees */
25struct nhg_connected {
26 struct nhg_connected_tree_item tree_item;
27 struct nhg_hash_entry *nhe;
28};
29
30static 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
36DECLARE_RBTREE_UNIQ(nhg_connected_tree, struct nhg_connected, tree_item,
37 nhg_connected_cmp);
38
39/* nhg connected tree direct access functions */
40extern void nhg_connected_tree_init(struct nhg_connected_tree_head *head);
41extern void nhg_connected_tree_free(struct nhg_connected_tree_head *head);
42extern bool
43nhg_connected_tree_is_empty(const struct nhg_connected_tree_head *head);
44extern struct nhg_connected *
45nhg_connected_tree_root(struct nhg_connected_tree_head *head);
5bf15faa
SW
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. */
56extern struct nhg_hash_entry *
57nhg_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. */
60extern struct nhg_hash_entry *
61nhg_connected_tree_add_nhe(struct nhg_connected_tree_head *head,
62 struct nhg_hash_entry *nhe);
5948f013 63
17e38209
RW
64#ifdef __cplusplus
65}
66#endif
67
5948f013 68#endif /* __ZEBRA_NHG_PRIVATE_H__ */