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