]>
Commit | Line | Data |
---|---|---|
d62a17ae | 1 | /* BGP attributes. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98 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 along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
00d252cb | 21 | #ifndef _QUAGGA_BGP_ATTR_H |
22 | #define _QUAGGA_BGP_ATTR_H | |
23 | ||
9bedbb1e | 24 | #include "mpls.h" |
684a7227 | 25 | #include "bgp_attr_evpn.h" |
f4bd90c5 | 26 | #include "bgpd/bgp_encap_types.h" |
ef3e0d04 | 27 | #include "srte.h" |
684a7227 | 28 | |
718e3744 | 29 | /* Simple bit mapping. */ |
30 | #define BITMAP_NBBY 8 | |
31 | ||
d62a17ae | 32 | #define SET_BITMAP(MAP, NUM) \ |
33 | SET_FLAG(MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY)) | |
718e3744 | 34 | |
d62a17ae | 35 | #define CHECK_BITMAP(MAP, NUM) \ |
36 | CHECK_FLAG(MAP[(NUM) / BITMAP_NBBY], 1 << ((NUM) % BITMAP_NBBY)) | |
718e3744 | 37 | |
3b424979 | 38 | #define BGP_MED_MAX UINT32_MAX |
39 | ||
718e3744 | 40 | /* BGP Attribute type range. */ |
41 | #define BGP_ATTR_TYPE_RANGE 256 | |
42 | #define BGP_ATTR_BITMAP_SIZE (BGP_ATTR_TYPE_RANGE / BITMAP_NBBY) | |
43 | ||
44 | /* BGP Attribute flags. */ | |
45 | #define BGP_ATTR_FLAG_OPTIONAL 0x80 /* Attribute is optional. */ | |
46 | #define BGP_ATTR_FLAG_TRANS 0x40 /* Attribute is transitive. */ | |
47 | #define BGP_ATTR_FLAG_PARTIAL 0x20 /* Attribute is partial. */ | |
48 | #define BGP_ATTR_FLAG_EXTLEN 0x10 /* Extended length flag. */ | |
49 | ||
50 | /* BGP attribute header must bigger than 2. */ | |
370b64a2 | 51 | #define BGP_ATTR_MIN_LEN 3 /* Attribute flag, type length. */ |
03e214c8 PJ |
52 | #define BGP_ATTR_DEFAULT_WEIGHT 32768 |
53 | ||
801a9bcc DS |
54 | /* Valid lengths for mp_nexthop_len */ |
55 | #define BGP_ATTR_NHLEN_IPV4 IPV4_MAX_BYTELEN | |
945c8fe9 | 56 | #define BGP_ATTR_NHLEN_VPNV4 8+IPV4_MAX_BYTELEN |
801a9bcc DS |
57 | #define BGP_ATTR_NHLEN_IPV6_GLOBAL IPV6_MAX_BYTELEN |
58 | #define BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL (IPV6_MAX_BYTELEN * 2) | |
945c8fe9 LB |
59 | #define BGP_ATTR_NHLEN_VPNV6_GLOBAL 8+IPV6_MAX_BYTELEN |
60 | #define BGP_ATTR_NHLEN_VPNV6_GLOBAL_AND_LL ((8+IPV6_MAX_BYTELEN) * 2) | |
801a9bcc | 61 | |
c5a543b4 DW |
62 | /* Prefix SID types */ |
63 | #define BGP_PREFIX_SID_LABEL_INDEX 1 | |
64 | #define BGP_PREFIX_SID_IPV6 2 | |
65 | #define BGP_PREFIX_SID_ORIGINATOR_SRGB 3 | |
e496b420 | 66 | #define BGP_PREFIX_SID_VPN_SID 4 |
c6ca155d HS |
67 | #define BGP_PREFIX_SID_SRV6_L3_SERVICE 5 |
68 | #define BGP_PREFIX_SID_SRV6_L2_SERVICE 6 | |
c5a543b4 DW |
69 | |
70 | #define BGP_PREFIX_SID_LABEL_INDEX_LENGTH 7 | |
71 | #define BGP_PREFIX_SID_IPV6_LENGTH 19 | |
72 | #define BGP_PREFIX_SID_ORIGINATOR_SRGB_LENGTH 6 | |
e496b420 HS |
73 | #define BGP_PREFIX_SID_VPN_SID_LENGTH 19 |
74 | #define BGP_PREFIX_SID_SRV6_L3_SERVICE_LENGTH 21 | |
f4c89855 | 75 | |
7c312383 AD |
76 | #define BGP_ATTR_NH_AFI(afi, attr) \ |
77 | ((afi != AFI_L2VPN) ? afi : \ | |
78 | ((attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) ? AFI_IP : AFI_IP6)) | |
79 | ||
7fd077aa | 80 | /* PMSI tunnel types (RFC 6514) */ |
81 | ||
f4c89855 | 82 | struct bgp_attr_encap_subtlv { |
d62a17ae | 83 | struct bgp_attr_encap_subtlv *next; /* for chaining */ |
84 | /* Reference count of this attribute. */ | |
85 | unsigned long refcnt; | |
86 | uint16_t type; | |
87 | uint16_t length; | |
8c9cc7bb | 88 | uint8_t value[0]; /* will be extended */ |
f4c89855 LB |
89 | }; |
90 | ||
49e5a4a0 | 91 | #ifdef ENABLE_BGP_VNC |
65efcfce LB |
92 | /* |
93 | * old rfp<->rfapi representation | |
94 | */ | |
95 | struct bgp_tea_options { | |
d62a17ae | 96 | struct bgp_tea_options *next; |
97 | uint8_t options_count; | |
98 | uint16_t options_length; /* each TLV may be 256 in length */ | |
99 | uint8_t type; | |
100 | uint8_t length; | |
101 | void *value; /* pointer to data */ | |
65efcfce LB |
102 | }; |
103 | ||
104 | #endif | |
105 | ||
7fd077aa | 106 | enum pta_type { |
b7d08f5a | 107 | PMSI_TNLTYPE_NO_INFO = 0, |
7fd077aa | 108 | PMSI_TNLTYPE_RSVP_TE_P2MP, |
109 | PMSI_TNLTYPE_MLDP_P2MP, | |
110 | PMSI_TNLTYPE_PIM_SSM, | |
111 | PMSI_TNLTYPE_PIM_SM, | |
112 | PMSI_TNLTYPE_PIM_BIDIR, | |
113 | PMSI_TNLTYPE_INGR_REPL, | |
114 | PMSI_TNLTYPE_MLDP_MP2MP, | |
115 | PMSI_TNLTYPE_MAX = PMSI_TNLTYPE_MLDP_MP2MP | |
116 | }; | |
117 | ||
e496b420 HS |
118 | /* |
119 | * Prefix-SID type-4 | |
120 | * SRv6-VPN-SID-TLV | |
121 | * draft-dawra-idr-srv6-vpn-04 | |
122 | */ | |
123 | struct bgp_attr_srv6_vpn { | |
124 | unsigned long refcnt; | |
125 | uint8_t sid_flags; | |
126 | struct in6_addr sid; | |
127 | }; | |
128 | ||
129 | /* | |
130 | * Prefix-SID type-5 | |
131 | * SRv6-L3VPN-Service-TLV | |
132 | * draft-dawra-idr-srv6-vpn-05 | |
133 | */ | |
134 | struct bgp_attr_srv6_l3vpn { | |
135 | unsigned long refcnt; | |
136 | uint8_t sid_flags; | |
137 | uint16_t endpoint_behavior; | |
138 | struct in6_addr sid; | |
139 | }; | |
140 | ||
aadc0905 | 141 | /* BGP core attribute structure. */ |
d62a17ae | 142 | struct attr { |
143 | /* AS Path structure */ | |
144 | struct aspath *aspath; | |
145 | ||
146 | /* Community structure */ | |
147 | struct community *community; | |
148 | ||
149 | /* Reference count of this attribute. */ | |
150 | unsigned long refcnt; | |
151 | ||
152 | /* Flag of attribute is set or not. */ | |
153 | uint64_t flag; | |
154 | ||
155 | /* Apart from in6_addr, the remaining static attributes */ | |
156 | struct in_addr nexthop; | |
d7c0a89a QY |
157 | uint32_t med; |
158 | uint32_t local_pref; | |
d62a17ae | 159 | ifindex_t nh_ifindex; |
160 | ||
161 | /* Path origin attribute */ | |
d7c0a89a | 162 | uint8_t origin; |
d62a17ae | 163 | |
7fd077aa | 164 | /* PMSI tunnel type (RFC 6514). */ |
165 | enum pta_type pmsi_tnl_type; | |
166 | ||
d62a17ae | 167 | /* has the route-map changed any attribute? |
168 | Used on the peer outbound side. */ | |
d7c0a89a | 169 | uint32_t rmap_change_flags; |
d62a17ae | 170 | |
171 | /* Multi-Protocol Nexthop, AFI IPv6 */ | |
172 | struct in6_addr mp_nexthop_global; | |
173 | struct in6_addr mp_nexthop_local; | |
174 | ||
77e62f2b | 175 | /* ifIndex corresponding to mp_nexthop_local. */ |
176 | ifindex_t nh_lla_ifindex; | |
177 | ||
d62a17ae | 178 | /* Extended Communities attribute. */ |
179 | struct ecommunity *ecommunity; | |
180 | ||
9a659715 PG |
181 | /* Extended Communities attribute. */ |
182 | struct ecommunity *ipv6_ecommunity; | |
183 | ||
d62a17ae | 184 | /* Large Communities attribute. */ |
185 | struct lcommunity *lcommunity; | |
186 | ||
187 | /* Route-Reflector Cluster attribute */ | |
779fee93 | 188 | struct cluster_list *cluster1; |
d62a17ae | 189 | |
190 | /* Unknown transitive attribute. */ | |
191 | struct transit *transit; | |
192 | ||
193 | struct in_addr mp_nexthop_global_in; | |
194 | ||
195 | /* Aggregator Router ID attribute */ | |
196 | struct in_addr aggregator_addr; | |
197 | ||
198 | /* Route Reflector Originator attribute */ | |
199 | struct in_addr originator_id; | |
200 | ||
201 | /* Local weight, not actually an attribute */ | |
d7c0a89a | 202 | uint32_t weight; |
d62a17ae | 203 | |
204 | /* Aggregator ASN */ | |
205 | as_t aggregator_as; | |
206 | ||
207 | /* MP Nexthop length */ | |
d7c0a89a | 208 | uint8_t mp_nexthop_len; |
d62a17ae | 209 | |
210 | /* MP Nexthop preference */ | |
d7c0a89a | 211 | uint8_t mp_nexthop_prefer_global; |
d62a17ae | 212 | |
213 | /* Static MAC for EVPN */ | |
d7c0a89a | 214 | uint8_t sticky; |
d62a17ae | 215 | |
ead40654 | 216 | /* Flag for default gateway extended community in EVPN */ |
d7c0a89a | 217 | uint8_t default_gw; |
ead40654 | 218 | |
68e33151 CS |
219 | /* NA router flag (R-bit) support in EVPN */ |
220 | uint8_t router_flag; | |
221 | ||
7904e9fd AK |
222 | /* ES info */ |
223 | uint8_t es_flags; | |
224 | /* Path is not "locally-active" on the advertising VTEP. This is | |
225 | * translated into an ARP-ND ECOM. | |
226 | */ | |
227 | #define ATTR_ES_PROXY_ADVERT (1 << 0) | |
228 | /* Destination ES is present locally. This flag is set on local | |
229 | * paths and sync paths | |
230 | */ | |
231 | #define ATTR_ES_IS_LOCAL (1 << 1) | |
232 | /* There are one or more non-best paths from ES peers. Note that | |
233 | * this flag is only set on the local MAC-IP paths in the VNI | |
234 | * route table (not set in the global routing table). And only | |
235 | * non-proxy advertisements from an ES peer can result in this | |
236 | * flag being set. | |
237 | */ | |
238 | #define ATTR_ES_PEER_ACTIVE (1 << 2) | |
239 | /* There are one or more non-best proxy paths from ES peers */ | |
240 | #define ATTR_ES_PEER_PROXY (1 << 3) | |
241 | /* An ES peer has router bit set - only applicable if | |
242 | * ATTR_ES_PEER_ACTIVE is set | |
243 | */ | |
244 | #define ATTR_ES_PEER_ROUTER (1 << 4) | |
245 | ||
d62a17ae | 246 | /* route tag */ |
247 | route_tag_t tag; | |
248 | ||
249 | /* Label index */ | |
d7c0a89a | 250 | uint32_t label_index; |
d62a17ae | 251 | |
252 | /* MPLS label */ | |
253 | mpls_label_t label; | |
254 | ||
e496b420 HS |
255 | /* SRv6 VPN SID */ |
256 | struct bgp_attr_srv6_vpn *srv6_vpn; | |
257 | ||
258 | /* SRv6 L3VPN SID */ | |
259 | struct bgp_attr_srv6_l3vpn *srv6_l3vpn; | |
260 | ||
d62a17ae | 261 | uint16_t encap_tunneltype; /* grr */ |
262 | struct bgp_attr_encap_subtlv *encap_subtlvs; /* rfc5512 */ | |
65efcfce | 263 | |
49e5a4a0 | 264 | #ifdef ENABLE_BGP_VNC |
d62a17ae | 265 | struct bgp_attr_encap_subtlv *vnc_subtlvs; /* VNC-specific */ |
65efcfce | 266 | #endif |
d62a17ae | 267 | /* EVPN */ |
ea7741a0 | 268 | struct bgp_route_evpn evpn_overlay; |
128ea8ab | 269 | |
d62a17ae | 270 | /* EVPN MAC Mobility sequence number, if any. */ |
d7c0a89a | 271 | uint32_t mm_seqnum; |
7904e9fd AK |
272 | /* highest MM sequence number rxed in a MAC-IP route from an |
273 | * ES peer (this includes both proxy and non-proxy MAC-IP | |
274 | * advertisements from ES peers). | |
275 | * This is only applicable to local paths in the VNI routing | |
276 | * table and derived from other imported/non-best paths. | |
277 | */ | |
278 | uint32_t mm_sync_seqnum; | |
bc59a672 MK |
279 | |
280 | /* EVPN local router-mac */ | |
281 | struct ethaddr rmac; | |
7b7d48e5 DS |
282 | |
283 | /* Distance as applied by Route map */ | |
284 | uint8_t distance; | |
951745bd PG |
285 | |
286 | /* rmap set table */ | |
287 | uint32_t rmap_table_id; | |
d901dc13 | 288 | |
289 | /* Link bandwidth value, if any. */ | |
290 | uint32_t link_bw; | |
0a50c248 AK |
291 | |
292 | /* EVPN ES */ | |
293 | esi_t esi; | |
ef3e0d04 SM |
294 | |
295 | /* SR-TE Color */ | |
296 | uint32_t srte_color; | |
74e2bd89 AK |
297 | |
298 | /* EVPN DF preference and algorithm for DF election on local ESs */ | |
299 | uint16_t df_pref; | |
300 | uint8_t df_alg; | |
fb982c25 PJ |
301 | }; |
302 | ||
3f9c7369 | 303 | /* rmap_change_flags definition */ |
3811f1e2 | 304 | #define BATTR_RMAP_IPV4_NHOP_CHANGED (1 << 0) |
3f9c7369 DS |
305 | #define BATTR_RMAP_NEXTHOP_PEER_ADDRESS (1 << 1) |
306 | #define BATTR_REFLECTED (1 << 2) | |
316e074d | 307 | #define BATTR_RMAP_NEXTHOP_UNCHANGED (1 << 3) |
3811f1e2 DS |
308 | #define BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED (1 << 4) |
309 | #define BATTR_RMAP_IPV6_LL_NHOP_CHANGED (1 << 5) | |
b2e03f7a | 310 | #define BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED (1 << 6) |
7b651a32 | 311 | #define BATTR_RMAP_LINK_BW_SET (1 << 7) |
3f9c7369 | 312 | |
718e3744 | 313 | /* Router Reflector related structure. */ |
d62a17ae | 314 | struct cluster_list { |
315 | unsigned long refcnt; | |
316 | int length; | |
317 | struct in_addr *list; | |
718e3744 | 318 | }; |
319 | ||
320 | /* Unknown transit attribute. */ | |
d62a17ae | 321 | struct transit { |
322 | unsigned long refcnt; | |
323 | int length; | |
d7c0a89a | 324 | uint8_t *val; |
718e3744 | 325 | }; |
326 | ||
96099b40 DL |
327 | /* "(void) 0" will generate a compiler error. this is a safety check to |
328 | * ensure we're not using a value that exceeds the bit size of attr->flag. */ | |
996c9314 LB |
329 | #define ATTR_FLAG_BIT(X) \ |
330 | __builtin_choose_expr((X) >= 1 && (X) <= 64, 1ULL << ((X)-1), (void)0) | |
718e3744 | 331 | |
d62a17ae | 332 | #define BGP_CLUSTER_LIST_LENGTH(attr) \ |
333 | (((attr)->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)) \ | |
779fee93 | 334 | ? bgp_attr_get_cluster((attr))->length \ |
d62a17ae | 335 | : 0) |
5e242b0d | 336 | |
b881c707 | 337 | typedef enum { |
d62a17ae | 338 | BGP_ATTR_PARSE_PROCEED = 0, |
339 | BGP_ATTR_PARSE_ERROR = -1, | |
340 | BGP_ATTR_PARSE_WITHDRAW = -2, | |
f57000c0 | 341 | |
d62a17ae | 342 | /* only used internally, send notify + convert to BGP_ATTR_PARSE_ERROR |
9d303b37 | 343 | */ |
d62a17ae | 344 | BGP_ATTR_PARSE_ERROR_NOTIFYPLS = -3, |
9b9df989 | 345 | BGP_ATTR_PARSE_EOR = -4, |
b881c707 PJ |
346 | } bgp_attr_parse_ret_t; |
347 | ||
3f9c7369 DS |
348 | struct bpacket_attr_vec_arr; |
349 | ||
718e3744 | 350 | /* Prototypes. */ |
d62a17ae | 351 | extern void bgp_attr_init(void); |
352 | extern void bgp_attr_finish(void); | |
353 | extern bgp_attr_parse_ret_t bgp_attr_parse(struct peer *, struct attr *, | |
354 | bgp_size_t, struct bgp_nlri *, | |
355 | struct bgp_nlri *); | |
f46d8e1e | 356 | extern void bgp_attr_undup(struct attr *new, struct attr *old); |
d62a17ae | 357 | extern struct attr *bgp_attr_intern(struct attr *attr); |
d62a17ae | 358 | extern void bgp_attr_unintern_sub(struct attr *); |
359 | extern void bgp_attr_unintern(struct attr **); | |
360 | extern void bgp_attr_flush(struct attr *); | |
d7c0a89a | 361 | extern struct attr *bgp_attr_default_set(struct attr *attr, uint8_t); |
5f040085 DS |
362 | extern struct attr *bgp_attr_aggregate_intern( |
363 | struct bgp *bgp, uint8_t origin, struct aspath *aspath, | |
364 | struct community *community, struct ecommunity *ecommunity, | |
365 | struct lcommunity *lcommunity, struct bgp_aggregate *aggregate, | |
366 | uint8_t atomic_aggregate, const struct prefix *p); | |
d62a17ae | 367 | extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *, |
368 | struct stream *, struct attr *, | |
369 | struct bpacket_attr_vec_arr *vecarr, | |
370 | struct prefix *, afi_t, safi_t, | |
371 | struct peer *, struct prefix_rd *, | |
d7c0a89a | 372 | mpls_label_t *, uint32_t, int, uint32_t); |
bd494ec5 DS |
373 | extern void bgp_dump_routes_attr(struct stream *s, struct attr *attr, |
374 | const struct prefix *p); | |
74df8d6d | 375 | extern bool attrhash_cmp(const void *arg1, const void *arg2); |
d8b87afe | 376 | extern unsigned int attrhash_key_make(const void *); |
d62a17ae | 377 | extern void attr_show_all(struct vty *); |
378 | extern unsigned long int attr_count(void); | |
379 | extern unsigned long int attr_unknown_count(void); | |
718e3744 | 380 | |
381 | /* Cluster list prototypes. */ | |
3dc339cd | 382 | extern bool cluster_loop_check(struct cluster_list *, struct in_addr); |
718e3744 | 383 | |
835315bf PJ |
384 | /* Below exported for unit-test purposes only */ |
385 | struct bgp_attr_parser_args { | |
d62a17ae | 386 | struct peer *peer; |
387 | bgp_size_t length; /* attribute data length; */ | |
388 | bgp_size_t total; /* total length, inc header */ | |
389 | struct attr *attr; | |
d7c0a89a QY |
390 | uint8_t type; |
391 | uint8_t flags; | |
392 | uint8_t *startp; | |
835315bf | 393 | }; |
d62a17ae | 394 | extern int bgp_mp_reach_parse(struct bgp_attr_parser_args *args, |
395 | struct bgp_nlri *); | |
396 | extern int bgp_mp_unreach_parse(struct bgp_attr_parser_args *args, | |
397 | struct bgp_nlri *); | |
30adbd4e | 398 | extern bgp_attr_parse_ret_t |
45a06b11 | 399 | bgp_attr_prefix_sid(struct bgp_attr_parser_args *args); |
03292809 | 400 | |
f4c89855 LB |
401 | extern struct bgp_attr_encap_subtlv * |
402 | encap_tlv_dup(struct bgp_attr_encap_subtlv *orig); | |
403 | ||
d62a17ae | 404 | extern void bgp_attr_flush_encap(struct attr *attr); |
f4c89855 | 405 | |
f4bd90c5 LK |
406 | extern void bgp_attr_extcom_tunnel_type(struct attr *attr, |
407 | bgp_encap_types *tunnel_type); | |
408 | ||
8c71e481 PM |
409 | /** |
410 | * Set of functions to encode MP_REACH_NLRI and MP_UNREACH_NLRI attributes. | |
411 | * Typical call sequence is to call _start(), followed by multiple _prefix(), | |
412 | * one for each NLRI that needs to be encoded into the UPDATE message, and | |
413 | * finally the _end() function. | |
414 | */ | |
2b26882d | 415 | extern size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, |
d62a17ae | 416 | afi_t afi, safi_t safi, |
417 | struct bpacket_attr_vec_arr *vecarr, | |
8c71e481 PM |
418 | struct attr *attr); |
419 | extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi, | |
5f040085 DS |
420 | const struct prefix *p, |
421 | const struct prefix_rd *prd, | |
d7c0a89a QY |
422 | mpls_label_t *label, uint32_t num_labels, |
423 | int addpath_encode, uint32_t addpath_tx_id, | |
424 | struct attr *); | |
93b73dfa | 425 | extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi, |
5f040085 | 426 | const struct prefix *p); |
8c71e481 PM |
427 | extern void bgp_packet_mpattr_end(struct stream *s, size_t sizep); |
428 | ||
d62a17ae | 429 | extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi, |
430 | safi_t safi); | |
5f040085 DS |
431 | extern void bgp_packet_mpunreach_prefix( |
432 | struct stream *s, const struct prefix *p, afi_t afi, safi_t safi, | |
433 | const struct prefix_rd *prd, mpls_label_t *label, uint32_t num_labels, | |
434 | int addpath_encode, uint32_t addpath_tx_id, struct attr *attr); | |
d62a17ae | 435 | extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt); |
8c71e481 | 436 | |
9738e9aa | 437 | extern bgp_attr_parse_ret_t bgp_attr_nexthop_valid(struct peer *peer, |
438 | struct attr *attr); | |
439 | ||
d7c0a89a QY |
440 | static inline int bgp_rmap_nhop_changed(uint32_t out_rmap_flags, |
441 | uint32_t in_rmap_flags) | |
3811f1e2 | 442 | { |
d62a17ae | 443 | return ((CHECK_FLAG(out_rmap_flags, BATTR_RMAP_NEXTHOP_PEER_ADDRESS) |
444 | || CHECK_FLAG(out_rmap_flags, BATTR_RMAP_NEXTHOP_UNCHANGED) | |
445 | || CHECK_FLAG(out_rmap_flags, BATTR_RMAP_IPV4_NHOP_CHANGED) | |
446 | || CHECK_FLAG(out_rmap_flags, | |
447 | BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED) | |
448 | || CHECK_FLAG(out_rmap_flags, | |
449 | BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED) | |
450 | || CHECK_FLAG(out_rmap_flags, BATTR_RMAP_IPV6_LL_NHOP_CHANGED) | |
451 | || CHECK_FLAG(in_rmap_flags, BATTR_RMAP_NEXTHOP_UNCHANGED)) | |
452 | ? 1 | |
453 | : 0); | |
3811f1e2 DS |
454 | } |
455 | ||
d7c0a89a | 456 | static inline uint32_t mac_mobility_seqnum(struct attr *attr) |
128ea8ab | 457 | { |
d62a17ae | 458 | return (attr) ? attr->mm_seqnum : 0; |
128ea8ab | 459 | } |
2a3f51cf DS |
460 | |
461 | static inline enum pta_type bgp_attr_get_pmsi_tnl_type(struct attr *attr) | |
462 | { | |
463 | return attr->pmsi_tnl_type; | |
464 | } | |
465 | ||
466 | static inline void bgp_attr_set_pmsi_tnl_type(struct attr *attr, | |
467 | enum pta_type pmsi_tnl_type) | |
468 | { | |
469 | attr->pmsi_tnl_type = pmsi_tnl_type; | |
470 | } | |
471 | ||
d04ac434 DS |
472 | static inline struct ecommunity * |
473 | bgp_attr_get_ipv6_ecommunity(const struct attr *attr) | |
474 | { | |
475 | return attr->ipv6_ecommunity; | |
476 | } | |
477 | ||
478 | static inline void bgp_attr_set_ipv6_ecommunity(struct attr *attr, | |
479 | struct ecommunity *ipv6_ecomm) | |
480 | { | |
481 | attr->ipv6_ecommunity = ipv6_ecomm; | |
482 | } | |
483 | ||
04fb21e2 DS |
484 | static inline struct transit *bgp_attr_get_transit(const struct attr *attr) |
485 | { | |
486 | return attr->transit; | |
487 | } | |
488 | ||
489 | static inline void bgp_attr_set_transit(struct attr *attr, | |
490 | struct transit *transit) | |
491 | { | |
492 | attr->transit = transit; | |
493 | } | |
779fee93 DS |
494 | |
495 | static inline struct cluster_list *bgp_attr_get_cluster(const struct attr *attr) | |
496 | { | |
497 | return attr->cluster1; | |
498 | } | |
499 | ||
500 | static inline void bgp_attr_set_cluster(struct attr *attr, | |
501 | struct cluster_list *cl) | |
502 | { | |
503 | attr->cluster1 = cl; | |
504 | } | |
6c924775 DS |
505 | |
506 | static inline const struct bgp_route_evpn * | |
507 | bgp_attr_get_evpn_overlay(const struct attr *attr) | |
508 | { | |
509 | return &attr->evpn_overlay; | |
510 | } | |
511 | ||
512 | static inline void bgp_attr_set_evpn_overlay(struct attr *attr, | |
513 | struct bgp_route_evpn *eo) | |
514 | { | |
515 | memcpy(&attr->evpn_overlay, eo, sizeof(struct bgp_route_evpn)); | |
516 | } | |
517 | ||
91ebf12c DS |
518 | static inline struct bgp_attr_encap_subtlv * |
519 | bgp_attr_get_vnc_subtlvs(const struct attr *attr) | |
520 | { | |
521 | #ifdef ENABLE_BGP_VNC | |
522 | return attr->vnc_subtlvs; | |
523 | #else | |
524 | return NULL; | |
525 | #endif | |
526 | } | |
527 | ||
528 | static inline void | |
529 | bgp_attr_set_vnc_subtlvs(struct attr *attr, | |
530 | struct bgp_attr_encap_subtlv *vnc_subtlvs) | |
531 | { | |
532 | #ifdef ENABLE_BGP_VNC | |
533 | attr->vnc_subtlvs = vnc_subtlvs; | |
534 | #endif | |
535 | } | |
536 | ||
00d252cb | 537 | #endif /* _QUAGGA_BGP_ATTR_H */ |