]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_te.h
*: reindent
[mirror_frr.git] / ospfd / ospf_te.h
1 /*
2 * This is an implementation of RFC3630, RFC5392 & RFC6827
3 * Copyright (C) 2001 KDD R&D Laboratories, Inc.
4 * http://www.kddlabs.co.jp/
5 *
6 * Copyright (C) 2012 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 /* Add support of RFC7471 */
27 /* Add support of RFC5392 */
28 /* Add support of RFC6827 (partial) */
29
30 #ifndef _ZEBRA_OSPF_MPLS_TE_H
31 #define _ZEBRA_OSPF_MPLS_TE_H
32
33 /*
34 * Opaque LSA's link state ID for Traffic Engineering is
35 * structured as follows.
36 *
37 * 24 16 8 0
38 * +--------+--------+--------+--------+
39 * | 1 | MBZ |........|........|
40 * +--------+--------+--------+--------+
41 * |<-Type->|<Resv'd>|<-- Instance --->|
42 *
43 *
44 * Type: IANA has assigned '1' for Traffic Engineering.
45 * MBZ: Reserved, must be set to zero.
46 * Instance: User may select an arbitrary 16-bit value.
47 *
48 */
49
50 #define MAX_LEGAL_TE_INSTANCE_NUM (0xffff)
51 #define LEGAL_TE_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
52
53 /*
54 * 24 16 8 0
55 * +--------+--------+--------+--------+ ---
56 * | LS age |Options | 10 | A
57 * +--------+--------+--------+--------+ |
58 * | 1 | 0 | Instance | |
59 * +--------+--------+--------+--------+ |
60 * | Advertising router | | Standard (Opaque) LSA header;
61 * +--------+--------+--------+--------+ | Only type-10 is used.
62 * | LS sequence number | |
63 * +--------+--------+--------+--------+ |
64 * | LS checksum | Length | V
65 * +--------+--------+--------+--------+ ---
66 * | Type | Length | A
67 * +--------+--------+--------+--------+ | TLV part for TE; Values might be
68 * | Values ... | V structured as a set of sub-TLVs.
69 * +--------+--------+--------+--------+ ---
70 */
71
72 /* Following define the type of TE link regarding the various RFC */
73 #define STD_TE 0x01
74 #define GMPLS 0x02
75 #define INTER_AS 0x04
76 #define PSEUDO_TE 0x08
77 #define FLOOD_AREA 0x10
78 #define FLOOD_AS 0x20
79 #define EMULATED 0x80
80
81 #define IS_STD_TE(x) (x & STD_TE)
82 #define IS_PSEUDO_TE(x) (x & PSEUDO_TE)
83 #define IS_INTER_AS(x) (x & INTER_AS)
84 #define IS_EMULATED(x) (x & EMULATED)
85 #define IS_FLOOD_AREA(x) (x & FLOOD_AREA)
86 #define IS_FLOOD_AS(x) (x & FLOOD_AS)
87 #define IS_INTER_AS_EMU(x) (x & INTER_AS & EMULATED)
88 #define IS_INTER_AS_AS(x) (x & INTER_AS & FLOOD_AS)
89
90 /* Flags to manage TE Link LSA */
91 #define LPFLG_LSA_INACTIVE 0x0
92 #define LPFLG_LSA_ACTIVE 0x1
93 #define LPFLG_LSA_ENGAGED 0x2
94 #define LPFLG_LOOKUP_DONE 0x4
95 #define LPFLG_LSA_FORCED_REFRESH 0x8
96
97 /*
98 * Following section defines TLV (tag, length, value) structures,
99 * used for Traffic Engineering.
100 */
101 struct te_tlv_header {
102 u_int16_t type; /* TE_TLV_XXX (see below) */
103 u_int16_t length; /* Value portion only, in octets */
104 };
105
106 #define TLV_HDR_SIZE (sizeof(struct te_tlv_header))
107
108 #define TLV_BODY_SIZE(tlvh) (ROUNDUP(ntohs((tlvh)->length), sizeof(u_int32_t)))
109
110 #define TLV_SIZE(tlvh) (TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh))
111
112 #define TLV_HDR_TOP(lsah) \
113 (struct te_tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE)
114
115 #define TLV_HDR_NEXT(tlvh) \
116 (struct te_tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh))
117
118 #define TLV_HDR_SUBTLV(tlvh) \
119 (struct te_tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE)
120
121 #define TLV_TYPE(tlvh) tlvh.header.type
122 #define TLV_LEN(tlvh) tlvh.header.length
123 #define TLV_HDR(tlvh) tlvh.header
124
125 /*
126 * Following section defines TLV body parts.
127 */
128 /* Router Address TLV */ /* Mandatory */
129 #define TE_TLV_ROUTER_ADDR 1
130 struct te_tlv_router_addr {
131 struct te_tlv_header header; /* Value length is 4 octets. */
132 struct in_addr value;
133 };
134
135 /* Link TLV */
136 #define TE_TLV_LINK 2
137 struct te_tlv_link {
138 struct te_tlv_header header;
139 /* A set of link-sub-TLVs will follow. */
140 };
141
142 #define TE_LINK_SUBTLV_DEF_SIZE 4
143
144 /* Link Type Sub-TLV */ /* Mandatory */
145 #define TE_LINK_SUBTLV_LINK_TYPE 1
146 #define TE_LINK_SUBTLV_TYPE_SIZE 1
147 struct te_link_subtlv_link_type {
148 struct te_tlv_header header; /* Value length is 1 octet. */
149 struct {
150 #define LINK_TYPE_SUBTLV_VALUE_PTP 1
151 #define LINK_TYPE_SUBTLV_VALUE_MA 2
152 u_char value;
153 u_char padding[3];
154 } link_type;
155 };
156
157 /* Link Sub-TLV: Link ID */ /* Mandatory */
158 #define TE_LINK_SUBTLV_LINK_ID 2
159 struct te_link_subtlv_link_id {
160 struct te_tlv_header header; /* Value length is 4 octets. */
161 struct in_addr value; /* Same as router-lsa's link-id. */
162 };
163
164 /* Link Sub-TLV: Local Interface IP Address */ /* Optional */
165 #define TE_LINK_SUBTLV_LCLIF_IPADDR 3
166 struct te_link_subtlv_lclif_ipaddr {
167 struct te_tlv_header header; /* Value length is 4 x N octets. */
168 struct in_addr value[1]; /* Local IP address(es). */
169 };
170
171 /* Link Sub-TLV: Remote Interface IP Address */ /* Optional */
172 #define TE_LINK_SUBTLV_RMTIF_IPADDR 4
173 struct te_link_subtlv_rmtif_ipaddr {
174 struct te_tlv_header header; /* Value length is 4 x N octets. */
175 struct in_addr value[1]; /* Neighbor's IP address(es). */
176 };
177
178 /* Link Sub-TLV: Traffic Engineering Metric */ /* Optional */
179 #define TE_LINK_SUBTLV_TE_METRIC 5
180 struct te_link_subtlv_te_metric {
181 struct te_tlv_header header; /* Value length is 4 octets. */
182 u_int32_t value; /* Link metric for TE purpose. */
183 };
184
185 /* Link Sub-TLV: Maximum Bandwidth */ /* Optional */
186 #define TE_LINK_SUBTLV_MAX_BW 6
187 struct te_link_subtlv_max_bw {
188 struct te_tlv_header header; /* Value length is 4 octets. */
189 float value; /* bytes/sec */
190 };
191
192 /* Link Sub-TLV: Maximum Reservable Bandwidth */ /* Optional */
193 #define TE_LINK_SUBTLV_MAX_RSV_BW 7
194 struct te_link_subtlv_max_rsv_bw {
195 struct te_tlv_header header; /* Value length is 4 octets. */
196 float value; /* bytes/sec */
197 };
198
199 /* Link Sub-TLV: Unreserved Bandwidth */ /* Optional */
200 #define TE_LINK_SUBTLV_UNRSV_BW 8
201 #define TE_LINK_SUBTLV_UNRSV_SIZE 32
202 struct te_link_subtlv_unrsv_bw {
203 struct te_tlv_header header; /* Value length is 32 octets. */
204 float value[MAX_CLASS_TYPE]; /* One for each priority level. */
205 };
206
207 /* Link Sub-TLV: Resource Class/Color */ /* Optional */
208 #define TE_LINK_SUBTLV_RSC_CLSCLR 9
209 struct te_link_subtlv_rsc_clsclr {
210 struct te_tlv_header header; /* Value length is 4 octets. */
211 u_int32_t value; /* Admin. group membership. */
212 };
213
214 /* For RFC6827 */
215 /* Local and Remote TE Router ID */
216 #define TE_LINK_SUBTLV_LRRID 10
217 #define TE_LINK_SUBTLV_LRRID_SIZE 8
218 struct te_link_subtlv_lrrid {
219 struct te_tlv_header header; /* Value length is 8 octets. */
220 struct in_addr local; /* Local TE Router Identifier */
221 struct in_addr remote; /* Remote TE Router Identifier */
222 };
223
224 /* RFC4203: Link Local/Remote Identifiers */
225 #define TE_LINK_SUBTLV_LLRI 11
226 #define TE_LINK_SUBTLV_LLRI_SIZE 8
227 struct te_link_subtlv_llri {
228 struct te_tlv_header header; /* Value length is 8 octets. */
229 u_int32_t local; /* Link Local Identifier */
230 u_int32_t remote; /* Link Remote Identifier */
231 };
232
233 /* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13)
234 * (RFC6827bis) are not yet supported */
235 /* SUBTLV 14-16 (RFC4203) are not yet supported */
236 /* Bandwidth Constraints sub-TLV (17) (RFC4124) is not yet supported */
237 /* SUBLV 18-20 are for OSPFv3 TE (RFC5329). see ospf6d */
238
239 /* For RFC 5392 */
240 /* Remote AS Number sub-TLV */
241 #define TE_LINK_SUBTLV_RAS 21
242 struct te_link_subtlv_ras {
243 struct te_tlv_header header; /* Value length is 4 octets. */
244 u_int32_t value; /* Remote AS number */
245 };
246
247 /* IPv4 Remote ASBR ID Sub-TLV */
248 #define TE_LINK_SUBTLV_RIP 22
249 struct te_link_subtlv_rip {
250 struct te_tlv_header header; /* Value length is 4 octets. */
251 struct in_addr value; /* Remote ASBR IP address */
252 };
253
254 /* SUBTLV 24 is IPv6 Remote ASBR ID (RFC5392). see ospf6d */
255
256 /* SUBTLV 23 (RFC5330) and 25 (RFC6001) are not yet supported */
257
258 /* SUBTLV 26 (RFC7308) is not yet supported */
259
260 /* RFC7471 */
261 /* Link Sub-TLV: Average Link Delay */ /* Optional */
262 #define TE_LINK_SUBTLV_AV_DELAY 27
263 struct te_link_subtlv_av_delay {
264 struct te_tlv_header header; /* Value length is 4 bytes. */
265 u_int32_t
266 value; /* delay in micro-seconds only 24 bits => 0 ... 16777215
267 with Anomalous Bit as Upper most bit */
268 };
269
270 /* Link Sub-TLV: Low/High Link Delay */
271 #define TE_LINK_SUBTLV_MM_DELAY 28
272 #define TE_LINK_SUBTLV_MM_DELAY_SIZE 8
273 struct te_link_subtlv_mm_delay {
274 struct te_tlv_header header; /* Value length is 8 bytes. */
275 u_int32_t low; /* low delay in micro-seconds only 24 bits => 0 ...
276 16777215
277 with Anomalous Bit (A) as Upper most bit */
278 u_int32_t high; /* high delay in micro-seconds only 24 bits => 0 ...
279 16777215 */
280 };
281
282 /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
283 #define TE_LINK_SUBTLV_DELAY_VAR 29
284 struct te_link_subtlv_delay_var {
285 struct te_tlv_header header; /* Value length is 4 bytes. */
286 u_int32_t value; /* interval in micro-seconds only 24 bits => 0 ...
287 16777215 */
288 };
289
290 /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
291 #define TE_LINK_SUBTLV_PKT_LOSS 30
292 struct te_link_subtlv_pkt_loss {
293 struct te_tlv_header header; /* Value length is 4 bytes. */
294 u_int32_t
295 value; /* in percentage of total traffic only 24 bits (2^24 - 2)
296 with Anomalous Bit as Upper most bit */
297 };
298
299 /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
300 #define TE_LINK_SUBTLV_RES_BW 31
301 struct te_link_subtlv_res_bw {
302 struct te_tlv_header header; /* Value length is 4 bytes. */
303 float value; /* bandwidth in IEEE floating point format with units in
304 bytes per second */
305 };
306
307 /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
308 #define TE_LINK_SUBTLV_AVA_BW 32
309 struct te_link_subtlv_ava_bw {
310 struct te_tlv_header header; /* Value length is 4 octets. */
311 float value; /* bandwidth in IEEE floating point format with units in
312 bytes per second */
313 };
314
315 /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
316 #define TE_LINK_SUBTLV_USE_BW 33
317 struct te_link_subtlv_use_bw {
318 struct te_tlv_header header; /* Value length is 4 octets. */
319 float value; /* bandwidth in IEEE floating point format with units in
320 bytes per second */
321 };
322
323 #define TE_LINK_SUBTLV_MAX 34 /* Last SUBTLV + 1 */
324
325 /* Here are "non-official" architectural constants. */
326 #define MPLS_TE_MINIMUM_BANDWIDTH 1.0 /* Reasonable? *//* XXX */
327
328 /* Following declaration concerns the MPLS-TE and LINk-TE management */
329 typedef enum _opcode_t {
330 REORIGINATE_THIS_LSA,
331 REFRESH_THIS_LSA,
332 FLUSH_THIS_LSA
333 } opcode_t;
334
335 typedef enum _status_t { disabled, enabled } status_t;
336
337 /* Mode for Inter-AS Opaque-LSA */
338 enum inter_as_mode { Disable, AS, Area };
339
340 struct te_link_subtlv {
341 struct te_tlv_header header;
342 union {
343 u_int32_t link_type;
344 struct in_addr link_id;
345 struct in_addr lclif;
346 struct in_addr rmtif;
347 u_int32_t te_metric;
348 float max_bw;
349 float max_rsv_bw;
350 float unrsv[8];
351 u_int32_t rsc_clsclr;
352 u_int32_t llri[2];
353 u_int32_t ras;
354 struct in_addr rip;
355 struct in_addr lrrid[2];
356 u_int32_t av_delay;
357 u_int32_t mm_delay;
358 u_int32_t delay_var;
359 u_int32_t pkt_loss;
360 float res_bw;
361 float ava_bw;
362 float use_bw;
363 } value;
364 };
365
366 /* Following structure are internal use only. */
367 struct ospf_mpls_te {
368 /* Status of MPLS-TE: enable or disbale */
369 status_t status;
370
371 /* RFC5392 */
372 enum inter_as_mode inter_as;
373 struct in_addr interas_areaid;
374
375 /* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi).
376 */
377 struct list *iflist;
378
379 /* Store Router-TLV in network byte order. */
380 struct te_tlv_router_addr router_addr;
381 };
382
383 struct mpls_te_link {
384 /*
385 * According to MPLS-TE (draft) specification, 24-bit Opaque-ID field
386 * is subdivided into 8-bit "unused" field and 16-bit "instance" field.
387 * In this implementation, each Link-TLV has its own instance.
388 */
389 u_int32_t instance;
390
391 /* Reference pointer to a Zebra-interface. */
392 struct interface *ifp;
393
394 /* Area info in which this MPLS-TE link belongs to. */
395 struct ospf_area *area;
396
397 /* Flags to manage this link parameters. */
398 u_int32_t flags;
399
400 /* Type of MPLS-TE link: RFC3630, RFC5392, RFC5392 emulated, RFC6827 */
401 u_int8_t type;
402
403 /* Store Link-TLV in network byte order. */
404 /* RFC3630 & RFC6827 / RFC 6827 */
405 struct te_tlv_link link_header;
406 struct te_link_subtlv_link_type link_type;
407 struct te_link_subtlv_link_id link_id;
408 struct te_link_subtlv_lclif_ipaddr lclif_ipaddr;
409 struct te_link_subtlv_rmtif_ipaddr rmtif_ipaddr;
410 struct te_link_subtlv_te_metric te_metric;
411 struct te_link_subtlv_max_bw max_bw;
412 struct te_link_subtlv_max_rsv_bw max_rsv_bw;
413 struct te_link_subtlv_unrsv_bw unrsv_bw;
414 struct te_link_subtlv_rsc_clsclr rsc_clsclr;
415 /* RFC4203 */
416 struct te_link_subtlv_llri llri;
417 /* RFC5392 */
418 struct te_link_subtlv_ras ras;
419 struct te_link_subtlv_rip rip;
420 /* RFC6827 */
421 struct te_link_subtlv_lrrid lrrid;
422 /* RFC7471 */
423 struct te_link_subtlv_av_delay av_delay;
424 struct te_link_subtlv_mm_delay mm_delay;
425 struct te_link_subtlv_delay_var delay_var;
426 struct te_link_subtlv_pkt_loss pkt_loss;
427 struct te_link_subtlv_res_bw res_bw;
428 struct te_link_subtlv_ava_bw ava_bw;
429 struct te_link_subtlv_use_bw use_bw;
430
431 struct in_addr adv_router;
432 struct in_addr id;
433 };
434
435 /* Prototypes. */
436 extern int ospf_mpls_te_init(void);
437 extern void ospf_mpls_te_term(void);
438 extern struct ospf_mpls_te *get_ospf_mpls_te(void);
439 extern void ospf_mpls_te_update_if(struct interface *);
440 extern void ospf_mpls_te_lsa_schedule(struct mpls_te_link *, opcode_t);
441 extern u_int32_t get_mpls_te_instance_value(void);
442 extern void set_linkparams_llri(struct mpls_te_link *, u_int32_t, u_int32_t);
443 extern void set_linkparams_lrrid(struct mpls_te_link *, struct in_addr,
444 struct in_addr);
445
446 #endif /* _ZEBRA_OSPF_MPLS_TE_H */