OSPF protocol manual merge from 1.6, due to cherry pick merge conflict
Change-Id: I93653e745468722ce95533537a79e897b4292f5d
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
index 63f4824..4983d30 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/LsdbAge.java
@@ -98,4 +98,11 @@
* @param lsaWrapper wrapper instance
*/
public void removeLsaFromBin(LsaWrapper lsaWrapper);
+
+ /**
+ * Gets the age counter roll over.
+ *
+ * @return the age counter roll over
+ */
+ public int getAgeCounterRollOver();
}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
index ccea5ac..3f490e7 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfAgent.java
@@ -38,17 +38,18 @@
void removeConnectedRouter(OspfRouter ospfRouter);
/**
- * Notifies that got a packet of link from network and need do processing.
+ * Notifies that got a packet of link from network and need to add the link.
*
- * @param ospfRouter router instance
- * @param ospfLinkTed link ted instance
+ * @param ospfRouter router instance
+ * @param ospfLinkTed link TED instance
*/
void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
/**
- * Notifies that got a packet of link from network and need do processing.
+ * Notifies that got a packet of link from network and need do delete the link.
*
* @param ospfRouter router instance
+ * @param ospfLinkTed link TED instance
*/
- void deleteLink(OspfRouter ospfRouter);
+ void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
index 9699814..4623ef5 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
@@ -59,7 +59,7 @@
*
* @return LSDB instance for this area
*/
- public OspfLsdb database();
+ OspfLsdb database();
/**
* Checks whether an instance of the given LSA exists in the database.
@@ -67,19 +67,12 @@
* @param lookupLsa LSA instance to lookup
* @return LSA wrapper instance which contains the LSA
*/
- public LsaWrapper lsaLookup(OspfLsa lookupLsa);
+ LsaWrapper lsaLookup(OspfLsa lookupLsa);
/**
* Initializes link state database, this acts as a place holder for storing the received LSA.
*/
- public void initializeDb();
-
- /**
- * Sets the stub cost.
- *
- * @param stubCost stub cost
- */
- void setStubCost(int stubCost);
+ void initializeDb();
/**
* Sets the options value.
@@ -89,38 +82,6 @@
void setOptions(int options);
/**
- * Gets area address ranges to which this area belongs to.
- *
- * @return list of area address ranges
- */
- List<OspfAreaAddressRange> addressRanges();
-
- /**
- * Sets the area address ranges to which this area belongs to.
- *
- * @param addrRangeList list of area address ranges
- */
- void setAddressRanges(List<OspfAreaAddressRange> addrRangeList);
-
- /**
- * Gets whether the area is transit capable or not.
- * This indicates whether the area can carry data traffic that neither originates
- * nor terminates in the area itself.
- *
- * @return true if transit capable, else false
- */
- boolean isTransitCapability();
-
- /**
- * Sets whether the area is transit capable or not.
- * This indicates whether the area can carry data traffic that neither originates
- * nor terminates in the area itself.
- *
- * @param transitCapability true if transit capable, else false
- */
- void setTransitCapability(boolean transitCapability);
-
- /**
* Gets external routing capability.
* This indicates Whether AS-external-LSAs will be flooded into/throughout the area.
*
@@ -137,13 +98,6 @@
void setExternalRoutingCapability(boolean externalRoutingCapability);
/**
- * Gets the stub cost, which indicates if the area has been configured as a stub area.
- *
- * @return stub cost
- */
- int stubCost();
-
- /**
* Gets if the router is opaque enabled or not.
* This indicates whether the router accepts opaque LSA.
*
@@ -156,14 +110,14 @@
*
* @return list of interfaces
*/
- List<OspfInterface> getInterfacesLst();
+ List<OspfInterface> ospfInterfaceList();
/**
* Sets the list of interfaces attached to this area.
*
* @param interfacesLst list of interface instances
*/
- void setInterfacesLst(List<OspfInterface> interfacesLst);
+ void setOspfInterfaceList(List<OspfInterface> interfacesLst);
/**
* Gets the options value, which indicates the supported optional capabilities.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
index 522bc9e..4271177 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfController.java
@@ -15,6 +15,8 @@
*/
package org.onosproject.ospf.controller;
+import com.fasterxml.jackson.databind.JsonNode;
+
import java.util.List;
import java.util.Set;
@@ -55,9 +57,9 @@
/**
* Updates configuration of processes.
*
- * @param processes process info to update
+ * @param processesNode process info to update
*/
- public void updateConfig(List<OspfProcess> processes);
+ void updateConfig(JsonNode processesNode);
/**
* Deletes configuration parameters.
@@ -65,7 +67,7 @@
* @param processes list of process instance
* @param attribute attribute to delete
*/
- public void deleteConfig(List<OspfProcess> processes, String attribute);
+ void deleteConfig(List<OspfProcess> processes, String attribute);
/**
* Gets the list of listeners registered for router events.
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
index 9647a00..8fbb33f 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfInterface.java
@@ -15,9 +15,10 @@
*/
package org.onosproject.ospf.controller;
+import org.jboss.netty.channel.ChannelHandlerContext;
import org.onlab.packet.Ip4Address;
-import java.util.HashMap;
+import java.util.Map;
/**
* Represents an OSPF Interface.
@@ -25,6 +26,34 @@
public interface OspfInterface {
/**
+ * Returns interface index.
+ *
+ * @return interface index
+ */
+ public int interfaceIndex();
+
+ /**
+ * Sets interface index.
+ *
+ * @param interfaceIndex interface index
+ */
+ public void setInterfaceIndex(int interfaceIndex);
+
+ /**
+ * Returns OSPF area instance.
+ *
+ * @return OSPF area instance
+ */
+ public OspfArea ospfArea();
+
+ /**
+ * Sets OSPF area instance.
+ *
+ * @param ospfArea OSPF area instance
+ */
+ public void setOspfArea(OspfArea ospfArea);
+
+ /**
* Gets network mask of the interface.
*
* @return network mask
@@ -32,29 +61,6 @@
Ip4Address ipNetworkMask();
/**
- * Sets area id, to which the interface belongs.
- *
- * @param areaId area identifier
- */
- void setAreaId(int areaId);
-
- /**
- * Sets the authentication key.
- * Interface uses this to authenticate while establishing communication with other routers.
- *
- * @param authKey represents authentication key
- */
- void setAuthKey(String authKey);
-
- /**
- * Sets the authentication type,
- * Interface uses this to authenticate while establishing communication with other routers.
- *
- * @param authType authType represents authentication type
- */
- void setAuthType(String authType);
-
- /**
* Sets the value of BDR.
* The BDR is calculated during adjacency formation.
*
@@ -87,13 +93,6 @@
void setRouterDeadIntervalTime(int routerDeadIntervalTime);
/**
- * Sets the interface cost which is the cost of sending a data packet onto the network.
- *
- * @param interfaceCost an integer represents interface cost
- */
- void setInterfaceCost(int interfaceCost);
-
- /**
* Sets interface type.
* This indicates whether the interface is on point to point mode or broadcast mode.
*
@@ -116,22 +115,6 @@
void setIpNetworkMask(Ip4Address ipNetworkMask);
/**
- * Sets the polling interval.
- * Polling interval indicates the interval until when the Hello Packets are
- * sent to a dead neighbor.
- *
- * @param pollInterval an integer represents poll interval
- */
- void setPollInterval(int pollInterval);
-
- /**
- * Sets transmission delay.
- *
- * @param transmitDelay an integer represents delay
- */
- void setTransmitDelay(int transmitDelay);
-
- /**
* Sets retransmit interval which indicates the number of seconds between LSA retransmissions.
*
* @param reTransmitInterval an integer represents interval
@@ -153,13 +136,6 @@
void setRouterPriority(int routerPriority);
/**
- * Gets the area id to which router belongs.
- *
- * @return areaId an integer value
- */
- int areaId();
-
- /**
* Gets the IP address.
*
* @return an string represents IP address
@@ -181,32 +157,11 @@
int mtu();
/**
- * Gets interface cost.
- *
- * @return an integer representing interface cost
- */
- int interfaceCost();
-
- /**
* Gets the list of neighbors associated with the interface.
*
* @return listOfNeighbors as key value pair
*/
- HashMap<String, OspfNbr> listOfNeighbors();
-
- /**
- * Gets poll interval.
- *
- * @return pollInterval an integer representing poll interval
- */
- int pollInterval();
-
- /**
- * Gets transmission delay.
- *
- * @return transmitDelay an integer representing delay
- */
- int transmitDelay();
+ Map<String, OspfNbr> listOfNeighbors();
/**
* Gets the IP address of the BDR.
@@ -223,20 +178,6 @@
Ip4Address dr();
/**
- * Gets authentication key.
- *
- * @return authKey represents authentication key
- */
- String authKey();
-
- /**
- * Gets authentication type.
- *
- * @return authType represents authentication type
- */
- String authType();
-
- /**
* Gets hello interval time in seconds, this defines how often we send the hello packet.
*
* @return hello interval time in seconds
@@ -294,4 +235,54 @@
* @param lsaKey key used to store lsa in map
*/
void removeLsaFromNeighborMap(String lsaKey);
+
+ /**
+ * When an OSPF message received it is handed over to this method.
+ * Based on the type of the OSPF message received it will be handed over
+ * to corresponding message handler methods.
+ *
+ * @param ospfMessage received OSPF message
+ * @param ctx channel handler context instance.
+ * @throws Exception might throws exception
+ */
+ void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception;
+
+ /**
+ * Represents an interface is up and connected.
+ *
+ * @throws Exception might throws exception
+ */
+ void interfaceUp() throws Exception;
+
+ /**
+ * Starts the timer which waits for configured seconds and sends Delayed Ack Packet.
+ */
+ void startDelayedAckTimer();
+
+ /**
+ * Stops the delayed acknowledge timer.
+ */
+ void stopDelayedAckTimer();
+
+ /**
+ * Starts the hello timer which sends hello packet every configured seconds.
+ */
+ void startHelloTimer();
+
+ /**
+ * Stops the hello timer.
+ */
+ void stopHelloTimer();
+
+ /**
+ * Gets called when an interface is down.
+ * All interface variables are reset, and interface timers disabled.
+ * Also all neighbor connections associated with the interface are destroyed.
+ */
+ void interfaceDown();
+
+ /**
+ * Removes all the neighbors.
+ */
+ void removeNeighbors();
}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
index b9b887c..2679384 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfLinkListener.java
@@ -23,7 +23,7 @@
/**
* Notifies that we got a link from network.
*
- * @param ospfRouter router instance
+ * @param ospfRouter router instance
* @param ospfLinkTed link TED information of router
*/
void addLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
@@ -31,7 +31,8 @@
/**
* Notifies that a link got removed from network.
*
- * @param ospfRouter router instance
+ * @param ospfRouter router instance
+ * @param ospfLinkTed link TED information of router
*/
- void deleteLink(OspfRouter ospfRouter);
+ void deleteLink(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed);
}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
new file mode 100644
index 0000000..bdd3c9d
--- /dev/null
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfMessage.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.controller;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onlab.packet.Ip4Address;
+
+/**
+ * Representation of an OSPF message.
+ */
+public interface OspfMessage {
+
+ /**
+ * Returns the interface index on which the message received.
+ *
+ * @return interface index on which the message received
+ */
+ int interfaceIndex();
+
+ /**
+ * Sets the interface index on which the message received.
+ *
+ * @param interfaceIndex interface index on which the message received
+ */
+ void setInterfaceIndex(int interfaceIndex);
+
+ /**
+ * Returns the type of OSPF message.
+ *
+ * @return OSPF message type
+ */
+ public OspfPacketType ospfMessageType();
+
+ /**
+ * Reads from ChannelBuffer and initializes the type of LSA.
+ *
+ * @param channelBuffer channel buffer instance
+ * @throws Exception might throws exception while parsing buffer
+ */
+ void readFrom(ChannelBuffer channelBuffer) throws Exception;
+
+ /**
+ * Returns OSPFMessage as byte array.
+ *
+ * @return OSPF message as bytes
+ */
+ byte[] asBytes();
+
+ /**
+ * Sets the source IP address.
+ *
+ * @param sourceIp IP address
+ */
+ public void setSourceIp(Ip4Address sourceIp);
+
+ /**
+ * Gets the destination IP address.
+ *
+ * @return destination IP address
+ */
+ public Ip4Address destinationIp();
+
+ /**
+ * Sets destination IP.
+ *
+ * @param destinationIp destination IP address
+ */
+ public void setDestinationIp(Ip4Address destinationIp);
+}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
index adc12f1..ff67852 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfNbr.java
@@ -189,4 +189,36 @@
* @return neighbor's state
*/
OspfNeighborState getState();
+
+ /**
+ * Starts the inactivity timer.
+ */
+ void startInactivityTimeCheck();
+
+ /**
+ * Stops the inactivity timer.
+ */
+ void stopInactivityTimeCheck();
+
+ /**
+ * Sets router dead interval.
+ *
+ * @param routerDeadInterval router dead interval
+ */
+ void setRouterDeadInterval(int routerDeadInterval);
+
+ /**
+ * Stops the flooding timer.
+ */
+ void stopFloodingTimer();
+
+ /**
+ * Stops the Dd Retransmission executor task.
+ */
+ void stopRxMtDdTimer();
+
+ /**
+ * Stops Ls request retransmission executor task.
+ */
+ void stopRxMtLsrTimer();
}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java
new file mode 100644
index 0000000..cce21ae
--- /dev/null
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfPacketType.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.ospf.controller;
+
+/**
+ * Representation of different OSPF packet types.
+ */
+public enum OspfPacketType {
+
+ /**
+ * OSPF hello packet.
+ */
+ HELLO(1),
+ /**
+ * OSPF device description packet.
+ */
+ DD(2),
+ /**
+ * OSPF link state request packet.
+ */
+ LSREQUEST(3),
+ /**
+ * OSPF link state update packet.
+ */
+ LSUPDATE(4),
+ /**
+ * OSPF link state acknowledge packet.
+ */
+ LSAACK(5);
+
+ private int value;
+
+ /**
+ * Creates instance of OSPF packet types.
+ *
+ * @param value OSPF packet types
+ */
+ OspfPacketType(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value.
+ *
+ * @return value
+ */
+ public int value() {
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterId.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterId.java
index ba512a5..9590ee2 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterId.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfRouterId.java
@@ -29,7 +29,7 @@
*/
public class OspfRouterId {
- private static final String SCHEME = "ospf";
+ private static final String SCHEME = "l3";
private static final long UNKNOWN = 0;
private final IpAddress ipAddress;
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
index 012457b..7514d5e 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/TopologyForDeviceAndLink.java
@@ -50,7 +50,7 @@
/**
* Sets link information.
*
- * @param key key used to store in map
+ * @param key key used to store in map
* @param linkInformationMap link information instance
*/
void setLinkInformationMap(String key, LinkInformation linkInformationMap);
@@ -79,7 +79,7 @@
void removeDeviceInformationMap(String key);
/**
- * Removes links from linkInformationMap.
+ * Removes links from link information map.
*
* @param routerId router's IP address
*/
@@ -109,4 +109,56 @@
* @param ospfArea area instance
*/
void updateLinkInformation(OspfLsa ospfLsa, OspfArea ospfArea);
+
+ /**
+ * Gets device information as map.
+ *
+ * @return deviceInformationMap to delete from core
+ */
+ Map<String, DeviceInformation> deviceInformationMapToDelete();
+
+ /**
+ * Sets device information as map.
+ *
+ * @param key key to store in device info map
+ * @param deviceInformationMapToDelete device information instance
+ */
+ void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete);
+
+ /**
+ * Removes device information from deviceInformationMapToDelete.
+ *
+ * @param key key to remove device information
+ */
+ void removeDeviceInformationMapFromDeleteMap(String key);
+
+ /**
+ * Gets device information as map for Point-To-Point.
+ *
+ * @return deviceInformationMap
+ */
+ Map<String, DeviceInformation> deviceInformationMapForPointToPoint();
+
+ /**
+ * Sets device information as map for Point-To-Point.
+ *
+ * @param key key to store in device info
+ * @param deviceInformationMap device information instance
+ */
+ void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap);
+
+ /**
+ * Gets link information as map for Point-To-Point.
+ *
+ * @return linkInformationMap
+ */
+ Map<String, LinkInformation> linkInformationMapForPointToPoint();
+
+ /**
+ * Sets link information as map for Point-To-Point.
+ *
+ * @param key key to store link info
+ * @param linkInformationMap link information instance
+ */
+ void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap);
}
\ No newline at end of file