blob: 2c4fb2096c256466e1dadd8ad0fc226927218206 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP message definition header.
2 Copyright (C) 1996, 97, 98, 99, 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_BGPD_H
22#define _QUAGGA_BGPD_H
23
paul718e3742002-12-13 20:15:29 +000024/* For union sockunion. */
25#include "sockunion.h"
26
27/* Typedef BGP specific types. */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +000028typedef u_int32_t as_t;
29typedef u_int16_t as16_t; /* we may still encounter 16 Bit asnums */
paul718e3742002-12-13 20:15:29 +000030typedef u_int16_t bgp_size_t;
31
32/* BGP master for system wide configurations and variables. */
33struct bgp_master
34{
35 /* BGP instance list. */
36 struct list *bgp;
37
38 /* BGP thread master. */
39 struct thread_master *master;
40
paul200df112005-06-01 11:17:05 +000041 /* work queues */
42 struct work_queue *process_main_queue;
43 struct work_queue *process_rsclient_queue;
paul200df112005-06-01 11:17:05 +000044
Paul Jakma0df7c912008-07-21 21:02:49 +000045 /* Listening sockets */
46 struct list *listen_sockets;
47
paul718e3742002-12-13 20:15:29 +000048 /* BGP port number. */
49 u_int16_t port;
50
Paul Jakma3a02d1f2007-11-01 14:29:11 +000051 /* Listener address */
52 char *address;
53
paul718e3742002-12-13 20:15:29 +000054 /* BGP start time. */
55 time_t start_time;
56
57 /* Various BGP global configuration. */
58 u_char options;
59#define BGP_OPT_NO_FIB (1 << 0)
60#define BGP_OPT_MULTIPLE_INSTANCE (1 << 1)
61#define BGP_OPT_CONFIG_CISCO (1 << 2)
Paul Jakmacccbc012012-06-14 10:40:26 +010062#define BGP_OPT_NO_LISTEN (1 << 3)
paul718e3742002-12-13 20:15:29 +000063};
64
65/* BGP instance structure. */
66struct bgp
67{
68 /* AS number of this BGP instance. */
69 as_t as;
70
71 /* Name of this BGP instance. */
72 char *name;
paul200df112005-06-01 11:17:05 +000073
Stephen Hemminger0088b5d2009-05-21 08:51:03 -070074 /* Reference count to allow peer_delete to finish after bgp_delete */
75 int lock;
76
paul718e3742002-12-13 20:15:29 +000077 /* Self peer. */
78 struct peer *peer_self;
79
80 /* BGP peer. */
81 struct list *peer;
82
83 /* BGP peer group. */
84 struct list *group;
85
paulfee0f4c2004-09-13 05:12:46 +000086 /* BGP route-server-clients. */
87 struct list *rsclient;
88
paul718e3742002-12-13 20:15:29 +000089 /* BGP configuration. */
90 u_int16_t config;
91#define BGP_CONFIG_ROUTER_ID (1 << 0)
92#define BGP_CONFIG_CLUSTER_ID (1 << 1)
93#define BGP_CONFIG_CONFEDERATION (1 << 2)
paul718e3742002-12-13 20:15:29 +000094
95 /* BGP router identifier. */
96 struct in_addr router_id;
hasso18a6dce2004-10-03 18:18:34 +000097 struct in_addr router_id_static;
paul718e3742002-12-13 20:15:29 +000098
99 /* BGP route reflector cluster ID. */
100 struct in_addr cluster_id;
101
102 /* BGP confederation information. */
103 as_t confed_id;
104 as_t *confed_peers;
105 int confed_peers_cnt;
106
Vipin Kumardd49eb12014-09-30 14:36:38 -0700107 struct thread *t_startup;
108
paul718e3742002-12-13 20:15:29 +0000109 /* BGP flags. */
110 u_int16_t flags;
111#define BGP_FLAG_ALWAYS_COMPARE_MED (1 << 0)
112#define BGP_FLAG_DETERMINISTIC_MED (1 << 1)
113#define BGP_FLAG_MED_MISSING_AS_WORST (1 << 2)
114#define BGP_FLAG_MED_CONFED (1 << 3)
115#define BGP_FLAG_NO_DEFAULT_IPV4 (1 << 4)
116#define BGP_FLAG_NO_CLIENT_TO_CLIENT (1 << 5)
117#define BGP_FLAG_ENFORCE_FIRST_AS (1 << 6)
118#define BGP_FLAG_COMPARE_ROUTER_ID (1 << 7)
119#define BGP_FLAG_ASPATH_IGNORE (1 << 8)
120#define BGP_FLAG_IMPORT_CHECK (1 << 9)
121#define BGP_FLAG_NO_FAST_EXT_FAILOVER (1 << 10)
paul848973c2003-08-13 00:32:49 +0000122#define BGP_FLAG_LOG_NEIGHBOR_CHANGES (1 << 11)
hasso538621f2004-05-21 09:31:30 +0000123#define BGP_FLAG_GRACEFUL_RESTART (1 << 12)
hasso68118452005-04-08 15:40:36 +0000124#define BGP_FLAG_ASPATH_CONFED (1 << 13)
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000125#define BGP_FLAG_ASPATH_MULTIPATH_RELAX (1 << 14)
paul718e3742002-12-13 20:15:29 +0000126
127 /* BGP Per AF flags */
128 u_int16_t af_flags[AFI_MAX][SAFI_MAX];
129#define BGP_CONFIG_DAMPENING (1 << 0)
130
131 /* Static route configuration. */
132 struct bgp_table *route[AFI_MAX][SAFI_MAX];
133
134 /* Aggregate address configuration. */
135 struct bgp_table *aggregate[AFI_MAX][SAFI_MAX];
136
137 /* BGP routing information base. */
138 struct bgp_table *rib[AFI_MAX][SAFI_MAX];
139
140 /* BGP redistribute configuration. */
141 u_char redist[AFI_MAX][ZEBRA_ROUTE_MAX];
142
143 /* BGP redistribute metric configuration. */
144 u_char redist_metric_flag[AFI_MAX][ZEBRA_ROUTE_MAX];
145 u_int32_t redist_metric[AFI_MAX][ZEBRA_ROUTE_MAX];
146
147 /* BGP redistribute route-map. */
148 struct
149 {
150 char *name;
151 struct route_map *map;
152 } rmap[AFI_MAX][ZEBRA_ROUTE_MAX];
153
154 /* BGP distance configuration. */
155 u_char distance_ebgp;
156 u_char distance_ibgp;
157 u_char distance_local;
158
159 /* BGP default local-preference. */
160 u_int32_t default_local_pref;
161
162 /* BGP default timer. */
163 u_int32_t default_holdtime;
164 u_int32_t default_keepalive;
hasso538621f2004-05-21 09:31:30 +0000165
166 /* BGP graceful restart */
hasso93406d82005-02-02 14:40:33 +0000167 u_int32_t restart_time;
168 u_int32_t stalepath_time;
Josh Bailey165b5ff2011-07-20 20:43:22 -0700169
170 /* Maximum-paths configuration */
171 struct bgp_maxpaths_cfg {
172 u_int16_t maxpaths_ebgp;
173 u_int16_t maxpaths_ibgp;
174 } maxpaths[AFI_MAX][SAFI_MAX];
paul718e3742002-12-13 20:15:29 +0000175};
176
177/* BGP peer-group support. */
178struct peer_group
179{
180 /* Name of the peer-group. */
181 char *name;
182
183 /* Pointer to BGP. */
184 struct bgp *bgp;
185
186 /* Peer-group client list. */
187 struct list *peer;
188
189 /* Peer-group config */
190 struct peer *conf;
191};
192
193/* BGP Notify message format. */
194struct bgp_notify
195{
196 u_char code;
197 u_char subcode;
198 char *data;
199 bgp_size_t length;
200};
201
202/* Next hop self address. */
203struct bgp_nexthop
204{
205 struct interface *ifp;
206 struct in_addr v4;
207#ifdef HAVE_IPV6
208 struct in6_addr v6_global;
209 struct in6_addr v6_local;
210#endif /* HAVE_IPV6 */
211};
212
213/* BGP router distinguisher value. */
214#define BGP_RD_SIZE 8
215
216struct bgp_rd
217{
218 u_char val[BGP_RD_SIZE];
219};
220
paulfee0f4c2004-09-13 05:12:46 +0000221#define RMAP_IN 0
222#define RMAP_OUT 1
223#define RMAP_IMPORT 2
224#define RMAP_EXPORT 3
225#define RMAP_MAX 4
226
paul718e3742002-12-13 20:15:29 +0000227/* BGP filter structure. */
228struct bgp_filter
229{
230 /* Distribute-list. */
231 struct
232 {
233 char *name;
234 struct access_list *alist;
235 } dlist[FILTER_MAX];
236
237 /* Prefix-list. */
238 struct
239 {
240 char *name;
241 struct prefix_list *plist;
242 } plist[FILTER_MAX];
243
244 /* Filter-list. */
245 struct
246 {
247 char *name;
248 struct as_list *aslist;
249 } aslist[FILTER_MAX];
250
251 /* Route-map. */
252 struct
253 {
254 char *name;
255 struct route_map *map;
paulfee0f4c2004-09-13 05:12:46 +0000256 } map[RMAP_MAX];
paul718e3742002-12-13 20:15:29 +0000257
258 /* Unsuppress-map. */
259 struct
260 {
261 char *name;
262 struct route_map *map;
263 } usmap;
264};
265
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000266/* IBGP/EBGP identifier. We also have a CONFED peer, which is to say,
267 a peer who's AS is part of our Confederation. */
268typedef enum
269{
270 BGP_PEER_IBGP = 1,
271 BGP_PEER_EBGP,
272 BGP_PEER_INTERNAL,
273 BGP_PEER_CONFED,
274} bgp_peer_sort_t;
275
paul718e3742002-12-13 20:15:29 +0000276/* BGP neighbor structure. */
277struct peer
278{
279 /* BGP structure. */
280 struct bgp *bgp;
281
paul200df112005-06-01 11:17:05 +0000282 /* reference count, primarily to allow bgp_process'ing of route_node's
283 * to be done after a struct peer is deleted.
284 *
285 * named 'lock' for hysterical reasons within Quagga.
286 */
287 int lock;
288
paul718e3742002-12-13 20:15:29 +0000289 /* BGP peer group. */
290 struct peer_group *group;
291 u_char af_group[AFI_MAX][SAFI_MAX];
292
293 /* Peer's remote AS number. */
294 as_t as;
295
296 /* Peer's local AS number. */
297 as_t local_as;
298
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000299 bgp_peer_sort_t sort;
300
paul718e3742002-12-13 20:15:29 +0000301 /* Peer's Change local AS number. */
302 as_t change_local_as;
303
304 /* Remote router ID. */
305 struct in_addr remote_id;
306
307 /* Local router ID. */
308 struct in_addr local_id;
309
paulfee0f4c2004-09-13 05:12:46 +0000310 /* Peer specific RIB when configured as route-server-client. */
311 struct bgp_table *rib[AFI_MAX][SAFI_MAX];
312
paul718e3742002-12-13 20:15:29 +0000313 /* Packet receive and send buffer. */
314 struct stream *ibuf;
315 struct stream_fifo *obuf;
316 struct stream *work;
317
Pradosh Mohapatra8c71e482014-01-15 06:57:57 +0000318 /* We use a separate stream to encode MP_REACH_NLRI for efficient
319 * NLRI packing. peer->work stores all the other attributes. The
320 * actual packet is then constructed by concatenating the two.
321 */
322 struct stream *scratch;
323
paul718e3742002-12-13 20:15:29 +0000324 /* Status of the peer. */
325 int status;
326 int ostatus;
327
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000328 /* Peer index, used for dumping TABLE_DUMP_V2 format */
329 uint16_t table_dump_index;
330
paul718e3742002-12-13 20:15:29 +0000331 /* Peer information */
pauleb821182004-05-01 08:44:08 +0000332 int fd; /* File descriptor */
333 int ttl; /* TTL of TCP connection to the peer. */
Timo Teräsef757702015-04-29 09:43:04 +0300334 int rtt; /* Estimated round-trip-time from TCP_INFO */
Nick Hilliardfa411a22011-03-23 15:33:17 +0000335 int gtsm_hops; /* minimum hopcount to peer */
pauleb821182004-05-01 08:44:08 +0000336 char *desc; /* Description of the peer. */
337 unsigned short port; /* Destination port for peer */
338 char *host; /* Printable address of the peer. */
339 union sockunion su; /* Sockunion address of the peer. */
340 time_t uptime; /* Last Up/Down time */
341 time_t readtime; /* Last read time */
342 time_t resettime; /* Last reset time */
paul718e3742002-12-13 20:15:29 +0000343
pauleb821182004-05-01 08:44:08 +0000344 unsigned int ifindex; /* ifindex of the BGP connection. */
345 char *ifname; /* bind interface name. */
346 char *update_if;
347 union sockunion *update_source;
348 struct zlog *log;
paul718e3742002-12-13 20:15:29 +0000349
pauleb821182004-05-01 08:44:08 +0000350 union sockunion *su_local; /* Sockunion of local address. */
351 union sockunion *su_remote; /* Sockunion of remote address. */
352 int shared_network; /* Is this peer shared same network. */
353 struct bgp_nexthop nexthop; /* Nexthop */
paul718e3742002-12-13 20:15:29 +0000354
355 /* Peer address family configuration. */
356 u_char afc[AFI_MAX][SAFI_MAX];
357 u_char afc_nego[AFI_MAX][SAFI_MAX];
358 u_char afc_adv[AFI_MAX][SAFI_MAX];
359 u_char afc_recv[AFI_MAX][SAFI_MAX];
360
hasso0a486e52005-02-01 20:57:17 +0000361 /* Capability flags (reset in bgp_stop) */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000362 u_int16_t cap;
paul718e3742002-12-13 20:15:29 +0000363#define PEER_CAP_REFRESH_ADV (1 << 0) /* refresh advertised */
364#define PEER_CAP_REFRESH_OLD_RCV (1 << 1) /* refresh old received */
365#define PEER_CAP_REFRESH_NEW_RCV (1 << 2) /* refresh rfc received */
366#define PEER_CAP_DYNAMIC_ADV (1 << 3) /* dynamic advertised */
367#define PEER_CAP_DYNAMIC_RCV (1 << 4) /* dynamic received */
hasso538621f2004-05-21 09:31:30 +0000368#define PEER_CAP_RESTART_ADV (1 << 5) /* restart advertised */
369#define PEER_CAP_RESTART_RCV (1 << 6) /* restart received */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000370#define PEER_CAP_AS4_ADV (1 << 7) /* as4 advertised */
371#define PEER_CAP_AS4_RCV (1 << 8) /* as4 received */
Vipin Kumardd49eb12014-09-30 14:36:38 -0700372#define PEER_CAP_RESTART_BIT_ADV (1 << 9) /* sent restart state */
373#define PEER_CAP_RESTART_BIT_RCV (1 << 10) /* peer restart state */
paul718e3742002-12-13 20:15:29 +0000374
hasso0a486e52005-02-01 20:57:17 +0000375 /* Capability flags (reset in bgp_stop) */
paul718e3742002-12-13 20:15:29 +0000376 u_int16_t af_cap[AFI_MAX][SAFI_MAX];
377#define PEER_CAP_ORF_PREFIX_SM_ADV (1 << 0) /* send-mode advertised */
378#define PEER_CAP_ORF_PREFIX_RM_ADV (1 << 1) /* receive-mode advertised */
379#define PEER_CAP_ORF_PREFIX_SM_RCV (1 << 2) /* send-mode received */
380#define PEER_CAP_ORF_PREFIX_RM_RCV (1 << 3) /* receive-mode received */
381#define PEER_CAP_ORF_PREFIX_SM_OLD_RCV (1 << 4) /* send-mode received */
382#define PEER_CAP_ORF_PREFIX_RM_OLD_RCV (1 << 5) /* receive-mode received */
hasso93406d82005-02-02 14:40:33 +0000383#define PEER_CAP_RESTART_AF_RCV (1 << 6) /* graceful restart afi/safi received */
384#define PEER_CAP_RESTART_AF_PRESERVE_RCV (1 << 7) /* graceful restart afi/safi F-bit received */
paul718e3742002-12-13 20:15:29 +0000385
386 /* Global configuration flags. */
387 u_int32_t flags;
388#define PEER_FLAG_PASSIVE (1 << 0) /* passive mode */
389#define PEER_FLAG_SHUTDOWN (1 << 1) /* shutdown */
390#define PEER_FLAG_DONT_CAPABILITY (1 << 2) /* dont-capability */
391#define PEER_FLAG_OVERRIDE_CAPABILITY (1 << 3) /* override-capability */
392#define PEER_FLAG_STRICT_CAP_MATCH (1 << 4) /* strict-match */
hassoc9502432005-02-01 22:01:48 +0000393#define PEER_FLAG_DYNAMIC_CAPABILITY (1 << 5) /* dynamic capability */
hasso6ffd2072005-02-02 14:50:11 +0000394#define PEER_FLAG_DISABLE_CONNECTED_CHECK (1 << 6) /* disable-connected-check */
hassoc9502432005-02-01 22:01:48 +0000395#define PEER_FLAG_LOCAL_AS_NO_PREPEND (1 << 7) /* local-as no-prepend */
Andrew Certain9d3f9702012-11-07 23:50:07 +0000396#define PEER_FLAG_LOCAL_AS_REPLACE_AS (1 << 8) /* local-as no-prepend replace-as */
paul718e3742002-12-13 20:15:29 +0000397
hasso93406d82005-02-02 14:40:33 +0000398 /* NSF mode (graceful restart) */
399 u_char nsf[AFI_MAX][SAFI_MAX];
400
paul718e3742002-12-13 20:15:29 +0000401 /* Per AF configuration flags. */
402 u_int32_t af_flags[AFI_MAX][SAFI_MAX];
403#define PEER_FLAG_SEND_COMMUNITY (1 << 0) /* send-community */
404#define PEER_FLAG_SEND_EXT_COMMUNITY (1 << 1) /* send-community ext. */
405#define PEER_FLAG_NEXTHOP_SELF (1 << 2) /* next-hop-self */
406#define PEER_FLAG_REFLECTOR_CLIENT (1 << 3) /* reflector-client */
407#define PEER_FLAG_RSERVER_CLIENT (1 << 4) /* route-server-client */
408#define PEER_FLAG_SOFT_RECONFIG (1 << 5) /* soft-reconfiguration */
409#define PEER_FLAG_AS_PATH_UNCHANGED (1 << 6) /* transparent-as */
410#define PEER_FLAG_NEXTHOP_UNCHANGED (1 << 7) /* transparent-next-hop */
411#define PEER_FLAG_MED_UNCHANGED (1 << 8) /* transparent-next-hop */
412#define PEER_FLAG_DEFAULT_ORIGINATE (1 << 9) /* default-originate */
413#define PEER_FLAG_REMOVE_PRIVATE_AS (1 << 10) /* remove-private-as */
414#define PEER_FLAG_ALLOWAS_IN (1 << 11) /* set allowas-in */
415#define PEER_FLAG_ORF_PREFIX_SM (1 << 12) /* orf capability send-mode */
416#define PEER_FLAG_ORF_PREFIX_RM (1 << 13) /* orf capability receive-mode */
417#define PEER_FLAG_MAX_PREFIX (1 << 14) /* maximum prefix */
418#define PEER_FLAG_MAX_PREFIX_WARNING (1 << 15) /* maximum prefix warning-only */
Paul Jakma0df7c912008-07-21 21:02:49 +0000419#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300420#define PEER_FLAG_NEXTHOP_SELF_ALL (1 << 17) /* next-hop-self all */
Paul Jakma0df7c912008-07-21 21:02:49 +0000421
422 /* MD5 password */
423 char *password;
paul718e3742002-12-13 20:15:29 +0000424
425 /* default-originate route-map. */
426 struct
427 {
428 char *name;
429 struct route_map *map;
430 } default_rmap[AFI_MAX][SAFI_MAX];
431
432 /* Peer status flags. */
433 u_int16_t sflags;
434#define PEER_STATUS_ACCEPT_PEER (1 << 0) /* accept peer */
435#define PEER_STATUS_PREFIX_OVERFLOW (1 << 1) /* prefix-overflow */
436#define PEER_STATUS_CAPABILITY_OPEN (1 << 2) /* capability open send */
437#define PEER_STATUS_HAVE_ACCEPT (1 << 3) /* accept peer's parent */
438#define PEER_STATUS_GROUP (1 << 4) /* peer-group conf */
hasso93406d82005-02-02 14:40:33 +0000439#define PEER_STATUS_NSF_MODE (1 << 5) /* NSF aware peer */
440#define PEER_STATUS_NSF_WAIT (1 << 6) /* wait comeback peer */
paul718e3742002-12-13 20:15:29 +0000441
hasso0a486e52005-02-01 20:57:17 +0000442 /* Peer status af flags (reset in bgp_stop) */
paul718e3742002-12-13 20:15:29 +0000443 u_int16_t af_sflags[AFI_MAX][SAFI_MAX];
444#define PEER_STATUS_ORF_PREFIX_SEND (1 << 0) /* prefix-list send peer */
445#define PEER_STATUS_ORF_WAIT_REFRESH (1 << 1) /* wait refresh received peer */
446#define PEER_STATUS_DEFAULT_ORIGINATE (1 << 2) /* default-originate peer */
hassoe0701b72004-05-20 09:19:34 +0000447#define PEER_STATUS_PREFIX_THRESHOLD (1 << 3) /* exceed prefix-threshold */
448#define PEER_STATUS_PREFIX_LIMIT (1 << 4) /* exceed prefix-limit */
hasso93406d82005-02-02 14:40:33 +0000449#define PEER_STATUS_EOR_SEND (1 << 5) /* end-of-rib send to peer */
450#define PEER_STATUS_EOR_RECEIVED (1 << 6) /* end-of-rib received from peer */
hassoe0701b72004-05-20 09:19:34 +0000451
paul718e3742002-12-13 20:15:29 +0000452 /* Default attribute value for the peer. */
453 u_int32_t config;
454#define PEER_CONFIG_WEIGHT (1 << 0) /* Default weight. */
455#define PEER_CONFIG_TIMER (1 << 1) /* keepalive & holdtime */
456#define PEER_CONFIG_CONNECT (1 << 2) /* connect */
457#define PEER_CONFIG_ROUTEADV (1 << 3) /* route advertise */
458 u_int32_t weight;
459 u_int32_t holdtime;
460 u_int32_t keepalive;
461 u_int32_t connect;
462 u_int32_t routeadv;
463
464 /* Timer values. */
465 u_int32_t v_start;
466 u_int32_t v_connect;
467 u_int32_t v_holdtime;
468 u_int32_t v_keepalive;
paul718e3742002-12-13 20:15:29 +0000469 u_int32_t v_routeadv;
hasso0a486e52005-02-01 20:57:17 +0000470 u_int32_t v_pmax_restart;
hasso93406d82005-02-02 14:40:33 +0000471 u_int32_t v_gr_restart;
paul718e3742002-12-13 20:15:29 +0000472
473 /* Threads. */
474 struct thread *t_read;
475 struct thread *t_write;
476 struct thread *t_start;
477 struct thread *t_connect;
478 struct thread *t_holdtime;
479 struct thread *t_keepalive;
paul718e3742002-12-13 20:15:29 +0000480 struct thread *t_routeadv;
hasso0a486e52005-02-01 20:57:17 +0000481 struct thread *t_pmax_restart;
hasso93406d82005-02-02 14:40:33 +0000482 struct thread *t_gr_restart;
483 struct thread *t_gr_stale;
Paul Jakma64e580a2006-02-21 01:09:01 +0000484
485 /* workqueues */
486 struct work_queue *clear_node_queue;
487
paul718e3742002-12-13 20:15:29 +0000488 /* Statistics field */
489 u_int32_t open_in; /* Open message input count */
490 u_int32_t open_out; /* Open message output count */
491 u_int32_t update_in; /* Update message input count */
492 u_int32_t update_out; /* Update message ouput count */
493 time_t update_time; /* Update message received time. */
494 u_int32_t keepalive_in; /* Keepalive input count */
495 u_int32_t keepalive_out; /* Keepalive output count */
496 u_int32_t notify_in; /* Notify input count */
497 u_int32_t notify_out; /* Notify output count */
498 u_int32_t refresh_in; /* Route Refresh input count */
499 u_int32_t refresh_out; /* Route Refresh output count */
500 u_int32_t dynamic_cap_in; /* Dynamic Capability input count. */
501 u_int32_t dynamic_cap_out; /* Dynamic Capability output count. */
502
503 /* BGP state count */
504 u_int32_t established; /* Established */
505 u_int32_t dropped; /* Dropped */
506
507 /* Syncronization list and time. */
508 struct bgp_synchronize *sync[AFI_MAX][SAFI_MAX];
509 time_t synctime;
510
511 /* Send prefix count. */
512 unsigned long scount[AFI_MAX][SAFI_MAX];
513
514 /* Announcement attribute hash. */
515 struct hash *hash[AFI_MAX][SAFI_MAX];
516
517 /* Notify data. */
518 struct bgp_notify notify;
519
520 /* Whole packet size to be read. */
521 unsigned long packet_size;
522
523 /* Filter structure. */
524 struct bgp_filter filter[AFI_MAX][SAFI_MAX];
525
526 /* ORF Prefix-list */
527 struct prefix_list *orf_plist[AFI_MAX][SAFI_MAX];
528
529 /* Prefix count. */
530 unsigned long pcount[AFI_MAX][SAFI_MAX];
531
532 /* Max prefix count. */
533 unsigned long pmax[AFI_MAX][SAFI_MAX];
hassoe0701b72004-05-20 09:19:34 +0000534 u_char pmax_threshold[AFI_MAX][SAFI_MAX];
hasso0a486e52005-02-01 20:57:17 +0000535 u_int16_t pmax_restart[AFI_MAX][SAFI_MAX];
hassoe0701b72004-05-20 09:19:34 +0000536#define MAXIMUM_PREFIX_THRESHOLD_DEFAULT 75
paul718e3742002-12-13 20:15:29 +0000537
538 /* allowas-in. */
539 char allowas_in[AFI_MAX][SAFI_MAX];
paulac41b2a2003-08-12 05:32:27 +0000540
hassoe0701b72004-05-20 09:19:34 +0000541 /* peer reset cause */
542 char last_reset;
543#define PEER_DOWN_RID_CHANGE 1 /* bgp router-id command */
544#define PEER_DOWN_REMOTE_AS_CHANGE 2 /* neighbor remote-as command */
545#define PEER_DOWN_LOCAL_AS_CHANGE 3 /* neighbor local-as command */
546#define PEER_DOWN_CLID_CHANGE 4 /* bgp cluster-id command */
547#define PEER_DOWN_CONFED_ID_CHANGE 5 /* bgp confederation identifier command */
548#define PEER_DOWN_CONFED_PEER_CHANGE 6 /* bgp confederation peer command */
549#define PEER_DOWN_RR_CLIENT_CHANGE 7 /* neighbor route-reflector-client command */
550#define PEER_DOWN_RS_CLIENT_CHANGE 8 /* neighbor route-server-client command */
551#define PEER_DOWN_UPDATE_SOURCE_CHANGE 9 /* neighbor update-source command */
552#define PEER_DOWN_AF_ACTIVATE 10 /* neighbor activate command */
553#define PEER_DOWN_USER_SHUTDOWN 11 /* neighbor shutdown command */
554#define PEER_DOWN_USER_RESET 12 /* clear ip bgp command */
555#define PEER_DOWN_NOTIFY_RECEIVED 13 /* notification received */
556#define PEER_DOWN_NOTIFY_SEND 14 /* notification send */
557#define PEER_DOWN_CLOSE_SESSION 15 /* tcp session close */
558#define PEER_DOWN_NEIGHBOR_DELETE 16 /* neghbor delete */
559#define PEER_DOWN_RMAP_BIND 17 /* neghbor peer-group command */
560#define PEER_DOWN_RMAP_UNBIND 18 /* no neighbor peer-group command */
561#define PEER_DOWN_CAPABILITY_CHANGE 19 /* neighbor capability command */
562#define PEER_DOWN_PASSIVE_CHANGE 20 /* neighbor passive command */
563#define PEER_DOWN_MULTIHOP_CHANGE 21 /* neighbor multihop command */
hasso93406d82005-02-02 14:40:33 +0000564#define PEER_DOWN_NSF_CLOSE_SESSION 22 /* NSF tcp session close */
hassoe0701b72004-05-20 09:19:34 +0000565
paulac41b2a2003-08-12 05:32:27 +0000566 /* The kind of route-map Flags.*/
567 u_char rmap_type;
568#define PEER_RMAP_TYPE_IN (1 << 0) /* neighbor route-map in */
569#define PEER_RMAP_TYPE_OUT (1 << 1) /* neighbor route-map out */
570#define PEER_RMAP_TYPE_NETWORK (1 << 2) /* network route-map */
571#define PEER_RMAP_TYPE_REDISTRIBUTE (1 << 3) /* redistribute route-map */
572#define PEER_RMAP_TYPE_DEFAULT (1 << 4) /* default-originate route-map */
573#define PEER_RMAP_TYPE_NOSET (1 << 5) /* not allow to set commands */
paulfee0f4c2004-09-13 05:12:46 +0000574#define PEER_RMAP_TYPE_IMPORT (1 << 6) /* neighbor route-map import */
575#define PEER_RMAP_TYPE_EXPORT (1 << 7) /* neighbor route-map export */
paul718e3742002-12-13 20:15:29 +0000576};
577
Paul Jakma0df7c912008-07-21 21:02:49 +0000578#define PEER_PASSWORD_MINLEN (1)
579#define PEER_PASSWORD_MAXLEN (80)
580
paul718e3742002-12-13 20:15:29 +0000581/* This structure's member directly points incoming packet data
582 stream. */
583struct bgp_nlri
584{
585 /* AFI. */
586 afi_t afi;
587
588 /* SAFI. */
589 safi_t safi;
590
591 /* Pointer to NLRI byte stream. */
592 u_char *nlri;
593
594 /* Length of whole NLRI. */
595 bgp_size_t length;
596};
597
598/* BGP versions. */
599#define BGP_VERSION_4 4
paul718e3742002-12-13 20:15:29 +0000600
601/* Default BGP port number. */
602#define BGP_PORT_DEFAULT 179
603
604/* BGP message header and packet size. */
605#define BGP_MARKER_SIZE 16
606#define BGP_HEADER_SIZE 19
607#define BGP_MAX_PACKET_SIZE 4096
608
609/* BGP minimum message size. */
610#define BGP_MSG_OPEN_MIN_SIZE (BGP_HEADER_SIZE + 10)
611#define BGP_MSG_UPDATE_MIN_SIZE (BGP_HEADER_SIZE + 4)
612#define BGP_MSG_NOTIFY_MIN_SIZE (BGP_HEADER_SIZE + 2)
613#define BGP_MSG_KEEPALIVE_MIN_SIZE (BGP_HEADER_SIZE + 0)
614#define BGP_MSG_ROUTE_REFRESH_MIN_SIZE (BGP_HEADER_SIZE + 4)
615#define BGP_MSG_CAPABILITY_MIN_SIZE (BGP_HEADER_SIZE + 3)
616
617/* BGP message types. */
618#define BGP_MSG_OPEN 1
619#define BGP_MSG_UPDATE 2
620#define BGP_MSG_NOTIFY 3
621#define BGP_MSG_KEEPALIVE 4
622#define BGP_MSG_ROUTE_REFRESH_NEW 5
623#define BGP_MSG_CAPABILITY 6
624#define BGP_MSG_ROUTE_REFRESH_OLD 128
625
626/* BGP open optional parameter. */
627#define BGP_OPEN_OPT_AUTH 1
628#define BGP_OPEN_OPT_CAP 2
629
630/* BGP4 attribute type codes. */
631#define BGP_ATTR_ORIGIN 1
632#define BGP_ATTR_AS_PATH 2
633#define BGP_ATTR_NEXT_HOP 3
634#define BGP_ATTR_MULTI_EXIT_DISC 4
635#define BGP_ATTR_LOCAL_PREF 5
636#define BGP_ATTR_ATOMIC_AGGREGATE 6
637#define BGP_ATTR_AGGREGATOR 7
638#define BGP_ATTR_COMMUNITIES 8
639#define BGP_ATTR_ORIGINATOR_ID 9
640#define BGP_ATTR_CLUSTER_LIST 10
641#define BGP_ATTR_DPA 11
642#define BGP_ATTR_ADVERTISER 12
643#define BGP_ATTR_RCID_PATH 13
644#define BGP_ATTR_MP_REACH_NLRI 14
645#define BGP_ATTR_MP_UNREACH_NLRI 15
646#define BGP_ATTR_EXT_COMMUNITIES 16
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000647#define BGP_ATTR_AS4_PATH 17
648#define BGP_ATTR_AS4_AGGREGATOR 18
Paul Jakma41367172007-08-06 15:24:51 +0000649#define BGP_ATTR_AS_PATHLIMIT 21
paul718e3742002-12-13 20:15:29 +0000650
651/* BGP update origin. */
652#define BGP_ORIGIN_IGP 0
653#define BGP_ORIGIN_EGP 1
654#define BGP_ORIGIN_INCOMPLETE 2
655
656/* BGP notify message codes. */
657#define BGP_NOTIFY_HEADER_ERR 1
658#define BGP_NOTIFY_OPEN_ERR 2
659#define BGP_NOTIFY_UPDATE_ERR 3
660#define BGP_NOTIFY_HOLD_ERR 4
661#define BGP_NOTIFY_FSM_ERR 5
662#define BGP_NOTIFY_CEASE 6
663#define BGP_NOTIFY_CAPABILITY_ERR 7
664#define BGP_NOTIFY_MAX 8
665
Dmitrij Tejblum4b4e07d2011-09-21 23:13:22 +0400666#define BGP_NOTIFY_SUBCODE_UNSPECIFIC 0
667
paul718e3742002-12-13 20:15:29 +0000668/* BGP_NOTIFY_HEADER_ERR sub codes. */
669#define BGP_NOTIFY_HEADER_NOT_SYNC 1
670#define BGP_NOTIFY_HEADER_BAD_MESLEN 2
671#define BGP_NOTIFY_HEADER_BAD_MESTYPE 3
672#define BGP_NOTIFY_HEADER_MAX 4
673
674/* BGP_NOTIFY_OPEN_ERR sub codes. */
Paul Jakma68ec4242015-11-25 17:14:34 +0000675#define BGP_NOTIFY_OPEN_UNSPECIFIC 0
paul718e3742002-12-13 20:15:29 +0000676#define BGP_NOTIFY_OPEN_UNSUP_VERSION 1
677#define BGP_NOTIFY_OPEN_BAD_PEER_AS 2
678#define BGP_NOTIFY_OPEN_BAD_BGP_IDENT 3
679#define BGP_NOTIFY_OPEN_UNSUP_PARAM 4
680#define BGP_NOTIFY_OPEN_AUTH_FAILURE 5
681#define BGP_NOTIFY_OPEN_UNACEP_HOLDTIME 6
682#define BGP_NOTIFY_OPEN_UNSUP_CAPBL 7
683#define BGP_NOTIFY_OPEN_MAX 8
684
685/* BGP_NOTIFY_UPDATE_ERR sub codes. */
686#define BGP_NOTIFY_UPDATE_MAL_ATTR 1
687#define BGP_NOTIFY_UPDATE_UNREC_ATTR 2
688#define BGP_NOTIFY_UPDATE_MISS_ATTR 3
689#define BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR 4
690#define BGP_NOTIFY_UPDATE_ATTR_LENG_ERR 5
691#define BGP_NOTIFY_UPDATE_INVAL_ORIGIN 6
692#define BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP 7
693#define BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP 8
694#define BGP_NOTIFY_UPDATE_OPT_ATTR_ERR 9
695#define BGP_NOTIFY_UPDATE_INVAL_NETWORK 10
696#define BGP_NOTIFY_UPDATE_MAL_AS_PATH 11
697#define BGP_NOTIFY_UPDATE_MAX 12
698
Dmitrij Tejblum4b4e07d2011-09-21 23:13:22 +0400699/* BGP_NOTIFY_CEASE sub codes (RFC 4486). */
paul718e3742002-12-13 20:15:29 +0000700#define BGP_NOTIFY_CEASE_MAX_PREFIX 1
701#define BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN 2
702#define BGP_NOTIFY_CEASE_PEER_UNCONFIG 3
703#define BGP_NOTIFY_CEASE_ADMIN_RESET 4
704#define BGP_NOTIFY_CEASE_CONNECT_REJECT 5
705#define BGP_NOTIFY_CEASE_CONFIG_CHANGE 6
paul545acaf2004-04-20 15:13:15 +0000706#define BGP_NOTIFY_CEASE_COLLISION_RESOLUTION 7
707#define BGP_NOTIFY_CEASE_OUT_OF_RESOURCE 8
708#define BGP_NOTIFY_CEASE_MAX 9
paul718e3742002-12-13 20:15:29 +0000709
710/* BGP_NOTIFY_CAPABILITY_ERR sub codes (draft-ietf-idr-dynamic-cap-02). */
711#define BGP_NOTIFY_CAPABILITY_INVALID_ACTION 1
712#define BGP_NOTIFY_CAPABILITY_INVALID_LENGTH 2
713#define BGP_NOTIFY_CAPABILITY_MALFORMED_CODE 3
714#define BGP_NOTIFY_CAPABILITY_MAX 4
715
716/* BGP finite state machine status. */
717#define Idle 1
718#define Connect 2
719#define Active 3
720#define OpenSent 4
721#define OpenConfirm 5
722#define Established 6
Paul Jakmaca058a32006-09-14 02:58:49 +0000723#define Clearing 7
724#define Deleted 8
725#define BGP_STATUS_MAX 9
paul718e3742002-12-13 20:15:29 +0000726
727/* BGP finite state machine events. */
728#define BGP_Start 1
729#define BGP_Stop 2
730#define TCP_connection_open 3
731#define TCP_connection_closed 4
732#define TCP_connection_open_failed 5
733#define TCP_fatal_error 6
734#define ConnectRetry_timer_expired 7
735#define Hold_Timer_expired 8
736#define KeepAlive_timer_expired 9
737#define Receive_OPEN_message 10
738#define Receive_KEEPALIVE_message 11
739#define Receive_UPDATE_message 12
740#define Receive_NOTIFICATION_message 13
Paul Jakmaca058a32006-09-14 02:58:49 +0000741#define Clearing_Completed 14
742#define BGP_EVENTS_MAX 15
paul718e3742002-12-13 20:15:29 +0000743
744/* BGP timers default value. */
745#define BGP_INIT_START_TIMER 5
Daniel Waltonf89b09b2015-10-21 06:42:52 -0700746#define BGP_DEFAULT_HOLDTIME 9
747#define BGP_DEFAULT_KEEPALIVE 3
paul718e3742002-12-13 20:15:29 +0000748#define BGP_DEFAULT_EBGP_ROUTEADV 30
749#define BGP_DEFAULT_IBGP_ROUTEADV 5
750#define BGP_CLEAR_CONNECT_RETRY 20
Daniel Waltonf822ad42015-10-21 06:42:47 -0700751#define BGP_DEFAULT_CONNECT_RETRY 10
paul718e3742002-12-13 20:15:29 +0000752
753/* BGP default local preference. */
754#define BGP_DEFAULT_LOCAL_PREF 100
755
hasso538621f2004-05-21 09:31:30 +0000756/* BGP graceful restart */
757#define BGP_DEFAULT_RESTART_TIME 120
758#define BGP_DEFAULT_STALEPATH_TIME 360
759
Denis Ovsienko42e6d742011-07-14 12:36:19 +0400760/* RFC4364 */
761#define SAFI_MPLS_LABELED_VPN 128
paul718e3742002-12-13 20:15:29 +0000762
763/* Max TTL value. */
764#define TTL_MAX 255
765
766/* BGP uptime string length. */
767#define BGP_UPTIME_LEN 25
768
769/* Default configuration settings for bgpd. */
770#define BGP_VTY_PORT 2605
paul718e3742002-12-13 20:15:29 +0000771#define BGP_DEFAULT_CONFIG "bgpd.conf"
772
773/* Check AS path loop when we send NLRI. */
774/* #define BGP_SEND_ASPATH_CHECK */
775
paul718e3742002-12-13 20:15:29 +0000776/* Flag for peer_clear_soft(). */
777enum bgp_clear_type
778{
779 BGP_CLEAR_SOFT_NONE,
780 BGP_CLEAR_SOFT_OUT,
781 BGP_CLEAR_SOFT_IN,
782 BGP_CLEAR_SOFT_BOTH,
paulfee0f4c2004-09-13 05:12:46 +0000783 BGP_CLEAR_SOFT_IN_ORF_PREFIX,
784 BGP_CLEAR_SOFT_RSCLIENT
paul718e3742002-12-13 20:15:29 +0000785};
786
787/* Macros. */
788#define BGP_INPUT(P) ((P)->ibuf)
789#define BGP_INPUT_PNT(P) (STREAM_PNT(BGP_INPUT(P)))
Vitaliy Senchyshyn6aa136f2013-10-02 10:40:20 +0000790#define BGP_IS_VALID_STATE_FOR_NOTIF(S)\
791 (((S) == OpenSent) || ((S) == OpenConfirm) || ((S) == Established))
paul718e3742002-12-13 20:15:29 +0000792
paul718e3742002-12-13 20:15:29 +0000793/* Count prefix size from mask length */
794#define PSIZE(a) (((a) + 7) / (8))
795
796/* BGP error codes. */
797#define BGP_SUCCESS 0
798#define BGP_ERR_INVALID_VALUE -1
799#define BGP_ERR_INVALID_FLAG -2
800#define BGP_ERR_INVALID_AS -3
801#define BGP_ERR_INVALID_BGP -4
802#define BGP_ERR_PEER_GROUP_MEMBER -5
803#define BGP_ERR_MULTIPLE_INSTANCE_USED -6
804#define BGP_ERR_PEER_GROUP_MEMBER_EXISTS -7
805#define BGP_ERR_PEER_BELONGS_TO_GROUP -8
806#define BGP_ERR_PEER_GROUP_AF_UNCONFIGURED -9
807#define BGP_ERR_PEER_GROUP_NO_REMOTE_AS -10
808#define BGP_ERR_PEER_GROUP_CANT_CHANGE -11
809#define BGP_ERR_PEER_GROUP_MISMATCH -12
810#define BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT -13
811#define BGP_ERR_MULTIPLE_INSTANCE_NOT_SET -14
812#define BGP_ERR_AS_MISMATCH -15
813#define BGP_ERR_PEER_INACTIVE -16
814#define BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER -17
815#define BGP_ERR_PEER_GROUP_HAS_THE_FLAG -18
816#define BGP_ERR_PEER_FLAG_CONFLICT -19
817#define BGP_ERR_PEER_GROUP_SHUTDOWN -20
818#define BGP_ERR_PEER_FILTER_CONFLICT -21
819#define BGP_ERR_NOT_INTERNAL_PEER -22
820#define BGP_ERR_REMOVE_PRIVATE_AS -23
821#define BGP_ERR_AF_UNCONFIGURED -24
822#define BGP_ERR_SOFT_RECONFIG_UNCONFIGURED -25
823#define BGP_ERR_INSTANCE_MISMATCH -26
824#define BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP -27
825#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS -28
Paul Jakma0df7c912008-07-21 21:02:49 +0000826#define BGP_ERR_TCPSIG_FAILED -29
Nick Hilliardfa411a22011-03-23 15:33:17 +0000827#define BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK -30
Stephen Hemmingerf5a48272011-03-24 17:30:21 +0000828#define BGP_ERR_NO_IBGP_WITH_TTLHACK -31
829#define BGP_ERR_MAX -32
Andrew Certain9d3f9702012-11-07 23:50:07 +0000830#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS -33
paul718e3742002-12-13 20:15:29 +0000831
832extern struct bgp_master *bm;
833
paul718e3742002-12-13 20:15:29 +0000834/* Prototypes. */
paul94f2b392005-06-28 12:44:16 +0000835extern void bgp_terminate (void);
836extern void bgp_reset (void);
Stephen Hemminger65957882010-01-15 16:22:10 +0300837extern time_t bgp_clock (void);
paul94f2b392005-06-28 12:44:16 +0000838extern void bgp_zclient_reset (void);
839extern int bgp_nexthop_set (union sockunion *, union sockunion *,
paul718e3742002-12-13 20:15:29 +0000840 struct bgp_nexthop *, struct peer *);
paul94f2b392005-06-28 12:44:16 +0000841extern struct bgp *bgp_get_default (void);
842extern struct bgp *bgp_lookup (as_t, const char *);
843extern struct bgp *bgp_lookup_by_name (const char *);
844extern struct peer *peer_lookup (struct bgp *, union sockunion *);
845extern struct peer_group *peer_group_lookup (struct bgp *, const char *);
846extern struct peer_group *peer_group_get (struct bgp *, const char *);
847extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *,
paul718e3742002-12-13 20:15:29 +0000848 int *);
Donald Sharp104576d2015-09-16 13:17:55 -0400849
850/*
851 * Peers are incredibly easy to memory leak
852 * due to the various ways that they are actually used
853 * Provide some functionality to debug locks and unlocks
854 */
855extern struct peer *peer_lock_with_caller(const char *, struct peer *);
856extern struct peer *peer_unlock_with_caller(const char *, struct peer *);
857#define peer_unlock(A) peer_unlock_with_caller(__FUNCTION__, (A))
858#define peer_lock(B) peer_lock_with_caller(__FUNCTION__, (B))
859
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000860extern bgp_peer_sort_t peer_sort (struct peer *peer);
paul94f2b392005-06-28 12:44:16 +0000861extern int peer_active (struct peer *);
862extern int peer_active_nego (struct peer *);
863extern struct peer *peer_create_accept (struct bgp *);
864extern char *peer_uptime (time_t, char *, size_t);
865extern int bgp_config_write (struct vty *);
866extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *);
David Lamparter6b0655a2014-06-04 06:53:35 +0200867
paul94f2b392005-06-28 12:44:16 +0000868extern void bgp_master_init (void);
paul718e3742002-12-13 20:15:29 +0000869
paul94f2b392005-06-28 12:44:16 +0000870extern void bgp_init (void);
871extern void bgp_route_map_init (void);
paul718e3742002-12-13 20:15:29 +0000872
paul94f2b392005-06-28 12:44:16 +0000873extern int bgp_option_set (int);
874extern int bgp_option_unset (int);
875extern int bgp_option_check (int);
paul718e3742002-12-13 20:15:29 +0000876
paul94f2b392005-06-28 12:44:16 +0000877extern int bgp_get (struct bgp **, as_t *, const char *);
878extern int bgp_delete (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000879
paul94f2b392005-06-28 12:44:16 +0000880extern int bgp_flag_set (struct bgp *, int);
881extern int bgp_flag_unset (struct bgp *, int);
882extern int bgp_flag_check (struct bgp *, int);
paul718e3742002-12-13 20:15:29 +0000883
Stephen Hemminger0088b5d2009-05-21 08:51:03 -0700884extern void bgp_lock (struct bgp *);
885extern void bgp_unlock (struct bgp *);
886
paul94f2b392005-06-28 12:44:16 +0000887extern int bgp_router_id_set (struct bgp *, struct in_addr *);
paul718e3742002-12-13 20:15:29 +0000888
paul94f2b392005-06-28 12:44:16 +0000889extern int bgp_cluster_id_set (struct bgp *, struct in_addr *);
890extern int bgp_cluster_id_unset (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000891
paul94f2b392005-06-28 12:44:16 +0000892extern int bgp_confederation_id_set (struct bgp *, as_t);
893extern int bgp_confederation_id_unset (struct bgp *);
894extern int bgp_confederation_peers_check (struct bgp *, as_t);
paul718e3742002-12-13 20:15:29 +0000895
paul94f2b392005-06-28 12:44:16 +0000896extern int bgp_confederation_peers_add (struct bgp *, as_t);
897extern int bgp_confederation_peers_remove (struct bgp *, as_t);
paul718e3742002-12-13 20:15:29 +0000898
paul94f2b392005-06-28 12:44:16 +0000899extern int bgp_timers_set (struct bgp *, u_int32_t, u_int32_t);
900extern int bgp_timers_unset (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000901
paul94f2b392005-06-28 12:44:16 +0000902extern int bgp_default_local_preference_set (struct bgp *, u_int32_t);
903extern int bgp_default_local_preference_unset (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000904
paul94f2b392005-06-28 12:44:16 +0000905extern int peer_rsclient_active (struct peer *);
paulfee0f4c2004-09-13 05:12:46 +0000906
paul94f2b392005-06-28 12:44:16 +0000907extern int peer_remote_as (struct bgp *, union sockunion *, as_t *, afi_t, safi_t);
908extern int peer_group_remote_as (struct bgp *, const char *, as_t *);
909extern int peer_delete (struct peer *peer);
910extern int peer_group_delete (struct peer_group *);
911extern int peer_group_remote_as_delete (struct peer_group *);
paul718e3742002-12-13 20:15:29 +0000912
paul94f2b392005-06-28 12:44:16 +0000913extern int peer_activate (struct peer *, afi_t, safi_t);
914extern int peer_deactivate (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000915
paul94f2b392005-06-28 12:44:16 +0000916extern int peer_group_bind (struct bgp *, union sockunion *, struct peer_group *,
paul718e3742002-12-13 20:15:29 +0000917 afi_t, safi_t, as_t *);
paul94f2b392005-06-28 12:44:16 +0000918extern int peer_group_unbind (struct bgp *, struct peer *, struct peer_group *,
paul718e3742002-12-13 20:15:29 +0000919 afi_t, safi_t);
920
paul94f2b392005-06-28 12:44:16 +0000921extern int peer_flag_set (struct peer *, u_int32_t);
922extern int peer_flag_unset (struct peer *, u_int32_t);
paul718e3742002-12-13 20:15:29 +0000923
paul94f2b392005-06-28 12:44:16 +0000924extern int peer_af_flag_set (struct peer *, afi_t, safi_t, u_int32_t);
925extern int peer_af_flag_unset (struct peer *, afi_t, safi_t, u_int32_t);
926extern int peer_af_flag_check (struct peer *, afi_t, safi_t, u_int32_t);
paul718e3742002-12-13 20:15:29 +0000927
paul94f2b392005-06-28 12:44:16 +0000928extern int peer_ebgp_multihop_set (struct peer *, int);
929extern int peer_ebgp_multihop_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000930
paul94f2b392005-06-28 12:44:16 +0000931extern int peer_description_set (struct peer *, char *);
932extern int peer_description_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000933
paul94f2b392005-06-28 12:44:16 +0000934extern int peer_update_source_if_set (struct peer *, const char *);
935extern int peer_update_source_addr_set (struct peer *, union sockunion *);
936extern int peer_update_source_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000937
paul94f2b392005-06-28 12:44:16 +0000938extern int peer_default_originate_set (struct peer *, afi_t, safi_t, const char *);
939extern int peer_default_originate_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000940
paul94f2b392005-06-28 12:44:16 +0000941extern int peer_port_set (struct peer *, u_int16_t);
942extern int peer_port_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000943
paul94f2b392005-06-28 12:44:16 +0000944extern int peer_weight_set (struct peer *, u_int16_t);
945extern int peer_weight_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000946
paul94f2b392005-06-28 12:44:16 +0000947extern int peer_timers_set (struct peer *, u_int32_t, u_int32_t);
948extern int peer_timers_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000949
paul94f2b392005-06-28 12:44:16 +0000950extern int peer_timers_connect_set (struct peer *, u_int32_t);
951extern int peer_timers_connect_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000952
paul94f2b392005-06-28 12:44:16 +0000953extern int peer_advertise_interval_set (struct peer *, u_int32_t);
954extern int peer_advertise_interval_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000955
paul94f2b392005-06-28 12:44:16 +0000956extern int peer_interface_set (struct peer *, const char *);
957extern int peer_interface_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000958
paul94f2b392005-06-28 12:44:16 +0000959extern int peer_distribute_set (struct peer *, afi_t, safi_t, int, const char *);
960extern int peer_distribute_unset (struct peer *, afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000961
paul94f2b392005-06-28 12:44:16 +0000962extern int peer_allowas_in_set (struct peer *, afi_t, safi_t, int);
963extern int peer_allowas_in_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000964
Andrew Certain9d3f9702012-11-07 23:50:07 +0000965extern int peer_local_as_set (struct peer *, as_t, int, int);
paul94f2b392005-06-28 12:44:16 +0000966extern int peer_local_as_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000967
paul94f2b392005-06-28 12:44:16 +0000968extern int peer_prefix_list_set (struct peer *, afi_t, safi_t, int, const char *);
969extern int peer_prefix_list_unset (struct peer *, afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000970
paul94f2b392005-06-28 12:44:16 +0000971extern int peer_aslist_set (struct peer *, afi_t, safi_t, int, const char *);
972extern int peer_aslist_unset (struct peer *,afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000973
paul94f2b392005-06-28 12:44:16 +0000974extern int peer_route_map_set (struct peer *, afi_t, safi_t, int, const char *);
975extern int peer_route_map_unset (struct peer *, afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000976
paul94f2b392005-06-28 12:44:16 +0000977extern int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, const char *);
Paul Jakma0df7c912008-07-21 21:02:49 +0000978
979extern int peer_password_set (struct peer *, const char *);
980extern int peer_password_unset (struct peer *);
981
paul94f2b392005-06-28 12:44:16 +0000982extern int peer_unsuppress_map_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000983
paul94f2b392005-06-28 12:44:16 +0000984extern int peer_maximum_prefix_set (struct peer *, afi_t, safi_t, u_int32_t, u_char, int, u_int16_t);
985extern int peer_maximum_prefix_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000986
paul94f2b392005-06-28 12:44:16 +0000987extern int peer_clear (struct peer *);
988extern int peer_clear_soft (struct peer *, afi_t, safi_t, enum bgp_clear_type);
hasso93406d82005-02-02 14:40:33 +0000989
Nick Hilliardfa411a22011-03-23 15:33:17 +0000990extern int peer_ttl_security_hops_set (struct peer *, int);
991extern int peer_ttl_security_hops_unset (struct peer *);
992
paul00d252c2005-05-23 14:19:54 +0000993#endif /* _QUAGGA_BGPD_H */