1 /* BGP routing information base
2 Copyright (C) 1996, 97, 98, 2000 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
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
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.
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
21 #ifndef _QUAGGA_BGP_ROUTE_H
22 #define _QUAGGA_BGP_ROUTE_H
24 #include "bgp_table.h"
26 /* Ancillary information to struct bgp_info,
27 * used for uncommonly used data (aggregation, MPLS, etc.)
28 * and lazily allocated to save memory.
32 /* Pointer to dampening structure. */
33 struct bgp_damp_info
*damp_info
;
35 /* This route is suppressed with aggregation. */
38 /* Nexthop reachability check. */
47 /* For linked list. */
48 struct bgp_info
*next
;
49 struct bgp_info
*prev
;
54 /* Attribute structure. */
57 /* Extra information */
58 struct bgp_info_extra
*extra
;
66 /* BGP information status. */
68 #define BGP_INFO_IGP_CHANGED (1 << 0)
69 #define BGP_INFO_DAMPED (1 << 1)
70 #define BGP_INFO_HISTORY (1 << 2)
71 #define BGP_INFO_SELECTED (1 << 3)
72 #define BGP_INFO_VALID (1 << 4)
73 #define BGP_INFO_ATTR_CHANGED (1 << 5)
74 #define BGP_INFO_DMED_CHECK (1 << 6)
75 #define BGP_INFO_DMED_SELECTED (1 << 7)
76 #define BGP_INFO_STALE (1 << 8)
77 #define BGP_INFO_REMOVED (1 << 9)
78 #define BGP_INFO_COUNTED (1 << 10)
80 /* BGP route type. This can be static, RIP, OSPF, BGP etc. */
83 /* When above type is BGP. This sub type specify BGP sub type
86 #define BGP_ROUTE_NORMAL 0
87 #define BGP_ROUTE_STATIC 1
88 #define BGP_ROUTE_AGGREGATE 2
89 #define BGP_ROUTE_REDISTRIBUTE 3
92 /* BGP static route configuration. */
95 /* Backdoor configuration. */
98 /* Import check status. */
105 struct in_addr igpnexthop
;
107 /* BGP redistribute route-map. */
111 struct route_map
*map
;
118 /* Flags which indicate a route is unuseable in some form */
119 #define BGP_INFO_UNUSEABLE \
120 (BGP_INFO_HISTORY|BGP_INFO_DAMPED|BGP_INFO_REMOVED)
121 /* Macro to check BGP information is alive or not. Sadly,
122 * not equivalent to just checking previous, because of the
123 * sense of the additional VALID flag.
125 #define BGP_INFO_HOLDDOWN(BI) \
126 (! CHECK_FLAG ((BI)->flags, BGP_INFO_VALID) \
127 || CHECK_FLAG ((BI)->flags, BGP_INFO_UNUSEABLE))
129 #define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name)
130 #define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist)
131 #define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name)
132 #define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist)
134 #define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name)
135 #define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist)
136 #define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name)
137 #define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist)
139 #define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name)
140 #define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist)
141 #define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name)
142 #define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist)
144 #define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name)
145 #define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map)
146 #define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name)
147 #define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map)
149 #define ROUTE_MAP_IMPORT_NAME(F) ((F)->map[RMAP_IMPORT].name)
150 #define ROUTE_MAP_IMPORT(F) ((F)->map[RMAP_IMPORT].map)
151 #define ROUTE_MAP_EXPORT_NAME(F) ((F)->map[RMAP_EXPORT].name)
152 #define ROUTE_MAP_EXPORT(F) ((F)->map[RMAP_EXPORT].map)
154 #define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
155 #define UNSUPPRESS_MAP(F) ((F)->usmap.map)
158 extern void bgp_route_init (void);
159 extern void bgp_cleanup_routes (void);
160 extern void bgp_announce_route (struct peer
*, afi_t
, safi_t
);
161 extern void bgp_announce_route_all (struct peer
*);
162 extern void bgp_default_originate (struct peer
*, afi_t
, safi_t
, int);
163 extern void bgp_soft_reconfig_in (struct peer
*, afi_t
, safi_t
);
164 extern void bgp_soft_reconfig_rsclient (struct peer
*, afi_t
, safi_t
);
165 extern void bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
);
166 extern void bgp_clear_route (struct peer
*, afi_t
, safi_t
);
167 extern void bgp_clear_route_all (struct peer
*);
168 extern void bgp_clear_adj_in (struct peer
*, afi_t
, safi_t
);
169 extern void bgp_clear_stale_route (struct peer
*, afi_t
, safi_t
);
171 extern struct bgp_info
*bgp_info_lock (struct bgp_info
*);
172 extern struct bgp_info
*bgp_info_unlock (struct bgp_info
*);
173 extern void bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
);
174 extern void bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
);
175 extern struct bgp_info_extra
*bgp_info_extra_get (struct bgp_info
*);
176 extern void bgp_info_set_flag (struct bgp_node
*, struct bgp_info
*, u_int32_t
);
177 extern void bgp_info_unset_flag (struct bgp_node
*, struct bgp_info
*, u_int32_t
);
179 extern int bgp_nlri_sanity_check (struct peer
*, int, u_char
*, bgp_size_t
);
180 extern int bgp_nlri_parse (struct peer
*, struct attr
*, struct bgp_nlri
*);
182 extern int bgp_maximum_prefix_overflow (struct peer
*, afi_t
, safi_t
, int);
184 extern void bgp_redistribute_add (struct prefix
*, struct in_addr
*, u_int32_t
, u_char
);
185 extern void bgp_redistribute_delete (struct prefix
*, u_char
);
186 extern void bgp_redistribute_withdraw (struct bgp
*, afi_t
, int);
188 extern void bgp_static_delete (struct bgp
*);
189 extern void bgp_static_update (struct bgp
*, struct prefix
*, struct bgp_static
*,
191 extern void bgp_static_withdraw (struct bgp
*, struct prefix
*, afi_t
, safi_t
);
193 extern int bgp_static_set_vpnv4 (struct vty
*vty
, const char *,
194 const char *, const char *);
196 extern int bgp_static_unset_vpnv4 (struct vty
*, const char *,
197 const char *, const char *);
199 /* this is primarily for MPLS-VPN */
200 extern int bgp_update (struct peer
*, struct prefix
*, struct attr
*,
201 afi_t
, safi_t
, int, int, struct prefix_rd
*,
203 extern int bgp_withdraw (struct peer
*, struct prefix
*, struct attr
*,
204 afi_t
, safi_t
, int, int, struct prefix_rd
*, u_char
*);
206 /* for bgp_nexthop and bgp_damp */
207 extern void bgp_process (struct bgp
*, struct bgp_node
*, afi_t
, safi_t
);
208 extern int bgp_config_write_network (struct vty
*, struct bgp
*, afi_t
, safi_t
, int *);
209 extern int bgp_config_write_distance (struct vty
*, struct bgp
*);
211 extern void bgp_aggregate_increment (struct bgp
*, struct prefix
*, struct bgp_info
*,
213 extern void bgp_aggregate_decrement (struct bgp
*, struct prefix
*, struct bgp_info
*,
216 extern u_char
bgp_distance_apply (struct prefix
*, struct bgp_info
*, struct bgp
*);
218 extern afi_t
bgp_node_afi (struct vty
*);
219 extern safi_t
bgp_node_safi (struct vty
*);
221 extern void route_vty_out (struct vty
*, struct prefix
*, struct bgp_info
*, int, safi_t
);
222 extern void route_vty_out_tag (struct vty
*, struct prefix
*, struct bgp_info
*, int, safi_t
);
223 extern void route_vty_out_tmp (struct vty
*, struct prefix
*, struct attr
*, safi_t
);
225 #endif /* _QUAGGA_BGP_ROUTE_H */