]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_tlvs.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / isisd / isis_tlvs.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
7ef5fefc
CF
2/*
3 * IS-IS TLV Serializer/Deserializer
4 *
5 * Copyright (C) 2015,2017 Christian Franke
1b3f47d0
OD
6
7 * Copyright (C) 2019 Olivier Dugeon - Orange Labs (for TE and SR)
7ef5fefc 8 */
841791b6
CF
9#ifndef ISIS_TLVS_H
10#define ISIS_TLVS_H
7ef5fefc 11
81a067cd 12#include "segment_routing.h"
7ef5fefc
CF
13#include "openbsd-tree.h"
14#include "prefix.h"
7f198e06 15#include "flex_algo.h"
78774bbc
HS
16#include "affinitymap.h"
17
7ef5fefc 18
bf8d3d6a 19DECLARE_MTYPE(ISIS_SUBTLV);
26f6acaf 20
4bef0ec4 21struct lspdb_head;
26f6acaf 22struct sr_prefix_cfg;
7ef5fefc 23
7ef5fefc
CF
24struct isis_area_address {
25 struct isis_area_address *next;
26
27 uint8_t addr[20];
28 uint8_t len;
29};
30
35f70ed3
RW
31#define ISIS_WIDE_METRIC_INFINITY 0xFFFFFE
32#define ISIS_NARROW_METRIC_INFINITY 62
33
7ef5fefc
CF
34struct isis_oldstyle_reach {
35 struct isis_oldstyle_reach *next;
36
37 uint8_t id[7];
38 uint8_t metric;
39};
40
7ef5fefc
CF
41struct isis_oldstyle_ip_reach {
42 struct isis_oldstyle_ip_reach *next;
43
44 uint8_t metric;
45 struct prefix_ipv4 prefix;
46};
47
7ef5fefc
CF
48struct isis_lsp_entry {
49 struct isis_lsp_entry *next;
50
51 uint16_t rem_lifetime;
52 uint8_t id[8];
53 uint16_t checksum;
54 uint32_t seqno;
55
56 struct isis_lsp *lsp;
57};
58
7ef5fefc
CF
59struct isis_extended_reach {
60 struct isis_extended_reach *next;
61
62 uint8_t id[7];
63 uint32_t metric;
64
1b3f47d0 65 struct isis_ext_subtlvs *subtlvs;
7ef5fefc
CF
66};
67
7ef5fefc
CF
68struct isis_extended_ip_reach {
69 struct isis_extended_ip_reach *next;
70
71 uint32_t metric;
72 bool down;
73 struct prefix_ipv4 prefix;
bd507085
CF
74
75 struct isis_subtlvs *subtlvs;
7ef5fefc
CF
76};
77
7ef5fefc
CF
78struct isis_ipv6_reach {
79 struct isis_ipv6_reach *next;
80
81 uint32_t metric;
82 bool down;
83 bool external;
84
85 struct prefix_ipv6 prefix;
86
87 struct isis_subtlvs *subtlvs;
88};
89
90struct isis_protocols_supported {
91 uint8_t count;
92 uint8_t *protocols;
93};
94
41a145f1
CF
95#define ISIS_TIER_UNDEFINED 15
96
97struct isis_spine_leaf {
98 uint8_t tier;
99
100 bool has_tier;
101 bool is_leaf;
102 bool is_spine;
103 bool is_backup;
104};
105
9fe21208
CF
106enum isis_threeway_state {
107 ISIS_THREEWAY_DOWN = 2,
108 ISIS_THREEWAY_INITIALIZING = 1,
9b19f67e 109 ISIS_THREEWAY_UP = 0,
9fe21208
CF
110};
111
112struct isis_threeway_adj {
113 enum isis_threeway_state state;
114 uint32_t local_circuit_id;
115 bool neighbor_set;
116 uint8_t neighbor_id[6];
117 uint32_t neighbor_circuit_id;
118};
119
f2333421 120/* Segment Routing subTLV's as per RFC8667 */
1b3f47d0
OD
121#define ISIS_SUBTLV_SRGB_FLAG_I 0x80
122#define ISIS_SUBTLV_SRGB_FLAG_V 0x40
d47d6089
RW
123#define IS_SR_IPV4(srgb) ((srgb)->flags & ISIS_SUBTLV_SRGB_FLAG_I)
124#define IS_SR_IPV6(srgb) ((srgb)->flags & ISIS_SUBTLV_SRGB_FLAG_V)
e075df3a
OD
125#define SUBTLV_SR_BLOCK_SIZE 6
126#define SUBTLV_RANGE_INDEX_SIZE 10
127#define SUBTLV_RANGE_LABEL_SIZE 9
1b3f47d0 128
d8391312
OD
129/* Structure aggregating SR Global (SRGB) or Local (SRLB) Block info */
130struct isis_sr_block {
1b3f47d0
OD
131 uint8_t flags;
132 uint32_t range_size;
133 uint32_t lower_bound;
134};
135
136/* Prefix-SID sub-TLVs flags */
137#define ISIS_PREFIX_SID_READVERTISED 0x80
138#define ISIS_PREFIX_SID_NODE 0x40
139#define ISIS_PREFIX_SID_NO_PHP 0x20
140#define ISIS_PREFIX_SID_EXPLICIT_NULL 0x10
141#define ISIS_PREFIX_SID_VALUE 0x08
142#define ISIS_PREFIX_SID_LOCAL 0x04
143
1b3f47d0
OD
144struct isis_prefix_sid {
145 struct isis_prefix_sid *next;
146
147 uint8_t flags;
148 uint8_t algorithm;
149 uint32_t value;
150};
151
152/* Adj-SID and LAN-Ajd-SID sub-TLVs flags */
153#define EXT_SUBTLV_LINK_ADJ_SID_FFLG 0x80
154#define EXT_SUBTLV_LINK_ADJ_SID_BFLG 0x40
155#define EXT_SUBTLV_LINK_ADJ_SID_VFLG 0x20
156#define EXT_SUBTLV_LINK_ADJ_SID_LFLG 0x10
157#define EXT_SUBTLV_LINK_ADJ_SID_SFLG 0x08
158#define EXT_SUBTLV_LINK_ADJ_SID_PFLG 0x04
159
1b3f47d0
OD
160struct isis_adj_sid {
161 struct isis_adj_sid *next;
162
163 uint8_t family;
164 uint8_t flags;
165 uint8_t weight;
166 uint32_t sid;
167};
168
1b3f47d0
OD
169struct isis_lan_adj_sid {
170 struct isis_lan_adj_sid *next;
171
172 uint8_t family;
173 uint8_t flags;
174 uint8_t weight;
175 uint8_t neighbor_id[ISIS_SYS_ID_LEN];
176 uint32_t sid;
177};
178
179/* RFC 4971 & RFC 7981 */
180#define ISIS_ROUTER_CAP_FLAG_S 0x01
181#define ISIS_ROUTER_CAP_FLAG_D 0x02
182#define ISIS_ROUTER_CAP_SIZE 5
183
e075df3a
OD
184#define MSD_TYPE_BASE_MPLS_IMPOSITION 0x01
185#define MSD_TLV_SIZE 2
186
7f198e06
HS
187#ifndef FABRICD
188struct isis_router_cap_fad;
189struct isis_router_cap_fad {
190 uint8_t sysid[ISIS_SYS_ID_LEN + 2];
191
192 struct flex_algo fad;
193};
194#endif /* ifndef FABRICD */
195
1b3f47d0
OD
196struct isis_router_cap {
197 struct in_addr router_id;
198 uint8_t flags;
199
f2333421 200 /* RFC 8667 section #3 */
d8391312
OD
201 struct isis_sr_block srgb;
202 struct isis_sr_block srlb;
1b3f47d0
OD
203 uint8_t algo[SR_ALGORITHM_COUNT];
204 /* RFC 8491 */
1b3f47d0 205 uint8_t msd;
7f198e06
HS
206
207#ifndef FABRICD
208 /* RFC9350 Flex-Algorithm */
209 struct isis_router_cap_fad *fads[SR_ALGORITHM_COUNT];
210#endif /* ifndef FABRICD */
1b3f47d0
OD
211};
212
7ef5fefc
CF
213struct isis_item {
214 struct isis_item *next;
215};
216
7ef5fefc
CF
217struct isis_lan_neighbor {
218 struct isis_lan_neighbor *next;
219
220 uint8_t mac[6];
221};
222
7ef5fefc
CF
223struct isis_ipv4_address {
224 struct isis_ipv4_address *next;
225
226 struct in_addr addr;
227};
228
7ef5fefc
CF
229struct isis_ipv6_address {
230 struct isis_ipv6_address *next;
231
232 struct in6_addr addr;
233};
234
7ef5fefc
CF
235struct isis_mt_router_info {
236 struct isis_mt_router_info *next;
237
238 bool overload;
239 bool attached;
240 uint16_t mtid;
241};
242
7ef5fefc
CF
243struct isis_auth {
244 struct isis_auth *next;
245
246 uint8_t type;
247 uint8_t length;
248 uint8_t value[256];
249
250 uint8_t plength;
251 uint8_t passwd[256];
252
253 size_t offset; /* Only valid after packing */
254};
255
7ef5fefc
CF
256struct isis_item_list {
257 struct isis_item *head;
258 struct isis_item **tail;
259
260 RB_ENTRY(isis_item_list) mt_tree;
261 uint16_t mtid;
262 unsigned int count;
263};
264
5f77d901
CF
265struct isis_purge_originator {
266 bool sender_set;
267
268 uint8_t generator[6];
269 uint8_t sender[6];
270};
271
3380c990
EDP
272enum isis_auth_result {
273 ISIS_AUTH_OK = 0,
274 ISIS_AUTH_TYPE_FAILURE,
275 ISIS_AUTH_FAILURE,
276 ISIS_AUTH_NO_VALIDATOR,
277};
278
7ef5fefc
CF
279RB_HEAD(isis_mt_item_list, isis_item_list);
280
281struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m,
282 uint16_t mtid);
283struct isis_item_list *isis_lookup_mt_items(struct isis_mt_item_list *m,
284 uint16_t mtid);
285
286struct isis_tlvs {
287 struct isis_item_list isis_auth;
5f77d901 288 struct isis_purge_originator *purge_originator;
7ef5fefc
CF
289 struct isis_item_list area_addresses;
290 struct isis_item_list oldstyle_reach;
291 struct isis_item_list lan_neighbor;
292 struct isis_item_list lsp_entries;
293 struct isis_item_list extended_reach;
294 struct isis_mt_item_list mt_reach;
295 struct isis_item_list oldstyle_ip_reach;
296 struct isis_protocols_supported protocols_supported;
297 struct isis_item_list oldstyle_ip_reach_ext;
298 struct isis_item_list ipv4_address;
299 struct isis_item_list ipv6_address;
173f8887 300 struct isis_item_list global_ipv6_address;
7ef5fefc
CF
301 struct isis_item_list mt_router_info;
302 bool mt_router_info_empty;
303 struct in_addr *te_router_id;
173f8887 304 struct in6_addr *te_router_id_ipv6;
7ef5fefc
CF
305 struct isis_item_list extended_ip_reach;
306 struct isis_mt_item_list mt_ip_reach;
307 char *hostname;
308 struct isis_item_list ipv6_reach;
309 struct isis_mt_item_list mt_ipv6_reach;
9fe21208 310 struct isis_threeway_adj *threeway_adj;
1b3f47d0 311 struct isis_router_cap *router_cap;
41a145f1 312 struct isis_spine_leaf *spine_leaf;
7ef5fefc
CF
313};
314
7ef5fefc
CF
315enum isis_tlv_context {
316 ISIS_CONTEXT_LSP,
317 ISIS_CONTEXT_SUBTLV_NE_REACH,
318 ISIS_CONTEXT_SUBTLV_IP_REACH,
319 ISIS_CONTEXT_SUBTLV_IPV6_REACH,
9b19f67e 320 ISIS_CONTEXT_MAX,
7ef5fefc
CF
321};
322
bd507085
CF
323struct isis_subtlvs {
324 enum isis_tlv_context context;
325
326 /* draft-baker-ipv6-isis-dst-src-routing-06 */
327 struct prefix_ipv6 *source_prefix;
f2333421 328 /* RFC 8667 section #2.4 */
bd507085
CF
329 struct isis_item_list prefix_sids;
330};
331
7ef5fefc 332enum isis_tlv_type {
1b3f47d0 333 /* TLVs code point */
7ef5fefc
CF
334 ISIS_TLV_AREA_ADDRESSES = 1,
335 ISIS_TLV_OLDSTYLE_REACH = 2,
336 ISIS_TLV_LAN_NEIGHBORS = 6,
337 ISIS_TLV_PADDING = 8,
338 ISIS_TLV_LSP_ENTRY = 9,
339 ISIS_TLV_AUTH = 10,
5f77d901 340 ISIS_TLV_PURGE_ORIGINATOR = 13,
7ef5fefc
CF
341 ISIS_TLV_EXTENDED_REACH = 22,
342
343 ISIS_TLV_OLDSTYLE_IP_REACH = 128,
344 ISIS_TLV_PROTOCOLS_SUPPORTED = 129,
345 ISIS_TLV_OLDSTYLE_IP_REACH_EXT = 130,
346 ISIS_TLV_IPV4_ADDRESS = 132,
347 ISIS_TLV_TE_ROUTER_ID = 134,
348 ISIS_TLV_EXTENDED_IP_REACH = 135,
349 ISIS_TLV_DYNAMIC_HOSTNAME = 137,
173f8887 350 ISIS_TLV_TE_ROUTER_ID_IPV6 = 140,
41a145f1 351 ISIS_TLV_SPINE_LEAF_EXT = 150,
7ef5fefc
CF
352 ISIS_TLV_MT_REACH = 222,
353 ISIS_TLV_MT_ROUTER_INFO = 229,
354 ISIS_TLV_IPV6_ADDRESS = 232,
173f8887 355 ISIS_TLV_GLOBAL_IPV6_ADDRESS = 233,
7ef5fefc
CF
356 ISIS_TLV_MT_IP_REACH = 235,
357 ISIS_TLV_IPV6_REACH = 236,
358 ISIS_TLV_MT_IPV6_REACH = 237,
9fe21208 359 ISIS_TLV_THREE_WAY_ADJ = 240,
1b3f47d0 360 ISIS_TLV_ROUTER_CAPABILITY = 242,
7ef5fefc
CF
361 ISIS_TLV_MAX = 256,
362
1b3f47d0
OD
363 /* subTLVs code point */
364 ISIS_SUBTLV_IPV6_SOURCE_PREFIX = 22,
365
366 /* RFC 5305 & RFC 6119 */
367 ISIS_SUBTLV_ADMIN_GRP = 3,
368 ISIS_SUBTLV_LOCAL_IPADDR = 6,
369 ISIS_SUBTLV_RMT_IPADDR = 8,
370 ISIS_SUBTLV_MAX_BW = 9,
371 ISIS_SUBTLV_MAX_RSV_BW = 10,
372 ISIS_SUBTLV_UNRSV_BW = 11,
373 ISIS_SUBTLV_LOCAL_IPADDR6 = 12,
374 ISIS_SUBTLV_RMT_IPADDR6 = 13,
375 ISIS_SUBTLV_TE_METRIC = 18,
376
377 /* RFC 5307 */
378 ISIS_SUBTLV_LLRI = 4,
379
f2333421
OD
380 /* RFC 8491 */
381 ISIS_SUBTLV_NODE_MSD = 23,
382
1b3f47d0
OD
383 /* RFC 5316 */
384 ISIS_SUBTLV_RAS = 24,
385 ISIS_SUBTLV_RIP = 25,
386
d8391312 387 /* RFC 8667 section #4 IANA allocation */
1b3f47d0
OD
388 ISIS_SUBTLV_SID_LABEL = 1,
389 ISIS_SUBTLV_SID_LABEL_RANGE = 2,
390 ISIS_SUBTLV_ALGORITHM = 19,
d8391312 391 ISIS_SUBTLV_SRLB = 22,
bd507085 392 ISIS_SUBTLV_PREFIX_SID = 3,
1b3f47d0
OD
393 ISIS_SUBTLV_ADJ_SID = 31,
394 ISIS_SUBTLV_LAN_ADJ_SID = 32,
395
396 /* RFC 7810 */
397 ISIS_SUBTLV_AV_DELAY = 33,
398 ISIS_SUBTLV_MM_DELAY = 34,
399 ISIS_SUBTLV_DELAY_VAR = 35,
400 ISIS_SUBTLV_PKT_LOSS = 36,
401 ISIS_SUBTLV_RES_BW = 37,
402 ISIS_SUBTLV_AVA_BW = 38,
403 ISIS_SUBTLV_USE_BW = 39,
404
78774bbc
HS
405 /* RFC 7308 */
406 ISIS_SUBTLV_EXT_ADMIN_GRP = 14,
407
5749ac83
LS
408 /* RFC 8919 */
409 ISIS_SUBTLV_ASLA = 16,
410
78774bbc
HS
411 /* draft-ietf-lsr-isis-srv6-extensions */
412 ISIS_SUBTLV_SID_END = 5,
413 ISIS_SUBTLV_SID_END_X = 43,
414
9b19f67e 415 ISIS_SUBTLV_MAX = 40,
78774bbc
HS
416
417 /* draft-ietf-lsr-isis-srv6-extensions */
418 ISIS_SUBSUBTLV_SID_STRUCTURE = 1,
419
420 ISIS_SUBSUBTLV_MAX = 256,
1b3f47d0
OD
421};
422
423/* subTLVs size for TE and SR */
424enum ext_subtlv_size {
f2333421 425 /* RFC 5307 */
1b3f47d0
OD
426 ISIS_SUBTLV_LLRI_SIZE = 8,
427
f2333421 428 /* RFC 5305 & RFC 6119 */
1b3f47d0
OD
429 ISIS_SUBTLV_UNRSV_BW_SIZE = 32,
430 ISIS_SUBTLV_TE_METRIC_SIZE = 3,
431 ISIS_SUBTLV_IPV6_ADDR_SIZE = 16,
432
f2333421
OD
433 /* RFC 8491 */
434 ISIS_SUBTLV_NODE_MSD_SIZE = 2,
435
d8391312 436 /* RFC 8667 sections #2 & #3 */
1b3f47d0 437 ISIS_SUBTLV_SID_LABEL_SIZE = 3,
9ba865f5 438 ISIS_SUBTLV_SID_INDEX_SIZE = 4,
1b3f47d0
OD
439 ISIS_SUBTLV_SID_LABEL_RANGE_SIZE = 9,
440 ISIS_SUBTLV_ALGORITHM_SIZE = 4,
1b3f47d0
OD
441 ISIS_SUBTLV_ADJ_SID_SIZE = 5,
442 ISIS_SUBTLV_LAN_ADJ_SID_SIZE = 11,
443 ISIS_SUBTLV_PREFIX_SID_SIZE = 5,
444
f2333421 445 /* RFC 7810 */
1b3f47d0
OD
446 ISIS_SUBTLV_MM_DELAY_SIZE = 8,
447
78774bbc
HS
448 /* RFC9350 - Flex-Algorithm */
449 ISIS_SUBTLV_FAD = 26,
450 ISIS_SUBTLV_FAD_MIN_SIZE = 4,
451
1b3f47d0
OD
452 ISIS_SUBTLV_HDR_SIZE = 2,
453 ISIS_SUBTLV_DEF_SIZE = 4,
454
78774bbc
HS
455 ISIS_SUBTLV_MAX_SIZE = 180,
456
457 /* draft-ietf-lsr-isis-srv6-extensions */
458 ISIS_SUBSUBTLV_SID_STRUCTURE_SIZE = 4,
fa1b95c3 459
5749ac83 460 ISIS_SUBSUBTLV_HDR_SIZE = 2,
78774bbc 461 ISIS_SUBSUBTLV_MAX_SIZE = 180,
5749ac83 462
78774bbc
HS
463 /* RFC9350 - Flex-Algorithm */
464 ISIS_SUBTLV_FAD_SUBSUBTLV_FLAGS_SIZE = 1,
465};
466
467enum ext_subsubtlv_types {
468 ISIS_SUBTLV_FAD_SUBSUBTLV_EXCAG = 1,
469 ISIS_SUBTLV_FAD_SUBSUBTLV_INCANYAG = 2,
470 ISIS_SUBTLV_FAD_SUBSUBTLV_INCALLAG = 3,
471 ISIS_SUBTLV_FAD_SUBSUBTLV_FLAGS = 4,
472 ISIS_SUBTLV_FAD_SUBSUBTLV_ESRLG = 5,
1b3f47d0
OD
473};
474
475/* Macros to manage the optional presence of EXT subTLVs */
476#define SET_SUBTLV(s, t) ((s->status) |= (t))
477#define UNSET_SUBTLV(s, t) ((s->status) &= ~(t))
478#define IS_SUBTLV(s, t) (s->status & t)
5749ac83
LS
479#define RESET_SUBTLV(s) (s->status = 0)
480#define NO_SUBTLV(s) (s->status == 0)
1b3f47d0
OD
481
482#define EXT_DISABLE 0x000000
483#define EXT_ADM_GRP 0x000001
484#define EXT_LLRI 0x000002
485#define EXT_LOCAL_ADDR 0x000004
486#define EXT_NEIGH_ADDR 0x000008
487#define EXT_LOCAL_ADDR6 0x000010
488#define EXT_NEIGH_ADDR6 0x000020
489#define EXT_MAX_BW 0x000040
490#define EXT_MAX_RSV_BW 0x000080
491#define EXT_UNRSV_BW 0x000100
492#define EXT_TE_METRIC 0x000200
493#define EXT_RMT_AS 0x000400
494#define EXT_RMT_IP 0x000800
495#define EXT_ADJ_SID 0x001000
496#define EXT_LAN_ADJ_SID 0x002000
497#define EXT_DELAY 0x004000
498#define EXT_MM_DELAY 0x008000
499#define EXT_DELAY_VAR 0x010000
500#define EXT_PKT_LOSS 0x020000
501#define EXT_RES_BW 0x040000
502#define EXT_AVA_BW 0x080000
503#define EXT_USE_BW 0x100000
fa1b95c3 504#define EXT_EXTEND_ADM_GRP 0x200000
1b3f47d0
OD
505
506/*
507 * This structure groups all Extended IS Reachability subTLVs.
508 *
509 * Each bit of the status field indicates if a subTLVs is valid or not.
510 * SubTLVs values use following units:
511 * - Bandwidth in bytes/sec following IEEE format,
512 * - Delay in micro-seconds with only 24 bits significant
513 * - Packet Loss in percentage of total traffic with only 24 bits (2^24 - 2)
514 *
515 * For Delay and packet Loss, upper bit (A) indicates if the value is
516 * normal (0) or anomalous (1).
517 */
e84179b6 518#define IS_ANORMAL(v) (v & TE_EXT_ANORMAL)
1b3f47d0
OD
519
520struct isis_ext_subtlvs {
521
522 uint32_t status;
523
524 uint32_t adm_group; /* Resource Class/Color - RFC 5305 */
fa1b95c3 525 struct admin_group ext_admin_group; /* Res. Class/Color - RFC 7308 */
1b3f47d0
OD
526 /* Link Local/Remote Identifiers - RFC 5307 */
527 uint32_t local_llri;
528 uint32_t remote_llri;
529 struct in_addr local_addr; /* Local IP Address - RFC 5305 */
530 struct in_addr neigh_addr; /* Neighbor IP Address - RFC 5305 */
531 struct in6_addr local_addr6; /* Local IPv6 Address - RFC 6119 */
532 struct in6_addr neigh_addr6; /* Neighbor IPv6 Address - RFC 6119 */
533 float max_bw; /* Maximum Bandwidth - RFC 5305 */
534 float max_rsv_bw; /* Maximum Reservable Bandwidth - RFC 5305 */
535 float unrsv_bw[8]; /* Unreserved Bandwidth - RFC 5305 */
536 uint32_t te_metric; /* Traffic Engineering Metric - RFC 5305 */
537 uint32_t remote_as; /* Remote AS Number sub-TLV - RFC5316 */
538 struct in_addr remote_ip; /* IPv4 Remote ASBR ID Sub-TLV - RFC5316 */
539
540 uint32_t delay; /* Average Link Delay - RFC 8570 */
541 uint32_t min_delay; /* Low Link Delay - RFC 8570 */
542 uint32_t max_delay; /* High Link Delay - RFC 8570 */
543 uint32_t delay_var; /* Link Delay Variation i.e. Jitter - RFC 8570 */
544 uint32_t pkt_loss; /* Unidirectional Link Packet Loss - RFC 8570 */
545 float res_bw; /* Unidirectional Residual Bandwidth - RFC 8570 */
546 float ava_bw; /* Unidirectional Available Bandwidth - RFC 8570 */
547 float use_bw; /* Unidirectional Utilized Bandwidth - RFC 8570 */
548
549 /* Segment Routing Adjacency & LAN Adjacency Segment ID */
550 struct isis_item_list adj_sid;
551 struct isis_item_list lan_sid;
5749ac83
LS
552
553 struct list *aslas;
554};
555
556/* RFC 8919 */
557#define ISIS_SABM_FLAG_R 0x80 /* RSVP-TE */
558#define ISIS_SABM_FLAG_S 0x40 /* Segment Routing Policy */
559#define ISIS_SABM_FLAG_L 0x20 /* Loop-Free Alternate */
560#define ISIS_SABM_FLAG_X 0x10 /* Flex-Algorithm - RFC9350 */
561
562#define ASLA_APP_IDENTIFIER_BIT_LENGTH 1
563#define ASLA_LEGACY_FLAG 0x80
564#define ASLA_APPS_LENGTH_MASK 0x7f
565
566struct isis_asla_subtlvs {
567 uint32_t status;
568
569 /* Application Specific Link Attribute - RFC 8919 */
570 bool legacy; /* L-Flag */
571 uint8_t standard_apps_length;
572 uint8_t user_def_apps_length;
573 uint8_t standard_apps;
574 uint8_t user_def_apps;
575
576 /* Sub-TLV list - rfc8919 section-3.1 */
577 uint32_t admin_group;
578 struct admin_group ext_admin_group; /* Res. Class/Color - RFC 7308 */
579 float max_bw; /* Maximum Bandwidth - RFC 5305 */
580 float max_rsv_bw; /* Maximum Reservable Bandwidth - RFC 5305 */
581 float unrsv_bw[8]; /* Unreserved Bandwidth - RFC 5305 */
582 uint32_t te_metric; /* Traffic Engineering Metric - RFC 5305 */
583 uint32_t delay; /* Average Link Delay - RFC 8570 */
584 uint32_t min_delay; /* Low Link Delay - RFC 8570 */
585 uint32_t max_delay; /* High Link Delay - RFC 8570 */
586 uint32_t delay_var; /* Link Delay Variation i.e. Jitter - RFC 8570 */
587 uint32_t pkt_loss; /* Unidirectional Link Packet Loss - RFC 8570 */
588 float res_bw; /* Unidirectional Residual Bandwidth - RFC 8570 */
589 float ava_bw; /* Unidirectional Available Bandwidth - RFC 8570 */
590 float use_bw; /* Unidirectional Utilized Bandwidth - RFC 8570 */
7ef5fefc
CF
591};
592
593#define IS_COMPAT_MT_TLV(tlv_type) \
594 ((tlv_type == ISIS_TLV_MT_REACH) || (tlv_type == ISIS_TLV_MT_IP_REACH) \
595 || (tlv_type == ISIS_TLV_MT_IPV6_REACH))
596
597struct stream;
598int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream,
599 size_t len_pointer, bool pad, bool is_lsp);
600void isis_free_tlvs(struct isis_tlvs *tlvs);
601struct isis_tlvs *isis_alloc_tlvs(void);
602int isis_unpack_tlvs(size_t avail_len, struct stream *stream,
603 struct isis_tlvs **dest, const char **error_log);
a2cac12a 604const char *isis_format_tlvs(struct isis_tlvs *tlvs, struct json_object *json);
7ef5fefc
CF
605struct isis_tlvs *isis_copy_tlvs(struct isis_tlvs *tlvs);
606struct list *isis_fragment_tlvs(struct isis_tlvs *tlvs, size_t size);
607
608#define ISIS_EXTENDED_IP_REACH_DOWN 0x80
609#define ISIS_EXTENDED_IP_REACH_SUBTLV 0x40
610
611#define ISIS_IPV6_REACH_DOWN 0x80
612#define ISIS_IPV6_REACH_EXTERNAL 0x40
613#define ISIS_IPV6_REACH_SUBTLV 0x20
614
615#ifndef ISIS_MT_MASK
616#define ISIS_MT_MASK 0x0fff
617#define ISIS_MT_OL_MASK 0x8000
618#define ISIS_MT_AT_MASK 0x4000
619#endif
620
5749ac83
LS
621/* RFC 8919 */
622#define ISIS_SABM_FLAG_R 0x80 /* RSVP-TE */
623#define ISIS_SABM_FLAG_S 0x40 /* Segment Routing Policy */
624#define ISIS_SABM_FLAG_L 0x20 /* Loop-Free Alternate */
625#define ISIS_SABM_FLAG_X 0x10 /* Flex-Algorithm - RFC9350 */
626
7ef5fefc
CF
627void isis_tlvs_add_auth(struct isis_tlvs *tlvs, struct isis_passwd *passwd);
628void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs,
629 struct list *addresses);
630void isis_tlvs_add_lan_neighbors(struct isis_tlvs *tlvs,
631 struct list *neighbors);
632void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs,
633 struct nlpids *nlpids);
634void isis_tlvs_add_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid,
635 bool overload, bool attached);
636void isis_tlvs_add_ipv4_address(struct isis_tlvs *tlvs, struct in_addr *addr);
637void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs,
638 struct list *addresses);
639void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs,
640 struct list *addresses);
173f8887
OD
641void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs,
642 struct list *addresses);
3380c990
EDP
643int isis_tlvs_auth_is_valid(struct isis_tlvs *tlvs, struct isis_passwd *passwd,
644 struct stream *stream, bool is_lsp);
7ef5fefc
CF
645bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs,
646 struct list *addresses);
647struct isis_adjacency;
648void isis_tlvs_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj,
649 bool *changed);
650bool isis_tlvs_own_snpa_found(struct isis_tlvs *tlvs, uint8_t *snpa);
651void isis_tlvs_add_lsp_entry(struct isis_tlvs *tlvs, struct isis_lsp *lsp);
652void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id,
653 uint8_t *stop_id, uint16_t num_lsps,
4bef0ec4
DL
654 struct lspdb_head *lspdb,
655 struct isis_lsp **last_lsp);
7ef5fefc
CF
656void isis_tlvs_set_dynamic_hostname(struct isis_tlvs *tlvs,
657 const char *hostname);
78774bbc
HS
658struct isis_router_cap *
659isis_tlvs_init_router_capability(struct isis_tlvs *tlvs);
660
661struct isis_area;
662struct isis_flex_algo;
663void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs,
664 struct flex_algo *fa, int algorithm,
665 uint8_t *sysid);
666
667struct isis_area;
e7948f8c
HS
668
669int isis_tlvs_sr_algo_count(const struct isis_router_cap *cap);
670
7ef5fefc
CF
671void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs,
672 const struct in_addr *id);
173f8887
OD
673void isis_tlvs_set_te_router_id_ipv6(struct isis_tlvs *tlvs,
674 const struct in6_addr *id);
7ef5fefc
CF
675void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs,
676 struct prefix_ipv4 *dest, uint8_t metric);
677void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs,
26f6acaf 678 struct prefix_ipv4 *dest, uint32_t metric,
0de7b433
HS
679 bool external,
680 struct sr_prefix_cfg **pcfgs);
7ef5fefc 681void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid,
26f6acaf 682 struct prefix_ipv6 *dest, uint32_t metric,
0de7b433 683 bool external, struct sr_prefix_cfg **pcfgs);
d43d2df5
CF
684void isis_tlvs_add_ipv6_dstsrc_reach(struct isis_tlvs *tlvs, uint16_t mtid,
685 struct prefix_ipv6 *dest,
686 struct prefix_ipv6 *src,
687 uint32_t metric);
1b3f47d0 688struct isis_ext_subtlvs *isis_alloc_ext_subtlvs(void);
1fa63850 689void isis_del_ext_subtlvs(struct isis_ext_subtlvs *ext);
1b3f47d0
OD
690void isis_tlvs_add_adj_sid(struct isis_ext_subtlvs *exts,
691 struct isis_adj_sid *adj);
692void isis_tlvs_del_adj_sid(struct isis_ext_subtlvs *exts,
693 struct isis_adj_sid *adj);
694void isis_tlvs_add_lan_adj_sid(struct isis_ext_subtlvs *exts,
695 struct isis_lan_adj_sid *lan);
696void isis_tlvs_del_lan_adj_sid(struct isis_ext_subtlvs *exts,
697 struct isis_lan_adj_sid *lan);
698
5749ac83
LS
699void isis_tlvs_del_asla_flex_algo(struct isis_ext_subtlvs *ext,
700 struct isis_asla_subtlvs *asla);
701struct isis_asla_subtlvs *
702isis_tlvs_find_alloc_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps);
703void isis_tlvs_free_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps);
704
7ef5fefc
CF
705void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id,
706 uint8_t metric);
707void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid,
708 uint8_t *id, uint32_t metric,
1b3f47d0 709 struct isis_ext_subtlvs *subtlvs);
7ef5fefc 710
9fe21208
CF
711const char *isis_threeway_state_name(enum isis_threeway_state state);
712
713void isis_tlvs_add_threeway_adj(struct isis_tlvs *tlvs,
714 enum isis_threeway_state state,
715 uint32_t local_circuit_id,
716 const uint8_t *neighbor_id,
717 uint32_t neighbor_circuit_id);
718
41a145f1
CF
719void isis_tlvs_add_spine_leaf(struct isis_tlvs *tlvs, uint8_t tier,
720 bool has_tier, bool is_leaf, bool is_spine,
721 bool is_backup);
722
7ef5fefc
CF
723struct isis_mt_router_info *
724isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid);
2c92bee4
CF
725
726void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs,
727 const uint8_t *generator,
728 const uint8_t *sender);
7ef5fefc 729#endif