]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_ext.h
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / ospfd / ospf_ext.h
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 *
7 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
8 * Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
9 *
10 * Copyright (C) 2016 - 2018 Orange Labs http://www.orange.com
11 *
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.
16 *
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.
21 *
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
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
42 * and '8' for Extended Link Opaque LSA
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
71 #define MAX_LEGAL_EXT_INSTANCE_NUM (0xffff)
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
94 /*
95 * Extended Prefix and Extended Prefix Range TLVs'
96 * Address family flag for IPv4
97 */
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;
115 uint8_t route_type;
116 uint8_t pref_length;
117 uint8_t af;
118 uint8_t flags;
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;
127 uint8_t link_type;
128 uint8_t reserved[3];
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 */
146 uint32_t flags;
147
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 */
152 uint8_t scope;
153
154 /* area pointer if flooding is Type 10 Null if flooding is AS scope */
155 struct ospf_area *area;
156 struct in_addr area_id;
157
158 /* List of interface with Segment Routing enable */
159 struct list *iflist;
160 };
161
162 /* Structure to aggregate interfaces information for Extended Prefix/Link */
163 struct ext_itf {
164 /* 24-bit Opaque-ID field value according to RFC 7684 specification */
165 uint32_t instance;
166 uint8_t type; /* Extended Prefix (7) or Link (8) */
167
168 /* Reference pointer to a Zebra-interface. */
169 struct interface *ifp;
170
171 /* Area info in which this SR link belongs to. */
172 struct ospf_area *area;
173
174 /* Flags to manage this link parameters. */
175 uint32_t flags;
176
177 /* SID type: Node, Adjacency or LAN Adjacency */
178 enum sid_type stype;
179
180 /* extended link/prefix TLV information */
181 struct ext_tlv_prefix prefix;
182 struct ext_subtlv_prefix_sid node_sid;
183 struct ext_tlv_link link;
184 struct ext_subtlv_adj_sid adj_sid[2];
185 struct ext_subtlv_lan_adj_sid lan_sid[2];
186
187 /* cisco experimental subtlv */
188 struct ext_subtlv_rmt_itf_addr rmt_itf_addr;
189 };
190
191 /* Prototypes. */
192 extern int ospf_ext_init(void);
193 extern void ospf_ext_term(void);
194 extern void ospf_ext_finish(void);
195 extern void ospf_ext_update_sr(bool enable);
196 extern uint32_t ospf_ext_schedule_prefix_index(struct interface *ifp,
197 uint32_t index,
198 struct prefix_ipv4 *p,
199 uint8_t flags);
200 #endif /* _FRR_OSPF_EXT_PREF_H_ */