]>
Commit | Line | Data |
---|---|---|
cf9b9f77 OD |
1 | /* |
2 | * This is an implementation of RFC7684 OSPFv2 Prefix/Link Attribute | |
3 | * Advertisement | |
4 | * | |
5 | * Module name: Extended Prefix/Link Opaque LSA header definition | |
6 | * | |
cf9b9f77 | 7 | * Author: Olivier Dugeon <olivier.dugeon@orange.com> |
7743f2f8 | 8 | * Author: Anselme Sawadogo <anselmesawadogo@gmail.com> |
cf9b9f77 | 9 | * |
7743f2f8 | 10 | * Copyright (C) 2016 - 2018 Orange Labs http://www.orange.com |
cf9b9f77 | 11 | * |
7743f2f8 OD |
12 | * This program is free software; you can redistribute it and/or modify it |
13 | * under the terms of the GNU General Public License as published by the Free | |
14 | * Software Foundation; either version 2 of the License, or (at your option) | |
15 | * any later version. | |
cf9b9f77 | 16 | * |
7743f2f8 OD |
17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
20 | * more details. | |
cf9b9f77 | 21 | * |
7743f2f8 OD |
22 | * You should have received a copy of the GNU General Public License along |
23 | * with this program; see the file COPYING; if not, write to the Free Software | |
24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
cf9b9f77 OD |
25 | */ |
26 | ||
27 | #ifndef _FRR_OSPF_EXT_PREF_H_ | |
28 | #define _FRR_OSPF_EXT_PREF_H_ | |
29 | ||
30 | /* | |
31 | * Opaque LSA's link state ID for Extended Prefix/Link is | |
32 | * structured as follows. | |
33 | * | |
34 | * 24 16 8 0 | |
35 | * +--------+--------+--------+--------+ | |
36 | * | 7/8 |........|........|........| | |
37 | * +--------+--------+--------+--------+ | |
38 | * |<-Type->|<------- Instance ------->| | |
39 | * | |
40 | * | |
41 | * Type: IANA has assigned '7' for Extended Prefix Opaque LSA | |
7743f2f8 | 42 | * and '8' for Extended Link Opaque LSA |
cf9b9f77 OD |
43 | * Instance: User may select arbitrary 24-bit values to identify |
44 | * different instances of Extended Prefix/Link Opaque LSA | |
45 | * | |
46 | */ | |
47 | ||
48 | /* | |
49 | * 24 16 8 0 | |
50 | * +--------+--------+--------+--------+ --- | |
51 | * | LS age |Options | 10,11 | A | |
52 | * +--------+--------+--------+--------+ | Standard (Opaque) LSA header; | |
53 | * | 7/8 | Instance | | | |
54 | * +--------+--------+--------+--------+ | Type 10 or 11 are used for Extended | |
55 | * | Advertising router | | Prefix Opaque LSA | |
56 | * +--------+--------+--------+--------+ | | |
57 | * | LS sequence number | | Type 10 only is used for Extended | |
58 | * +--------+--------+--------+--------+ | Link Opaque LSA | |
59 | * | LS checksum | Length | V | |
60 | * +--------+--------+--------+--------+ --- | |
61 | * | Type | Length | A | |
62 | * +--------+--------+--------+--------+ | TLV part for Extended Prefix/Link | |
63 | * | | | Opaque LSA; | |
64 | * ~ Values ... ~ | Values might be structured as a set | |
65 | * | | V of sub-TLVs. | |
66 | * +--------+--------+--------+--------+ --- | |
67 | */ | |
68 | ||
69 | /* Global use constant numbers */ | |
70 | ||
7743f2f8 | 71 | #define MAX_LEGAL_EXT_INSTANCE_NUM (0xffff) |
cf9b9f77 OD |
72 | #define LEGAL_EXT_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff) |
73 | ||
74 | /* Flags to manage Extended Link/Prefix Opaque LSA */ | |
75 | #define EXT_LPFLG_LSA_INACTIVE 0x00 | |
76 | #define EXT_LPFLG_LSA_ACTIVE 0x01 | |
77 | #define EXT_LPFLG_LSA_ENGAGED 0x02 | |
78 | #define EXT_LPFLG_LSA_LOOKUP_DONE 0x04 | |
79 | #define EXT_LPFLG_LSA_FORCED_REFRESH 0x08 | |
80 | #define EXT_LPFLG_FIB_ENTRY_SET 0x10 | |
81 | ||
82 | /* | |
83 | * Following section defines TLV (tag, length, value) structures, | |
84 | * used in Extended Prefix/Link Opaque LSA. | |
85 | */ | |
86 | ||
87 | /* Extended Prefix TLV Route Types */ | |
88 | #define EXT_TLV_PREF_ROUTE_UNSPEC 0 | |
89 | #define EXT_TLV_PREF_ROUTE_INTRA_AREA 1 | |
90 | #define EXT_TLV_PREF_ROUTE_INTER_AREA 3 | |
91 | #define EXT_TLV_PREF_ROUTE_AS_EXT 5 | |
92 | #define EXT_TLV_PREF_ROUTE_NSSA_EXT 7 | |
93 | ||
7743f2f8 OD |
94 | /* |
95 | * Extended Prefix and Extended Prefix Range TLVs' | |
96 | * Address family flag for IPv4 | |
97 | */ | |
cf9b9f77 OD |
98 | #define EXT_TLV_PREF_AF_IPV4 0 |
99 | ||
100 | /* Extended Prefix TLV Flags */ | |
101 | #define EXT_TLV_PREF_AFLG 0x80 | |
102 | #define EXT_TLV_PREF_NFLG 0x40 | |
103 | ||
104 | /* Extended Prefix Range TLV Flags */ | |
105 | #define EXT_TLV_PREF_RANGE_IAFLG 0x80 | |
106 | ||
107 | /* ERO subtlvs Flags */ | |
108 | #define EXT_SUBTLV_ERO_LFLG 0x80 | |
109 | ||
110 | /* Extended Prefix TLV see RFC 7684 section 2.1 */ | |
111 | #define EXT_TLV_PREFIX 1 | |
112 | #define EXT_TLV_PREFIX_SIZE 8 | |
113 | struct ext_tlv_prefix { | |
114 | struct tlv_header header; | |
93f0a26e OD |
115 | uint8_t route_type; |
116 | uint8_t pref_length; | |
117 | uint8_t af; | |
118 | uint8_t flags; | |
cf9b9f77 OD |
119 | struct in_addr address; |
120 | }; | |
121 | ||
122 | /* Extended Link TLV see RFC 7684 section 3.1 */ | |
123 | #define EXT_TLV_LINK 1 | |
124 | #define EXT_TLV_LINK_SIZE 12 | |
125 | struct ext_tlv_link { | |
126 | struct tlv_header header; | |
93f0a26e OD |
127 | uint8_t link_type; |
128 | uint8_t reserved[3]; | |
cf9b9f77 OD |
129 | struct in_addr link_id; |
130 | struct in_addr link_data; | |
131 | }; | |
132 | ||
133 | /* Remote Interface Address Sub-TLV, Cisco experimental use Sub-TLV */ | |
134 | #define EXT_SUBTLV_RMT_ITF_ADDR 32768 | |
135 | #define EXT_SUBTLV_RMT_ITF_ADDR_SIZE 4 | |
136 | struct ext_subtlv_rmt_itf_addr { | |
137 | struct tlv_header header; | |
138 | struct in_addr value; | |
139 | }; | |
140 | ||
141 | /* Internal structure to manage Extended Link/Prefix Opaque LSA */ | |
142 | struct ospf_ext_lp { | |
143 | bool enabled; | |
144 | ||
145 | /* Flags to manage this Extended Prefix/Link Opaque LSA */ | |
93f0a26e | 146 | uint32_t flags; |
cf9b9f77 | 147 | |
7743f2f8 OD |
148 | /* |
149 | * Scope is area Opaque Type 10 or AS Opaque LSA Type 11 for | |
150 | * Extended Prefix and area Opaque Type 10 for Extended Link | |
151 | */ | |
93f0a26e | 152 | uint8_t scope; |
cf9b9f77 | 153 | |
cf9b9f77 OD |
154 | /* List of interface with Segment Routing enable */ |
155 | struct list *iflist; | |
156 | }; | |
157 | ||
158 | /* Structure to aggregate interfaces information for Extended Prefix/Link */ | |
159 | struct ext_itf { | |
160 | /* 24-bit Opaque-ID field value according to RFC 7684 specification */ | |
93f0a26e OD |
161 | uint32_t instance; |
162 | uint8_t type; /* Extended Prefix (7) or Link (8) */ | |
cf9b9f77 OD |
163 | |
164 | /* Reference pointer to a Zebra-interface. */ | |
165 | struct interface *ifp; | |
166 | ||
167 | /* Area info in which this SR link belongs to. */ | |
168 | struct ospf_area *area; | |
169 | ||
170 | /* Flags to manage this link parameters. */ | |
93f0a26e | 171 | uint32_t flags; |
cf9b9f77 OD |
172 | |
173 | /* SID type: Node, Adjacency or LAN Adjacency */ | |
174 | enum sid_type stype; | |
175 | ||
176 | /* extended link/prefix TLV information */ | |
177 | struct ext_tlv_prefix prefix; | |
178 | struct ext_subtlv_prefix_sid node_sid; | |
179 | struct ext_tlv_link link; | |
180 | struct ext_subtlv_adj_sid adj_sid[2]; | |
181 | struct ext_subtlv_lan_adj_sid lan_sid[2]; | |
182 | ||
183 | /* cisco experimental subtlv */ | |
184 | struct ext_subtlv_rmt_itf_addr rmt_itf_addr; | |
185 | }; | |
186 | ||
187 | /* Prototypes. */ | |
188 | extern int ospf_ext_init(void); | |
189 | extern void ospf_ext_term(void); | |
bcf4475e | 190 | extern void ospf_ext_finish(void); |
7743f2f8 | 191 | extern void ospf_ext_update_sr(bool enable); |
6f751f14 | 192 | extern void ospf_ext_link_srlb_update(void); |
db28a51f | 193 | extern uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp, |
996c9314 LB |
194 | uint32_t index, |
195 | struct prefix_ipv4 *p, | |
196 | uint8_t flags); | |
cf9b9f77 | 197 | #endif /* _FRR_OSPF_EXT_PREF_H_ */ |