blob: 1e8df46d516a0cc01a1e9f4efe035309cc7c4fa1 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * Routing Table
3 * Copyright (C) 1998 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#ifndef _ZEBRA_TABLE_H
24#define _ZEBRA_TABLE_H
25
26/* Routing table top structure. */
27struct route_table
28{
29 struct route_node *top;
Avneesh Sachdev3eb8ef32012-08-17 08:19:47 -070030
31 unsigned long count;
paul718e3742002-12-13 20:15:29 +000032};
33
34/* Each routing entry. */
35struct route_node
36{
37 /* Actual prefix of this radix. */
38 struct prefix p;
39
40 /* Tree link. */
41 struct route_table *table;
42 struct route_node *parent;
43 struct route_node *link[2];
44#define l_left link[0]
45#define l_right link[1]
46
47 /* Lock of this radix */
48 unsigned int lock;
49
50 /* Each node of route. */
51 void *info;
52
53 /* Aggregation. */
54 void *aggregate;
55};
56
57/* Prototypes. */
paul8cc41982005-05-06 21:25:49 +000058extern struct route_table *route_table_init (void);
59extern void route_table_finish (struct route_table *);
60extern void route_unlock_node (struct route_node *node);
paul8cc41982005-05-06 21:25:49 +000061extern struct route_node *route_top (struct route_table *);
62extern struct route_node *route_next (struct route_node *);
63extern struct route_node *route_next_until (struct route_node *,
64 struct route_node *);
Avneesh Sachdev3eb8ef32012-08-17 08:19:47 -070065extern struct route_node *route_node_get (struct route_table *const,
paul8cc41982005-05-06 21:25:49 +000066 struct prefix *);
Avneesh Sachdev3eb8ef32012-08-17 08:19:47 -070067extern struct route_node *route_node_lookup (const struct route_table *,
paul8cc41982005-05-06 21:25:49 +000068 struct prefix *);
69extern struct route_node *route_lock_node (struct route_node *node);
Stephen Hemminger38cc00c2009-12-08 12:00:50 +030070extern struct route_node *route_node_match (const struct route_table *,
71 const struct prefix *);
72extern struct route_node *route_node_match_ipv4 (const struct route_table *,
73 const struct in_addr *);
paul718e3742002-12-13 20:15:29 +000074#ifdef HAVE_IPV6
Stephen Hemminger38cc00c2009-12-08 12:00:50 +030075extern struct route_node *route_node_match_ipv6 (const struct route_table *,
76 const struct in6_addr *);
paul718e3742002-12-13 20:15:29 +000077#endif /* HAVE_IPV6 */
78
Avneesh Sachdev3eb8ef32012-08-17 08:19:47 -070079extern unsigned long route_table_count (const struct route_table *);
paul718e3742002-12-13 20:15:29 +000080#endif /* _ZEBRA_TABLE_H */