]>
git.proxmox.com Git - mirror_frr.git/blob - lib/agg_table.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * agg_table - Aggregate Table Header
4 * Copyright (C) 2018 Cumulus Networks, Inc.
7 #ifndef __AGG_TABLE_H__
8 #define __AGG_TABLE_H__
18 struct route_table
*route_table
;
25 * Caution these must be the very first fields
26 * @see agg_node_to_rnode
27 * @see agg_node_from_rnode
35 static inline struct route_node
*agg_node_to_rnode(struct agg_node
*node
)
37 return (struct route_node
*)node
;
40 static inline struct agg_node
*agg_node_from_rnode(struct route_node
*node
)
42 return (struct agg_node
*)node
;
45 static inline struct agg_node
*agg_lock_node(struct agg_node
*node
)
47 return (struct agg_node
*)route_lock_node(agg_node_to_rnode(node
));
50 static inline void agg_unlock_node(struct agg_node
*node
)
52 route_unlock_node(agg_node_to_rnode(node
));
55 static inline void agg_set_table_info(struct agg_table
*atable
, void *data
)
60 static inline void *agg_get_table_info(struct agg_table
*atable
)
65 static inline struct agg_node
*agg_route_top(struct agg_table
*table
)
67 return agg_node_from_rnode(route_top(table
->route_table
));
70 static inline struct agg_node
*agg_route_next(struct agg_node
*node
)
72 return agg_node_from_rnode(route_next(agg_node_to_rnode(node
)));
75 static inline struct agg_node
*agg_node_get(struct agg_table
*table
,
76 const struct prefix
*p
)
78 return agg_node_from_rnode(route_node_get(table
->route_table
, p
));
81 static inline struct agg_node
*
82 agg_node_lookup(const struct agg_table
*const table
, const struct prefix
*p
)
84 return agg_node_from_rnode(route_node_lookup(table
->route_table
, p
));
87 static inline struct agg_node
*agg_route_next_until(struct agg_node
*node
,
88 struct agg_node
*limit
)
90 struct route_node
*rnode
;
92 rnode
= route_next_until(agg_node_to_rnode(node
),
93 agg_node_to_rnode(limit
));
95 return agg_node_from_rnode(rnode
);
98 static inline struct agg_node
*agg_node_match(struct agg_table
*table
,
99 const struct prefix
*p
)
101 return agg_node_from_rnode(route_node_match(table
->route_table
, p
));
104 static inline struct agg_node
*agg_node_parent(struct agg_node
*node
)
106 struct route_node
*rn
= agg_node_to_rnode(node
);
108 return agg_node_from_rnode(rn
->parent
);
111 static inline struct agg_node
*agg_node_left(struct agg_node
*node
)
113 struct route_node
*rn
= agg_node_to_rnode(node
);
115 return agg_node_from_rnode(rn
->l_left
);
118 static inline struct agg_node
*agg_node_right(struct agg_node
*node
)
120 struct route_node
*rn
= agg_node_to_rnode(node
);
122 return agg_node_from_rnode(rn
->l_right
);
125 extern struct agg_table
*agg_table_init(void);
127 static inline void agg_table_finish(struct agg_table
*atable
)
129 route_table_finish(atable
->route_table
);
130 atable
->route_table
= NULL
;
132 XFREE(MTYPE_TMP
, atable
);
135 static inline struct agg_node
*agg_route_table_top(struct agg_node
*node
)
137 return (struct agg_node
*)route_top(node
->table
);
140 static inline struct agg_table
*agg_get_table(struct agg_node
*node
)
142 return (struct agg_table
*)route_table_get_info(node
->table
);
145 static inline const struct prefix
*
146 agg_node_get_prefix(const struct agg_node
*node
)
151 static inline unsigned int agg_node_get_lock_count(const struct agg_node
*node
)
156 #ifdef _FRR_ATTRIBUTE_PRINTFRR
157 #pragma FRR printfrr_ext "%pRN" (struct agg_node *)