]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_tlvs.h
pimd: When doing json output do not output non-json strings
[mirror_frr.git] / isisd / isis_tlvs.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * IS-IS TLV Serializer/Deserializer
4 *
5 * Copyright (C) 2015,2017 Christian Franke
6
7 * Copyright (C) 2019 Olivier Dugeon - Orange Labs (for TE and SR)
8 */
9 #ifndef ISIS_TLVS_H
10 #define ISIS_TLVS_H
11
12 #include "segment_routing.h"
13 #include "openbsd-tree.h"
14 #include "prefix.h"
15 #include "flex_algo.h"
16 #include "affinitymap.h"
17
18
19 DECLARE_MTYPE(ISIS_SUBTLV);
20
21 struct lspdb_head;
22 struct sr_prefix_cfg;
23
24 struct isis_area_address {
25 struct isis_area_address *next;
26
27 uint8_t addr[20];
28 uint8_t len;
29 };
30
31 #define ISIS_WIDE_METRIC_INFINITY 0xFFFFFE
32 #define ISIS_NARROW_METRIC_INFINITY 62
33
34 struct isis_oldstyle_reach {
35 struct isis_oldstyle_reach *next;
36
37 uint8_t id[7];
38 uint8_t metric;
39 };
40
41 struct isis_oldstyle_ip_reach {
42 struct isis_oldstyle_ip_reach *next;
43
44 uint8_t metric;
45 struct prefix_ipv4 prefix;
46 };
47
48 struct 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
59 struct isis_extended_reach {
60 struct isis_extended_reach *next;
61
62 uint8_t id[7];
63 uint32_t metric;
64
65 struct isis_ext_subtlvs *subtlvs;
66 };
67
68 struct isis_extended_ip_reach {
69 struct isis_extended_ip_reach *next;
70
71 uint32_t metric;
72 bool down;
73 struct prefix_ipv4 prefix;
74
75 struct isis_subtlvs *subtlvs;
76 };
77
78 struct 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
90 struct isis_protocols_supported {
91 uint8_t count;
92 uint8_t *protocols;
93 };
94
95 #define ISIS_TIER_UNDEFINED 15
96
97 struct 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
106 enum isis_threeway_state {
107 ISIS_THREEWAY_DOWN = 2,
108 ISIS_THREEWAY_INITIALIZING = 1,
109 ISIS_THREEWAY_UP = 0,
110 };
111
112 struct 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
120 /* Segment Routing subTLV's as per RFC8667 */
121 #define ISIS_SUBTLV_SRGB_FLAG_I 0x80
122 #define ISIS_SUBTLV_SRGB_FLAG_V 0x40
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)
125 #define SUBTLV_SR_BLOCK_SIZE 6
126 #define SUBTLV_RANGE_INDEX_SIZE 10
127 #define SUBTLV_RANGE_LABEL_SIZE 9
128
129 /* Structure aggregating SR Global (SRGB) or Local (SRLB) Block info */
130 struct isis_sr_block {
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
144 struct 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
160 struct 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
169 struct 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
184 #define MSD_TYPE_BASE_MPLS_IMPOSITION 0x01
185 #define MSD_TLV_SIZE 2
186
187 #ifndef FABRICD
188 struct isis_router_cap_fad;
189 struct 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
196 struct isis_router_cap {
197 struct in_addr router_id;
198 uint8_t flags;
199
200 /* RFC 8667 section #3 */
201 struct isis_sr_block srgb;
202 struct isis_sr_block srlb;
203 uint8_t algo[SR_ALGORITHM_COUNT];
204 /* RFC 8491 */
205 uint8_t msd;
206
207 #ifndef FABRICD
208 /* RFC9350 Flex-Algorithm */
209 struct isis_router_cap_fad *fads[SR_ALGORITHM_COUNT];
210 #endif /* ifndef FABRICD */
211 };
212
213 struct isis_item {
214 struct isis_item *next;
215 };
216
217 struct isis_lan_neighbor {
218 struct isis_lan_neighbor *next;
219
220 uint8_t mac[6];
221 };
222
223 struct isis_ipv4_address {
224 struct isis_ipv4_address *next;
225
226 struct in_addr addr;
227 };
228
229 struct isis_ipv6_address {
230 struct isis_ipv6_address *next;
231
232 struct in6_addr addr;
233 };
234
235 struct isis_mt_router_info {
236 struct isis_mt_router_info *next;
237
238 bool overload;
239 bool attached;
240 uint16_t mtid;
241 };
242
243 struct 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
256 struct 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
265 struct isis_purge_originator {
266 bool sender_set;
267
268 uint8_t generator[6];
269 uint8_t sender[6];
270 };
271
272 enum isis_auth_result {
273 ISIS_AUTH_OK = 0,
274 ISIS_AUTH_TYPE_FAILURE,
275 ISIS_AUTH_FAILURE,
276 ISIS_AUTH_NO_VALIDATOR,
277 };
278
279 RB_HEAD(isis_mt_item_list, isis_item_list);
280
281 struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m,
282 uint16_t mtid);
283 struct isis_item_list *isis_lookup_mt_items(struct isis_mt_item_list *m,
284 uint16_t mtid);
285
286 struct isis_tlvs {
287 struct isis_item_list isis_auth;
288 struct isis_purge_originator *purge_originator;
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;
300 struct isis_item_list global_ipv6_address;
301 struct isis_item_list mt_router_info;
302 bool mt_router_info_empty;
303 struct in_addr *te_router_id;
304 struct in6_addr *te_router_id_ipv6;
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;
310 struct isis_threeway_adj *threeway_adj;
311 struct isis_router_cap *router_cap;
312 struct isis_spine_leaf *spine_leaf;
313 };
314
315 enum 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,
320 ISIS_CONTEXT_MAX,
321 };
322
323 struct isis_subtlvs {
324 enum isis_tlv_context context;
325
326 /* draft-baker-ipv6-isis-dst-src-routing-06 */
327 struct prefix_ipv6 *source_prefix;
328 /* RFC 8667 section #2.4 */
329 struct isis_item_list prefix_sids;
330 };
331
332 enum isis_tlv_type {
333 /* TLVs code point */
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,
340 ISIS_TLV_PURGE_ORIGINATOR = 13,
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,
350 ISIS_TLV_TE_ROUTER_ID_IPV6 = 140,
351 ISIS_TLV_SPINE_LEAF_EXT = 150,
352 ISIS_TLV_MT_REACH = 222,
353 ISIS_TLV_MT_ROUTER_INFO = 229,
354 ISIS_TLV_IPV6_ADDRESS = 232,
355 ISIS_TLV_GLOBAL_IPV6_ADDRESS = 233,
356 ISIS_TLV_MT_IP_REACH = 235,
357 ISIS_TLV_IPV6_REACH = 236,
358 ISIS_TLV_MT_IPV6_REACH = 237,
359 ISIS_TLV_THREE_WAY_ADJ = 240,
360 ISIS_TLV_ROUTER_CAPABILITY = 242,
361 ISIS_TLV_MAX = 256,
362
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
380 /* RFC 8491 */
381 ISIS_SUBTLV_NODE_MSD = 23,
382
383 /* RFC 5316 */
384 ISIS_SUBTLV_RAS = 24,
385 ISIS_SUBTLV_RIP = 25,
386
387 /* RFC 8667 section #4 IANA allocation */
388 ISIS_SUBTLV_SID_LABEL = 1,
389 ISIS_SUBTLV_SID_LABEL_RANGE = 2,
390 ISIS_SUBTLV_ALGORITHM = 19,
391 ISIS_SUBTLV_SRLB = 22,
392 ISIS_SUBTLV_PREFIX_SID = 3,
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
405 /* RFC 7308 */
406 ISIS_SUBTLV_EXT_ADMIN_GRP = 14,
407
408 /* RFC 8919 */
409 ISIS_SUBTLV_ASLA = 16,
410
411 /* draft-ietf-lsr-isis-srv6-extensions */
412 ISIS_SUBTLV_SID_END = 5,
413 ISIS_SUBTLV_SID_END_X = 43,
414
415 ISIS_SUBTLV_MAX = 40,
416
417 /* draft-ietf-lsr-isis-srv6-extensions */
418 ISIS_SUBSUBTLV_SID_STRUCTURE = 1,
419
420 ISIS_SUBSUBTLV_MAX = 256,
421 };
422
423 /* subTLVs size for TE and SR */
424 enum ext_subtlv_size {
425 /* RFC 5307 */
426 ISIS_SUBTLV_LLRI_SIZE = 8,
427
428 /* RFC 5305 & RFC 6119 */
429 ISIS_SUBTLV_UNRSV_BW_SIZE = 32,
430 ISIS_SUBTLV_TE_METRIC_SIZE = 3,
431 ISIS_SUBTLV_IPV6_ADDR_SIZE = 16,
432
433 /* RFC 8491 */
434 ISIS_SUBTLV_NODE_MSD_SIZE = 2,
435
436 /* RFC 8667 sections #2 & #3 */
437 ISIS_SUBTLV_SID_LABEL_SIZE = 3,
438 ISIS_SUBTLV_SID_INDEX_SIZE = 4,
439 ISIS_SUBTLV_SID_LABEL_RANGE_SIZE = 9,
440 ISIS_SUBTLV_ALGORITHM_SIZE = 4,
441 ISIS_SUBTLV_ADJ_SID_SIZE = 5,
442 ISIS_SUBTLV_LAN_ADJ_SID_SIZE = 11,
443 ISIS_SUBTLV_PREFIX_SID_SIZE = 5,
444
445 /* RFC 7810 */
446 ISIS_SUBTLV_MM_DELAY_SIZE = 8,
447
448 /* RFC9350 - Flex-Algorithm */
449 ISIS_SUBTLV_FAD = 26,
450 ISIS_SUBTLV_FAD_MIN_SIZE = 4,
451
452 ISIS_SUBTLV_HDR_SIZE = 2,
453 ISIS_SUBTLV_DEF_SIZE = 4,
454
455 ISIS_SUBTLV_MAX_SIZE = 180,
456
457 /* draft-ietf-lsr-isis-srv6-extensions */
458 ISIS_SUBSUBTLV_SID_STRUCTURE_SIZE = 4,
459
460 ISIS_SUBSUBTLV_HDR_SIZE = 2,
461 ISIS_SUBSUBTLV_MAX_SIZE = 180,
462
463 /* RFC9350 - Flex-Algorithm */
464 ISIS_SUBTLV_FAD_SUBSUBTLV_FLAGS_SIZE = 1,
465 };
466
467 enum 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,
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)
479 #define RESET_SUBTLV(s) (s->status = 0)
480 #define NO_SUBTLV(s) (s->status == 0)
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
504 #define EXT_EXTEND_ADM_GRP 0x200000
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 */
518 #define IS_ANORMAL(v) (v & TE_EXT_ANORMAL)
519
520 struct isis_ext_subtlvs {
521
522 uint32_t status;
523
524 uint32_t adm_group; /* Resource Class/Color - RFC 5305 */
525 struct admin_group ext_admin_group; /* Res. Class/Color - RFC 7308 */
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;
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
566 struct 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 */
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
597 struct stream;
598 int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream,
599 size_t len_pointer, bool pad, bool is_lsp);
600 void isis_free_tlvs(struct isis_tlvs *tlvs);
601 struct isis_tlvs *isis_alloc_tlvs(void);
602 int isis_unpack_tlvs(size_t avail_len, struct stream *stream,
603 struct isis_tlvs **dest, const char **error_log);
604 const char *isis_format_tlvs(struct isis_tlvs *tlvs, struct json_object *json);
605 struct isis_tlvs *isis_copy_tlvs(struct isis_tlvs *tlvs);
606 struct 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
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
627 void isis_tlvs_add_auth(struct isis_tlvs *tlvs, struct isis_passwd *passwd);
628 void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs,
629 struct list *addresses);
630 void isis_tlvs_add_lan_neighbors(struct isis_tlvs *tlvs,
631 struct list *neighbors);
632 void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs,
633 struct nlpids *nlpids);
634 void isis_tlvs_add_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid,
635 bool overload, bool attached);
636 void isis_tlvs_add_ipv4_address(struct isis_tlvs *tlvs, struct in_addr *addr);
637 void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs,
638 struct list *addresses);
639 void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs,
640 struct list *addresses);
641 void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs,
642 struct list *addresses);
643 int isis_tlvs_auth_is_valid(struct isis_tlvs *tlvs, struct isis_passwd *passwd,
644 struct stream *stream, bool is_lsp);
645 bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs,
646 struct list *addresses);
647 struct isis_adjacency;
648 void isis_tlvs_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj,
649 bool *changed);
650 bool isis_tlvs_own_snpa_found(struct isis_tlvs *tlvs, uint8_t *snpa);
651 void isis_tlvs_add_lsp_entry(struct isis_tlvs *tlvs, struct isis_lsp *lsp);
652 void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id,
653 uint8_t *stop_id, uint16_t num_lsps,
654 struct lspdb_head *lspdb,
655 struct isis_lsp **last_lsp);
656 void isis_tlvs_set_dynamic_hostname(struct isis_tlvs *tlvs,
657 const char *hostname);
658 struct isis_router_cap *
659 isis_tlvs_init_router_capability(struct isis_tlvs *tlvs);
660
661 struct isis_area;
662 struct isis_flex_algo;
663 void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs,
664 struct flex_algo *fa, int algorithm,
665 uint8_t *sysid);
666
667 struct isis_area;
668
669 int isis_tlvs_sr_algo_count(const struct isis_router_cap *cap);
670
671 void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs,
672 const struct in_addr *id);
673 void isis_tlvs_set_te_router_id_ipv6(struct isis_tlvs *tlvs,
674 const struct in6_addr *id);
675 void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs,
676 struct prefix_ipv4 *dest, uint8_t metric);
677 void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs,
678 struct prefix_ipv4 *dest, uint32_t metric,
679 bool external,
680 struct sr_prefix_cfg **pcfgs);
681 void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid,
682 struct prefix_ipv6 *dest, uint32_t metric,
683 bool external, struct sr_prefix_cfg **pcfgs);
684 void 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);
688 struct isis_ext_subtlvs *isis_alloc_ext_subtlvs(void);
689 void isis_del_ext_subtlvs(struct isis_ext_subtlvs *ext);
690 void isis_tlvs_add_adj_sid(struct isis_ext_subtlvs *exts,
691 struct isis_adj_sid *adj);
692 void isis_tlvs_del_adj_sid(struct isis_ext_subtlvs *exts,
693 struct isis_adj_sid *adj);
694 void isis_tlvs_add_lan_adj_sid(struct isis_ext_subtlvs *exts,
695 struct isis_lan_adj_sid *lan);
696 void isis_tlvs_del_lan_adj_sid(struct isis_ext_subtlvs *exts,
697 struct isis_lan_adj_sid *lan);
698
699 void isis_tlvs_del_asla_flex_algo(struct isis_ext_subtlvs *ext,
700 struct isis_asla_subtlvs *asla);
701 struct isis_asla_subtlvs *
702 isis_tlvs_find_alloc_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps);
703 void isis_tlvs_free_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps);
704
705 void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id,
706 uint8_t metric);
707 void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid,
708 uint8_t *id, uint32_t metric,
709 struct isis_ext_subtlvs *subtlvs);
710
711 const char *isis_threeway_state_name(enum isis_threeway_state state);
712
713 void 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
719 void 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
723 struct isis_mt_router_info *
724 isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid);
725
726 void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs,
727 const uint8_t *generator,
728 const uint8_t *sender);
729 #endif