]>
Commit | Line | Data |
---|---|---|
0ef4bcdc OD |
1 | /* |
2 | * This is an implementation of RFC4970 Router Information | |
3 | * with support of RFC5088 PCE Capabilites announcement | |
cf9b9f77 OD |
4 | * and support of draft-ietf-ospf-segment-routing-extensions-18 |
5 | * for Segment Routing Capabilities announcement | |
6 | * | |
0ef4bcdc OD |
7 | * |
8 | * Module name: Router Information | |
cf9b9f77 OD |
9 | * Author: Olivier Dugeon <olivier.dugeon@orange.com> |
10 | * Copyright (C) 2012 - 2017 Orange Labs http://www.orange.com/ | |
0ef4bcdc OD |
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 | * | |
896014f4 DL |
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 | |
0ef4bcdc OD |
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 | * +--------+--------+--------+--------+ | |
cf9b9f77 | 38 | * | 4 | MBZ |........|........| |
0ef4bcdc OD |
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 | * +--------+--------+--------+--------+ --- | |
cf9b9f77 OD |
62 | * | Type | Length | A TLV part for Router Information; |
63 | * +--------+--------+--------+--------+ | Values might be | |
0ef4bcdc OD |
64 | * | Values ... | V structured as a set of sub-TLVs. |
65 | * +--------+--------+--------+--------+ --- | |
66 | */ | |
67 | ||
0ef4bcdc OD |
68 | /* |
69 | * Following section defines TLV body parts. | |
70 | */ | |
71 | ||
cf9b9f77 | 72 | /* Up to now, 11 code points have been assigned to Router Information */ |
0ef4bcdc | 73 | /* Only type 1 Router Capabilities and 6 PCE are supported with this code */ |
cf9b9f77 | 74 | #define RI_IANA_MAX_TYPE 11 |
0ef4bcdc OD |
75 | |
76 | /* RFC4970: Router Information Capabilities TLV */ /* Mandatory */ | |
77 | #define RI_TLV_CAPABILITIES 1 | |
78 | ||
d62a17ae | 79 | struct ri_tlv_router_cap { |
ead99d5f | 80 | struct tlv_header header; /* Value length is 4 bytes. */ |
d7c0a89a | 81 | uint32_t value; |
0ef4bcdc OD |
82 | }; |
83 | ||
cf9b9f77 OD |
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 | |
c97dbe20 | 90 | #define RI_TE_EXPERIMENTAL 0x04000000 |
0ef4bcdc OD |
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 | ||
d62a17ae | 98 | struct ri_tlv_pce { |
ead99d5f | 99 | struct tlv_header header; |
d62a17ae | 100 | /* A set of PCE-sub-TLVs will follow. */ |
0ef4bcdc OD |
101 | }; |
102 | ||
103 | /* PCE Address Sub-TLV */ /* Mandatory */ | |
104 | #define RI_PCE_SUBTLV_ADDRESS 1 | |
d62a17ae | 105 | struct ri_pce_subtlv_address { |
ead99d5f OD |
106 | /* Type = 1; Length is 8 (IPv4) or 20 (IPv6) bytes. */ |
107 | struct tlv_header header; | |
0ef4bcdc OD |
108 | #define PCE_ADDRESS_LENGTH_IPV4 8 |
109 | #define PCE_ADDRESS_LENGTH_IPV6 20 | |
d62a17ae | 110 | struct { |
d7c0a89a | 111 | uint16_t type; /* Address type: 1 = IPv4, 2 = IPv6 */ |
0ef4bcdc OD |
112 | #define PCE_ADDRESS_TYPE_IPV4 1 |
113 | #define PCE_ADDRESS_TYPE_IPV6 2 | |
d7c0a89a | 114 | uint16_t reserved; |
d62a17ae | 115 | struct in_addr value; /* PCE address */ |
116 | } address; | |
0ef4bcdc OD |
117 | }; |
118 | ||
119 | /* PCE Path-Scope Sub-TLV */ /* Mandatory */ | |
120 | #define RI_PCE_SUBTLV_PATH_SCOPE 2 | |
d62a17ae | 121 | struct ri_pce_subtlv_path_scope { |
ead99d5f OD |
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 | */ | |
d7c0a89a | 127 | uint32_t value; |
0ef4bcdc OD |
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 | ||
d62a17ae | 136 | struct ri_pce_subtlv_domain { |
ead99d5f | 137 | struct tlv_header header; /* Type = 3; Length = 8 bytes. */ |
d7c0a89a QY |
138 | uint16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */ |
139 | uint16_t reserved; | |
140 | uint32_t value; | |
0ef4bcdc OD |
141 | }; |
142 | ||
143 | /* PCE Neighbor Sub-TLV */ /* Mandatory if R or S bit is set */ | |
144 | #define RI_PCE_SUBTLV_NEIGHBOR 4 | |
d62a17ae | 145 | struct ri_pce_subtlv_neighbor { |
ead99d5f | 146 | struct tlv_header header; /* Type = 4; Length = 8 bytes. */ |
d7c0a89a QY |
147 | uint16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */ |
148 | uint16_t reserved; | |
149 | uint32_t value; | |
0ef4bcdc OD |
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 | |
cf9b9f77 OD |
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 | |
0ef4bcdc OD |
160 | #define PCE_CAP_OBJECTIVES 0x0020 |
161 | #define PCE_CAP_ADDITIVE 0x0040 | |
cf9b9f77 OD |
162 | #define PCE_CAP_PRIORIZATION 0x0080 |
163 | #define PCE_CAP_MULTIPLE_REQ 0x0100 | |
0ef4bcdc | 164 | |
d62a17ae | 165 | struct ri_pce_subtlv_cap_flag { |
ead99d5f | 166 | struct tlv_header header; /* Type = 5; Length = n x 4 bytes. */ |
d7c0a89a | 167 | uint32_t value; |
0ef4bcdc OD |
168 | }; |
169 | ||
cf9b9f77 OD |
170 | /* Structure to share flooding scope info for Segment Routing */ |
171 | struct scope_info { | |
93f0a26e | 172 | uint8_t scope; |
ddd73a96 OD |
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; | |
cf9b9f77 OD |
238 | }; |
239 | ||
0ef4bcdc | 240 | /* Prototypes. */ |
d62a17ae | 241 | extern int ospf_router_info_init(void); |
242 | extern void ospf_router_info_term(void); | |
bcf4475e | 243 | extern void ospf_router_info_finish(void); |
cf9b9f77 | 244 | extern int ospf_router_info_enable(void); |
7743f2f8 OD |
245 | extern void ospf_router_info_update_sr(bool enable, struct sr_srgb srgb, |
246 | uint8_t msd); | |
cf9b9f77 | 247 | extern struct scope_info ospf_router_info_get_flooding_scope(void); |
0ef4bcdc | 248 | #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */ |