ISIS protocol manual merge from 1.6 due to cherry pick merge conflict
Change-Id: I6c3abf6a83ddaeba76293dc7864fcec88e9b4e7e
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/DefaultIsisNeighbor.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
old mode 100644
new mode 100755
index 3e05a37..0839eb5
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
@@ -356,6 +356,8 @@
stopInactivityTimeCheck();
stopHoldingTimeCheck();
isisInterface.removeNeighbor(this);
+
+ isisInterface.isisLsdb().removeTopology(this, isisInterface);
}
/**
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 100755
index 0000000..8730814
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/LspEventConsumer.java
@@ -0,0 +1,354 @@
+/*
+* 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.onlab.packet.Ip4Address;
+import org.onlab.util.Bandwidth;
+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.DefaultIsisLinkInformation;
+import org.onosproject.isis.controller.impl.topology.DefaultIsisLinkTed;
+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.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.InterfaceIpAddress;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth;
+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.TrafficEngineeringSubTlv;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth;
+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.LinkedHashMap;
+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);
+ private BlockingQueue queue = null;
+ private Controller controller = null;
+ private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl();
+ private Map<String, IsisRouter> isisRouterDetails = new LinkedHashMap<>();
+
+ /**
+ * 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() {
+ try {
+ while (true) {
+ if (!queue.isEmpty()) {
+ LspWrapper wrapper = (LspWrapper) queue.take();
+ LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
+ if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) {
+ callTopologyToRemoveInfo(lsPdu);
+ } else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) {
+ callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(),
+ wrapper.isisInterface().systemId() + ".00");
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error::LspsForProvider::{}", e.getMessage());
+ }
+ }
+
+ /**
+ * Sends topology information to core.
+ *
+ * @param lsPdu ls pdu instance
+ * @param isisNetworkType ISIS network type
+ * @param ownSystemId own system ID
+ */
+ private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType,
+ String ownSystemId) {
+ if ((lsPdu.lspId().equals(ownSystemId + "-00"))) {
+ return;
+ }
+ sendDeviceInfo(createDeviceInfo(lsPdu));
+
+ for (IsisTlv isisTlv : lsPdu.tlvs()) {
+ if (isisTlv instanceof IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs teTlv : neighbours) {
+ String neighbor = teTlv.neighborId();
+ IsisRouter isisRouter = isisRouterDetails.get(neighbor);
+ if (isisRouter != null) {
+ IsisRouter sourceRouter = isisRouterDetails.get(IsisUtil.removeTailingZeros(lsPdu.lspId()));
+ IsisRouter destinationRouter = isisRouter;
+ if (sourceRouter.isDis()) {
+ LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(),
+ destinationRouter.systemId(),
+ sourceRouter.interfaceId(),
+ destinationRouter.interfaceId(), lsPdu);
+ controller.addLinkDetails(createIsisLink(linkInformation, lsPdu));
+ } else if (destinationRouter.isDis()) {
+ LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(),
+ sourceRouter.systemId(),
+ destinationRouter.interfaceId(),
+ sourceRouter.interfaceId(), lsPdu);
+ controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu));
+ } else {
+ LinkInformation linkInformation = createLinkInfo(sourceRouter.systemId(),
+ destinationRouter.systemId(),
+ sourceRouter.interfaceId(),
+ destinationRouter.interfaceId(), lsPdu);
+ controller.addLinkDetails(createIsisLink(linkInformation, lsPdu));
+ LinkInformation linkInformation1 = createLinkInfo(destinationRouter.systemId(),
+ sourceRouter.systemId(),
+ destinationRouter.interfaceId(),
+ sourceRouter.interfaceId(), lsPdu);
+ controller.addLinkDetails(createIsisLink(linkInformation1, lsPdu));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes topology information from core.
+ *
+ * @param lsPdu ls pdu instance
+ */
+ private void callTopologyToRemoveInfo(LsPdu lsPdu) {
+ String routerId = IsisUtil.removeTailingZeros(lsPdu.lspId());
+ IsisRouter isisRouter = isisRouterDetails.get(routerId);
+ removeDeviceInfo(isisRouter);
+ removeLinkInfo(lsPdu);
+ }
+
+ /**
+ * Sends the device information to topology provider.
+ *
+ * @param isisRouter ISIS router instance
+ */
+ private void sendDeviceInfo(IsisRouter isisRouter) {
+ if (isisRouter.systemId() != null) {
+ controller.addDeviceDetails(isisRouter);
+ }
+ }
+
+ /**
+ * 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) {
+ isisRouterDetails.put(isisRouter.systemId(), isisRouter);
+ }
+ return isisRouter;
+ }
+
+ /**
+ * 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 IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs teTlv : neighbours) {
+ List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
+ for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
+ if (teSubTlv instanceof InterfaceIpAddress) {
+ InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
+ isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress());
+ } else if (teSubTlv instanceof NeighborIpAddress) {
+ NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
+ isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress());
+ }
+
+ }
+ }
+ }
+ }
+ if (isisRouter.interfaceId() == null) {
+ isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
+ }
+ if (isisRouter.neighborRouterId() == null) {
+ isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
+ }
+ return isisRouter;
+ }
+
+ /**
+ * Creates link information.
+ *
+ * @param localSystemId local system ID
+ * @param remoteSystemId remote system ID
+ * @return link information
+ * @param interfaceIp interface address
+ * @param neighborIp neighbor address
+ * @param lsPdu link state PDU instance
+ * @return link information instance
+ */
+ public LinkInformation createLinkInfo(String localSystemId, String remoteSystemId,
+ Ip4Address interfaceIp, Ip4Address neighborIp,
+ LsPdu lsPdu) {
+
+ String linkId = "link:" + localSystemId + "-" + remoteSystemId;
+ LinkInformation linkInformation = new DefaultIsisLinkInformation();
+ linkInformation.setInterfaceIp(interfaceIp);
+ linkInformation.setNeighborIp(neighborIp);
+ linkInformation.setLinkId(linkId);
+ linkInformation.setAlreadyCreated(false);
+ linkInformation.setLinkDestinationId(remoteSystemId);
+ linkInformation.setLinkSourceId(localSystemId);
+
+ return linkInformation;
+ }
+
+ /**
+ * Removes the device information from topology provider.
+ *
+ * @param isisRouter ISIS router instance
+ */
+ private void removeDeviceInfo(IsisRouter isisRouter) {
+ if (isisRouter.systemId() != null) {
+ controller.removeDeviceDetails(isisRouter);
+ }
+ isisRouterDetails.remove(isisRouter.systemId());
+ }
+
+
+ /**
+ * Removes the link information from topology provider.
+ *
+ * @param lsPdu ls pdu instance
+ */
+ private void removeLinkInfo(LsPdu lsPdu) {
+ Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu.lspId());
+ 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(createIsisLinkTedInfo(lsPdu));
+ return isisLink;
+ }
+
+ /**
+ * 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 IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs teTlv : neighbours) {
+ List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
+ for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
+ if (teSubTlv instanceof AdministrativeGroup) {
+ AdministrativeGroup ag = (AdministrativeGroup) teSubTlv;
+ isisLinkTed.setAdministrativeGroup(ag.administrativeGroup());
+ }
+ if (teSubTlv instanceof InterfaceIpAddress) {
+ InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
+ isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress());
+ }
+ if (teSubTlv instanceof NeighborIpAddress) {
+ NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
+ isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress());
+ }
+ if (teSubTlv instanceof TrafficEngineeringMetric) {
+ TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv;
+ isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue());
+ }
+ if (teSubTlv instanceof MaximumBandwidth) {
+ MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv;
+ isisLinkTed.setMaximumLinkBandwidth(
+ Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue()));
+ }
+ if (teSubTlv instanceof MaximumReservableBandwidth) {
+ MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv;
+ isisLinkTed.setMaximumReservableLinkBandwidth(
+ Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue()));
+ }
+ if (teSubTlv instanceof UnreservedBandwidth) {
+ UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv;
+ List<Bandwidth> bandwidthList = new ArrayList<>();
+ List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue();
+ for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) {
+ Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue);
+ bandwidthList.add(bandwidth);
+ }
+ isisLinkTed.setUnreservedBandwidth(bandwidthList);
+ }
+ }
+ }
+ }
+ }
+ 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
old mode 100644
new mode 100755
index 3c66bf8..2062ccc
--- 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
@@ -21,17 +21,24 @@
import org.onosproject.isis.controller.IsisLsdbAge;
import org.onosproject.isis.controller.IsisLspBin;
import org.onosproject.isis.controller.IsisMessage;
+import org.onosproject.isis.controller.IsisNeighbor;
import org.onosproject.isis.controller.IsisPduType;
+import org.onosproject.isis.controller.IsisRouterType;
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 +50,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 +67,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 +127,6 @@
return lspKey.toString();
}
-
/**
* Returns the neighbor L1 database information.
*
@@ -215,7 +245,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 +266,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 +311,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 +376,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 +388,47 @@
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);
+ }
+ }
+
+ /**
+ * Removes topology information when neighbor down.
+ *
+ * @param neighbor ISIS neighbor instance
+ * @param isisInterface ISIS interface instance
+ */
+ public void removeTopology(IsisNeighbor neighbor, IsisInterface isisInterface) {
+ String lspKey = neighbor.neighborSystemId() + ".00-00";
+ LspWrapper lspWrapper = null;
+ switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
+ case L1:
+ lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey);
+ break;
+ case L2:
+ lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey);
+ break;
+ case L1L2:
+ lspWrapper = findLsp(IsisPduType.L1LSPDU, lspKey);
+ if (lspWrapper == null) {
+ lspWrapper = findLsp(IsisPduType.L2LSPDU, lspKey);
+ }
+ break;
+ default:
+ log.debug("Unknown type");
+ }
+ try {
+ if (lspWrapper != null) {
+ 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..6122c9a
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/DefaultIsisLinkTed.java
@@ -0,0 +1,145 @@
+/*
+ * 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.ArrayList;
+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 = new ArrayList<>();
+ 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..8682a4a
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/TopologyForDeviceAndLinkImpl.java
@@ -0,0 +1,490 @@
+/*
+* 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.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.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.AdministrativeGroup;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth;
+import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth;
+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.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<>();
+
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * Returns the ISIS router instance.
+ *
+ * @param systemId system ID to get router details
+ * @return ISIS router instance
+ */
+ public IsisRouter isisRouter(String systemId) {
+ String routerId = IsisUtil.removeTailingZeros(systemId);
+ IsisRouter isisRouter = isisRouterDetails.get(routerId);
+ if (isisRouter != null) {
+ return isisRouter;
+ } else {
+ log.debug("IsisRouter is not available");
+ IsisRouter isisRouterCheck = new DefaultIsisRouter();
+ isisRouterCheck.setSystemId(routerId);
+ return isisRouterCheck;
+ }
+ }
+
+ /**
+ * Removes the ISIS router instance from map.
+ *
+ * @param systemId system ID to remove router details
+ */
+ public void removeRouter(String systemId) {
+ String routerId = IsisUtil.removeTailingZeros(systemId);
+ isisRouterDetails.remove(systemId);
+ }
+
+ /**
+ * 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 systemId system ID to remove link information
+ * @return updated link information
+ */
+ public Map<String, LinkInformation> removeLinkInfo(String systemId) {
+ String routerId = IsisUtil.removeTailingZeros(systemId);
+ Map<String, LinkInformation> removeLinkInformationMap = new LinkedHashMap<>();
+ for (String key : addedLinkInformationMap.keySet()) {
+ if (key.contains(routerId)) {
+ 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 IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs teTlv : neighbours) {
+ List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
+ for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
+ if (teSubTlv instanceof InterfaceIpAddress) {
+ InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
+ linkInformation.setInterfaceIp(localIpAddress.localInterfaceIPAddress());
+ } else if (teSubTlv instanceof NeighborIpAddress) {
+ NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
+ linkInformation.setNeighborIp(neighborIpAddress.neighborIPAddress());
+ }
+
+ }
+ }
+ }
+ }
+ 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 IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs teTlv : neighbours) {
+ List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
+ for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
+ if (teSubTlv instanceof InterfaceIpAddress) {
+ InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
+ isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress());
+ } else if (teSubTlv instanceof NeighborIpAddress) {
+ NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
+ isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress());
+ }
+
+ }
+ }
+ }
+ }
+ 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 IsExtendedReachability) {
+ IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
+ List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
+ for (NeighborForExtendedIs teTlv : neighbours) {
+ List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
+ for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
+ if (teSubTlv instanceof AdministrativeGroup) {
+ AdministrativeGroup ag = (AdministrativeGroup) teSubTlv;
+ isisLinkTed.setAdministrativeGroup(ag.administrativeGroup());
+ }
+ if (teSubTlv instanceof InterfaceIpAddress) {
+ InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
+ isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress());
+ }
+ if (teSubTlv instanceof NeighborIpAddress) {
+ NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
+ isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress());
+ }
+ if (teSubTlv instanceof TrafficEngineeringMetric) {
+ TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv;
+ isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue());
+ }
+ if (teSubTlv instanceof MaximumBandwidth) {
+ MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv;
+ isisLinkTed.setMaximumLinkBandwidth(
+ Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue()));
+ }
+ if (teSubTlv instanceof MaximumReservableBandwidth) {
+ MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv;
+ isisLinkTed.setMaximumReservableLinkBandwidth(
+ Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue()));
+ }
+ if (teSubTlv instanceof UnreservedBandwidth) {
+ UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv;
+ List<Bandwidth> bandwidthList = new ArrayList<>();
+ List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue();
+ for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) {
+ Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue);
+ bandwidthList.add(bandwidth);
+ }
+ isisLinkTed.setUnreservedBandwidth(bandwidthList);
+ }
+ }
+ }
+ }
+ }
+ return isisLinkTed;
+ }
+}
\ No newline at end of file
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java
new file mode 100644
index 0000000..f9b4c0c
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/topology/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of the ISIS controller topology.
+ */
+package org.onosproject.isis.controller.impl.topology;
\ No newline at end of file