]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgpd.h
[tools/multiple-bgpd.sh] make it easier to use IPv6 peer addresses
[mirror_frr.git] / bgpd / bgpd.h
CommitLineData
718e3744 1/* 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
00d252cb 21#ifndef _QUAGGA_BGPD_H
22#define _QUAGGA_BGPD_H
23
718e3744 24/* For union sockunion. */
25#include "sockunion.h"
26
27/* Typedef BGP specific types. */
0b2aa3a0
PJ
28typedef u_int32_t as_t;
29typedef u_int16_t as16_t; /* we may still encounter 16 Bit asnums */
718e3744 30typedef 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
200df115 41 /* work queues */
42 struct work_queue *process_main_queue;
43 struct work_queue *process_rsclient_queue;
200df115 44
718e3744 45 /* BGP port number. */
46 u_int16_t port;
47
3a02d1f7
PJ
48 /* Listener address */
49 char *address;
50
718e3744 51 /* BGP start time. */
52 time_t start_time;
53
54 /* Various BGP global configuration. */
55 u_char options;
56#define BGP_OPT_NO_FIB (1 << 0)
57#define BGP_OPT_MULTIPLE_INSTANCE (1 << 1)
58#define BGP_OPT_CONFIG_CISCO (1 << 2)
59};
60
61/* BGP instance structure. */
62struct bgp
63{
64 /* AS number of this BGP instance. */
65 as_t as;
66
67 /* Name of this BGP instance. */
68 char *name;
200df115 69
718e3744 70 /* Self peer. */
71 struct peer *peer_self;
72
73 /* BGP peer. */
74 struct list *peer;
75
76 /* BGP peer group. */
77 struct list *group;
78
fee0f4c6 79 /* BGP route-server-clients. */
80 struct list *rsclient;
81
718e3744 82 /* BGP configuration. */
83 u_int16_t config;
84#define BGP_CONFIG_ROUTER_ID (1 << 0)
85#define BGP_CONFIG_CLUSTER_ID (1 << 1)
86#define BGP_CONFIG_CONFEDERATION (1 << 2)
718e3744 87
88 /* BGP router identifier. */
89 struct in_addr router_id;
18a6dce6 90 struct in_addr router_id_static;
718e3744 91
92 /* BGP route reflector cluster ID. */
93 struct in_addr cluster_id;
94
95 /* BGP confederation information. */
96 as_t confed_id;
97 as_t *confed_peers;
98 int confed_peers_cnt;
99
100 /* BGP flags. */
101 u_int16_t flags;
102#define BGP_FLAG_ALWAYS_COMPARE_MED (1 << 0)
103#define BGP_FLAG_DETERMINISTIC_MED (1 << 1)
104#define BGP_FLAG_MED_MISSING_AS_WORST (1 << 2)
105#define BGP_FLAG_MED_CONFED (1 << 3)
106#define BGP_FLAG_NO_DEFAULT_IPV4 (1 << 4)
107#define BGP_FLAG_NO_CLIENT_TO_CLIENT (1 << 5)
108#define BGP_FLAG_ENFORCE_FIRST_AS (1 << 6)
109#define BGP_FLAG_COMPARE_ROUTER_ID (1 << 7)
110#define BGP_FLAG_ASPATH_IGNORE (1 << 8)
111#define BGP_FLAG_IMPORT_CHECK (1 << 9)
112#define BGP_FLAG_NO_FAST_EXT_FAILOVER (1 << 10)
848973c7 113#define BGP_FLAG_LOG_NEIGHBOR_CHANGES (1 << 11)
538621f2 114#define BGP_FLAG_GRACEFUL_RESTART (1 << 12)
6811845b 115#define BGP_FLAG_ASPATH_CONFED (1 << 13)
718e3744 116
117 /* BGP Per AF flags */
118 u_int16_t af_flags[AFI_MAX][SAFI_MAX];
119#define BGP_CONFIG_DAMPENING (1 << 0)
120
121 /* Static route configuration. */
122 struct bgp_table *route[AFI_MAX][SAFI_MAX];
123
124 /* Aggregate address configuration. */
125 struct bgp_table *aggregate[AFI_MAX][SAFI_MAX];
126
127 /* BGP routing information base. */
128 struct bgp_table *rib[AFI_MAX][SAFI_MAX];
129
130 /* BGP redistribute configuration. */
131 u_char redist[AFI_MAX][ZEBRA_ROUTE_MAX];
132
133 /* BGP redistribute metric configuration. */
134 u_char redist_metric_flag[AFI_MAX][ZEBRA_ROUTE_MAX];
135 u_int32_t redist_metric[AFI_MAX][ZEBRA_ROUTE_MAX];
136
137 /* BGP redistribute route-map. */
138 struct
139 {
140 char *name;
141 struct route_map *map;
142 } rmap[AFI_MAX][ZEBRA_ROUTE_MAX];
143
144 /* BGP distance configuration. */
145 u_char distance_ebgp;
146 u_char distance_ibgp;
147 u_char distance_local;
148
149 /* BGP default local-preference. */
150 u_int32_t default_local_pref;
151
152 /* BGP default timer. */
153 u_int32_t default_holdtime;
154 u_int32_t default_keepalive;
538621f2 155
156 /* BGP graceful restart */
93406d87 157 u_int32_t restart_time;
158 u_int32_t stalepath_time;
718e3744 159};
160
161/* BGP peer-group support. */
162struct peer_group
163{
164 /* Name of the peer-group. */
165 char *name;
166
167 /* Pointer to BGP. */
168 struct bgp *bgp;
169
170 /* Peer-group client list. */
171 struct list *peer;
172
173 /* Peer-group config */
174 struct peer *conf;
175};
176
177/* BGP Notify message format. */
178struct bgp_notify
179{
180 u_char code;
181 u_char subcode;
182 char *data;
183 bgp_size_t length;
184};
185
186/* Next hop self address. */
187struct bgp_nexthop
188{
189 struct interface *ifp;
190 struct in_addr v4;
191#ifdef HAVE_IPV6
192 struct in6_addr v6_global;
193 struct in6_addr v6_local;
194#endif /* HAVE_IPV6 */
195};
196
197/* BGP router distinguisher value. */
198#define BGP_RD_SIZE 8
199
200struct bgp_rd
201{
202 u_char val[BGP_RD_SIZE];
203};
204
fee0f4c6 205#define RMAP_IN 0
206#define RMAP_OUT 1
207#define RMAP_IMPORT 2
208#define RMAP_EXPORT 3
209#define RMAP_MAX 4
210
718e3744 211/* BGP filter structure. */
212struct bgp_filter
213{
214 /* Distribute-list. */
215 struct
216 {
217 char *name;
218 struct access_list *alist;
219 } dlist[FILTER_MAX];
220
221 /* Prefix-list. */
222 struct
223 {
224 char *name;
225 struct prefix_list *plist;
226 } plist[FILTER_MAX];
227
228 /* Filter-list. */
229 struct
230 {
231 char *name;
232 struct as_list *aslist;
233 } aslist[FILTER_MAX];
234
235 /* Route-map. */
236 struct
237 {
238 char *name;
239 struct route_map *map;
fee0f4c6 240 } map[RMAP_MAX];
718e3744 241
242 /* Unsuppress-map. */
243 struct
244 {
245 char *name;
246 struct route_map *map;
247 } usmap;
248};
249
250/* BGP neighbor structure. */
251struct peer
252{
253 /* BGP structure. */
254 struct bgp *bgp;
255
200df115 256 /* reference count, primarily to allow bgp_process'ing of route_node's
257 * to be done after a struct peer is deleted.
258 *
259 * named 'lock' for hysterical reasons within Quagga.
260 */
261 int lock;
262
718e3744 263 /* BGP peer group. */
264 struct peer_group *group;
265 u_char af_group[AFI_MAX][SAFI_MAX];
266
267 /* Peer's remote AS number. */
268 as_t as;
269
270 /* Peer's local AS number. */
271 as_t local_as;
272
273 /* Peer's Change local AS number. */
274 as_t change_local_as;
275
276 /* Remote router ID. */
277 struct in_addr remote_id;
278
279 /* Local router ID. */
280 struct in_addr local_id;
281
fee0f4c6 282 /* Peer specific RIB when configured as route-server-client. */
283 struct bgp_table *rib[AFI_MAX][SAFI_MAX];
284
718e3744 285 /* Packet receive and send buffer. */
286 struct stream *ibuf;
287 struct stream_fifo *obuf;
288 struct stream *work;
289
290 /* Status of the peer. */
291 int status;
292 int ostatus;
293
0b2aa3a0
PJ
294 /* Peer index, used for dumping TABLE_DUMP_V2 format */
295 uint16_t table_dump_index;
296
718e3744 297 /* Peer information */
eb821189 298 int fd; /* File descriptor */
299 int ttl; /* TTL of TCP connection to the peer. */
300 char *desc; /* Description of the peer. */
301 unsigned short port; /* Destination port for peer */
302 char *host; /* Printable address of the peer. */
303 union sockunion su; /* Sockunion address of the peer. */
304 time_t uptime; /* Last Up/Down time */
305 time_t readtime; /* Last read time */
306 time_t resettime; /* Last reset time */
718e3744 307
eb821189 308 unsigned int ifindex; /* ifindex of the BGP connection. */
309 char *ifname; /* bind interface name. */
310 char *update_if;
311 union sockunion *update_source;
312 struct zlog *log;
eb821189 313
314 union sockunion *su_local; /* Sockunion of local address. */
315 union sockunion *su_remote; /* Sockunion of remote address. */
316 int shared_network; /* Is this peer shared same network. */
317 struct bgp_nexthop nexthop; /* Nexthop */
718e3744 318
319 /* Peer address family configuration. */
320 u_char afc[AFI_MAX][SAFI_MAX];
321 u_char afc_nego[AFI_MAX][SAFI_MAX];
322 u_char afc_adv[AFI_MAX][SAFI_MAX];
323 u_char afc_recv[AFI_MAX][SAFI_MAX];
324
0a486e5f 325 /* Capability flags (reset in bgp_stop) */
0b2aa3a0 326 u_int16_t cap;
718e3744 327#define PEER_CAP_REFRESH_ADV (1 << 0) /* refresh advertised */
328#define PEER_CAP_REFRESH_OLD_RCV (1 << 1) /* refresh old received */
329#define PEER_CAP_REFRESH_NEW_RCV (1 << 2) /* refresh rfc received */
330#define PEER_CAP_DYNAMIC_ADV (1 << 3) /* dynamic advertised */
331#define PEER_CAP_DYNAMIC_RCV (1 << 4) /* dynamic received */
538621f2 332#define PEER_CAP_RESTART_ADV (1 << 5) /* restart advertised */
333#define PEER_CAP_RESTART_RCV (1 << 6) /* restart received */
0b2aa3a0
PJ
334#define PEER_CAP_AS4_ADV (1 << 7) /* as4 advertised */
335#define PEER_CAP_AS4_RCV (1 << 8) /* as4 received */
718e3744 336
0a486e5f 337 /* Capability flags (reset in bgp_stop) */
718e3744 338 u_int16_t af_cap[AFI_MAX][SAFI_MAX];
339#define PEER_CAP_ORF_PREFIX_SM_ADV (1 << 0) /* send-mode advertised */
340#define PEER_CAP_ORF_PREFIX_RM_ADV (1 << 1) /* receive-mode advertised */
341#define PEER_CAP_ORF_PREFIX_SM_RCV (1 << 2) /* send-mode received */
342#define PEER_CAP_ORF_PREFIX_RM_RCV (1 << 3) /* receive-mode received */
343#define PEER_CAP_ORF_PREFIX_SM_OLD_RCV (1 << 4) /* send-mode received */
344#define PEER_CAP_ORF_PREFIX_RM_OLD_RCV (1 << 5) /* receive-mode received */
93406d87 345#define PEER_CAP_RESTART_AF_RCV (1 << 6) /* graceful restart afi/safi received */
346#define PEER_CAP_RESTART_AF_PRESERVE_RCV (1 << 7) /* graceful restart afi/safi F-bit received */
718e3744 347
348 /* Global configuration flags. */
349 u_int32_t flags;
350#define PEER_FLAG_PASSIVE (1 << 0) /* passive mode */
351#define PEER_FLAG_SHUTDOWN (1 << 1) /* shutdown */
352#define PEER_FLAG_DONT_CAPABILITY (1 << 2) /* dont-capability */
353#define PEER_FLAG_OVERRIDE_CAPABILITY (1 << 3) /* override-capability */
354#define PEER_FLAG_STRICT_CAP_MATCH (1 << 4) /* strict-match */
c9502438 355#define PEER_FLAG_DYNAMIC_CAPABILITY (1 << 5) /* dynamic capability */
6ffd2079 356#define PEER_FLAG_DISABLE_CONNECTED_CHECK (1 << 6) /* disable-connected-check */
c9502438 357#define PEER_FLAG_LOCAL_AS_NO_PREPEND (1 << 7) /* local-as no-prepend */
718e3744 358
93406d87 359 /* NSF mode (graceful restart) */
360 u_char nsf[AFI_MAX][SAFI_MAX];
361
718e3744 362 /* Per AF configuration flags. */
363 u_int32_t af_flags[AFI_MAX][SAFI_MAX];
364#define PEER_FLAG_SEND_COMMUNITY (1 << 0) /* send-community */
365#define PEER_FLAG_SEND_EXT_COMMUNITY (1 << 1) /* send-community ext. */
366#define PEER_FLAG_NEXTHOP_SELF (1 << 2) /* next-hop-self */
367#define PEER_FLAG_REFLECTOR_CLIENT (1 << 3) /* reflector-client */
368#define PEER_FLAG_RSERVER_CLIENT (1 << 4) /* route-server-client */
369#define PEER_FLAG_SOFT_RECONFIG (1 << 5) /* soft-reconfiguration */
370#define PEER_FLAG_AS_PATH_UNCHANGED (1 << 6) /* transparent-as */
371#define PEER_FLAG_NEXTHOP_UNCHANGED (1 << 7) /* transparent-next-hop */
372#define PEER_FLAG_MED_UNCHANGED (1 << 8) /* transparent-next-hop */
373#define PEER_FLAG_DEFAULT_ORIGINATE (1 << 9) /* default-originate */
374#define PEER_FLAG_REMOVE_PRIVATE_AS (1 << 10) /* remove-private-as */
375#define PEER_FLAG_ALLOWAS_IN (1 << 11) /* set allowas-in */
376#define PEER_FLAG_ORF_PREFIX_SM (1 << 12) /* orf capability send-mode */
377#define PEER_FLAG_ORF_PREFIX_RM (1 << 13) /* orf capability receive-mode */
378#define PEER_FLAG_MAX_PREFIX (1 << 14) /* maximum prefix */
379#define PEER_FLAG_MAX_PREFIX_WARNING (1 << 15) /* maximum prefix warning-only */
fee0f4c6 380#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */
718e3744 381
382 /* default-originate route-map. */
383 struct
384 {
385 char *name;
386 struct route_map *map;
387 } default_rmap[AFI_MAX][SAFI_MAX];
388
389 /* Peer status flags. */
390 u_int16_t sflags;
391#define PEER_STATUS_ACCEPT_PEER (1 << 0) /* accept peer */
392#define PEER_STATUS_PREFIX_OVERFLOW (1 << 1) /* prefix-overflow */
393#define PEER_STATUS_CAPABILITY_OPEN (1 << 2) /* capability open send */
394#define PEER_STATUS_HAVE_ACCEPT (1 << 3) /* accept peer's parent */
395#define PEER_STATUS_GROUP (1 << 4) /* peer-group conf */
93406d87 396#define PEER_STATUS_NSF_MODE (1 << 5) /* NSF aware peer */
397#define PEER_STATUS_NSF_WAIT (1 << 6) /* wait comeback peer */
718e3744 398
0a486e5f 399 /* Peer status af flags (reset in bgp_stop) */
718e3744 400 u_int16_t af_sflags[AFI_MAX][SAFI_MAX];
401#define PEER_STATUS_ORF_PREFIX_SEND (1 << 0) /* prefix-list send peer */
402#define PEER_STATUS_ORF_WAIT_REFRESH (1 << 1) /* wait refresh received peer */
403#define PEER_STATUS_DEFAULT_ORIGINATE (1 << 2) /* default-originate peer */
e0701b79 404#define PEER_STATUS_PREFIX_THRESHOLD (1 << 3) /* exceed prefix-threshold */
405#define PEER_STATUS_PREFIX_LIMIT (1 << 4) /* exceed prefix-limit */
93406d87 406#define PEER_STATUS_EOR_SEND (1 << 5) /* end-of-rib send to peer */
407#define PEER_STATUS_EOR_RECEIVED (1 << 6) /* end-of-rib received from peer */
e0701b79 408
718e3744 409 /* Default attribute value for the peer. */
410 u_int32_t config;
411#define PEER_CONFIG_WEIGHT (1 << 0) /* Default weight. */
412#define PEER_CONFIG_TIMER (1 << 1) /* keepalive & holdtime */
413#define PEER_CONFIG_CONNECT (1 << 2) /* connect */
414#define PEER_CONFIG_ROUTEADV (1 << 3) /* route advertise */
415 u_int32_t weight;
416 u_int32_t holdtime;
417 u_int32_t keepalive;
418 u_int32_t connect;
419 u_int32_t routeadv;
420
421 /* Timer values. */
422 u_int32_t v_start;
423 u_int32_t v_connect;
424 u_int32_t v_holdtime;
425 u_int32_t v_keepalive;
426 u_int32_t v_asorig;
427 u_int32_t v_routeadv;
0a486e5f 428 u_int32_t v_pmax_restart;
93406d87 429 u_int32_t v_gr_restart;
718e3744 430
431 /* Threads. */
432 struct thread *t_read;
433 struct thread *t_write;
434 struct thread *t_start;
435 struct thread *t_connect;
436 struct thread *t_holdtime;
437 struct thread *t_keepalive;
438 struct thread *t_asorig;
439 struct thread *t_routeadv;
0a486e5f 440 struct thread *t_pmax_restart;
93406d87 441 struct thread *t_gr_restart;
442 struct thread *t_gr_stale;
64e580a7
PJ
443
444 /* workqueues */
445 struct work_queue *clear_node_queue;
446
718e3744 447 /* Statistics field */
448 u_int32_t open_in; /* Open message input count */
449 u_int32_t open_out; /* Open message output count */
450 u_int32_t update_in; /* Update message input count */
451 u_int32_t update_out; /* Update message ouput count */
452 time_t update_time; /* Update message received time. */
453 u_int32_t keepalive_in; /* Keepalive input count */
454 u_int32_t keepalive_out; /* Keepalive output count */
455 u_int32_t notify_in; /* Notify input count */
456 u_int32_t notify_out; /* Notify output count */
457 u_int32_t refresh_in; /* Route Refresh input count */
458 u_int32_t refresh_out; /* Route Refresh output count */
459 u_int32_t dynamic_cap_in; /* Dynamic Capability input count. */
460 u_int32_t dynamic_cap_out; /* Dynamic Capability output count. */
461
462 /* BGP state count */
463 u_int32_t established; /* Established */
464 u_int32_t dropped; /* Dropped */
465
466 /* Syncronization list and time. */
467 struct bgp_synchronize *sync[AFI_MAX][SAFI_MAX];
468 time_t synctime;
469
470 /* Send prefix count. */
471 unsigned long scount[AFI_MAX][SAFI_MAX];
472
473 /* Announcement attribute hash. */
474 struct hash *hash[AFI_MAX][SAFI_MAX];
475
476 /* Notify data. */
477 struct bgp_notify notify;
478
479 /* Whole packet size to be read. */
480 unsigned long packet_size;
481
482 /* Filter structure. */
483 struct bgp_filter filter[AFI_MAX][SAFI_MAX];
484
485 /* ORF Prefix-list */
486 struct prefix_list *orf_plist[AFI_MAX][SAFI_MAX];
487
488 /* Prefix count. */
489 unsigned long pcount[AFI_MAX][SAFI_MAX];
490
491 /* Max prefix count. */
492 unsigned long pmax[AFI_MAX][SAFI_MAX];
e0701b79 493 u_char pmax_threshold[AFI_MAX][SAFI_MAX];
0a486e5f 494 u_int16_t pmax_restart[AFI_MAX][SAFI_MAX];
e0701b79 495#define MAXIMUM_PREFIX_THRESHOLD_DEFAULT 75
718e3744 496
497 /* allowas-in. */
498 char allowas_in[AFI_MAX][SAFI_MAX];
ac41b2a2 499
e0701b79 500 /* peer reset cause */
501 char last_reset;
502#define PEER_DOWN_RID_CHANGE 1 /* bgp router-id command */
503#define PEER_DOWN_REMOTE_AS_CHANGE 2 /* neighbor remote-as command */
504#define PEER_DOWN_LOCAL_AS_CHANGE 3 /* neighbor local-as command */
505#define PEER_DOWN_CLID_CHANGE 4 /* bgp cluster-id command */
506#define PEER_DOWN_CONFED_ID_CHANGE 5 /* bgp confederation identifier command */
507#define PEER_DOWN_CONFED_PEER_CHANGE 6 /* bgp confederation peer command */
508#define PEER_DOWN_RR_CLIENT_CHANGE 7 /* neighbor route-reflector-client command */
509#define PEER_DOWN_RS_CLIENT_CHANGE 8 /* neighbor route-server-client command */
510#define PEER_DOWN_UPDATE_SOURCE_CHANGE 9 /* neighbor update-source command */
511#define PEER_DOWN_AF_ACTIVATE 10 /* neighbor activate command */
512#define PEER_DOWN_USER_SHUTDOWN 11 /* neighbor shutdown command */
513#define PEER_DOWN_USER_RESET 12 /* clear ip bgp command */
514#define PEER_DOWN_NOTIFY_RECEIVED 13 /* notification received */
515#define PEER_DOWN_NOTIFY_SEND 14 /* notification send */
516#define PEER_DOWN_CLOSE_SESSION 15 /* tcp session close */
517#define PEER_DOWN_NEIGHBOR_DELETE 16 /* neghbor delete */
518#define PEER_DOWN_RMAP_BIND 17 /* neghbor peer-group command */
519#define PEER_DOWN_RMAP_UNBIND 18 /* no neighbor peer-group command */
520#define PEER_DOWN_CAPABILITY_CHANGE 19 /* neighbor capability command */
521#define PEER_DOWN_PASSIVE_CHANGE 20 /* neighbor passive command */
522#define PEER_DOWN_MULTIHOP_CHANGE 21 /* neighbor multihop command */
93406d87 523#define PEER_DOWN_NSF_CLOSE_SESSION 22 /* NSF tcp session close */
e0701b79 524
ac41b2a2 525 /* The kind of route-map Flags.*/
526 u_char rmap_type;
527#define PEER_RMAP_TYPE_IN (1 << 0) /* neighbor route-map in */
528#define PEER_RMAP_TYPE_OUT (1 << 1) /* neighbor route-map out */
529#define PEER_RMAP_TYPE_NETWORK (1 << 2) /* network route-map */
530#define PEER_RMAP_TYPE_REDISTRIBUTE (1 << 3) /* redistribute route-map */
531#define PEER_RMAP_TYPE_DEFAULT (1 << 4) /* default-originate route-map */
532#define PEER_RMAP_TYPE_NOSET (1 << 5) /* not allow to set commands */
fee0f4c6 533#define PEER_RMAP_TYPE_IMPORT (1 << 6) /* neighbor route-map import */
534#define PEER_RMAP_TYPE_EXPORT (1 << 7) /* neighbor route-map export */
718e3744 535};
536
537/* This structure's member directly points incoming packet data
538 stream. */
539struct bgp_nlri
540{
541 /* AFI. */
542 afi_t afi;
543
544 /* SAFI. */
545 safi_t safi;
546
547 /* Pointer to NLRI byte stream. */
548 u_char *nlri;
549
550 /* Length of whole NLRI. */
551 bgp_size_t length;
552};
553
554/* BGP versions. */
555#define BGP_VERSION_4 4
718e3744 556
557/* Default BGP port number. */
558#define BGP_PORT_DEFAULT 179
559
560/* BGP message header and packet size. */
561#define BGP_MARKER_SIZE 16
562#define BGP_HEADER_SIZE 19
563#define BGP_MAX_PACKET_SIZE 4096
564
565/* BGP minimum message size. */
566#define BGP_MSG_OPEN_MIN_SIZE (BGP_HEADER_SIZE + 10)
567#define BGP_MSG_UPDATE_MIN_SIZE (BGP_HEADER_SIZE + 4)
568#define BGP_MSG_NOTIFY_MIN_SIZE (BGP_HEADER_SIZE + 2)
569#define BGP_MSG_KEEPALIVE_MIN_SIZE (BGP_HEADER_SIZE + 0)
570#define BGP_MSG_ROUTE_REFRESH_MIN_SIZE (BGP_HEADER_SIZE + 4)
571#define BGP_MSG_CAPABILITY_MIN_SIZE (BGP_HEADER_SIZE + 3)
572
573/* BGP message types. */
574#define BGP_MSG_OPEN 1
575#define BGP_MSG_UPDATE 2
576#define BGP_MSG_NOTIFY 3
577#define BGP_MSG_KEEPALIVE 4
578#define BGP_MSG_ROUTE_REFRESH_NEW 5
579#define BGP_MSG_CAPABILITY 6
580#define BGP_MSG_ROUTE_REFRESH_OLD 128
581
582/* BGP open optional parameter. */
583#define BGP_OPEN_OPT_AUTH 1
584#define BGP_OPEN_OPT_CAP 2
585
586/* BGP4 attribute type codes. */
587#define BGP_ATTR_ORIGIN 1
588#define BGP_ATTR_AS_PATH 2
589#define BGP_ATTR_NEXT_HOP 3
590#define BGP_ATTR_MULTI_EXIT_DISC 4
591#define BGP_ATTR_LOCAL_PREF 5
592#define BGP_ATTR_ATOMIC_AGGREGATE 6
593#define BGP_ATTR_AGGREGATOR 7
594#define BGP_ATTR_COMMUNITIES 8
595#define BGP_ATTR_ORIGINATOR_ID 9
596#define BGP_ATTR_CLUSTER_LIST 10
597#define BGP_ATTR_DPA 11
598#define BGP_ATTR_ADVERTISER 12
599#define BGP_ATTR_RCID_PATH 13
600#define BGP_ATTR_MP_REACH_NLRI 14
601#define BGP_ATTR_MP_UNREACH_NLRI 15
602#define BGP_ATTR_EXT_COMMUNITIES 16
0b2aa3a0
PJ
603#define BGP_ATTR_AS4_PATH 17
604#define BGP_ATTR_AS4_AGGREGATOR 18
41367172 605#define BGP_ATTR_AS_PATHLIMIT 21
718e3744 606
607/* BGP update origin. */
608#define BGP_ORIGIN_IGP 0
609#define BGP_ORIGIN_EGP 1
610#define BGP_ORIGIN_INCOMPLETE 2
611
612/* BGP notify message codes. */
613#define BGP_NOTIFY_HEADER_ERR 1
614#define BGP_NOTIFY_OPEN_ERR 2
615#define BGP_NOTIFY_UPDATE_ERR 3
616#define BGP_NOTIFY_HOLD_ERR 4
617#define BGP_NOTIFY_FSM_ERR 5
618#define BGP_NOTIFY_CEASE 6
619#define BGP_NOTIFY_CAPABILITY_ERR 7
620#define BGP_NOTIFY_MAX 8
621
622/* BGP_NOTIFY_HEADER_ERR sub codes. */
623#define BGP_NOTIFY_HEADER_NOT_SYNC 1
624#define BGP_NOTIFY_HEADER_BAD_MESLEN 2
625#define BGP_NOTIFY_HEADER_BAD_MESTYPE 3
626#define BGP_NOTIFY_HEADER_MAX 4
627
628/* BGP_NOTIFY_OPEN_ERR sub codes. */
629#define BGP_NOTIFY_OPEN_UNSUP_VERSION 1
630#define BGP_NOTIFY_OPEN_BAD_PEER_AS 2
631#define BGP_NOTIFY_OPEN_BAD_BGP_IDENT 3
632#define BGP_NOTIFY_OPEN_UNSUP_PARAM 4
633#define BGP_NOTIFY_OPEN_AUTH_FAILURE 5
634#define BGP_NOTIFY_OPEN_UNACEP_HOLDTIME 6
635#define BGP_NOTIFY_OPEN_UNSUP_CAPBL 7
636#define BGP_NOTIFY_OPEN_MAX 8
637
638/* BGP_NOTIFY_UPDATE_ERR sub codes. */
639#define BGP_NOTIFY_UPDATE_MAL_ATTR 1
640#define BGP_NOTIFY_UPDATE_UNREC_ATTR 2
641#define BGP_NOTIFY_UPDATE_MISS_ATTR 3
642#define BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR 4
643#define BGP_NOTIFY_UPDATE_ATTR_LENG_ERR 5
644#define BGP_NOTIFY_UPDATE_INVAL_ORIGIN 6
645#define BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP 7
646#define BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP 8
647#define BGP_NOTIFY_UPDATE_OPT_ATTR_ERR 9
648#define BGP_NOTIFY_UPDATE_INVAL_NETWORK 10
649#define BGP_NOTIFY_UPDATE_MAL_AS_PATH 11
650#define BGP_NOTIFY_UPDATE_MAX 12
651
545acafb 652/* BGP_NOTIFY_CEASE sub codes (draft-ietf-idr-cease-subcode-05). */
718e3744 653#define BGP_NOTIFY_CEASE_MAX_PREFIX 1
654#define BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN 2
655#define BGP_NOTIFY_CEASE_PEER_UNCONFIG 3
656#define BGP_NOTIFY_CEASE_ADMIN_RESET 4
657#define BGP_NOTIFY_CEASE_CONNECT_REJECT 5
658#define BGP_NOTIFY_CEASE_CONFIG_CHANGE 6
545acafb 659#define BGP_NOTIFY_CEASE_COLLISION_RESOLUTION 7
660#define BGP_NOTIFY_CEASE_OUT_OF_RESOURCE 8
661#define BGP_NOTIFY_CEASE_MAX 9
718e3744 662
663/* BGP_NOTIFY_CAPABILITY_ERR sub codes (draft-ietf-idr-dynamic-cap-02). */
664#define BGP_NOTIFY_CAPABILITY_INVALID_ACTION 1
665#define BGP_NOTIFY_CAPABILITY_INVALID_LENGTH 2
666#define BGP_NOTIFY_CAPABILITY_MALFORMED_CODE 3
667#define BGP_NOTIFY_CAPABILITY_MAX 4
668
669/* BGP finite state machine status. */
670#define Idle 1
671#define Connect 2
672#define Active 3
673#define OpenSent 4
674#define OpenConfirm 5
675#define Established 6
ca058a30
PJ
676#define Clearing 7
677#define Deleted 8
678#define BGP_STATUS_MAX 9
718e3744 679
680/* BGP finite state machine events. */
681#define BGP_Start 1
682#define BGP_Stop 2
683#define TCP_connection_open 3
684#define TCP_connection_closed 4
685#define TCP_connection_open_failed 5
686#define TCP_fatal_error 6
687#define ConnectRetry_timer_expired 7
688#define Hold_Timer_expired 8
689#define KeepAlive_timer_expired 9
690#define Receive_OPEN_message 10
691#define Receive_KEEPALIVE_message 11
692#define Receive_UPDATE_message 12
693#define Receive_NOTIFICATION_message 13
ca058a30
PJ
694#define Clearing_Completed 14
695#define BGP_EVENTS_MAX 15
718e3744 696
697/* BGP timers default value. */
698#define BGP_INIT_START_TIMER 5
699#define BGP_ERROR_START_TIMER 30
700#define BGP_DEFAULT_HOLDTIME 180
701#define BGP_DEFAULT_KEEPALIVE 60
702#define BGP_DEFAULT_ASORIGINATE 15
703#define BGP_DEFAULT_EBGP_ROUTEADV 30
704#define BGP_DEFAULT_IBGP_ROUTEADV 5
705#define BGP_CLEAR_CONNECT_RETRY 20
706#define BGP_DEFAULT_CONNECT_RETRY 120
707
708/* BGP default local preference. */
709#define BGP_DEFAULT_LOCAL_PREF 100
710
538621f2 711/* BGP graceful restart */
712#define BGP_DEFAULT_RESTART_TIME 120
713#define BGP_DEFAULT_STALEPATH_TIME 360
714
718e3744 715/* SAFI which used in open capability negotiation. */
716#define BGP_SAFI_VPNV4 128
717#define BGP_SAFI_VPNV6 129
718
719/* Max TTL value. */
720#define TTL_MAX 255
721
722/* BGP uptime string length. */
723#define BGP_UPTIME_LEN 25
724
725/* Default configuration settings for bgpd. */
726#define BGP_VTY_PORT 2605
718e3744 727#define BGP_DEFAULT_CONFIG "bgpd.conf"
728
729/* Check AS path loop when we send NLRI. */
730/* #define BGP_SEND_ASPATH_CHECK */
731
732/* IBGP/EBGP identifier. We also have a CONFED peer, which is to say,
733 a peer who's AS is part of our Confederation. */
734enum
735{
736 BGP_PEER_IBGP,
737 BGP_PEER_EBGP,
738 BGP_PEER_INTERNAL,
739 BGP_PEER_CONFED
740};
741
742/* Flag for peer_clear_soft(). */
743enum bgp_clear_type
744{
745 BGP_CLEAR_SOFT_NONE,
746 BGP_CLEAR_SOFT_OUT,
747 BGP_CLEAR_SOFT_IN,
748 BGP_CLEAR_SOFT_BOTH,
fee0f4c6 749 BGP_CLEAR_SOFT_IN_ORF_PREFIX,
750 BGP_CLEAR_SOFT_RSCLIENT
718e3744 751};
752
753/* Macros. */
754#define BGP_INPUT(P) ((P)->ibuf)
755#define BGP_INPUT_PNT(P) (STREAM_PNT(BGP_INPUT(P)))
756
718e3744 757/* Count prefix size from mask length */
758#define PSIZE(a) (((a) + 7) / (8))
759
760/* BGP error codes. */
761#define BGP_SUCCESS 0
762#define BGP_ERR_INVALID_VALUE -1
763#define BGP_ERR_INVALID_FLAG -2
764#define BGP_ERR_INVALID_AS -3
765#define BGP_ERR_INVALID_BGP -4
766#define BGP_ERR_PEER_GROUP_MEMBER -5
767#define BGP_ERR_MULTIPLE_INSTANCE_USED -6
768#define BGP_ERR_PEER_GROUP_MEMBER_EXISTS -7
769#define BGP_ERR_PEER_BELONGS_TO_GROUP -8
770#define BGP_ERR_PEER_GROUP_AF_UNCONFIGURED -9
771#define BGP_ERR_PEER_GROUP_NO_REMOTE_AS -10
772#define BGP_ERR_PEER_GROUP_CANT_CHANGE -11
773#define BGP_ERR_PEER_GROUP_MISMATCH -12
774#define BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT -13
775#define BGP_ERR_MULTIPLE_INSTANCE_NOT_SET -14
776#define BGP_ERR_AS_MISMATCH -15
777#define BGP_ERR_PEER_INACTIVE -16
778#define BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER -17
779#define BGP_ERR_PEER_GROUP_HAS_THE_FLAG -18
780#define BGP_ERR_PEER_FLAG_CONFLICT -19
781#define BGP_ERR_PEER_GROUP_SHUTDOWN -20
782#define BGP_ERR_PEER_FILTER_CONFLICT -21
783#define BGP_ERR_NOT_INTERNAL_PEER -22
784#define BGP_ERR_REMOVE_PRIVATE_AS -23
785#define BGP_ERR_AF_UNCONFIGURED -24
786#define BGP_ERR_SOFT_RECONFIG_UNCONFIGURED -25
787#define BGP_ERR_INSTANCE_MISMATCH -26
788#define BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP -27
789#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS -28
790#define BGP_ERR_MAX -29
791
792extern struct bgp_master *bm;
793
794extern struct thread_master *master;
795
796/* Prototypes. */
94f2b392 797extern void bgp_terminate (void);
798extern void bgp_reset (void);
799extern void bgp_zclient_reset (void);
800extern int bgp_nexthop_set (union sockunion *, union sockunion *,
718e3744 801 struct bgp_nexthop *, struct peer *);
94f2b392 802extern struct bgp *bgp_get_default (void);
803extern struct bgp *bgp_lookup (as_t, const char *);
804extern struct bgp *bgp_lookup_by_name (const char *);
805extern struct peer *peer_lookup (struct bgp *, union sockunion *);
806extern struct peer_group *peer_group_lookup (struct bgp *, const char *);
807extern struct peer_group *peer_group_get (struct bgp *, const char *);
808extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *,
718e3744 809 int *);
200df115 810extern struct peer *peer_lock (struct peer *);
811extern struct peer *peer_unlock (struct peer *);
94f2b392 812extern int peer_sort (struct peer *peer);
813extern int peer_active (struct peer *);
814extern int peer_active_nego (struct peer *);
815extern struct peer *peer_create_accept (struct bgp *);
816extern char *peer_uptime (time_t, char *, size_t);
817extern int bgp_config_write (struct vty *);
818extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *);
718e3744 819\f
94f2b392 820extern void bgp_master_init (void);
718e3744 821
94f2b392 822extern void bgp_init (void);
823extern void bgp_route_map_init (void);
718e3744 824
94f2b392 825extern int bgp_option_set (int);
826extern int bgp_option_unset (int);
827extern int bgp_option_check (int);
718e3744 828
94f2b392 829extern int bgp_get (struct bgp **, as_t *, const char *);
830extern int bgp_delete (struct bgp *);
718e3744 831
94f2b392 832extern int bgp_flag_set (struct bgp *, int);
833extern int bgp_flag_unset (struct bgp *, int);
834extern int bgp_flag_check (struct bgp *, int);
718e3744 835
94f2b392 836extern int bgp_router_id_set (struct bgp *, struct in_addr *);
718e3744 837
94f2b392 838extern int bgp_cluster_id_set (struct bgp *, struct in_addr *);
839extern int bgp_cluster_id_unset (struct bgp *);
718e3744 840
94f2b392 841extern int bgp_confederation_id_set (struct bgp *, as_t);
842extern int bgp_confederation_id_unset (struct bgp *);
843extern int bgp_confederation_peers_check (struct bgp *, as_t);
718e3744 844
94f2b392 845extern int bgp_confederation_peers_add (struct bgp *, as_t);
846extern int bgp_confederation_peers_remove (struct bgp *, as_t);
718e3744 847
94f2b392 848extern int bgp_timers_set (struct bgp *, u_int32_t, u_int32_t);
849extern int bgp_timers_unset (struct bgp *);
718e3744 850
94f2b392 851extern int bgp_default_local_preference_set (struct bgp *, u_int32_t);
852extern int bgp_default_local_preference_unset (struct bgp *);
718e3744 853
94f2b392 854extern int peer_rsclient_active (struct peer *);
fee0f4c6 855
94f2b392 856extern int peer_remote_as (struct bgp *, union sockunion *, as_t *, afi_t, safi_t);
857extern int peer_group_remote_as (struct bgp *, const char *, as_t *);
858extern int peer_delete (struct peer *peer);
859extern int peer_group_delete (struct peer_group *);
860extern int peer_group_remote_as_delete (struct peer_group *);
718e3744 861
94f2b392 862extern int peer_activate (struct peer *, afi_t, safi_t);
863extern int peer_deactivate (struct peer *, afi_t, safi_t);
718e3744 864
94f2b392 865extern int peer_group_bind (struct bgp *, union sockunion *, struct peer_group *,
718e3744 866 afi_t, safi_t, as_t *);
94f2b392 867extern int peer_group_unbind (struct bgp *, struct peer *, struct peer_group *,
718e3744 868 afi_t, safi_t);
869
94f2b392 870extern int peer_flag_set (struct peer *, u_int32_t);
871extern int peer_flag_unset (struct peer *, u_int32_t);
718e3744 872
94f2b392 873extern int peer_af_flag_set (struct peer *, afi_t, safi_t, u_int32_t);
874extern int peer_af_flag_unset (struct peer *, afi_t, safi_t, u_int32_t);
875extern int peer_af_flag_check (struct peer *, afi_t, safi_t, u_int32_t);
718e3744 876
94f2b392 877extern int peer_ebgp_multihop_set (struct peer *, int);
878extern int peer_ebgp_multihop_unset (struct peer *);
718e3744 879
94f2b392 880extern int peer_description_set (struct peer *, char *);
881extern int peer_description_unset (struct peer *);
718e3744 882
94f2b392 883extern int peer_update_source_if_set (struct peer *, const char *);
884extern int peer_update_source_addr_set (struct peer *, union sockunion *);
885extern int peer_update_source_unset (struct peer *);
718e3744 886
94f2b392 887extern int peer_default_originate_set (struct peer *, afi_t, safi_t, const char *);
888extern int peer_default_originate_unset (struct peer *, afi_t, safi_t);
718e3744 889
94f2b392 890extern int peer_port_set (struct peer *, u_int16_t);
891extern int peer_port_unset (struct peer *);
718e3744 892
94f2b392 893extern int peer_weight_set (struct peer *, u_int16_t);
894extern int peer_weight_unset (struct peer *);
718e3744 895
94f2b392 896extern int peer_timers_set (struct peer *, u_int32_t, u_int32_t);
897extern int peer_timers_unset (struct peer *);
718e3744 898
94f2b392 899extern int peer_timers_connect_set (struct peer *, u_int32_t);
900extern int peer_timers_connect_unset (struct peer *);
718e3744 901
94f2b392 902extern int peer_advertise_interval_set (struct peer *, u_int32_t);
903extern int peer_advertise_interval_unset (struct peer *);
718e3744 904
94f2b392 905extern int peer_interface_set (struct peer *, const char *);
906extern int peer_interface_unset (struct peer *);
718e3744 907
94f2b392 908extern int peer_distribute_set (struct peer *, afi_t, safi_t, int, const char *);
909extern int peer_distribute_unset (struct peer *, afi_t, safi_t, int);
718e3744 910
94f2b392 911extern int peer_allowas_in_set (struct peer *, afi_t, safi_t, int);
912extern int peer_allowas_in_unset (struct peer *, afi_t, safi_t);
718e3744 913
94f2b392 914extern int peer_local_as_set (struct peer *, as_t, int);
915extern int peer_local_as_unset (struct peer *);
718e3744 916
94f2b392 917extern int peer_prefix_list_set (struct peer *, afi_t, safi_t, int, const char *);
918extern int peer_prefix_list_unset (struct peer *, afi_t, safi_t, int);
718e3744 919
94f2b392 920extern int peer_aslist_set (struct peer *, afi_t, safi_t, int, const char *);
921extern int peer_aslist_unset (struct peer *,afi_t, safi_t, int);
718e3744 922
94f2b392 923extern int peer_route_map_set (struct peer *, afi_t, safi_t, int, const char *);
924extern int peer_route_map_unset (struct peer *, afi_t, safi_t, int);
718e3744 925
94f2b392 926extern int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, const char *);
927extern int peer_unsuppress_map_unset (struct peer *, afi_t, safi_t);
718e3744 928
94f2b392 929extern int peer_maximum_prefix_set (struct peer *, afi_t, safi_t, u_int32_t, u_char, int, u_int16_t);
930extern int peer_maximum_prefix_unset (struct peer *, afi_t, safi_t);
718e3744 931
94f2b392 932extern int peer_clear (struct peer *);
933extern int peer_clear_soft (struct peer *, afi_t, safi_t, enum bgp_clear_type);
93406d87 934
94f2b392 935extern void peer_nsf_stop (struct peer *);
00d252cb 936
937#endif /* _QUAGGA_BGPD_H */