tejeshwer degala
Committed by Gerrit Code Review

ONOS-4086 to ONOS-4091, ONOS-4098 to ONOS-4100:ISIS controller implementation

Change-Id: I7be52805652fe762baf808515401d6b5042b2aa5
Showing 32 changed files with 2179 additions and 55 deletions
......@@ -15,6 +15,7 @@
*/
package org.onosproject.isis.controller;
import com.fasterxml.jackson.databind.JsonNode;
import org.onosproject.isis.controller.topology.IsisRouterListener;
import java.util.List;
......@@ -41,18 +42,9 @@ public interface IsisController {
/**
* Updates configuration of processes.
*
* @param processes process instance to update
* @param processesNode json node represents process
*/
void updateConfig(List<IsisProcess> processes);
/**
* Deletes configuration parameters.
*
* @param processes list of process instance
* @param attribute string key which deletes the particular node or element
* from the controller
*/
void deleteConfig(List<IsisProcess> processes, String attribute);
void updateConfig(JsonNode processesNode);
/**
* Gets the all configured processes.
......
......@@ -230,6 +230,13 @@ public interface IsisInterface {
void setPriority(int priority);
/**
* Returns hello interval.
*
* @return hello interval
*/
public int helloInterval();
/**
* Sets hello interval.
*
* @param helloInterval hello interval
......@@ -301,4 +308,11 @@ public interface IsisInterface {
* @param circuitId circuit ID
*/
void setCircuitId(String circuitId);
/**
* Removes neighbor from the interface neighbor map.
*
* @param isisNeighbor ISIS neighbor instance
*/
void removeNeighbor(IsisNeighbor isisNeighbor);
}
......
......@@ -98,4 +98,14 @@ public interface IsisNeighbor {
* @param holdingTime Holding time of neighbor
*/
void setHoldingTime(int holdingTime);
/**
* Starts the inactivity timer for this neighbor.
*/
void startInactivityTimeCheck();
/**
* Stops the inactivity timer.
*/
void stopInactivityTimeCheck();
}
......
......@@ -23,6 +23,13 @@ import java.util.List;
public interface IsisProcess {
/**
* Returns process ID.
*
* @return process ID
*/
public String processId();
/**
* Sets process ID.
*
* @param processId process ID
......
<!--
~ 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.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-isis</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-isis-ctl</artifactId>
<packaging>bundle</packaging>
<description>ONOS ISIS controller subsystem API</description>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-isis-isisio</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
/*
* 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 com.fasterxml.jackson.databind.JsonNode;
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.apache.felix.scr.annotations.Service;
import org.onosproject.isis.controller.IsisController;
import org.onosproject.isis.controller.IsisProcess;
import org.onosproject.isis.controller.topology.IsisRouterListener;
import org.onosproject.net.driver.DriverService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* Represents ISIS controller implementation.
*/
@Component(immediate = true)
@Service
public class DefaultIsisController implements IsisController {
protected static final Logger log = LoggerFactory.getLogger(DefaultIsisController.class);
private final Controller controller = new Controller();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DriverService driverService;
@Activate
public void activate() {
log.debug("ISISControllerImpl activate");
}
@Deactivate
public void deactivate() {
controller.isisDeactivate();
log.debug("ISISControllerImpl deActivate");
}
@Override
public List<IsisProcess> allConfiguredProcesses() {
List<IsisProcess> processes = controller.getAllConfiguredProcesses();
return processes;
}
@Override
public void updateConfig(JsonNode jsonNode) {
log.debug("updateConfig::IsisList::processes::{}", jsonNode);
try {
controller.updateConfig(jsonNode);
} catch (Exception e) {
log.debug("Error::updateConfig::{}", e.getMessage());
}
}
@Override
public void addRouterListener(IsisRouterListener isisRouterListener) {
log.debug("IsisControllerImpl::addRouterListener...");
}
@Override
public void removeRouterListener(IsisRouterListener isisRouterListener) {
log.debug("IsisControllerImpl::removeRouterListener...");
}
}
\ No newline at end of file
/*
* 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.packet.MacAddress;
import org.onosproject.isis.controller.IsisInterface;
import org.onosproject.isis.controller.IsisInterfaceState;
import org.onosproject.isis.controller.IsisNeighbor;
import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.IsisRouterType;
import org.onosproject.isis.io.isispacket.pdu.HelloPdu;
import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu;
import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu;
import org.onosproject.isis.io.util.IsisConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Representation of an ISIS neighbor.
* The first thing an ISIS router must do is find its neighbors and form adjacency.
* Each neighbor that the router finds will be represented by this class.
*/
public class DefaultIsisNeighbor implements IsisNeighbor {
private static final Logger log = LoggerFactory.getLogger(DefaultIsisNeighbor.class);
private String neighborAreaId;
private String neighborSystemId;
private Ip4Address interfaceIp;
private MacAddress neighborMacAddress;
private int holdingTime;
private IsisRouterType routerType;
private String l1LanId;
private String l2LanId;
private byte localCircuitId;
private int localExtendedCircuitId;
private IsisInterfaceState neighborState = IsisInterfaceState.INITIAL;
private InternalInactivityTimeCheck inActivityTimeCheckTask;
private ScheduledExecutorService exServiceInActivity;
private boolean inActivityTimerScheduled = false;
private IsisInterface isisInterface;
/**
* Creates an instance of ISIS neighbor.
*
* @param helloMessage hello message instance
* @param isisInterface ISIS interface instance
*/
public DefaultIsisNeighbor(HelloPdu helloMessage, IsisInterface isisInterface) {
this.neighborMacAddress = helloMessage.sourceMac();
List<String> areaAddresses = helloMessage.areaAddress();
this.neighborAreaId = (areaAddresses != null) ? areaAddresses.get(0) : "";
this.neighborSystemId = helloMessage.sourceId();
List<Ip4Address> interfaceIpAddresses = helloMessage.interfaceIpAddresses();
this.interfaceIp = (helloMessage.interfaceIpAddresses() != null) ?
interfaceIpAddresses.get(0) : IsisConstants.DEFAULTIP;
this.holdingTime = helloMessage.holdingTime();
this.routerType = IsisRouterType.get(helloMessage.circuitType());
if (helloMessage instanceof L1L2HelloPdu) {
if (IsisPduType.L1HELLOPDU == helloMessage.isisPduType()) {
l1LanId = ((L1L2HelloPdu) helloMessage).lanId();
} else if (IsisPduType.L2HELLOPDU == helloMessage.isisPduType()) {
l2LanId = ((L1L2HelloPdu) helloMessage).lanId();
}
} else if (helloMessage instanceof P2PHelloPdu) {
this.localCircuitId = ((P2PHelloPdu) helloMessage).localCircuitId();
}
this.isisInterface = isisInterface;
}
/**
* Returns local extended circuit ID.
*
* @return local extended circuit ID
*/
public int localExtendedCircuitId() {
return localExtendedCircuitId;
}
/**
* Sets local extended circuit ID.
*
* @param localExtendedCircuitId neighbor extended circuit ID
*/
public void setLocalExtendedCircuitId(int localExtendedCircuitId) {
this.localExtendedCircuitId = localExtendedCircuitId;
}
/**
* Returns neighbor area ID.
*
* @return neighbor area ID
*/
public String neighborAreaId() {
return neighborAreaId;
}
/**
* Sets neighbor area ID.
*
* @param neighborAreaId neighbor area ID
*/
public void setNeighborAreaId(String neighborAreaId) {
this.neighborAreaId = neighborAreaId;
}
/**
* Returns neighbor system ID.
*
* @return neighbor system ID
*/
public String neighborSystemId() {
return neighborSystemId;
}
/**
* Sets neighbor system ID.
*
* @param neighborSystemId neighbor system ID
*/
public void setNeighborSystemId(String neighborSystemId) {
this.neighborSystemId = neighborSystemId;
}
/**
* Returns interface IP.
*
* @return interface IP
*/
public Ip4Address interfaceIp() {
return interfaceIp;
}
/**
* Sets interface IP.
*
* @param interfaceIp IP
*/
public void setInterfaceIp(Ip4Address interfaceIp) {
this.interfaceIp = interfaceIp;
}
/**
* Returns neighbor mac address.
*
* @return neighborMacAddress neighbor mac address
*/
public MacAddress neighborMacAddress() {
return neighborMacAddress;
}
/**
* Sets neighbor mac address.
*
* @param neighborMacAddress mac address
*/
public void setNeighborMacAddress(MacAddress neighborMacAddress) {
this.neighborMacAddress = neighborMacAddress;
}
/**
* Returns holding time.
*
* @return holding time
*/
public int holdingTime() {
return holdingTime;
}
/**
* Sets holding time.
*
* @param holdingTime holding time
*/
public void setHoldingTime(int holdingTime) {
this.holdingTime = holdingTime;
}
/**
* Returns router type.
*
* @return router type
*/
public IsisRouterType routerType() {
return routerType;
}
/**
* Sets router type.
*
* @param routerType router type
*/
public void setRouterType(IsisRouterType routerType) {
this.routerType = routerType;
}
/**
* Returns L1 lan ID.
*
* @return L1 lan ID
*/
public String l1LanId() {
return l1LanId;
}
/**
* Sets L1 lan ID.
*
* @param l1LanId L1 lan ID
*/
public void setL1LanId(String l1LanId) {
this.l1LanId = l1LanId;
}
/**
* Returns L2 lan ID.
*
* @return L2 lan ID
*/
public String l2LanId() {
return l2LanId;
}
/**
* Sets L2 lan ID.
*
* @param l2LanId L2 lan ID
*/
public void setL2LanId(String l2LanId) {
this.l1LanId = l1LanId;
}
/**
* Gets the neighbor interface state.
*
* @return neighbor interface state
*/
public IsisInterfaceState interfaceState() {
return neighborState;
}
/**
* Sets the neighbor interface state.
*
* @param neighborState the neighbor interface state
*/
public void setNeighborState(IsisInterfaceState neighborState) {
this.neighborState = neighborState;
}
/**
* Returns local circuit ID.
*
* @return local circuit ID
*/
public byte localCircuitId() {
return localCircuitId;
}
/**
* Sets local circuit ID.
*
* @param localCircuitId local circuit ID
*/
public void setLocalCircuitId(byte localCircuitId) {
this.localCircuitId = localCircuitId;
}
/**
* Returns neighbor state.
*
* @return neighbor state
*/
public IsisInterfaceState neighborState() {
return neighborState;
}
/**
* Starts the inactivity timer.
*/
public void startInactivityTimeCheck() {
if (!inActivityTimerScheduled) {
log.debug("IsisNeighbor::startInactivityTimeCheck");
inActivityTimeCheckTask = new InternalInactivityTimeCheck();
exServiceInActivity = Executors.newSingleThreadScheduledExecutor();
exServiceInActivity.scheduleAtFixedRate(inActivityTimeCheckTask, holdingTime,
holdingTime, TimeUnit.SECONDS);
inActivityTimerScheduled = true;
}
}
/**
* Stops the inactivity timer.
*/
public void stopInactivityTimeCheck() {
if (inActivityTimerScheduled) {
log.debug("IsisNeighbor::stopInactivityTimeCheck ");
exServiceInActivity.shutdown();
inActivityTimerScheduled = false;
}
}
/**
* Called when neighbor is down.
*/
public void neighborDown() {
log.debug("Neighbor Down {} and NeighborSystemId {}", neighborMacAddress,
neighborSystemId);
stopInactivityTimeCheck();
isisInterface.setL1LanId(IsisConstants.DEFAULTLANID);
isisInterface.setL2LanId(IsisConstants.DEFAULTLANID);
neighborState = IsisInterfaceState.DOWN;
isisInterface.removeNeighbor(this);
}
/**
* Represents a Task which will do an inactivity time check.
*/
private class InternalInactivityTimeCheck implements Runnable {
/**
* Creates an instance.
*/
InternalInactivityTimeCheck() {
}
@Override
public void run() {
log.debug("Neighbor Not Heard till the past router dead interval .");
neighborDown();
}
}
}
\ No newline at end of file
/*
* 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.IsisInterface;
import org.onosproject.isis.controller.IsisProcess;
import java.util.List;
/**
* Represents of an ISIS process.
*/
public class DefaultIsisProcess implements IsisProcess {
private String processId;
private List<IsisInterface> isisInterfaceList;
/**
* Gets process ID.
*
* @return process ID
*/
public String processId() {
return processId;
}
/**
* Sets process ID.
*
* @param processId process ID
*/
public void setProcessId(String processId) {
this.processId = processId;
}
/**
* Gets list of ISIS interface details.
*
* @return list of ISIS interface details
*/
public List<IsisInterface> isisInterfaceList() {
return isisInterfaceList;
}
/**
* Sets list of ISIS interface details.
*
* @param isisInterfaceList list of ISIS interface details
*/
public void setIsisInterfaceList(List<IsisInterface> isisInterfaceList) {
this.isisInterfaceList = isisInterfaceList;
}
}
\ No newline at end of file
/*
* 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 com.google.common.primitives.Bytes;
import org.jboss.netty.channel.Channel;
import org.onosproject.isis.controller.IsisInterface;
import org.onosproject.isis.controller.IsisNetworkType;
import org.onosproject.isis.controller.IsisRouterType;
import org.onosproject.isis.io.util.IsisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Representation of an ISIS hello pdu sender task.
*/
public class IsisHelloPduSender implements Runnable {
private static final Logger log = LoggerFactory.getLogger(IsisHelloPduSender.class);
private Channel channel = null;
private IsisInterface isisInterface = null;
/**
* Creates an instance of Hello PDU Sender task.
*
* @param channel netty channel instance
* @param isisInterface ISIS interface instance
*/
public IsisHelloPduSender(Channel channel, IsisInterface isisInterface) {
this.channel = channel;
this.isisInterface = isisInterface;
}
@Override
public void run() {
if (channel != null) {
try {
byte[] helloPdu = null;
byte[] interfaceIndex = {(byte) isisInterface.interfaceIndex()};
if (isisInterface.networkType() == IsisNetworkType.P2P) {
helloPdu = IsisUtil.getP2pHelloPdu(isisInterface, true);
helloPdu = Bytes.concat(helloPdu, interfaceIndex);
channel.write(helloPdu);
} else if (isisInterface.networkType() == IsisNetworkType.BROADCAST) {
switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
case L1:
helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
helloPdu = Bytes.concat(helloPdu, interfaceIndex);
channel.write(helloPdu);
break;
case L2:
helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
helloPdu = Bytes.concat(helloPdu, interfaceIndex);
channel.write(helloPdu);
break;
case L1L2:
helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
helloPdu = Bytes.concat(helloPdu, interfaceIndex);
channel.write(helloPdu);
helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
helloPdu = Bytes.concat(helloPdu, interfaceIndex);
channel.write(helloPdu);
break;
default:
log.debug("IsisHelloPduSender::Unknown circuit type...!!!");
break;
}
}
} catch (Exception e) {
log.debug("Exception @IsisHelloPduSender:: {}", e.getMessage());
}
}
}
}
\ No newline at end of file
/*
* 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.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
import org.onlab.packet.MacAddress;
import org.onosproject.isis.controller.IsisMessage;
import org.onosproject.isis.io.isispacket.IsisMessageReader;
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.LinkedList;
import java.util.List;
/**
* Decodes an ISIS message from a Channel, for use in a netty pipeline.
*/
public class IsisMessageDecoder extends FrameDecoder {
private static final Logger log = LoggerFactory.getLogger(IsisMessageDecoder.class);
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
log.debug("IsisMessageDecoder::Message received <:> length {}", buffer.readableBytes());
if (!channel.isConnected()) {
log.info("Channel is not connected.");
return null;
}
IsisMessageReader messageReader = new IsisMessageReader();
List<IsisMessage> isisMessageList = new LinkedList<>();
int dataLength = buffer.readableBytes();
while (buffer.readableBytes() >= IsisConstants.MINIMUM_FRAME_LEN) {
ChannelBuffer payload = buffer.readBytes(IsisConstants.MINIMUM_FRAME_LEN);
ChannelBuffer ethernetHeader = payload.readBytes(IsisUtil.ETHER_HEADER_LEN);
//Read the Source MAC address from ethernet header at the 6th position
MacAddress sourceMac = getSourceMac(ethernetHeader);
//Strip 17 byte ethernet header and get the ISIS data buffer
ChannelBuffer isisDataBuffer = payload.readBytes(payload.readableBytes());
int readableBytes = isisDataBuffer.readableBytes();
IsisMessage message = messageReader.readFromBuffer(isisDataBuffer);
//Last 7 bytes is metadata. ie. interface MAC address and interface index.
if (message != null) {
if (isisDataBuffer.readableBytes() >= IsisConstants.METADATA_LEN) {
//Sets the source MAC
message.setSourceMac(sourceMac);
isisDataBuffer.readerIndex(readableBytes - IsisConstants.METADATA_LEN);
log.debug("IsisMessageDecoder::Reading metadata <:> length {}", isisDataBuffer.readableBytes());
byte[] macBytes = new byte[IsisUtil.SIX_BYTES];
isisDataBuffer.readBytes(macBytes, 0, IsisUtil.SIX_BYTES);
MacAddress macAddress = MacAddress.valueOf(macBytes);
int interfaceIndex = isisDataBuffer.readByte();
message.setInterfaceMac(macAddress);
message.setInterfaceIndex(interfaceIndex);
}
isisMessageList.add(message);
}
}
return isisMessageList;
}
/**
* Gets the source MAC address from the ethernet header.
*
* @param ethHeader ethernet header bytes
* @return MAC address of the source router
*/
private MacAddress getSourceMac(ChannelBuffer ethHeader) {
//Source MAC is at position 6 to 11 (6 bytes)
ethHeader.skipBytes(IsisUtil.SIX_BYTES);
MacAddress sourceMac = MacAddress.valueOf(ethHeader.readBytes(IsisUtil.SIX_BYTES).array());
return sourceMac;
}
}
\ No newline at end of file
/*
* 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.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Encodes an ISIS message for output into a ChannelBuffer, for use in a netty pipeline.
*/
public class IsisMessageEncoder extends OneToOneEncoder {
private static final Logger log = LoggerFactory.getLogger(IsisMessageEncoder.class);
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
byte[] byteMsg = (byte[]) msg;
log.debug("Encoding isisMessage of length {}", byteMsg.length);
ChannelBuffer channelBuffer = ChannelBuffers.buffer(byteMsg.length);
channelBuffer.writeBytes(byteMsg);
return channelBuffer;
}
}
\ No newline at end of file
/*
* 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.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
/**
* Creates a ChannelPipeline for a client-side ISIS channel.
*/
public class IsisPipelineFactory implements ChannelPipelineFactory {
private IsisChannelHandler isisChannelHandler;
/**
* Creates an instance of ISIS channel pipeline factory.
*
* @param isisChannelHandler ISIS channel handler instance
*/
public IsisPipelineFactory(IsisChannelHandler isisChannelHandler) {
this.isisChannelHandler = isisChannelHandler;
}
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("encoder", new IsisMessageDecoder());
pipeline.addLast("decoder", new IsisMessageEncoder());
pipeline.addLast("handler", isisChannelHandler);
return pipeline;
}
}
\ No newline at end of file
/*
* 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.lsdb;
import org.onosproject.isis.controller.IsisInterface;
import org.onosproject.isis.controller.IsisLsdb;
import org.onosproject.isis.controller.IsisLsdbAge;
import org.onosproject.isis.controller.IsisLspBin;
import org.onosproject.isis.controller.IsisMessage;
import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.LspWrapper;
import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import org.onosproject.isis.io.util.IsisConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Representation of ISIS link state database.
*/
public class DefaultIsisLsdb implements IsisLsdb {
private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdb.class);
private Map<String, LspWrapper> isisL1Db = new ConcurrentHashMap<>();
private Map<String, LspWrapper> isisL2Db = new ConcurrentHashMap<>();
private IsisLsdbAge lsdbAge = null;
private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM;
/**
* Creates an instance of ISIS LSDB.
*/
public DefaultIsisLsdb() {
lsdbAge = new DefaultIsisLsdbAge();
}
/**
* Initializes the link state database.
*/
public void initializeDb() {
lsdbAge.startDbAging();
}
/**
* Returns the LSDB LSP key.
*
* @param systemId system ID
* @return key
*/
public String lspKey(String systemId) {
StringBuilder lspKey = new StringBuilder();
lspKey.append(systemId);
lspKey.append(".00");
lspKey.append("-");
lspKey.append("00");
return lspKey.toString();
}
/**
* Returns the neighbor L1 database information.
*
* @return neighbor L1 database information
*/
public Map<String, LspWrapper> getL1Db() {
return isisL1Db;
}
/**
* Returns the neighbor L2 database information.
*
* @return neighbor L2 database information
*/
public Map<String, LspWrapper> getL2Db() {
return isisL2Db;
}
/**
* Returns the LSDB instance.
*
* @return LSDB instance
*/
public IsisLsdb isisLsdb() {
return this;
}
/**
* Returns all LSPs (L1 and L2).
*
* @param excludeMaxAgeLsp exclude the max age LSPs
* @return List of LSPs
*/
public List<LspWrapper> allLspHeaders(boolean excludeMaxAgeLsp) {
List<LspWrapper> summaryList = new CopyOnWriteArrayList();
addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL1Db);
addLspToHeaderList(summaryList, excludeMaxAgeLsp, isisL2Db);
return summaryList;
}
/**
* Adds the LSPs to summary list.
*
* @param summaryList summary list
* @param excludeMaxAgeLsp exclude max age LSP
* @param lspMap map of LSP
*/
private void addLspToHeaderList(List summaryList, boolean excludeMaxAgeLsp, Map lspMap) {
Iterator slotVals = lspMap.values().iterator();
while (slotVals.hasNext()) {
LspWrapper wrapper = (LspWrapper) slotVals.next();
if (excludeMaxAgeLsp) {
//if current age of lsa is max age or lsa present in Max Age bin
if (wrapper.remainingLifetime() != 0) {
addToList(wrapper, summaryList);
}
} else {
addToList(wrapper, summaryList);
}
}
}
/**
* Adds the LSPWrapper to summary list.
*
* @param wrapper LSP wrapper instance
* @param summList LSP summary list
*/
private void addToList(LspWrapper wrapper, List summList) {
//set the current age
((LsPdu) wrapper.lsPdu()).setRemainingLifeTime(wrapper.remainingLifetime());
summList.add(wrapper);
}
/**
* Finds the LSP from appropriate maps L1 or L2 based on type.
*
* @param pduType L1 or L2 LSP
* @param lspId LSP ID
* @return LSP wrapper object
*/
public LspWrapper findLsp(IsisPduType pduType, String lspId) {
LspWrapper lspWrapper = null;
switch (pduType) {
case L1LSPDU:
lspWrapper = isisL1Db.get(lspId);
break;
case L2LSPDU:
lspWrapper = isisL2Db.get(lspId);
break;
default:
log.debug("Unknown LSP type..!!!");
break;
}
//set the current age
if (lspWrapper != null) {
//set the current age
((DefaultLspWrapper) lspWrapper).lsPdu().setRemainingLifeTime(lspWrapper.remainingLifetime());
}
return lspWrapper;
}
/**
* Installs a new self-originated LSP.
*
* @return true if successfully added
*/
public boolean addLsp(IsisMessage isisMessage, boolean isSelfOriginated, IsisInterface isisInterface) {
LsPdu lspdu = (LsPdu) isisMessage;
DefaultLspWrapper lspWrapper = new DefaultLspWrapper();
lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime());
lspWrapper.setRemainingLifetime(IsisConstants.LSPMAXAGE - lsdbAge.ageCounter());
lspWrapper.setLspType(IsisPduType.get(lspdu.pduType()));
lspWrapper.setLsPdu(lspdu);
lspWrapper.setAgeCounterWhenReceived(lsdbAge.ageCounter());
lspWrapper.setAgeCounterRollOverWhenAdded(lsdbAge.ageCounterRollOver());
lspWrapper.setSelfOriginated(isSelfOriginated);
lspWrapper.setIsisInterface(isisInterface);
lspWrapper.setLsdbAge(lsdbAge);
addLsp(lspWrapper, lspdu.lspId());
log.debug("Added LSp In LSDB: {}", lspWrapper);
return true;
}
/**
* Adds the LSP to L1 or L2 database.
*
* @param lspWrapper LSA wrapper instance
* @param key key
* @return True if added else false
*/
private boolean addLsp(LspWrapper lspWrapper, String key) {
//Remove the lsa from bin if exist.
removeLspFromBin(lspWrapper);
switch (lspWrapper.lsPdu().isisPduType()) {
case L1LSPDU:
isisL1Db.put(key, lspWrapper);
break;
case L2LSPDU:
isisL2Db.put(key, lspWrapper);
break;
default:
log.debug("Unknown LSP type to add..!!!");
break;
}
//add it to bin
Integer binNumber = lsdbAge.age2Bin(IsisConstants.LSPMAXAGE - lspWrapper.remainingLifetime());
IsisLspBin lspBin = lsdbAge.getLspBin(binNumber);
if (lspBin != null) {
//remove from existing
lspWrapper.setBinNumber(binNumber);
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());
}
return false;
}
/**
* Removes LSP from Bin.
*
* @param lsaWrapper LSP wrapper instance
*/
public void removeLspFromBin(LspWrapper lsaWrapper) {
if (lsaWrapper != null) {
lsdbAge.removeLspFromBin(lsaWrapper);
}
}
/**
* Returns new ,latest or old according to the type of ISIS message received.
*
* @param lsp1 LSP instance
* @param lsp2 LSP instance
* @return string status
*/
public String isNewerOrSameLsp(IsisMessage lsp1, IsisMessage lsp2) {
LsPdu receivedLsp = (LsPdu) lsp1;
LsPdu lspFromDb = (LsPdu) lsp2;
if (receivedLsp.sequenceNumber() > lspFromDb.sequenceNumber()) {
return "latest";
} else if (receivedLsp.sequenceNumber() < lspFromDb.sequenceNumber()) {
return "old";
} else if (receivedLsp.sequenceNumber() == lspFromDb.sequenceNumber()) {
return "same";
}
return "";
}
/**
* Returns the sequence number.
*
* @param lspType type of LSP
* @return sequence number
*/
public int lsSequenceNumber(IsisPduType lspType) {
switch (lspType) {
case L1LSPDU:
return l1LspSeqNo++;
case L2LSPDU:
return l2LspSeqNo++;
default:
return IsisConstants.STARTLSSEQUENCENUM;
}
}
/**
* Deletes the given LSP.
*
* @param lspMessage LSP instance
*/
public void deleteLsp(IsisMessage lspMessage) {
LsPdu lsp = (LsPdu) lspMessage;
String lspKey = lsp.lspId();
switch (lsp.isisPduType()) {
case L1LSPDU:
isisL1Db.remove(lspKey);
break;
case L2LSPDU:
isisL2Db.remove(lspKey);
break;
default:
log.debug("Unknown LSP type to remove..!!!");
break;
}
}
}
\ No newline at end of file
/*
* 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.lsdb;
import org.onosproject.isis.controller.IsisLsdbAge;
import org.onosproject.isis.controller.IsisLspBin;
import org.onosproject.isis.controller.LspWrapper;
import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import org.onosproject.isis.io.util.IsisConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* Representation of ISIS link state database ageing process.
*/
public class DefaultIsisLsdbAge implements IsisLsdbAge {
private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdbAge.class);
protected static int ageCounter = 0;
private InternalAgeTimer dbAgeTimer;
private ScheduledExecutorService exServiceage;
private Integer maxBins = 1200;
private Map<Integer, IsisLspBin> ageBins = new ConcurrentHashMap<>(maxBins);
private int ageCounterRollOver = 0;
private IsisLspQueueConsumer queueConsumer = null;
private BlockingQueue<LspWrapper> lsaQueue = new ArrayBlockingQueue<>(1024);
/**
* Creates an instance of LSDB age.
*/
public DefaultIsisLsdbAge() {
// create LSBin's in the HashMap.
for (int i = 0; i < maxBins; i++) {
IsisLspBin lspBin = new DefaultIsisLspBin(i);
ageBins.put(i, lspBin);
}
}
/**
* Returns age counter.
*
* @return age counter
*/
public int ageCounter() {
return ageCounter;
}
/**
* Returns age counter roll over.
*
* @return age counter roll over
*/
public int ageCounterRollOver() {
return ageCounterRollOver;
}
/**
* Adds LSP to LS bin for ageing.
*
* @param binNumber key to store in bin
* @param lspBin LSP bin instance
*/
public void addLspBin(int binNumber, IsisLspBin lspBin) {
if (!ageBins.containsKey(binNumber)) {
ageBins.put(binNumber, lspBin);
}
}
/**
* Returns LSP from Bin.
*
* @param binKey key
* @return bin instance
*/
public IsisLspBin getLspBin(int binKey) {
return ageBins.get(binKey);
}
/**
* Removes LSP from Bin.
*
* @param lspWrapper wrapper instance
*/
public void removeLspFromBin(LspWrapper lspWrapper) {
if (ageBins.containsKey(lspWrapper.binNumber())) {
IsisLspBin lsaBin = ageBins.get(lspWrapper.binNumber());
lsaBin.removeIsisLsp(((LsPdu) lspWrapper.lsPdu()).lspId(), lspWrapper);
}
}
/**
* Returns the bin number.
*
* @param age Can be either age or ageCounter
* @return bin number.
*/
public int age2Bin(int age) {
if (age <= ageCounter) {
return (ageCounter - age);
} else {
return ((IsisConstants.LSPMAXAGE - 1) + (ageCounter - age));
}
}
/**
* Starts the aging timer and queue consumer.
*/
public void startDbAging() {
startDbAgeTimer();
queueConsumer = new IsisLspQueueConsumer(lsaQueue);
new Thread(queueConsumer).start();
}
/**
* Starts DB aging task.
*/
private void startDbAgeTimer() {
dbAgeTimer = new InternalAgeTimer();
//from 1 sec
exServiceage = Executors.newSingleThreadScheduledExecutor();
exServiceage.scheduleAtFixedRate(dbAgeTimer, 1, 1, TimeUnit.SECONDS);
}
/**
* Gets called every second as part of the aging process.
*/
public void ageLsp() {
refreshLsa();
maxAgeLsa();
if (ageCounter == IsisConstants.LSPMAXAGE) {
ageCounter = 0;
ageCounterRollOver++;
} else {
ageCounter++;
}
}
/**
* If the LSP have completed the MaxAge - they are moved called stop aging.
*/
public void maxAgeLsa() {
if (ageCounter == 0) {
return;
}
//Get from Age Bins
IsisLspBin lspBin = ageBins.get(ageCounter - 1);
if (lspBin == null) {
return;
}
Map lspBinMap = lspBin.listOfLsp();
for (Object key : lspBinMap.keySet()) {
LspWrapper lspWrapper = (LspWrapper) lspBinMap.get((String) key);
if (lspWrapper.currentAge() == IsisConstants.LSPMAXAGE) {
lspWrapper.setLspProcessing(IsisConstants.MAXAGELSP);
log.debug("Lsp picked for maxage removal. Age Counter: {}, AgeCounterRollover: {}, " +
"AgeCounterRollover WhenAddedToDb: {}, LSA Type: {}, LSA Key: {}",
ageCounter, ageCounterRollOver, lspWrapper.currentAge(),
lspWrapper.lsPdu().isisPduType(), key);
//add it to lspQueue for processing
try {
lsaQueue.put(lspWrapper);
//remove from bin
lspBin.removeIsisLsp((String) key, lspWrapper);
} catch (InterruptedException e) {
log.debug("Error::LSDBAge::maxAgeLsp::{}", e.getMessage());
}
}
}
}
/*
* If the LSP is in age bin of 900s- it's pushed into refresh list.
*/
public void refreshLsa() {
int binNumber;
if (ageCounter < IsisConstants.LSPREFRESH) {
binNumber = ageCounter + IsisConstants.LSPREFRESH;
} else {
binNumber = ageCounter - IsisConstants.LSPREFRESH;
}
if (binNumber > IsisConstants.LSPMAXAGE) {
binNumber = binNumber - IsisConstants.LSPMAXAGE;
}
IsisLspBin lspBin = ageBins.get(binNumber);
if (lspBin == null) {
return;
}
Map lspBinMap = lspBin.listOfLsp();
for (Object key : lspBinMap.keySet()) {
LspWrapper lsp = (LspWrapper) lspBinMap.get((String) key);
try {
if (lsp.isSelfOriginated()) {
log.debug("Lsp picked for refreshLsp. binNumber: {}, LSA Type: {}, LSA Key: {}",
binNumber, lsp.lspType(), key);
lsp.setLspProcessing(IsisConstants.REFRESHLSP);
lsaQueue.put(lsp);
//remove from bin
lspBin.removeIsisLsp((String) key, lsp);
}
} catch (InterruptedException e) {
log.debug("Error::LSDBAge::refreshLsp::{}", e.getMessage());
}
}
}
/**
* Runnable task which runs every second and calls aging process.
*/
private class InternalAgeTimer implements Runnable {
/**
* Creates an instance of age timer task.
*/
InternalAgeTimer() {
log.debug("Starts::IsisLsdbAge::AgeTimer...!!! ");
}
@Override
public void run() {
ageLsp();
}
}
}
\ No newline at end of file
/*
* 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.lsdb;
import com.google.common.base.MoreObjects;
import org.onosproject.isis.controller.IsisLspBin;
import org.onosproject.isis.controller.LspWrapper;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Representation of LSP bin, where an LSP is stored for Aging.
* A bin is identified by a bin number and can have one or more LSPs
* store in a particular bin location
*/
public class DefaultIsisLspBin implements IsisLspBin {
private int binNumber;
private Map<String, LspWrapper> listOfLsp = new ConcurrentHashMap<>();
/**
* Creates ISIS LSP bin instance.
*
* @param binNumber bin number
*/
public DefaultIsisLspBin(int binNumber) {
this.binNumber = binNumber;
}
/**
* Adds the LSP to wrapper.
*
* @param lspKey key to add the LSP
* @param lspWrapper LSP wrapper instance
*/
public void addIsisLsp(String lspKey, LspWrapper lspWrapper) {
if (!listOfLsp.containsKey(lspKey)) {
listOfLsp.put(lspKey, lspWrapper);
lspWrapper.setBinNumber(this.binNumber);
}
}
/**
* Returns the LSP wrapper.
*
* @param lspKey LSP key
* @return LSP wrapper
*/
public LspWrapper isisLsp(String lspKey) {
return listOfLsp.get(lspKey);
}
/**
* Removes ISIS LSP from database.
*
* @param lspKey LSP key
* @param lspWrapper LSP wrapper instance
*/
public void removeIsisLsp(String lspKey, LspWrapper lspWrapper) {
if (listOfLsp.containsKey(lspKey)) {
listOfLsp.remove(lspKey);
}
}
/**
* Returns all LSP wrappers.
*
* @return all LSP wrappers
*/
public Map<String, LspWrapper> listOfLsp() {
return listOfLsp;
}
/**
* Returns the bin number.
*
* @return the bin number
*/
public int binNumber() {
return binNumber;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.omitNullValues()
.add("binNumber", binNumber)
.add("listOfLsp", listOfLsp)
.toString();
}
}
\ No newline at end of file
/*
* 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.lsdb;
import org.onosproject.isis.controller.IsisInterface;
import org.onosproject.isis.controller.IsisLsdbAge;
import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.LspWrapper;
import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import org.onosproject.isis.io.util.IsisConstants;
/**
* Representation of LSP wrapper where the LSPs are stored with metadata.
*/
public class DefaultLspWrapper implements LspWrapper {
private int binNumber = -1;
private boolean selfOriginated = false;
private IsisPduType lspType;
private int lspAgeReceived;
private int ageCounterWhenReceived;
private LsPdu lsPdu;
private IsisLsdbAge lsdbAge;
private int ageCounterRollOverWhenAdded;
private int remainingLifetime;
private IsisInterface isisInterface;
private String lspProcessing;
/**
* Returns "refreshLsp" or "maxageLsp" based on LSP to process.
*
* @return LSP processing string
*/
public String lspProcessing() {
return lspProcessing;
}
/**
* Sets LSP processing "refreshLsp" or "maxageLsp" based on LSP to process.
*
* @param lspProcessing "refreshLsp" or "maxageLsp" based on LSP to process
*/
public void setLspProcessing(String lspProcessing) {
this.lspProcessing = lspProcessing;
}
/**
* Returns LSP age received.
*
* @return LSP age received
*/
public int lspAgeReceived() {
return lspAgeReceived;
}
/**
* Sets LSP age received.
*
* @param lspAgeReceived LSP age received.
*/
public void setLspAgeReceived(int lspAgeReceived) {
this.lspAgeReceived = lspAgeReceived;
}
/**
* Returns ISIS interface instance.
*
* @return ISIS interface instance
*/
public IsisInterface isisInterface() {
return isisInterface;
}
/**
* Sets ISIS interface.
*
* @param isisInterface ISIS interface instance
*/
public void setIsisInterface(IsisInterface isisInterface) {
this.isisInterface = isisInterface;
}
/**
* Returns age counter when received.
*
* @return age counter when received
*/
public int ageCounterWhenReceived() {
return ageCounterWhenReceived;
}
/**
* Sets age counter when received.
*
* @param ageCounterWhenReceived age counter when received
*/
public void setAgeCounterWhenReceived(int ageCounterWhenReceived) {
this.ageCounterWhenReceived = ageCounterWhenReceived;
}
/**
* Returns age counter roll over.
*
* @return age counter roll over
*/
public int ageCounterRollOverWhenAdded() {
return ageCounterRollOverWhenAdded;
}
/**
* Sets age counter roll over when added.
*
* @param ageCounterRollOverWhenAdded age counter roll over when added
*/
public void setAgeCounterRollOverWhenAdded(int ageCounterRollOverWhenAdded) {
this.ageCounterRollOverWhenAdded = ageCounterRollOverWhenAdded;
}
/**
* Returns bin number.
*
* @return bin number
*/
public int binNumber() {
return binNumber;
}
/**
* Sets bin number.
*
* @param binNumber bin number
*/
public void setBinNumber(int binNumber) {
this.binNumber = binNumber;
}
/**
* Returns true if self originated.
*
* @return true if self originated.
*/
public boolean isSelfOriginated() {
return selfOriginated;
}
/**
* Sets true if self originated.
*
* @param selfOriginated true if self originated else false
*/
public void setSelfOriginated(boolean selfOriginated) {
this.selfOriginated = selfOriginated;
}
/**
* Returns ISIS PDU type.
*
* @return ISIS PDU type
*/
public IsisPduType lspType() {
return lspType;
}
/**
* Sets ISIS PDU type.
*
* @param lspType ISIS PDU type
*/
public void setLspType(IsisPduType lspType) {
this.lspType = lspType;
}
/**
* Returns LSPDU which the wrapper contains.
*
* @return LSPDU which the wrapper contains
*/
public LsPdu lsPdu() {
return lsPdu;
}
/**
* Sets LSPDU which the wrapper contains.
*
* @param lsPdu LSPDU which the wrapper contains
*/
public void setLsPdu(LsPdu lsPdu) {
this.lsPdu = lsPdu;
}
/**
* Returns ISIS LSDB age.
*
* @return ISIS LSDB age
*/
public IsisLsdbAge lsdbAge() {
return lsdbAge;
}
/**
* Sets LSDB age.
*
* @param lsdbAge LSDB age
*/
public void setLsdbAge(IsisLsdbAge lsdbAge) {
this.lsdbAge = lsdbAge;
}
/**
* Returns the current LSP Age.
*
* @return LSP age
*/
public int currentAge() {
int currentAge = 0;
//ls age received
if (lsdbAge.ageCounter() >= ageCounterWhenReceived) {
currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived);
} else {
currentAge = lspAgeReceived + ((IsisConstants.LSPMAXAGE + lsdbAge.ageCounter())
- ageCounterWhenReceived);
}
if (currentAge >= IsisConstants.LSPMAXAGE) {
return IsisConstants.LSPMAXAGE;
} else if ((currentAge == lspAgeReceived) && ageCounterRollOverWhenAdded
!= lsdbAge.ageCounterRollOver()) {
return IsisConstants.LSPMAXAGE;
}
return currentAge;
}
/**
* Returns remaining time.
*
* @return remaining time
*/
public int remainingLifetime() {
//Calculate the remaining lifetime
remainingLifetime = IsisConstants.LSPMAXAGE - lsdbAge.ageCounter();
return remainingLifetime;
}
/**
* Sets remaining life time.
*
* @param remainingLifetime LSPs remaining life time
*/
public void setRemainingLifetime(int remainingLifetime) {
this.remainingLifetime = remainingLifetime;
}
}
\ No newline at end of file
/*
* 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.lsdb;
import org.jboss.netty.channel.Channel;
import org.onosproject.isis.controller.IsisLsdb;
import org.onosproject.isis.controller.IsisPduType;
import org.onosproject.isis.controller.LspWrapper;
import org.onosproject.isis.controller.impl.DefaultIsisInterface;
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.concurrent.BlockingQueue;
/**
* Representation of LSP queue consumer.
*/
public class IsisLspQueueConsumer implements Runnable {
private static final Logger log = LoggerFactory.getLogger(IsisLspQueueConsumer.class);
private BlockingQueue queue = null;
/**
* Creates an instance of LSP queue consumer.
*
* @param queue queue instance
*/
public IsisLspQueueConsumer(BlockingQueue queue) {
this.queue = queue;
}
/**
* Gets the LSP wrapper instance from queue and process it.
*/
@Override
public void run() {
log.debug("LSPQueueConsumer:run...!!!");
try {
while (true) {
if (!queue.isEmpty()) {
LspWrapper wrapper = (LspWrapper) queue.take();
String lspProcessing = wrapper.lspProcessing();
switch (lspProcessing) {
case IsisConstants.REFRESHLSP:
log.debug("LSPQueueConsumer: Message - " + IsisConstants.REFRESHLSP +
" consumed.");
processRefreshLsp(wrapper);
break;
case IsisConstants.MAXAGELSP:
log.debug("LSPQueueConsumer: Message - " + IsisConstants.MAXAGELSP +
" consumed.");
processMaxAgeLsa(wrapper);
break;
default:
log.debug("Unknown command to process the LSP in queue ...!!!");
break;
}
}
}
} catch (Exception e) {
log.debug("Error::LSPQueueConsumer::{}", e.getMessage());
}
}
/**
* Process refresh LSP.
*
* @param wrapper LSP wrapper instance
*/
private void processRefreshLsp(LspWrapper wrapper) throws Exception {
if (wrapper.isSelfOriginated()) { //self originated
DefaultIsisInterface isisInterface = (DefaultIsisInterface) wrapper.isisInterface();
Channel channel = isisInterface.channel();
if (channel != null && channel.isConnected()) {
LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
lsPdu.setSequenceNumber(isisInterface.isisLsdb().lsSequenceNumber(
IsisPduType.get(lsPdu.pduType())));
lsPdu.setRemainingLifeTime(IsisConstants.LSPMAXAGE);
byte[] lspBytes = lsPdu.asBytes();
lspBytes = IsisUtil.addLengthAndMarkItInReserved(lspBytes, IsisConstants.LENGTHPOSITION,
IsisConstants.LENGTHPOSITION + 1,
IsisConstants.RESERVEDPOSITION);
lspBytes = IsisUtil.addChecksum(lspBytes, IsisConstants.CHECKSUMPOSITION,
IsisConstants.CHECKSUMPOSITION + 1);
//write to the channel
channel.write(IsisUtil.framePacket(lspBytes, isisInterface.interfaceIndex()));
log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}",
wrapper.lsPdu());
}
}
}
/**
* Process max age LSP.
*
* @param wrapper LSP wrapper instance
*/
private void processMaxAgeLsa(LspWrapper wrapper) {
//set the destination
DefaultIsisInterface isisInterface = (DefaultIsisInterface) wrapper.isisInterface();
if (isisInterface != null) {
//delete from db
LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
IsisLsdb isisDb = isisInterface.isisLsdb();
isisDb.deleteLsp(lsPdu);
log.debug("LSPQueueConsumer: processMaxAgeLsp - Removed-Max Age LSP {}",
wrapper.lsPdu());
}
}
}
\ No newline at end of file
......@@ -13,32 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.isis.io.util;
import com.fasterxml.jackson.databind.JsonNode;
/**
* Representation of ISIS config.
*/
public enum IsisConfig {
INSTANCE;
private JsonNode jsonNodes = null;
/**
* Returns the config value.
*
* @return jsonNodes json node
*/
public JsonNode config() {
return jsonNodes;
}
/**
* Sets the config value for jsonNode.
*
* @param jsonNodes json node
* Implementation of the ISIS controller LSDB and related functionality.
*/
public void setConfig(JsonNode jsonNodes) {
this.jsonNodes = jsonNodes;
}
}
\ No newline at end of file
package org.onosproject.isis.controller.impl.lsdb;
\ No newline at end of file
......
/*
* 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.
*/
package org.onosproject.isis.controller.impl;
\ No newline at end of file
......@@ -280,7 +280,7 @@ public class LsPdu extends IsisHeader {
* Returns the packet data unit length of link state packet.
* Entire length of this PDU, in octets
*
* @return pduLength packte date unit length
* @return pduLength packet data unit length
*/
public int pduLength() {
return pduLength;
......@@ -290,7 +290,7 @@ public class LsPdu extends IsisHeader {
* Sets the packet data unit length for link state packet.
* Entire Length of this PDU, in octets
*
* @param pduLength packte data length
* @param pduLength packet data length
*/
public void setPduLength(int pduLength) {
this.pduLength = pduLength;
......
......@@ -220,10 +220,9 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
byte[] bytes = null;
byte[] tlvHeader = tlvHeaderAsByteArray();
byte[] tlvBody = tlvBodyAsBytes();
//systemID + pseudo number+length of subtlv=11l
tlvBody[10] = (byte) (tlvBody.length - 11);
tlvHeader[1] = (byte) tlvBody.length;
bytes = Bytes.concat(tlvHeader, tlvBody);
return bytes;
}
......@@ -246,8 +245,8 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
} else {
controlInfo = controlInfo + "0";
}
String prefixlength = IsisUtil.toEightBitBinary(Integer.toBinaryString(this.prefixLength()));
controlInfo = controlInfo + prefixlength.substring(2, prefixlength.length());
String prefixLength = IsisUtil.toEightBitBinary(Integer.toBinaryString(this.prefixLength()));
controlInfo = controlInfo + prefixLength.substring(2, prefixLength.length());
bodyLst.add(Byte.parseByte(controlInfo, 2));
if (this.isSubTlvPresence()) {
bodyLst.add(this.subTlvLength());
......@@ -255,6 +254,8 @@ public class IpExtendedReachabilityTlv extends TlvHeader implements IsisTlv {
bodyLst.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv));
}
}
bodyLst.addAll(Bytes.asList(IsisUtil.prefixToBytes(this.prefix())));
return Bytes.toArray(bodyLst);
}
......
/*
* 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;
import com.google.common.base.MoreObjects;
import com.google.common.primitives.Bytes;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvFinder;
import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvToBytes;
import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvType;
import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
import org.onosproject.isis.io.util.IsisUtil;
import java.util.ArrayList;
import java.util.List;
/**
* Representation of IS extended reachability TLV.
*/
public class IsExtendedReachability extends TlvHeader implements IsisTlv {
private String neighborId;
private int metric;
private List<TrafficEngineeringSubTlv> trafEnginSubTlv = new ArrayList<>();
/**
* Creates an instance of IP external reachability TLV.
*
* @param tlvHeader TLV header
*/
public IsExtendedReachability(TlvHeader tlvHeader) {
this.setTlvType(tlvHeader.tlvType());
this.setTlvLength(tlvHeader.tlvLength());
}
/**
* Returns neighbor ID.
*
* @return neighbor ID
*/
public String neighborId() {
return neighborId;
}
/**
* Sets neighbor ID.
*
* @param neighborId neighbor ID
*/
public void setNeighborId(String neighborId) {
this.neighborId = neighborId;
}
/**
* Returns metric.
*
* @return metric
*/
public int metric() {
return metric;
}
/**
* Sets metric.
*
* @param metric metric
*/
public void setMetric(int metric) {
this.metric = metric;
}
/**
* Adds the traffic engineering sub TLV to IS extended reachability TLV.
*
* @param trafEnginSubTlv traffic engineering sub TLV
*/
public void addSubTlv(TrafficEngineeringSubTlv trafEnginSubTlv) {
this.trafEnginSubTlv.add(trafEnginSubTlv);
}
@Override
public void readFrom(ChannelBuffer channelBuffer) {
byte[] tempByteArray = new byte[IsisUtil.ID_SIX_BYTES];
channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_SIX_BYTES);
this.setNeighborId(IsisUtil.systemId(tempByteArray));
this.setMetric(channelBuffer.readUnsignedMedium());
while (channelBuffer.readableBytes() > 0) {
TlvHeader tlvHeader = new TlvHeader();
tlvHeader.setTlvType(channelBuffer.readByte());
tlvHeader.setTlvLength(channelBuffer.readByte());
SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType());
if (tlvValue != null) {
this.addSubTlv(SubTlvFinder.findSubTlv(tlvHeader,
channelBuffer.readBytes(tlvHeader.tlvLength())));
} else {
channelBuffer.readBytes(tlvHeader.tlvLength());
}
}
}
@Override
public byte[] asBytes() {
byte[] bytes = null;
byte[] tlvHeader = tlvHeaderAsByteArray();
byte[] tlvBody = tlvBodyAsBytes();
tlvHeader[1] = (byte) tlvBody.length;
bytes = Bytes.concat(tlvHeader, tlvBody);
return bytes;
}
/**
* Returns TLV body of IS extended reachability TLV.
*
* @return byteArray TLV body of IS extended reachability TLV.
*/
private byte[] tlvBodyAsBytes() {
List<Byte> byteList = new ArrayList<>();
byteList.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborId()));
byteList.addAll(Bytes.asList(IsisUtil.convertToThreeBytes(this.metric())));
if (this.trafEnginSubTlv.size() > 0) {
for (TrafficEngineeringSubTlv trafficEngineeringSubTlv : this.trafEnginSubTlv) {
byteList.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv));
}
}
return Bytes.toArray(byteList);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.omitNullValues()
.add("neighborId", neighborId)
.add("metric", metric)
.add("trafEnginSubTlv", trafEnginSubTlv)
.toString();
}
}
......@@ -358,10 +358,7 @@ public class MetricOfInternalReachability {
} else {
this.setErrorMetricSupported(false);
}
List<Byte> byteList = new ArrayList<>();
while (channelBuffer.readableBytes() > 0) {
byteList.add(channelBuffer.readByte());
}
byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES];
channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES);
this.setIpAddress(Ip4Address.valueOf(tempByteArray));
......
......@@ -42,7 +42,10 @@ public class TlvFinder extends TlvHeader {
//TODO
break;
case EXTENDEDISREACHABILITY:
//TODO
IsExtendedReachability isExtendedReachability =
new IsExtendedReachability(tlvHeader);
isExtendedReachability.readFrom(channelBuffer);
isisTlv = isExtendedReachability;
break;
case HOSTNAME:
HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader);
......
......@@ -82,6 +82,10 @@ public final class TlvsToBytes {
LspEntriesTlv lspEntriesTlv
= (LspEntriesTlv) isisTlv;
tlvBytes.addAll(Bytes.asList(lspEntriesTlv.asBytes()));
} else if (isisTlv instanceof IsExtendedReachability) {
IsExtendedReachability isExtendedReachability
= (IsExtendedReachability) isisTlv;
tlvBytes.addAll(Bytes.asList(isExtendedReachability.asBytes()));
} else {
log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes ");
}
......
......@@ -16,21 +16,25 @@
package org.onosproject.isis.io.util;
import org.onlab.packet.Ip4Address;
/**
* Representation of ISIS Constants.
*/
public final class IsisConstants {
public static final char PDU_LENGTH = 1497; // mtu (1500) - (3) LLC
public static final char PDU_LENGTH = 1497;
public static final char CONFIG_LENGTH = 1498;
public static final int MINIMUM_FRAME_LEN = 1521;
public static final int METADATA_LEN = 7;
public static final String SHOST = "127.0.0.1";
public static final Ip4Address DEFAULTIP = Ip4Address.valueOf("0.0.0.0");
public static final int SPORT = 3000;
public static final byte L2 = 1;
public static final int IRPDISCRIMINATOR = 131;
public static final int ISISVERSION = 1;
public static final int RESERVED = 0;
public static final int MAXAREAADDRESS = 0;
public static final int IDLENGTH = 0;
public static final int SYSTEMIDLENGTH = 0;
public static final int PROTOCOLSUPPORTED = 204;
public static final int LOCALCIRCUITIDFORP2P = 130;
public static final int P2PHELLOHEADERLENGTH = 20;
......@@ -48,6 +52,27 @@ public final class IsisConstants {
public static final int CHECKSUMPOSITION = 24;
public static final String REFRESHLSP = "refreshLsp";
public static final String MAXAGELSP = "maxAgeLsp";
public static final String DEFAULTLANID = "0000.0000.0000.00";
public static final String PROCESSESID = "processId";
public static final String INTERFACE = "interface";
public static final String INTERFACEIP = "interfaceIp";
public static final String NETWORKMASK = "networkMask";
public static final String INTERFACEINDEX = "interfaceIndex";
public static final String INTERMEDIATESYSTEMNAME = "intermediateSystemName";
public static final String SYSTEMID = "systemId";
public static final String LANID = "lanId";
public static final String IDLENGTH = "idLength";
public static final String MAXAREAADDRESSES = "maxAreaAddresses";
public static final String RESERVEDPACKETCIRCUITTYPE = "reservedPacketCircuitType";
public static final String CIRCUITID = "circuitId";
public static final String NETWORKTYPE = "networkType";
public static final String AREAADDRESS = "areaAddress";
public static final String AREALENGTH = "areaLength";
public static final String LSPID = "lspId";
public static final String HOLDINGTIME = "holdingTime";
public static final String HELLOINTERVAL = "helloInterval";
public static final String PRIORITY = "priority";
public static final String MACADDRESS = "macAddress";
/**
* Non parameterized constructor.
......
......@@ -391,7 +391,7 @@ public final class IsisUtil {
isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
isisHeader.setPduHeaderLength((byte) IsisConstants.P2PHELLOHEADERLENGTH);
isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
isisHeader.setIdLength((byte) IsisConstants.IDLENGTH);
isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value());
isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
//isisHeader.setReserved((byte) IsisConstants.RESERVED);
......@@ -484,7 +484,7 @@ public final class IsisUtil {
isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
isisHeader.setPduHeaderLength((byte) IsisConstants.HELLOHEADERLENGTH);
isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
isisHeader.setIdLength((byte) IsisConstants.IDLENGTH);
isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
if (isisPduType == IsisPduType.L1HELLOPDU) {
isisHeader.setIsisPduType(IsisPduType.L1HELLOPDU.value());
lanId = isisInterface.l1LanId();
......@@ -693,4 +693,19 @@ public final class IsisUtil {
}
return prefix;
}
/**
* Converts the prefix to bytes.
*
* @param prefix prefix
* @return prefix to bytes
*/
public static byte[] prefixToBytes(String prefix) {
List<Byte> byteList = new ArrayList<>();
StringTokenizer tokenizer = new StringTokenizer(prefix, ".");
while (tokenizer.hasMoreTokens()) {
byteList.add((byte) Integer.parseInt(tokenizer.nextToken()));
}
return Bytes.toArray(byteList);
}
}
\ No newline at end of file
......
......@@ -26,6 +26,7 @@ import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas;
import org.onosproject.isis.io.isispacket.pdu.LsPdu;
import org.onosproject.isis.io.isispacket.tlv.AreaAddressTlv;
import org.onosproject.isis.io.isispacket.tlv.HostNameTlv;
import org.onosproject.isis.io.isispacket.tlv.IpExtendedReachabilityTlv;
import org.onosproject.isis.io.isispacket.tlv.IpInterfaceAddressTlv;
import org.onosproject.isis.io.isispacket.tlv.IpInternalReachabilityTlv;
import org.onosproject.isis.io.isispacket.tlv.IsReachabilityTlv;
......@@ -115,7 +116,7 @@ public class LspGenerator {
} else if (isisInterface.networkType() == IsisNetworkType.P2P) {
MacAddress neighborMac = isisInterface.neighbors().iterator().next();
IsisNeighbor neighbor = isisInterface.lookup(neighborMac);
metricsOfReachability.setNeighborId(neighbor.neighborSystemId());
metricsOfReachability.setNeighborId(neighbor.neighborSystemId() + ".00");
}
isReachabilityTlv.addMeticsOfReachability(metricsOfReachability);
......@@ -137,10 +138,25 @@ public class LspGenerator {
metricOfIntRea.setErrorMetric((byte) 0);
metricOfIntRea.setErrorMetricSupported(false);
metricOfIntRea.setExpenseIsInternal(true);
metricOfIntRea.setIpAddress(isisInterface.interfaceIpAddress());
Ip4Address ip4Address = isisInterface.interfaceIpAddress();
byte[] ipAddress = ip4Address.toOctets();
ipAddress[ipAddress.length - 1] = 0;
metricOfIntRea.setIpAddress(Ip4Address.valueOf(ipAddress));
metricOfIntRea.setSubnetAddres(Ip4Address.valueOf(isisInterface.networkMask()));
ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea);
lsp.addTlv(ipInterReacTlv);
tlvHeader.setTlvType(TlvType.IPEXTENDEDREACHABILITY.value());
tlvHeader.setTlvLength(0);
IpExtendedReachabilityTlv extendedTlv = new IpExtendedReachabilityTlv(tlvHeader);
extendedTlv.setDown(false);
extendedTlv.setMetric(10);
extendedTlv.setPrefix("192.168.7");
extendedTlv.setPrefixLength(24);
extendedTlv.setSubTlvLength((byte) 0);
extendedTlv.setSubTlvPresence(false);
lsp.addTlv(extendedTlv);
return lsp;
}
......@@ -149,7 +165,7 @@ public class LspGenerator {
isisHeader.setIrpDiscriminator((byte) IsisConstants.IRPDISCRIMINATOR);
isisHeader.setPduHeaderLength((byte) IsisUtil.getPduHeaderLength(pduType.value()));
isisHeader.setVersion((byte) IsisConstants.ISISVERSION);
isisHeader.setIdLength((byte) IsisConstants.IDLENGTH);
isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH);
isisHeader.setIsisPduType(pduType.value());
isisHeader.setVersion2((byte) IsisConstants.ISISVERSION);
isisHeader.setReserved((byte) IsisConstants.RESERVED);
......
......@@ -34,6 +34,7 @@
<modules>
<module>api</module>
<module>isisio</module>
<module>ctl</module>
</modules>
</project>
......