blob: f4e825580c79d6bfaed26ecd3e3d72a419f01658 [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;
Ray Milkey019fba42018-01-31 14:07:47 -080019import org.onosproject.ospf.exceptions.OspfParseException;
sunish vk30637eb2016-02-16 15:19:32 +053020
21import java.util.List;
22
23/**
24 * Representation of an OSPF area. OSPF areas are collections of network segments.
25 * The configuration of OSPF area consists of assigning an area id to each network segment.
26 * Each area has its own link state database.
27 */
28public interface OspfArea {
29
30 /**
31 * Gets the router id associated with the area.
32 *
33 * @return router id
34 */
35 Ip4Address routerId();
36
37 /**
38 * Sets the router id for this area.
39 *
40 * @param routerId router's ip address
41 */
42 void setRouterId(Ip4Address routerId);
43
44 /**
45 * Gets the area id.
46 *
47 * @return area id
48 */
49 Ip4Address areaId();
50
51 /**
52 * Sets the area id.
53 *
54 * @param areaId area id as an IPv4 address
55 */
56 void setAreaId(Ip4Address areaId);
57
58 /**
59 * Gets the LSDB instance for this area.
60 *
61 * @return LSDB instance for this area
62 */
sunishvkf7c56552016-07-18 16:02:39 +053063 OspfLsdb database();
sunish vk30637eb2016-02-16 15:19:32 +053064
65 /**
66 * Checks whether an instance of the given LSA exists in the database.
67 *
68 * @param lookupLsa LSA instance to lookup
69 * @return LSA wrapper instance which contains the LSA
70 */
sunishvkf7c56552016-07-18 16:02:39 +053071 LsaWrapper lsaLookup(OspfLsa lookupLsa);
sunish vk30637eb2016-02-16 15:19:32 +053072
73 /**
74 * Initializes link state database, this acts as a place holder for storing the received LSA.
75 */
sunishvkf7c56552016-07-18 16:02:39 +053076 void initializeDb();
sunish vk30637eb2016-02-16 15:19:32 +053077
78 /**
79 * Sets the options value.
80 *
81 * @param options integer value
82 */
83 void setOptions(int options);
84
85 /**
sunish vk30637eb2016-02-16 15:19:32 +053086 * Gets external routing capability.
87 * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
88 *
89 * @return true if external routing capable, else false
90 */
91 boolean isExternalRoutingCapability();
92
93 /**
94 * Sets external routing capability.
95 * This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
96 *
97 * @param externalRoutingCapability true if external routing capable, else false
98 */
99 void setExternalRoutingCapability(boolean externalRoutingCapability);
100
101 /**
sunish vk30637eb2016-02-16 15:19:32 +0530102 * Gets if the router is opaque enabled or not.
103 * This indicates whether the router accepts opaque LSA.
104 *
105 * @return true if opaque enabled else false
106 */
107 boolean isOpaqueEnabled();
108
109 /**
110 * Gets the list of interfaces attached to this area.
111 *
112 * @return list of interfaces
113 */
sunishvkf7c56552016-07-18 16:02:39 +0530114 List<OspfInterface> ospfInterfaceList();
sunish vk30637eb2016-02-16 15:19:32 +0530115
116 /**
117 * Sets the list of interfaces attached to this area.
118 *
119 * @param interfacesLst list of interface instances
120 */
sunishvkf7c56552016-07-18 16:02:39 +0530121 void setOspfInterfaceList(List<OspfInterface> interfacesLst);
sunish vk30637eb2016-02-16 15:19:32 +0530122
123 /**
124 * Gets the options value, which indicates the supported optional capabilities.
125 *
126 * @return options value
127 */
128 int options();
129
130 /**
131 * Gets the opaque enabled options value, which indicates support of opaque capabilities.
132 *
133 * @return opaque enabled options value
134 */
135 int opaqueEnabledOptions();
136
137 /**
138 * Sets opaque enabled to true or false, which indicates whether the router accepts opaque LSA.
139 *
140 * @param isOpaqueEnable true if opaque enabled else false
141 */
142 void setIsOpaqueEnabled(boolean isOpaqueEnable);
143
144 /**
145 * Refreshes areas, by sending a router LSA and network LSA (in case of DR).
146 * with a new sequence number.
147 *
148 * @param ospfInterface interface instance
sunish vk30637eb2016-02-16 15:19:32 +0530149 */
Ray Milkey019fba42018-01-31 14:07:47 -0800150 void refreshArea(OspfInterface ospfInterface);
sunish vk30637eb2016-02-16 15:19:32 +0530151
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
sunish vk30637eb2016-02-16 15:19:32 +0530194 */
Ray Milkey019fba42018-01-31 14:07:47 -0800195 void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface);
sunish vk30637eb2016-02-16 15:19:32 +0530196
197 /**
198 * Adds the received LSA to LSDB,this method creates an LSA wrapper for the LSA.
199 * Adds it to the LSDB of the area.
200 *
201 * @param ospfLsa LSA instance
202 * @param ospfInterface interface instance
Ray Milkey019fba42018-01-31 14:07:47 -0800203 * @throws OspfParseException might throws exception
sunish vk30637eb2016-02-16 15:19:32 +0530204 */
Ray Milkey019fba42018-01-31 14:07:47 -0800205 void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws OspfParseException;
sunish vk30637eb2016-02-16 15:19:32 +0530206
207 /**
208 * Sets router sequence number for router LSA.
209 *
210 * @param newSequenceNumber sequence number
211 */
212 void setDbRouterSequenceNumber(long newSequenceNumber);
213
214 /**
215 * Gets LSA header of all types of LSAs present in the link state database.
216 *
217 * @param excludeMaxAgeLsa need to include(true) or exclude(false) max age LSA
218 * @param isOpaqueCapable need to include(true) or exclude(false) type 10 Opaque LSA
219 * @return list of LSA header in the LSDB
220 */
221 List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
222
223 /**
224 * Gets the LSA wrapper from link state database based on the parameters passed.
225 *
226 * @param lsType type of LSA to form the key
227 * @param linkStateID link state id to form the key
228 * @param advertisingRouter advertising router to form the key
229 * @return LSA wrapper instance which contains the LSA
sunish vk30637eb2016-02-16 15:19:32 +0530230 */
Ray Milkey019fba42018-01-31 14:07:47 -0800231 LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter);
sunish vk30637eb2016-02-16 15:19:32 +0530232
233}