]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_te.h
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / isisd / isis_te.h
1 /*
2 * IS-IS Rout(e)ing protocol - isis_te.c
3 *
4 * This is an implementation of RFC5305, RFC 5307 and RFC 7810
5 *
6 * Copyright (C) 2014 Orange Labs
7 * http://www.orange.com
8 *
9 * This file is part of GNU Zebra.
10 *
11 * GNU Zebra is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2, or (at your option) any
14 * later version.
15 *
16 * GNU Zebra is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; see the file COPYING; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #ifndef _ZEBRA_ISIS_MPLS_TE_H
27 #define _ZEBRA_ISIS_MPLS_TE_H
28
29 /*
30 * Traffic Engineering information are transport through LSP:
31 * - Extended IS Reachability TLV = 22
32 * - Traffic Engineering Router ID TLV = 134
33 * - Extended IP Reachability TLV = 135
34 * - Inter-AS Reachability Information TLV = 141
35 *
36 * and support following sub-TLV:
37 *
38 * Name Value Status
39 * _________________________________________________
40 * Administartive group (color) 3 RFC5305
41 * Link Local/Remote Identifiers 4 RFC5307
42 * IPv4 interface address 6 RFC5305
43 * IPv4 neighbor address 8 RFC5305
44 * Maximum link bandwidth 9 RFC5305
45 * Reservable link bandwidth 10 RFC5305
46 * Unreserved bandwidth 11 RFC5305
47 * TE Default metric 18 RFC5305
48 * Link Protection Type 20 RFC5307
49 * Interface Switching Capability 21 RFC5307
50 * Remote AS number 24 RFC5316
51 * IPv4 Remote ASBR identifier 25 RFC5316
52 *
53 */
54
55 /* NOTE: RFC5316 is not yet supported in this version */
56
57 /* Following define the type of TE link regarding the various RFC */
58 #define STD_TE 0x01
59 #define GMPLS 0x02
60 #define INTER_AS 0x04
61 #define FLOOD_L1 0x10
62 #define FLOOD_L2 0x20
63 #define FLOOD_AS 0x40
64 #define EMULATED 0x80
65
66 #define IS_STD_TE(x) (x & STD_TE)
67 #define IS_INTER_AS(x) (x & INTER_AS)
68 #define IS_EMULATED(x) (x & EMULATED)
69 #define IS_FLOOD_L1(x) (x & FLOOD_L1)
70 #define IS_FLOOD_L2(x) (x & FLOOD_L2)
71 #define IS_FLOOD_AS(x) (x & FLOOD_AS)
72 #define IS_INTER_AS_EMU(x) (x & INTER_AS & EMULATED)
73 #define IS_INTER_AS_AS(x) (x & INTER_AS & FLOOD_AS)
74
75 /*
76 * Following section defines subTLV (tag, length, value) structures,
77 * used for Traffic Engineering.
78 */
79 struct subtlv_header {
80 uint8_t type; /* sub_TLV_XXX type (see above) */
81 uint8_t length; /* Value portion only, in byte */
82 };
83
84 #define MAX_SUBTLV_SIZE 256
85
86 #define SUBTLV_HDR_SIZE 2 /* (sizeof (struct sub_tlv_header)) */
87
88 #define SUBTLV_SIZE(stlvh) (SUBTLV_HDR_SIZE + (stlvh)->length)
89
90 #define SUBTLV_HDR_TOP(lsph) (struct subtlv_header *)((char *)(lsph) + ISIS_LSP_HEADER_SIZE)
91
92 #define SUBTLV_HDR_NEXT(stlvh) (struct subtlv_header *)((char *)(stlvh) + SUBTLV_SIZE(stlvh))
93
94 #define SUBTLV_TYPE(stlvh) stlvh.header.type
95 #define SUBTLV_LEN(stlvh) stlvh.header.length
96 #define SUBTLV_VAL(stlvh) stlvh.value
97 #define SUBTLV_DATA(stlvh) stlvh + SUBTLV_HDR_SIZE
98
99 #define SUBTLV_DEF_SIZE 4
100
101 /* Link Sub-TLV: Resource Class/Color - RFC 5305 */
102 #define TE_SUBTLV_ADMIN_GRP 3
103 struct te_subtlv_admin_grp {
104 struct subtlv_header header; /* Value length is 4 octets. */
105 uint32_t value; /* Admin. group membership. */
106 } __attribute__((__packed__));
107
108 /* Link Local/Remote Identifiers - RFC 5307 */
109 #define TE_SUBTLV_LLRI 4
110 #define TE_SUBTLV_LLRI_SIZE 8
111 struct te_subtlv_llri {
112 struct subtlv_header header; /* Value length is 8 octets. */
113 uint32_t local; /* Link Local Identifier */
114 uint32_t remote; /* Link Remote Identifier */
115 } __attribute__((__packed__));
116
117 /* Link Sub-TLV: Local Interface IP Address - RFC 5305 */
118 #define TE_SUBTLV_LOCAL_IPADDR 6
119 struct te_subtlv_local_ipaddr {
120 struct subtlv_header header; /* Value length is 4 x N octets. */
121 struct in_addr value; /* Local IP address(es). */
122 } __attribute__((__packed__));
123
124 /* Link Sub-TLV: Neighbor Interface IP Address - RFC 5305 */
125 #define TE_SUBTLV_RMT_IPADDR 8
126 struct te_subtlv_rmt_ipaddr {
127 struct subtlv_header header; /* Value length is 4 x N octets. */
128 struct in_addr value; /* Neighbor's IP address(es). */
129 } __attribute__((__packed__));
130
131 /* Link Sub-TLV: Maximum Bandwidth - RFC 5305 */
132 #define TE_SUBTLV_MAX_BW 9
133 struct te_subtlv_max_bw {
134 struct subtlv_header header; /* Value length is 4 octets. */
135 float value; /* bytes/sec */
136 } __attribute__((__packed__));
137
138 /* Link Sub-TLV: Maximum Reservable Bandwidth - RFC 5305 */
139 #define TE_SUBTLV_MAX_RSV_BW 10
140 struct te_subtlv_max_rsv_bw {
141 struct subtlv_header header; /* Value length is 4 octets. */
142 float value; /* bytes/sec */
143 } __attribute__((__packed__));
144
145 /* Link Sub-TLV: Unreserved Bandwidth - RFC 5305 */
146 #define TE_SUBTLV_UNRSV_BW 11
147 #define TE_SUBTLV_UNRSV_SIZE 32
148 struct te_subtlv_unrsv_bw {
149 struct subtlv_header header; /* Value length is 32 octets. */
150 float value[8]; /* One for each priority level. */
151 } __attribute__((__packed__));
152
153 /* Link Sub-TLV: Traffic Engineering Metric - RFC 5305 */
154 #define TE_SUBTLV_TE_METRIC 18
155 #define TE_SUBTLV_TE_METRIC_SIZE 3
156 struct te_subtlv_te_metric {
157 struct subtlv_header header; /* Value length is 4 octets. */
158 uint8_t value[3]; /* Link metric for TE purpose. */
159 } __attribute__((__packed__));
160
161 /* Remote AS Number sub-TLV - RFC5316 */
162 #define TE_SUBTLV_RAS 24
163 struct te_subtlv_ras {
164 struct subtlv_header header; /* Value length is 4 octets. */
165 uint32_t value; /* Remote AS number */
166 } __attribute__((__packed__));
167
168 /* IPv4 Remote ASBR ID Sub-TLV - RFC5316 */
169 #define TE_SUBTLV_RIP 25
170 struct te_subtlv_rip {
171 struct subtlv_header header; /* Value length is 4 octets. */
172 struct in_addr value; /* Remote ASBR IP address */
173 } __attribute__((__packed__));
174
175
176 /* TE Metric Extensions - RFC 7810 */
177 /* Link Sub-TLV: Average Link Delay */
178 #define TE_SUBTLV_AV_DELAY 33
179 struct te_subtlv_av_delay {
180 struct subtlv_header header; /* Value length is 4 bytes. */
181 uint32_t value; /* Average delay in micro-seconds only 24 bits => 0 ...
182 16777215
183 with Anomalous Bit (A) as Upper most bit */
184 } __attribute__((__packed__));
185
186 /* Link Sub-TLV: Low/High Link Delay */
187 #define TE_SUBTLV_MM_DELAY 34
188 #define TE_SUBTLV_MM_DELAY_SIZE 8
189 struct te_subtlv_mm_delay {
190 struct subtlv_header header; /* Value length is 8 bytes. */
191 uint32_t low; /* low delay in micro-seconds only 24 bits => 0 ...
192 16777215
193 with Anomalous Bit (A) as Upper most bit */
194 uint32_t high; /* high delay in micro-seconds only 24 bits => 0 ...
195 16777215 */
196 } __attribute__((__packed__));
197
198 /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
199 #define TE_SUBTLV_DELAY_VAR 35
200 struct te_subtlv_delay_var {
201 struct subtlv_header header; /* Value length is 4 bytes. */
202 uint32_t value; /* interval in micro-seconds only 24 bits => 0 ...
203 16777215 */
204 } __attribute__((__packed__));
205
206 /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
207 #define TE_SUBTLV_PKT_LOSS 36
208 struct te_subtlv_pkt_loss {
209 struct subtlv_header header; /* Value length is 4 bytes. */
210 uint32_t
211 value; /* in percentage of total traffic only 24 bits (2^24 - 2)
212 with Anomalous Bit (A) as Upper most bit */
213 } __attribute__((__packed__));
214
215 /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
216 #define TE_SUBTLV_RES_BW 37
217 struct te_subtlv_res_bw {
218 struct subtlv_header header; /* Value length is 4 bytes. */
219 float value; /* bandwidth in IEEE floating point format with units in
220 bytes per second */
221 } __attribute__((__packed__));
222
223 /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
224 #define TE_SUBTLV_AVA_BW 38
225 struct te_subtlv_ava_bw {
226 struct subtlv_header header; /* Value length is 4 octets. */
227 float value; /* bandwidth in IEEE floating point format with units in
228 bytes per second */
229 } __attribute__((__packed__));
230
231 /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
232 #define TE_SUBTLV_USE_BW 39
233 struct te_subtlv_use_bw {
234 struct subtlv_header header; /* Value length is 4 octets. */
235 float value; /* bandwidth in IEEE floating point format with units in
236 bytes per second */
237 } __attribute__((__packed__));
238
239 #define TE_SUBTLV_MAX 40 /* Last SUBTLV + 1 */
240
241 /* Following declaration concerns the MPLS-TE and LINk-TE management */
242 typedef enum _status_t { disable, enable, learn } status_t;
243
244 /* Mode for Inter-AS LSP */ /* TODO: Check how if LSP is flooded in RFC5316 */
245 typedef enum _interas_mode_t { off, region, as, emulate } interas_mode_t;
246
247 #define IS_MPLS_TE(m) (m.status == enable)
248 #define IS_CIRCUIT_TE(c) (c->status == enable)
249
250 /* Following structure are internal use only. */
251 struct isis_mpls_te {
252 /* Status of MPLS-TE: enable or disable */
253 status_t status;
254
255 /* L1, L1-L2, L2-Only */
256 uint8_t level;
257
258 /* RFC5316 */
259 interas_mode_t inter_as;
260 struct in_addr interas_areaid;
261
262 /* Circuit list on which TE are enable */
263 struct list *cir_list;
264
265 /* MPLS_TE router ID */
266 struct in_addr router_id;
267 };
268
269 extern struct isis_mpls_te isisMplsTE;
270
271 struct mpls_te_circuit {
272
273 /* Status of MPLS-TE on this interface */
274 status_t status;
275
276 /* Type of MPLS-TE circuit: STD_TE(RFC5305), INTER_AS(RFC5316),
277 * INTER_AS_EMU(RFC5316 emulated) */
278 uint8_t type;
279
280 /* Total size of sub_tlvs */
281 uint8_t length;
282
283 /* Store subTLV in network byte order. */
284 /* RFC5305 */
285 struct te_subtlv_admin_grp admin_grp;
286 /* RFC5307 */
287 struct te_subtlv_llri llri;
288 /* RFC5305 */
289 struct te_subtlv_local_ipaddr local_ipaddr;
290 struct te_subtlv_rmt_ipaddr rmt_ipaddr;
291 struct te_subtlv_max_bw max_bw;
292 struct te_subtlv_max_rsv_bw max_rsv_bw;
293 struct te_subtlv_unrsv_bw unrsv_bw;
294 struct te_subtlv_te_metric te_metric;
295 /* RFC5316 */
296 struct te_subtlv_ras ras;
297 struct te_subtlv_rip rip;
298 /* RFC7810 */
299 struct te_subtlv_av_delay av_delay;
300 struct te_subtlv_mm_delay mm_delay;
301 struct te_subtlv_delay_var delay_var;
302 struct te_subtlv_pkt_loss pkt_loss;
303 struct te_subtlv_res_bw res_bw;
304 struct te_subtlv_ava_bw ava_bw;
305 struct te_subtlv_use_bw use_bw;
306 };
307
308 /* Prototypes. */
309 void isis_mpls_te_init(void);
310 struct mpls_te_circuit *mpls_te_circuit_new(void);
311 struct sbuf;
312 void mpls_te_print_detail(struct sbuf *buf, int indent, uint8_t *subtlvs,
313 uint8_t subtlv_len);
314 void set_circuitparams_local_ipaddr(struct mpls_te_circuit *, struct in_addr);
315 void set_circuitparams_rmt_ipaddr(struct mpls_te_circuit *, struct in_addr);
316 uint8_t subtlvs_len(struct mpls_te_circuit *);
317 uint8_t add_te_subtlvs(uint8_t *, struct mpls_te_circuit *);
318 uint8_t build_te_subtlvs(uint8_t *, struct isis_circuit *);
319 void isis_link_params_update(struct isis_circuit *, struct interface *);
320 void isis_mpls_te_update(struct interface *);
321 void isis_mpls_te_config_write_router(struct vty *);
322
323 #endif /* _ZEBRA_ISIS_MPLS_TE_H */