]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_ext.h
OSPFD: Set Segment Routing patch conform to C99
[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: Anselme Sawadogo <anselmesawadogo@gmail.com>
8 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
9 *
10 * Copyright (C) 2016 - 2017 Orange Labs http://www.orange.com
11 *
12 * This file is part of FRR.
13 *
14 * FRR 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 * FRR 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
25 * along with FRR; see the file COPYING. If not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 */
29
30 #ifndef _FRR_OSPF_EXT_PREF_H_
31 #define _FRR_OSPF_EXT_PREF_H_
32
33 /*
34 * Opaque LSA's link state ID for Extended Prefix/Link is
35 * structured as follows.
36 *
37 * 24 16 8 0
38 * +--------+--------+--------+--------+
39 * | 7/8 |........|........|........|
40 * +--------+--------+--------+--------+
41 * |<-Type->|<------- Instance ------->|
42 *
43 *
44 * Type: IANA has assigned '7' for Extended Prefix Opaque LSA
45 * and '8' for Extended Link Opaque LSA
46 * Instance: User may select arbitrary 24-bit values to identify
47 * different instances of Extended Prefix/Link Opaque LSA
48 *
49 */
50
51 /*
52 * 24 16 8 0
53 * +--------+--------+--------+--------+ ---
54 * | LS age |Options | 10,11 | A
55 * +--------+--------+--------+--------+ | Standard (Opaque) LSA header;
56 * | 7/8 | Instance | |
57 * +--------+--------+--------+--------+ | Type 10 or 11 are used for Extended
58 * | Advertising router | | Prefix Opaque LSA
59 * +--------+--------+--------+--------+ |
60 * | LS sequence number | | Type 10 only is used for Extended
61 * +--------+--------+--------+--------+ | Link Opaque LSA
62 * | LS checksum | Length | V
63 * +--------+--------+--------+--------+ ---
64 * | Type | Length | A
65 * +--------+--------+--------+--------+ | TLV part for Extended Prefix/Link
66 * | | | Opaque LSA;
67 * ~ Values ... ~ | Values might be structured as a set
68 * | | V of sub-TLVs.
69 * +--------+--------+--------+--------+ ---
70 */
71
72 /* Global use constant numbers */
73
74 #define MAX_LEGAL_EXT_INSTANCE_NUM (0xffff)
75 #define LEGAL_EXT_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
76
77 /* Flags to manage Extended Link/Prefix Opaque LSA */
78 #define EXT_LPFLG_LSA_INACTIVE 0x00
79 #define EXT_LPFLG_LSA_ACTIVE 0x01
80 #define EXT_LPFLG_LSA_ENGAGED 0x02
81 #define EXT_LPFLG_LSA_LOOKUP_DONE 0x04
82 #define EXT_LPFLG_LSA_FORCED_REFRESH 0x08
83 #define EXT_LPFLG_FIB_ENTRY_SET 0x10
84
85 /*
86 * Following section defines TLV (tag, length, value) structures,
87 * used in Extended Prefix/Link Opaque LSA.
88 */
89
90 /* Extended Prefix TLV Route Types */
91 #define EXT_TLV_PREF_ROUTE_UNSPEC 0
92 #define EXT_TLV_PREF_ROUTE_INTRA_AREA 1
93 #define EXT_TLV_PREF_ROUTE_INTER_AREA 3
94 #define EXT_TLV_PREF_ROUTE_AS_EXT 5
95 #define EXT_TLV_PREF_ROUTE_NSSA_EXT 7
96
97 /* Extended Prefix and Extended Prefix Range TLVs'
98 * Address family flag for IPv4 */
99 #define EXT_TLV_PREF_AF_IPV4 0
100
101 /* Extended Prefix TLV Flags */
102 #define EXT_TLV_PREF_AFLG 0x80
103 #define EXT_TLV_PREF_NFLG 0x40
104
105 /* Extended Prefix Range TLV Flags */
106 #define EXT_TLV_PREF_RANGE_IAFLG 0x80
107
108 /* ERO subtlvs Flags */
109 #define EXT_SUBTLV_ERO_LFLG 0x80
110
111 /* Extended Prefix TLV see RFC 7684 section 2.1 */
112 #define EXT_TLV_PREFIX 1
113 #define EXT_TLV_PREFIX_SIZE 8
114 struct ext_tlv_prefix {
115 struct tlv_header header;
116 uint8_t route_type;
117 uint8_t pref_length;
118 uint8_t af;
119 uint8_t flags;
120 struct in_addr address;
121 };
122
123 /* Extended Link TLV see RFC 7684 section 3.1 */
124 #define EXT_TLV_LINK 1
125 #define EXT_TLV_LINK_SIZE 12
126 struct ext_tlv_link {
127 struct tlv_header header;
128 uint8_t link_type;
129 uint8_t reserved[3];
130 struct in_addr link_id;
131 struct in_addr link_data;
132 };
133
134 /* Remote Interface Address Sub-TLV, Cisco experimental use Sub-TLV */
135 #define EXT_SUBTLV_RMT_ITF_ADDR 32768
136 #define EXT_SUBTLV_RMT_ITF_ADDR_SIZE 4
137 struct ext_subtlv_rmt_itf_addr {
138 struct tlv_header header;
139 struct in_addr value;
140 };
141
142 /* Internal structure to manage Extended Link/Prefix Opaque LSA */
143 struct ospf_ext_lp {
144 bool enabled;
145
146 /* Flags to manage this Extended Prefix/Link Opaque LSA */
147 uint32_t flags;
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 uint8_t scope;
152
153 /* area pointer if flooding is Type 10 Null if flooding is AS scope */
154 struct ospf_area *area;
155 struct in_addr area_id;
156
157 /* List of interface with Segment Routing enable */
158 struct list *iflist;
159 };
160
161 /* Structure to aggregate interfaces information for Extended Prefix/Link */
162 struct ext_itf {
163 /* 24-bit Opaque-ID field value according to RFC 7684 specification */
164 uint32_t instance;
165 uint8_t type; /* Extended Prefix (7) or Link (8) */
166
167 /* Reference pointer to a Zebra-interface. */
168 struct interface *ifp;
169
170 /* Area info in which this SR link belongs to. */
171 struct ospf_area *area;
172
173 /* Flags to manage this link parameters. */
174 uint32_t flags;
175
176 /* SID type: Node, Adjacency or LAN Adjacency */
177 enum sid_type stype;
178
179 /* extended link/prefix TLV information */
180 struct ext_tlv_prefix prefix;
181 struct ext_subtlv_prefix_sid node_sid;
182 struct ext_tlv_link link;
183 struct ext_subtlv_adj_sid adj_sid[2];
184 struct ext_subtlv_lan_adj_sid lan_sid[2];
185
186 /* cisco experimental subtlv */
187 struct ext_subtlv_rmt_itf_addr rmt_itf_addr;
188 };
189
190 /* Prototypes. */
191 extern int ospf_ext_init(void);
192 extern void ospf_ext_term(void);
193 extern void ospf_ext_update_sr(bool);
194 extern int ospf_ext_schedule_prefix_index(struct interface *, uint32_t,
195 struct prefix_ipv4 *);
196 #endif /* _FRR_OSPF_EXT_PREF_H_ */