2 * This is an implementation of RFC3630, RFC5392 & RFC6827
3 * Copyright (C) 2001 KDD R&D Laboratories, Inc.
4 * http://www.kddlabs.co.jp/
6 * Copyright (C) 2012 Orange Labs
7 * http://www.orange.com
9 * This file is part of GNU Zebra.
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
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.
21 * You should have received a copy of the GNU General Public License
22 * along with GNU Zebra; see the file COPYING. If not, write to the Free
23 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 /* Add support of RFC7471 */
28 /* Add support of RFC5392 */
29 /* Add support of RFC6827 (partial) */
31 #ifndef _ZEBRA_OSPF_MPLS_TE_H
32 #define _ZEBRA_OSPF_MPLS_TE_H
35 * Opaque LSA's link state ID for Traffic Engineering is
36 * structured as follows.
39 * +--------+--------+--------+--------+
40 * | 1 | MBZ |........|........|
41 * +--------+--------+--------+--------+
42 * |<-Type->|<Resv'd>|<-- Instance --->|
45 * Type: IANA has assigned '1' for Traffic Engineering.
46 * MBZ: Reserved, must be set to zero.
47 * Instance: User may select an arbitrary 16-bit value.
51 #define MAX_LEGAL_TE_INSTANCE_NUM (0xffff)
52 #define LEGAL_TE_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
56 * +--------+--------+--------+--------+ ---
57 * | LS age |Options | 10 | A
58 * +--------+--------+--------+--------+ |
59 * | 1 | 0 | Instance | |
60 * +--------+--------+--------+--------+ |
61 * | Advertising router | | Standard (Opaque) LSA header;
62 * +--------+--------+--------+--------+ | Only type-10 is used.
63 * | LS sequence number | |
64 * +--------+--------+--------+--------+ |
65 * | LS checksum | Length | V
66 * +--------+--------+--------+--------+ ---
68 * +--------+--------+--------+--------+ | TLV part for TE; Values might be
69 * | Values ... | V structured as a set of sub-TLVs.
70 * +--------+--------+--------+--------+ ---
73 /* Following define the type of TE link regarding the various RFC */
77 #define PSEUDO_TE 0x08
78 #define FLOOD_AREA 0x10
82 #define IS_STD_TE(x) (x & STD_TE)
83 #define IS_PSEUDO_TE(x) (x & PSEUDO_TE)
84 #define IS_INTER_AS(x) (x & INTER_AS)
85 #define IS_EMULATED(x) (x & EMULATED)
86 #define IS_FLOOD_AREA(x) (x & FLOOD_AREA)
87 #define IS_FLOOD_AS(x) (x & FLOOD_AS)
88 #define IS_INTER_AS_EMU(x) (x & INTER_AS & EMULATED)
89 #define IS_INTER_AS_AS(x) (x & INTER_AS & FLOOD_AS)
91 /* Flags to manage TE Link LSA */
92 #define LPFLG_LSA_INACTIVE 0x0
93 #define LPFLG_LSA_ACTIVE 0x1
94 #define LPFLG_LSA_ENGAGED 0x2
95 #define LPFLG_LOOKUP_DONE 0x4
96 #define LPFLG_LSA_FORCED_REFRESH 0x8
99 * Following section defines TLV (tag, length, value) structures,
100 * used for Traffic Engineering.
104 u_int16_t type; /* TE_TLV_XXX (see below) */
105 u_int16_t length; /* Value portion only, in octets */
108 #define TLV_HDR_SIZE \
109 (sizeof (struct te_tlv_header))
111 #define TLV_BODY_SIZE(tlvh) \
112 (ROUNDUP (ntohs ((tlvh)->length), sizeof (u_int32_t)))
114 #define TLV_SIZE(tlvh) \
115 (TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh))
117 #define TLV_HDR_TOP(lsah) \
118 (struct te_tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE)
120 #define TLV_HDR_NEXT(tlvh) \
121 (struct te_tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh))
123 #define TLV_HDR_SUBTLV(tlvh) \
124 (struct te_tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE)
126 #define TLV_TYPE(tlvh) tlvh.header.type
127 #define TLV_LEN(tlvh) tlvh.header.length
128 #define TLV_HDR(tlvh) tlvh.header
132 * Following section defines TLV body parts.
134 /* Router Address TLV */ /* Mandatory */
135 #define TE_TLV_ROUTER_ADDR 1
136 struct te_tlv_router_addr
138 struct te_tlv_header header; /* Value length is 4 octets. */
139 struct in_addr value;
143 #define TE_TLV_LINK 2
146 struct te_tlv_header header;
147 /* A set of link-sub-TLVs will follow. */
150 #define TE_LINK_SUBTLV_DEF_SIZE 4
152 /* Link Type Sub-TLV */ /* Mandatory */
153 #define TE_LINK_SUBTLV_LINK_TYPE 1
154 #define TE_LINK_SUBTLV_TYPE_SIZE 1
155 struct te_link_subtlv_link_type
157 struct te_tlv_header header; /* Value length is 1 octet. */
160 #define LINK_TYPE_SUBTLV_VALUE_PTP 1
161 #define LINK_TYPE_SUBTLV_VALUE_MA 2
167 /* Link Sub-TLV: Link ID */ /* Mandatory */
168 #define TE_LINK_SUBTLV_LINK_ID 2
169 struct te_link_subtlv_link_id
171 struct te_tlv_header header; /* Value length is 4 octets. */
172 struct in_addr value; /* Same as router-lsa's link-id. */
175 /* Link Sub-TLV: Local Interface IP Address */ /* Optional */
176 #define TE_LINK_SUBTLV_LCLIF_IPADDR 3
177 struct te_link_subtlv_lclif_ipaddr
179 struct te_tlv_header header; /* Value length is 4 x N octets. */
180 struct in_addr value[1]; /* Local IP address(es). */
183 /* Link Sub-TLV: Remote Interface IP Address */ /* Optional */
184 #define TE_LINK_SUBTLV_RMTIF_IPADDR 4
185 struct te_link_subtlv_rmtif_ipaddr
187 struct te_tlv_header header; /* Value length is 4 x N octets. */
188 struct in_addr value[1]; /* Neighbor's IP address(es). */
191 /* Link Sub-TLV: Traffic Engineering Metric */ /* Optional */
192 #define TE_LINK_SUBTLV_TE_METRIC 5
193 struct te_link_subtlv_te_metric
195 struct te_tlv_header header; /* Value length is 4 octets. */
196 u_int32_t value; /* Link metric for TE purpose. */
199 /* Link Sub-TLV: Maximum Bandwidth */ /* Optional */
200 #define TE_LINK_SUBTLV_MAX_BW 6
201 struct te_link_subtlv_max_bw
203 struct te_tlv_header header; /* Value length is 4 octets. */
204 float value; /* bytes/sec */
207 /* Link Sub-TLV: Maximum Reservable Bandwidth */ /* Optional */
208 #define TE_LINK_SUBTLV_MAX_RSV_BW 7
209 struct te_link_subtlv_max_rsv_bw
211 struct te_tlv_header header; /* Value length is 4 octets. */
212 float value; /* bytes/sec */
215 /* Link Sub-TLV: Unreserved Bandwidth */ /* Optional */
216 #define TE_LINK_SUBTLV_UNRSV_BW 8
217 #define TE_LINK_SUBTLV_UNRSV_SIZE 32
218 struct te_link_subtlv_unrsv_bw
220 struct te_tlv_header header; /* Value length is 32 octets. */
221 float value[MAX_CLASS_TYPE]; /* One for each priority level. */
224 /* Link Sub-TLV: Resource Class/Color */ /* Optional */
225 #define TE_LINK_SUBTLV_RSC_CLSCLR 9
226 struct te_link_subtlv_rsc_clsclr
228 struct te_tlv_header header; /* Value length is 4 octets. */
229 u_int32_t value; /* Admin. group membership. */
233 /* Local and Remote TE Router ID */
234 #define TE_LINK_SUBTLV_LRRID 10
235 #define TE_LINK_SUBTLV_LRRID_SIZE 8
236 struct te_link_subtlv_lrrid
238 struct te_tlv_header header; /* Value length is 8 octets. */
239 struct in_addr local; /* Local TE Router Identifier */
240 struct in_addr remote; /* Remote TE Router Identifier */
243 /* RFC4203: Link Local/Remote Identifiers */
244 #define TE_LINK_SUBTLV_LLRI 11
245 #define TE_LINK_SUBTLV_LLRI_SIZE 8
246 struct te_link_subtlv_llri
248 struct te_tlv_header header; /* Value length is 8 octets. */
249 u_int32_t local; /* Link Local Identifier */
250 u_int32_t remote; /* Link Remote Identifier */
253 /* Inter-RA Export Upward sub-TLV (12) and Inter-RA Export Downward sub-TLV (13) (RFC6827bis) are not yet supported */
254 /* SUBTLV 14-16 (RFC4203) are not yet supported */
255 /* Bandwidth Constraints sub-TLV (17) (RFC4124) is not yet supported */
256 /* SUBLV 18-20 are for OSPFv6 TE (RFC5329). see ospf6d */
259 /* Remote AS Number sub-TLV */
260 #define TE_LINK_SUBTLV_RAS 21
261 struct te_link_subtlv_ras
263 struct te_tlv_header header; /* Value length is 4 octets. */
264 u_int32_t value; /* Remote AS number */
267 /* IPv4 Remote ASBR ID Sub-TLV */
268 #define TE_LINK_SUBTLV_RIP 22
269 struct te_link_subtlv_rip
271 struct te_tlv_header header; /* Value length is 4 octets. */
272 struct in_addr value; /* Remote ASBR IP address */
275 /* SUBTLV 24 is IPv6 Remote ASBR ID (RFC5392). see ospf6d */
277 /* SUBTLV 23 (RFC5330) and 25 (RFC6001) are not yet supported */
279 /* SUBTLV 26 (RFC7308) is not yet supported */
282 /* Link Sub-TLV: Average Link Delay */ /* Optional */
283 #define TE_LINK_SUBTLV_AV_DELAY 27
284 struct te_link_subtlv_av_delay
286 struct te_tlv_header header; /* Value length is 4 bytes. */
287 u_int32_t value; /* delay in micro-seconds only 24 bits => 0 ... 16777215
288 with Anomalous Bit as Upper most bit */
291 /* Link Sub-TLV: Low/High Link Delay */
292 #define TE_LINK_SUBTLV_MM_DELAY 28
293 #define TE_LINK_SUBTLV_MM_DELAY_SIZE 8
294 struct te_link_subtlv_mm_delay
296 struct te_tlv_header header; /* Value length is 8 bytes. */
297 u_int32_t low; /* low delay in micro-seconds only 24 bits => 0 ... 16777215
298 with Anomalous Bit (A) as Upper most bit */
299 u_int32_t high; /* high delay in micro-seconds only 24 bits => 0 ... 16777215 */
302 /* Link Sub-TLV: Link Delay Variation i.e. Jitter */
303 #define TE_LINK_SUBTLV_DELAY_VAR 29
304 struct te_link_subtlv_delay_var
306 struct te_tlv_header header; /* Value length is 4 bytes. */
307 u_int32_t value; /* interval in micro-seconds only 24 bits => 0 ... 16777215 */
310 /* Link Sub-TLV: Routine Unidirectional Link Packet Loss */
311 #define TE_LINK_SUBTLV_PKT_LOSS 30
312 struct te_link_subtlv_pkt_loss
314 struct te_tlv_header header; /* Value length is 4 bytes. */
315 u_int32_t value; /* in percentage of total traffic only 24 bits (2^24 - 2)
316 with Anomalous Bit as Upper most bit */
319 /* Link Sub-TLV: Unidirectional Residual Bandwidth */ /* Optional */
320 #define TE_LINK_SUBTLV_RES_BW 31
321 struct te_link_subtlv_res_bw
323 struct te_tlv_header header; /* Value length is 4 bytes. */
324 float value; /* bandwidth in IEEE floating point format with units in bytes per second */
327 /* Link Sub-TLV: Unidirectional Available Bandwidth */ /* Optional */
328 #define TE_LINK_SUBTLV_AVA_BW 32
329 struct te_link_subtlv_ava_bw
331 struct te_tlv_header header; /* Value length is 4 octets. */
332 float value; /* bandwidth in IEEE floating point format with units in bytes per second */
335 /* Link Sub-TLV: Unidirectional Utilized Bandwidth */ /* Optional */
336 #define TE_LINK_SUBTLV_USE_BW 33
337 struct te_link_subtlv_use_bw
339 struct te_tlv_header header; /* Value length is 4 octets. */
340 float value; /* bandwidth in IEEE floating point format with units in bytes per second */
343 #define TE_LINK_SUBTLV_MAX 34 /* Last SUBTLV + 1 */
345 /* Here are "non-official" architectural constants. */
346 #define MPLS_TE_MINIMUM_BANDWIDTH 1.0 /* Reasonable? *//* XXX */
348 /* Following declaration concerns the MPLS-TE and LINk-TE management */
349 typedef enum _opcode_t
350 { REORIGINATE_THIS_LSA, REFRESH_THIS_LSA, FLUSH_THIS_LSA } opcode_t;
352 typedef enum _status_t
353 { disabled, enabled } status_t;
355 /* Mode for Inter-AS Opaque-LSA */
356 enum inter_as_mode { Disable, AS, Area };
358 struct te_link_subtlv
360 struct te_tlv_header header;
364 struct in_addr link_id;
365 struct in_addr lclif;
366 struct in_addr rmtif;
371 u_int32_t rsc_clsclr;
375 struct in_addr lrrid[2];
386 /* Following structure are internal use only. */
389 /* Status of MPLS-TE: enable or disable */
393 enum inter_as_mode inter_as;
394 struct in_addr interas_areaid;
396 /* List elements are zebra-interfaces (ifp), not ospf-interfaces (oi). */
399 /* Store Router-TLV in network byte order. */
400 struct te_tlv_router_addr router_addr;
406 * According to MPLS-TE (draft) specification, 24-bit Opaque-ID field
407 * is subdivided into 8-bit "unused" field and 16-bit "instance" field.
408 * In this implementation, each Link-TLV has its own instance.
412 /* Reference pointer to a Zebra-interface. */
413 struct interface *ifp;
415 /* Area info in which this MPLS-TE link belongs to. */
416 struct ospf_area *area;
418 /* Flags to manage this link parameters. */
421 /* Type of MPLS-TE link: RFC3630, RFC5392, RFC5392 emulated, RFC6827 */
424 /* Store Link-TLV in network byte order. */
425 /* RFC3630 & RFC6827 / RFC 6827 */
426 struct te_tlv_link link_header;
427 struct te_link_subtlv_link_type link_type;
428 struct te_link_subtlv_link_id link_id;
429 struct te_link_subtlv_lclif_ipaddr lclif_ipaddr;
430 struct te_link_subtlv_rmtif_ipaddr rmtif_ipaddr;
431 struct te_link_subtlv_te_metric te_metric;
432 struct te_link_subtlv_max_bw max_bw;
433 struct te_link_subtlv_max_rsv_bw max_rsv_bw;
434 struct te_link_subtlv_unrsv_bw unrsv_bw;
435 struct te_link_subtlv_rsc_clsclr rsc_clsclr;
437 struct te_link_subtlv_llri llri;
439 struct te_link_subtlv_ras ras;
440 struct te_link_subtlv_rip rip;
442 struct te_link_subtlv_lrrid lrrid;
444 struct te_link_subtlv_av_delay av_delay;
445 struct te_link_subtlv_mm_delay mm_delay;
446 struct te_link_subtlv_delay_var delay_var;
447 struct te_link_subtlv_pkt_loss pkt_loss;
448 struct te_link_subtlv_res_bw res_bw;
449 struct te_link_subtlv_ava_bw ava_bw;
450 struct te_link_subtlv_use_bw use_bw;
452 struct in_addr adv_router;
457 extern int ospf_mpls_te_init (void);
458 extern void ospf_mpls_te_term (void);
459 extern struct ospf_mpls_te *get_ospf_mpls_te (void);
460 extern void ospf_mpls_te_update_if (struct interface *);
461 extern void ospf_mpls_te_lsa_schedule (struct mpls_te_link *, opcode_t);
462 extern u_int32_t get_mpls_te_instance_value (void);
463 extern void set_linkparams_llri (struct mpls_te_link *, u_int32_t, u_int32_t);
464 extern void set_linkparams_lrrid (struct mpls_te_link *, struct in_addr, struct in_addr);
466 #endif /* _ZEBRA_OSPF_MPLS_TE_H */