]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_ri.h
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[mirror_frr.git] / ospfd / ospf_ri.h
1 /*
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
6 *
7 *
8 * Module name: Router Information
9 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
10 * Copyright (C) 2012 - 2017 Orange Labs http://www.orange.com/
11 *
12 * This file is part of GNU Zebra.
13 *
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
17 * later version.
18 *
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.
23 *
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
27 */
28
29 #ifndef _ZEBRA_OSPF_ROUTER_INFO_H
30 #define _ZEBRA_OSPF_ROUTER_INFO_H
31
32 /*
33 * Opaque LSA's link state ID for Router Information is
34 * structured as follows.
35 *
36 * 24 16 8 0
37 * +--------+--------+--------+--------+
38 * | 4 | MBZ |........|........|
39 * +--------+--------+--------+--------+
40 * |<-Type->|<Resv'd>|<-- Instance --->|
41 *
42 *
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.
46 *
47 */
48
49 /*
50 * 24 16 8 0
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 * +--------+--------+--------+--------+ ---
66 */
67
68 /*
69 * Following section defines TLV body parts.
70 */
71
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
75
76 /* RFC4970: Router Information Capabilities TLV */ /* Mandatory */
77 #define RI_TLV_CAPABILITIES 1
78
79 struct ri_tlv_router_cap {
80 struct tlv_header header; /* Value length is 4 bytes. */
81 uint32_t value;
82 };
83
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
91
92 #define RI_TLV_LENGTH 4
93
94 /* RFC5088: PCE Capabilities TLV */ /* Optional */
95 /* RI PCE TLV */
96 #define RI_TLV_PCE 6
97
98 struct ri_tlv_pce {
99 struct tlv_header header;
100 /* A set of PCE-sub-TLVs will follow. */
101 };
102
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_LENGTH_IPV4 8
109 #define PCE_ADDRESS_LENGTH_IPV6 20
110 struct {
111 uint16_t type; /* Address type: 1 = IPv4, 2 = IPv6 */
112 #define PCE_ADDRESS_TYPE_IPV4 1
113 #define PCE_ADDRESS_TYPE_IPV6 2
114 uint16_t reserved;
115 struct in_addr value; /* PCE address */
116 } address;
117 };
118
119 /* PCE Path-Scope Sub-TLV */ /* Mandatory */
120 #define RI_PCE_SUBTLV_PATH_SCOPE 2
121 struct ri_pce_subtlv_path_scope {
122 struct tlv_header header; /* Type = 2; Length = 4 bytes. */
123 /*
124 * L, R, Rd, S, Sd, Y, PrefL, PrefR, PrefS and PrefY bits:
125 * see RFC5088 page 9
126 */
127 uint32_t value;
128 };
129
130 /* PCE Domain Sub-TLV */ /* Optional */
131 #define RI_PCE_SUBTLV_DOMAIN 3
132
133 #define PCE_DOMAIN_TYPE_AREA 1
134 #define PCE_DOMAIN_TYPE_AS 2
135
136 struct ri_pce_subtlv_domain {
137 struct tlv_header header; /* Type = 3; Length = 8 bytes. */
138 uint16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
139 uint16_t reserved;
140 uint32_t value;
141 };
142
143 /* PCE Neighbor Sub-TLV */ /* Mandatory if R or S bit is set */
144 #define RI_PCE_SUBTLV_NEIGHBOR 4
145 struct ri_pce_subtlv_neighbor {
146 struct tlv_header header; /* Type = 4; Length = 8 bytes. */
147 uint16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
148 uint16_t reserved;
149 uint32_t value;
150 };
151
152 /* PCE Capabilities Flags Sub-TLV */ /* Optional */
153 #define RI_PCE_SUBTLV_CAP_FLAG 5
154
155 #define PCE_CAP_GMPLS_LINK 0x0001
156 #define PCE_CAP_BIDIRECTIONAL 0x0002
157 #define PCE_CAP_DIVERSE_PATH 0x0004
158 #define PCE_CAP_LOAD_BALANCE 0x0008
159 #define PCE_CAP_SYNCHRONIZED 0x0010
160 #define PCE_CAP_OBJECTIVES 0x0020
161 #define PCE_CAP_ADDITIVE 0x0040
162 #define PCE_CAP_PRIORIZATION 0x0080
163 #define PCE_CAP_MULTIPLE_REQ 0x0100
164
165 struct ri_pce_subtlv_cap_flag {
166 struct tlv_header header; /* Type = 5; Length = n x 4 bytes. */
167 uint32_t value;
168 };
169
170 /* Structure to share flooding scope info for Segment Routing */
171 struct scope_info {
172 uint8_t scope;
173 struct list *areas;
174 };
175
176 /* Flags to manage the Router Information LSA. */
177 #define RIFLG_LSA_INACTIVE 0x0
178 #define RIFLG_LSA_ENGAGED 0x1
179 #define RIFLG_LSA_FORCED_REFRESH 0x2
180
181 /* Store Router Information PCE TLV and SubTLV in network byte order. */
182 struct ospf_pce_info {
183 bool enabled;
184 struct ri_tlv_pce pce_header;
185 struct ri_pce_subtlv_address pce_address;
186 struct ri_pce_subtlv_path_scope pce_scope;
187 struct list *pce_domain;
188 struct list *pce_neighbor;
189 struct ri_pce_subtlv_cap_flag pce_cap_flag;
190 };
191
192 /*
193 * Store Router Information Segment Routing TLV and SubTLV
194 * in network byte order
195 */
196 struct ospf_ri_sr_info {
197 bool enabled;
198 /* Algorithms supported by the node */
199 struct ri_sr_tlv_sr_algorithm algo;
200 /*
201 * Segment Routing Global Block i.e. label range
202 * Only one range supported in this code
203 */
204 struct ri_sr_tlv_sid_label_range range;
205 /* Maximum SID Depth supported by the node */
206 struct ri_sr_tlv_node_msd msd;
207 };
208
209 /* Store area information to flood LSA per area */
210 struct ospf_ri_area_info {
211
212 uint32_t flags;
213
214 /* area pointer if flooding is Type 10 Null if flooding is AS scope */
215 struct ospf_area *area;
216 };
217
218 /* Following structure are internal use only. */
219 struct ospf_router_info {
220 bool enabled;
221
222 uint8_t registered;
223 uint8_t scope;
224 /* LSA flags are only used when scope is AS flooding */
225 uint32_t as_flags;
226
227 /* List of area info to flood RI LSA */
228 struct list *area_info;
229
230 /* Store Router Information Capabilities LSA */
231 struct ri_tlv_router_cap router_cap;
232
233 /* Store PCE capability LSA */
234 struct ospf_pce_info pce_info;
235
236 /* Store SR capability LSA */
237 struct ospf_ri_sr_info sr_info;
238 };
239
240 /* Prototypes. */
241 extern int ospf_router_info_init(void);
242 extern void ospf_router_info_term(void);
243 extern void ospf_router_info_finish(void);
244 extern int ospf_router_info_enable(void);
245 extern void ospf_router_info_update_sr(bool enable, struct sr_srgb srgb,
246 uint8_t msd);
247 extern struct scope_info ospf_router_info_get_flooding_scope(void);
248 #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */