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