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