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