2 * IS-IS Rout(e)ing protocol - isis_te.c
4 * This is an implementation of RFC5305, RFC 5307 and RFC 7810
6 * Copyright (C) 2014 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 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
26 #ifndef _ZEBRA_ISIS_MPLS_TE_H
27 #define _ZEBRA_ISIS_MPLS_TE_H
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
36 * and support following sub-TLV:
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
55 /* NOTE: RFC5316 is not yet supported in this version */
57 /* Following define the type of TE link regarding the various RFC */
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)
76 * Following section defines subTLV (tag, length, value) structures,
77 * used for Traffic Engineering.
79 struct subtlv_header
{
80 u_char type
; /* sub_TLV_XXX type (see above) */
81 u_char length
; /* Value portion only, in byte */
84 #define SUBTLV_HDR_SIZE 2 /* (sizeof (struct sub_tlv_header)) */
86 #define SUBTLV_SIZE(stlvh) (SUBTLV_HDR_SIZE + (stlvh)->length)
88 #define SUBTLV_HDR_TOP(lsph) (struct subtlv_header *)((char *)(lsph) + ISIS_LSP_HEADER_SIZE)
90 #define SUBTLV_HDR_NEXT(stlvh) (struct subtlv_header *)((char *)(stlvh) + SUBTLV_SIZE(stlvh))
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
97 #define SUBTLV_DEF_SIZE 4
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__
));
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__
));
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__
));
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__
));
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__
));
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__
));
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__
));
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__
));
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__
));
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__
));
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 ...
181 with Anomalous Bit (A) as Upper most bit */
182 } __attribute__((__packed__
));
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 ...
191 with Anomalous Bit (A) as Upper most bit */
192 u_int32_t high
; /* high delay in micro-seconds only 24 bits => 0 ...
194 } __attribute__((__packed__
));
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 ...
202 } __attribute__((__packed__
));
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. */
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__
));
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
219 } __attribute__((__packed__
));
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
227 } __attribute__((__packed__
));
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
235 } __attribute__((__packed__
));
237 #define TE_SUBTLV_MAX 40 /* Last SUBTLV + 1 */
239 /* Following declaration concerns the MPLS-TE and LINk-TE management */
240 typedef enum _status_t
{ disable
, enable
, learn
} status_t
;
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
;
245 #define IS_MPLS_TE(m) (m.status == enable)
246 #define IS_CIRCUIT_TE(c) (c->status == enable)
248 /* Following structure are internal use only. */
249 struct isis_mpls_te
{
250 /* Status of MPLS-TE: enable or disable */
253 /* L1, L1-L2, L2-Only */
257 interas_mode_t inter_as
;
258 struct in_addr interas_areaid
;
260 /* Circuit list on which TE are enable */
261 struct list
*cir_list
;
263 /* MPLS_TE router ID */
264 struct in_addr router_id
;
267 extern struct isis_mpls_te isisMplsTE
;
269 struct mpls_te_circuit
{
271 /* Status of MPLS-TE on this interface */
274 /* Type of MPLS-TE circuit: STD_TE(RFC5305), INTER_AS(RFC5316),
275 * INTER_AS_EMU(RFC5316 emulated) */
278 /* Total size of sub_tlvs */
281 /* Store subTLV in network byte order. */
283 struct te_subtlv_admin_grp admin_grp
;
285 struct te_subtlv_llri llri
;
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
;
294 struct te_subtlv_ras ras
;
295 struct te_subtlv_rip rip
;
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
;
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
*);
319 #endif /* _ZEBRA_ISIS_MPLS_TE_H */