paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* BGP routing information base |
| 2 | Copyright (C) 1996, 97, 98, 2000 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 | |
| 21 | struct bgp_info |
| 22 | { |
| 23 | /* For linked list. */ |
| 24 | struct bgp_info *next; |
| 25 | struct bgp_info *prev; |
| 26 | |
| 27 | /* BGP route type. This can be static, RIP, OSPF, BGP etc. */ |
| 28 | u_char type; |
| 29 | |
| 30 | /* When above type is BGP. This sub type specify BGP sub type |
| 31 | information. */ |
| 32 | u_char sub_type; |
| 33 | #define BGP_ROUTE_NORMAL 0 |
| 34 | #define BGP_ROUTE_STATIC 1 |
| 35 | #define BGP_ROUTE_AGGREGATE 2 |
| 36 | #define BGP_ROUTE_REDISTRIBUTE 3 |
| 37 | |
| 38 | /* BGP information status. */ |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 39 | u_int16_t flags; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | #define BGP_INFO_IGP_CHANGED (1 << 0) |
| 41 | #define BGP_INFO_DAMPED (1 << 1) |
| 42 | #define BGP_INFO_HISTORY (1 << 2) |
| 43 | #define BGP_INFO_SELECTED (1 << 3) |
| 44 | #define BGP_INFO_VALID (1 << 4) |
| 45 | #define BGP_INFO_ATTR_CHANGED (1 << 5) |
| 46 | #define BGP_INFO_DMED_CHECK (1 << 6) |
| 47 | #define BGP_INFO_DMED_SELECTED (1 << 7) |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 48 | #define BGP_INFO_STALE (1 << 8) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 49 | |
| 50 | /* Peer structure. */ |
| 51 | struct peer *peer; |
| 52 | |
| 53 | /* Attribute structure. */ |
| 54 | struct attr *attr; |
| 55 | |
| 56 | /* This route is suppressed with aggregation. */ |
| 57 | int suppress; |
| 58 | |
| 59 | /* Nexthop reachability check. */ |
| 60 | u_int32_t igpmetric; |
| 61 | |
| 62 | /* Uptime. */ |
| 63 | time_t uptime; |
| 64 | |
| 65 | /* Pointer to dampening structure. */ |
| 66 | struct bgp_damp_info *damp_info; |
| 67 | |
| 68 | /* MPLS label. */ |
| 69 | u_char tag[3]; |
| 70 | }; |
| 71 | |
| 72 | /* BGP static route configuration. */ |
| 73 | struct bgp_static |
| 74 | { |
| 75 | /* Backdoor configuration. */ |
| 76 | int backdoor; |
| 77 | |
| 78 | /* Import check status. */ |
| 79 | u_char valid; |
| 80 | |
| 81 | /* IGP metric. */ |
| 82 | u_int32_t igpmetric; |
| 83 | |
| 84 | /* IGP nexthop. */ |
| 85 | struct in_addr igpnexthop; |
| 86 | |
| 87 | /* BGP redistribute route-map. */ |
| 88 | struct |
| 89 | { |
| 90 | char *name; |
| 91 | struct route_map *map; |
| 92 | } rmap; |
| 93 | |
| 94 | /* MPLS label. */ |
| 95 | u_char tag[3]; |
| 96 | }; |
| 97 | |
| 98 | #define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name) |
| 99 | #define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist) |
| 100 | #define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name) |
| 101 | #define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist) |
| 102 | |
| 103 | #define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name) |
| 104 | #define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist) |
| 105 | #define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name) |
| 106 | #define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist) |
| 107 | |
| 108 | #define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name) |
| 109 | #define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist) |
| 110 | #define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name) |
| 111 | #define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist) |
| 112 | |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 113 | #define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name) |
| 114 | #define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map) |
| 115 | #define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name) |
| 116 | #define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map) |
| 117 | |
| 118 | #define ROUTE_MAP_IMPORT_NAME(F) ((F)->map[RMAP_IMPORT].name) |
| 119 | #define ROUTE_MAP_IMPORT(F) ((F)->map[RMAP_IMPORT].map) |
| 120 | #define ROUTE_MAP_EXPORT_NAME(F) ((F)->map[RMAP_EXPORT].name) |
| 121 | #define ROUTE_MAP_EXPORT(F) ((F)->map[RMAP_EXPORT].map) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 122 | |
| 123 | #define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name) |
| 124 | #define UNSUPPRESS_MAP(F) ((F)->usmap.map) |
| 125 | |
| 126 | /* Prototypes. */ |
| 127 | void bgp_route_init (); |
paul | 545acaf | 2004-04-20 15:13:15 +0000 | [diff] [blame] | 128 | void bgp_cleanup_routes (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 129 | void bgp_announce_route (struct peer *, afi_t, safi_t); |
| 130 | void bgp_announce_route_all (struct peer *); |
| 131 | void bgp_default_originate (struct peer *, afi_t, safi_t, int); |
| 132 | void bgp_soft_reconfig_in (struct peer *, afi_t, safi_t); |
paul | fee0f4c | 2004-09-13 05:12:46 +0000 | [diff] [blame] | 133 | void bgp_soft_reconfig_rsclient (struct peer *, afi_t, safi_t); |
| 134 | void bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 135 | void bgp_clear_route (struct peer *, afi_t, safi_t); |
| 136 | void bgp_clear_route_all (struct peer *); |
| 137 | void bgp_clear_adj_in (struct peer *, afi_t, safi_t); |
hasso | 93406d8 | 2005-02-02 14:40:33 +0000 | [diff] [blame] | 138 | void bgp_clear_stale_route (struct peer *, afi_t, safi_t); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 139 | |
| 140 | int bgp_nlri_sanity_check (struct peer *, int, u_char *, bgp_size_t); |
| 141 | int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *); |
| 142 | |
hasso | e0701b7 | 2004-05-20 09:19:34 +0000 | [diff] [blame] | 143 | int bgp_maximum_prefix_overflow (struct peer *, afi_t, safi_t, int); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 144 | |
| 145 | void bgp_redistribute_add (struct prefix *, struct in_addr *, u_int32_t, u_char); |
| 146 | void bgp_redistribute_delete (struct prefix *, u_char); |
| 147 | void bgp_redistribute_withdraw (struct bgp *, afi_t, int); |
| 148 | |
| 149 | void bgp_static_delete (struct bgp *); |
| 150 | void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static *, |
| 151 | afi_t, safi_t); |
| 152 | void bgp_static_withdraw (struct bgp *, struct prefix *, afi_t, safi_t); |
| 153 | |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 154 | int bgp_static_set_vpnv4 (struct vty *vty, const char *, |
| 155 | const char *, const char *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 156 | |
paul | fd79ac9 | 2004-10-13 05:06:08 +0000 | [diff] [blame] | 157 | int bgp_static_unset_vpnv4 (struct vty *, const char *, |
| 158 | const char *, const char *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | |
| 160 | int bgp_config_write_network (struct vty *, struct bgp *, afi_t, safi_t, int *); |
| 161 | int bgp_config_write_distance (struct vty *, struct bgp *); |
| 162 | |
| 163 | void bgp_aggregate_increment (struct bgp *, struct prefix *, struct bgp_info *, |
| 164 | afi_t, safi_t); |
| 165 | void bgp_aggregate_decrement (struct bgp *, struct prefix *, struct bgp_info *, |
| 166 | afi_t, safi_t); |
| 167 | |
| 168 | u_char bgp_distance_apply (struct prefix *, struct bgp_info *, struct bgp *); |
| 169 | |
| 170 | afi_t bgp_node_afi (struct vty *); |
| 171 | safi_t bgp_node_safi (struct vty *); |
ajs | 5a64665 | 2004-11-05 01:25:55 +0000 | [diff] [blame] | 172 | |
| 173 | void route_vty_out (struct vty *, struct prefix *, struct bgp_info *, int, safi_t); |
| 174 | void route_vty_out_tag (struct vty *, struct prefix *, struct bgp_info *, int, safi_t); |
| 175 | void route_vty_out_tmp (struct vty *, struct prefix *, struct attr *, safi_t); |