blob: a66160d910936fdac7cf60156b3a320e532d1230 [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
sunish vk30637eb2016-02-16 15:19:32 +0530148 */
Ray Milkey019fba42018-01-31 14:07:47 -0800149 void refreshArea(OspfInterface ospfInterface);
sunish vk30637eb2016-02-16 15:19:32 +0530150
151 /**
152 * Verifies no neighbor is in exchange process.
153 *
154 * @return boolean indicating that there is no Neighbor in Database Exchange
155 */
156 boolean noNeighborInLsaExchangeProcess();
157
158 /**
159 * Checks whether an instance of the given LSA exists in the database belonging to this area.
160 * If so return true else false.
161 *
162 * @param lsa1 LSA instance to compare
163 * @param lsa2 LSA instance to compare
164 * @return "same" if both instances are same, "latest" if lsa1 is latest, or "old" if lsa1 is old
165 */
166 String isNewerOrSameLsa(OspfLsa lsa1, OspfLsa lsa2);
167
168 /**
169 * Whenever we receive an LSA with max age - we put it in the max age bin.
170 * This is later used to flush LSAs out of the routing domain.
171 *
172 * @param key key to add it to LSDB
173 * @param wrapper LSA wrapper instance
174 */
175 void addLsaToMaxAgeBin(String key, LsaWrapper wrapper);
176
177 /**
178 * Whenever an LSA is being flushed out or reaches max age, it must be stopped from aging.
179 * This achieved by removing it from bin.
180 *
181 * @param lsaWrapper the LSA wrapper instance to delete
182 */
183 void removeLsaFromBin(LsaWrapper lsaWrapper);
184
185 /**
186 * Adds the received LSA to LSDB, this method creates an LSA wrapper for the LSA.
187 * Also adds it to the LSDB of the area. This method is specifically called for
188 * the self originated LSAs.
189 *
190 * @param ospfLsa LSA instance
191 * @param isSelfOriginated true if the LSA is self originated else false
192 * @param ospfInterface interface instance
sunish vk30637eb2016-02-16 15:19:32 +0530193 */
Ray Milkey019fba42018-01-31 14:07:47 -0800194 void addLsa(OspfLsa ospfLsa, boolean isSelfOriginated, OspfInterface ospfInterface);
sunish vk30637eb2016-02-16 15:19:32 +0530195
196 /**
197 * Adds the received LSA to LSDB,this method creates an LSA wrapper for the LSA.
198 * Adds it to the LSDB of the area.
199 *
200 * @param ospfLsa LSA instance
201 * @param ospfInterface interface instance
sunish vk30637eb2016-02-16 15:19:32 +0530202 */
Ray Milkey986a47a2018-01-25 11:38:51 -0800203 void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface);
sunish vk30637eb2016-02-16 15:19:32 +0530204
205 /**
206 * Sets router sequence number for router LSA.
207 *
208 * @param newSequenceNumber sequence number
209 */
210 void setDbRouterSequenceNumber(long newSequenceNumber);
211
212 /**
213 * Gets LSA header of all types of LSAs present in the link state database.
214 *
215 * @param excludeMaxAgeLsa need to include(true) or exclude(false) max age LSA
216 * @param isOpaqueCapable need to include(true) or exclude(false) type 10 Opaque LSA
217 * @return list of LSA header in the LSDB
218 */
219 List getLsaHeaders(boolean excludeMaxAgeLsa, boolean isOpaqueCapable);
220
221 /**
222 * Gets the LSA wrapper from link state database based on the parameters passed.
223 *
224 * @param lsType type of LSA to form the key
225 * @param linkStateID link state id to form the key
226 * @param advertisingRouter advertising router to form the key
227 * @return LSA wrapper instance which contains the LSA
sunish vk30637eb2016-02-16 15:19:32 +0530228 */
Ray Milkey019fba42018-01-31 14:07:47 -0800229 LsaWrapper getLsa(int lsType, String linkStateID, String advertisingRouter);
sunish vk30637eb2016-02-16 15:19:32 +0530230
231}