]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_nhg_private.h
Merge pull request #5722 from donaldsharp/kernel_routes
[mirror_frr.git] / zebra / zebra_nhg_private.h
CommitLineData
5948f013
SW
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 */
34struct nhg_connected {
35 struct nhg_connected_tree_item tree_item;
36 struct nhg_hash_entry *nhe;
37};
38
39static 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
45DECLARE_RBTREE_UNIQ(nhg_connected_tree, struct nhg_connected, tree_item,
46 nhg_connected_cmp);
47
48/* nhg connected tree direct access functions */
49extern void nhg_connected_tree_init(struct nhg_connected_tree_head *head);
50extern void nhg_connected_tree_free(struct nhg_connected_tree_head *head);
51extern bool
52nhg_connected_tree_is_empty(const struct nhg_connected_tree_head *head);
53extern struct nhg_connected *
54nhg_connected_tree_root(struct nhg_connected_tree_head *head);
5bf15faa
SW
55
56/* I realize _add/_del returns are backwords.
57 *
58 * Currently the list APIs are not standardized for what happens in
59 * the _del() function when the item isn't present.
60 *
61 * We are choosing to return NULL if not found in the _del case for now.
62 */
63
64/* Delete NHE from the tree. On success, return the NHE, otherwise NULL. */
65extern struct nhg_hash_entry *
66nhg_connected_tree_del_nhe(struct nhg_connected_tree_head *head,
67 struct nhg_hash_entry *nhe);
68/* ADD NHE to the tree. On success, return NULL, otherwise return the NHE. */
69extern struct nhg_hash_entry *
70nhg_connected_tree_add_nhe(struct nhg_connected_tree_head *head,
71 struct nhg_hash_entry *nhe);
5948f013 72
5948f013 73#endif /* __ZEBRA_NHG_PRIVATE_H__ */