blob: 619003a0e3603e5d57d2fae8a79266e7c9a62ead [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
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; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24#ifndef _ZEBRA_ISIS_TLV_H
25#define _ZEBRA_ISIS_TLV_H
26
27/*
hasso72b9c952005-09-19 06:02:34 +000028 * The list of TLVs we (should) support.
29 * ____________________________________________________________________________
30 * Name Value IIH LSP SNP Status
31 * LAN
32 * ____________________________________________________________________________
Josh Bailey3f045a02012-03-24 08:35:20 -070033 *
hasso72b9c952005-09-19 06:02:34 +000034 * Area Addresses 1 y y n ISO10589
35 * IIS Neighbors 2 n y n ISO10589
36 * ES Neighbors 3 n y n ISO10589
37 * IIS Neighbors 6 y n n ISO10589
38 * Padding 8 y n n ISO10589
39 * LSP Entries 9 n n y ISO10589
40 * Authentication 10 y y y ISO10589, RFC3567
41 * Checksum 12 y n y RFC3358
Josh Bailey3f045a02012-03-24 08:35:20 -070042 * TE IS Reachability 22 n y n RFC5305
hasso72b9c952005-09-19 06:02:34 +000043 * IS Alias 24 n y n RFC3786
44 * IP Int. Reachability 128 n y n RFC1195
45 * Protocols Supported 129 y y n RFC1195
46 * IP Ext. Reachability 130 n y n RFC1195
47 * IDRPI 131 n y y RFC1195
48 * IP Interface Address 132 y y n RFC1195
Josh Bailey3f045a02012-03-24 08:35:20 -070049 * TE Router ID 134 n y n RFC5305
50 * Extended IP Reachability 135 n y n RFC5305
hasso72b9c952005-09-19 06:02:34 +000051 * Dynamic Hostname 137 n y n RFC2763
Josh Bailey3f045a02012-03-24 08:35:20 -070052 * Shared Risk Link Group 138 n y y RFC5307
hasso72b9c952005-09-19 06:02:34 +000053 * Restart TLV 211 y n n RFC3847
Josh Bailey3f045a02012-03-24 08:35:20 -070054 * MT IS Reachability 222 n y n RFC5120
55 * MT Supported 229 y y n RFC5120
56 * IPv6 Interface Address 232 y y n RFC5308
57 * MT IP Reachability 235 n y n RFC5120
58 * IPv6 IP Reachability 236 n y n RFC5308
59 * MT IPv6 IP Reachability 237 n y n RFC5120
hasso72b9c952005-09-19 06:02:34 +000060 * P2P Adjacency State 240 y n n RFC3373
61 * IIH Sequence Number 241 y n n draft-shen-isis-iih-sequence
62 * Router Capability 242 - - - draft-ietf-isis-caps
63 *
Josh Bailey3f045a02012-03-24 08:35:20 -070064 *
hasso72b9c952005-09-19 06:02:34 +000065 * IS Reachability sub-TLVs we (should) support.
66 * ____________________________________________________________________________
67 * Name Value Status
68 * ____________________________________________________________________________
Josh Bailey3f045a02012-03-24 08:35:20 -070069 * Administartive group (color) 3 RFC5305
70 * Link Local/Remote Identifiers 4 RFC5307
71 * IPv4 interface address 6 RFC5305
72 * IPv4 neighbor address 8 RFC5305
73 * Maximum link bandwidth 9 RFC5305
74 * Reservable link bandwidth 10 RFC5305
75 * Unreserved bandwidth 11 RFC5305
76 * TE Default metric 18 RFC5305
77 * Link Protection Type 20 RFC5307
78 * Interface Switching Capability 21 RFC5307
hasso72b9c952005-09-19 06:02:34 +000079 *
Josh Bailey3f045a02012-03-24 08:35:20 -070080 *
hasso72b9c952005-09-19 06:02:34 +000081 * IP Reachability sub-TLVs we (should) support.
82 * ____________________________________________________________________________
83 * Name Value Status
84 * ____________________________________________________________________________
Josh Bailey3f045a02012-03-24 08:35:20 -070085 * 32bit administrative tag 1 RFC5130
86 * 64bit administrative tag 2 RFC5130
87 * Management prefix color 117 RFC5120
jardineb5d44e2003-12-23 08:09:43 +000088 */
89
90#define AREA_ADDRESSES 1
91#define IS_NEIGHBOURS 2
92#define ES_NEIGHBOURS 3
jardineb5d44e2003-12-23 08:09:43 +000093#define LAN_NEIGHBOURS 6
94#define PADDING 8
95#define LSP_ENTRIES 9
96#define AUTH_INFO 10
97#define CHECKSUM 12
98#define TE_IS_NEIGHBOURS 22
hasso72b9c952005-09-19 06:02:34 +000099#define IS_ALIAS 24
jardineb5d44e2003-12-23 08:09:43 +0000100#define IPV4_INT_REACHABILITY 128
jardineb5d44e2003-12-23 08:09:43 +0000101#define PROTOCOLS_SUPPORTED 129
hasso72b9c952005-09-19 06:02:34 +0000102#define IPV4_EXT_REACHABILITY 130
jardineb5d44e2003-12-23 08:09:43 +0000103#define IDRP_INFO 131
104#define IPV4_ADDR 132
105#define TE_ROUTER_ID 134
106#define TE_IPV4_REACHABILITY 135
107#define DYNAMIC_HOSTNAME 137
hasso00995cf2004-05-19 13:43:50 +0000108#define GRACEFUL_RESTART 211
jardineb5d44e2003-12-23 08:09:43 +0000109#define IPV6_ADDR 232
hasso72b9c952005-09-19 06:02:34 +0000110#define IPV6_REACHABILITY 236
jardineb5d44e2003-12-23 08:09:43 +0000111#define WAY3_HELLO 240
112
Josh Bailey3f045a02012-03-24 08:35:20 -0700113#define AUTH_INFO_HDRLEN 3
114
Christian Frankef35169e2015-11-12 14:09:08 +0100115#define MAX_TLV_LEN 255
116
jardineb5d44e2003-12-23 08:09:43 +0000117#define IS_NEIGHBOURS_LEN (ISIS_SYS_ID_LEN + 5)
118#define LAN_NEIGHBOURS_LEN 6
hassof390d2c2004-09-10 20:48:21 +0000119#define LSP_ENTRIES_LEN (10 + ISIS_SYS_ID_LEN) /* FIXME: should be entry */
jardineb5d44e2003-12-23 08:09:43 +0000120#define IPV4_REACH_LEN 12
121#define IPV6_REACH_LEN 22
Josh Bailey3f045a02012-03-24 08:35:20 -0700122#define TE_IPV4_REACH_LEN 9
jardineb5d44e2003-12-23 08:09:43 +0000123
124/* struct for neighbor */
hassof390d2c2004-09-10 20:48:21 +0000125struct is_neigh
126{
127 struct metric metrics;
128 u_char neigh_id[ISIS_SYS_ID_LEN + 1];
jardineb5d44e2003-12-23 08:09:43 +0000129};
130
131/* struct for te is neighbor */
hassof390d2c2004-09-10 20:48:21 +0000132struct te_is_neigh
133{
134 u_char neigh_id[ISIS_SYS_ID_LEN + 1];
135 u_char te_metric[3];
136 u_char sub_tlvs_length;
jardineb5d44e2003-12-23 08:09:43 +0000137};
138
Josh Bailey3f045a02012-03-24 08:35:20 -0700139/* Decode and encode three-octet metric into host byte order integer */
140#define GET_TE_METRIC(t) \
141 (((unsigned)(t)->te_metric[0]<<16) | ((t)->te_metric[1]<<8) | \
142 (t)->te_metric[2])
143#define SET_TE_METRIC(t, m) \
144 (((t)->te_metric[0] = (m) >> 16), \
145 ((t)->te_metric[1] = (m) >> 8), \
146 ((t)->te_metric[2] = (m)))
147
jardineb5d44e2003-12-23 08:09:43 +0000148/* struct for es neighbors */
hassof390d2c2004-09-10 20:48:21 +0000149struct es_neigh
150{
151 struct metric metrics;
jardineb5d44e2003-12-23 08:09:43 +0000152 /* approximate position of first, we use the
153 * length ((uchar*)metric-1) to know all */
hassof390d2c2004-09-10 20:48:21 +0000154 u_char first_es_neigh[ISIS_SYS_ID_LEN];
155
jardineb5d44e2003-12-23 08:09:43 +0000156};
157
hassof390d2c2004-09-10 20:48:21 +0000158struct partition_desig_level2_is
159{
160 struct list *isis_system_ids;
jardineb5d44e2003-12-23 08:09:43 +0000161};
162
163/* struct for lan neighbors */
hassof390d2c2004-09-10 20:48:21 +0000164struct lan_neigh
165{
166 u_char LAN_addr[6];
jardineb5d44e2003-12-23 08:09:43 +0000167};
168
Paul Jakma238497f2007-08-07 18:49:18 +0000169#ifdef __SUNPRO_C
170#pragma pack(1)
171#endif
172
jardineb5d44e2003-12-23 08:09:43 +0000173/* struct for LSP entry */
hassof390d2c2004-09-10 20:48:21 +0000174struct lsp_entry
175{
176 u_int16_t rem_lifetime;
177 u_char lsp_id[ISIS_SYS_ID_LEN + 2];
178 u_int32_t seq_num;
179 u_int16_t checksum;
180} __attribute__ ((packed));
jardineb5d44e2003-12-23 08:09:43 +0000181
Paul Jakma238497f2007-08-07 18:49:18 +0000182#ifdef __SUNPRO_C
183#pragma pack()
184#endif
185
jardineb5d44e2003-12-23 08:09:43 +0000186/* struct for checksum */
hassof390d2c2004-09-10 20:48:21 +0000187struct checksum
188{
jardineb5d44e2003-12-23 08:09:43 +0000189 u_int16_t checksum;
190};
191
192/* ipv4 reachability */
hassof390d2c2004-09-10 20:48:21 +0000193struct ipv4_reachability
194{
jardineb5d44e2003-12-23 08:09:43 +0000195 struct metric metrics;
196 struct in_addr prefix;
hassof390d2c2004-09-10 20:48:21 +0000197 struct in_addr mask;
jardineb5d44e2003-12-23 08:09:43 +0000198};
199
200/* te router id */
hassof390d2c2004-09-10 20:48:21 +0000201struct te_router_id
202{
203 struct in_addr id;
jardineb5d44e2003-12-23 08:09:43 +0000204};
205
206/* te ipv4 reachability */
hassof390d2c2004-09-10 20:48:21 +0000207struct te_ipv4_reachability
208{
209 u_int32_t te_metric;
210 u_char control;
211 u_char prefix_start; /* since this is variable length by nature it only */
212}; /* points to an approximate location */
jardineb5d44e2003-12-23 08:09:43 +0000213
214
215
hassof390d2c2004-09-10 20:48:21 +0000216struct idrp_info
217{
jardineb5d44e2003-12-23 08:09:43 +0000218 u_char len;
219 u_char *value;
220};
221
222#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000223struct ipv6_reachability
224{
225 u_int32_t metric;
226 u_char control_info;
227 u_char prefix_len;
228 u_char prefix[16];
jardineb5d44e2003-12-23 08:09:43 +0000229};
jardineb5d44e2003-12-23 08:09:43 +0000230
231/* bits in control_info */
232#define CTRL_INFO_DIRECTION 0x80
Christian Frankeacf98652015-11-12 14:24:22 +0100233#define DIRECTION_UP 0x00
234#define DIRECTION_DOWN 0x80
235
jardineb5d44e2003-12-23 08:09:43 +0000236#define CTRL_INFO_DISTRIBUTION 0x40
Christian Frankeacf98652015-11-12 14:24:22 +0100237#define DISTRIBUTION_INTERNAL 0x00
238#define DISTRIBUTION_EXTERNAL 0x40
239
jardineb5d44e2003-12-23 08:09:43 +0000240#define CTRL_INFO_SUBTLVS 0x20
Josh Bailey3f045a02012-03-24 08:35:20 -0700241#endif /* HAVE_IPV6 */
jardineb5d44e2003-12-23 08:09:43 +0000242
243/*
244 * Pointer to each tlv type, filled by parse_tlvs()
245 */
hassof390d2c2004-09-10 20:48:21 +0000246struct tlvs
247{
Josh Bailey3f045a02012-03-24 08:35:20 -0700248 struct checksum *checksum;
249 struct hostname *hostname;
250 struct nlpids *nlpids;
251 struct te_router_id *router_id;
hassof390d2c2004-09-10 20:48:21 +0000252 struct list *area_addrs;
253 struct list *is_neighs;
254 struct list *te_is_neighs;
255 struct list *es_neighs;
256 struct list *lsp_entries;
257 struct list *prefix_neighs;
258 struct list *lan_neighs;
hassof390d2c2004-09-10 20:48:21 +0000259 struct list *ipv4_addrs;
260 struct list *ipv4_int_reachs;
261 struct list *ipv4_ext_reachs;
262 struct list *te_ipv4_reachs;
jardineb5d44e2003-12-23 08:09:43 +0000263#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000264 struct list *ipv6_addrs;
265 struct list *ipv6_reachs;
jardineb5d44e2003-12-23 08:09:43 +0000266#endif
hassof390d2c2004-09-10 20:48:21 +0000267 struct isis_passwd auth_info;
jardineb5d44e2003-12-23 08:09:43 +0000268};
269
270/*
271 * Own definitions - used to bitmask found and expected
272 */
273
274#define TLVFLAG_AREA_ADDRS (1<<0)
275#define TLVFLAG_IS_NEIGHS (1<<1)
276#define TLVFLAG_ES_NEIGHS (1<<2)
277#define TLVFLAG_PARTITION_DESIG_LEVEL2_IS (1<<3)
278#define TLVFLAG_PREFIX_NEIGHS (1<<4)
279#define TLVFLAG_LAN_NEIGHS (1<<5)
280#define TLVFLAG_LSP_ENTRIES (1<<6)
281#define TLVFLAG_PADDING (1<<7)
282#define TLVFLAG_AUTH_INFO (1<<8)
283#define TLVFLAG_IPV4_INT_REACHABILITY (1<<9)
284#define TLVFLAG_NLPID (1<<10)
285#define TLVFLAG_IPV4_EXT_REACHABILITY (1<<11)
286#define TLVFLAG_IPV4_ADDR (1<<12)
287#define TLVFLAG_DYN_HOSTNAME (1<<13)
288#define TLVFLAG_IPV6_ADDR (1<<14)
289#define TLVFLAG_IPV6_REACHABILITY (1<<15)
290#define TLVFLAG_TE_IS_NEIGHS (1<<16)
291#define TLVFLAG_TE_IPV4_REACHABILITY (1<<17)
292#define TLVFLAG_3WAY_HELLO (1<<18)
293#define TLVFLAG_TE_ROUTER_ID (1<<19)
294#define TLVFLAG_CHECKSUM (1<<20)
hasso00995cf2004-05-19 13:43:50 +0000295#define TLVFLAG_GRACEFUL_RESTART (1<<21)
jardineb5d44e2003-12-23 08:09:43 +0000296
hassof390d2c2004-09-10 20:48:21 +0000297void init_tlvs (struct tlvs *tlvs, uint32_t expected);
298void free_tlvs (struct tlvs *tlvs);
299int parse_tlvs (char *areatag, u_char * stream, int size,
Josh Bailey3f045a02012-03-24 08:35:20 -0700300 u_int32_t * expected, u_int32_t * found, struct tlvs *tlvs,
301 u_int32_t * auth_tlv_offset);
302int add_tlv (u_char, u_char, u_char *, struct stream *);
hassof390d2c2004-09-10 20:48:21 +0000303void free_tlv (void *val);
jardineb5d44e2003-12-23 08:09:43 +0000304
hassof390d2c2004-09-10 20:48:21 +0000305int tlv_add_area_addrs (struct list *area_addrs, struct stream *stream);
306int tlv_add_is_neighs (struct list *is_neighs, struct stream *stream);
hassoea3be4c2005-09-26 17:11:12 +0000307int tlv_add_te_is_neighs (struct list *te_is_neighs, struct stream *stream);
hassof390d2c2004-09-10 20:48:21 +0000308int tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream);
309int tlv_add_nlpid (struct nlpids *nlpids, struct stream *stream);
310int tlv_add_checksum (struct checksum *checksum, struct stream *stream);
Josh Bailey3f045a02012-03-24 08:35:20 -0700311int tlv_add_authinfo (u_char auth_type, u_char authlen, u_char *auth_value,
hassof390d2c2004-09-10 20:48:21 +0000312 struct stream *stream);
313int tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream);
hasso81ad8f62005-09-26 17:58:24 +0000314int tlv_add_in_addr (struct in_addr *, struct stream *stream, u_char tag);
hassof390d2c2004-09-10 20:48:21 +0000315int tlv_add_dynamic_hostname (struct hostname *hostname,
jardineb5d44e2003-12-23 08:09:43 +0000316 struct stream *stream);
hassof390d2c2004-09-10 20:48:21 +0000317int tlv_add_lsp_entries (struct list *lsps, struct stream *stream);
Christian Frankeacf98652015-11-12 14:24:22 +0100318int tlv_add_ipv4_int_reachs (struct list *ipv4_reachs, struct stream *stream);
319int tlv_add_ipv4_ext_reachs (struct list *ipv4_reachs, struct stream *stream);
hassoea3be4c2005-09-26 17:11:12 +0000320int tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream);
jardineb5d44e2003-12-23 08:09:43 +0000321#ifdef HAVE_IPV6
hassof390d2c2004-09-10 20:48:21 +0000322int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream);
323int tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream);
jardineb5d44e2003-12-23 08:09:43 +0000324#endif /* HAVE_IPV6 */
325
hassof390d2c2004-09-10 20:48:21 +0000326int tlv_add_padding (struct stream *stream);
jardineb5d44e2003-12-23 08:09:43 +0000327
328#endif /* _ZEBRA_ISIS_TLV_H */