]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_te.h
*: reindent
[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 u_char type; /* sub_TLV_XXX type (see above) */
81 u_char length; /* Value portion only, in byte */
82 };
83
84 #define SUBTLV_HDR_SIZE 2 /* (sizeof (struct sub_tlv_header)) */
85
86 #define SUBTLV_SIZE(stlvh) (SUBTLV_HDR_SIZE + (stlvh)->length)
87
88 #define SUBTLV_HDR_TOP(lsph) (struct subtlv_header *)((char *)(lsph) + ISIS_LSP_HEADER_SIZE)
89
90 #define SUBTLV_HDR_NEXT(stlvh) (struct subtlv_header *)((char *)(stlvh) + SUBTLV_SIZE(stlvh))
91
92 #define SUBTLV_TYPE(stlvh) stlvh.header.type
93 #define SUBTLV_LEN(stlvh) stlvh.header.length
94 #define SUBTLV_VAL(stlvh) stlvh.value
95 #define SUBTLV_DATA(stlvh) stlvh + SUBTLV_HDR_SIZE
96
97 #define SUBTLV_DEF_SIZE 4
98
99 /* Link Sub-TLV: Resource Class/Color - RFC 5305 */
100 #define TE_SUBTLV_ADMIN_GRP 3
101 struct te_subtlv_admin_grp {
102 struct subtlv_header header; /* Value length is 4 octets. */
103 u_int32_t value; /* Admin. group membership. */
104 } __attribute__((__packed__));
105
106 /* Link Local/Remote Identifiers - RFC 5307 */
107 #define TE_SUBTLV_LLRI 4
108 #define TE_SUBTLV_LLRI_SIZE 8
109 struct te_subtlv_llri {
110 struct subtlv_header header; /* Value length is 8 octets. */
111 u_int32_t local; /* Link Local Identifier */
112 u_int32_t remote; /* Link Remote Identifier */
113 } __attribute__((__packed__));
114
115 /* Link Sub-TLV: Local Interface IP Address - RFC 5305 */
116 #define TE_SUBTLV_LOCAL_IPADDR 6
117 struct te_subtlv_local_ipaddr {
118 struct subtlv_header header; /* Value length is 4 x N octets. */
119 struct in_addr value; /* Local IP address(es). */
120 } __attribute__((__packed__));
121
122 /* Link Sub-TLV: Neighbor Interface IP Address - RFC 5305 */
123 #define TE_SUBTLV_RMT_IPADDR 8
124 struct te_subtlv_rmt_ipaddr {
125 struct subtlv_header header; /* Value length is 4 x N octets. */
126 struct in_addr value; /* Neighbor's IP address(es). */
127 } __attribute__((__packed__));
128
129 /* Link Sub-TLV: Maximum Bandwidth - RFC 5305 */
130 #define TE_SUBTLV_MAX_BW 9
131 struct te_subtlv_max_bw {
132 struct subtlv_header header; /* Value length is 4 octets. */
133 float value; /* bytes/sec */
134 } __attribute__((__packed__));
135
136 /* Link Sub-TLV: Maximum Reservable Bandwidth - RFC 5305 */
137 #define TE_SUBTLV_MAX_RSV_BW 10
138 struct te_subtlv_max_rsv_bw {
139 struct subtlv_header header; /* Value length is 4 octets. */
140 float value; /* bytes/sec */
141 } __attribute__((__packed__));
142
143 /* Link Sub-TLV: Unreserved Bandwidth - RFC 5305 */
144 #define TE_SUBTLV_UNRSV_BW 11
145 #define TE_SUBTLV_UNRSV_SIZE 32
146 struct te_subtlv_unrsv_bw {
147 struct subtlv_header header; /* Value length is 32 octets. */
148 float value[8]; /* One for each priority level. */
149 } __attribute__((__packed__));
150
151 /* Link Sub-TLV: Traffic Engineering Metric - RFC 5305 */
152 #define TE_SUBTLV_TE_METRIC 18
153 #define TE_SUBTLV_TE_METRIC_SIZE 3
154 struct te_subtlv_te_metric {
155 struct subtlv_header header; /* Value length is 4 octets. */
156 u_char value[3]; /* Link metric for TE purpose. */
157 } __attribute__((__packed__));
158
159 /* Remote AS Number sub-TLV - RFC5316 */
160 #define TE_SUBTLV_RAS 24
161 struct te_subtlv_ras {
162 struct subtlv_header header; /* Value length is 4 octets. */
163 u_int32_t value; /* Remote AS number */
164 } __attribute__((__packed__));
165
166 /* IPv4 Remote ASBR ID Sub-TLV - RFC5316 */
167 #define TE_SUBTLV_RIP 25
168 struct te_subtlv_rip {
169 struct subtlv_header header; /* Value length is 4 octets. */
170 struct in_addr value; /* Remote ASBR IP address */
171 } __attribute__((__packed__));
172
173
174 /* TE Metric Extensions - RFC 7810 */
175 /* Link Sub-TLV: Average Link Delay */
176 #define TE_SUBTLV_AV_DELAY 33
177 struct te_subtlv_av_delay {
178 struct subtlv_header header; /* Value length is 4 bytes. */
179 u_int32_t value; /* Average delay in micro-seconds only 24 bits => 0 ...
180 16777215
181 with Anomalous Bit (A) as Upper most bit */
182 } __attribute__((__packed__));
183
184 /* Link Sub-TLV: Low/High Link Delay */
185 #define TE_SUBTLV_MM_DELAY 34
186 #define TE_SUBTLV_MM_DELAY_SIZE 8
187 struct te_subtlv_mm_delay {
188 struct subtlv_header header; /* Value length is 8 bytes. */
189 u_int32_t low; /* low delay in micro-seconds only 24 bits => 0 ...
190 16777215
191 with Anomalous Bit (A) as Upper most bit */
192 u_int32_t high; /* high delay in micro-seconds only 24 bits => 0 ...
193 16777215 */
194 } __attribute__((__packed__));
195
196 /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
197 #define TE_SUBTLV_DELAY_VAR 35
198 struct te_subtlv_delay_var {
199 struct subtlv_header header; /* Value length is 4 bytes. */
200 u_int32_t value; /* interval in micro-seconds only 24 bits => 0 ...
201 16777215 */
202 } __attribute__((__packed__));
203
204 /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
205 #define TE_SUBTLV_PKT_LOSS 36
206 struct te_subtlv_pkt_loss {
207 struct subtlv_header header; /* Value length is 4 bytes. */
208 u_int32_t
209 value; /* in percentage of total traffic only 24 bits (2^24 - 2)
210 with Anomalous Bit (A) as Upper most bit */
211 } __attribute__((__packed__));
212
213 /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
214 #define TE_SUBTLV_RES_BW 37
215 struct te_subtlv_res_bw {
216 struct subtlv_header header; /* Value length is 4 bytes. */
217 float value; /* bandwidth in IEEE floating point format with units in
218 bytes per second */
219 } __attribute__((__packed__));
220
221 /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
222 #define TE_SUBTLV_AVA_BW 38
223 struct te_subtlv_ava_bw {
224 struct subtlv_header header; /* Value length is 4 octets. */
225 float value; /* bandwidth in IEEE floating point format with units in
226 bytes per second */
227 } __attribute__((__packed__));
228
229 /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
230 #define TE_SUBTLV_USE_BW 39
231 struct te_subtlv_use_bw {
232 struct subtlv_header header; /* Value length is 4 octets. */
233 float value; /* bandwidth in IEEE floating point format with units in
234 bytes per second */
235 } __attribute__((__packed__));
236
237 #define TE_SUBTLV_MAX 40 /* Last SUBTLV + 1 */
238
239 /* Following declaration concerns the MPLS-TE and LINk-TE management */
240 typedef enum _status_t { disable, enable, learn } status_t;
241
242 /* Mode for Inter-AS LSP */ /* TODO: Check how if LSP is flooded in RFC5316 */
243 typedef enum _interas_mode_t { off, region, as, emulate } interas_mode_t;
244
245 #define IS_MPLS_TE(m) (m.status == enable)
246 #define IS_CIRCUIT_TE(c) (c->status == enable)
247
248 /* Following structure are internal use only. */
249 struct isis_mpls_te {
250 /* Status of MPLS-TE: enable or disable */
251 status_t status;
252
253 /* L1, L1-L2, L2-Only */
254 u_int8_t level;
255
256 /* RFC5316 */
257 interas_mode_t inter_as;
258 struct in_addr interas_areaid;
259
260 /* Circuit list on which TE are enable */
261 struct list *cir_list;
262
263 /* MPLS_TE router ID */
264 struct in_addr router_id;
265 };
266
267 extern struct isis_mpls_te isisMplsTE;
268
269 struct mpls_te_circuit {
270
271 /* Status of MPLS-TE on this interface */
272 status_t status;
273
274 /* Type of MPLS-TE circuit: STD_TE(RFC5305), INTER_AS(RFC5316),
275 * INTER_AS_EMU(RFC5316 emulated) */
276 u_int8_t type;
277
278 /* Total size of sub_tlvs */
279 u_char length;
280
281 /* Store subTLV in network byte order. */
282 /* RFC5305 */
283 struct te_subtlv_admin_grp admin_grp;
284 /* RFC5307 */
285 struct te_subtlv_llri llri;
286 /* RFC5305 */
287 struct te_subtlv_local_ipaddr local_ipaddr;
288 struct te_subtlv_rmt_ipaddr rmt_ipaddr;
289 struct te_subtlv_max_bw max_bw;
290 struct te_subtlv_max_rsv_bw max_rsv_bw;
291 struct te_subtlv_unrsv_bw unrsv_bw;
292 struct te_subtlv_te_metric te_metric;
293 /* RFC5316 */
294 struct te_subtlv_ras ras;
295 struct te_subtlv_rip rip;
296 /* RFC7810 */
297 struct te_subtlv_av_delay av_delay;
298 struct te_subtlv_mm_delay mm_delay;
299 struct te_subtlv_delay_var delay_var;
300 struct te_subtlv_pkt_loss pkt_loss;
301 struct te_subtlv_res_bw res_bw;
302 struct te_subtlv_ava_bw ava_bw;
303 struct te_subtlv_use_bw use_bw;
304 };
305
306 /* Prototypes. */
307 void isis_mpls_te_init(void);
308 struct mpls_te_circuit *mpls_te_circuit_new(void);
309 void mpls_te_print_detail(struct vty *, struct te_is_neigh *);
310 void set_circuitparams_local_ipaddr(struct mpls_te_circuit *, struct in_addr);
311 void set_circuitparams_rmt_ipaddr(struct mpls_te_circuit *, struct in_addr);
312 u_char subtlvs_len(struct mpls_te_circuit *);
313 u_char add_te_subtlvs(u_char *, struct mpls_te_circuit *);
314 u_char build_te_subtlvs(u_char *, struct isis_circuit *);
315 void isis_link_params_update(struct isis_circuit *, struct interface *);
316 void isis_mpls_te_update(struct interface *);
317 void isis_mpls_te_config_write_router(struct vty *);
318
319 #endif /* _ZEBRA_ISIS_MPLS_TE_H */