]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_tlv.h
*: make consistent & update GPLv2 file headers
[mirror_frr.git] / isisd / isis_tlv.h
1 /*
2 * IS-IS Rout(e)ing protocol - isis_tlv.h
3 * IS-IS TLV related routines
4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
6 * Tampere University of Technology
7 * Institute of Communications Engineering
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public Licenseas published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef _ZEBRA_ISIS_TLV_H
25 #define _ZEBRA_ISIS_TLV_H
26
27 #include "isisd/isis_mt.h"
28
29 /*
30 * The list of TLVs we (should) support.
31 * ____________________________________________________________________________
32 * Name Value IIH LSP SNP Status
33 * LAN
34 * ____________________________________________________________________________
35 *
36 * Area Addresses 1 y y n ISO10589
37 * IIS Neighbors 2 n y n ISO10589
38 * ES Neighbors 3 n y n ISO10589
39 * IIS Neighbors 6 y n n ISO10589
40 * Padding 8 y n n ISO10589
41 * LSP Entries 9 n n y ISO10589
42 * Authentication 10 y y y ISO10589, RFC3567
43 * Checksum 12 y n y RFC3358
44 * Extended IS Reachability 22 n y n RFC5305
45 * IS Alias 24 n y n RFC3786
46 * IP Int. Reachability 128 n y n RFC1195
47 * Protocols Supported 129 y y n RFC1195
48 * IP Ext. Reachability 130 n y n RFC1195
49 * IDRPI 131 n y y RFC1195
50 * IP Interface Address 132 y y n RFC1195
51 * TE Router ID 134 n y n RFC5305
52 * Extended IP Reachability 135 n y n RFC5305
53 * Dynamic Hostname 137 n y n RFC2763
54 * Shared Risk Link Group 138 n y y RFC5307
55 * Inter-AS Reachability 141 n y n RFC5316
56 * Restart TLV 211 y n n RFC3847
57 * MT IS Reachability 222 n y n RFC5120
58 * MT Supported 229 y y n RFC5120
59 * IPv6 Interface Address 232 y y n RFC5308
60 * MT IP Reachability 235 n y n RFC5120
61 * IPv6 IP Reachability 236 n y n RFC5308
62 * MT IPv6 IP Reachability 237 n y n RFC5120
63 * P2P Adjacency State 240 y n n RFC3373
64 * IIH Sequence Number 241 y n n draft-shen-isis-iih-sequence
65 * Router Capability 242 n y n RFC4971
66 *
67 *
68 * IS Reachability sub-TLVs we support (See isis_te.[c,h])
69 * ____________________________________________________________________________
70 * Name Value Status
71 * ____________________________________________________________________________
72 * Administartive group (color) 3 RFC5305
73 * Link Local/Remote Identifiers 4 RFC5307
74 * IPv4 interface address 6 RFC5305
75 * IPv4 neighbor address 8 RFC5305
76 * Maximum link bandwidth 9 RFC5305
77 * Reservable link bandwidth 10 RFC5305
78 * Unreserved bandwidth 11 RFC5305
79 * TE Default metric 18 RFC5305
80 * Link Protection Type 20 RFC5307
81 * Interface Switching Capability 21 RFC5307
82 * Remote AS number 24 RFC5316
83 * IPv4 Remote ASBR identifier 25 RFC5316
84 *
85 *
86 * IP Reachability sub-TLVs we (should) support.
87 * ____________________________________________________________________________
88 * Name Value Status
89 * ____________________________________________________________________________
90 * 32bit administrative tag 1 RFC5130
91 * 64bit administrative tag 2 RFC5130
92 * Management prefix color 117 RFC5120
93 */
94
95 #define AREA_ADDRESSES 1
96 #define IS_NEIGHBOURS 2
97 #define ES_NEIGHBOURS 3
98 #define LAN_NEIGHBOURS 6
99 #define PADDING 8
100 #define LSP_ENTRIES 9
101 #define AUTH_INFO 10
102 #define CHECKSUM 12
103 #define TE_IS_NEIGHBOURS 22
104 #define IS_ALIAS 24
105 #define IPV4_INT_REACHABILITY 128
106 #define PROTOCOLS_SUPPORTED 129
107 #define IPV4_EXT_REACHABILITY 130
108 #define IDRP_INFO 131
109 #define IPV4_ADDR 132
110 #define TE_ROUTER_ID 134
111 #define TE_IPV4_REACHABILITY 135
112 #define DYNAMIC_HOSTNAME 137
113 #define GRACEFUL_RESTART 211
114 #define MT_IS_NEIGHBOURS 222
115 #define MT_ROUTER_INFORMATION 229
116 #define IPV6_ADDR 232
117 #define MT_IPV4_REACHABILITY 235
118 #define IPV6_REACHABILITY 236
119 #define MT_IPV6_REACHABILITY 237
120 #define WAY3_HELLO 240
121 #define ROUTER_INFORMATION 242
122
123 #define AUTH_INFO_HDRLEN 3
124
125 #define MAX_TLV_LEN 255
126
127 #define IS_NEIGHBOURS_LEN (ISIS_SYS_ID_LEN + 5)
128 #define LAN_NEIGHBOURS_LEN 6
129 #define LSP_ENTRIES_LEN (10 + ISIS_SYS_ID_LEN) /* FIXME: should be entry */
130 #define IPV4_REACH_LEN 12
131 #define IPV6_REACH_LEN 22
132 #define TE_IPV4_REACH_LEN 9
133
134 #define MAX_SUBTLV_SIZE 256
135
136 /* struct for neighbor */
137 struct is_neigh
138 {
139 struct metric metrics;
140 u_char neigh_id[ISIS_SYS_ID_LEN + 1];
141 };
142
143 /* struct for te metric */
144 struct te_is_neigh
145 {
146 u_char neigh_id[ISIS_SYS_ID_LEN + 1];
147 u_char te_metric[3];
148 u_char sub_tlvs_length;
149 /* Theorical Maximum SubTLVs is 256 because the sub_tlvs_length is 8 bits */
150 /* Practically, 118 bytes are necessary to store all supported TE parameters */
151 /* FIXME: A pointer will use less memory, but need to be free */
152 /* which is hard to fix, especially within free_tlvs() function */
153 /* and malloc() / free() as a CPU cost compared to the memory usage */
154 u_char sub_tlvs[MAX_SUBTLV_SIZE]; /* SUB TLVs storage */
155 };
156
157 /* Decode and encode three-octet metric into host byte order integer */
158 #define GET_TE_METRIC(t) \
159 (((unsigned)(t)->te_metric[0]<<16) | ((t)->te_metric[1]<<8) | \
160 (t)->te_metric[2])
161 #define SET_TE_METRIC(t, m) \
162 (((t)->te_metric[0] = (m) >> 16), \
163 ((t)->te_metric[1] = (m) >> 8), \
164 ((t)->te_metric[2] = (m)))
165
166 /* struct for es neighbors */
167 struct es_neigh
168 {
169 struct metric metrics;
170 /* approximate position of first, we use the
171 * length ((uchar*)metric-1) to know all */
172 u_char first_es_neigh[ISIS_SYS_ID_LEN];
173
174 };
175
176 struct partition_desig_level2_is
177 {
178 struct list *isis_system_ids;
179 };
180
181 /* struct for lan neighbors */
182 struct lan_neigh
183 {
184 u_char LAN_addr[6];
185 };
186
187 #ifdef __SUNPRO_C
188 #pragma pack(1)
189 #endif
190
191 /* struct for LSP entry */
192 struct lsp_entry
193 {
194 u_int16_t rem_lifetime;
195 u_char lsp_id[ISIS_SYS_ID_LEN + 2];
196 u_int32_t seq_num;
197 u_int16_t checksum;
198 } __attribute__ ((packed));
199
200 #ifdef __SUNPRO_C
201 #pragma pack()
202 #endif
203
204 /* struct for checksum */
205 struct checksum
206 {
207 u_int16_t checksum;
208 };
209
210 /* ipv4 reachability */
211 struct ipv4_reachability
212 {
213 struct metric metrics;
214 struct in_addr prefix;
215 struct in_addr mask;
216 };
217
218 /* te router id */
219 struct te_router_id
220 {
221 struct in_addr id;
222 };
223
224 /* te ipv4 reachability */
225 struct te_ipv4_reachability
226 {
227 u_int32_t te_metric;
228 u_char control;
229 u_char prefix_start; /* since this is variable length by nature it only */
230 }; /* points to an approximate location */
231
232 #define TE_IPV4_HAS_SUBTLV (0x40)
233
234 struct idrp_info
235 {
236 u_char len;
237 u_char *value;
238 };
239
240 struct ipv6_reachability
241 {
242 u_int32_t metric;
243 u_char control_info;
244 u_char prefix_len;
245 u_char prefix[16];
246 };
247
248 /* bits in control_info */
249 #define CTRL_INFO_DIRECTION 0x80
250 #define DIRECTION_UP 0x00
251 #define DIRECTION_DOWN 0x80
252
253 #define CTRL_INFO_DISTRIBUTION 0x40
254 #define DISTRIBUTION_INTERNAL 0x00
255 #define DISTRIBUTION_EXTERNAL 0x40
256
257 #define CTRL_INFO_SUBTLVS 0x20
258
259 struct mt_router_info
260 {
261 ISIS_MT_INFO_FIELDS
262 bool overload;
263 };
264
265 /*
266 * Pointer to each tlv type, filled by parse_tlvs()
267 */
268 struct tlvs
269 {
270 struct checksum *checksum;
271 struct hostname *hostname;
272 struct nlpids *nlpids;
273 struct te_router_id *router_id;
274 struct list *area_addrs;
275 struct list *mt_router_info;
276 struct list *is_neighs;
277 struct list *te_is_neighs;
278 struct list *mt_is_neighs;
279 struct list *es_neighs;
280 struct list *lsp_entries;
281 struct list *prefix_neighs;
282 struct list *lan_neighs;
283 struct list *ipv4_addrs;
284 struct list *ipv4_int_reachs;
285 struct list *ipv4_ext_reachs;
286 struct list *te_ipv4_reachs;
287 struct list *mt_ipv4_reachs;
288 struct list *ipv6_addrs;
289 struct list *ipv6_reachs;
290 struct list *mt_ipv6_reachs;
291 struct isis_passwd auth_info;
292 };
293
294 /*
295 * Own definitions - used to bitmask found and expected
296 */
297
298 #define TLVFLAG_AREA_ADDRS (1<<0)
299 #define TLVFLAG_IS_NEIGHS (1<<1)
300 #define TLVFLAG_ES_NEIGHS (1<<2)
301 #define TLVFLAG_PARTITION_DESIG_LEVEL2_IS (1<<3)
302 #define TLVFLAG_PREFIX_NEIGHS (1<<4)
303 #define TLVFLAG_LAN_NEIGHS (1<<5)
304 #define TLVFLAG_LSP_ENTRIES (1<<6)
305 #define TLVFLAG_PADDING (1<<7)
306 #define TLVFLAG_AUTH_INFO (1<<8)
307 #define TLVFLAG_IPV4_INT_REACHABILITY (1<<9)
308 #define TLVFLAG_NLPID (1<<10)
309 #define TLVFLAG_IPV4_EXT_REACHABILITY (1<<11)
310 #define TLVFLAG_IPV4_ADDR (1<<12)
311 #define TLVFLAG_DYN_HOSTNAME (1<<13)
312 #define TLVFLAG_IPV6_ADDR (1<<14)
313 #define TLVFLAG_IPV6_REACHABILITY (1<<15)
314 #define TLVFLAG_TE_IS_NEIGHS (1<<16)
315 #define TLVFLAG_TE_IPV4_REACHABILITY (1<<17)
316 #define TLVFLAG_3WAY_HELLO (1<<18)
317 #define TLVFLAG_TE_ROUTER_ID (1<<19)
318 #define TLVFLAG_CHECKSUM (1<<20)
319 #define TLVFLAG_GRACEFUL_RESTART (1<<21)
320 #define TLVFLAG_MT_ROUTER_INFORMATION (1<<22)
321
322 void init_tlvs (struct tlvs *tlvs, uint32_t expected);
323 void free_tlvs (struct tlvs *tlvs);
324 int parse_tlvs (char *areatag, u_char * stream, int size,
325 u_int32_t * expected, u_int32_t * found, struct tlvs *tlvs,
326 u_int32_t * auth_tlv_offset);
327 int add_tlv (u_char, u_char, u_char *, struct stream *);
328 void free_tlv (void *val);
329
330 int tlv_add_mt_router_info (struct list *mt_router_info, struct stream *stream);
331 int tlv_add_area_addrs (struct list *area_addrs, struct stream *stream);
332 int tlv_add_is_neighs (struct list *is_neighs, struct stream *stream);
333 unsigned int tlv_add_te_is_neighs (struct list *te_is_neighs, struct stream *stream, void *arg);
334 int tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream);
335 int tlv_add_nlpid (struct nlpids *nlpids, struct stream *stream);
336 int tlv_add_checksum (struct checksum *checksum, struct stream *stream);
337 int tlv_add_authinfo (u_char auth_type, u_char authlen, u_char *auth_value,
338 struct stream *stream);
339 int tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream);
340 int tlv_add_in_addr (struct in_addr *, struct stream *stream, u_char tag);
341 int tlv_add_dynamic_hostname (struct hostname *hostname,
342 struct stream *stream);
343 int tlv_add_lsp_entries (struct list *lsps, struct stream *stream);
344 int tlv_add_ipv4_int_reachs (struct list *ipv4_reachs, struct stream *stream);
345 int tlv_add_ipv4_ext_reachs (struct list *ipv4_reachs, struct stream *stream);
346 unsigned int tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream, void *arg);
347 int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream);
348 unsigned int tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream, void *arg);
349
350 int tlv_add_padding (struct stream *stream);
351
352 #endif /* _ZEBRA_ISIS_TLV_H */