blob: 53df0bc6caa0f3998d5a1247dce73d2eea940cf7 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing table
2 Copyright (C) 1998, 2001 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
paul00d252c2005-05-23 14:19:54 +000021#ifndef _QUAGGA_BGP_TABLE_H
22#define _QUAGGA_BGP_TABLE_H
23
paulfee0f4c2004-09-13 05:12:46 +000024typedef enum
25{
26 BGP_TABLE_MAIN,
27 BGP_TABLE_RSCLIENT,
28} bgp_table_t;
29
paul718e3742002-12-13 20:15:29 +000030struct bgp_table
31{
paulfee0f4c2004-09-13 05:12:46 +000032 bgp_table_t type;
Paul Jakma64e580a2006-02-21 01:09:01 +000033
34 /* afi/safi of this table */
35 afi_t afi;
36 safi_t safi;
37
Chris Caputo228da422009-07-18 05:44:03 +000038 int lock;
39
paulfee0f4c2004-09-13 05:12:46 +000040 /* The owner of this 'bgp_table' structure. */
Chris Caputo228da422009-07-18 05:44:03 +000041 struct peer *owner;
paulfee0f4c2004-09-13 05:12:46 +000042
paul718e3742002-12-13 20:15:29 +000043 struct bgp_node *top;
Paul Jakmacbdfbaa2006-03-30 13:20:48 +000044
45 unsigned long count;
paul718e3742002-12-13 20:15:29 +000046};
47
48struct bgp_node
49{
50 struct prefix p;
51
52 struct bgp_table *table;
53 struct bgp_node *parent;
54 struct bgp_node *link[2];
55#define l_left link[0]
56#define l_right link[1]
57
paul718e3742002-12-13 20:15:29 +000058 void *info;
59
60 struct bgp_adj_out *adj_out;
61
62 struct bgp_adj_in *adj_in;
63
paul718e3742002-12-13 20:15:29 +000064 struct bgp_node *prn;
paul200df112005-06-01 11:17:05 +000065
Chris Caputo228da422009-07-18 05:44:03 +000066 int lock;
Paul Jakmacbdfbaa2006-03-30 13:20:48 +000067
paul200df112005-06-01 11:17:05 +000068 u_char flags;
69#define BGP_NODE_PROCESS_SCHEDULED (1 << 0)
paul718e3742002-12-13 20:15:29 +000070};
71
Paul Jakma64e580a2006-02-21 01:09:01 +000072extern struct bgp_table *bgp_table_init (afi_t, safi_t);
Chris Caputo228da422009-07-18 05:44:03 +000073extern void bgp_table_lock (struct bgp_table *);
74extern void bgp_table_unlock (struct bgp_table *);
Paul Jakmab608d5b2008-07-02 02:12:07 +000075extern void bgp_table_finish (struct bgp_table **);
paul94f2b392005-06-28 12:44:16 +000076extern void bgp_unlock_node (struct bgp_node *node);
Paul Jakma851a1a52008-07-22 19:56:56 +000077extern struct bgp_node *bgp_table_top (const struct bgp_table *const);
paul94f2b392005-06-28 12:44:16 +000078extern struct bgp_node *bgp_route_next (struct bgp_node *);
79extern struct bgp_node *bgp_route_next_until (struct bgp_node *, struct bgp_node *);
Paul Jakma851a1a52008-07-22 19:56:56 +000080extern struct bgp_node *bgp_node_get (struct bgp_table *const, struct prefix *);
81extern struct bgp_node *bgp_node_lookup (const struct bgp_table *const, struct prefix *);
paul94f2b392005-06-28 12:44:16 +000082extern struct bgp_node *bgp_lock_node (struct bgp_node *node);
Paul Jakma851a1a52008-07-22 19:56:56 +000083extern struct bgp_node *bgp_node_match (const struct bgp_table *, struct prefix *);
84extern struct bgp_node *bgp_node_match_ipv4 (const struct bgp_table *,
paul718e3742002-12-13 20:15:29 +000085 struct in_addr *);
86#ifdef HAVE_IPV6
Paul Jakma851a1a52008-07-22 19:56:56 +000087extern struct bgp_node *bgp_node_match_ipv6 (const struct bgp_table *,
paul718e3742002-12-13 20:15:29 +000088 struct in6_addr *);
89#endif /* HAVE_IPV6 */
Paul Jakma851a1a52008-07-22 19:56:56 +000090extern unsigned long bgp_table_count (const struct bgp_table *const);
paul00d252c2005-05-23 14:19:54 +000091#endif /* _QUAGGA_BGP_TABLE_H */