ONOS-4107: Changes to provider
Change-Id: Ice1a5d49a66fc4f8e5033b47c0ee90601d55589e
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisController.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisController.java
index fc10019..2b4cde0 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisController.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisController.java
@@ -16,9 +16,11 @@
package org.onosproject.isis.controller;
import com.fasterxml.jackson.databind.JsonNode;
+import org.onosproject.isis.controller.topology.IsisLinkListener;
import org.onosproject.isis.controller.topology.IsisRouterListener;
import java.util.List;
+import java.util.Set;
/**
* Representation of an ISIS controller.
@@ -52,4 +54,32 @@
* @return list of process instances
*/
List<IsisProcess> allConfiguredProcesses();
+
+ /**
+ * Registers a listener for ISIS message events.
+ *
+ * @param listener the listener to notify
+ */
+ void addLinkListener(IsisLinkListener listener);
+
+ /**
+ * Unregisters a link listener.
+ *
+ * @param listener the listener to unregister
+ */
+ void removeLinkListener(IsisLinkListener listener);
+
+ /**
+ * Gets the list of listeners registered for router events.
+ *
+ * @return list of listeners
+ */
+ Set<IsisRouterListener> listener();
+
+ /**
+ * Gets the list of listeners registered for link events.
+ *
+ * @return list of listeners
+ */
+ Set<IsisLinkListener> linkListener();
}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
index 3f775cc..d80c208 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisInterface.java
@@ -318,4 +318,4 @@
* Removes all the neighbors.
*/
void removeNeighbors();
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdbAge.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdbAge.java
index 314f9f8..e58aeef 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdbAge.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLsdbAge.java
@@ -69,4 +69,4 @@
* @param lspWrapper LSP wrapper instance
*/
void removeLspFromBin(LspWrapper lspWrapper);
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLspBin.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLspBin.java
index 0964aae..c5ced26 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLspBin.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisLspBin.java
@@ -44,4 +44,4 @@
* @param lspWrapper LSP wrapper instance
*/
void removeIsisLsp(String lspKey, LspWrapper lspWrapper);
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNetworkType.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNetworkType.java
index 083e6d9..d4a5dc5 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNetworkType.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/IsisNetworkType.java
@@ -43,7 +43,6 @@
private int value;
-
/**
* Creates an instance of ISIS network type.
*
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/LspWrapper.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/LspWrapper.java
index a4615f7..2f667c7 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/LspWrapper.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/LspWrapper.java
@@ -124,4 +124,4 @@
* @param lspProcessing "refreshLsp" or "maxageLsp" based on LSP to process
*/
void setLspProcessing(String lspProcessing);
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/DeviceInformation.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/DeviceInformation.java
new file mode 100644
index 0000000..7f8947f
--- /dev/null
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/DeviceInformation.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2016 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.isis.controller.topology;
+
+import org.onlab.packet.Ip4Address;
+
+/**
+ * Representation of an ISIS device information.
+ */
+public interface DeviceInformation {
+
+ /**
+ * Gets system id.
+ *
+ * @return system id
+ */
+ String systemId();
+
+ /**
+ * Sets system id.
+ *
+ * @param systemId system id
+ */
+ void setSystemId(String systemId);
+
+ /**
+ * Gets interface ids.
+ *
+ * @return interface ids
+ */
+ Ip4Address interfaceId();
+
+ /**
+ * Sets interface id.
+ *
+ * @param interfaceId interface id
+ */
+ void setInterfaceId(Ip4Address interfaceId);
+
+ /**
+ * Gets area id.
+ *
+ * @return area id
+ */
+ String areaId();
+
+ /**
+ * Sets area id.
+ *
+ * @param areaId area id
+ */
+ void setAreaId(String areaId);
+
+ /**
+ * Gets device information is already created or not.
+ *
+ * @return true if device information is already created else false
+ */
+ boolean isAlreadyCreated();
+
+ /**
+ * Sets device information is already created or not.
+ *
+ * @param alreadyCreated true if device information is already created else false
+ */
+ void setAlreadyCreated(boolean alreadyCreated);
+
+ /**
+ * Gets device is dis or not.
+ *
+ * @return true if device is dis else false
+ */
+ boolean isDis();
+
+ /**
+ * Sets device is dis or not.
+ *
+ * @param dis true if device is dr else false
+ */
+ void setDis(boolean dis);
+
+ /**
+ * Gets neighbor id.
+ *
+ * @return neighbor id
+ */
+ String neighborId();
+
+ /**
+ * Sets neighbor id.
+ *
+ * @param neighborId neighbor id
+ */
+ void setNeighborId(String neighborId);
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisAgent.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisAgent.java
new file mode 100644
index 0000000..7207fd4
--- /dev/null
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisAgent.java
@@ -0,0 +1,53 @@
+/*
+ * 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.isis.controller.topology;
+
+/**
+ * Representation of an ISIS agent.
+ * It is responsible for keeping track of the current set of routers
+ * connected to the system.
+ */
+public interface IsisAgent {
+ /**
+ * Adds a router that has just connected to the system.
+ *
+ * @param isisRouter the router id to add
+ * @return true if added, false otherwise
+ */
+ boolean addConnectedRouter(IsisRouter isisRouter);
+
+ /**
+ * Removes the router which got disconnected from the system.
+ *
+ * @param isisRouter the router id to remove
+ */
+ void removeConnectedRouter(IsisRouter isisRouter);
+
+ /**
+ * Notifies that got a packet of link from network and need do processing.
+ *
+ * @param isisLink link instance
+ */
+ void addLink(IsisLink isisLink);
+
+ /**
+ * Notifies that got a packet of link from network and need do processing.
+ *
+ * @param isisLink link instance
+ */
+ void deleteLink(IsisLink isisLink);
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLink.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLink.java
index 1760106..7a70cc3 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLink.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLink.java
@@ -15,9 +15,7 @@
*/
package org.onosproject.isis.controller.topology;
-import org.onlab.packet.IpAddress;
-
-import java.util.List;
+import org.onlab.packet.Ip4Address;
/**
* Abstraction of an ISIS Link.
@@ -25,58 +23,72 @@
public interface IsisLink {
/**
- * Returns IP address of the Router.
+ * Returns the remote system ID.
*
- * @return IP address of router
+ * @return remote system ID
*/
- IpAddress remoteRouterId();
+ String remoteSystemId();
/**
- * Returns the area ID for this device.
+ * Returns the local system ID.
*
- * @return the area ID
+ * @return local system ID
*/
- int areaIdOfInterface();
+ String localSystemId();
/**
* Returns IP address of the interface.
*
* @return IP address of the interface
*/
- IpAddress interfaceIp();
+ Ip4Address interfaceIp();
/**
- * Returns the list of link TED details.
+ * Returns IP address of the neighbor.
*
- * @return linkTed list of link TED
+ * @return IP address of the neighbor
*/
- List<IsisLinkTed> linkTed();
+ Ip4Address neighborIp();
/**
- * Sets IP address of the router.
+ * Returns the link TED details.
*
- * @param routerIp router's IP address
+ * @return linkTed link TED
*/
- void setRouterIp(IpAddress routerIp);
+ IsisLinkTed linkTed();
/**
- * Sets the area ID for this device.
+ * Sets remote system ID.
*
- * @param areaIdOfInterface area ID
+ * @param remoteSystemId remote system ID
*/
- void setAreaIdOfInterface(int areaIdOfInterface);
+ void setRemoteSystemId(String remoteSystemId);
+
+ /**
+ * Sets local system ID.
+ *
+ * @param localSystemId remote system ID
+ */
+ void setLocalSystemId(String localSystemId);
/**
* Sets IP address of the interface.
*
* @param interfaceIp IP address of the interface
*/
- void setInterfaceIp(IpAddress interfaceIp);
+ void setInterfaceIp(Ip4Address interfaceIp);
/**
- * Sets the list of link TED.
+ * Sets IP address of the neighbor.
*
- * @param linkTed list of link TED
+ * @param neighborIp IP address of the neighbor
*/
- void setLinkTed(List<IsisLinkTed> linkTed);
+ void setNeighborIp(Ip4Address neighborIp);
+
+ /**
+ * Sets the link TED information.
+ *
+ * @param linkTed link TED
+ */
+ void setLinkTed(IsisLinkTed linkTed);
}
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkListener.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkListener.java
index b96d81c..3f7e484 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkListener.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkListener.java
@@ -23,16 +23,14 @@
/**
* Notifies that we got a link from network.
*
- * @param isisRouter router instance
- * @param isisLinkTed link TED information of router
+ * @param isisLink link instance
*/
- void addLink(IsisRouter isisRouter, IsisLinkTed isisLinkTed);
+ void addLink(IsisLink isisLink);
/**
* Notifies that a link got removed from network.
*
- * @param isisRouter router instance
- * @param isisLinkTed isis link ted infromation
+ * @param isisLink link instance
*/
- void deleteLink(IsisRouter isisRouter, IsisLinkTed isisLinkTed);
+ void deleteLink(IsisLink isisLink);
}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkTed.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkTed.java
index 08014b8..25f3177 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkTed.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisLinkTed.java
@@ -16,7 +16,6 @@
package org.onosproject.isis.controller.topology;
import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip6Address;
import org.onlab.util.Bandwidth;
import java.util.List;
@@ -27,114 +26,100 @@
public interface IsisLinkTed {
/**
- * Provides maximum bandwidth can be used on the link.
+ * Gets the administrative group.
*
- * @return maximum bandwidth
+ * @return administrative group
*/
- Bandwidth maximumLink();
+ int administrativeGroup();
/**
- * Sets maximum band width.
+ * Sets the administrative group.
*
- * @param bandwidth maximum bandwidth
+ * @param administrativeGroup administrative group
*/
- void setMaximumLink(Bandwidth bandwidth);
+ void setAdministrativeGroup(int administrativeGroup);
/**
- * Amount of bandwidth reservable on the link.
+ * Provides the IPv4 interface address.
+ *
+ * @return IPv4 interface address
+ */
+ Ip4Address ipv4InterfaceAddress();
+
+ /**
+ * Sets the IPv4 interface address.
+ *
+ * @param interfaceAddress IPv4 interface address
+ */
+ void setIpv4InterfaceAddress(Ip4Address interfaceAddress);
+
+ /**
+ * Provides the IPv4 neighbor address.
+ *
+ * @return IPv4 neighbor address
+ */
+ Ip4Address ipv4NeighborAddress();
+
+ /**
+ * Sets the IPv4 neighbor address.
+ *
+ * @param neighborAddress IPv4 neighbor address
+ */
+ void setIpv4NeighborAddress(Ip4Address neighborAddress);
+
+ /**
+ * Gets the maximum link bandwidth.
+ *
+ * @return maximum link bandwidth
+ */
+ Bandwidth maximumLinkBandwidth();
+
+ /**
+ * Sets the maximum link bandwidth.
+ *
+ * @param bandwidth maximum link bandwidth
+ */
+ void setMaximumLinkBandwidth(Bandwidth bandwidth);
+
+ /**
+ * Provides max bandwidth that can be reservable on the link.
+ *
+ * @return max bandwidth reservable
+ */
+ Bandwidth maximumReservableLinkBandwidth();
+
+ /**
+ * Sets max bandwidth that can be reservable on the link.
+ *
+ * @param bandwidth max bandwidth that can be reservable on the link
+ */
+ void setMaximumReservableLinkBandwidth(Bandwidth bandwidth);
+
+ /**
+ * Amount of bandwidth unreserved on the link.
*
* @return unreserved bandwidth
*/
- List<Bandwidth> maxUnResBandwidth();
+ List<Bandwidth> unreservedBandwidth();
/**
- * Sets max bandwidth that is not reserved on the link.
+ * Sets the bandwidth unreserved on the link.
*
- * @param bandwidth max bandwidth that is not reserved on the link
+ * @param bandwidth bandwidth unreserved
*/
- void setMaxUnResBandwidth(Bandwidth bandwidth);
-
- /**
- * Provides max bandwidth that can be reserved on the link.
- *
- * @return max bandwidth reserved
- */
- Bandwidth maxReserved();
-
- /**
- * Sets max bandwidth that can be reserved on the link.
- *
- * @param bandwidth max bandwidth that can be reserved on the link
- */
- void setMaxReserved(Bandwidth bandwidth);
+ void setUnreservedBandwidth(List<Bandwidth> bandwidth);
/**
* Provides Traffic Engineering metric for the link.
*
- * @return Traffic Engineering metric
+ * @return Traffic Engineering Default metric
*/
- int teMetric();
+ long teDefaultMetric();
/**
* Sets Traffic Engineering metric for the link.
*
- * @param teMetric Traffic Engineering metric for the link
+ * @param teMetric Traffic Engineering Default metric for the link
*/
- void setTeMetric(int teMetric);
-
- /**
- * Provides IPv4 router-Id of local node.
- *
- * @return IPv4 router-Id of local node
- */
- List<Ip4Address> ipv4LocRouterId();
-
- /**
- * Sets IPv4 router-Id of local node.
- *
- * @param routerIds IPv4 router-Id of local node
- */
- void setIpv4LocRouterId(List<Ip4Address> routerIds);
-
- /**
- * Provides IPv6 router-Id of local node.
- *
- * @return IPv6 router-Id of local node
- */
- List<Ip6Address> ipv6LocRouterId();
-
- /**
- * Sets IPv6 router-Id of local node.
- *
- * @param routerIds IPv6 router-Id of local node
- */
- void setIpv6LocRouterId(List<Ip6Address> routerIds);
-
- /**
- * Provides IPv4 router-Id of remote node.
- *
- * @return IPv4 router-Id of remote node
- */
- List<Ip4Address> ipv4RemRouterId();
-
- /**
- * Sets IPv4 router-Id of remote node.
- *
- * @param routerIds IPv4 router-Id of remote node
- */
- void setIpv4RemRouterId(List<Ip4Address> routerIds);
-
- /**
- * Provides IPv6 router-Id of remote node.
- *
- * @return IPv6 router-Id of remote node
- */
- List<Ip6Address> ipv6RemRouterId();
-
- /**
- * Sets IPv6 router-Id of remote node.
- *
- * @param routerIds IPv6 router-Id of remote node
- */
- void setIpv6RemRouterId(List<Ip6Address> routerIds);
+ void setTeDefaultMetric(long teMetric);
}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouter.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouter.java
index 56ad7da..40ed48a2a 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouter.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouter.java
@@ -23,11 +23,11 @@
public interface IsisRouter {
/**
- * Returns IP address of the router.
+ * Returns system ID for the router.
*
- * @return IP address of the router
+ * @return system ID of the router
*/
- Ip4Address routerIp();
+ String systemId();
/**
* Returns IP address of the interface.
@@ -37,9 +37,44 @@
Ip4Address interfaceId();
/**
- * Sets IP address of the Router.
+ * Gets IP address of the interface.
*
- * @param routerIp IP address of the router
+ * @param interfaceId IP address of the interface
*/
- void setRouterIp(Ip4Address routerIp);
+ void setInterfaceId(Ip4Address interfaceId);
+
+ /**
+ * Sets system ID of the Router.
+ *
+ * @param systemId system ID of the router
+ */
+ void setSystemId(String systemId);
+
+ /**
+ * Gets neighbours ID.
+ *
+ * @return neighbour ID
+ */
+ Ip4Address neighborRouterId();
+
+ /**
+ * Sets the neighbour Id.
+ *
+ * @param neighbourId neighbour Id
+ */
+ void setNeighborRouterId(Ip4Address neighbourId);
+
+ /**
+ * Gets if the router id DIS or not.
+ *
+ * @return true if the router is DIS else false
+ */
+ boolean isDis();
+
+ /**
+ * Sets if the router id DIS or not.
+ *
+ * @param dis true if the router is DIS else false
+ */
+ void setDis(boolean dis);
}
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterId.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterId.java
new file mode 100644
index 0000000..a40d68b
--- /dev/null
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterId.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016 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.isis.controller.topology;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Represents an ISIS router id.
+ */
+public class IsisRouterId {
+
+ private static final String SCHEME = "l3";
+ private static final long UNKNOWN = 0;
+ private final String ipAddress;
+
+ /**
+ * Creates an instance of ISIS router id.
+ *
+ * @param ipAddress IP address of the router
+ */
+ public IsisRouterId(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ /**
+ * Creates an instance from ip address.
+ *
+ * @param ipAddress IP address
+ * @return ISIS router id instance
+ */
+ public static IsisRouterId isisRouterId(String ipAddress) {
+ return new IsisRouterId(ipAddress);
+ }
+
+ /**
+ * Creates ISIS router id instance from the URI.
+ *
+ * @param uri device URI
+ * @return ISIS router id instance
+ */
+ public static IsisRouterId isisRouterId(URI uri) {
+ checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
+ return new IsisRouterId(uri.getSchemeSpecificPart());
+ }
+
+ /**
+ * Returns device URI from the given router id.
+ *
+ * @param isisRouterId router id instance
+ * @return device URI
+ */
+ public static URI uri(IsisRouterId isisRouterId) {
+ return uri(isisRouterId.ipAddress());
+ }
+
+ /**
+ * Returns device URI from the given IP address.
+ *
+ * @param ipAddress device IP address
+ * @return device URI
+ */
+ public static URI uri(String ipAddress) {
+ try {
+ return new URI(SCHEME, ipAddress, null);
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the IP address.
+ *
+ * @return IP address
+ */
+ public String ipAddress() {
+ return ipAddress;
+ }
+
+ @Override
+ public String toString() {
+ return ipAddress;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof IsisRouterId)) {
+ return false;
+ }
+
+ IsisRouterId otherIsisRouterId = (IsisRouterId) other;
+ return Objects.equals(ipAddress, otherIsisRouterId.ipAddress);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipAddress);
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterListener.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterListener.java
index 82d6c61..56da9b5 100644
--- a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterListener.java
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/IsisRouterListener.java
@@ -34,11 +34,4 @@
* @param isisRouter ISIS router instance
*/
void routerRemoved(IsisRouter isisRouter);
-
- /**
- * Notifies that the router has changed in some way.
- *
- * @param isisRouter ISIS router instance
- */
- void routerChanged(IsisRouter isisRouter);
}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/LinkInformation.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/LinkInformation.java
new file mode 100644
index 0000000..9c30f4d
--- /dev/null
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/LinkInformation.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2016 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.isis.controller.topology;
+
+import org.onlab.packet.Ip4Address;
+
+/**
+ * Representation of an ISIS link information.
+ */
+public interface LinkInformation {
+
+ /**
+ * Gets link id.
+ *
+ * @return link id
+ */
+ String linkId();
+
+ /**
+ * Sets link id.
+ *
+ * @param linkId link id
+ */
+ void setLinkId(String linkId);
+
+ /**
+ * Gets whether link information is already created or not.
+ *
+ * @return true if link information is already created else false
+ */
+ boolean isAlreadyCreated();
+
+ /**
+ * Sets link information is already created or not.
+ *
+ * @param alreadyCreated true if link information is already created else false
+ */
+ void setAlreadyCreated(boolean alreadyCreated);
+
+
+ /**
+ * Returns link destination ID.
+ *
+ * @return link destination ID
+ */
+ String linkDestinationId();
+
+ /**
+ * Sets link destination id.
+ *
+ * @param linkDestinationId link destination id
+ */
+ void setLinkDestinationId(String linkDestinationId);
+
+ /**
+ * Gets link source id.
+ *
+ * @return link source id
+ */
+ String linkSourceId();
+
+ /**
+ * Sets link source id.
+ *
+ * @param linkSourceId link source id
+ */
+ void setLinkSourceId(String linkSourceId);
+
+ /**
+ * Gets interface ip address.
+ *
+ * @return interface ip address
+ */
+ Ip4Address interfaceIp();
+
+ /**
+ * Sets interface ip address.
+ *
+ * @param interfaceIp interface ip address
+ */
+ void setInterfaceIp(Ip4Address interfaceIp);
+
+ /**
+ * Gets neighbor ip address.
+ *
+ * @return neighbor ip address
+ */
+ Ip4Address neighborIp();
+
+ /**
+ * Sets neighbor ip address.
+ *
+ * @param neighborIp neighbor ip address
+ */
+ void setNeighborIp(Ip4Address neighborIp);
+}
\ No newline at end of file
diff --git a/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/TopologyForDeviceAndLink.java b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/TopologyForDeviceAndLink.java
new file mode 100644
index 0000000..4153efb
--- /dev/null
+++ b/protocols/isis/api/src/main/java/org/onosproject/isis/controller/topology/TopologyForDeviceAndLink.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016 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.isis.controller.topology;
+
+import java.util.Map;
+
+/**
+ * Represents IP topology for ISIS device and link details.
+ */
+public interface TopologyForDeviceAndLink {
+
+ /**
+ * Gets the device information.
+ *
+ * @return device information
+ */
+ Map<String, DeviceInformation> deviceInformationMap();
+
+ /**
+ * Sets the device information.
+ *
+ * @param key system ID of the device as key
+ * @param deviceInformationMap device information instance
+ */
+ void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap);
+
+ /**
+ * Gets the link information.
+ *
+ * @return link information
+ */
+ Map<String, LinkInformation> linkInformationMap();
+
+ /**
+ * Sets link information.
+ *
+ * @param key system ID of the device as key
+ * @param linkInformationMap link information instance
+ */
+ void setLinkInformationMap(String key, LinkInformation linkInformationMap);
+
+ /**
+ * Removes link information.
+ *
+ * @param key key used to remove from map
+ */
+ void removeLinkInformationMap(String key);
+
+ /**
+ * Removes device information.
+ *
+ * @param key key used to remove from map
+ */
+ void removeDeviceInformationMap(String key);
+
+ /**
+ * Removes links from linkInformationMap.
+ *
+ * @param linkId ID
+ */
+ void removeLinks(String linkId);
+
+ /**
+ * Gets deviceInformation as map.
+ *
+ * @return deviceInformationMap to delete from core
+ */
+ Map<String, DeviceInformation> deviceInformationMapToDelete();
+
+ /**
+ * Sets deviceInformation as map.
+ *
+ * @param key key used to add in map
+ * @param deviceInformationMapToDelete device information to delete from map
+ */
+ void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete);
+
+ /**
+ * Removes Device Information from deviceInformationMapToDelete.
+ *
+ * @param key key to remove from map
+ */
+ void removeDeviceInformationMapFromDeleteMap(String key);
+
+ /**
+ * Gets deviceInformation as map for Point-To-Point.
+ *
+ * @return deviceInformationMap
+ */
+ Map<String, DeviceInformation> deviceInformationMapForPointToPoint();
+
+ /**
+ * Sets deviceInformation as map for Point-To-Point..
+ *
+ * @param key key to add to map
+ * @param deviceInformationMap device information map
+ */
+ void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap);
+
+ /**
+ * Gets linkInformation as map for PointToPoint.
+ *
+ * @return linkInformationMap
+ */
+ Map<String, LinkInformation> linkInformationMapForPointToPoint();
+
+ /**
+ * Sets linkInformation as map for PointToPoint.
+ *
+ * @param key key to add link information to map
+ * @param linkInformationMap link information to add
+ */
+ void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap);
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
index 7cd7785..406d09c 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
@@ -30,6 +30,9 @@
import org.onosproject.isis.controller.IsisNetworkType;
import org.onosproject.isis.controller.IsisProcess;
import org.onosproject.isis.controller.IsisRouterType;
+import org.onosproject.isis.controller.topology.IsisAgent;
+import org.onosproject.isis.controller.topology.IsisLink;
+import org.onosproject.isis.controller.topology.IsisRouter;
import org.onosproject.isis.io.util.IsisConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,6 +46,7 @@
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import static org.onlab.util.Tools.groupedThreads;
@@ -64,15 +68,29 @@
private ScheduledExecutorService connectExecutor = null;
private int connectRetryCounter = 0;
private int connectRetryTime;
+ private ScheduledFuture future = null;
+ private IsisAgent agent;
/**
* Deactivates ISIS controller.
*/
public void isisDeactivate() {
+ disconnectExecutor();
+ processes = null;
peerExecFactory.shutdown();
}
/**
+ * Sets ISIS agent.
+ *
+ * @param agent ISIS agent instance
+ */
+ public void setAgent(IsisAgent agent) {
+ this.agent = agent;
+ }
+
+
+ /**
* Updates the processes configuration.
*
* @param jsonNode json node instance
@@ -134,17 +152,17 @@
peerBootstrap.setOption("keepAlive", true);
peerBootstrap.setOption("receiveBufferSize", Controller.BUFFER_SIZE);
peerBootstrap.setOption("receiveBufferSizePredictorFactory",
- new FixedReceiveBufferSizePredictorFactory(
- Controller.BUFFER_SIZE));
+ new FixedReceiveBufferSizePredictorFactory(
+ Controller.BUFFER_SIZE));
peerBootstrap.setOption("receiveBufferSizePredictor",
- new AdaptiveReceiveBufferSizePredictor(64, 1024, 65536));
+ new AdaptiveReceiveBufferSizePredictor(64, 1024, 65536));
peerBootstrap.setOption("child.keepAlive", true);
peerBootstrap.setOption("child.tcpNoDelay", true);
peerBootstrap.setOption("child.sendBufferSize", Controller.BUFFER_SIZE);
peerBootstrap.setOption("child.receiveBufferSize", Controller.BUFFER_SIZE);
peerBootstrap.setOption("child.receiveBufferSizePredictorFactory",
- new FixedReceiveBufferSizePredictorFactory(
- Controller.BUFFER_SIZE));
+ new FixedReceiveBufferSizePredictorFactory(
+ Controller.BUFFER_SIZE));
peerBootstrap.setOption("child.reuseAddress", true);
isisChannelHandler = new IsisChannelHandler(this, processes);
@@ -236,8 +254,8 @@
continue;
}
isisInterface.setIntermediateSystemName(jsonNode1
- .path(IsisConstants.INTERMEDIATESYSTEMNAME)
- .asText());
+ .path(IsisConstants.INTERMEDIATESYSTEMNAME)
+ .asText());
String systemId = jsonNode1.path(IsisConstants.SYSTEMID).asText();
if (isValidSystemId(systemId)) {
isisInterface.setSystemId(systemId);
@@ -462,7 +480,8 @@
*/
public void disconnectExecutor() {
if (connectExecutor != null) {
- connectExecutor.shutdown();
+ future.cancel(true);
+ connectExecutor.shutdownNow();
connectExecutor = null;
}
}
@@ -480,10 +499,55 @@
* @param retryDelay retry delay
*/
private void scheduleConnectionRetry(long retryDelay) {
- if (this.connectExecutor == null) {
- this.connectExecutor = Executors.newSingleThreadScheduledExecutor();
+ if (connectExecutor == null) {
+ connectExecutor = Executors.newSingleThreadScheduledExecutor();
}
- this.connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES);
+ future = connectExecutor.schedule(new ConnectionRetry(), retryDelay, TimeUnit.MINUTES);
+ }
+
+ /**
+ * Adds device details.
+ *
+ * @param isisRouter ISIS router instance
+ */
+ public void addDeviceDetails(IsisRouter isisRouter) {
+ agent.addConnectedRouter(isisRouter);
+ }
+
+ /**
+ * Removes device details.
+ *
+ * @param isisRouter Isis router instance
+ */
+ public void removeDeviceDetails(IsisRouter isisRouter) {
+ agent.removeConnectedRouter(isisRouter);
+ }
+
+ /**
+ * Adds link details.
+ *
+ * @param isisLink ISIS link instance
+ */
+ public void addLinkDetails(IsisLink isisLink) {
+ agent.addLink(isisLink);
+ }
+
+ /**
+ * Removes link details.
+ *
+ * @param isisLink ISIS link instance
+ */
+ public void removeLinkDetails(IsisLink isisLink) {
+ agent.deleteLink(isisLink);
+ }
+
+ /**
+ * Returns the isisAgent instance.
+ *
+ * @return agent
+ */
+ public IsisAgent agent() {
+ return this.agent;
}
/**
@@ -503,7 +567,7 @@
if (!future.isSuccess()) {
connectRetryCounter++;
log.error("Connection failed, ConnectRetryCounter {} remote host {}", connectRetryCounter,
- IsisConstants.SHOST);
+ IsisConstants.SHOST);
/*
* Reconnect to peer on failure is exponential till 4 mins, later on retry after every 4
* mins.
@@ -517,7 +581,7 @@
isisChannelHandler.sentConfigPacket(configPacket);
connectRetryCounter++;
log.info("Connected to remote host {}, Connect Counter {}", IsisConstants.SHOST,
- connectRetryCounter);
+ connectRetryCounter);
disconnectExecutor();
return;
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java
index 0929db4..aa0b00f 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java
@@ -16,6 +16,7 @@
package org.onosproject.isis.controller.impl;
import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -24,12 +25,18 @@
import org.apache.felix.scr.annotations.Service;
import org.onosproject.isis.controller.IsisController;
import org.onosproject.isis.controller.IsisProcess;
+import org.onosproject.isis.controller.topology.IsisAgent;
+import org.onosproject.isis.controller.topology.IsisLink;
+import org.onosproject.isis.controller.topology.IsisLinkListener;
+import org.onosproject.isis.controller.topology.IsisRouter;
import org.onosproject.isis.controller.topology.IsisRouterListener;
import org.onosproject.net.driver.DriverService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
/**
* Represents ISIS controller implementation.
@@ -42,10 +49,14 @@
private final Controller controller = new Controller();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DriverService driverService;
+ protected Set<IsisRouterListener> isisRouterListener = new HashSet<>();
+ protected Set<IsisLinkListener> isisLinkListener = Sets.newHashSet();
+ protected IsisAgent agent = new InternalDeviceConfig();
@Activate
public void activate() {
log.debug("ISISControllerImpl activate");
+ controller.setAgent(agent);
}
@Deactivate
@@ -55,6 +66,38 @@
}
@Override
+ public void addRouterListener(IsisRouterListener listener) {
+ if (!isisRouterListener.contains(listener)) {
+ this.isisRouterListener.add(listener);
+ }
+ }
+
+ @Override
+ public void removeRouterListener(IsisRouterListener listener) {
+ this.isisRouterListener.remove(listener);
+ }
+
+ @Override
+ public void addLinkListener(IsisLinkListener listener) {
+ isisLinkListener.add(listener);
+ }
+
+ @Override
+ public void removeLinkListener(IsisLinkListener listener) {
+ isisLinkListener.remove(listener);
+ }
+
+ @Override
+ public Set<IsisRouterListener> listener() {
+ return isisRouterListener;
+ }
+
+ @Override
+ public Set<IsisLinkListener> linkListener() {
+ return isisLinkListener;
+ }
+
+ @Override
public List<IsisProcess> allConfiguredProcesses() {
List<IsisProcess> processes = controller.getAllConfiguredProcesses();
return processes;
@@ -70,13 +113,37 @@
}
}
- @Override
- public void addRouterListener(IsisRouterListener isisRouterListener) {
- log.debug("IsisControllerImpl::addRouterListener...");
- }
+ /**
+ * Notifier for internal ISIS device and link changes.
+ */
+ private class InternalDeviceConfig implements IsisAgent {
+ @Override
+ public boolean addConnectedRouter(IsisRouter isisRouter) {
+ for (IsisRouterListener l : listener()) {
+ l.routerAdded(isisRouter);
+ }
+ return true;
+ }
- @Override
- public void removeRouterListener(IsisRouterListener isisRouterListener) {
- log.debug("IsisControllerImpl::removeRouterListener...");
+ @Override
+ public void removeConnectedRouter(IsisRouter isisRouter) {
+ for (IsisRouterListener l : listener()) {
+ l.routerRemoved(isisRouter);
+ }
+ }
+
+ @Override
+ public void addLink(IsisLink isisLink) {
+ for (IsisLinkListener l : linkListener()) {
+ l.addLink(isisLink);
+ }
+ }
+
+ @Override
+ public void deleteLink(IsisLink isisLink) {
+ for (IsisLinkListener l : linkListener()) {
+ l.deleteLink(isisLink);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
index 73a5626..38e98d1 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
@@ -68,6 +68,16 @@
public IsisChannelHandler(Controller controller, List<IsisProcess> processes) {
this.controller = controller;
this.processes = processes;
+ ((DefaultIsisLsdb) isisLsdb).setController(this.controller);
+ ((DefaultIsisLsdb) isisLsdb).setIsisInterface(isisInterfaceList());
+ }
+
+ private List<IsisInterface> isisInterfaceList() {
+ List<IsisInterface> isisInterfaceList = new ArrayList<>();
+ for (Integer key : isisInterfaceMap.keySet()) {
+ isisInterfaceList.add(isisInterfaceMap.get(key));
+ }
+ return isisInterfaceList;
}
/**
@@ -178,30 +188,25 @@
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
- log.info("[exceptionCaught]: " + e.toString());
if (e.getCause() instanceof ReadTimeoutException) {
- log.error("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
+ log.debug("Disconnecting device {} due to read timeout", e.getChannel().getRemoteAddress());
return;
} else if (e.getCause() instanceof ClosedChannelException) {
log.debug("Channel for ISIS {} already closed", e.getChannel().getRemoteAddress());
} else if (e.getCause() instanceof IOException) {
- log.error("Disconnecting ISIS {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
+ log.debug("Disconnecting ISIS {} due to IO Error: {}", e.getChannel().getRemoteAddress(),
e.getCause().getMessage());
- if (log.isDebugEnabled()) {
- log.debug("StackTrace for previous Exception: {}", e.getCause());
- }
} else if (e.getCause() instanceof IsisParseException) {
IsisParseException errMsg = (IsisParseException) e.getCause();
byte errorCode = errMsg.errorCode();
byte errorSubCode = errMsg.errorSubCode();
- log.error("Error while parsing message from ISIS {}, ErrorCode {}",
+ log.debug("Error while parsing message from ISIS {}, ErrorCode {}",
e.getChannel().getRemoteAddress(), errorCode);
} else if (e.getCause() instanceof RejectedExecutionException) {
- log.warn("Could not process message: queue full");
+ log.debug("Could not process message: queue full");
} else {
- log.error("Error while processing message from ISIS {}, {}",
+ log.debug("Error while processing message from ISIS {}, {}",
e.getChannel().getRemoteAddress(), e.getCause().getMessage());
- e.getCause().printStackTrace();
}
}
@@ -274,7 +279,7 @@
* @param configPacket interface configuration
*/
public void sentConfigPacket(byte[] configPacket) {
- if (channel != null) {
+ if (channel != null && channel.isConnected() && channel.isOpen()) {
channel.write(configPacket);
log.debug("IsisChannelHandler sentConfigPacket packet sent..!!!");
} else {
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java
new file mode 100644
index 0000000..98586f0
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java
@@ -0,0 +1,264 @@
+/*
+* 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.isis.controller.impl;
+
+import org.onosproject.isis.controller.IsisNetworkType;
+import org.onosproject.isis.controller.LspWrapper;
+import org.onosproject.isis.controller.impl.topology.DefaultIsisLink;
+import org.onosproject.isis.controller.impl.topology.DefaultIsisRouter;
+import org.onosproject.isis.controller.impl.topology.TopologyForDeviceAndLinkImpl;
+import org.onosproject.isis.controller.topology.IsisLink;
+import org.onosproject.isis.controller.topology.IsisLinkTed;
+import org.onosproject.isis.controller.topology.IsisRouter;
+import org.onosproject.isis.controller.topology.LinkInformation;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
+import org.onosproject.isis.io.isispacket.tlv.IpExtendedReachabilityTlv;
+import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability;
+import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
+import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs;
+import org.onosproject.isis.io.util.IsisConstants;
+import org.onosproject.isis.io.util.IsisUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * Representation of LSP event consumer.
+ */
+public class LspEventConsumer implements Runnable {
+ private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class);
+ public static List<LsPdu> lsPdus = new ArrayList<>();
+ private String lspAdded = "LSP_ADDED";
+ private String lspRemoved = "LSP_REMOVED";
+ private BlockingQueue queue = null;
+ private Controller controller = null;
+ private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl();
+
+ /**
+ * Creates an instance of this.
+ *
+ * @param queue blocking queue instance
+ * @param controller controller instance
+ */
+ public LspEventConsumer(BlockingQueue queue, Controller controller) {
+ this.queue = queue;
+ this.controller = controller;
+ }
+
+ @Override
+ public void run() {
+ log.debug("LspsForProvider:run...!!!");
+ try {
+ while (true) {
+ if (!queue.isEmpty()) {
+ LspWrapper wrapper = (LspWrapper) queue.take();
+ LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
+ for (IsisTlv isisTlv : lsPdu.tlvs()) {
+ if ((isisTlv instanceof IpExtendedReachabilityTlv) ||
+ (isisTlv instanceof IsExtendedReachability)) {
+ lsPdus.add(lsPdu);
+ if (wrapper.lspProcessing().equals(lspAdded)) {
+ callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(),
+ wrapper.isisInterface().systemId() + ".00");
+ }
+ if (wrapper.lspProcessing().equals(lspRemoved)) {
+ callTopologyToRemoveInfo(lsPdu);
+ }
+ break;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error::LspsForProvider::{}", e.getMessage());
+ }
+ }
+
+ /**
+ * Sends topology information to core.
+ *
+ * @param lsPdu ls pdu instance
+ * @param isisNetworkType ISIS network type
+ */
+ private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType,
+ String ownSystemId) {
+ if (isisNetworkType.equals(IsisNetworkType.BROADCAST)) {
+ sendDeviceInfo(lsPdu);
+ boolean isDis = IsisUtil.checkIsDis(lsPdu.lspId());
+ if (isDis) {
+ sendLinkInfo(lsPdu, ownSystemId);
+ }
+ } else if (isisNetworkType.equals(IsisNetworkType.P2P)) {
+
+ sendDeviceInfo(lsPdu);
+
+ for (LsPdu wrapper : lsPdus) {
+ LsPdu lsPduStored = wrapper;
+ List<String> neStringList = neighborList(lsPduStored, ownSystemId);
+ String lspId = IsisUtil.removeTailingZeros(lsPdu.lspId());
+ if (neStringList.contains(lspId)) {
+ sendLinkInfo(lsPduStored, ownSystemId);
+ }
+ }
+
+ List<String> neStringList = neighborList(lsPdu, ownSystemId);
+ Map<String, IsisRouter> routerPresence = deviceAndLink.isisDeviceList();
+ for (String neighbor : neStringList) {
+ IsisRouter isisRouter = routerPresence.get(neighbor);
+ if (isisRouter != null) {
+ sendLinkInfo(lsPdu, ownSystemId);
+ } else {
+ lsPdus.add(lsPdu);
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes topology information from core.
+ *
+ * @param lsPdu ls pdu instance
+ */
+ private void callTopologyToRemoveInfo(LsPdu lsPdu) {
+ removeDeviceInfo(lsPdu);
+ removeLinkInfo(lsPdu);
+ }
+
+ /**
+ * Sends the device information to topology provider.
+ *
+ * @param lsPdu ls pdu instance
+ */
+ private void sendDeviceInfo(LsPdu lsPdu) {
+ IsisRouter isisRouter = deviceAndLink.createDeviceInfo(lsPdu);
+ if (isisRouter.systemId() != null) {
+ controller.addDeviceDetails(isisRouter);
+ }
+ }
+
+ /**
+ * Returns the list of neighbors.
+ *
+ * @param lsPdu link state Pdu
+ * @return neighbor list
+ */
+ private List<String> neighborList(LsPdu lsPdu, String ownSystemId) {
+ List<String> neighbourList = new ArrayList<>();
+ for (IsisTlv isisTlv : lsPdu.tlvs()) {
+ if (isisTlv instanceof IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighborForExtendedIsList = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs neighbor : neighborForExtendedIsList) {
+ String neighbourId = neighbor.neighborId();
+ if (!(neighbourId.equals(ownSystemId))) {
+ neighbourList.add(neighbourId);
+ }
+
+ }
+ }
+ }
+ return neighbourList;
+ }
+
+ /**
+ * Creates ISIS router instance.
+ *
+ * @param systemId system ID
+ * @return isisRouter instance
+ */
+ private IsisRouter createIsisRouterDummy(String systemId) {
+ IsisRouter isisRouter = new DefaultIsisRouter();
+ isisRouter.setSystemId(systemId);
+ isisRouter.setDis(false);
+ isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
+ isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
+ return isisRouter;
+ }
+
+ /**
+ * Removes the device information from topology provider.
+ *
+ * @param lsPdu ls pdu instance
+ */
+ private void removeDeviceInfo(LsPdu lsPdu) {
+ IsisRouter isisRouter = deviceAndLink.removeDeviceAndLinkInfo(lsPdu);
+ if (isisRouter.systemId() != null) {
+ controller.removeDeviceDetails(isisRouter);
+ }
+ }
+
+ /**
+ * Sends the link information to topology provider.
+ *
+ * @param lsPdu ls pdu instance
+ */
+ private void sendLinkInfo(LsPdu lsPdu, String ownSystemId) {
+ Map<String, LinkInformation> linkInformationList = deviceAndLink.createLinkInfo(lsPdu, ownSystemId);
+ for (String key : linkInformationList.keySet()) {
+ LinkInformation linkInformation = linkInformationList.get(key);
+ if (linkInformation.isAlreadyCreated()) {
+ controller.addDeviceDetails(createIsisRouterDummy(linkInformation.linkDestinationId()));
+ controller.addLinkDetails(createIsisLink(linkInformation, lsPdu));
+ } else {
+ controller.addLinkDetails(createIsisLink(linkInformation, lsPdu));
+ }
+ }
+ }
+
+ /**
+ * Removes the link information from topology provider.
+ *
+ * @param lsPdu ls pdu instance
+ */
+ private void removeLinkInfo(LsPdu lsPdu) {
+ Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu);
+ for (String key : linkInformationList.keySet()) {
+ LinkInformation linkInformation = linkInformationList.get(key);
+ controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu));
+ }
+ }
+
+ /**
+ * Creates ISIS link instance.
+ *
+ * @param linkInformation link information instance
+ * @return isisLink instance
+ */
+ private IsisLink createIsisLink(LinkInformation linkInformation, LsPdu lsPdu) {
+ IsisLink isisLink = new DefaultIsisLink();
+ isisLink.setLocalSystemId(linkInformation.linkSourceId());
+ isisLink.setRemoteSystemId(linkInformation.linkDestinationId());
+ isisLink.setInterfaceIp(linkInformation.interfaceIp());
+ isisLink.setNeighborIp(linkInformation.neighborIp());
+ isisLink.setLinkTed(createLinkTedInfo(lsPdu));
+ return isisLink;
+ }
+
+ /**
+ * Creates the link TED information.
+ *
+ * @param lsPdu link state PDU
+ * @return isisLinkTed
+ */
+ private IsisLinkTed createLinkTedInfo(LsPdu lsPdu) {
+ IsisLinkTed isisLinkTed = deviceAndLink.createIsisLinkTedInfo(lsPdu);
+ return isisLinkTed;
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
index 3c66bf8..e9fd120 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
@@ -23,15 +23,20 @@
import org.onosproject.isis.controller.IsisMessage;
import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.LspWrapper;
+import org.onosproject.isis.controller.impl.Controller;
+import org.onosproject.isis.controller.impl.LspEventConsumer;
import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import org.onosproject.isis.io.util.IsisConstants;
import org.onosproject.isis.io.util.IsisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -43,10 +48,14 @@
private Map<String, LspWrapper> isisL1Db = new ConcurrentHashMap<>();
private Map<String, LspWrapper> isisL2Db = new ConcurrentHashMap<>();
private IsisLsdbAge lsdbAge = null;
+ private Controller controller = null;
+ private List<IsisInterface> isisInterfaceList = new ArrayList<>();
private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
+ private LspEventConsumer queueConsumer = null;
+ private BlockingQueue<LspWrapper> lspForProviderQueue = new ArrayBlockingQueue<>(1024);
/**
* Creates an instance of ISIS LSDB.
@@ -56,10 +65,30 @@
}
/**
+ * Sets the controller instance.
+ *
+ * @param controller controller instance
+ */
+ public void setController(Controller controller) {
+ this.controller = controller;
+ }
+
+ /**
+ * Sets the list of IsisInterface instance.
+ *
+ * @param isisInterfaceList isisInterface instance
+ */
+ public void setIsisInterface(List<IsisInterface> isisInterfaceList) {
+ this.isisInterfaceList = isisInterfaceList;
+ }
+
+ /**
* Initializes the link state database.
*/
public void initializeDb() {
lsdbAge.startDbAging();
+ queueConsumer = new LspEventConsumer(lspForProviderQueue, controller);
+ new Thread(queueConsumer).start();
}
/**
@@ -96,7 +125,6 @@
return lspKey.toString();
}
-
/**
* Returns the neighbor L1 database information.
*
@@ -215,7 +243,7 @@
byte[] lspBytes = lspdu.asBytes();
lspdu.setPduLength(lspBytes.length);
lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
- IsisConstants.CHECKSUMPOSITION + 1);
+ IsisConstants.CHECKSUMPOSITION + 1);
byte[] checkSum = {lspBytes[IsisConstants.CHECKSUMPOSITION], lspBytes[IsisConstants.CHECKSUMPOSITION + 1]};
lspdu.setCheckSum(ChannelBuffers.copiedBuffer(checkSum).readUnsignedShort());
}
@@ -236,6 +264,14 @@
addLsp(lspWrapper, lspdu.lspId());
log.debug("Added LSp In LSDB: {}", lspWrapper);
+ try {
+ if (!lspWrapper.isSelfOriginated()) {
+ lspWrapper.setLspProcessing(IsisConstants.LSPADDED);
+ lspForProviderQueue.put(lspWrapper);
+ }
+ } catch (Exception e) {
+ log.debug("Added LSp In Blocking queue: {}", lspWrapper);
+ }
return true;
}
@@ -273,9 +309,10 @@
lspBin.addIsisLsp(key, lspWrapper);
lsdbAge.addLspBin(binNumber, lspBin);
log.debug("Added Type {} LSP to LSDB and LSABin[{}], Remaining life time of LSA {}",
- lspWrapper.lsPdu().isisPduType(),
- binNumber, lspWrapper.remainingLifetime());
+ lspWrapper.lsPdu().isisPduType(),
+ binNumber, lspWrapper.remainingLifetime());
}
+
return false;
}
@@ -337,6 +374,7 @@
public void deleteLsp(IsisMessage lspMessage) {
LsPdu lsp = (LsPdu) lspMessage;
String lspKey = lsp.lspId();
+ LspWrapper lspWrapper = findLsp(lspMessage.isisPduType(), lspKey);
switch (lsp.isisPduType()) {
case L1LSPDU:
isisL1Db.remove(lspKey);
@@ -348,5 +386,12 @@
log.debug("Unknown LSP type to remove..!!!");
break;
}
+
+ try {
+ lspWrapper.setLspProcessing(IsisConstants.LSPREMOVED);
+ lspForProviderQueue.put(lspWrapper);
+ } catch (Exception e) {
+ log.debug("Added LSp In Blocking queue: {}", lspWrapper);
+ }
}
}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
index 9ceb97c..790d3ae 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
@@ -231,7 +231,6 @@
}
}
-
/**
* Runnable task which runs every second and calls aging process.
*/
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
index b5eca27..c2626d4 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
@@ -58,12 +58,12 @@
switch (lspProcessing) {
case IsisConstants.REFRESHLSP:
log.debug("LSPQueueConsumer: Message - " + IsisConstants.REFRESHLSP +
- " consumed.");
+ " consumed.");
processRefreshLsp(wrapper);
break;
case IsisConstants.MAXAGELSP:
log.debug("LSPQueueConsumer: Message - " + IsisConstants.MAXAGELSP +
- " consumed.");
+ " consumed.");
processMaxAgeLsa(wrapper);
break;
default:
@@ -72,7 +72,6 @@
}
}
}
-
} catch (Exception e) {
log.debug("Error::LSPQueueConsumer::{}", e.getMessage());
}
@@ -94,19 +93,18 @@
lsPdu.setRemainingLifeTime(IsisConstants.LSPMAXAGE);
byte[] lspBytes = lsPdu.asBytes();
lspBytes = IsisUtil.addLengthAndMarkItInReserved(lspBytes, IsisConstants.LENGTHPOSITION,
- IsisConstants.LENGTHPOSITION + 1,
- IsisConstants.RESERVEDPOSITION);
+ IsisConstants.LENGTHPOSITION + 1,
+ IsisConstants.RESERVEDPOSITION);
lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
- IsisConstants.CHECKSUMPOSITION + 1);
+ IsisConstants.CHECKSUMPOSITION + 1);
//write to the channel
channel.write(IsisUtil.framePacket(lspBytes, isisInterface.interfaceIndex()));
// Updating the database with resetting remaining life time to default.
IsisLsdb isisDb = isisInterface.isisLsdb();
isisDb.addLsp(lsPdu, true, isisInterface);
log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}",
- wrapper.lsPdu());
+ wrapper.lsPdu());
}
-
}
}
@@ -124,7 +122,7 @@
IsisLsdb isisDb = isisInterface.isisLsdb();
isisDb.deleteLsp(lsPdu);
log.debug("LSPQueueConsumer: processMaxAgeLsp - Removed-Max Age LSP {}",
- wrapper.lsPdu());
+ wrapper.lsPdu());
}
}
}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLink.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLink.java
new file mode 100644
index 0000000..2df4276
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLink.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2015 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.isis.controller.impl.topology;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.isis.controller.topology.IsisLink;
+import org.onosproject.isis.controller.topology.IsisLinkTed;
+
+/**
+ * Representation of an ISIS Link.
+ */
+public class DefaultIsisLink implements IsisLink {
+
+ private String remoteSystemId;
+ private String localSystemId;
+ private Ip4Address interfaceIp;
+ private Ip4Address neighborIp;
+ private IsisLinkTed linkTed;
+
+ @Override
+ public String remoteSystemId() {
+ return this.remoteSystemId;
+ }
+
+ @Override
+ public String localSystemId() {
+ return this.localSystemId;
+ }
+
+ @Override
+ public Ip4Address interfaceIp() {
+ return this.interfaceIp;
+ }
+
+ @Override
+ public Ip4Address neighborIp() {
+ return this.neighborIp;
+ }
+
+ @Override
+ public IsisLinkTed linkTed() {
+ return this.linkTed;
+ }
+
+ @Override
+ public void setRemoteSystemId(String remoteSystemId) {
+ this.remoteSystemId = remoteSystemId;
+ }
+
+ @Override
+ public void setLocalSystemId(String localSystemId) {
+ this.localSystemId = localSystemId;
+ }
+
+ @Override
+ public void setInterfaceIp(Ip4Address interfaceIp) {
+ this.interfaceIp = interfaceIp;
+ }
+
+ @Override
+ public void setNeighborIp(Ip4Address neighborIp) {
+ this.neighborIp = neighborIp;
+ }
+
+ @Override
+ public void setLinkTed(IsisLinkTed linkTed) {
+ this.linkTed = linkTed;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("remoteSystemId", remoteSystemId)
+ .add("localSystemId", localSystemId)
+ .add("interfaceIp", interfaceIp)
+ .add("neighborIp", neighborIp)
+ .add("linkTed", linkTed)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultIsisLink that = (DefaultIsisLink) o;
+ return Objects.equal(remoteSystemId, that.remoteSystemId) &&
+ Objects.equal(localSystemId, that.localSystemId) &&
+ Objects.equal(interfaceIp, that.interfaceIp) &&
+ Objects.equal(neighborIp, that.neighborIp) &&
+ Objects.equal(linkTed, that.linkTed);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(remoteSystemId, localSystemId, interfaceIp, neighborIp, linkTed);
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkInformation.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkInformation.java
new file mode 100644
index 0000000..574f440
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkInformation.java
@@ -0,0 +1,166 @@
+/*
+ * 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.isis.controller.impl.topology;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.isis.controller.topology.LinkInformation;
+
+/**
+ * Representation of an ISIS link information..
+ */
+public class DefaultIsisLinkInformation implements LinkInformation {
+
+ String linkId;
+ String linkSourceId;
+ String linkDestinationId;
+ Ip4Address interfaceIp;
+ Ip4Address neighborIp;
+ boolean alreadyCreated;
+
+ /**
+ * Gets link id.
+ *
+ * @return link id
+ */
+ public String linkId() {
+ return linkId;
+ }
+
+ /**
+ * Sets link id.DefaultIsisDeviceInformation.
+ *
+ * @param linkId link id
+ */
+ public void setLinkId(String linkId) {
+ this.linkId = linkId;
+ }
+
+ /**
+ * Gets is already created or not.
+ *
+ * @return true if already created else false
+ */
+ public boolean isAlreadyCreated() {
+ return alreadyCreated;
+ }
+
+ /**
+ * Sets is already created or not.
+ *
+ * @param alreadyCreated true or false
+ */
+ public void setAlreadyCreated(boolean alreadyCreated) {
+ this.alreadyCreated = alreadyCreated;
+ }
+
+ /**
+ * Gets link destination id.
+ *
+ * @return link destination id
+ */
+ public String linkDestinationId() {
+ return linkDestinationId;
+ }
+
+ /**
+ * Sets link destination id.
+ *
+ * @param linkDestinationId link destination id
+ */
+ public void setLinkDestinationId(String linkDestinationId) {
+ this.linkDestinationId = linkDestinationId;
+ }
+
+ /**
+ * Gets link source id.
+ *
+ * @return link source id
+ */
+ public String linkSourceId() {
+ return linkSourceId;
+ }
+
+ /**
+ * Sets link source id.
+ *
+ * @param linkSourceId link source id
+ */
+ public void setLinkSourceId(String linkSourceId) {
+ this.linkSourceId = linkSourceId;
+ }
+
+ /**
+ * Gets interface IP address.
+ *
+ * @return interface IP address
+ */
+ public Ip4Address interfaceIp() {
+ return interfaceIp;
+ }
+
+ /**
+ * Sets interface IP address.
+ *
+ * @param interfaceIp interface IP address
+ */
+ public void setInterfaceIp(Ip4Address interfaceIp) {
+ this.interfaceIp = interfaceIp;
+ }
+
+ @Override
+ public Ip4Address neighborIp() {
+ return this.neighborIp;
+ }
+
+ @Override
+ public void setNeighborIp(Ip4Address neighborIp) {
+ this.neighborIp = neighborIp;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("linkId", linkId)
+ .add("linkSourceId", linkSourceId)
+ .add("linkDestinationId", linkDestinationId)
+ .add("interfaceIp", interfaceIp)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultIsisLinkInformation that = (DefaultIsisLinkInformation) o;
+ return Objects.equal(linkId, that.linkId) &&
+ Objects.equal(linkSourceId, that.linkSourceId) &&
+ Objects.equal(linkDestinationId, that.linkDestinationId) &&
+ Objects.equal(interfaceIp, that.interfaceIp);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(linkId, linkSourceId, linkDestinationId,
+ interfaceIp);
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkTed.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkTed.java
new file mode 100644
index 0000000..a363b3d
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkTed.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2016 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.isis.controller.impl.topology;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onlab.packet.Ip4Address;
+import org.onlab.util.Bandwidth;
+import org.onosproject.isis.controller.topology.IsisLinkTed;
+
+import java.util.List;
+
+/**
+ * Representation of an ISIS device information.
+ */
+public class DefaultIsisLinkTed implements IsisLinkTed {
+
+
+ private int administrativeGroup;
+ private Ip4Address ipv4InterfaceAddress;
+ private Ip4Address ipv4NeighborAddress;
+ private Bandwidth maximumLinkBandwidth;
+ private Bandwidth maximumReservableLinkBandwidth;
+ private List<Bandwidth> unreservedBandwidth;
+ private long teDefaultMetric;
+
+ @Override
+ public int administrativeGroup() {
+ return administrativeGroup;
+ }
+
+ @Override
+ public void setAdministrativeGroup(int administrativeGroup) {
+ this.administrativeGroup = administrativeGroup;
+ }
+
+ @Override
+ public Ip4Address ipv4InterfaceAddress() {
+ return ipv4InterfaceAddress;
+ }
+
+ @Override
+ public void setIpv4InterfaceAddress(Ip4Address interfaceAddress) {
+ this.ipv4InterfaceAddress = interfaceAddress;
+ }
+
+ @Override
+ public Ip4Address ipv4NeighborAddress() {
+ return ipv4NeighborAddress;
+ }
+
+ @Override
+ public void setIpv4NeighborAddress(Ip4Address neighborAddress) {
+ this.ipv4NeighborAddress = neighborAddress;
+ }
+
+ @Override
+ public Bandwidth maximumLinkBandwidth() {
+ return maximumLinkBandwidth;
+ }
+
+ @Override
+ public void setMaximumLinkBandwidth(Bandwidth bandwidth) {
+ this.maximumLinkBandwidth = bandwidth;
+ }
+
+ @Override
+ public Bandwidth maximumReservableLinkBandwidth() {
+ return maximumReservableLinkBandwidth;
+ }
+
+ @Override
+ public void setMaximumReservableLinkBandwidth(Bandwidth bandwidth) {
+ this.maximumReservableLinkBandwidth = bandwidth;
+ }
+
+ @Override
+ public List<Bandwidth> unreservedBandwidth() {
+ return this.unreservedBandwidth;
+ }
+
+ @Override
+ public void setUnreservedBandwidth(List<Bandwidth> bandwidth) {
+ this.unreservedBandwidth.addAll(bandwidth);
+ }
+
+ @Override
+ public long teDefaultMetric() {
+ return teDefaultMetric;
+ }
+
+ @Override
+ public void setTeDefaultMetric(long teMetric) {
+ this.teDefaultMetric = teMetric;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("administrativeGroup", administrativeGroup)
+ .add("ipv4InterfaceAddress", ipv4InterfaceAddress)
+ .add("ipv4NeighborAddress", ipv4NeighborAddress)
+ .add("maximumLinkBandwidth", maximumLinkBandwidth)
+ .add("maximumReservableLinkBandwidth", maximumReservableLinkBandwidth)
+ .add("teDefaultMetric", teDefaultMetric)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultIsisLinkTed that = (DefaultIsisLinkTed) o;
+ return Objects.equal(administrativeGroup, that.administrativeGroup) &&
+ Objects.equal(ipv4InterfaceAddress, that.ipv4InterfaceAddress) &&
+ Objects.equal(ipv4NeighborAddress, that.ipv4NeighborAddress) &&
+ Objects.equal(maximumLinkBandwidth, that.maximumLinkBandwidth) &&
+ Objects.equal(maximumReservableLinkBandwidth,
+ that.maximumReservableLinkBandwidth) &&
+ Objects.equal(teDefaultMetric, that.teDefaultMetric);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(administrativeGroup, ipv4InterfaceAddress,
+ ipv4NeighborAddress, maximumLinkBandwidth, teDefaultMetric);
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisRouter.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisRouter.java
new file mode 100644
index 0000000..216ce37
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisRouter.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2015 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.isis.controller.impl.topology;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.isis.controller.topology.IsisRouter;
+
+/**
+ * Representation of an ISIS Router.
+ */
+public class DefaultIsisRouter implements IsisRouter {
+
+ private String systemId;
+ private Ip4Address neighborRouterId;
+ private Ip4Address interfaceId;
+ private boolean isDis;
+
+ /**
+ * Gets the system ID.
+ *
+ * @return systemId system ID
+ */
+ public String systemId() {
+ return systemId;
+ }
+
+ /**
+ * Sets IP address of the Router.
+ */
+ public void setSystemId(String systemId) {
+ this.systemId = systemId;
+ }
+
+ /**
+ * Gets IP address of the interface.
+ *
+ * @return IP address of the interface
+ */
+ public Ip4Address interfaceId() {
+ return interfaceId;
+ }
+
+ /**
+ * Gets IP address of the interface.
+ *
+ * @param interfaceId IP address of the interface
+ */
+ public void setInterfaceId(Ip4Address interfaceId) {
+ this.interfaceId = interfaceId;
+ }
+
+ /**
+ * Gets neighbor's Router id.
+ *
+ * @return neighbor's Router id
+ */
+ public Ip4Address neighborRouterId() {
+ return neighborRouterId;
+ }
+
+ /**
+ * Sets neighbor's Router id.
+ *
+ * @param advertisingRouterId neighbor's Router id
+ */
+ public void setNeighborRouterId(Ip4Address advertisingRouterId) {
+ this.neighborRouterId = advertisingRouterId;
+ }
+
+ /**
+ * Gets if DR or not.
+ *
+ * @return true if DR else false
+ */
+ public boolean isDis() {
+ return isDis;
+ }
+
+ /**
+ * Sets dis or not.
+ *
+ * @param dis true if DIS else false
+ */
+ public void setDis(boolean dis) {
+ isDis = dis;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("systemId", systemId)
+ .add("neighborRouterId", neighborRouterId)
+ .add("interfaceId", interfaceId)
+ .toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ DefaultIsisRouter that = (DefaultIsisRouter) o;
+ return Objects.equal(systemId, that.systemId) &&
+ Objects.equal(neighborRouterId, that.neighborRouterId) &&
+ Objects.equal(interfaceId, that.interfaceId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(systemId, neighborRouterId, interfaceId);
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/TopologyForDeviceAndLinkImpl.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/TopologyForDeviceAndLinkImpl.java
new file mode 100644
index 0000000..75427b4
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/TopologyForDeviceAndLinkImpl.java
@@ -0,0 +1,437 @@
+/*
+* Copyright 2016 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.isis.controller.impl.topology;
+
+import org.onlab.util.Bandwidth;
+import org.onosproject.isis.controller.topology.DeviceInformation;
+import org.onosproject.isis.controller.topology.IsisRouter;
+import org.onosproject.isis.controller.topology.LinkInformation;
+import org.onosproject.isis.controller.topology.TopologyForDeviceAndLink;
+import org.onosproject.isis.controller.topology.IsisLinkTed;
+import org.onosproject.isis.io.isispacket.pdu.LsPdu;
+import org.onosproject.isis.io.isispacket.tlv.IpExtendedReachabilityTlv;
+import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability;
+import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
+import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth;
+import org.onosproject.isis.io.util.IsisConstants;
+import org.onosproject.isis.io.util.IsisUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents device and link topology information.
+ */
+public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
+
+ private static final Logger log = LoggerFactory.getLogger(TopologyForDeviceAndLinkImpl.class);
+ private Map<String, DeviceInformation> deviceInformationMap = new LinkedHashMap<>();
+ private Map<String, IsisRouter> isisRouterDetails = new LinkedHashMap<>();
+ private Map<String, DeviceInformation> deviceInformationMapForPointToPoint = new LinkedHashMap<>();
+ private Map<String, DeviceInformation> deviceInformationMapToDelete = new LinkedHashMap<>();
+ private Map<String, LinkInformation> addedLinkInformationMap = new LinkedHashMap<>();
+ private Map<String, LinkInformation> removeLinkInformationMap = new LinkedHashMap<>();
+
+ /**
+ * Gets device information.
+ *
+ * @return device information
+ */
+ public Map<String, DeviceInformation> deviceInformationMap() {
+ return deviceInformationMap;
+ }
+
+ /**
+ * Gets ISIS router list information.
+ *
+ * @return router information
+ */
+ public Map<String, IsisRouter> isisDeviceList() {
+ return isisRouterDetails;
+ }
+
+ /**
+ * Sets device information.
+ *
+ * @param key key used to add in map
+ * @param deviceInformationMap device information instance
+ */
+ public void setDeviceInformationMap(String key, DeviceInformation deviceInformationMap) {
+ if (deviceInformationMap != null) {
+ this.deviceInformationMap.put(key, deviceInformationMap);
+ }
+
+ }
+
+ /**
+ * Gets deviceInformation as map for Point-To-Point.
+ *
+ * @return deviceInformationMap
+ */
+ public Map<String, DeviceInformation> deviceInformationMapForPointToPoint() {
+ return deviceInformationMapForPointToPoint;
+ }
+
+ /**
+ * Sets deviceInformation as map for Point-To-Point..
+ *
+ * @param key key used to add in map
+ * @param deviceInformationMap device information instance
+ */
+ public void setDeviceInformationMapForPointToPoint(String key, DeviceInformation deviceInformationMap) {
+ if (deviceInformationMap != null) {
+ this.deviceInformationMapForPointToPoint.put(key, deviceInformationMap);
+ }
+
+ }
+
+ /**
+ * Gets deviceInformation as map.
+ *
+ * @return deviceInformationMap to delete from core
+ */
+ public Map<String, DeviceInformation> deviceInformationMapToDelete() {
+ return deviceInformationMapToDelete;
+ }
+
+ /**
+ * Sets device information for removal.
+ *
+ * @param key ket used to add in map
+ * @param deviceInformationMapToDelete map from device information to remove
+ */
+ public void setDeviceInformationMapToDelete(String key, DeviceInformation deviceInformationMapToDelete) {
+ if (deviceInformationMapToDelete != null) {
+ this.deviceInformationMapToDelete.put(key, deviceInformationMapToDelete);
+ }
+ }
+
+ /**
+ * Removes Device Information.
+ *
+ * @param key ket used to remove from map
+ */
+ public void removeDeviceInformationMapFromDeleteMap(String key) {
+ removeDeviceInformationMap(key);
+ if (this.deviceInformationMapToDelete.containsKey(key)) {
+ this.deviceInformationMapToDelete.remove(key);
+ }
+ }
+
+ /**
+ * Gets Device Information.
+ *
+ * @param key system id as key to store in map
+ * @return Device Information
+ */
+ public DeviceInformation deviceInformation(String key) {
+ DeviceInformation deviceInformation = this.deviceInformationMap.get(key);
+ return deviceInformation;
+ }
+
+ /**
+ * Removes Device Information from map.
+ *
+ * @param key key used to remove from map
+ */
+ public void removeDeviceInformationMap(String key) {
+ if (this.deviceInformationMap.containsKey(key)) {
+ this.deviceInformationMap.remove(key);
+ }
+ }
+
+ @Override
+ public void removeLinks(String linkId) {
+ this.addedLinkInformationMap.remove(linkId);
+ }
+
+ /**
+ * Gets link information as map.
+ *
+ * @return link information as map
+ */
+ public Map<String, LinkInformation> linkInformationMap() {
+ return addedLinkInformationMap;
+ }
+
+ private LinkInformation getLinkInformation(String key) {
+ LinkInformation linkInformation = this.addedLinkInformationMap.get(key);
+ return linkInformation;
+ }
+
+ /**
+ * Sets link information in map.
+ *
+ * @param key key used to add in map
+ * @param linkInformationMap link information instance
+ */
+ public void setLinkInformationMap(String key, LinkInformation linkInformationMap) {
+ if (!this.addedLinkInformationMap.containsKey(key)) {
+ this.addedLinkInformationMap.put(key, linkInformationMap);
+ }
+ }
+
+ /**
+ * Gets linkInformation as map for PointToPoint.
+ *
+ * @return linkInformationMap
+ */
+ public Map<String, LinkInformation> linkInformationMapForPointToPoint() {
+ return addedLinkInformationMap;
+ }
+
+ /**
+ * Sets linkInformation as map for PointToPoint.
+ *
+ * @param key key used to add in map
+ * @param linkInformationMap link information instance
+ */
+ public void setLinkInformationMapForPointToPoint(String key, LinkInformation linkInformationMap) {
+ if (!this.addedLinkInformationMap.containsKey(key)) {
+ this.addedLinkInformationMap.put(key, linkInformationMap);
+ }
+ }
+
+ /**
+ * Removes Link Information from linkInformationMap.
+ *
+ * @param key key used to remove in map
+ */
+ public void removeLinkInformationMap(String key) {
+ if (this.addedLinkInformationMap.containsKey(key)) {
+ this.addedLinkInformationMap.remove(key);
+ }
+ }
+
+ /**
+ * Creates Device and Link instance.
+ *
+ * @param lsPdu ISIS LSPDU instance
+ *
+ */
+
+ /**
+ * Creates Device instance.
+ *
+ * @param lsPdu ISIS LSPDU instance
+ * @return isisRouter isisRouter instance
+ */
+ public IsisRouter createDeviceInfo(LsPdu lsPdu) {
+ IsisRouter isisRouter = createIsisRouter(lsPdu);
+
+ if (isisRouter.systemId() != null) {
+ if (isisRouter.interfaceId() == null && isisRouter.neighborRouterId() == null) {
+ isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
+ isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
+ isisRouterDetails.put(isisRouter.systemId(), isisRouter);
+ }
+ }
+ return isisRouter;
+ }
+
+ /**
+ * Removes Device and Link instance.
+ *
+ * @param lsPdu ISIS LSPDU instance
+ * @return isisRouter isisRouter instance
+ */
+ public IsisRouter removeDeviceAndLinkInfo(LsPdu lsPdu) {
+ IsisRouter isisRouter = createIsisRouter(lsPdu);
+ return isisRouter;
+ }
+
+ /**
+ * Creates link information.
+ *
+ * @param lsPdu ls pdu instance
+ * @param ownSystemId system ID
+ * @return link information
+ */
+ public Map<String, LinkInformation> createLinkInfo(LsPdu lsPdu, String ownSystemId) {
+ for (IsisTlv isisTlv : lsPdu.tlvs()) {
+ if (isisTlv instanceof IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighborForExtendedIsList = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs neighbor : neighborForExtendedIsList) {
+ String neighbourId = neighbor.neighborId();
+ String routerId = IsisUtil.removeTailingZeros(lsPdu.lspId());
+ if (!(neighbourId.equals(ownSystemId))) {
+ IsisRouter isisRouter = isisRouterDetails.get(neighbourId);
+ if (isisRouter != null) {
+ String linkId = "link:" + routerId + "-" + neighbourId;
+ addedLinkInformationMap.put(linkId, createLinkInformation(lsPdu, linkId,
+ routerId, neighbourId));
+ } else {
+ createIsisRouterDummy(neighbourId);
+ String linkId = "link:" + routerId + "-" + neighbourId;
+ LinkInformation linkInformation = createLinkInformation(lsPdu, linkId,
+ routerId, neighbourId);
+ linkInformation.setAlreadyCreated(true);
+ addedLinkInformationMap.put(linkId, linkInformation);
+ }
+ }
+
+ }
+ }
+ }
+ return addedLinkInformationMap;
+ }
+
+ /**
+ * Removes link information.
+ *
+ * @param lsPdu ls pdu instance
+ * @return updated link information
+ */
+ public Map<String, LinkInformation> removeLinkInfo(LsPdu lsPdu) {
+ String lspId = lsPdu.lspId();
+ for (String key : addedLinkInformationMap.keySet()) {
+ if (key.contains(lspId)) {
+ removeLinkInformationMap.put(key, addedLinkInformationMap.get(key));
+ }
+ }
+ return removeLinkInformationMap;
+ }
+
+ /**
+ * Creates link information.
+ *
+ * @param lsPdu link state pdu
+ * @param linkId link id
+ * @param localRouter local router system id
+ * @param neighborId destination router system id
+ * @return linkInformation instance
+ */
+ private LinkInformation createLinkInformation(LsPdu lsPdu, String linkId, String localRouter, String neighborId) {
+ LinkInformation linkInformation = new DefaultIsisLinkInformation();
+ IsisRouter isisRouter = isisRouterDetails.get(neighborId);
+ for (IsisTlv isisTlv : lsPdu.tlvs()) {
+ if (isisTlv instanceof IpExtendedReachabilityTlv) {
+ IpExtendedReachabilityTlv ipExtendedReachabilityTlv = (IpExtendedReachabilityTlv) isisTlv;
+ List<TrafficEngineeringSubTlv> trafEnginSubTlv = ipExtendedReachabilityTlv.teTlvs();
+ for (TrafficEngineeringSubTlv teTlv : trafEnginSubTlv) {
+ if (teTlv instanceof InterfaceIpAddress) {
+ InterfaceIpAddress localIpAddress = (InterfaceIpAddress) isisTlv;
+ linkInformation.setInterfaceIp(localIpAddress.localInterfaceIPAddress());
+ }
+
+ }
+ } else {
+ linkInformation.setInterfaceIp(IsisConstants.DEFAULTIP);
+ linkInformation.setNeighborIp(IsisConstants.DEFAULTIP);
+ }
+ }
+ linkInformation.setNeighborIp(IsisConstants.DEFAULTIP);
+ linkInformation.setLinkId(linkId);
+ linkInformation.setAlreadyCreated(false);
+ linkInformation.setLinkDestinationId(neighborId);
+ linkInformation.setLinkSourceId(localRouter);
+ return linkInformation;
+ }
+
+ /**
+ * Creates ISIS router instance.
+ *
+ * @param lsPdu lsp instance
+ * @return isisRouter instance
+ */
+ private IsisRouter createIsisRouter(LsPdu lsPdu) {
+ IsisRouter isisRouter = new DefaultIsisRouter();
+ if (IsisUtil.checkIsDis(lsPdu.lspId())) {
+ isisRouter.setDis(true);
+ } else {
+ isisRouter.setDis(false);
+ }
+ isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId()));
+ for (IsisTlv isisTlv : lsPdu.tlvs()) {
+ if (isisTlv instanceof IpExtendedReachabilityTlv) {
+ IpExtendedReachabilityTlv ipExtendedReachabilityTlv = (IpExtendedReachabilityTlv) isisTlv;
+ List<TrafficEngineeringSubTlv> trafEnginSubTlv = ipExtendedReachabilityTlv.teTlvs();
+ for (TrafficEngineeringSubTlv teTlv : trafEnginSubTlv) {
+ if (teTlv instanceof InterfaceIpAddress) {
+ InterfaceIpAddress localIpAddress = (InterfaceIpAddress) isisTlv;
+ isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress());
+ }
+ if (teTlv instanceof NeighborIpAddress) {
+ NeighborIpAddress neighborIpAddress = (NeighborIpAddress) isisTlv;
+ isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress());
+ }
+ }
+ } else {
+ log.info("Invalid TLV");
+ }
+ }
+ return isisRouter;
+ }
+
+ /**
+ * Creates ISIS router instance.
+ *
+ * @param systemId system ID
+ * @return isisRouter instance
+ */
+ private IsisRouter createIsisRouterDummy(String systemId) {
+ IsisRouter isisRouter = new DefaultIsisRouter();
+ isisRouter.setSystemId(systemId);
+ isisRouter.setDis(false);
+ isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
+ isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
+ return isisRouter;
+ }
+
+ /**
+ * Creates the ISIS link TED information.
+ *
+ * @param lsPdu link state PDU
+ * @return isisLinkTed
+ */
+ public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) {
+ IsisLinkTed isisLinkTed = new DefaultIsisLinkTed();
+ for (IsisTlv isisTlv : lsPdu.tlvs()) {
+ if (isisTlv instanceof IpExtendedReachabilityTlv) {
+ IpExtendedReachabilityTlv ipExtendedReachabilityTlv = (IpExtendedReachabilityTlv) isisTlv;
+ List<TrafficEngineeringSubTlv> trafficEngSubTlv = ipExtendedReachabilityTlv.teTlvs();
+ for (TrafficEngineeringSubTlv teTlv : trafficEngSubTlv) {
+ if (teTlv instanceof AdministrativeGroup) {
+ AdministrativeGroup ag = (AdministrativeGroup) isisTlv;
+ isisLinkTed.setAdministrativeGroup(ag.administrativeGroup());
+ }
+ if (teTlv instanceof TrafficEngineeringMetric) {
+ TrafficEngineeringMetric teM = (TrafficEngineeringMetric) isisTlv;
+ isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue());
+ }
+ if (teTlv instanceof MaximumReservableBandwidth) {
+ MaximumReservableBandwidth reservableBw = (MaximumReservableBandwidth) isisTlv;
+ isisLinkTed.setMaximumReservableLinkBandwidth(
+ Bandwidth.bps(reservableBw.getMaximumBandwidthValue()));
+ }
+ }
+ } else {
+ log.debug("TLV type not supported");
+ }
+ }
+ return isisLinkTed;
+ }
+}
\ No newline at end of file
diff --git a/providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/package-info.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java
similarity index 82%
copy from providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/package-info.java
copy to protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java
index eb8d960..f9b4c0c 100644
--- a/providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/package-info.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java
@@ -15,6 +15,6 @@
*/
/**
- * Provider that uses ISIS request as a means of infrastructure device discovery.
+ * Implementation of the ISIS controller topology.
*/
-package org.onosproject.provider.isis.device.impl;
\ No newline at end of file
+package org.onosproject.isis.controller.impl.topology;
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/LsPdu.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/LsPdu.java
index b7c40a3..971f9a1 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/LsPdu.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/LsPdu.java
@@ -90,7 +90,6 @@
/**
* Creates an instance of Link State packet.
- * Parameterized constructor which populate
*
* @param isisHeader isis header details
*/
@@ -99,6 +98,15 @@
}
/**
+ * Returns the ISIS tlvs.
+ *
+ * @return tlvs
+ */
+ public List<IsisTlv> tlvs() {
+ return this.variableLengths;
+ }
+
+ /**
* Adds the isis tlv to the list for the link state PDU.
*
* @param isisTlv isis tlv
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlv.java
index 90b79cc..649b2dc 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlv.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IpExtendedReachabilityTlv.java
@@ -52,6 +52,15 @@
}
/**
+ * Returns list of traffic engineering sub tlvs.
+ *
+ * @return trafEnginSubTlv
+ */
+ public List<TrafficEngineeringSubTlv> teTlvs() {
+ return this.trafEnginSubTlv;
+ }
+
+ /**
* Returns the prefix of IP external reachability TLV.
*
* @return prefix
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsExtendedReachability.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsExtendedReachability.java
index d8e75b1..2028a35 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsExtendedReachability.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/IsExtendedReachability.java
@@ -41,6 +41,15 @@
}
/**
+ * Returns neighbor list.
+ *
+ * @return neighbor list
+ */
+ public List<NeighborForExtendedIs> neighbours() {
+ return neighbors;
+ }
+
+ /**
* Adds the neighbor for extended IS instance to IS extended reachability TLV.
*
* @param neighbor neighbor for extended IS instance
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddress.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddress.java
index cc6174f..e9b0a95 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddress.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddress.java
@@ -1,18 +1,18 @@
/*
- * 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.
- */
+* 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.isis.io.isispacket.tlv.subtlv;
import com.google.common.base.MoreObjects;
@@ -32,8 +32,8 @@
*/
public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringSubTlv {
private static final Logger log =
- LoggerFactory.getLogger(InterfaceIpAddress.class);
- private List<Ip4Address> localInterfaceIPAddress = new ArrayList<>();
+ LoggerFactory.getLogger(NeighborIpAddress.class);
+ private Ip4Address localInterfaceIPAddress;
/**
* Creates an instance of local interface ip address.
@@ -50,16 +50,16 @@
*
* @param localAddress ip address
*/
- public void addLocalInterfaceIPAddress(Ip4Address localAddress) {
- localInterfaceIPAddress.add(localAddress);
+ public void setIpAddress(Ip4Address localAddress) {
+ this.localInterfaceIPAddress = localAddress;
}
/**
- * Returns local interface ip address.
+ * Gets local interface ip address.
*
* @return localAddress ip address
*/
- public List<Ip4Address> getLocalInterfaceIPAddress() {
+ public Ip4Address localInterfaceIPAddress() {
return localInterfaceIPAddress;
}
@@ -72,17 +72,19 @@
while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) {
byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES];
channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
- this.addLocalInterfaceIPAddress(Ip4Address.valueOf(tempByteArray));
+ this.setIpAddress(Ip4Address.valueOf(tempByteArray));
+
}
}
/**
- * Returns local interface ip address as byte array.
+ * Gets local interface ip address as byte array.
*
* @return local interface ip address as byte array
*/
public byte[] asBytes() {
byte[] linkSubType = null;
+
byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
byte[] linkSubTlvBody = tlvBodyAsBytes();
linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
@@ -91,15 +93,16 @@
}
/**
- * Returns byte array of local interface ip address.
+ * Gets byte array of local interface ip address.
*
* @return byte array of local interface ip address
*/
public byte[] tlvBodyAsBytes() {
+
List<Byte> linkSubTypeBody = new ArrayList<>();
- for (Ip4Address remoteAddress : this.localInterfaceIPAddress) {
- linkSubTypeBody.addAll(Bytes.asList(remoteAddress.toOctets()));
- }
+
+ linkSubTypeBody.addAll(Bytes.asList(this.localInterfaceIPAddress.toOctets()));
+
return Bytes.toArray(linkSubTypeBody);
}
@@ -111,4 +114,4 @@
.add("localInterfaceIPAddress", localInterfaceIPAddress)
.toString();
}
-}
+}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/NeighborIpAddress.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/NeighborIpAddress.java
new file mode 100644
index 0000000..72eb3a9
--- /dev/null
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/NeighborIpAddress.java
@@ -0,0 +1,135 @@
+/*
+* 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.isis.io.isispacket.tlv.subtlv;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.primitives.Bytes;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.isis.io.isispacket.tlv.TlvHeader;
+import org.onosproject.isis.io.util.IsisUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Representation of neighbor ip address TE value.
+ */
+public class NeighborIpAddress extends TlvHeader implements TrafficEngineeringSubTlv {
+ private static final Logger log =
+ LoggerFactory.getLogger(NeighborIpAddress.class);
+ private Ip4Address neighborIPAddress;
+
+ /**
+ * Creates an instance of neighbor ip address.
+ *
+ * @param header tlv header instance
+ */
+ public NeighborIpAddress(TlvHeader header) {
+ this.setTlvType(header.tlvType());
+ this.setTlvLength(header.tlvLength());
+ }
+
+ /**
+ * Sets the neighbor ip address.
+ *
+ * @param neighborIPAddress ip address
+ */
+ public void setIpAddress(Ip4Address neighborIPAddress) {
+ this.neighborIPAddress = neighborIPAddress;
+ }
+
+ /**
+ * Gets the neighbor ip address.
+ *
+ * @return neighbor ip address
+ */
+ public Ip4Address neighborIPAddress() {
+ return neighborIPAddress;
+ }
+
+ /**
+ * Reads bytes from channel buffer.
+ *
+ * @param channelBuffer channel buffer instance
+ */
+ public void readFrom(ChannelBuffer channelBuffer) {
+ while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) {
+ byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES];
+ channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
+ this.setIpAddress(Ip4Address.valueOf(tempByteArray));
+
+ }
+ }
+
+ /**
+ * Gets the neighbor ip address as byte array.
+ *
+ * @return neighbor ip address as byte array
+ */
+ public byte[] asBytes() {
+ byte[] linkSubType = null;
+
+ byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
+ byte[] linkSubTlvBody = tlvBodyAsBytes();
+ linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
+
+ return linkSubType;
+ }
+
+ /**
+ * Gets byte array of neighborIPAddress.
+ *
+ * @return byte array of neighborIPAddress
+ */
+ public byte[] tlvBodyAsBytes() {
+
+ List<Byte> linkSubTypeBody = new ArrayList<>();
+
+ linkSubTypeBody.addAll(Bytes.asList(this.neighborIPAddress.toOctets()));
+
+
+ return Bytes.toArray(linkSubTypeBody);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ NeighborIpAddress that = (NeighborIpAddress) o;
+ return Objects.equal(neighborIPAddress, that.neighborIPAddress);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(neighborIPAddress);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("localInterfaceIPAddress", neighborIPAddress)
+ .toString();
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinder.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinder.java
index 92ea143..b18f69c 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinder.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvFinder.java
@@ -67,7 +67,7 @@
subTlv = unreservedBandwidth;
break;
case INTERFACEADDRESS:
- InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
+ NeighborIpAddress ipInterfaceAddressTlv = new NeighborIpAddress(tlvHeader);
ipInterfaceAddressTlv.readFrom(channelBuffer);
subTlv = ipInterfaceAddressTlv;
break;
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java
index 8b41c4b..5c20a00 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java
@@ -60,8 +60,8 @@
} else if (subTlv instanceof UnreservedBandwidth) {
UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) subTlv;
subTlvBytes.addAll(Bytes.asList(unreservedBandwidth.asBytes()));
- } else if (subTlv instanceof InterfaceIpAddress) {
- InterfaceIpAddress interfaceIpAddress = (InterfaceIpAddress) subTlv;
+ } else if (subTlv instanceof NeighborIpAddress) {
+ NeighborIpAddress interfaceIpAddress = (NeighborIpAddress) subTlv;
subTlvBytes.addAll(Bytes.asList(interfaceIpAddress.asBytes()));
} else {
log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes ");
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvType.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvType.java
index 5caecbf..027a50e 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvType.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvType.java
@@ -44,6 +44,10 @@
*/
INTERFACEADDRESS(6),
/**
+ * Represents traffic engineering neighbor address TLV.
+ */
+ NEIGHBORADDRESS(8),
+ /**
* Represents traffic engineering unreserved bandwidth TLV.
*/
UNRESERVEDBANDWIDTH(11);
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
index 9156eb4..f7eb99a 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisConstants.java
@@ -65,6 +65,9 @@
public static final String AREAADDRESS = "areaAddress";
public static final String HOLDINGTIME = "holdingTime";
public static final String HELLOINTERVAL = "helloInterval";
+ public static final int PORT = 7000;
+ public static final String LSPADDED = "LSP_ADDED";
+ public static final String LSPREMOVED = "LSP_REMOVED";
/**
* Non parameterized constructor.
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
index cfd941e..80bd083 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/util/IsisUtil.java
@@ -726,4 +726,37 @@
}
return Bytes.toArray(byteList);
}
+
+ /**
+ * Return the DIS value from the systemId.
+ *
+ * @param systemId system Id.
+ * @return return true if DIS else false
+ */
+ public static boolean checkIsDis(String systemId) {
+ StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-");
+ int count = 0;
+ while (stringTokenizer.hasMoreTokens()) {
+ String str = stringTokenizer.nextToken();
+ if (count == 3) {
+ int x = Integer.parseInt(str);
+ if (x > 0) {
+ return true;
+ }
+ }
+ count++;
+ }
+ return false;
+ }
+
+ /**
+ * Return the systemId.
+ *
+ * @param systemId system Id.
+ * @return return system ID
+ */
+ public static String removeTailingZeros(String systemId) {
+ StringTokenizer stringTokenizer = new StringTokenizer(systemId, "-");
+ return stringTokenizer.nextToken();
+ }
}
\ No newline at end of file
diff --git a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java
index 5acb728..5019fe1 100644
--- a/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java
+++ b/protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/subtlv/InterfaceIpAddressTest.java
@@ -33,7 +33,7 @@
public class InterfaceIpAddressTest {
private final byte[] packet = {1, 1, 1, 1};
private final byte[] packet1 = {};
- private InterfaceIpAddress interfaceIpAddress;
+ private NeighborIpAddress interfaceIpAddress;
private TlvHeader tlvHeader;
private Ip4Address ip4Address = Ip4Address.valueOf("1.1.1.1");
private byte[] result;
@@ -41,7 +41,7 @@
@Before
public void setUp() throws Exception {
- interfaceIpAddress = new InterfaceIpAddress(new TlvHeader());
+ interfaceIpAddress = new NeighborIpAddress(new TlvHeader());
}
@After
@@ -61,15 +61,6 @@
}
/**
- * Tests addLocalInterfaceIPAddress() method.
- */
- @Test
- public void testAddLocalInterfaceIPAddress() throws Exception {
- interfaceIpAddress.addLocalInterfaceIPAddress(ip4Address);
- assertThat(interfaceIpAddress, is(notNullValue()));
- }
-
- /**
* Tests readFrom() method.
*/
@Test
@@ -77,7 +68,7 @@
tlvHeader = new TlvHeader();
tlvHeader.setTlvType(3);
tlvHeader.setTlvLength(4);
- interfaceIpAddress = new InterfaceIpAddress(tlvHeader);
+ interfaceIpAddress = new NeighborIpAddress(tlvHeader);
channelBuffer = ChannelBuffers.copiedBuffer(packet);
interfaceIpAddress.readFrom(channelBuffer);
assertThat(interfaceIpAddress, is(notNullValue()));
@@ -91,27 +82,11 @@
tlvHeader = new TlvHeader();
tlvHeader.setTlvType(3);
tlvHeader.setTlvLength(4);
- interfaceIpAddress = new InterfaceIpAddress(tlvHeader);
+ interfaceIpAddress = new NeighborIpAddress(tlvHeader);
channelBuffer = ChannelBuffers.copiedBuffer(packet1);
interfaceIpAddress.readFrom(channelBuffer);
assertThat(interfaceIpAddress, is(notNullValue()));
}
- /**
- * Tests asBytes() method.
- */
- @Test
- public void testAsBytes() throws Exception {
- result = interfaceIpAddress.asBytes();
- assertThat(result, is(notNullValue()));
- }
- /**
- * Tests getLinkSubTypeTlvBodyAsByteArray() method.
- */
- @Test
- public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
- result = interfaceIpAddress.tlvBodyAsBytes();
- assertThat(result, is(notNullValue()));
- }
}
\ No newline at end of file
diff --git a/providers/isis/BUCK b/providers/isis/BUCK
index 1663d60..adc7a6f 100644
--- a/providers/isis/BUCK
+++ b/providers/isis/BUCK
@@ -3,7 +3,7 @@
'//protocols/isis/ctl:onos-protocols-isis-ctl',
'//protocols/isis/isisio:onos-protocols-isis-isisio',
'//providers/isis/cfg:onos-providers-isis-cfg',
- '//providers/isis/device:onos-providers-isis-device',
+ '//providers/isis/topology:onos-providers-isis-topology',
]
onos_app (
diff --git a/providers/isis/app/app.xml b/providers/isis/app/app.xml
index 3158848..c07a454 100644
--- a/providers/isis/app/app.xml
+++ b/providers/isis/app/app.xml
@@ -21,6 +21,7 @@
<artifact>mvn:${project.groupId}/onos-isis-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-isis-isisio/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-isis-ctl/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-isis-provider-device/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-isis-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-isis-provider-cli/${project.version}</artifact>
</app>
\ No newline at end of file
diff --git a/providers/isis/app/features.xml b/providers/isis/app/features.xml
index 132bcda..d4a13cc 100644
--- a/providers/isis/app/features.xml
+++ b/providers/isis/app/features.xml
@@ -15,13 +15,15 @@
~ limitations under the License.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
+ <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/onos-isis-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-isis-isisio/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-isis-ctl/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-isis-provider-device/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-isis-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-isis-provider-cfg/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-isis-provider-cli/${project.version}</bundle>
</feature>
-</features>
+</features>
\ No newline at end of file
diff --git a/providers/isis/app/pom.xml b/providers/isis/app/pom.xml
index b0c0aa0..9f15602 100644
--- a/providers/isis/app/pom.xml
+++ b/providers/isis/app/pom.xml
@@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
- <artifactId>onos-isis-provider-device</artifactId>
+ <artifactId>onos-isis-provider-topology</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -57,5 +57,10 @@
<artifactId>onos-isis-provider-cfg</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-isis-provider-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
diff --git a/providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/IsisTopologyProvider.java b/providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/IsisTopologyProvider.java
deleted file mode 100644
index 5557429..0000000
--- a/providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/IsisTopologyProvider.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.provider.isis.device.impl;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onosproject.isis.controller.IsisController;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-import org.slf4j.Logger;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provider which advertises device descriptions to the core.
- */
-@Component(immediate = true)
-public class IsisTopologyProvider extends AbstractProvider {
-
- private static final Logger log = getLogger(IsisTopologyProvider.class);
- final InternalDeviceProvider listener = new InternalDeviceProvider();
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- private IsisController isisController;
-
-
- /**
- * Creates an ISIS device provider.
- */
- public IsisTopologyProvider() {
- super(new ProviderId("isis", "org.onosproject.provider.isis"));
- }
-
- @Activate
- public void activate() {
- log.debug("Activate...!!!");
- }
-
- @Deactivate
- public void deactivate() {
- log.debug("Deactivate...!!!");
- }
-
- /**
- * Internal device provider implementation.
- */
- private class InternalDeviceProvider {
-
- }
-}
diff --git a/providers/isis/pom.xml b/providers/isis/pom.xml
index c6968ac..20801dd28 100644
--- a/providers/isis/pom.xml
+++ b/providers/isis/pom.xml
@@ -32,10 +32,10 @@
<description>ONOS ISIS protocol adapters</description>
<modules>
- <module>device</module>
<module>app</module>
<module>cfg</module>
<module>cli</module>
+ <module>topology</module>
</modules>
<dependencies>
diff --git a/providers/isis/device/BUCK b/providers/isis/topology/BUCK
similarity index 100%
rename from providers/isis/device/BUCK
rename to providers/isis/topology/BUCK
diff --git a/providers/isis/device/pom.xml b/providers/isis/topology/pom.xml
similarity index 96%
rename from providers/isis/device/pom.xml
rename to providers/isis/topology/pom.xml
index 9576791..106386c 100644
--- a/providers/isis/device/pom.xml
+++ b/providers/isis/topology/pom.xml
@@ -26,7 +26,7 @@
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>onos-isis-provider-device</artifactId>
+ <artifactId>onos-isis-provider-topology</artifactId>
<packaging>bundle</packaging>
<description>ONOS ISIS Providers</description>
diff --git a/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProvider.java b/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProvider.java
new file mode 100644
index 0000000..8a58289
--- /dev/null
+++ b/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/IsisTopologyProvider.java
@@ -0,0 +1,322 @@
+/*
+ * 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.provider.isis.topology.impl;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onlab.packet.ChassisId;
+import org.onlab.util.Bandwidth;
+import org.onosproject.isis.controller.IsisController;
+import org.onosproject.isis.controller.topology.IsisLink;
+import org.onosproject.isis.controller.topology.IsisLinkListener;
+import org.onosproject.isis.controller.topology.IsisLinkTed;
+import org.onosproject.isis.controller.topology.IsisRouter;
+import org.onosproject.isis.controller.topology.IsisRouterId;
+import org.onosproject.isis.controller.topology.IsisRouterListener;
+import org.onosproject.net.AnnotationKeys;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.config.basics.BandwidthCapacity;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceProvider;
+import org.onosproject.net.device.DeviceProviderRegistry;
+import org.onosproject.net.device.DeviceProviderService;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.link.DefaultLinkDescription;
+import org.onosproject.net.link.LinkDescription;
+import org.onosproject.net.link.LinkProvider;
+import org.onosproject.net.link.LinkProviderRegistry;
+import org.onosproject.net.link.LinkProviderService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Provider which advertises device descriptions to the core.
+ */
+@Component(immediate = true)
+public class IsisTopologyProvider extends AbstractProvider implements DeviceProvider, LinkProvider {
+
+ public static final long PSEUDO_PORT = 0xffffffff;
+ public static final String ADMINISTRATIVEGROUP = "administrativeGroup";
+ public static final String TE_METRIC = "teMetric";
+ public static final String MAXRESERVABLEBANDWIDTH = "maxReservableBandwidth";
+ public static final String ROUTERID = "routerId";
+ public static final String NEIGHBORID = "neighborId";
+ private static final Logger log = getLogger(IsisTopologyProvider.class);
+ // Default values for tunable parameters
+ private static final String UNKNOWN = "unknown";
+ final InternalTopologyProvider listener = new InternalTopologyProvider();
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceProviderRegistry deviceProviderRegistry;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LinkProviderRegistry linkProviderRegistry;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigService networkConfigService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected IsisController controller;
+ //This Interface that defines how this provider can interact with the core.
+ private LinkProviderService linkProviderService;
+ // The interface that defines how this Provider can interact with the core
+ private DeviceProviderService deviceProviderService;
+ private HashMap<DeviceId, List<PortDescription>> portMap = new HashMap<>();
+
+ /**
+ * Creates an ISIS device provider.
+ */
+ public IsisTopologyProvider() {
+ super(new ProviderId("l3", "org.onosproject.provider.isis"));
+ }
+
+ @Activate
+ public void activate() {
+ deviceProviderService = deviceProviderRegistry.register(this);
+ linkProviderService = linkProviderRegistry.register(this);
+ controller.addRouterListener(listener);
+ controller.addLinkListener(listener);
+ log.debug("IsisDeviceProvider::activate...!!!!");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.debug("IsisDeviceProvider::deactivate...!!!!");
+ deviceProviderRegistry.unregister(this);
+ deviceProviderService = null;
+ linkProviderRegistry.unregister(this);
+ linkProviderService = null;
+ controller.removeRouterListener(listener);
+ controller.removeLinkListener(listener);
+ }
+
+ @Override
+ public void triggerProbe(DeviceId deviceId) {
+ log.debug("IsisDeviceProvider::triggerProbe...!!!!");
+ }
+
+ @Override
+ public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
+ log.debug("IsisDeviceProvider::roleChanged...!!!!");
+ }
+
+ @Override
+ public boolean isReachable(DeviceId deviceId) {
+ log.debug("IsisDeviceProvider::isReachable...!!!!");
+ return false;
+ }
+
+ @Override
+ public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) {
+ log.debug("IsisDeviceProvider::changePortState...!!!!");
+ }
+
+ /**
+ * Builds link description.
+ *
+ * @param isisLink ISIS link instance
+ * @return link description
+ */
+ private LinkDescription buildLinkDes(IsisLink isisLink) {
+ long srcAddress = 0;
+ long dstAddress = 0;
+ String localSystemId = isisLink.localSystemId();
+ String remoteSystemId = isisLink.remoteSystemId();
+ //Changing of port numbers
+ srcAddress = isisLink.interfaceIp().toInt();
+ dstAddress = isisLink.neighborIp().toInt();
+ DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId));
+ DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId));
+ if (srcAddress == 0) {
+ srcAddress = PSEUDO_PORT;
+ } else if (dstAddress == 0) {
+ dstAddress = PSEUDO_PORT;
+ }
+
+ ConnectPoint src = new ConnectPoint(srcId, PortNumber.portNumber(srcAddress));
+ ConnectPoint dst = new ConnectPoint(dstId, PortNumber.portNumber(dstAddress));
+ DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
+ if (isisLink != null) {
+ annotationBuilder = buildAnnotations(annotationBuilder, isisLink);
+ }
+
+ return new DefaultLinkDescription(src, dst, Link.Type.DIRECT, false, annotationBuilder.build());
+ }
+
+ /**
+ * Builds port description.
+ *
+ * @param deviceId device ID for the port
+ * @param portNumber port number of the link
+ * @return list of port description
+ */
+ private List<PortDescription> buildPortDescriptions(DeviceId deviceId,
+ PortNumber portNumber) {
+
+ List<PortDescription> portList;
+
+ if (portMap.containsKey(deviceId)) {
+ portList = portMap.get(deviceId);
+ } else {
+ portList = new ArrayList<>();
+ }
+ if (portNumber != null) {
+ PortDescription portDescriptions = new DefaultPortDescription(portNumber, true);
+ portList.add(portDescriptions);
+ }
+
+ portMap.put(deviceId, portList);
+ return portList;
+ }
+
+ /**
+ * Builds the annotation details.
+ *
+ * @param annotationBuilder default annotation builder instance
+ * @param isisLink ISIS link instance
+ * @return annotation builder instance
+ */
+ private DefaultAnnotations.Builder buildAnnotations(DefaultAnnotations.Builder annotationBuilder,
+ IsisLink isisLink) {
+ int administrativeGroup = 0;
+ long teMetric = 0;
+ Bandwidth maxReservableBandwidth = Bandwidth.bps(0);
+ String routerId = null;
+ String neighborId = null;
+
+ //TE Info
+ IsisLinkTed isisLinkTed = isisLink.linkTed();
+ administrativeGroup = isisLinkTed.administrativeGroup();
+ teMetric = isisLinkTed.teDefaultMetric();
+ maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth();
+ routerId = isisLink.localSystemId();
+ neighborId = isisLink.remoteSystemId();
+ annotationBuilder.set(ADMINISTRATIVEGROUP, String.valueOf(administrativeGroup));
+ annotationBuilder.set(TE_METRIC, String.valueOf(teMetric));
+ annotationBuilder.set(MAXRESERVABLEBANDWIDTH, String.valueOf(maxReservableBandwidth));
+ annotationBuilder.set(ROUTERID, String.valueOf(routerId));
+ annotationBuilder.set(NEIGHBORID, String.valueOf(neighborId));
+ return annotationBuilder;
+ }
+
+ /**
+ * Internal device provider implementation.
+ */
+ private class InternalTopologyProvider implements IsisRouterListener, IsisLinkListener {
+
+ @Override
+ public void routerAdded(IsisRouter isisRouter) {
+ String systemId = isisRouter.systemId();
+ log.info("Added device {}", systemId);
+ DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId));
+ Device.Type deviceType = Device.Type.ROUTER;
+ //If our routerType is Dr or Bdr type is PSEUDO
+ if (isisRouter.isDis()) {
+ deviceType = Device.Type.ROUTER;
+ } else {
+ deviceType = Device.Type.VIRTUAL;
+ }
+ ChassisId cId = new ChassisId();
+ DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
+ newBuilder.set(AnnotationKeys.TYPE, "L3");
+ newBuilder.set("RouterId", systemId);
+ DeviceDescription description =
+ new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
+ UNKNOWN, cId, newBuilder.build());
+ deviceProviderService.deviceConnected(deviceId, description);
+ }
+
+ @Override
+ public void routerRemoved(IsisRouter isisRouter) {
+ String systemId = isisRouter.systemId();
+ log.info("Delete device {}", systemId);
+ DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId));
+ if (deviceProviderService == null) {
+ return;
+ }
+ deviceProviderService.deviceDisconnected(deviceId);
+ log.info("delete device {}", systemId);
+ }
+
+ @Override
+ public void addLink(IsisLink isisLink) {
+ log.debug("Addlink {}", isisLink.localSystemId());
+ if (linkProviderService == null) {
+ return;
+ }
+ LinkDescription linkDes = buildLinkDes(isisLink);
+ //Updating ports of the link
+ deviceProviderService.updatePorts(linkDes.src().deviceId(), buildPortDescriptions(linkDes.src().deviceId(),
+ linkDes.src().port()));
+ deviceProviderService.updatePorts(linkDes.dst().deviceId(), buildPortDescriptions(linkDes.dst().deviceId(),
+ linkDes.dst().port()));
+ registerBandwidth(linkDes, isisLink);
+ linkProviderService.linkDetected(linkDes);
+ }
+
+ @Override
+ public void deleteLink(IsisLink isisLink) {
+ log.debug("Delete link {}", isisLink.localSystemId());
+ if (linkProviderService == null) {
+ return;
+ }
+ LinkDescription linkDes = buildLinkDes(isisLink);
+ linkProviderService.linkVanished(linkDes);
+ }
+
+ /**
+ * Registers the bandwidth for source and destination points.
+ *
+ * @param linkDes link description instance
+ * @param isisLink ISIS link instance
+ */
+ private void registerBandwidth(LinkDescription linkDes, IsisLink isisLink) {
+ if (isisLink == null) {
+ log.error("Could not able to register bandwidth ");
+ return;
+ }
+ IsisLinkTed isisLinkTed = isisLink.linkTed();
+ Bandwidth maxReservableBw = isisLinkTed.maximumReservableLinkBandwidth();
+ if (maxReservableBw != null) {
+ if (maxReservableBw.compareTo(Bandwidth.bps(0)) == 0) {
+ return;
+ }
+ //Configure bandwidth for src and dst port
+ BandwidthCapacity config = networkConfigService.addConfig(linkDes.src(), BandwidthCapacity.class);
+ config.capacity(maxReservableBw).apply();
+
+ config = networkConfigService.addConfig(linkDes.dst(), BandwidthCapacity.class);
+ config.capacity(maxReservableBw).apply();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/package-info.java b/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/package-info.java
similarity index 92%
rename from providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/package-info.java
rename to providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/package-info.java
index eb8d960..886a345 100644
--- a/providers/isis/device/src/main/java/org/onosproject/provider/isis/device/impl/package-info.java
+++ b/providers/isis/topology/src/main/java/org/onosproject/provider/isis/topology/impl/package-info.java
@@ -17,4 +17,4 @@
/**
* Provider that uses ISIS request as a means of infrastructure device discovery.
*/
-package org.onosproject.provider.isis.device.impl;
\ No newline at end of file
+package org.onosproject.provider.isis.topology.impl;