blob: d8afbf386e442ad30f4df9b727c92ea537907e37 [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)
Lou Berger82dd7072016-01-12 13:41:57 -0500126#define BGP_FLAG_DELETING (1 << 15)
paul718e3742002-12-13 20:15:29 +0000127
128 /* BGP Per AF flags */
129 u_int16_t af_flags[AFI_MAX][SAFI_MAX];
130#define BGP_CONFIG_DAMPENING (1 << 0)
131
132 /* Static route configuration. */
133 struct bgp_table *route[AFI_MAX][SAFI_MAX];
134
135 /* Aggregate address configuration. */
136 struct bgp_table *aggregate[AFI_MAX][SAFI_MAX];
137
138 /* BGP routing information base. */
139 struct bgp_table *rib[AFI_MAX][SAFI_MAX];
140
141 /* BGP redistribute configuration. */
142 u_char redist[AFI_MAX][ZEBRA_ROUTE_MAX];
143
144 /* BGP redistribute metric configuration. */
145 u_char redist_metric_flag[AFI_MAX][ZEBRA_ROUTE_MAX];
146 u_int32_t redist_metric[AFI_MAX][ZEBRA_ROUTE_MAX];
147
148 /* BGP redistribute route-map. */
149 struct
150 {
151 char *name;
152 struct route_map *map;
153 } rmap[AFI_MAX][ZEBRA_ROUTE_MAX];
154
155 /* BGP distance configuration. */
156 u_char distance_ebgp;
157 u_char distance_ibgp;
158 u_char distance_local;
Roman Hoog Antink6184c392014-03-17 14:01:42 +0100159
160 /* BGP ipv6 distance configuration. */
161 u_char ipv6_distance_ebgp;
162 u_char ipv6_distance_ibgp;
163 u_char ipv6_distance_local;
paul718e3742002-12-13 20:15:29 +0000164
165 /* BGP default local-preference. */
166 u_int32_t default_local_pref;
167
168 /* BGP default timer. */
169 u_int32_t default_holdtime;
170 u_int32_t default_keepalive;
hasso538621f2004-05-21 09:31:30 +0000171
172 /* BGP graceful restart */
hasso93406d82005-02-02 14:40:33 +0000173 u_int32_t restart_time;
174 u_int32_t stalepath_time;
Josh Bailey165b5ff2011-07-20 20:43:22 -0700175
176 /* Maximum-paths configuration */
177 struct bgp_maxpaths_cfg {
178 u_int16_t maxpaths_ebgp;
179 u_int16_t maxpaths_ibgp;
180 } maxpaths[AFI_MAX][SAFI_MAX];
paul718e3742002-12-13 20:15:29 +0000181};
182
183/* BGP peer-group support. */
184struct peer_group
185{
186 /* Name of the peer-group. */
187 char *name;
188
189 /* Pointer to BGP. */
190 struct bgp *bgp;
191
192 /* Peer-group client list. */
193 struct list *peer;
194
195 /* Peer-group config */
196 struct peer *conf;
197};
198
199/* BGP Notify message format. */
200struct bgp_notify
201{
202 u_char code;
203 u_char subcode;
204 char *data;
205 bgp_size_t length;
206};
207
208/* Next hop self address. */
209struct bgp_nexthop
210{
211 struct interface *ifp;
212 struct in_addr v4;
paul718e3742002-12-13 20:15:29 +0000213 struct in6_addr v6_global;
214 struct in6_addr v6_local;
paul718e3742002-12-13 20:15:29 +0000215};
216
217/* BGP router distinguisher value. */
218#define BGP_RD_SIZE 8
219
220struct bgp_rd
221{
222 u_char val[BGP_RD_SIZE];
223};
224
paulfee0f4c2004-09-13 05:12:46 +0000225#define RMAP_IN 0
226#define RMAP_OUT 1
227#define RMAP_IMPORT 2
228#define RMAP_EXPORT 3
229#define RMAP_MAX 4
230
paul718e3742002-12-13 20:15:29 +0000231/* BGP filter structure. */
232struct bgp_filter
233{
234 /* Distribute-list. */
235 struct
236 {
237 char *name;
238 struct access_list *alist;
239 } dlist[FILTER_MAX];
240
241 /* Prefix-list. */
242 struct
243 {
244 char *name;
245 struct prefix_list *plist;
246 } plist[FILTER_MAX];
247
248 /* Filter-list. */
249 struct
250 {
251 char *name;
252 struct as_list *aslist;
253 } aslist[FILTER_MAX];
254
255 /* Route-map. */
256 struct
257 {
258 char *name;
259 struct route_map *map;
paulfee0f4c2004-09-13 05:12:46 +0000260 } map[RMAP_MAX];
paul718e3742002-12-13 20:15:29 +0000261
262 /* Unsuppress-map. */
263 struct
264 {
265 char *name;
266 struct route_map *map;
267 } usmap;
268};
269
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000270/* IBGP/EBGP identifier. We also have a CONFED peer, which is to say,
271 a peer who's AS is part of our Confederation. */
272typedef enum
273{
274 BGP_PEER_IBGP = 1,
275 BGP_PEER_EBGP,
276 BGP_PEER_INTERNAL,
277 BGP_PEER_CONFED,
278} bgp_peer_sort_t;
279
paul718e3742002-12-13 20:15:29 +0000280/* BGP neighbor structure. */
281struct peer
282{
283 /* BGP structure. */
284 struct bgp *bgp;
285
paul200df112005-06-01 11:17:05 +0000286 /* reference count, primarily to allow bgp_process'ing of route_node's
287 * to be done after a struct peer is deleted.
288 *
289 * named 'lock' for hysterical reasons within Quagga.
290 */
291 int lock;
292
paul718e3742002-12-13 20:15:29 +0000293 /* BGP peer group. */
294 struct peer_group *group;
295 u_char af_group[AFI_MAX][SAFI_MAX];
296
297 /* Peer's remote AS number. */
298 as_t as;
299
300 /* Peer's local AS number. */
301 as_t local_as;
302
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000303 bgp_peer_sort_t sort;
304
paul718e3742002-12-13 20:15:29 +0000305 /* Peer's Change local AS number. */
306 as_t change_local_as;
307
308 /* Remote router ID. */
309 struct in_addr remote_id;
310
311 /* Local router ID. */
312 struct in_addr local_id;
313
paulfee0f4c2004-09-13 05:12:46 +0000314 /* Peer specific RIB when configured as route-server-client. */
315 struct bgp_table *rib[AFI_MAX][SAFI_MAX];
316
paul718e3742002-12-13 20:15:29 +0000317 /* Packet receive and send buffer. */
318 struct stream *ibuf;
319 struct stream_fifo *obuf;
320 struct stream *work;
321
Pradosh Mohapatra8c71e482014-01-15 06:57:57 +0000322 /* We use a separate stream to encode MP_REACH_NLRI for efficient
323 * NLRI packing. peer->work stores all the other attributes. The
324 * actual packet is then constructed by concatenating the two.
325 */
326 struct stream *scratch;
327
paul718e3742002-12-13 20:15:29 +0000328 /* Status of the peer. */
329 int status;
330 int ostatus;
331
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000332 /* Peer index, used for dumping TABLE_DUMP_V2 format */
333 uint16_t table_dump_index;
334
paul718e3742002-12-13 20:15:29 +0000335 /* Peer information */
pauleb821182004-05-01 08:44:08 +0000336 int fd; /* File descriptor */
337 int ttl; /* TTL of TCP connection to the peer. */
Timo Teräsef757702015-04-29 09:43:04 +0300338 int rtt; /* Estimated round-trip-time from TCP_INFO */
Nick Hilliardfa411a22011-03-23 15:33:17 +0000339 int gtsm_hops; /* minimum hopcount to peer */
pauleb821182004-05-01 08:44:08 +0000340 char *desc; /* Description of the peer. */
341 unsigned short port; /* Destination port for peer */
342 char *host; /* Printable address of the peer. */
343 union sockunion su; /* Sockunion address of the peer. */
344 time_t uptime; /* Last Up/Down time */
345 time_t readtime; /* Last read time */
346 time_t resettime; /* Last reset time */
paul718e3742002-12-13 20:15:29 +0000347
Paul Jakma9099f9b2016-01-18 10:12:10 +0000348 ifindex_t ifindex; /* ifindex of the BGP connection. */
pauleb821182004-05-01 08:44:08 +0000349 char *ifname; /* bind interface name. */
350 char *update_if;
351 union sockunion *update_source;
352 struct zlog *log;
paul718e3742002-12-13 20:15:29 +0000353
pauleb821182004-05-01 08:44:08 +0000354 union sockunion *su_local; /* Sockunion of local address. */
355 union sockunion *su_remote; /* Sockunion of remote address. */
356 int shared_network; /* Is this peer shared same network. */
357 struct bgp_nexthop nexthop; /* Nexthop */
paul718e3742002-12-13 20:15:29 +0000358
359 /* Peer address family configuration. */
360 u_char afc[AFI_MAX][SAFI_MAX];
361 u_char afc_nego[AFI_MAX][SAFI_MAX];
362 u_char afc_adv[AFI_MAX][SAFI_MAX];
363 u_char afc_recv[AFI_MAX][SAFI_MAX];
364
hasso0a486e52005-02-01 20:57:17 +0000365 /* Capability flags (reset in bgp_stop) */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000366 u_int16_t cap;
paul718e3742002-12-13 20:15:29 +0000367#define PEER_CAP_REFRESH_ADV (1 << 0) /* refresh advertised */
368#define PEER_CAP_REFRESH_OLD_RCV (1 << 1) /* refresh old received */
369#define PEER_CAP_REFRESH_NEW_RCV (1 << 2) /* refresh rfc received */
370#define PEER_CAP_DYNAMIC_ADV (1 << 3) /* dynamic advertised */
371#define PEER_CAP_DYNAMIC_RCV (1 << 4) /* dynamic received */
hasso538621f2004-05-21 09:31:30 +0000372#define PEER_CAP_RESTART_ADV (1 << 5) /* restart advertised */
373#define PEER_CAP_RESTART_RCV (1 << 6) /* restart received */
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000374#define PEER_CAP_AS4_ADV (1 << 7) /* as4 advertised */
375#define PEER_CAP_AS4_RCV (1 << 8) /* as4 received */
Vipin Kumardd49eb12014-09-30 14:36:38 -0700376#define PEER_CAP_RESTART_BIT_ADV (1 << 9) /* sent restart state */
377#define PEER_CAP_RESTART_BIT_RCV (1 << 10) /* peer restart state */
paul718e3742002-12-13 20:15:29 +0000378
hasso0a486e52005-02-01 20:57:17 +0000379 /* Capability flags (reset in bgp_stop) */
paul718e3742002-12-13 20:15:29 +0000380 u_int16_t af_cap[AFI_MAX][SAFI_MAX];
381#define PEER_CAP_ORF_PREFIX_SM_ADV (1 << 0) /* send-mode advertised */
382#define PEER_CAP_ORF_PREFIX_RM_ADV (1 << 1) /* receive-mode advertised */
383#define PEER_CAP_ORF_PREFIX_SM_RCV (1 << 2) /* send-mode received */
384#define PEER_CAP_ORF_PREFIX_RM_RCV (1 << 3) /* receive-mode received */
385#define PEER_CAP_ORF_PREFIX_SM_OLD_RCV (1 << 4) /* send-mode received */
386#define PEER_CAP_ORF_PREFIX_RM_OLD_RCV (1 << 5) /* receive-mode received */
hasso93406d82005-02-02 14:40:33 +0000387#define PEER_CAP_RESTART_AF_RCV (1 << 6) /* graceful restart afi/safi received */
388#define PEER_CAP_RESTART_AF_PRESERVE_RCV (1 << 7) /* graceful restart afi/safi F-bit received */
paul718e3742002-12-13 20:15:29 +0000389
390 /* Global configuration flags. */
391 u_int32_t flags;
392#define PEER_FLAG_PASSIVE (1 << 0) /* passive mode */
393#define PEER_FLAG_SHUTDOWN (1 << 1) /* shutdown */
394#define PEER_FLAG_DONT_CAPABILITY (1 << 2) /* dont-capability */
395#define PEER_FLAG_OVERRIDE_CAPABILITY (1 << 3) /* override-capability */
396#define PEER_FLAG_STRICT_CAP_MATCH (1 << 4) /* strict-match */
hassoc9502432005-02-01 22:01:48 +0000397#define PEER_FLAG_DYNAMIC_CAPABILITY (1 << 5) /* dynamic capability */
hasso6ffd2072005-02-02 14:50:11 +0000398#define PEER_FLAG_DISABLE_CONNECTED_CHECK (1 << 6) /* disable-connected-check */
hassoc9502432005-02-01 22:01:48 +0000399#define PEER_FLAG_LOCAL_AS_NO_PREPEND (1 << 7) /* local-as no-prepend */
Andrew Certain9d3f9702012-11-07 23:50:07 +0000400#define PEER_FLAG_LOCAL_AS_REPLACE_AS (1 << 8) /* local-as no-prepend replace-as */
paul718e3742002-12-13 20:15:29 +0000401
hasso93406d82005-02-02 14:40:33 +0000402 /* NSF mode (graceful restart) */
403 u_char nsf[AFI_MAX][SAFI_MAX];
404
paul718e3742002-12-13 20:15:29 +0000405 /* Per AF configuration flags. */
406 u_int32_t af_flags[AFI_MAX][SAFI_MAX];
407#define PEER_FLAG_SEND_COMMUNITY (1 << 0) /* send-community */
408#define PEER_FLAG_SEND_EXT_COMMUNITY (1 << 1) /* send-community ext. */
409#define PEER_FLAG_NEXTHOP_SELF (1 << 2) /* next-hop-self */
410#define PEER_FLAG_REFLECTOR_CLIENT (1 << 3) /* reflector-client */
411#define PEER_FLAG_RSERVER_CLIENT (1 << 4) /* route-server-client */
412#define PEER_FLAG_SOFT_RECONFIG (1 << 5) /* soft-reconfiguration */
413#define PEER_FLAG_AS_PATH_UNCHANGED (1 << 6) /* transparent-as */
414#define PEER_FLAG_NEXTHOP_UNCHANGED (1 << 7) /* transparent-next-hop */
415#define PEER_FLAG_MED_UNCHANGED (1 << 8) /* transparent-next-hop */
416#define PEER_FLAG_DEFAULT_ORIGINATE (1 << 9) /* default-originate */
417#define PEER_FLAG_REMOVE_PRIVATE_AS (1 << 10) /* remove-private-as */
418#define PEER_FLAG_ALLOWAS_IN (1 << 11) /* set allowas-in */
419#define PEER_FLAG_ORF_PREFIX_SM (1 << 12) /* orf capability send-mode */
420#define PEER_FLAG_ORF_PREFIX_RM (1 << 13) /* orf capability receive-mode */
421#define PEER_FLAG_MAX_PREFIX (1 << 14) /* maximum prefix */
422#define PEER_FLAG_MAX_PREFIX_WARNING (1 << 15) /* maximum prefix warning-only */
Paul Jakma0df7c912008-07-21 21:02:49 +0000423#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300424#define PEER_FLAG_NEXTHOP_SELF_ALL (1 << 17) /* next-hop-self all */
Paul Jakma0df7c912008-07-21 21:02:49 +0000425
426 /* MD5 password */
427 char *password;
paul718e3742002-12-13 20:15:29 +0000428
429 /* default-originate route-map. */
430 struct
431 {
432 char *name;
433 struct route_map *map;
434 } default_rmap[AFI_MAX][SAFI_MAX];
435
436 /* Peer status flags. */
437 u_int16_t sflags;
438#define PEER_STATUS_ACCEPT_PEER (1 << 0) /* accept peer */
439#define PEER_STATUS_PREFIX_OVERFLOW (1 << 1) /* prefix-overflow */
440#define PEER_STATUS_CAPABILITY_OPEN (1 << 2) /* capability open send */
441#define PEER_STATUS_HAVE_ACCEPT (1 << 3) /* accept peer's parent */
442#define PEER_STATUS_GROUP (1 << 4) /* peer-group conf */
hasso93406d82005-02-02 14:40:33 +0000443#define PEER_STATUS_NSF_MODE (1 << 5) /* NSF aware peer */
444#define PEER_STATUS_NSF_WAIT (1 << 6) /* wait comeback peer */
paul718e3742002-12-13 20:15:29 +0000445
hasso0a486e52005-02-01 20:57:17 +0000446 /* Peer status af flags (reset in bgp_stop) */
paul718e3742002-12-13 20:15:29 +0000447 u_int16_t af_sflags[AFI_MAX][SAFI_MAX];
448#define PEER_STATUS_ORF_PREFIX_SEND (1 << 0) /* prefix-list send peer */
449#define PEER_STATUS_ORF_WAIT_REFRESH (1 << 1) /* wait refresh received peer */
450#define PEER_STATUS_DEFAULT_ORIGINATE (1 << 2) /* default-originate peer */
hassoe0701b72004-05-20 09:19:34 +0000451#define PEER_STATUS_PREFIX_THRESHOLD (1 << 3) /* exceed prefix-threshold */
452#define PEER_STATUS_PREFIX_LIMIT (1 << 4) /* exceed prefix-limit */
hasso93406d82005-02-02 14:40:33 +0000453#define PEER_STATUS_EOR_SEND (1 << 5) /* end-of-rib send to peer */
454#define PEER_STATUS_EOR_RECEIVED (1 << 6) /* end-of-rib received from peer */
hassoe0701b72004-05-20 09:19:34 +0000455
paul718e3742002-12-13 20:15:29 +0000456 /* Default attribute value for the peer. */
457 u_int32_t config;
458#define PEER_CONFIG_WEIGHT (1 << 0) /* Default weight. */
459#define PEER_CONFIG_TIMER (1 << 1) /* keepalive & holdtime */
460#define PEER_CONFIG_CONNECT (1 << 2) /* connect */
461#define PEER_CONFIG_ROUTEADV (1 << 3) /* route advertise */
462 u_int32_t weight;
463 u_int32_t holdtime;
464 u_int32_t keepalive;
465 u_int32_t connect;
466 u_int32_t routeadv;
467
468 /* Timer values. */
469 u_int32_t v_start;
470 u_int32_t v_connect;
471 u_int32_t v_holdtime;
472 u_int32_t v_keepalive;
paul718e3742002-12-13 20:15:29 +0000473 u_int32_t v_routeadv;
hasso0a486e52005-02-01 20:57:17 +0000474 u_int32_t v_pmax_restart;
hasso93406d82005-02-02 14:40:33 +0000475 u_int32_t v_gr_restart;
paul718e3742002-12-13 20:15:29 +0000476
477 /* Threads. */
478 struct thread *t_read;
479 struct thread *t_write;
480 struct thread *t_start;
481 struct thread *t_connect;
482 struct thread *t_holdtime;
483 struct thread *t_keepalive;
paul718e3742002-12-13 20:15:29 +0000484 struct thread *t_routeadv;
hasso0a486e52005-02-01 20:57:17 +0000485 struct thread *t_pmax_restart;
hasso93406d82005-02-02 14:40:33 +0000486 struct thread *t_gr_restart;
487 struct thread *t_gr_stale;
Paul Jakma64e580a2006-02-21 01:09:01 +0000488
489 /* workqueues */
490 struct work_queue *clear_node_queue;
491
paul718e3742002-12-13 20:15:29 +0000492 /* Statistics field */
493 u_int32_t open_in; /* Open message input count */
494 u_int32_t open_out; /* Open message output count */
495 u_int32_t update_in; /* Update message input count */
496 u_int32_t update_out; /* Update message ouput count */
497 time_t update_time; /* Update message received time. */
498 u_int32_t keepalive_in; /* Keepalive input count */
499 u_int32_t keepalive_out; /* Keepalive output count */
500 u_int32_t notify_in; /* Notify input count */
501 u_int32_t notify_out; /* Notify output count */
502 u_int32_t refresh_in; /* Route Refresh input count */
503 u_int32_t refresh_out; /* Route Refresh output count */
504 u_int32_t dynamic_cap_in; /* Dynamic Capability input count. */
505 u_int32_t dynamic_cap_out; /* Dynamic Capability output count. */
506
507 /* BGP state count */
508 u_int32_t established; /* Established */
509 u_int32_t dropped; /* Dropped */
510
511 /* Syncronization list and time. */
512 struct bgp_synchronize *sync[AFI_MAX][SAFI_MAX];
513 time_t synctime;
514
515 /* Send prefix count. */
516 unsigned long scount[AFI_MAX][SAFI_MAX];
517
518 /* Announcement attribute hash. */
519 struct hash *hash[AFI_MAX][SAFI_MAX];
520
521 /* Notify data. */
522 struct bgp_notify notify;
523
524 /* Whole packet size to be read. */
525 unsigned long packet_size;
526
527 /* Filter structure. */
528 struct bgp_filter filter[AFI_MAX][SAFI_MAX];
529
530 /* ORF Prefix-list */
531 struct prefix_list *orf_plist[AFI_MAX][SAFI_MAX];
532
533 /* Prefix count. */
534 unsigned long pcount[AFI_MAX][SAFI_MAX];
535
536 /* Max prefix count. */
537 unsigned long pmax[AFI_MAX][SAFI_MAX];
hassoe0701b72004-05-20 09:19:34 +0000538 u_char pmax_threshold[AFI_MAX][SAFI_MAX];
hasso0a486e52005-02-01 20:57:17 +0000539 u_int16_t pmax_restart[AFI_MAX][SAFI_MAX];
hassoe0701b72004-05-20 09:19:34 +0000540#define MAXIMUM_PREFIX_THRESHOLD_DEFAULT 75
paul718e3742002-12-13 20:15:29 +0000541
542 /* allowas-in. */
543 char allowas_in[AFI_MAX][SAFI_MAX];
paulac41b2a2003-08-12 05:32:27 +0000544
hassoe0701b72004-05-20 09:19:34 +0000545 /* peer reset cause */
546 char last_reset;
547#define PEER_DOWN_RID_CHANGE 1 /* bgp router-id command */
548#define PEER_DOWN_REMOTE_AS_CHANGE 2 /* neighbor remote-as command */
549#define PEER_DOWN_LOCAL_AS_CHANGE 3 /* neighbor local-as command */
550#define PEER_DOWN_CLID_CHANGE 4 /* bgp cluster-id command */
551#define PEER_DOWN_CONFED_ID_CHANGE 5 /* bgp confederation identifier command */
552#define PEER_DOWN_CONFED_PEER_CHANGE 6 /* bgp confederation peer command */
553#define PEER_DOWN_RR_CLIENT_CHANGE 7 /* neighbor route-reflector-client command */
554#define PEER_DOWN_RS_CLIENT_CHANGE 8 /* neighbor route-server-client command */
555#define PEER_DOWN_UPDATE_SOURCE_CHANGE 9 /* neighbor update-source command */
556#define PEER_DOWN_AF_ACTIVATE 10 /* neighbor activate command */
557#define PEER_DOWN_USER_SHUTDOWN 11 /* neighbor shutdown command */
558#define PEER_DOWN_USER_RESET 12 /* clear ip bgp command */
559#define PEER_DOWN_NOTIFY_RECEIVED 13 /* notification received */
560#define PEER_DOWN_NOTIFY_SEND 14 /* notification send */
561#define PEER_DOWN_CLOSE_SESSION 15 /* tcp session close */
562#define PEER_DOWN_NEIGHBOR_DELETE 16 /* neghbor delete */
563#define PEER_DOWN_RMAP_BIND 17 /* neghbor peer-group command */
564#define PEER_DOWN_RMAP_UNBIND 18 /* no neighbor peer-group command */
565#define PEER_DOWN_CAPABILITY_CHANGE 19 /* neighbor capability command */
566#define PEER_DOWN_PASSIVE_CHANGE 20 /* neighbor passive command */
567#define PEER_DOWN_MULTIHOP_CHANGE 21 /* neighbor multihop command */
hasso93406d82005-02-02 14:40:33 +0000568#define PEER_DOWN_NSF_CLOSE_SESSION 22 /* NSF tcp session close */
hassoe0701b72004-05-20 09:19:34 +0000569
paulac41b2a2003-08-12 05:32:27 +0000570 /* The kind of route-map Flags.*/
571 u_char rmap_type;
572#define PEER_RMAP_TYPE_IN (1 << 0) /* neighbor route-map in */
573#define PEER_RMAP_TYPE_OUT (1 << 1) /* neighbor route-map out */
574#define PEER_RMAP_TYPE_NETWORK (1 << 2) /* network route-map */
575#define PEER_RMAP_TYPE_REDISTRIBUTE (1 << 3) /* redistribute route-map */
576#define PEER_RMAP_TYPE_DEFAULT (1 << 4) /* default-originate route-map */
577#define PEER_RMAP_TYPE_NOSET (1 << 5) /* not allow to set commands */
paulfee0f4c2004-09-13 05:12:46 +0000578#define PEER_RMAP_TYPE_IMPORT (1 << 6) /* neighbor route-map import */
579#define PEER_RMAP_TYPE_EXPORT (1 << 7) /* neighbor route-map export */
paul718e3742002-12-13 20:15:29 +0000580};
581
Paul Jakma0df7c912008-07-21 21:02:49 +0000582#define PEER_PASSWORD_MINLEN (1)
583#define PEER_PASSWORD_MAXLEN (80)
584
paul718e3742002-12-13 20:15:29 +0000585/* This structure's member directly points incoming packet data
586 stream. */
587struct bgp_nlri
588{
589 /* AFI. */
590 afi_t afi;
591
592 /* SAFI. */
593 safi_t safi;
594
595 /* Pointer to NLRI byte stream. */
596 u_char *nlri;
597
598 /* Length of whole NLRI. */
599 bgp_size_t length;
600};
601
602/* BGP versions. */
603#define BGP_VERSION_4 4
paul718e3742002-12-13 20:15:29 +0000604
605/* Default BGP port number. */
606#define BGP_PORT_DEFAULT 179
607
608/* BGP message header and packet size. */
609#define BGP_MARKER_SIZE 16
610#define BGP_HEADER_SIZE 19
611#define BGP_MAX_PACKET_SIZE 4096
612
613/* BGP minimum message size. */
614#define BGP_MSG_OPEN_MIN_SIZE (BGP_HEADER_SIZE + 10)
615#define BGP_MSG_UPDATE_MIN_SIZE (BGP_HEADER_SIZE + 4)
616#define BGP_MSG_NOTIFY_MIN_SIZE (BGP_HEADER_SIZE + 2)
617#define BGP_MSG_KEEPALIVE_MIN_SIZE (BGP_HEADER_SIZE + 0)
618#define BGP_MSG_ROUTE_REFRESH_MIN_SIZE (BGP_HEADER_SIZE + 4)
619#define BGP_MSG_CAPABILITY_MIN_SIZE (BGP_HEADER_SIZE + 3)
620
621/* BGP message types. */
622#define BGP_MSG_OPEN 1
623#define BGP_MSG_UPDATE 2
624#define BGP_MSG_NOTIFY 3
625#define BGP_MSG_KEEPALIVE 4
626#define BGP_MSG_ROUTE_REFRESH_NEW 5
627#define BGP_MSG_CAPABILITY 6
628#define BGP_MSG_ROUTE_REFRESH_OLD 128
629
630/* BGP open optional parameter. */
631#define BGP_OPEN_OPT_AUTH 1
632#define BGP_OPEN_OPT_CAP 2
633
634/* BGP4 attribute type codes. */
635#define BGP_ATTR_ORIGIN 1
636#define BGP_ATTR_AS_PATH 2
637#define BGP_ATTR_NEXT_HOP 3
638#define BGP_ATTR_MULTI_EXIT_DISC 4
639#define BGP_ATTR_LOCAL_PREF 5
640#define BGP_ATTR_ATOMIC_AGGREGATE 6
641#define BGP_ATTR_AGGREGATOR 7
642#define BGP_ATTR_COMMUNITIES 8
643#define BGP_ATTR_ORIGINATOR_ID 9
644#define BGP_ATTR_CLUSTER_LIST 10
645#define BGP_ATTR_DPA 11
646#define BGP_ATTR_ADVERTISER 12
647#define BGP_ATTR_RCID_PATH 13
648#define BGP_ATTR_MP_REACH_NLRI 14
649#define BGP_ATTR_MP_UNREACH_NLRI 15
650#define BGP_ATTR_EXT_COMMUNITIES 16
Paul Jakma0b2aa3a2007-10-14 22:32:21 +0000651#define BGP_ATTR_AS4_PATH 17
652#define BGP_ATTR_AS4_AGGREGATOR 18
Paul Jakma41367172007-08-06 15:24:51 +0000653#define BGP_ATTR_AS_PATHLIMIT 21
Lou Bergerc3741782016-01-12 13:42:01 -0500654#define BGP_ATTR_ENCAP 23
paul718e3742002-12-13 20:15:29 +0000655
656/* BGP update origin. */
657#define BGP_ORIGIN_IGP 0
658#define BGP_ORIGIN_EGP 1
659#define BGP_ORIGIN_INCOMPLETE 2
660
661/* BGP notify message codes. */
662#define BGP_NOTIFY_HEADER_ERR 1
663#define BGP_NOTIFY_OPEN_ERR 2
664#define BGP_NOTIFY_UPDATE_ERR 3
665#define BGP_NOTIFY_HOLD_ERR 4
666#define BGP_NOTIFY_FSM_ERR 5
667#define BGP_NOTIFY_CEASE 6
668#define BGP_NOTIFY_CAPABILITY_ERR 7
669#define BGP_NOTIFY_MAX 8
670
Dmitrij Tejblum4b4e07d2011-09-21 23:13:22 +0400671#define BGP_NOTIFY_SUBCODE_UNSPECIFIC 0
672
paul718e3742002-12-13 20:15:29 +0000673/* BGP_NOTIFY_HEADER_ERR sub codes. */
674#define BGP_NOTIFY_HEADER_NOT_SYNC 1
675#define BGP_NOTIFY_HEADER_BAD_MESLEN 2
676#define BGP_NOTIFY_HEADER_BAD_MESTYPE 3
677#define BGP_NOTIFY_HEADER_MAX 4
678
679/* BGP_NOTIFY_OPEN_ERR sub codes. */
Paul Jakma68ec4242015-11-25 17:14:34 +0000680#define BGP_NOTIFY_OPEN_UNSPECIFIC 0
paul718e3742002-12-13 20:15:29 +0000681#define BGP_NOTIFY_OPEN_UNSUP_VERSION 1
682#define BGP_NOTIFY_OPEN_BAD_PEER_AS 2
683#define BGP_NOTIFY_OPEN_BAD_BGP_IDENT 3
684#define BGP_NOTIFY_OPEN_UNSUP_PARAM 4
685#define BGP_NOTIFY_OPEN_AUTH_FAILURE 5
686#define BGP_NOTIFY_OPEN_UNACEP_HOLDTIME 6
687#define BGP_NOTIFY_OPEN_UNSUP_CAPBL 7
688#define BGP_NOTIFY_OPEN_MAX 8
689
690/* BGP_NOTIFY_UPDATE_ERR sub codes. */
691#define BGP_NOTIFY_UPDATE_MAL_ATTR 1
692#define BGP_NOTIFY_UPDATE_UNREC_ATTR 2
693#define BGP_NOTIFY_UPDATE_MISS_ATTR 3
694#define BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR 4
695#define BGP_NOTIFY_UPDATE_ATTR_LENG_ERR 5
696#define BGP_NOTIFY_UPDATE_INVAL_ORIGIN 6
697#define BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP 7
698#define BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP 8
699#define BGP_NOTIFY_UPDATE_OPT_ATTR_ERR 9
700#define BGP_NOTIFY_UPDATE_INVAL_NETWORK 10
701#define BGP_NOTIFY_UPDATE_MAL_AS_PATH 11
702#define BGP_NOTIFY_UPDATE_MAX 12
703
Dmitrij Tejblum4b4e07d2011-09-21 23:13:22 +0400704/* BGP_NOTIFY_CEASE sub codes (RFC 4486). */
paul718e3742002-12-13 20:15:29 +0000705#define BGP_NOTIFY_CEASE_MAX_PREFIX 1
706#define BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN 2
707#define BGP_NOTIFY_CEASE_PEER_UNCONFIG 3
708#define BGP_NOTIFY_CEASE_ADMIN_RESET 4
709#define BGP_NOTIFY_CEASE_CONNECT_REJECT 5
710#define BGP_NOTIFY_CEASE_CONFIG_CHANGE 6
paul545acaf2004-04-20 15:13:15 +0000711#define BGP_NOTIFY_CEASE_COLLISION_RESOLUTION 7
712#define BGP_NOTIFY_CEASE_OUT_OF_RESOURCE 8
713#define BGP_NOTIFY_CEASE_MAX 9
paul718e3742002-12-13 20:15:29 +0000714
715/* BGP_NOTIFY_CAPABILITY_ERR sub codes (draft-ietf-idr-dynamic-cap-02). */
716#define BGP_NOTIFY_CAPABILITY_INVALID_ACTION 1
717#define BGP_NOTIFY_CAPABILITY_INVALID_LENGTH 2
718#define BGP_NOTIFY_CAPABILITY_MALFORMED_CODE 3
719#define BGP_NOTIFY_CAPABILITY_MAX 4
720
721/* BGP finite state machine status. */
722#define Idle 1
723#define Connect 2
724#define Active 3
725#define OpenSent 4
726#define OpenConfirm 5
727#define Established 6
Paul Jakmaca058a32006-09-14 02:58:49 +0000728#define Clearing 7
729#define Deleted 8
730#define BGP_STATUS_MAX 9
paul718e3742002-12-13 20:15:29 +0000731
732/* BGP finite state machine events. */
733#define BGP_Start 1
734#define BGP_Stop 2
735#define TCP_connection_open 3
736#define TCP_connection_closed 4
737#define TCP_connection_open_failed 5
738#define TCP_fatal_error 6
739#define ConnectRetry_timer_expired 7
740#define Hold_Timer_expired 8
741#define KeepAlive_timer_expired 9
742#define Receive_OPEN_message 10
743#define Receive_KEEPALIVE_message 11
744#define Receive_UPDATE_message 12
745#define Receive_NOTIFICATION_message 13
Paul Jakmaca058a32006-09-14 02:58:49 +0000746#define Clearing_Completed 14
747#define BGP_EVENTS_MAX 15
paul718e3742002-12-13 20:15:29 +0000748
749/* BGP timers default value. */
750#define BGP_INIT_START_TIMER 5
Paul Jakmac0cb90c2016-03-08 18:14:50 +0000751#define BGP_DEFAULT_HOLDTIME 180
752#define BGP_DEFAULT_KEEPALIVE 60
paul718e3742002-12-13 20:15:29 +0000753#define BGP_DEFAULT_EBGP_ROUTEADV 30
754#define BGP_DEFAULT_IBGP_ROUTEADV 5
755#define BGP_CLEAR_CONNECT_RETRY 20
Daniel Waltonf822ad42015-10-21 06:42:47 -0700756#define BGP_DEFAULT_CONNECT_RETRY 10
paul718e3742002-12-13 20:15:29 +0000757
758/* BGP default local preference. */
759#define BGP_DEFAULT_LOCAL_PREF 100
760
hasso538621f2004-05-21 09:31:30 +0000761/* BGP graceful restart */
762#define BGP_DEFAULT_RESTART_TIME 120
763#define BGP_DEFAULT_STALEPATH_TIME 360
764
Denis Ovsienko42e6d742011-07-14 12:36:19 +0400765/* RFC4364 */
766#define SAFI_MPLS_LABELED_VPN 128
paul718e3742002-12-13 20:15:29 +0000767
768/* Max TTL value. */
769#define TTL_MAX 255
770
771/* BGP uptime string length. */
772#define BGP_UPTIME_LEN 25
773
774/* Default configuration settings for bgpd. */
775#define BGP_VTY_PORT 2605
paul718e3742002-12-13 20:15:29 +0000776#define BGP_DEFAULT_CONFIG "bgpd.conf"
777
778/* Check AS path loop when we send NLRI. */
779/* #define BGP_SEND_ASPATH_CHECK */
780
paul718e3742002-12-13 20:15:29 +0000781/* Flag for peer_clear_soft(). */
782enum bgp_clear_type
783{
784 BGP_CLEAR_SOFT_NONE,
785 BGP_CLEAR_SOFT_OUT,
786 BGP_CLEAR_SOFT_IN,
787 BGP_CLEAR_SOFT_BOTH,
paulfee0f4c2004-09-13 05:12:46 +0000788 BGP_CLEAR_SOFT_IN_ORF_PREFIX,
789 BGP_CLEAR_SOFT_RSCLIENT
paul718e3742002-12-13 20:15:29 +0000790};
791
792/* Macros. */
793#define BGP_INPUT(P) ((P)->ibuf)
794#define BGP_INPUT_PNT(P) (STREAM_PNT(BGP_INPUT(P)))
Vitaliy Senchyshyn6aa136f2013-10-02 10:40:20 +0000795#define BGP_IS_VALID_STATE_FOR_NOTIF(S)\
796 (((S) == OpenSent) || ((S) == OpenConfirm) || ((S) == Established))
paul718e3742002-12-13 20:15:29 +0000797
paul718e3742002-12-13 20:15:29 +0000798/* BGP error codes. */
799#define BGP_SUCCESS 0
800#define BGP_ERR_INVALID_VALUE -1
801#define BGP_ERR_INVALID_FLAG -2
802#define BGP_ERR_INVALID_AS -3
803#define BGP_ERR_INVALID_BGP -4
804#define BGP_ERR_PEER_GROUP_MEMBER -5
805#define BGP_ERR_MULTIPLE_INSTANCE_USED -6
806#define BGP_ERR_PEER_GROUP_MEMBER_EXISTS -7
807#define BGP_ERR_PEER_BELONGS_TO_GROUP -8
808#define BGP_ERR_PEER_GROUP_AF_UNCONFIGURED -9
809#define BGP_ERR_PEER_GROUP_NO_REMOTE_AS -10
810#define BGP_ERR_PEER_GROUP_CANT_CHANGE -11
811#define BGP_ERR_PEER_GROUP_MISMATCH -12
812#define BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT -13
813#define BGP_ERR_MULTIPLE_INSTANCE_NOT_SET -14
814#define BGP_ERR_AS_MISMATCH -15
815#define BGP_ERR_PEER_INACTIVE -16
816#define BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER -17
817#define BGP_ERR_PEER_GROUP_HAS_THE_FLAG -18
818#define BGP_ERR_PEER_FLAG_CONFLICT -19
819#define BGP_ERR_PEER_GROUP_SHUTDOWN -20
820#define BGP_ERR_PEER_FILTER_CONFLICT -21
821#define BGP_ERR_NOT_INTERNAL_PEER -22
822#define BGP_ERR_REMOVE_PRIVATE_AS -23
823#define BGP_ERR_AF_UNCONFIGURED -24
824#define BGP_ERR_SOFT_RECONFIG_UNCONFIGURED -25
825#define BGP_ERR_INSTANCE_MISMATCH -26
826#define BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP -27
827#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS -28
Paul Jakma0df7c912008-07-21 21:02:49 +0000828#define BGP_ERR_TCPSIG_FAILED -29
Nick Hilliardfa411a22011-03-23 15:33:17 +0000829#define BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK -30
Stephen Hemmingerf5a48272011-03-24 17:30:21 +0000830#define BGP_ERR_NO_IBGP_WITH_TTLHACK -31
831#define BGP_ERR_MAX -32
Andrew Certain9d3f9702012-11-07 23:50:07 +0000832#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS -33
paul718e3742002-12-13 20:15:29 +0000833
834extern struct bgp_master *bm;
835
paul718e3742002-12-13 20:15:29 +0000836/* Prototypes. */
paul94f2b392005-06-28 12:44:16 +0000837extern void bgp_terminate (void);
838extern void bgp_reset (void);
Stephen Hemminger65957882010-01-15 16:22:10 +0300839extern time_t bgp_clock (void);
paul94f2b392005-06-28 12:44:16 +0000840extern void bgp_zclient_reset (void);
841extern int bgp_nexthop_set (union sockunion *, union sockunion *,
paul718e3742002-12-13 20:15:29 +0000842 struct bgp_nexthop *, struct peer *);
paul94f2b392005-06-28 12:44:16 +0000843extern struct bgp *bgp_get_default (void);
844extern struct bgp *bgp_lookup (as_t, const char *);
845extern struct bgp *bgp_lookup_by_name (const char *);
846extern struct peer *peer_lookup (struct bgp *, union sockunion *);
847extern struct peer_group *peer_group_lookup (struct bgp *, const char *);
848extern struct peer_group *peer_group_get (struct bgp *, const char *);
849extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *,
paul718e3742002-12-13 20:15:29 +0000850 int *);
Donald Sharp104576d2015-09-16 13:17:55 -0400851
852/*
853 * Peers are incredibly easy to memory leak
854 * due to the various ways that they are actually used
855 * Provide some functionality to debug locks and unlocks
856 */
857extern struct peer *peer_lock_with_caller(const char *, struct peer *);
858extern struct peer *peer_unlock_with_caller(const char *, struct peer *);
859#define peer_unlock(A) peer_unlock_with_caller(__FUNCTION__, (A))
860#define peer_lock(B) peer_lock_with_caller(__FUNCTION__, (B))
861
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000862extern bgp_peer_sort_t peer_sort (struct peer *peer);
paul94f2b392005-06-28 12:44:16 +0000863extern int peer_active (struct peer *);
864extern int peer_active_nego (struct peer *);
865extern struct peer *peer_create_accept (struct bgp *);
866extern char *peer_uptime (time_t, char *, size_t);
867extern int bgp_config_write (struct vty *);
868extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *);
David Lamparter6b0655a2014-06-04 06:53:35 +0200869
paul94f2b392005-06-28 12:44:16 +0000870extern void bgp_master_init (void);
paul718e3742002-12-13 20:15:29 +0000871
paul94f2b392005-06-28 12:44:16 +0000872extern void bgp_init (void);
873extern void bgp_route_map_init (void);
paul718e3742002-12-13 20:15:29 +0000874
paul94f2b392005-06-28 12:44:16 +0000875extern int bgp_option_set (int);
876extern int bgp_option_unset (int);
877extern int bgp_option_check (int);
paul718e3742002-12-13 20:15:29 +0000878
paul94f2b392005-06-28 12:44:16 +0000879extern int bgp_get (struct bgp **, as_t *, const char *);
880extern int bgp_delete (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000881
paul94f2b392005-06-28 12:44:16 +0000882extern int bgp_flag_set (struct bgp *, int);
883extern int bgp_flag_unset (struct bgp *, int);
884extern int bgp_flag_check (struct bgp *, int);
paul718e3742002-12-13 20:15:29 +0000885
Stephen Hemminger0088b5d2009-05-21 08:51:03 -0700886extern void bgp_lock (struct bgp *);
887extern void bgp_unlock (struct bgp *);
888
paul94f2b392005-06-28 12:44:16 +0000889extern int bgp_router_id_set (struct bgp *, struct in_addr *);
paul718e3742002-12-13 20:15:29 +0000890
paul94f2b392005-06-28 12:44:16 +0000891extern int bgp_cluster_id_set (struct bgp *, struct in_addr *);
892extern int bgp_cluster_id_unset (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000893
paul94f2b392005-06-28 12:44:16 +0000894extern int bgp_confederation_id_set (struct bgp *, as_t);
895extern int bgp_confederation_id_unset (struct bgp *);
896extern int bgp_confederation_peers_check (struct bgp *, as_t);
paul718e3742002-12-13 20:15:29 +0000897
paul94f2b392005-06-28 12:44:16 +0000898extern int bgp_confederation_peers_add (struct bgp *, as_t);
899extern int bgp_confederation_peers_remove (struct bgp *, as_t);
paul718e3742002-12-13 20:15:29 +0000900
paul94f2b392005-06-28 12:44:16 +0000901extern int bgp_timers_set (struct bgp *, u_int32_t, u_int32_t);
902extern int bgp_timers_unset (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000903
paul94f2b392005-06-28 12:44:16 +0000904extern int bgp_default_local_preference_set (struct bgp *, u_int32_t);
905extern int bgp_default_local_preference_unset (struct bgp *);
paul718e3742002-12-13 20:15:29 +0000906
paul94f2b392005-06-28 12:44:16 +0000907extern int peer_rsclient_active (struct peer *);
paulfee0f4c2004-09-13 05:12:46 +0000908
paul94f2b392005-06-28 12:44:16 +0000909extern int peer_remote_as (struct bgp *, union sockunion *, as_t *, afi_t, safi_t);
910extern int peer_group_remote_as (struct bgp *, const char *, as_t *);
911extern int peer_delete (struct peer *peer);
912extern int peer_group_delete (struct peer_group *);
913extern int peer_group_remote_as_delete (struct peer_group *);
paul718e3742002-12-13 20:15:29 +0000914
paul94f2b392005-06-28 12:44:16 +0000915extern int peer_activate (struct peer *, afi_t, safi_t);
916extern int peer_deactivate (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000917
paul94f2b392005-06-28 12:44:16 +0000918extern int peer_group_bind (struct bgp *, union sockunion *, struct peer_group *,
paul718e3742002-12-13 20:15:29 +0000919 afi_t, safi_t, as_t *);
paul94f2b392005-06-28 12:44:16 +0000920extern int peer_group_unbind (struct bgp *, struct peer *, struct peer_group *,
paul718e3742002-12-13 20:15:29 +0000921 afi_t, safi_t);
922
paul94f2b392005-06-28 12:44:16 +0000923extern int peer_flag_set (struct peer *, u_int32_t);
924extern int peer_flag_unset (struct peer *, u_int32_t);
paul718e3742002-12-13 20:15:29 +0000925
paul94f2b392005-06-28 12:44:16 +0000926extern int peer_af_flag_set (struct peer *, afi_t, safi_t, u_int32_t);
927extern int peer_af_flag_unset (struct peer *, afi_t, safi_t, u_int32_t);
928extern int peer_af_flag_check (struct peer *, afi_t, safi_t, u_int32_t);
paul718e3742002-12-13 20:15:29 +0000929
paul94f2b392005-06-28 12:44:16 +0000930extern int peer_ebgp_multihop_set (struct peer *, int);
931extern int peer_ebgp_multihop_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000932
paul94f2b392005-06-28 12:44:16 +0000933extern int peer_description_set (struct peer *, char *);
934extern int peer_description_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000935
paul94f2b392005-06-28 12:44:16 +0000936extern int peer_update_source_if_set (struct peer *, const char *);
937extern int peer_update_source_addr_set (struct peer *, union sockunion *);
938extern int peer_update_source_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000939
paul94f2b392005-06-28 12:44:16 +0000940extern int peer_default_originate_set (struct peer *, afi_t, safi_t, const char *);
941extern int peer_default_originate_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000942
paul94f2b392005-06-28 12:44:16 +0000943extern int peer_port_set (struct peer *, u_int16_t);
944extern int peer_port_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000945
paul94f2b392005-06-28 12:44:16 +0000946extern int peer_weight_set (struct peer *, u_int16_t);
947extern int peer_weight_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000948
paul94f2b392005-06-28 12:44:16 +0000949extern int peer_timers_set (struct peer *, u_int32_t, u_int32_t);
950extern int peer_timers_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000951
paul94f2b392005-06-28 12:44:16 +0000952extern int peer_timers_connect_set (struct peer *, u_int32_t);
953extern int peer_timers_connect_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000954
paul94f2b392005-06-28 12:44:16 +0000955extern int peer_advertise_interval_set (struct peer *, u_int32_t);
956extern int peer_advertise_interval_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000957
paul94f2b392005-06-28 12:44:16 +0000958extern int peer_interface_set (struct peer *, const char *);
959extern int peer_interface_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000960
paul94f2b392005-06-28 12:44:16 +0000961extern int peer_distribute_set (struct peer *, afi_t, safi_t, int, const char *);
962extern int peer_distribute_unset (struct peer *, afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000963
paul94f2b392005-06-28 12:44:16 +0000964extern int peer_allowas_in_set (struct peer *, afi_t, safi_t, int);
965extern int peer_allowas_in_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000966
Andrew Certain9d3f9702012-11-07 23:50:07 +0000967extern int peer_local_as_set (struct peer *, as_t, int, int);
paul94f2b392005-06-28 12:44:16 +0000968extern int peer_local_as_unset (struct peer *);
paul718e3742002-12-13 20:15:29 +0000969
paul94f2b392005-06-28 12:44:16 +0000970extern int peer_prefix_list_set (struct peer *, afi_t, safi_t, int, const char *);
971extern int peer_prefix_list_unset (struct peer *, afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000972
paul94f2b392005-06-28 12:44:16 +0000973extern int peer_aslist_set (struct peer *, afi_t, safi_t, int, const char *);
974extern int peer_aslist_unset (struct peer *,afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000975
paul94f2b392005-06-28 12:44:16 +0000976extern int peer_route_map_set (struct peer *, afi_t, safi_t, int, const char *);
977extern int peer_route_map_unset (struct peer *, afi_t, safi_t, int);
paul718e3742002-12-13 20:15:29 +0000978
paul94f2b392005-06-28 12:44:16 +0000979extern int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, const char *);
Paul Jakma0df7c912008-07-21 21:02:49 +0000980
981extern int peer_password_set (struct peer *, const char *);
982extern int peer_password_unset (struct peer *);
983
paul94f2b392005-06-28 12:44:16 +0000984extern int peer_unsuppress_map_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000985
paul94f2b392005-06-28 12:44:16 +0000986extern int peer_maximum_prefix_set (struct peer *, afi_t, safi_t, u_int32_t, u_char, int, u_int16_t);
987extern int peer_maximum_prefix_unset (struct peer *, afi_t, safi_t);
paul718e3742002-12-13 20:15:29 +0000988
paul94f2b392005-06-28 12:44:16 +0000989extern int peer_clear (struct peer *);
990extern int peer_clear_soft (struct peer *, afi_t, safi_t, enum bgp_clear_type);
hasso93406d82005-02-02 14:40:33 +0000991
Nick Hilliardfa411a22011-03-23 15:33:17 +0000992extern int peer_ttl_security_hops_set (struct peer *, int);
993extern int peer_ttl_security_hops_unset (struct peer *);
994
paul00d252c2005-05-23 14:19:54 +0000995#endif /* _QUAGGA_BGPD_H */