]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_ri.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / ospfd / ospf_ri.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * This is an implementation of RFC4970 Router Information
4 * with support of RFC5088 PCE Capabilites announcement
5 * and support of draft-ietf-ospf-segment-routing-extensions-18
6 * for Segment Routing Capabilities announcement
7 *
8 *
9 * Module name: Router Information
10 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
11 * Copyright (C) 2012 - 2017 Orange Labs http://www.orange.com/
12 */
13
14 #ifndef _ZEBRA_OSPF_ROUTER_INFO_H
15 #define _ZEBRA_OSPF_ROUTER_INFO_H
16
17 /*
18 * Opaque LSA's link state ID for Router Information is
19 * structured as follows.
20 *
21 * 24 16 8 0
22 * +--------+--------+--------+--------+
23 * | 4 | MBZ |........|........|
24 * +--------+--------+--------+--------+
25 * |<-Type->|<Resv'd>|<-- Instance --->|
26 *
27 *
28 * Type: IANA has assigned '4' for Router Information.
29 * MBZ: Reserved, must be set to zero.
30 * Instance: User may select an arbitrary 16-bit value.
31 *
32 */
33
34 /*
35 * 24 16 8 0
36 * +--------+--------+--------+--------+ ---
37 * | LS age |Options | 9,10,11| A
38 * +--------+--------+--------+--------+ |
39 * | 4 | 0 | Instance | |
40 * +--------+--------+--------+--------+ |
41 * | Advertising router | | Standard (Opaque) LSA header;
42 * +--------+--------+--------+--------+ | Type 9,10 or 11 are used.
43 * | LS sequence number | |
44 * +--------+--------+--------+--------+ |
45 * | LS checksum | Length | V
46 * +--------+--------+--------+--------+ ---
47 * | Type | Length | A TLV part for Router Information;
48 * +--------+--------+--------+--------+ | Values might be
49 * | Values ... | V structured as a set of sub-TLVs.
50 * +--------+--------+--------+--------+ ---
51 */
52
53 /*
54 * Following section defines TLV body parts.
55 */
56
57 /* Up to now, 11 code points have been assigned to Router Information */
58 /* Only type 1 Router Capabilities and 6 PCE are supported with this code */
59 #define RI_IANA_MAX_TYPE 11
60
61 /* RFC4970: Router Information Capabilities TLV */ /* Mandatory */
62 #define RI_TLV_CAPABILITIES 1
63 #define RI_TLV_CAPABILITIES_SIZE 4
64 struct ri_tlv_router_cap {
65 struct tlv_header header; /* Value length is 4 bytes. */
66 uint32_t value;
67 };
68
69 /* Capabilities bits are left align */
70 #define RI_GRACE_RESTART 0x80000000
71 #define RI_GRACE_HELPER 0x40000000
72 #define RI_STUB_SUPPORT 0x20000000
73 #define RI_TE_SUPPORT 0x10000000
74 #define RI_P2P_OVER_LAN 0x08000000
75 #define RI_TE_EXPERIMENTAL 0x04000000
76
77 #define RI_TLV_LENGTH 4
78
79 /* RFC5088: PCE Capabilities TLV */ /* Optional */
80 /* RI PCE TLV */
81 #define RI_TLV_PCE 6
82
83 struct ri_tlv_pce {
84 struct tlv_header header;
85 /* A set of PCE-sub-TLVs will follow. */
86 };
87
88 /* PCE Address Sub-TLV */ /* Mandatory */
89 #define RI_PCE_SUBTLV_ADDRESS 1
90 struct ri_pce_subtlv_address {
91 /* Type = 1; Length is 8 (IPv4) or 20 (IPv6) bytes. */
92 struct tlv_header header;
93 #define PCE_ADDRESS_IPV4_SIZE 8
94 #define PCE_ADDRESS_IPV6_SIZE 20
95 struct {
96 uint16_t type; /* Address type: 1 = IPv4, 2 = IPv6 */
97 #define PCE_ADDRESS_IPV4 1
98 #define PCE_ADDRESS_IPV6 2
99 uint16_t reserved;
100 struct in_addr value; /* PCE address */
101 } address;
102 };
103
104 /* PCE Path-Scope Sub-TLV */ /* Mandatory */
105 #define RI_PCE_SUBTLV_PATH_SCOPE 2
106 #define RI_PCE_SUBTLV_PATH_SCOPE_SIZE 4
107 struct ri_pce_subtlv_path_scope {
108 struct tlv_header header; /* Type = 2; Length = 4 bytes. */
109 /*
110 * L, R, Rd, S, Sd, Y, PrefL, PrefR, PrefS and PrefY bits:
111 * see RFC5088 page 9
112 */
113 uint32_t value;
114 };
115
116 /* PCE Domain Sub-TLV */ /* Optional */
117 #define PCE_DOMAIN_TYPE_AREA 1
118 #define PCE_DOMAIN_TYPE_AS 2
119
120 #define RI_PCE_SUBTLV_DOMAIN 3
121 #define RI_PCE_SUBTLV_DOMAIN_SIZE 8
122 struct ri_pce_subtlv_domain {
123 struct tlv_header header; /* Type = 3; Length = 8 bytes. */
124 uint16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
125 uint16_t reserved;
126 uint32_t value;
127 };
128
129 /* PCE Neighbor Sub-TLV */ /* Mandatory if R or S bit is set */
130 #define RI_PCE_SUBTLV_NEIGHBOR 4
131 #define RI_PCE_SUBTLV_NEIGHBOR_SIZE 8
132 struct ri_pce_subtlv_neighbor {
133 struct tlv_header header; /* Type = 4; Length = 8 bytes. */
134 uint16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
135 uint16_t reserved;
136 uint32_t value;
137 };
138
139 /* PCE Capabilities Flags Sub-TLV */ /* Optional */
140 #define RI_PCE_SUBTLV_CAP_FLAG 5
141 #define RI_PCE_SUBTLV_CAP_FLAG_SIZE 4
142
143 #define PCE_CAP_GMPLS_LINK 0x0001
144 #define PCE_CAP_BIDIRECTIONAL 0x0002
145 #define PCE_CAP_DIVERSE_PATH 0x0004
146 #define PCE_CAP_LOAD_BALANCE 0x0008
147 #define PCE_CAP_SYNCHRONIZED 0x0010
148 #define PCE_CAP_OBJECTIVES 0x0020
149 #define PCE_CAP_ADDITIVE 0x0040
150 #define PCE_CAP_PRIORIZATION 0x0080
151 #define PCE_CAP_MULTIPLE_REQ 0x0100
152
153 struct ri_pce_subtlv_cap_flag {
154 struct tlv_header header; /* Type = 5; Length = n x 4 bytes. */
155 uint32_t value;
156 };
157
158 /* Structure to share flooding scope info for Segment Routing */
159 struct scope_info {
160 uint8_t scope;
161 struct list *areas;
162 };
163
164 /* Flags to manage the Router Information LSA. */
165 #define RIFLG_LSA_INACTIVE 0x0
166 #define RIFLG_LSA_ENGAGED 0x1
167 #define RIFLG_LSA_FORCED_REFRESH 0x2
168
169 /* Store Router Information PCE TLV and SubTLV in network byte order. */
170 struct ospf_pce_info {
171 bool enabled;
172 struct ri_tlv_pce pce_header;
173 struct ri_pce_subtlv_address pce_address;
174 struct ri_pce_subtlv_path_scope pce_scope;
175 struct list *pce_domain;
176 struct list *pce_neighbor;
177 struct ri_pce_subtlv_cap_flag pce_cap_flag;
178 };
179
180 /*
181 * Store Router Information Segment Routing TLV and SubTLV
182 * in network byte order
183 */
184 struct ospf_ri_sr_info {
185 bool enabled;
186 /* Algorithms supported by the node */
187 struct ri_sr_tlv_sr_algorithm algo;
188 /*
189 * Segment Routing Global Block i.e. label range
190 * Only one range supported in this code
191 */
192 struct ri_sr_tlv_sid_label_range srgb;
193 /*
194 * Segment Routing Local Block.
195 * Only one block is authorized - see section 3.3
196 */
197 struct ri_sr_tlv_sid_label_range srlb;
198 /* Maximum SID Depth supported by the node */
199 struct ri_sr_tlv_node_msd msd;
200 };
201
202 /* Store area information to flood LSA per area */
203 struct ospf_ri_area_info {
204
205 uint32_t flags;
206
207 /* area pointer if flooding is Type 10 Null if flooding is AS scope */
208 struct ospf_area *area;
209 };
210
211 /* Following structure are internal use only. */
212 struct ospf_router_info {
213 bool enabled;
214
215 uint8_t registered;
216 uint8_t scope;
217 /* LSA flags are only used when scope is AS flooding */
218 uint32_t as_flags;
219
220 /* List of area info to flood RI LSA */
221 struct list *area_info;
222
223 /* Store Router Information Capabilities LSA */
224 struct ri_tlv_router_cap router_cap;
225
226 /* Store PCE capability LSA */
227 struct ospf_pce_info pce_info;
228
229 /* Store SR capability LSA */
230 struct ospf_ri_sr_info sr_info;
231 };
232
233 /* Prototypes. */
234 extern int ospf_router_info_init(void);
235 extern void ospf_router_info_term(void);
236 extern void ospf_router_info_finish(void);
237 extern int ospf_router_info_enable(void);
238 extern void ospf_router_info_update_sr(bool enable, struct sr_node *self);
239 extern struct scope_info ospf_router_info_get_flooding_scope(void);
240 #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */