1/*
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;
30};
31
32/* Each routing entry. */
33struct route_node
34{
35  /* Actual prefix of this radix. */
36  struct prefix p;
37
38  /* Tree link. */
39  struct route_table *table;
40  struct route_node *parent;
41  struct route_node *link[2];
42#define l_left   link[0]
43#define l_right  link[1]
44
45  /* Lock of this radix */
46  unsigned int lock;
47
48  /* Each node of route. */
49  void *info;
50
51  /* Aggregation. */
52  void *aggregate;
53};
54
55/* Prototypes. */
56struct route_table *route_table_init (void);
57void route_table_finish (struct route_table *);
58void route_unlock_node (struct route_node *node);
59void route_node_delete (struct route_node *node);
60struct route_node *route_top (struct route_table *);
61struct route_node *route_next (struct route_node *);
62struct route_node *route_next_until (struct route_node *, struct route_node *);
63struct route_node *route_node_get (struct route_table *, struct prefix *);
64struct route_node *route_node_lookup (struct route_table *, struct prefix *);
65struct route_node *route_lock_node (struct route_node *node);
66struct route_node *route_node_match (struct route_table *, struct prefix *);
67struct route_node *route_node_match_ipv4 (struct route_table *,
68					  struct in_addr *);
69#ifdef HAVE_IPV6
70struct route_node *route_node_match_ipv6 (struct route_table *,
71					  struct in6_addr *);
72#endif /* HAVE_IPV6 */
73
74#endif /* _ZEBRA_TABLE_H */
75