1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * This is an implementation of RFC7684 OSPFv2 Prefix/Link Attribute
6 * Module name: Extended Prefix/Link Opaque LSA header definition
8 * Author: Olivier Dugeon <olivier.dugeon@orange.com>
9 * Author: Anselme Sawadogo <anselmesawadogo@gmail.com>
11 * Copyright (C) 2016 - 2018 Orange Labs http://www.orange.com
14 #ifndef _FRR_OSPF_EXT_PREF_H_
15 #define _FRR_OSPF_EXT_PREF_H_
18 * Opaque LSA's link state ID for Extended Prefix/Link is
19 * structured as follows.
22 * +--------+--------+--------+--------+
23 * | 7/8 |........|........|........|
24 * +--------+--------+--------+--------+
25 * |<-Type->|<------- Instance ------->|
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
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 * +--------+--------+--------+--------+ ---
49 * +--------+--------+--------+--------+ | TLV part for Extended Prefix/Link
51 * ~ Values ... ~ | Values might be structured as a set
53 * +--------+--------+--------+--------+ ---
56 /* Global use constant numbers */
58 #define MAX_LEGAL_EXT_INSTANCE_NUM (0xffff)
59 #define LEGAL_EXT_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
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
70 * Following section defines TLV (tag, length, value) structures,
71 * used in Extended Prefix/Link Opaque LSA.
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
82 * Extended Prefix and Extended Prefix Range TLVs'
83 * Address family flag for IPv4
85 #define EXT_TLV_PREF_AF_IPV4 0
87 /* Extended Prefix TLV Flags */
88 #define EXT_TLV_PREF_AFLG 0x80
89 #define EXT_TLV_PREF_NFLG 0x40
91 /* Extended Prefix Range TLV Flags */
92 #define EXT_TLV_PREF_RANGE_IAFLG 0x80
94 /* ERO subtlvs Flags */
95 #define EXT_SUBTLV_ERO_LFLG 0x80
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
;
106 struct in_addr address
;
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
;
116 struct in_addr link_id
;
117 struct in_addr link_data
;
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
;
128 /* Internal structure to manage Extended Link/Prefix Opaque LSA */
132 /* Flags to manage this Extended Prefix/Link Opaque LSA */
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
141 /* List of interface with Segment Routing enable */
145 /* Structure to aggregate interfaces information for Extended Prefix/Link */
147 /* 24-bit Opaque-ID field value according to RFC 7684 specification */
149 uint8_t type
; /* Extended Prefix (7) or Link (8) */
151 /* Reference pointer to a Zebra-interface. */
152 struct interface
*ifp
;
154 /* Area info in which this SR link belongs to. */
155 struct ospf_area
*area
;
157 /* Flags to manage this link parameters. */
160 /* SID type: Node, Adjacency or LAN Adjacency */
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];
170 /* cisco experimental subtlv */
171 struct ext_subtlv_rmt_itf_addr rmt_itf_addr
;
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
,
182 struct prefix_ipv4
*p
,
184 #endif /* _FRR_OSPF_EXT_PREF_H_ */