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