blob: 64cf9a7b778ea36039db93fcaa0487944fddab1d [file] [log] [blame]
sunish vk30637eb2016-02-16 15:19:32 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
sunish vk30637eb2016-02-16 15:19:32 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ospf.controller;
17
18import org.onlab.packet.Ip4Address;
19
20import java.util.List;
21
22/**
23 * Representation of an OSPF area. OSPF areas are collections of network segments.
24 * The configuration of OSPF area consists of assigning an area id to each network segment.
25 * Each area has its own link state database.
26 */
27public interface OspfArea {
28
29 /**
30 * Gets the router id associated with the area.
31 *
32 * @return router id
33 */
34 Ip4Address routerId();
35
36 /**
37 * Sets the router id for this area.
38 *
39 * @param routerId router's ip address
40 */
41 void setRouterId(Ip4Address routerId);
42
43 /**
44 * Gets the area id.
45 *
46 * @return area id
47 */
48 Ip4Address areaId();
49
50 /**
51 * Sets the area id.
52 *
53 * @param areaId area id as an IPv4 address
54 */
55 void setAreaId(Ip4Address areaId);
56
57 /**
58 * Gets the LSDB instance for this area.
59 *
60 * @return LSDB instance for this area
61 */
sunishvkf7c56552016-07-18 16:02:39 +053062 OspfLsdb database();
sunish vk30637eb2016-02-16 15:19:32 +053063
64 /**
65 * Checks whether an instance of the given LSA exists in the database.
66 *
67 * @param lookupLsa LSA instance to lookup
68 * @return LSA wrapper instance which contains the LSA
69 */
sunishvkf7c56552016-07-18 16:02:39 +053070 LsaWrapper lsaLookup(OspfLsa lookupLsa);
sunish vk30637eb2016-02-16 15:19:32 +053071
72 /**
73 * Initializes link state database, this acts as a place holder for storing the received LSA.
74 */
sunishvkf7c56552016-07-18 16:02:39 +053075 void initializeDb();
sunish vk30637eb2016-02-16 15:19:32 +053076
77 /**
78 * Sets the options value.
79 *
80 * @param options integer value
81 */
82 void setOptions(int options);
83
84 /**
sunish vk30637eb2016-02-16 15:19:32 +053085 * Gets external routing capability.
86 * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
87 *
88 * @return true if external routing capable, else false
89 */
90 boolean isExternalRoutingCapability();
91
92 /**
93 * Sets external routing capability.
94 * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
95 *
96 * @param externalRoutingCapability true if external routing capable, else false
97 */
98 void setExternalRoutingCapability(boolean externalRoutingCapability);
99
100 /**
sunish vk30637eb2016-02-16 15:19:32 +0530101 * Gets if the router is opaque enabled or not.
102 * This indicates whether the router accepts opaque LSA.
103 *
104 * @return true if opaque enabled else false
105 */
106 boolean isOpaqueEnabled();
107
108 /**
109 * Gets the list of interfaces attached to this area.
110 *
111 * @return list of interfaces
112 */
sunishvkf7c56552016-07-18 16:02:39 +0530113 List<OspfInterface> ospfInterfaceList();
sunish vk30637eb2016-02-16 15:19:32 +0530114
115 /**
116 * Sets the list of interfaces attached to this area.
117 *
118 * @param interfacesLst list of interface instances
119 */
sunishvkf7c56552016-07-18 16:02:39 +0530120 void setOspfInterfaceList(List<OspfInterface> interfacesLst);
sunish vk30637eb2016-02-16 15:19:32 +0530121
122 /**
123 * Gets the options value, which indicates the supported optional capabilities.
124 *
125 * @return options value
126 */
127 int options();
128
129 /**
130 * Gets the opaque enabled options value, which indicates support of opaque capabilities.
131 *
132 * @return opaque enabled options value
133 */
134 int opaqueEnabledOptions();
135
136 /**
137 * Sets opaque enabled to true or false, which indicates whether the router accepts opaque LSA.
138 *
139 * @param isOpaqueEnable true if opaque enabled else false
140 */
141 void setIsOpaqueEnabled(boolean isOpaqueEnable);
142
143 /**
144 * Refreshes areas, by sending a router LSA and network LSA (in case of DR).
145 * with a new sequence number.
146 *
147 * @param ospfInterface interface instance
148 * @throws Exception might throw exception
149 */
150 void refreshArea(OspfInterface ospfInterface) throws Exception;
151
152 /**
153 * Verifies no neighbor is in exchange process.
154 *
155 * @return boolean indicating that there is no Neighbor in Database Exchange
156 */
157 boolean noNeighborInLsaExchangeProcess();
158
159 /**
160 * Checks whether an instance of the given LSA exists in the database belonging to this area.
161 * If so return true else false.
162 *
163 * @param lsa1 LSA instance to compare
164 * @param lsa2 LSA instance to compare
165 * @return "same" if both instances are same, "latest" if lsa1 is latest, or "old" if lsa1 is old
166 */
167 String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2);
168
169 /**
170 * Whenever we receive an LSA with max age - we put it in the max age bin.
171 * This is later used to flush LSAs out of the routing domain.
172 *
173 * @param key key to add it to LSDB
174 * @param wrapper LSA wrapper instance
175 */
176 void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
177
178 /**
179 * Whenever an LSA is being flushed out or reaches max age, it must be stopped from aging.
180 * This achieved by removing it from bin.
181 *
182 * @param lsaWrapper the LSA wrapper instance to delete
183 */
184 void removeLsaFromBin(LsaWrapper lsaWrapper);
185
186 /**
187 * Adds the received LSA to LSDB, this method creates an LSA wrapper for the LSA.
188 * Also adds it to the LSDB of the area. This method is specifically called for
189 * the self originated LSAs.
190 *
191 * @param ospfLsa LSA instance
192 * @param isSelfOriginated true if the LSA is self originated else false
193 * @param ospfInterface interface instance
194 * @throws Exception might throws exception
195 */
196 void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface)
197 throws Exception;
198
199 /**
200 * Adds the received LSA to LSDB,this method creates an LSA wrapper for the LSA.
201 * Adds it to the LSDB of the area.
202 *
203 * @param ospfLsa LSA instance
204 * @param ospfInterface interface instance
205 * @throws Exception might throws exception
206 */
207 void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws Exception;
208
209 /**
210 * Sets router sequence number for router LSA.
211 *
212 * @param newSequenceNumber sequence number
213 */
214 void setDbRouterSequenceNumber(long newSequenceNumber);
215
216 /**
217 * Gets LSA header of all types of LSAs present in the link state database.
218 *
219 * @param excludeMaxAgeLsa need to include(true) or exclude(false) max age LSA
220 * @param isOpaqueCapable need to include(true) or exclude(false) type 10 Opaque LSA
221 * @return list of LSA header in the LSDB
222 */
223 List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
224
225 /**
226 * Gets the LSA wrapper from link state database based on the parameters passed.
227 *
228 * @param lsType type of LSA to form the key
229 * @param linkStateID link state id to form the key
230 * @param advertisingRouter advertising router to form the key
231 * @return LSA wrapper instance which contains the LSA
232 * @throws Exception might throws exception
233 */
234 LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception;
235
236}