]>
git.proxmox.com Git - mirror_frr.git/blob - lib/agg_table.h
2 * agg_table - Aggregate Table Header
3 * Copyright (C) 2018 Cumulus Networks, Inc.
6 * FRR 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
8 * Free Software Foundation; either version 2, or (at your option) any
11 * FRR is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
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
20 #ifndef __AGG_TABLE_H__
21 #define __AGG_TABLE_H__
31 struct route_table
*route_table
;
38 * Caution these must be the very first fields
39 * @see agg_node_to_rnode
40 * @see agg_node_from_rnode
48 static inline struct route_node
*agg_node_to_rnode(struct agg_node
*node
)
50 return (struct route_node
*)node
;
53 static inline struct agg_node
*agg_node_from_rnode(struct route_node
*node
)
55 return (struct agg_node
*)node
;
58 static inline struct agg_node
*agg_lock_node(struct agg_node
*node
)
60 return (struct agg_node
*)route_lock_node(agg_node_to_rnode(node
));
63 static inline void agg_unlock_node(struct agg_node
*node
)
65 route_unlock_node(agg_node_to_rnode(node
));
68 static inline void agg_set_table_info(struct agg_table
*atable
, void *data
)
73 static inline void *agg_get_table_info(struct agg_table
*atable
)
78 static inline struct agg_node
*agg_route_top(struct agg_table
*table
)
80 return agg_node_from_rnode(route_top(table
->route_table
));
83 static inline struct agg_node
*agg_route_next(struct agg_node
*node
)
85 return agg_node_from_rnode(route_next(agg_node_to_rnode(node
)));
88 static inline struct agg_node
*agg_node_get(struct agg_table
*table
,
89 const struct prefix
*p
)
91 return agg_node_from_rnode(route_node_get(table
->route_table
, p
));
94 static inline struct agg_node
*
95 agg_node_lookup(const struct agg_table
*const table
, const struct prefix
*p
)
97 return agg_node_from_rnode(route_node_lookup(table
->route_table
, p
));
100 static inline struct agg_node
*agg_route_next_until(struct agg_node
*node
,
101 struct agg_node
*limit
)
103 struct route_node
*rnode
;
105 rnode
= route_next_until(agg_node_to_rnode(node
),
106 agg_node_to_rnode(limit
));
108 return agg_node_from_rnode(rnode
);
111 static inline struct agg_node
*agg_node_match(struct agg_table
*table
,
112 const struct prefix
*p
)
114 return agg_node_from_rnode(route_node_match(table
->route_table
, p
));
117 static inline struct agg_node
*agg_node_parent(struct agg_node
*node
)
119 struct route_node
*rn
= agg_node_to_rnode(node
);
121 return agg_node_from_rnode(rn
->parent
);
124 static inline struct agg_node
*agg_node_left(struct agg_node
*node
)
126 struct route_node
*rn
= agg_node_to_rnode(node
);
128 return agg_node_from_rnode(rn
->l_left
);
131 static inline struct agg_node
*agg_node_right(struct agg_node
*node
)
133 struct route_node
*rn
= agg_node_to_rnode(node
);
135 return agg_node_from_rnode(rn
->l_right
);
138 extern struct agg_table
*agg_table_init(void);
140 static inline void agg_table_finish(struct agg_table
*atable
)
142 route_table_finish(atable
->route_table
);
143 atable
->route_table
= NULL
;
145 XFREE(MTYPE_TMP
, atable
);
148 static inline struct agg_node
*agg_route_table_top(struct agg_node
*node
)
150 return (struct agg_node
*)route_top(node
->table
);
153 static inline struct agg_table
*agg_get_table(struct agg_node
*node
)
155 return (struct agg_table
*)route_table_get_info(node
->table
);
158 static inline const struct prefix
*
159 agg_node_get_prefix(const struct agg_node
*node
)
164 #ifdef _FRR_ATTRIBUTE_PRINTFRR
165 #pragma FRR printfrr_ext "%pRN" (struct agg_node *)