blob: 84aa76a7dc49662770804d29edf83d365343ae27 [file] [log] [blame]
sunish vk30637eb2016-02-16 15:19:32 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
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 */
62 public OspfLsdb database();
63
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 */
70 public LsaWrapper lsaLookup(OspfLsa lookupLsa);
71
72 /**
73 * Initializes link state database, this acts as a place holder for storing the received LSA.
74 */
75 public void initializeDb();
76
77 /**
78 * Sets the stub cost.
79 *
80 * @param stubCost stub cost
81 */
82 void setStubCost(int stubCost);
83
84 /**
85 * Sets the options value.
86 *
87 * @param options integer value
88 */
89 void setOptions(int options);
90
91 /**
92 * Gets area address ranges to which this area belongs to.
93 *
94 * @return list of area address ranges
95 */
96 List<OspfAreaAddressRange> addressRanges();
97
98 /**
99 * Sets the area address ranges to which this area belongs to.
100 *
101 * @param addrRangeList list of area address ranges
102 */
103 void setAddressRanges(List<OspfAreaAddressRange> addrRangeList);
104
105 /**
106 * Gets whether the area is transit capable or not.
107 * This indicates whether the area can carry data traffic that neither originates
108 * nor terminates in the area itself.
109 *
110 * @return true if transit capable, else false
111 */
112 boolean isTransitCapability();
113
114 /**
115 * Sets whether the area is transit capable or not.
116 * This indicates whether the area can carry data traffic that neither originates
117 * nor terminates in the area itself.
118 *
119 * @param transitCapability true if transit capable, else false
120 */
121 void setTransitCapability(boolean transitCapability);
122
123 /**
124 * Gets external routing capability.
125 * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
126 *
127 * @return true if external routing capable, else false
128 */
129 boolean isExternalRoutingCapability();
130
131 /**
132 * Sets external routing capability.
133 * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
134 *
135 * @param externalRoutingCapability true if external routing capable, else false
136 */
137 void setExternalRoutingCapability(boolean externalRoutingCapability);
138
139 /**
140 * Gets the stub cost, which indicates if the area has been configured as a stub area.
141 *
142 * @return stub cost
143 */
144 int stubCost();
145
146 /**
147 * Gets if the router is opaque enabled or not.
148 * This indicates whether the router accepts opaque LSA.
149 *
150 * @return true if opaque enabled else false
151 */
152 boolean isOpaqueEnabled();
153
154 /**
155 * Gets the list of interfaces attached to this area.
156 *
157 * @return list of interfaces
158 */
159 List<OspfInterface> getInterfacesLst();
160
161 /**
162 * Sets the list of interfaces attached to this area.
163 *
164 * @param interfacesLst list of interface instances
165 */
166 void setInterfacesLst(List<OspfInterface> interfacesLst);
167
168 /**
169 * Gets the options value, which indicates the supported optional capabilities.
170 *
171 * @return options value
172 */
173 int options();
174
175 /**
176 * Gets the opaque enabled options value, which indicates support of opaque capabilities.
177 *
178 * @return opaque enabled options value
179 */
180 int opaqueEnabledOptions();
181
182 /**
183 * Sets opaque enabled to true or false, which indicates whether the router accepts opaque LSA.
184 *
185 * @param isOpaqueEnable true if opaque enabled else false
186 */
187 void setIsOpaqueEnabled(boolean isOpaqueEnable);
188
189 /**
190 * Refreshes areas, by sending a router LSA and network LSA (in case of DR).
191 * with a new sequence number.
192 *
193 * @param ospfInterface interface instance
194 * @throws Exception might throw exception
195 */
196 void refreshArea(OspfInterface ospfInterface) throws Exception;
197
198 /**
199 * Verifies no neighbor is in exchange process.
200 *
201 * @return boolean indicating that there is no Neighbor in Database Exchange
202 */
203 boolean noNeighborInLsaExchangeProcess();
204
205 /**
206 * Checks whether an instance of the given LSA exists in the database belonging to this area.
207 * If so return true else false.
208 *
209 * @param lsa1 LSA instance to compare
210 * @param lsa2 LSA instance to compare
211 * @return "same" if both instances are same, "latest" if lsa1 is latest, or "old" if lsa1 is old
212 */
213 String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2);
214
215 /**
216 * Whenever we receive an LSA with max age - we put it in the max age bin.
217 * This is later used to flush LSAs out of the routing domain.
218 *
219 * @param key key to add it to LSDB
220 * @param wrapper LSA wrapper instance
221 */
222 void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
223
224 /**
225 * Whenever an LSA is being flushed out or reaches max age, it must be stopped from aging.
226 * This achieved by removing it from bin.
227 *
228 * @param lsaWrapper the LSA wrapper instance to delete
229 */
230 void removeLsaFromBin(LsaWrapper lsaWrapper);
231
232 /**
233 * Adds the received LSA to LSDB, this method creates an LSA wrapper for the LSA.
234 * Also adds it to the LSDB of the area. This method is specifically called for
235 * the self originated LSAs.
236 *
237 * @param ospfLsa LSA instance
238 * @param isSelfOriginated true if the LSA is self originated else false
239 * @param ospfInterface interface instance
240 * @throws Exception might throws exception
241 */
242 void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface)
243 throws Exception;
244
245 /**
246 * Adds the received LSA to LSDB,this method creates an LSA wrapper for the LSA.
247 * Adds it to the LSDB of the area.
248 *
249 * @param ospfLsa LSA instance
250 * @param ospfInterface interface instance
251 * @throws Exception might throws exception
252 */
253 void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws Exception;
254
255 /**
256 * Sets router sequence number for router LSA.
257 *
258 * @param newSequenceNumber sequence number
259 */
260 void setDbRouterSequenceNumber(long newSequenceNumber);
261
262 /**
263 * Gets LSA header of all types of LSAs present in the link state database.
264 *
265 * @param excludeMaxAgeLsa need to include(true) or exclude(false) max age LSA
266 * @param isOpaqueCapable need to include(true) or exclude(false) type 10 Opaque LSA
267 * @return list of LSA header in the LSDB
268 */
269 List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
270
271 /**
272 * Gets the LSA wrapper from link state database based on the parameters passed.
273 *
274 * @param lsType type of LSA to form the key
275 * @param linkStateID link state id to form the key
276 * @param advertisingRouter advertising router to form the key
277 * @return LSA wrapper instance which contains the LSA
278 * @throws Exception might throws exception
279 */
280 LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter) throws Exception;
281
282}