blob: 8d63e4606f3b92e98f7bd858f7c5a74ab7dffd3f [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing information base
2 Copyright (C) 1996, 97, 98, 2000 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_ROUTE_H
22#define _QUAGGA_BGP_ROUTE_H
23
paul200df112005-06-01 11:17:05 +000024#include "bgp_table.h"
25
paul718e3742002-12-13 20:15:29 +000026struct bgp_info
27{
28 /* For linked list. */
29 struct bgp_info *next;
30 struct bgp_info *prev;
paul200df112005-06-01 11:17:05 +000031
32 /* reference count */
33 unsigned int lock;
34
paul718e3742002-12-13 20:15:29 +000035 /* BGP route type. This can be static, RIP, OSPF, BGP etc. */
36 u_char type;
37
38 /* When above type is BGP. This sub type specify BGP sub type
39 information. */
40 u_char sub_type;
41#define BGP_ROUTE_NORMAL 0
42#define BGP_ROUTE_STATIC 1
43#define BGP_ROUTE_AGGREGATE 2
44#define BGP_ROUTE_REDISTRIBUTE 3
45
46 /* BGP information status. */
hasso93406d82005-02-02 14:40:33 +000047 u_int16_t flags;
paul718e3742002-12-13 20:15:29 +000048#define BGP_INFO_IGP_CHANGED (1 << 0)
49#define BGP_INFO_DAMPED (1 << 1)
50#define BGP_INFO_HISTORY (1 << 2)
51#define BGP_INFO_SELECTED (1 << 3)
52#define BGP_INFO_VALID (1 << 4)
53#define BGP_INFO_ATTR_CHANGED (1 << 5)
54#define BGP_INFO_DMED_CHECK (1 << 6)
55#define BGP_INFO_DMED_SELECTED (1 << 7)
hasso93406d82005-02-02 14:40:33 +000056#define BGP_INFO_STALE (1 << 8)
paul718e3742002-12-13 20:15:29 +000057
58 /* Peer structure. */
59 struct peer *peer;
60
61 /* Attribute structure. */
62 struct attr *attr;
63
64 /* This route is suppressed with aggregation. */
65 int suppress;
66
67 /* Nexthop reachability check. */
68 u_int32_t igpmetric;
69
70 /* Uptime. */
71 time_t uptime;
72
73 /* Pointer to dampening structure. */
74 struct bgp_damp_info *damp_info;
75
76 /* MPLS label. */
77 u_char tag[3];
78};
79
80/* BGP static route configuration. */
81struct bgp_static
82{
83 /* Backdoor configuration. */
84 int backdoor;
85
86 /* Import check status. */
87 u_char valid;
88
89 /* IGP metric. */
90 u_int32_t igpmetric;
91
92 /* IGP nexthop. */
93 struct in_addr igpnexthop;
94
95 /* BGP redistribute route-map. */
96 struct
97 {
98 char *name;
99 struct route_map *map;
100 } rmap;
101
102 /* MPLS label. */
103 u_char tag[3];
104};
105
106#define DISTRIBUTE_IN_NAME(F) ((F)->dlist[FILTER_IN].name)
107#define DISTRIBUTE_IN(F) ((F)->dlist[FILTER_IN].alist)
108#define DISTRIBUTE_OUT_NAME(F) ((F)->dlist[FILTER_OUT].name)
109#define DISTRIBUTE_OUT(F) ((F)->dlist[FILTER_OUT].alist)
110
111#define PREFIX_LIST_IN_NAME(F) ((F)->plist[FILTER_IN].name)
112#define PREFIX_LIST_IN(F) ((F)->plist[FILTER_IN].plist)
113#define PREFIX_LIST_OUT_NAME(F) ((F)->plist[FILTER_OUT].name)
114#define PREFIX_LIST_OUT(F) ((F)->plist[FILTER_OUT].plist)
115
116#define FILTER_LIST_IN_NAME(F) ((F)->aslist[FILTER_IN].name)
117#define FILTER_LIST_IN(F) ((F)->aslist[FILTER_IN].aslist)
118#define FILTER_LIST_OUT_NAME(F) ((F)->aslist[FILTER_OUT].name)
119#define FILTER_LIST_OUT(F) ((F)->aslist[FILTER_OUT].aslist)
120
paulfee0f4c2004-09-13 05:12:46 +0000121#define ROUTE_MAP_IN_NAME(F) ((F)->map[RMAP_IN].name)
122#define ROUTE_MAP_IN(F) ((F)->map[RMAP_IN].map)
123#define ROUTE_MAP_OUT_NAME(F) ((F)->map[RMAP_OUT].name)
124#define ROUTE_MAP_OUT(F) ((F)->map[RMAP_OUT].map)
125
126#define ROUTE_MAP_IMPORT_NAME(F) ((F)->map[RMAP_IMPORT].name)
127#define ROUTE_MAP_IMPORT(F) ((F)->map[RMAP_IMPORT].map)
128#define ROUTE_MAP_EXPORT_NAME(F) ((F)->map[RMAP_EXPORT].name)
129#define ROUTE_MAP_EXPORT(F) ((F)->map[RMAP_EXPORT].map)
paul718e3742002-12-13 20:15:29 +0000130
131#define UNSUPPRESS_MAP_NAME(F) ((F)->usmap.name)
132#define UNSUPPRESS_MAP(F) ((F)->usmap.map)
133
134/* Prototypes. */
paul94f2b392005-06-28 12:44:16 +0000135extern void bgp_route_init (void);
136extern void bgp_cleanup_routes (void);
137extern void bgp_announce_route (struct peer *, afi_t, safi_t);
138extern void bgp_announce_route_all (struct peer *);
139extern void bgp_default_originate (struct peer *, afi_t, safi_t, int);
140extern void bgp_soft_reconfig_in (struct peer *, afi_t, safi_t);
141extern void bgp_soft_reconfig_rsclient (struct peer *, afi_t, safi_t);
142extern void bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi);
143extern void bgp_clear_route (struct peer *, afi_t, safi_t);
144extern void bgp_clear_route_all (struct peer *);
145extern void bgp_clear_adj_in (struct peer *, afi_t, safi_t);
146extern void bgp_clear_stale_route (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000147
paul200df112005-06-01 11:17:05 +0000148extern struct bgp_info *bgp_info_lock (struct bgp_info *);
149extern struct bgp_info *bgp_info_unlock (struct bgp_info *);
150extern void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri);
151extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri);
152
paul94f2b392005-06-28 12:44:16 +0000153extern int bgp_nlri_sanity_check (struct peer *, int, u_char *, bgp_size_t);
154extern int bgp_nlri_parse (struct peer *, struct attr *, struct bgp_nlri *);
paul718e3742002-12-13 20:15:29 +0000155
paul94f2b392005-06-28 12:44:16 +0000156extern int bgp_maximum_prefix_overflow (struct peer *, afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000157
paul94f2b392005-06-28 12:44:16 +0000158extern void bgp_redistribute_add (struct prefix *, struct in_addr *, u_int32_t, u_char);
159extern void bgp_redistribute_delete (struct prefix *, u_char);
160extern void bgp_redistribute_withdraw (struct bgp *, afi_t, int);
paul718e3742002-12-13 20:15:29 +0000161
paul94f2b392005-06-28 12:44:16 +0000162extern void bgp_static_delete (struct bgp *);
163extern void bgp_static_update (struct bgp *, struct prefix *, struct bgp_static *,
paul718e3742002-12-13 20:15:29 +0000164 afi_t, safi_t);
paul94f2b392005-06-28 12:44:16 +0000165extern void bgp_static_withdraw (struct bgp *, struct prefix *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000166
paul94f2b392005-06-28 12:44:16 +0000167extern int bgp_static_set_vpnv4 (struct vty *vty, const char *,
paulfd79ac92004-10-13 05:06:08 +0000168 const char *, const char *);
paul718e3742002-12-13 20:15:29 +0000169
paul94f2b392005-06-28 12:44:16 +0000170extern int bgp_static_unset_vpnv4 (struct vty *, const char *,
paulfd79ac92004-10-13 05:06:08 +0000171 const char *, const char *);
paul718e3742002-12-13 20:15:29 +0000172
paul94f2b392005-06-28 12:44:16 +0000173/* this is primarily for MPLS-VPN */
174extern int bgp_update (struct peer *, struct prefix *, struct attr *,
175 afi_t, safi_t, int, int, struct prefix_rd *,
176 u_char *, int);
177extern int bgp_withdraw (struct peer *, struct prefix *, struct attr *,
178 afi_t, safi_t, int, int, struct prefix_rd *, u_char *);
paul718e3742002-12-13 20:15:29 +0000179
paul94f2b392005-06-28 12:44:16 +0000180/* for bgp_nexthop and bgp_damp */
181extern void bgp_process (struct bgp *, struct bgp_node *, afi_t, safi_t);
182
183extern int bgp_config_write_network (struct vty *, struct bgp *, afi_t, safi_t, int *);
184extern int bgp_config_write_distance (struct vty *, struct bgp *);
185
186extern void bgp_aggregate_increment (struct bgp *, struct prefix *, struct bgp_info *,
paul718e3742002-12-13 20:15:29 +0000187 afi_t, safi_t);
paul94f2b392005-06-28 12:44:16 +0000188extern void bgp_aggregate_decrement (struct bgp *, struct prefix *, struct bgp_info *,
paul718e3742002-12-13 20:15:29 +0000189 afi_t, safi_t);
190
paul94f2b392005-06-28 12:44:16 +0000191extern u_char bgp_distance_apply (struct prefix *, struct bgp_info *, struct bgp *);
paul718e3742002-12-13 20:15:29 +0000192
paul94f2b392005-06-28 12:44:16 +0000193extern afi_t bgp_node_afi (struct vty *);
194extern safi_t bgp_node_safi (struct vty *);
ajs5a646652004-11-05 01:25:55 +0000195
paul94f2b392005-06-28 12:44:16 +0000196extern void route_vty_out (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
197extern void route_vty_out_tag (struct vty *, struct prefix *, struct bgp_info *, int, safi_t);
198extern void route_vty_out_tmp (struct vty *, struct prefix *, struct attr *, safi_t);
paul00d252c2005-05-23 14:19:54 +0000199
200#endif /* _QUAGGA_BGP_ROUTE_H */