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