]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_ri.h
Merge remote-tracking branch 'origin/cmaster' into cmaster-next
[mirror_frr.git] / ospfd / ospf_ri.h
1 /*
2 * This is an implementation of RFC4970 Router Information
3 * with support of RFC5088 PCE Capabilites announcement
4 *
5 * Module name: Router Information
6 * Version: 0.99.22
7 * Created: 2012-02-01 by Olivier Dugeon
8 * Copyright (C) 2012 Orange Labs http://www.orange.com/
9 *
10 * This file is part of GNU Zebra.
11 *
12 * GNU Zebra 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
14 * Free Software Foundation; either version 2, or (at your option) any
15 * later version.
16 *
17 * GNU Zebra is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with GNU Zebra; see the file COPYING. If not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
26 */
27
28 #ifndef _ZEBRA_OSPF_ROUTER_INFO_H
29 #define _ZEBRA_OSPF_ROUTER_INFO_H
30
31 /*
32 * Opaque LSA's link state ID for Router Information is
33 * structured as follows.
34 *
35 * 24 16 8 0
36 * +--------+--------+--------+--------+
37 * | 1 | MBZ |........|........|
38 * +--------+--------+--------+--------+
39 * |<-Type->|<Resv'd>|<-- Instance --->|
40 *
41 *
42 * Type: IANA has assigned '4' for Router Information.
43 * MBZ: Reserved, must be set to zero.
44 * Instance: User may select an arbitrary 16-bit value.
45 *
46 */
47
48 /*
49 * 24 16 8 0
50 * +--------+--------+--------+--------+ ---
51 * | LS age |Options | 9,10,11| A
52 * +--------+--------+--------+--------+ |
53 * | 4 | 0 | Instance | |
54 * +--------+--------+--------+--------+ |
55 * | Advertising router | | Standard (Opaque) LSA header;
56 * +--------+--------+--------+--------+ | Type 9,10 or 11 are used.
57 * | LS sequence number | |
58 * +--------+--------+--------+--------+ |
59 * | LS checksum | Length | V
60 * +--------+--------+--------+--------+ ---
61 * | Type | Length | A
62 * +--------+--------+--------+--------+ | TLV part for Router Information; Values might be
63 * | Values ... | V structured as a set of sub-TLVs.
64 * +--------+--------+--------+--------+ ---
65 */
66
67 /*
68 * Following section defines TLV (tag, length, value) structures,
69 * used for Router Information.
70 */
71 struct ri_tlv_header
72 {
73 u_int16_t type; /* RI_TLV_XXX (see below) */
74 u_int16_t length; /* Value portion only, in byte */
75 };
76
77 #define RI_TLV_HDR_SIZE (sizeof (struct ri_tlv_header))
78 #define RI_TLV_BODY_SIZE(tlvh) (ROUNDUP (ntohs ((tlvh)->length), sizeof (u_int32_t)))
79 #define RI_TLV_SIZE(tlvh) (RI_TLV_HDR_SIZE + RI_TLV_BODY_SIZE(tlvh))
80 #define RI_TLV_HDR_TOP(lsah) (struct ri_tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE)
81 #define RI_TLV_HDR_NEXT(tlvh) (struct ri_tlv_header *)((char *)(tlvh) + RI_TLV_SIZE(tlvh))
82
83 /*
84 * Following section defines TLV body parts.
85 */
86
87 /* Up to now, 8 code point have been assigned to Router Information */
88 /* Only type 1 Router Capabilities and 6 PCE are supported with this code */
89 #define RI_IANA_MAX_TYPE 8
90
91 /* RFC4970: Router Information Capabilities TLV */ /* Mandatory */
92 #define RI_TLV_CAPABILITIES 1
93
94 struct ri_tlv_router_cap
95 {
96 struct ri_tlv_header header; /* Value length is 4 bytes. */
97 u_int32_t value;
98 };
99
100 #define RI_GRACE_RESTART 0x01
101 #define RI_GRACE_HELPER 0x02
102 #define RI_STUB_SUPPORT 0x04
103 #define RI_TE_SUPPORT 0x08
104 #define RI_P2P_OVER_LAN 0x10
105 #define RI_TE_EXPERIMENTAL 0x20
106
107 #define RI_TLV_LENGTH 4
108
109 /* RFC5088: PCE Capabilities TLV */ /* Optional */
110 /* RI PCE TLV */
111 #define RI_TLV_PCE 6
112
113 struct ri_tlv_pce
114 {
115 struct ri_tlv_header header;
116 /* A set of PCE-sub-TLVs will follow. */
117 };
118
119 /* PCE Address Sub-TLV */ /* Mandatory */
120 #define RI_PCE_SUBTLV_ADDRESS 1
121 struct ri_pce_subtlv_address
122 {
123 struct ri_tlv_header header; /* Type = 1; Length is 8 (IPv4) or 20 (IPv6) bytes. */
124 #define PCE_ADDRESS_LENGTH_IPV4 8
125 #define PCE_ADDRESS_LENGTH_IPV6 20
126 struct
127 {
128 u_int16_t type; /* Address type: 1 = IPv4, 2 = IPv6 */
129 #define PCE_ADDRESS_TYPE_IPV4 1
130 #define PCE_ADDRESS_TYPE_IPV6 2
131 u_int16_t reserved;
132 struct in_addr value; /* PCE address */
133 } address;
134 };
135
136 /* PCE Path-Scope Sub-TLV */ /* Mandatory */
137 #define RI_PCE_SUBTLV_PATH_SCOPE 2
138 struct ri_pce_subtlv_path_scope
139 {
140 struct ri_tlv_header header; /* Type = 2; Length = 4 bytes. */
141 u_int32_t value; /* L, R, Rd, S, Sd, Y, PrefL, PrefR, PrefS and PrefY bits see RFC5088 page 9 */
142 };
143
144 /* PCE Domain Sub-TLV */ /* Optional */
145 #define RI_PCE_SUBTLV_DOMAIN 3
146
147 #define PCE_DOMAIN_TYPE_AREA 1
148 #define PCE_DOMAIN_TYPE_AS 2
149
150 struct ri_pce_subtlv_domain
151 {
152 struct ri_tlv_header header; /* Type = 3; Length = 8 bytes. */
153 u_int16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
154 u_int16_t reserved;
155 u_int32_t value;
156 };
157
158 /* PCE Neighbor Sub-TLV */ /* Mandatory if R or S bit is set */
159 #define RI_PCE_SUBTLV_NEIGHBOR 4
160 struct ri_pce_subtlv_neighbor
161 {
162 struct ri_tlv_header header; /* Type = 4; Length = 8 bytes. */
163 u_int16_t type; /* Domain type: 1 = OSPF Area ID, 2 = AS Number */
164 u_int16_t reserved;
165 u_int32_t value;
166 };
167
168 /* PCE Capabilities Flags Sub-TLV */ /* Optional */
169 #define RI_PCE_SUBTLV_CAP_FLAG 5
170
171 #define PCE_CAP_GMPLS_LINK 0x0001
172 #define PCE_CAP_BIDIRECTIONAL 0x0002
173 #define PCE_CAP_DIVERSE_PATH 0x0004
174 #define PCE_CAP_LOAD_BALANCE 0x0008
175 #define PCE_CAP_SYNCHRONIZED 0x0010
176 #define PCE_CAP_OBJECTIVES 0x0020
177 #define PCE_CAP_ADDITIVE 0x0040
178 #define PCE_CAP_PRIORIZATION 0x0080
179 #define PCE_CAP_MULTIPLE_REQ 0x0100
180
181 struct ri_pce_subtlv_cap_flag
182 {
183 struct ri_tlv_header header; /* Type = 5; Length = n x 4 bytes. */
184 u_int32_t value;
185 };
186
187 /* Prototypes. */
188 extern int ospf_router_info_init (void);
189 extern void ospf_router_info_term (void);
190
191 #endif /* _ZEBRA_OSPF_ROUTER_INFO_H */