paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP routing table |
| 2 | Copyright (C) 1998, 2001 Kunihiro Ishiguro |
| 3 | |
| 4 | This file is part of GNU Zebra. |
| 5 | |
| 6 | GNU Zebra 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 |
| 9 | later version. |
| 10 | |
| 11 | GNU Zebra 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. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU Zebra; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 19 | 02111-1307, USA. */ |
| 20 | |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 21 | #ifndef _QUAGGA_BGP_TABLE_H |
| 22 | #define _QUAGGA_BGP_TABLE_H |
| 23 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 24 | typedef enum |
| 25 | { |
| 26 | BGP_TABLE_MAIN, |
| 27 | BGP_TABLE_RSCLIENT, |
| 28 | } bgp_table_t; |
| 29 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 30 | struct bgp_table |
| 31 | { |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 32 | bgp_table_t type; |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 33 | |
| 34 | /* afi/safi of this table */ |
| 35 | afi_t afi; |
| 36 | safi_t safi; |
| 37 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 38 | /* The owner of this 'bgp_table' structure. */ |
| 39 | void *owner; |
| 40 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 41 | struct bgp_node *top; |
Paul Jakma | cbdfbaa | 2006-03-30 13:20:48 +0000 | [diff] [blame] | 42 | |
| 43 | unsigned long count; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct bgp_node |
| 47 | { |
| 48 | struct prefix p; |
| 49 | |
| 50 | struct bgp_table *table; |
| 51 | struct bgp_node *parent; |
| 52 | struct bgp_node *link[2]; |
| 53 | #define l_left link[0] |
| 54 | #define l_right link[1] |
| 55 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 56 | void *info; |
| 57 | |
| 58 | struct bgp_adj_out *adj_out; |
| 59 | |
| 60 | struct bgp_adj_in *adj_in; |
| 61 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 62 | struct bgp_node *prn; |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 63 | |
Paul Jakma | cbdfbaa | 2006-03-30 13:20:48 +0000 | [diff] [blame] | 64 | unsigned int lock; |
| 65 | |
paul | 200df11 | 2005-06-01 11:17:05 +0000 | [diff] [blame] | 66 | u_char flags; |
| 67 | #define BGP_NODE_PROCESS_SCHEDULED (1 << 0) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
Paul Jakma | 64e580a | 2006-02-21 01:09:01 +0000 | [diff] [blame] | 70 | extern struct bgp_table *bgp_table_init (afi_t, safi_t); |
Paul Jakma | b608d5b | 2008-07-02 02:12:07 +0000 | [diff] [blame^] | 71 | extern void bgp_table_finish (struct bgp_table **); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 72 | extern void bgp_unlock_node (struct bgp_node *node); |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 73 | extern struct bgp_node *bgp_table_top (struct bgp_table *); |
| 74 | extern struct bgp_node *bgp_route_next (struct bgp_node *); |
| 75 | extern struct bgp_node *bgp_route_next_until (struct bgp_node *, struct bgp_node *); |
| 76 | extern struct bgp_node *bgp_node_get (struct bgp_table *, struct prefix *); |
| 77 | extern struct bgp_node *bgp_node_lookup (struct bgp_table *, struct prefix *); |
| 78 | extern struct bgp_node *bgp_lock_node (struct bgp_node *node); |
| 79 | extern struct bgp_node *bgp_node_match (struct bgp_table *, struct prefix *); |
| 80 | extern struct bgp_node *bgp_node_match_ipv4 (struct bgp_table *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 81 | struct in_addr *); |
| 82 | #ifdef HAVE_IPV6 |
paul | 94f2b39 | 2005-06-28 12:44:16 +0000 | [diff] [blame] | 83 | extern struct bgp_node *bgp_node_match_ipv6 (struct bgp_table *, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | struct in6_addr *); |
| 85 | #endif /* HAVE_IPV6 */ |
Paul Jakma | cbdfbaa | 2006-03-30 13:20:48 +0000 | [diff] [blame] | 86 | extern unsigned long bgp_table_count (struct bgp_table *); |
paul | 00d252c | 2005-05-23 14:19:54 +0000 | [diff] [blame] | 87 | #endif /* _QUAGGA_BGP_TABLE_H */ |