]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_open.h
Merge pull request #12830 from anlancs/fix/doc-ripd-rst
[mirror_frr.git] / bgpd / bgp_open.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* BGP open message handling
3 * Copyright (C) 1999 Kunihiro Ishiguro
4 */
5
6 #ifndef _QUAGGA_BGP_OPEN_H
7 #define _QUAGGA_BGP_OPEN_H
8
9 /* Standard header for capability TLV */
10 struct capability_header {
11 uint8_t code;
12 uint8_t length;
13 };
14
15 /* Generic MP capability data */
16 struct capability_mp_data {
17 uint16_t afi; /* iana_afi_t */
18 uint8_t reserved;
19 uint8_t safi; /* iana_safi_t */
20 };
21
22 struct graceful_restart_af {
23 afi_t afi;
24 safi_t safi;
25 uint8_t flag;
26 };
27
28 /* Capability Code */
29 #define CAPABILITY_CODE_MP 1 /* Multiprotocol Extensions */
30 #define CAPABILITY_CODE_REFRESH 2 /* Route Refresh Capability */
31 #define CAPABILITY_CODE_ORF 3 /* Cooperative Route Filtering Capability */
32 #define CAPABILITY_CODE_RESTART 64 /* Graceful Restart Capability */
33 #define CAPABILITY_CODE_AS4 65 /* 4-octet AS number Capability */
34 #define CAPABILITY_CODE_DYNAMIC_OLD 66 /* Dynamic Capability, deprecated since 2003 */
35 #define CAPABILITY_CODE_DYNAMIC 67 /* Dynamic Capability */
36 #define CAPABILITY_CODE_ADDPATH 69 /* Addpath Capability */
37 #define CAPABILITY_CODE_ENHANCED_RR 70 /* Enhanced Route Refresh capability */
38 #define CAPABILITY_CODE_LLGR 71 /* Long-lived Graceful Restart */
39 #define CAPABILITY_CODE_FQDN 73 /* Advertise hostname capability */
40 #define CAPABILITY_CODE_SOFT_VERSION 75 /* Software Version capability */
41 #define CAPABILITY_CODE_ENHE 5 /* Extended Next Hop Encoding */
42 #define CAPABILITY_CODE_REFRESH_OLD 128 /* Route Refresh Capability(cisco) */
43 #define CAPABILITY_CODE_ORF_OLD 130 /* Cooperative Route Filtering Capability(cisco) */
44 #define CAPABILITY_CODE_EXT_MESSAGE 6 /* Extended Message Support */
45 #define CAPABILITY_CODE_ROLE 9 /* Role Capability */
46
47 /* Capability Length */
48 #define CAPABILITY_CODE_MP_LEN 4
49 #define CAPABILITY_CODE_REFRESH_LEN 0
50 #define CAPABILITY_CODE_DYNAMIC_LEN 0
51 #define CAPABILITY_CODE_RESTART_LEN 2 /* Receiving only case */
52 #define CAPABILITY_CODE_AS4_LEN 4
53 #define CAPABILITY_CODE_ADDPATH_LEN 4
54 #define CAPABILITY_CODE_ENHE_LEN 6 /* NRLI AFI = 2, SAFI = 2, Nexthop AFI = 2 */
55 #define CAPABILITY_CODE_MIN_FQDN_LEN 2
56 #define CAPABILITY_CODE_ENHANCED_LEN 0
57 #define CAPABILITY_CODE_LLGR_LEN 0
58 #define CAPABILITY_CODE_ORF_LEN 5
59 #define CAPABILITY_CODE_EXT_MESSAGE_LEN 0 /* Extended Message Support */
60 #define CAPABILITY_CODE_ROLE_LEN 1
61 #define CAPABILITY_CODE_SOFT_VERSION_LEN 1
62
63 /* Cooperative Route Filtering Capability. */
64
65 /* ORF Type */
66 #define ORF_TYPE_RESERVED 0
67 #define ORF_TYPE_PREFIX 64
68 #define ORF_TYPE_PREFIX_OLD 128
69
70 /* ORF Mode */
71 #define ORF_MODE_RECEIVE 1
72 #define ORF_MODE_SEND 2
73 #define ORF_MODE_BOTH 3
74
75 /* Capability Message Action. */
76 #define CAPABILITY_ACTION_SET 0
77 #define CAPABILITY_ACTION_UNSET 1
78
79 /* Graceful Restart */
80 #define GRACEFUL_RESTART_R_BIT 0x8000
81 #define GRACEFUL_RESTART_N_BIT 0x4000
82 #define GRACEFUL_RESTART_F_BIT 0x80
83
84 /* Long-lived Graceful Restart */
85 #define LLGR_F_BIT 0x80
86
87 /* Optional Parameters */
88 #define BGP_OPEN_NON_EXT_OPT_LEN 255 /* Non-Ext OP Len. */
89 #define BGP_OPEN_NON_EXT_OPT_TYPE_EXTENDED_LENGTH 255 /* Non-Ext OP Type */
90 #define BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(peer) \
91 (CHECK_FLAG(peer->flags, PEER_FLAG_EXTENDED_OPT_PARAMS) \
92 || CHECK_FLAG(peer->sflags, PEER_STATUS_EXT_OPT_PARAMS_LENGTH))
93
94 extern int bgp_open_option_parse(struct peer *peer, uint16_t length,
95 int *mp_capability);
96 extern uint16_t bgp_open_capability(struct stream *s, struct peer *peer,
97 bool ext_opt_params);
98 extern void bgp_capability_vty_out(struct vty *vty, struct peer *peer,
99 bool use_json, json_object *json_neigh);
100 extern as_t peek_for_as4_capability(struct peer *peer, uint16_t length);
101
102 #endif /* _QUAGGA_BGP_OPEN_H */