]>
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__
27 struct route_table
*route_table
;
34 * Caution these must be the very first fields
35 * @see agg_node_to_rnode
36 * @see agg_node_from_rnode
44 static inline struct route_node
*agg_node_to_rnode(struct agg_node
*node
)
46 return (struct route_node
*)node
;
49 static inline struct agg_node
*agg_node_from_rnode(struct route_node
*node
)
51 return (struct agg_node
*)node
;
54 static inline struct agg_node
*agg_lock_node(struct agg_node
*node
)
56 return (struct agg_node
*)route_lock_node(agg_node_to_rnode(node
));
59 static inline void agg_unlock_node(struct agg_node
*node
)
61 route_unlock_node(agg_node_to_rnode(node
));
64 static inline void agg_set_table_info(struct agg_table
*atable
, void *data
)
69 static inline void *agg_get_table_info(struct agg_table
*atable
)
74 static inline struct agg_node
*agg_route_top(struct agg_table
*table
)
76 return agg_node_from_rnode(route_top(table
->route_table
));
79 static inline struct agg_node
*agg_route_next(struct agg_node
*node
)
81 return agg_node_from_rnode(route_next(agg_node_to_rnode(node
)));
84 static inline struct agg_node
*agg_node_get(struct agg_table
*table
,
87 return agg_node_from_rnode(route_node_get(table
->route_table
, p
));
90 static inline struct agg_node
*
91 agg_node_lookup(const struct agg_table
*const table
, struct prefix
*p
)
93 return agg_node_from_rnode(route_node_lookup(table
->route_table
, p
));
96 static inline struct agg_node
*agg_route_next_until(struct agg_node
*node
,
97 struct agg_node
*limit
)
99 struct route_node
*rnode
;
101 rnode
= route_next_until(agg_node_to_rnode(node
),
102 agg_node_to_rnode(limit
));
104 return agg_node_from_rnode(rnode
);
107 static inline struct agg_node
*agg_node_match(struct agg_table
*table
,
110 return agg_node_from_rnode(route_node_match(table
->route_table
, p
));
113 static inline struct agg_node
*agg_node_parent(struct agg_node
*node
)
115 struct route_node
*rn
= agg_node_to_rnode(node
);
117 return agg_node_from_rnode(rn
->parent
);
120 static inline struct agg_node
*agg_node_left(struct agg_node
*node
)
122 struct route_node
*rn
= agg_node_to_rnode(node
);
124 return agg_node_from_rnode(rn
->l_left
);
127 static inline struct agg_node
*agg_node_right(struct agg_node
*node
)
129 struct route_node
*rn
= agg_node_to_rnode(node
);
131 return agg_node_from_rnode(rn
->l_right
);
134 extern struct agg_table
*agg_table_init(void);
136 static inline void agg_table_finish(struct agg_table
*atable
)
138 route_table_finish(atable
->route_table
);
139 atable
->route_table
= NULL
;
141 XFREE(MTYPE_TMP
, atable
);
144 static inline struct agg_node
*agg_route_table_top(struct agg_node
*node
)
146 return (struct agg_node
*)route_top(node
->table
);
149 static inline struct agg_table
*agg_get_table(struct agg_node
*node
)
151 return (struct agg_table
*)route_table_get_info(node
->table
);