]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_tlvs.h
isisd: retrofit the 'max-lsp-lifetime' command
[mirror_frr.git] / isisd / isis_tlvs.h
CommitLineData
7ef5fefc
CF
1/*
2 * IS-IS TLV Serializer/Deserializer
3 *
4 * Copyright (C) 2015,2017 Christian Franke
5 *
6 * This file is part of FRR.
7 *
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with FRR; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * 02111-1307, USA.
22 */
841791b6
CF
23#ifndef ISIS_TLVS_H
24#define ISIS_TLVS_H
7ef5fefc
CF
25
26#include "openbsd-tree.h"
27#include "prefix.h"
28#include "isisd/dict.h"
29
30struct isis_subtlvs;
31
32struct isis_area_address;
33struct isis_area_address {
34 struct isis_area_address *next;
35
36 uint8_t addr[20];
37 uint8_t len;
38};
39
40struct isis_oldstyle_reach;
41struct isis_oldstyle_reach {
42 struct isis_oldstyle_reach *next;
43
44 uint8_t id[7];
45 uint8_t metric;
46};
47
48struct isis_oldstyle_ip_reach;
49struct isis_oldstyle_ip_reach {
50 struct isis_oldstyle_ip_reach *next;
51
52 uint8_t metric;
53 struct prefix_ipv4 prefix;
54};
55
56struct isis_lsp_entry;
57struct isis_lsp_entry {
58 struct isis_lsp_entry *next;
59
60 uint16_t rem_lifetime;
61 uint8_t id[8];
62 uint16_t checksum;
63 uint32_t seqno;
64
65 struct isis_lsp *lsp;
66};
67
68struct isis_extended_reach;
69struct isis_extended_reach {
70 struct isis_extended_reach *next;
71
72 uint8_t id[7];
73 uint32_t metric;
74
75 uint8_t *subtlvs;
76 uint8_t subtlv_len;
77};
78
79struct isis_extended_ip_reach;
80struct 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
90struct isis_ipv6_reach;
91struct isis_ipv6_reach {
92 struct isis_ipv6_reach *next;
93
94 uint32_t metric;
95 bool down;
96 bool external;
97
98 struct prefix_ipv6 prefix;
99
100 struct isis_subtlvs *subtlvs;
101};
102
103struct isis_protocols_supported {
104 uint8_t count;
105 uint8_t *protocols;
106};
107
41a145f1
CF
108#define ISIS_TIER_UNDEFINED 15
109
110struct isis_spine_leaf {
111 uint8_t tier;
112
113 bool has_tier;
114 bool is_leaf;
115 bool is_spine;
116 bool is_backup;
117};
118
9fe21208
CF
119enum isis_threeway_state {
120 ISIS_THREEWAY_DOWN = 2,
121 ISIS_THREEWAY_INITIALIZING = 1,
122 ISIS_THREEWAY_UP = 0
123};
124
125struct isis_threeway_adj {
126 enum isis_threeway_state state;
127 uint32_t local_circuit_id;
128 bool neighbor_set;
129 uint8_t neighbor_id[6];
130 uint32_t neighbor_circuit_id;
131};
132
7ef5fefc
CF
133struct isis_item;
134struct isis_item {
135 struct isis_item *next;
136};
137
138struct isis_lan_neighbor;
139struct isis_lan_neighbor {
140 struct isis_lan_neighbor *next;
141
142 uint8_t mac[6];
143};
144
145struct isis_ipv4_address;
146struct isis_ipv4_address {
147 struct isis_ipv4_address *next;
148
149 struct in_addr addr;
150};
151
152struct isis_ipv6_address;
153struct isis_ipv6_address {
154 struct isis_ipv6_address *next;
155
156 struct in6_addr addr;
157};
158
159struct isis_mt_router_info;
160struct isis_mt_router_info {
161 struct isis_mt_router_info *next;
162
163 bool overload;
164 bool attached;
165 uint16_t mtid;
166};
167
168struct isis_auth;
169struct isis_auth {
170 struct isis_auth *next;
171
172 uint8_t type;
173 uint8_t length;
174 uint8_t value[256];
175
176 uint8_t plength;
177 uint8_t passwd[256];
178
179 size_t offset; /* Only valid after packing */
180};
181
182struct isis_item_list;
183struct isis_item_list {
184 struct isis_item *head;
185 struct isis_item **tail;
186
187 RB_ENTRY(isis_item_list) mt_tree;
188 uint16_t mtid;
189 unsigned int count;
190};
191
5f77d901
CF
192struct isis_purge_originator {
193 bool sender_set;
194
195 uint8_t generator[6];
196 uint8_t sender[6];
197};
198
7ef5fefc
CF
199RB_HEAD(isis_mt_item_list, isis_item_list);
200
201struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m,
202 uint16_t mtid);
203struct isis_item_list *isis_lookup_mt_items(struct isis_mt_item_list *m,
204 uint16_t mtid);
205
206struct isis_tlvs {
207 struct isis_item_list isis_auth;
5f77d901 208 struct isis_purge_originator *purge_originator;
7ef5fefc
CF
209 struct isis_item_list area_addresses;
210 struct isis_item_list oldstyle_reach;
211 struct isis_item_list lan_neighbor;
212 struct isis_item_list lsp_entries;
213 struct isis_item_list extended_reach;
214 struct isis_mt_item_list mt_reach;
215 struct isis_item_list oldstyle_ip_reach;
216 struct isis_protocols_supported protocols_supported;
217 struct isis_item_list oldstyle_ip_reach_ext;
218 struct isis_item_list ipv4_address;
219 struct isis_item_list ipv6_address;
220 struct isis_item_list mt_router_info;
221 bool mt_router_info_empty;
222 struct in_addr *te_router_id;
223 struct isis_item_list extended_ip_reach;
224 struct isis_mt_item_list mt_ip_reach;
225 char *hostname;
226 struct isis_item_list ipv6_reach;
227 struct isis_mt_item_list mt_ipv6_reach;
9fe21208 228 struct isis_threeway_adj *threeway_adj;
41a145f1 229 struct isis_spine_leaf *spine_leaf;
7ef5fefc
CF
230};
231
bd507085
CF
232#define ISIS_PREFIX_SID_READVERTISED 0x80
233#define ISIS_PREFIX_SID_NODE 0x40
234#define ISIS_PREFIX_SID_NO_PHP 0x20
235#define ISIS_PREFIX_SID_EXPLICIT_NULL 0x10
236#define ISIS_PREFIX_SID_VALUE 0x08
237#define ISIS_PREFIX_SID_LOCAL 0x04
238
239struct isis_prefix_sid;
240struct isis_prefix_sid {
241 struct isis_prefix_sid *next;
242
243 uint8_t flags;
244 uint8_t algorithm;
245
246 uint32_t value;
7ef5fefc
CF
247};
248
249enum isis_tlv_context {
250 ISIS_CONTEXT_LSP,
251 ISIS_CONTEXT_SUBTLV_NE_REACH,
252 ISIS_CONTEXT_SUBTLV_IP_REACH,
253 ISIS_CONTEXT_SUBTLV_IPV6_REACH,
254 ISIS_CONTEXT_MAX
255};
256
bd507085
CF
257struct isis_subtlvs {
258 enum isis_tlv_context context;
259
260 /* draft-baker-ipv6-isis-dst-src-routing-06 */
261 struct prefix_ipv6 *source_prefix;
262 /* draft-ietf-isis-segment-routing-extensions-16 */
263 struct isis_item_list prefix_sids;
264};
265
7ef5fefc
CF
266enum isis_tlv_type {
267 ISIS_TLV_AREA_ADDRESSES = 1,
268 ISIS_TLV_OLDSTYLE_REACH = 2,
269 ISIS_TLV_LAN_NEIGHBORS = 6,
270 ISIS_TLV_PADDING = 8,
271 ISIS_TLV_LSP_ENTRY = 9,
272 ISIS_TLV_AUTH = 10,
5f77d901 273 ISIS_TLV_PURGE_ORIGINATOR = 13,
7ef5fefc
CF
274 ISIS_TLV_EXTENDED_REACH = 22,
275
276 ISIS_TLV_OLDSTYLE_IP_REACH = 128,
277 ISIS_TLV_PROTOCOLS_SUPPORTED = 129,
278 ISIS_TLV_OLDSTYLE_IP_REACH_EXT = 130,
279 ISIS_TLV_IPV4_ADDRESS = 132,
280 ISIS_TLV_TE_ROUTER_ID = 134,
281 ISIS_TLV_EXTENDED_IP_REACH = 135,
282 ISIS_TLV_DYNAMIC_HOSTNAME = 137,
41a145f1 283 ISIS_TLV_SPINE_LEAF_EXT = 150,
7ef5fefc
CF
284 ISIS_TLV_MT_REACH = 222,
285 ISIS_TLV_MT_ROUTER_INFO = 229,
286 ISIS_TLV_IPV6_ADDRESS = 232,
287 ISIS_TLV_MT_IP_REACH = 235,
288 ISIS_TLV_IPV6_REACH = 236,
289 ISIS_TLV_MT_IPV6_REACH = 237,
9fe21208 290 ISIS_TLV_THREE_WAY_ADJ = 240,
7ef5fefc
CF
291 ISIS_TLV_MAX = 256,
292
bd507085 293 ISIS_SUBTLV_PREFIX_SID = 3,
7ef5fefc
CF
294 ISIS_SUBTLV_IPV6_SOURCE_PREFIX = 22
295};
296
297#define IS_COMPAT_MT_TLV(tlv_type) \
298 ((tlv_type == ISIS_TLV_MT_REACH) || (tlv_type == ISIS_TLV_MT_IP_REACH) \
299 || (tlv_type == ISIS_TLV_MT_IPV6_REACH))
300
301struct stream;
302int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream,
303 size_t len_pointer, bool pad, bool is_lsp);
304void isis_free_tlvs(struct isis_tlvs *tlvs);
305struct isis_tlvs *isis_alloc_tlvs(void);
306int isis_unpack_tlvs(size_t avail_len, struct stream *stream,
307 struct isis_tlvs **dest, const char **error_log);
308const char *isis_format_tlvs(struct isis_tlvs *tlvs);
309struct isis_tlvs *isis_copy_tlvs(struct isis_tlvs *tlvs);
310struct list *isis_fragment_tlvs(struct isis_tlvs *tlvs, size_t size);
311
312#define ISIS_EXTENDED_IP_REACH_DOWN 0x80
313#define ISIS_EXTENDED_IP_REACH_SUBTLV 0x40
314
315#define ISIS_IPV6_REACH_DOWN 0x80
316#define ISIS_IPV6_REACH_EXTERNAL 0x40
317#define ISIS_IPV6_REACH_SUBTLV 0x20
318
319#ifndef ISIS_MT_MASK
320#define ISIS_MT_MASK 0x0fff
321#define ISIS_MT_OL_MASK 0x8000
322#define ISIS_MT_AT_MASK 0x4000
323#endif
324
325
326void isis_tlvs_add_auth(struct isis_tlvs *tlvs, struct isis_passwd *passwd);
327void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs,
328 struct list *addresses);
329void isis_tlvs_add_lan_neighbors(struct isis_tlvs *tlvs,
330 struct list *neighbors);
331void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs,
332 struct nlpids *nlpids);
333void isis_tlvs_add_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid,
334 bool overload, bool attached);
335void isis_tlvs_add_ipv4_address(struct isis_tlvs *tlvs, struct in_addr *addr);
336void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs,
337 struct list *addresses);
338void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs,
339 struct list *addresses);
340bool isis_tlvs_auth_is_valid(struct isis_tlvs *tlvs, struct isis_passwd *passwd,
341 struct stream *stream, bool is_lsp);
342bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs,
343 struct list *addresses);
344struct isis_adjacency;
345void isis_tlvs_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj,
346 bool *changed);
347bool isis_tlvs_own_snpa_found(struct isis_tlvs *tlvs, uint8_t *snpa);
348void isis_tlvs_add_lsp_entry(struct isis_tlvs *tlvs, struct isis_lsp *lsp);
349void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id,
350 uint8_t *stop_id, uint16_t num_lsps,
351 dict_t *lspdb, struct isis_lsp **last_lsp);
352void isis_tlvs_set_dynamic_hostname(struct isis_tlvs *tlvs,
353 const char *hostname);
354void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs,
355 const struct in_addr *id);
356void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs,
357 struct prefix_ipv4 *dest, uint8_t metric);
358void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs,
359 struct prefix_ipv4 *dest, uint32_t metric);
360void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid,
361 struct prefix_ipv6 *dest, uint32_t metric);
d43d2df5
CF
362void isis_tlvs_add_ipv6_dstsrc_reach(struct isis_tlvs *tlvs, uint16_t mtid,
363 struct prefix_ipv6 *dest,
364 struct prefix_ipv6 *src,
365 uint32_t metric);
7ef5fefc
CF
366void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id,
367 uint8_t metric);
368void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid,
369 uint8_t *id, uint32_t metric,
370 uint8_t *subtlvs, uint8_t subtlv_len);
371
9fe21208
CF
372const char *isis_threeway_state_name(enum isis_threeway_state state);
373
374void isis_tlvs_add_threeway_adj(struct isis_tlvs *tlvs,
375 enum isis_threeway_state state,
376 uint32_t local_circuit_id,
377 const uint8_t *neighbor_id,
378 uint32_t neighbor_circuit_id);
379
41a145f1
CF
380void isis_tlvs_add_spine_leaf(struct isis_tlvs *tlvs, uint8_t tier,
381 bool has_tier, bool is_leaf, bool is_spine,
382 bool is_backup);
383
7ef5fefc
CF
384struct isis_mt_router_info *
385isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid);
2c92bee4
CF
386
387void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs,
388 const uint8_t *generator,
389 const uint8_t *sender);
7ef5fefc 390#endif