2 * This is an implementation of RFC4970 Router Information
3 * with support of RFC5088 PCE Capabilites announcement
4 * and support of draft-ietf-ospf-segment-routing-extensions-18
5 * for Segment Routing Capabilities announcement
8 * Module name: Router Information
9 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
10 * Copyright (C) 2012 - 2017 Orange Labs http://www.orange.com/
12 * This file is part of GNU Zebra.
14 * GNU Zebra is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2, or (at your option) any
19 * GNU Zebra is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; see the file COPYING; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #ifndef _ZEBRA_OSPF_ROUTER_INFO_H
30 #define _ZEBRA_OSPF_ROUTER_INFO_H
33 * Opaque LSA's link state ID for Router Information is
34 * structured as follows.
37 * +--------+--------+--------+--------+
38 * | 4 | MBZ |........|........|
39 * +--------+--------+--------+--------+
40 * |<-Type->|<Resv'd>|<-- Instance --->|
43 * Type: IANA has assigned '4' for Router Information.
44 * MBZ: Reserved, must be set to zero.
45 * Instance: User may select an arbitrary 16-bit value.
51 * +--------+--------+--------+--------+ ---
52 * | LS age |Options | 9,10,11| A
53 * +--------+--------+--------+--------+ |
54 * | 4 | 0 | Instance | |
55 * +--------+--------+--------+--------+ |
56 * | Advertising router | | Standard (Opaque) LSA header;
57 * +--------+--------+--------+--------+ | Type 9,10 or 11 are used.
58 * | LS sequence number | |
59 * +--------+--------+--------+--------+ |
60 * | LS checksum | Length | V
61 * +--------+--------+--------+--------+ ---
62 * | Type | Length | A TLV part for Router Information;
63 * +--------+--------+--------+--------+ | Values might be
64 * | Values ... | V structured as a set of sub-TLVs.
65 * +--------+--------+--------+--------+ ---
69 * Following section defines TLV body parts.
72 /* Up to now, 11 code points have been assigned to Router Information */
73 /* Only type 1 Router Capabilities and 6 PCE are supported with this code */
74 #define RI_IANA_MAX_TYPE 11
76 /* RFC4970: Router Information Capabilities TLV */ /* Mandatory */
77 #define RI_TLV_CAPABILITIES 1
78 #define RI_TLV_CAPABILITIES_SIZE 4
79 struct ri_tlv_router_cap
{
80 struct tlv_header header
; /* Value length is 4 bytes. */
84 /* Capabilities bits are left align */
85 #define RI_GRACE_RESTART 0x80000000
86 #define RI_GRACE_HELPER 0x40000000
87 #define RI_STUB_SUPPORT 0x20000000
88 #define RI_TE_SUPPORT 0x10000000
89 #define RI_P2P_OVER_LAN 0x08000000
90 #define RI_TE_EXPERIMENTAL 0x04000000
92 #define RI_TLV_LENGTH 4
94 /* RFC5088: PCE Capabilities TLV */ /* Optional */
99 struct tlv_header header
;
100 /* A set of PCE-sub-TLVs will follow. */
103 /* PCE Address Sub-TLV */ /* Mandatory */
104 #define RI_PCE_SUBTLV_ADDRESS 1
105 struct ri_pce_subtlv_address
{
106 /* Type = 1; Length is 8 (IPv4) or 20 (IPv6) bytes. */
107 struct tlv_header header
;
108 #define PCE_ADDRESS_IPV4_SIZE 8
109 #define PCE_ADDRESS_IPV6_SIZE 20
111 uint16_t type
; /* Address type: 1 = IPv4, 2 = IPv6 */
112 #define PCE_ADDRESS_IPV4 1
113 #define PCE_ADDRESS_IPV6 2
115 struct in_addr value
; /* PCE address */
119 /* PCE Path-Scope Sub-TLV */ /* Mandatory */
120 #define RI_PCE_SUBTLV_PATH_SCOPE 2
121 #define RI_PCE_SUBTLV_PATH_SCOPE_SIZE 4
122 struct ri_pce_subtlv_path_scope
{
123 struct tlv_header header
; /* Type = 2; Length = 4 bytes. */
125 * L, R, Rd, S, Sd, Y, PrefL, PrefR, PrefS and PrefY bits:
131 /* PCE Domain Sub-TLV */ /* Optional */
132 #define PCE_DOMAIN_TYPE_AREA 1
133 #define PCE_DOMAIN_TYPE_AS 2
135 #define RI_PCE_SUBTLV_DOMAIN 3
136 #define RI_PCE_SUBTLV_DOMAIN_SIZE 8
137 struct ri_pce_subtlv_domain
{
138 struct tlv_header header
; /* Type = 3; Length = 8 bytes. */
139 uint16_t type
; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
144 /* PCE Neighbor Sub-TLV */ /* Mandatory if R or S bit is set */
145 #define RI_PCE_SUBTLV_NEIGHBOR 4
146 #define RI_PCE_SUBTLV_NEIGHBOR_SIZE 8
147 struct ri_pce_subtlv_neighbor
{
148 struct tlv_header header
; /* Type = 4; Length = 8 bytes. */
149 uint16_t type
; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
154 /* PCE Capabilities Flags Sub-TLV */ /* Optional */
155 #define RI_PCE_SUBTLV_CAP_FLAG 5
156 #define RI_PCE_SUBTLV_CAP_FLAG_SIZE 4
158 #define PCE_CAP_GMPLS_LINK 0x0001
159 #define PCE_CAP_BIDIRECTIONAL 0x0002
160 #define PCE_CAP_DIVERSE_PATH 0x0004
161 #define PCE_CAP_LOAD_BALANCE 0x0008
162 #define PCE_CAP_SYNCHRONIZED 0x0010
163 #define PCE_CAP_OBJECTIVES 0x0020
164 #define PCE_CAP_ADDITIVE 0x0040
165 #define PCE_CAP_PRIORIZATION 0x0080
166 #define PCE_CAP_MULTIPLE_REQ 0x0100
168 struct ri_pce_subtlv_cap_flag
{
169 struct tlv_header header
; /* Type = 5; Length = n x 4 bytes. */
173 /* Structure to share flooding scope info for Segment Routing */
179 /* Flags to manage the Router Information LSA. */
180 #define RIFLG_LSA_INACTIVE 0x0
181 #define RIFLG_LSA_ENGAGED 0x1
182 #define RIFLG_LSA_FORCED_REFRESH 0x2
184 /* Store Router Information PCE TLV and SubTLV in network byte order. */
185 struct ospf_pce_info
{
187 struct ri_tlv_pce pce_header
;
188 struct ri_pce_subtlv_address pce_address
;
189 struct ri_pce_subtlv_path_scope pce_scope
;
190 struct list
*pce_domain
;
191 struct list
*pce_neighbor
;
192 struct ri_pce_subtlv_cap_flag pce_cap_flag
;
196 * Store Router Information Segment Routing TLV and SubTLV
197 * in network byte order
199 struct ospf_ri_sr_info
{
201 /* Algorithms supported by the node */
202 struct ri_sr_tlv_sr_algorithm algo
;
204 * Segment Routing Global Block i.e. label range
205 * Only one range supported in this code
207 struct ri_sr_tlv_sid_label_range srgb
;
209 * Segment Routing Local Block.
210 * Only one block is authorized - see section 3.3
212 struct ri_sr_tlv_sid_label_range srlb
;
213 /* Maximum SID Depth supported by the node */
214 struct ri_sr_tlv_node_msd msd
;
217 /* Store area information to flood LSA per area */
218 struct ospf_ri_area_info
{
222 /* area pointer if flooding is Type 10 Null if flooding is AS scope */
223 struct ospf_area
*area
;
226 /* Following structure are internal use only. */
227 struct ospf_router_info
{
232 /* LSA flags are only used when scope is AS flooding */
235 /* List of area info to flood RI LSA */
236 struct list
*area_info
;
238 /* Store Router Information Capabilities LSA */
239 struct ri_tlv_router_cap router_cap
;
241 /* Store PCE capability LSA */
242 struct ospf_pce_info pce_info
;
244 /* Store SR capability LSA */
245 struct ospf_ri_sr_info sr_info
;
249 extern int ospf_router_info_init(void);
250 extern void ospf_router_info_term(void);
251 extern void ospf_router_info_finish(void);
252 extern int ospf_router_info_enable(void);
253 extern void ospf_router_info_update_sr(bool enable
, struct sr_node
*self
);
254 extern struct scope_info
ospf_router_info_get_flooding_scope(void);
255 #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */