1 /* $OpenBSD: bgpd.h,v 1.245 2009/09/04 11:50:28 claudio Exp $ */ 2 3 /* 4 * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 #ifndef __BGPD_H__ 19 #define __BGPD_H__ 20 21 #include <sys/types.h> 22 #include <sys/socket.h> 23 #include <sys/queue.h> 24 #include <net/route.h> 25 #include <netinet/in.h> 26 #include <arpa/inet.h> 27 #include <net/if.h> 28 #include <net/pfkeyv2.h> 29 30 #include <poll.h> 31 #include <stdarg.h> 32 33 #include <imsg.h> 34 35 #define BGP_VERSION 4 36 #define BGP_PORT 179 37 #define CONFFILE "/etc/bgpd.conf" 38 #define BGPD_USER "_bgpd" 39 #define PEER_DESCR_LEN 32 40 #define PFTABLE_LEN 16 41 #define TCP_MD5_KEY_LEN 80 42 #define IPSEC_ENC_KEY_LEN 32 43 #define IPSEC_AUTH_KEY_LEN 20 44 45 #define MAX_PKTSIZE 4096 46 #define MIN_HOLDTIME 3 47 #define READ_BUF_SIZE 65535 48 #define RT_BUF_SIZE 16384 49 #define MAX_RTSOCK_BUF 128 * 1024 50 51 #define BGPD_OPT_VERBOSE 0x0001 52 #define BGPD_OPT_VERBOSE2 0x0002 53 #define BGPD_OPT_NOACTION 0x0004 54 #define BGPD_OPT_FORCE_DEMOTE 0x0008 55 56 #define BGPD_FLAG_NO_FIB_UPDATE 0x0001 57 #define BGPD_FLAG_NO_EVALUATE 0x0002 58 #define BGPD_FLAG_REFLECTOR 0x0004 59 #define BGPD_FLAG_REDIST_STATIC 0x0008 60 #define BGPD_FLAG_REDIST_CONNECTED 0x0010 61 #define BGPD_FLAG_REDIST6_STATIC 0x0020 62 #define BGPD_FLAG_REDIST6_CONNECTED 0x0040 63 #define BGPD_FLAG_NEXTHOP_BGP 0x0080 64 #define BGPD_FLAG_NEXTHOP_DEFAULT 0x1000 65 #define BGPD_FLAG_DECISION_MASK 0x0f00 66 #define BGPD_FLAG_DECISION_ROUTEAGE 0x0100 67 #define BGPD_FLAG_DECISION_TRANS_AS 0x0200 68 #define BGPD_FLAG_DECISION_MED_ALWAYS 0x0400 69 70 #define BGPD_LOG_UPDATES 0x0001 71 72 #define SOCKET_NAME "/var/run/bgpd.sock" 73 74 #define F_BGPD_INSERTED 0x0001 75 #define F_KERNEL 0x0002 76 #define F_CONNECTED 0x0004 77 #define F_NEXTHOP 0x0008 78 #define F_DOWN 0x0010 79 #define F_STATIC 0x0020 80 #define F_DYNAMIC 0x0040 81 #define F_REJECT 0x0080 82 #define F_BLACKHOLE 0x0100 83 #define F_LONGER 0x0200 84 #define F_CTL_DETAIL 0x1000 /* only used by bgpctl */ 85 #define F_CTL_ADJ_IN 0x2000 86 #define F_CTL_ADJ_OUT 0x4000 87 88 /* 89 * Limit the number of control messages generated by the RDE and queued in 90 * session engine. The RDE limit defines how many imsg are generated in 91 * one poll round. Then if the SE limit is hit the RDE control socket will no 92 * longer be polled. 93 */ 94 #define RDE_RUNNER_ROUNDS 100 95 #define SESSION_CTL_QUEUE_MAX 10000 96 97 enum { 98 PROC_MAIN, 99 PROC_SE, 100 PROC_RDE 101 } bgpd_process; 102 103 enum reconf_action { 104 RECONF_NONE, 105 RECONF_KEEP, 106 RECONF_REINIT, 107 RECONF_DELETE 108 }; 109 110 struct bgpd_addr { 111 sa_family_t af; 112 union { 113 struct in_addr v4; 114 struct in6_addr v6; 115 u_int8_t addr8[16]; 116 u_int16_t addr16[8]; 117 u_int32_t addr32[4]; 118 } ba; /* 128-bit address */ 119 u_int32_t scope_id; /* iface scope id for v6 */ 120 #define v4 ba.v4 121 #define v6 ba.v6 122 #define addr8 ba.addr8 123 #define addr16 ba.addr16 124 #define addr32 ba.addr32 125 }; 126 127 #define DEFAULT_LISTENER 0x01 128 #define LISTENER_LISTENING 0x02 129 130 struct listen_addr { 131 TAILQ_ENTRY(listen_addr) entry; 132 struct sockaddr_storage sa; 133 int fd; 134 enum reconf_action reconf; 135 u_int8_t flags; 136 }; 137 138 TAILQ_HEAD(listen_addrs, listen_addr); 139 TAILQ_HEAD(filter_set_head, filter_set); 140 141 struct bgpd_config { 142 struct filter_set_head connectset; 143 struct filter_set_head connectset6; 144 struct filter_set_head staticset; 145 struct filter_set_head staticset6; 146 struct listen_addrs *listen_addrs; 147 char *csock; 148 char *rcsock; 149 int opts; 150 int flags; 151 int log; 152 u_int rtableid; 153 u_int32_t bgpid; 154 u_int32_t clusterid; 155 u_int32_t as; 156 u_int16_t short_as; 157 u_int16_t holdtime; 158 u_int16_t min_holdtime; 159 u_int16_t connectretry; 160 }; 161 162 enum announce_type { 163 ANNOUNCE_UNDEF, 164 ANNOUNCE_SELF, 165 ANNOUNCE_NONE, 166 ANNOUNCE_DEFAULT_ROUTE, 167 ANNOUNCE_ALL 168 }; 169 170 enum enforce_as { 171 ENFORCE_AS_UNDEF, 172 ENFORCE_AS_OFF, 173 ENFORCE_AS_ON 174 }; 175 176 enum auth_method { 177 AUTH_NONE, 178 AUTH_MD5SIG, 179 AUTH_IPSEC_MANUAL_ESP, 180 AUTH_IPSEC_MANUAL_AH, 181 AUTH_IPSEC_IKE_ESP, 182 AUTH_IPSEC_IKE_AH 183 }; 184 185 struct peer_auth { 186 char md5key[TCP_MD5_KEY_LEN]; 187 char auth_key_in[IPSEC_AUTH_KEY_LEN]; 188 char auth_key_out[IPSEC_AUTH_KEY_LEN]; 189 char enc_key_in[IPSEC_ENC_KEY_LEN]; 190 char enc_key_out[IPSEC_ENC_KEY_LEN]; 191 u_int32_t spi_in; 192 u_int32_t spi_out; 193 enum auth_method method; 194 u_int8_t md5key_len; 195 u_int8_t auth_alg_in; 196 u_int8_t auth_alg_out; 197 u_int8_t auth_keylen_in; 198 u_int8_t auth_keylen_out; 199 u_int8_t enc_alg_in; 200 u_int8_t enc_alg_out; 201 u_int8_t enc_keylen_in; 202 u_int8_t enc_keylen_out; 203 }; 204 205 struct capabilities { 206 u_int8_t mp_v4; /* multiprotocol extensions, RFC 4760 */ 207 u_int8_t mp_v6; 208 u_int8_t refresh; /* route refresh, RFC 2918 */ 209 u_int8_t restart; /* graceful restart, RFC 4724 */ 210 u_int8_t as4byte; /* draft-ietf-idr-as4bytes-13 */ 211 }; 212 213 struct peer_config { 214 struct bgpd_addr remote_addr; 215 struct bgpd_addr local_addr; 216 struct peer_auth auth; 217 struct capabilities capabilities; 218 char group[PEER_DESCR_LEN]; 219 char descr[PEER_DESCR_LEN]; 220 char rib[PEER_DESCR_LEN]; 221 char if_depend[IFNAMSIZ]; 222 char demote_group[IFNAMSIZ]; 223 u_int32_t id; 224 u_int32_t groupid; 225 u_int32_t remote_as; 226 u_int32_t local_as; 227 u_int32_t max_prefix; 228 enum announce_type announce_type; 229 enum enforce_as enforce_as; 230 enum reconf_action reconf_action; 231 u_int16_t max_prefix_restart; 232 u_int16_t holdtime; 233 u_int16_t min_holdtime; 234 u_int16_t local_short_as; 235 u_int8_t template; 236 u_int8_t remote_masklen; 237 u_int8_t cloned; 238 u_int8_t ebgp; /* 1 = ebgp, 0 = ibgp */ 239 u_int8_t distance; /* 1 = direct, >1 = multihop */ 240 u_int8_t passive; 241 u_int8_t down; 242 u_int8_t announce_capa; 243 u_int8_t reflector_client; 244 u_int8_t softreconfig_in; 245 u_int8_t softreconfig_out; 246 u_int8_t ttlsec; /* TTL security hack */ 247 u_int8_t flags; 248 u_int8_t pad[3]; 249 }; 250 251 #define PEERFLAG_TRANS_AS 0x01 252 253 struct network_config { 254 struct bgpd_addr prefix; 255 struct filter_set_head attrset; 256 u_int8_t prefixlen; 257 }; 258 259 TAILQ_HEAD(network_head, network); 260 261 struct network { 262 struct network_config net; 263 TAILQ_ENTRY(network) entry; 264 }; 265 266 enum imsg_type { 267 IMSG_NONE, 268 IMSG_CTL_END, 269 IMSG_CTL_RELOAD, 270 IMSG_CTL_FIB_COUPLE, 271 IMSG_CTL_FIB_DECOUPLE, 272 IMSG_CTL_NEIGHBOR_UP, 273 IMSG_CTL_NEIGHBOR_DOWN, 274 IMSG_CTL_NEIGHBOR_CLEAR, 275 IMSG_CTL_NEIGHBOR_RREFRESH, 276 IMSG_CTL_KROUTE, 277 IMSG_CTL_KROUTE6, 278 IMSG_CTL_KROUTE_ADDR, 279 IMSG_CTL_RESULT, 280 IMSG_CTL_SHOW_NEIGHBOR, 281 IMSG_CTL_SHOW_NEXTHOP, 282 IMSG_CTL_SHOW_INTERFACE, 283 IMSG_CTL_SHOW_RIB, 284 IMSG_CTL_SHOW_RIB_AS, 285 IMSG_CTL_SHOW_RIB_PREFIX, 286 IMSG_CTL_SHOW_RIB_ATTR, 287 IMSG_CTL_SHOW_RIB_COMMUNITY, 288 IMSG_CTL_SHOW_NETWORK, 289 IMSG_CTL_SHOW_NETWORK6, 290 IMSG_CTL_SHOW_RIB_MEM, 291 IMSG_CTL_SHOW_TERSE, 292 IMSG_CTL_SHOW_TIMER, 293 IMSG_NETWORK_ADD, 294 IMSG_NETWORK_REMOVE, 295 IMSG_NETWORK_FLUSH, 296 IMSG_NETWORK_DONE, 297 IMSG_FILTER_SET, 298 IMSG_RECONF_CONF, 299 IMSG_RECONF_RIB, 300 IMSG_RECONF_PEER, 301 IMSG_RECONF_FILTER, 302 IMSG_RECONF_LISTENER, 303 IMSG_RECONF_DONE, 304 IMSG_UPDATE, 305 IMSG_UPDATE_ERR, 306 IMSG_SESSION_ADD, 307 IMSG_SESSION_UP, 308 IMSG_SESSION_DOWN, 309 IMSG_MRT_OPEN, 310 IMSG_MRT_REOPEN, 311 IMSG_MRT_CLOSE, 312 IMSG_KROUTE_CHANGE, 313 IMSG_KROUTE_DELETE, 314 IMSG_KROUTE6_CHANGE, 315 IMSG_KROUTE6_DELETE, 316 IMSG_NEXTHOP_ADD, 317 IMSG_NEXTHOP_REMOVE, 318 IMSG_NEXTHOP_UPDATE, 319 IMSG_PFTABLE_ADD, 320 IMSG_PFTABLE_REMOVE, 321 IMSG_PFTABLE_COMMIT, 322 IMSG_REFRESH, 323 IMSG_IFINFO, 324 IMSG_DEMOTE 325 }; 326 327 struct demote_msg { 328 char demote_group[IFNAMSIZ]; 329 int level; 330 }; 331 332 enum ctl_results { 333 CTL_RES_OK, 334 CTL_RES_NOSUCHPEER, 335 CTL_RES_DENIED, 336 CTL_RES_NOCAP, 337 CTL_RES_PARSE_ERROR, 338 CTL_RES_NOMEM 339 }; 340 341 /* needed for session.h parse prototype */ 342 LIST_HEAD(mrt_head, mrt); 343 344 /* error codes and subcodes needed in SE and RDE */ 345 enum err_codes { 346 ERR_HEADER = 1, 347 ERR_OPEN, 348 ERR_UPDATE, 349 ERR_HOLDTIMEREXPIRED, 350 ERR_FSM, 351 ERR_CEASE 352 }; 353 354 enum suberr_update { 355 ERR_UPD_UNSPECIFIC, 356 ERR_UPD_ATTRLIST, 357 ERR_UPD_UNKNWN_WK_ATTR, 358 ERR_UPD_MISSNG_WK_ATTR, 359 ERR_UPD_ATTRFLAGS, 360 ERR_UPD_ATTRLEN, 361 ERR_UPD_ORIGIN, 362 ERR_UPD_LOOP, 363 ERR_UPD_NEXTHOP, 364 ERR_UPD_OPTATTR, 365 ERR_UPD_NETWORK, 366 ERR_UPD_ASPATH 367 }; 368 369 enum suberr_cease { 370 ERR_CEASE_MAX_PREFIX = 1, 371 ERR_CEASE_ADMIN_DOWN, 372 ERR_CEASE_PEER_UNCONF, 373 ERR_CEASE_ADMIN_RESET, 374 ERR_CEASE_CONN_REJECT, 375 ERR_CEASE_OTHER_CHANGE, 376 ERR_CEASE_COLLISION, 377 ERR_CEASE_RSRC_EXHAUST 378 }; 379 380 struct kroute { 381 struct in_addr prefix; 382 struct in_addr nexthop; 383 u_int16_t flags; 384 u_int16_t labelid; 385 u_short ifindex; 386 u_int8_t prefixlen; 387 u_int8_t priority; 388 }; 389 390 struct kroute6 { 391 struct in6_addr prefix; 392 struct in6_addr nexthop; 393 u_int16_t flags; 394 u_int16_t labelid; 395 u_short ifindex; 396 u_int8_t prefixlen; 397 u_int8_t priority; 398 }; 399 400 struct kroute_nexthop { 401 union { 402 struct kroute kr4; 403 struct kroute6 kr6; 404 } kr; 405 struct bgpd_addr nexthop; 406 struct bgpd_addr gateway; 407 u_int8_t valid; 408 u_int8_t connected; 409 }; 410 411 struct kif { 412 char ifname[IFNAMSIZ]; 413 u_int64_t baudrate; 414 int flags; 415 u_short ifindex; 416 u_int8_t media_type; 417 u_int8_t link_state; 418 u_int8_t nh_reachable; /* for nexthop verification */ 419 }; 420 421 struct session_up { 422 struct bgpd_addr local_addr; 423 struct bgpd_addr remote_addr; 424 struct capabilities capa_announced; 425 struct capabilities capa_received; 426 u_int32_t remote_bgpid; 427 u_int16_t short_as; 428 }; 429 430 struct pftable_msg { 431 struct bgpd_addr addr; 432 char pftable[PFTABLE_LEN]; 433 u_int8_t len; 434 }; 435 436 struct ctl_show_nexthop { 437 struct bgpd_addr addr; 438 struct kif kif; 439 union { 440 struct kroute kr4; 441 struct kroute6 kr6; 442 } kr; 443 u_int8_t valid; 444 u_int8_t krvalid;; 445 }; 446 447 struct ctl_neighbor { 448 struct bgpd_addr addr; 449 char descr[PEER_DESCR_LEN]; 450 int show_timers; 451 }; 452 453 struct kroute_label { 454 struct kroute kr; 455 char label[RTLABEL_LEN]; 456 }; 457 458 struct kroute6_label { 459 struct kroute6 kr; 460 char label[RTLABEL_LEN]; 461 }; 462 463 #define F_RIB_ELIGIBLE 0x01 464 #define F_RIB_ACTIVE 0x02 465 #define F_RIB_INTERNAL 0x04 466 #define F_RIB_ANNOUNCE 0x08 467 468 struct ctl_show_rib { 469 struct bgpd_addr true_nexthop; 470 struct bgpd_addr exit_nexthop; 471 struct bgpd_addr prefix; 472 struct bgpd_addr remote_addr; 473 char descr[PEER_DESCR_LEN]; 474 time_t lastchange; 475 u_int32_t remote_id; 476 u_int32_t local_pref; 477 u_int32_t med; 478 u_int32_t prefix_cnt; 479 u_int32_t active_cnt; 480 u_int32_t rib_cnt; 481 u_int16_t aspath_len; 482 u_int16_t flags; 483 u_int8_t prefixlen; 484 u_int8_t origin; 485 /* plus a aspath_len bytes long aspath */ 486 }; 487 488 struct ctl_show_rib_prefix { 489 struct bgpd_addr prefix; 490 time_t lastchange; 491 u_int16_t flags; 492 u_int8_t prefixlen; 493 }; 494 495 enum as_spec { 496 AS_NONE, 497 AS_ALL, 498 AS_SOURCE, 499 AS_TRANSIT, 500 AS_PEER, 501 AS_EMPTY 502 }; 503 504 struct filter_as { 505 enum as_spec type; 506 u_int32_t as; 507 }; 508 509 struct filter_community { 510 int as; 511 int type; 512 }; 513 514 struct ctl_show_rib_request { 515 char rib[PEER_DESCR_LEN]; 516 struct ctl_neighbor neighbor; 517 struct bgpd_addr prefix; 518 struct filter_as as; 519 struct filter_community community; 520 u_int32_t peerid; 521 pid_t pid; 522 u_int16_t flags; 523 enum imsg_type type; 524 sa_family_t af; 525 u_int8_t prefixlen; 526 }; 527 528 enum filter_actions { 529 ACTION_NONE, 530 ACTION_ALLOW, 531 ACTION_DENY 532 }; 533 534 enum directions { 535 DIR_IN = 1, 536 DIR_OUT 537 }; 538 539 enum from_spec { 540 FROM_ALL, 541 FROM_ADDRESS, 542 FROM_DESCR, 543 FROM_GROUP 544 }; 545 546 enum comp_ops { 547 OP_NONE, 548 OP_RANGE, 549 OP_XRANGE, 550 OP_EQ, 551 OP_NE, 552 OP_LE, 553 OP_LT, 554 OP_GE, 555 OP_GT 556 }; 557 558 struct filter_peers { 559 u_int32_t peerid; 560 u_int32_t groupid; 561 u_int16_t ribid; 562 }; 563 564 /* special community type */ 565 #define COMMUNITY_ERROR -1 566 #define COMMUNITY_ANY -2 567 #define COMMUNITY_NEIGHBOR_AS -3 568 #define COMMUNITY_UNSET -4 569 #define COMMUNITY_WELLKNOWN 0xffff 570 #define COMMUNITY_NO_EXPORT 0xff01 571 #define COMMUNITY_NO_ADVERTISE 0xff02 572 #define COMMUNITY_NO_EXPSUBCONFED 0xff03 573 #define COMMUNITY_NO_PEER 0xff04 /* RFC 3765 */ 574 575 /* extended community definitions */ 576 #define EXT_COMMUNITY_IANA 0x80 577 #define EXT_COMMUNITY_TRANSITIVE 0x40 578 #define EXT_COMMUNITY_VALUE 0x3f 579 /* extended types */ 580 #define EXT_COMMUNITY_TWO_AS 0 /* 2 octet AS specific */ 581 #define EXT_COMMUNITY_IPV4 1 /* IPv4 specific */ 582 #define EXT_COMMUNITY_FOUR_AS 2 /* 4 octet AS specific */ 583 #define EXT_COMMUNITY_OPAQUE 3 /* opaque ext community */ 584 /* sub types */ 585 #define EXT_COMMUNITY_ROUTE_TGT 2 /* RFC 4360 & RFC4364 */ 586 #define EXT_CUMMUNITY_ROUTE_ORIG 3 /* RFC 4360 & RFC4364 */ 587 #define EXT_COMMUNITY_OSPF_DOM_ID 5 /* RFC 4577 */ 588 #define EXT_COMMUNITY_OSPF_RTR_TYPE 6 /* RFC 4577 */ 589 #define EXT_COMMUNITY_OSPF_RTR_ID 7 /* RFC 4577 */ 590 #define EXT_COMMUNITY_BGP_COLLECT 8 /* RFC 4384 */ 591 592 593 struct filter_prefix { 594 struct bgpd_addr addr; 595 u_int8_t len; 596 }; 597 598 struct filter_prefixlen { 599 enum comp_ops op; 600 sa_family_t af; 601 u_int8_t len_min; 602 u_int8_t len_max; 603 }; 604 605 struct filter_match { 606 struct filter_prefix prefix; 607 struct filter_prefixlen prefixlen; 608 struct filter_as as; 609 struct filter_community community; 610 }; 611 612 TAILQ_HEAD(filter_head, filter_rule); 613 614 struct filter_rule { 615 TAILQ_ENTRY(filter_rule) entry; 616 char rib[PEER_DESCR_LEN]; 617 struct filter_peers peer; 618 struct filter_match match; 619 struct filter_set_head set; 620 enum filter_actions action; 621 enum directions dir; 622 u_int8_t quick; 623 }; 624 625 enum action_types { 626 ACTION_SET_LOCALPREF, 627 ACTION_SET_RELATIVE_LOCALPREF, 628 ACTION_SET_MED, 629 ACTION_SET_RELATIVE_MED, 630 ACTION_SET_WEIGHT, 631 ACTION_SET_RELATIVE_WEIGHT, 632 ACTION_SET_PREPEND_SELF, 633 ACTION_SET_PREPEND_PEER, 634 ACTION_SET_NEXTHOP, 635 ACTION_SET_NEXTHOP_REJECT, 636 ACTION_SET_NEXTHOP_BLACKHOLE, 637 ACTION_SET_NEXTHOP_NOMODIFY, 638 ACTION_SET_NEXTHOP_SELF, 639 ACTION_SET_COMMUNITY, 640 ACTION_DEL_COMMUNITY, 641 ACTION_PFTABLE, 642 ACTION_PFTABLE_ID, 643 ACTION_RTLABEL, 644 ACTION_RTLABEL_ID 645 }; 646 647 struct filter_set { 648 TAILQ_ENTRY(filter_set) entry; 649 union { 650 u_int8_t prepend; 651 u_int16_t id; 652 u_int32_t metric; 653 int32_t relative; 654 struct bgpd_addr nexthop; 655 struct filter_community community; 656 char pftable[PFTABLE_LEN]; 657 char rtlabel[RTLABEL_LEN]; 658 } action; 659 enum action_types type; 660 }; 661 662 struct rrefresh { 663 u_int16_t afi; 664 u_int8_t safi; 665 }; 666 667 struct rde_memstats { 668 int64_t path_cnt; 669 int64_t prefix_cnt; 670 int64_t rib_cnt; 671 int64_t pt4_cnt; 672 int64_t pt6_cnt; 673 int64_t nexthop_cnt; 674 int64_t aspath_cnt; 675 int64_t aspath_size; 676 int64_t aspath_refs; 677 int64_t attr_cnt; 678 int64_t attr_refs; 679 int64_t attr_data; 680 int64_t attr_dcnt; 681 }; 682 683 struct rde_rib { 684 SIMPLEQ_ENTRY(rde_rib) entry; 685 char name[PEER_DESCR_LEN]; 686 u_int16_t id; 687 u_int16_t flags; 688 }; 689 SIMPLEQ_HEAD(rib_names, rde_rib); 690 extern struct rib_names ribnames; 691 692 /* Address Family Numbers as per RFC 1700 */ 693 #define AFI_IPv4 1 694 #define AFI_IPv6 2 695 #define AFI_ALL 0xffff 696 697 /* Subsequent Address Family Identifier as per RFC 4760 */ 698 #define SAFI_NONE 0x00 699 #define SAFI_UNICAST 0x01 700 #define SAFI_MULTICAST 0x02 701 #define SAFI_MPLS 0x04 702 #define SAFI_ALL 0xff 703 704 /* 4-byte magic AS number */ 705 #define AS_TRANS 23456 706 707 /* prototypes */ 708 /* bgpd.c */ 709 void send_nexthop_update(struct kroute_nexthop *); 710 void send_imsg_session(int, pid_t, void *, u_int16_t); 711 int bgpd_redistribute(int, struct kroute *, struct kroute6 *); 712 int bgpd_filternexthop(struct kroute *, struct kroute6 *); 713 714 /* log.c */ 715 void log_init(int); 716 void vlog(int, const char *, va_list); 717 void log_peer_warn(const struct peer_config *, const char *, ...); 718 void log_peer_warnx(const struct peer_config *, const char *, ...); 719 void log_warn(const char *, ...); 720 void log_warnx(const char *, ...); 721 void log_info(const char *, ...); 722 void log_debug(const char *, ...); 723 void fatal(const char *) __dead; 724 void fatalx(const char *) __dead; 725 726 /* parse.y */ 727 int cmdline_symset(char *); 728 729 /* config.c */ 730 int host(const char *, struct bgpd_addr *, u_int8_t *); 731 732 /* kroute.c */ 733 int kr_init(int, u_int); 734 int kr_change(struct kroute_label *); 735 int kr_delete(struct kroute_label *); 736 int kr6_change(struct kroute6_label *); 737 int kr6_delete(struct kroute6_label *); 738 void kr_shutdown(void); 739 void kr_fib_couple(void); 740 void kr_fib_decouple(void); 741 int kr_dispatch_msg(void); 742 int kr_nexthop_add(struct bgpd_addr *); 743 void kr_nexthop_delete(struct bgpd_addr *); 744 void kr_show_route(struct imsg *); 745 void kr_ifinfo(char *); 746 int kr_reload(void); 747 struct in6_addr *prefixlen2mask6(u_int8_t prefixlen); 748 749 /* control.c */ 750 void control_cleanup(const char *); 751 int control_imsg_relay(struct imsg *); 752 753 /* pftable.c */ 754 int pftable_exists(const char *); 755 int pftable_add(const char *); 756 int pftable_clear_all(void); 757 int pftable_addr_add(struct pftable_msg *); 758 int pftable_addr_remove(struct pftable_msg *); 759 int pftable_commit(void); 760 761 /* name2id.c */ 762 u_int16_t rib_name2id(const char *); 763 const char *rib_id2name(u_int16_t); 764 void rib_unref(u_int16_t); 765 void rib_ref(u_int16_t); 766 u_int16_t rtlabel_name2id(const char *); 767 const char *rtlabel_id2name(u_int16_t); 768 void rtlabel_unref(u_int16_t); 769 void rtlabel_ref(u_int16_t); 770 u_int16_t pftable_name2id(const char *); 771 const char *pftable_id2name(u_int16_t); 772 void pftable_unref(u_int16_t); 773 void pftable_ref(u_int16_t); 774 775 776 /* rde_filter.c */ 777 void filterset_free(struct filter_set_head *); 778 int filterset_cmp(struct filter_set *, struct filter_set *); 779 const char *filterset_name(enum action_types); 780 781 /* util.c */ 782 const char *log_addr(const struct bgpd_addr *); 783 const char *log_in6addr(const struct in6_addr *); 784 const char *log_sockaddr(struct sockaddr *); 785 const char *log_as(u_int32_t); 786 int aspath_snprint(char *, size_t, void *, u_int16_t); 787 int aspath_asprint(char **, void *, u_int16_t); 788 size_t aspath_strlen(void *, u_int16_t); 789 in_addr_t prefixlen2mask(u_int8_t); 790 void inet6applymask(struct in6_addr *, const struct in6_addr *, 791 int); 792 793 #endif /* __BGPD_H__ */ 794