mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-12-15 22:31:50 +01:00
Fixed pom.xml issues and build issues. Corrected checkstyle issues
Change-Id: I90744f53e40f417ffe7ae62ffe138eea7a489bc0
This commit is contained in:
parent
156c480cf1
commit
aa48da8d16
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright 2014 Open Networking Laboratory
|
||||
~ 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.
|
||||
@ -29,7 +29,7 @@
|
||||
<artifactId>onos-ospf-api</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<description>ONOS Ospf controller subsystem API</description>
|
||||
<description>ONOS OSPF controller subsystem API</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@ -31,29 +31,11 @@
|
||||
<description>ONOS OSPF controller subsystem API</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-ospf-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
<artifactId>onos-ospf-protocol</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
||||
@ -65,8 +47,6 @@
|
||||
<dependency>
|
||||
<groupId>org.easymock</groupId>
|
||||
<artifactId>easymock</artifactId>
|
||||
<version>3.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -729,8 +729,8 @@ public class OspfAreaImpl implements OspfArea {
|
||||
if (nbr.getLsReqList().containsKey(key)) {
|
||||
LsaWrapper lsWrapper = lsaLookup(recLsa);
|
||||
if (lsWrapper != null) {
|
||||
LsaHeader ownLSA = (LsaHeader) lsWrapper.ospfLsa();
|
||||
String status = isNewerOrSameLsa(recLsa, ownLSA);
|
||||
LsaHeader ownLsa = (LsaHeader) lsWrapper.ospfLsa();
|
||||
String status = isNewerOrSameLsa(recLsa, ownLsa);
|
||||
if (status.equals("old")) {
|
||||
continue;
|
||||
} else if (status.equals("same")) {
|
||||
|
||||
@ -258,7 +258,7 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler {
|
||||
log.debug("OspfChannelHandler::List of OspfMessages Size {}", ospfMessageList.size());
|
||||
if (ospfMessageList != null) {
|
||||
for (OspfMessage ospfMessage : ospfMessageList) {
|
||||
processOSPFMessage(ospfMessage, ctx);
|
||||
processOspfMessage(ospfMessage, ctx);
|
||||
}
|
||||
} else {
|
||||
log.debug("OspfChannelHandler::OspfMessages Null List...!!");
|
||||
@ -267,7 +267,7 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler {
|
||||
if (message instanceof OspfMessage) {
|
||||
OspfMessage ospfMessage = (OspfMessage) message;
|
||||
log.debug("OspfChannelHandler::OspfMessages received...!!");
|
||||
processOSPFMessage(ospfMessage, ctx);
|
||||
processOspfMessage(ospfMessage, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,8 +280,8 @@ public class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler {
|
||||
* @param ctx channel handler context instance.
|
||||
* @throws Exception might throws exception
|
||||
*/
|
||||
public void processOSPFMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
|
||||
log.debug("OspfChannelHandler::processOSPFMessage...!!!");
|
||||
public void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception {
|
||||
log.debug("OspfChannelHandler::processOspfMessage...!!!");
|
||||
|
||||
if (!validateMessage(ospfMessage)) {
|
||||
return;
|
||||
|
||||
@ -1046,8 +1046,7 @@ public class OspfNbrImpl implements OspfNbr {
|
||||
|
||||
//If LSA type is external & the area is configured as stub area discard the lsa RFC 2328 13(3)
|
||||
if ((recLsa.getOspfLsaType() == OspfLsaType.EXTERNAL_LSA) &&
|
||||
(!ospfArea.isExternalRoutingCapability())) // to determine how to store options
|
||||
{
|
||||
(!ospfArea.isExternalRoutingCapability())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
package org.onosproject.ospf.controller.area;
|
||||
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -105,17 +104,12 @@ public class OspfAreaAddressRangeImplTest {
|
||||
*/
|
||||
@Test
|
||||
public void testEquals() throws Exception {
|
||||
assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(false));
|
||||
assertThat(ospfAreaAddressRange.equals(new OspfAreaAddressRangeImpl()), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests equals() method.
|
||||
* Tests hashCode() method.
|
||||
*/
|
||||
@Test
|
||||
public void testEquals1() throws Exception {
|
||||
assertThat(ospfAreaAddressRange.equals(EasyMock.createMock(OspfAreaAddressRange.class)), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() throws Exception {
|
||||
result = ospfAreaAddressRange.hashCode();
|
||||
|
||||
@ -186,22 +186,22 @@ public class OspfAreaImplTest {
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink));
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink));
|
||||
ospfNbrList.put("3.3.3.3", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
|
||||
Ip4Address.valueOf("1.1.1.1"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink));
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink));
|
||||
ospfNbrList.put("4.4.4.4", new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
|
||||
Ip4Address.valueOf("1.1.1.1"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink));
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink));
|
||||
|
||||
ospfInterface.setListOfNeighbors(ospfNbrList);
|
||||
ospfInterface.setIpAddress(Ip4Address.valueOf("10.10.10.10"));
|
||||
@ -265,8 +265,8 @@ public class OspfAreaImplTest {
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
ospfInterface1.addNeighbouringRouter(ospfNbr);
|
||||
ospfInterfaces.add(ospfInterface1);
|
||||
@ -290,8 +290,8 @@ public class OspfAreaImplTest {
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
ospfInterfaces = new ArrayList();
|
||||
ospfInterface1 = new OspfInterfaceImpl();
|
||||
@ -352,8 +352,8 @@ public class OspfAreaImplTest {
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
ospfInterface1.addNeighbouringRouter(ospfNbr);
|
||||
ospfInterfaces.add(ospfInterface1);
|
||||
@ -516,8 +516,8 @@ public class OspfAreaImplTest {
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.EXCHANGE.EXCHANGE);
|
||||
ospfInterface1.addNeighbouringRouter(ospfNbr);
|
||||
ospfInterfaces.add(ospfInterface1);
|
||||
@ -633,8 +633,8 @@ public class OspfAreaImplTest {
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
ospfInterface1.addNeighbouringRouter(ospfNbr);
|
||||
ospfInterfaces.add(ospfInterface1);
|
||||
@ -665,8 +665,8 @@ public class OspfAreaImplTest {
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
ospfInterface1.addNeighbouringRouter(ospfNbr);
|
||||
ospfInterfaces.add(ospfInterface1);
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.onosproject.ospf.controller.area;
|
||||
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@ -115,8 +114,8 @@ public class OspfInterfaceImplTest {
|
||||
ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
|
||||
Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
|
||||
ospfInterface.addNeighbouringRouter(ospfNbr);
|
||||
assertThat(ospfInterface, is(notNullValue()));
|
||||
@ -131,8 +130,8 @@ public class OspfInterfaceImplTest {
|
||||
ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
|
||||
Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
|
||||
ospfInterface.addNeighbouringRouter(ospfNbr);
|
||||
assertThat(ospfInterface.neighbouringRouter("111.111.111.111"), is(notNullValue()));
|
||||
@ -166,8 +165,8 @@ public class OspfInterfaceImplTest {
|
||||
ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
|
||||
Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
|
||||
ospfInterface.addNeighbouringRouter(ospfNbr);
|
||||
assertThat(ospfInterface.isNeighborInList("111.111.111.111"), is(notNullValue()));
|
||||
@ -183,8 +182,8 @@ public class OspfInterfaceImplTest {
|
||||
Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
|
||||
ospfNbrHashMap.put("111.111.111.111", ospfNbr);
|
||||
ospfInterface.setListOfNeighbors(ospfNbrHashMap);
|
||||
@ -200,8 +199,8 @@ public class OspfInterfaceImplTest {
|
||||
ospfNbr = new OspfNbrImpl(new OspfAreaImpl(), new OspfInterfaceImpl(),
|
||||
Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
|
||||
ospfNbrHashMap.put("111.111.111.111", ospfNbr);
|
||||
ospfInterface.setListOfNeighbors(ospfNbrHashMap);
|
||||
|
||||
@ -104,8 +104,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
ospfInterface)
|
||||
, topologyForDeviceAndLink);
|
||||
ospfInterface),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("10.10.10.10"));
|
||||
ospfNbr.setRouterPriority(0);
|
||||
ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
|
||||
@ -219,8 +219,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
Ip4Address.valueOf("1.1.1.1"), Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
new OspfAreaImpl(),
|
||||
new OspfInterfaceImpl())
|
||||
, topologyForDeviceAndLink);
|
||||
new OspfInterfaceImpl()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("111.111.111.111"));
|
||||
ospfNbrHashMap.put("111.111.111.111", ospfNbr);
|
||||
ospfNbr.setState(OspfNeighborState.EXCHANGE);
|
||||
@ -333,10 +333,10 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests processOSPFMessage() method.
|
||||
* Tests processOspfMessage() method.
|
||||
*/
|
||||
@Test
|
||||
public void testProcessOSPFMessage() throws Exception {
|
||||
public void testProcessOspfMessage() throws Exception {
|
||||
ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11"));
|
||||
ospfInterface.setIpNetworkMask(Ip4Address.valueOf("225.225.225.225"));
|
||||
ospfInterface.setInterfaceType(2);
|
||||
@ -364,7 +364,7 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
buf = ChannelBuffers.copiedBuffer(checkArray);
|
||||
helloPacket.setChecksum(buf.readUnsignedShort());
|
||||
message = helloPacket;
|
||||
ospfInterfaceChannelHandler.processOSPFMessage(message, channelHandlerContext);
|
||||
ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
|
||||
ddPacket = new DdPacket();
|
||||
ddPacket.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
|
||||
ddPacket.setRouterId(Ip4Address.valueOf("10.10.10.10"));
|
||||
@ -383,7 +383,7 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
buf = ChannelBuffers.copiedBuffer(checkArray);
|
||||
ddPacket.setChecksum(buf.readUnsignedShort());
|
||||
message = ddPacket;
|
||||
ospfInterfaceChannelHandler.processOSPFMessage(message, channelHandlerContext);
|
||||
ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
|
||||
lsRequest = new LsRequest();
|
||||
lsRequest.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
|
||||
lsRequest.setRouterId(Ip4Address.valueOf("10.10.10.10"));
|
||||
@ -401,7 +401,7 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
buf = ChannelBuffers.copiedBuffer(checkArray);
|
||||
lsRequest.setChecksum(buf.readUnsignedShort());
|
||||
message = lsRequest;
|
||||
ospfInterfaceChannelHandler.processOSPFMessage(message, channelHandlerContext);
|
||||
ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
|
||||
lsUpdate = new LsUpdate();
|
||||
lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
|
||||
lsUpdate.setRouterId(Ip4Address.valueOf("10.10.10.10"));
|
||||
@ -419,7 +419,7 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
buf = ChannelBuffers.copiedBuffer(checkArray);
|
||||
lsUpdate.setChecksum(buf.readUnsignedShort());
|
||||
message = lsUpdate;
|
||||
ospfInterfaceChannelHandler.processOSPFMessage(message, channelHandlerContext);
|
||||
ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
|
||||
lsAck = new LsAcknowledge();
|
||||
lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1"));
|
||||
lsAck.setRouterId(Ip4Address.valueOf("10.10.10.10"));
|
||||
@ -437,7 +437,7 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
buf = ChannelBuffers.copiedBuffer(checkArray);
|
||||
lsAck.setChecksum(buf.readUnsignedShort());
|
||||
message = lsAck;
|
||||
ospfInterfaceChannelHandler.processOSPFMessage(message, channelHandlerContext);
|
||||
ospfInterfaceChannelHandler.processOspfMessage(message, channelHandlerContext);
|
||||
assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
|
||||
|
||||
}
|
||||
@ -504,8 +504,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
ospfInterface)
|
||||
, topologyForDeviceAndLink);
|
||||
ospfInterface),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setRouterPriority(0);
|
||||
ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13"));
|
||||
@ -542,8 +542,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
ospfInterface)
|
||||
, topologyForDeviceAndLink);
|
||||
ospfInterface),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setLastDdPacket(createDdPacket());
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setState(OspfNeighborState.EXSTART);
|
||||
@ -583,8 +583,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
ospfInterface)
|
||||
, topologyForDeviceAndLink);
|
||||
ospfInterface),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setLastDdPacket(createDdPacket());
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setState(OspfNeighborState.EXSTART);
|
||||
@ -629,8 +629,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
ospfInterface)
|
||||
, topologyForDeviceAndLink);
|
||||
ospfInterface),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setLastDdPacket(createDdPacket());
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setState(OspfNeighborState.EXCHANGE);
|
||||
@ -676,8 +676,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
ospfInterface)
|
||||
, topologyForDeviceAndLink);
|
||||
ospfInterface),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setLastDdPacket(createDdPacket());
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setState(OspfNeighborState.LOADING);
|
||||
@ -733,8 +733,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("10.226.165.100"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
createOspfInterface1())
|
||||
, topologyForDeviceAndLink);
|
||||
createOspfInterface1()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setLastDdPacket(createDdPacket());
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
@ -775,8 +775,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("10.226.165.100"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
createOspfInterface1())
|
||||
, topologyForDeviceAndLink);
|
||||
createOspfInterface1()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setLastDdPacket(createDdPacket());
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
@ -809,8 +809,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("10.226.165.100"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
createOspfInterface())
|
||||
, topologyForDeviceAndLink);
|
||||
createOspfInterface()),
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setLastDdPacket(createDdPacket());
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2"));
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
@ -976,8 +976,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("10.226.165.100"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
createOspfInterface())
|
||||
, topologyForDeviceAndLink);
|
||||
createOspfInterface()),
|
||||
topologyForDeviceAndLink);
|
||||
|
||||
ospfInterfaceChannelHandler.addDeviceInformation(new OspfRouterImpl());
|
||||
assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
|
||||
@ -991,8 +991,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("10.226.165.100"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
createOspfInterface())
|
||||
, topologyForDeviceAndLink);
|
||||
createOspfInterface()),
|
||||
topologyForDeviceAndLink);
|
||||
|
||||
ospfInterfaceChannelHandler.removeDeviceInformation(new OspfRouterImpl());
|
||||
assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
|
||||
@ -1006,8 +1006,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("10.226.165.100"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
createOspfInterface())
|
||||
, topologyForDeviceAndLink);
|
||||
createOspfInterface()),
|
||||
topologyForDeviceAndLink);
|
||||
|
||||
List topTlv = new ArrayList();
|
||||
topTlv.add(new RouterTlv(new TlvHeader()));
|
||||
@ -1023,8 +1023,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"),
|
||||
Ip4Address.valueOf("10.226.165.100"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(), ospfArea,
|
||||
createOspfInterface())
|
||||
, topologyForDeviceAndLink);
|
||||
createOspfInterface()),
|
||||
topologyForDeviceAndLink);
|
||||
|
||||
ospfInterfaceChannelHandler.removeLinkInformation(ospfNbr);
|
||||
assertThat(ospfInterfaceChannelHandler, is(notNullValue()));
|
||||
@ -1052,8 +1052,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
|
||||
OspfInterfaceChannelHandler.class);
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
|
||||
Ip4Address.valueOf("1.1.1.1"), 2, ospfInterfaceChannelHandler
|
||||
, topologyForDeviceAndLink);
|
||||
Ip4Address.valueOf("1.1.1.1"), 2, ospfInterfaceChannelHandler,
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.EXSTART);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
|
||||
this.ospfInterface = new OspfInterfaceImpl();
|
||||
@ -1087,8 +1087,8 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
|
||||
OspfInterfaceChannelHandler.class);
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("10.226.165.164"),
|
||||
Ip4Address.valueOf("1.1.1.1"), 2, ospfInterfaceChannelHandler
|
||||
, topologyForDeviceAndLink);
|
||||
Ip4Address.valueOf("1.1.1.1"), 2, ospfInterfaceChannelHandler,
|
||||
topologyForDeviceAndLink);
|
||||
ospfNbr.setState(OspfNeighborState.FULL);
|
||||
ospfNbr.setNeighborId(Ip4Address.valueOf("10.226.165.100"));
|
||||
ospfInterface = new OspfInterfaceImpl();
|
||||
@ -1153,5 +1153,4 @@ public class OspfInterfaceChannelHandlerTest {
|
||||
ospfAreaAddressRange.setMask("mask");
|
||||
return ospfAreaAddressRange;
|
||||
}
|
||||
|
||||
}
|
||||
@ -47,8 +47,8 @@ public class OspfMessageDecoderTest {
|
||||
-88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48};
|
||||
private final byte[] lsUpdatePacket = {0, 0, 0, 0, 2, 4, 0, 76, -64, -88, -86, 3, 0, 0, 0, 1, 7, 111,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 14, 16, 2, 1, -64, -88,
|
||||
-86, 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48, 2, 0, 0, 2
|
||||
, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10};
|
||||
-86, 2, -64, -88, -86, 2, -128, 0, 0, 1, 74, -114, 0, 48, 2, 0, 0, 2,
|
||||
-64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10};
|
||||
private final byte[] lsRequestPacket = {0, 0, 0, 0, 2, 3, 0, 36, -64, -88, -86, 3, 0, 0, 0, 1, -67, -57,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -64, -88, -86, 8, -64, -88, -86, 8};
|
||||
private OspfMessageDecoder ospfMessageDecoder;
|
||||
@ -80,7 +80,5 @@ public class OspfMessageDecoderTest {
|
||||
socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
|
||||
channelBuffer = ChannelBuffers.copiedBuffer(hellopacket);
|
||||
assertThat(ospfMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,6 @@ import org.onosproject.ospf.controller.area.OspfInterfaceImpl;
|
||||
import org.onosproject.ospf.controller.lsdb.LsaWrapperImpl;
|
||||
import org.onosproject.ospf.controller.lsdb.LsdbAgeImpl;
|
||||
import org.onosproject.ospf.protocol.lsa.LsaHeader;
|
||||
|
||||
import org.onosproject.ospf.protocol.lsa.types.NetworkLsa;
|
||||
import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
|
||||
import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
|
||||
@ -42,7 +41,6 @@ import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
|
||||
import org.onosproject.ospf.protocol.ospfpacket.types.LsRequest;
|
||||
import org.onosproject.ospf.protocol.ospfpacket.types.LsUpdate;
|
||||
import org.onosproject.ospf.protocol.util.ChecksumCalculator;
|
||||
|
||||
import org.onosproject.ospf.protocol.util.OspfUtil;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
@ -102,8 +100,8 @@ public class OspfNbrImplTest {
|
||||
ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, Ip4Address.valueOf("1.1.1.1"),
|
||||
Ip4Address.valueOf("2.2.2.2"), 2,
|
||||
new OspfInterfaceChannelHandler(new Controller(),
|
||||
ospfArea, ospfInterface)
|
||||
, topologyForDeviceAndLink);
|
||||
ospfArea, ospfInterface),
|
||||
topologyForDeviceAndLink);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ public class LsaWrapperImplTest {
|
||||
* Tests addLsa() method.
|
||||
*/
|
||||
@Test
|
||||
public void testAddLSA() throws Exception {
|
||||
public void testAddLsa() throws Exception {
|
||||
lsaWrapper.addLsa(OspfLsaType.ROUTER, new RouterLsa());
|
||||
assertThat(lsaWrapper, is(notNullValue()));
|
||||
}
|
||||
@ -216,7 +216,7 @@ public class LsaWrapperImplTest {
|
||||
* Tests isSentReplyForOlderLsa() method.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSentReplyForOlderLSA() throws Exception {
|
||||
public void testIsSentReplyForOlderLsa() throws Exception {
|
||||
lsaWrapper.setSentReplyForOlderLsa(true);
|
||||
assertThat(lsaWrapper.isSentReplyForOlderLsa(), is(true));
|
||||
}
|
||||
@ -230,15 +230,6 @@ public class LsaWrapperImplTest {
|
||||
assertThat(lsaWrapper.isCheckAge(), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests isCheckAge() setter method.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSentReplyForOlderLsa() throws Exception {
|
||||
lsaWrapper.setIsSequenceRollOver(true);
|
||||
assertThat(lsaWrapper.isSequenceRollOver(), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests isSentReplyForOlderLsa() getter method.
|
||||
*/
|
||||
|
||||
@ -65,8 +65,6 @@ public class OspfLsdbImplTest {
|
||||
opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader());
|
||||
opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader());
|
||||
externalLsa = new ExternalLsa(new LsaHeader());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
@ -130,7 +128,6 @@ public class OspfLsdbImplTest {
|
||||
assertThat(ospfLsdb.addLsa(externalLsa, false, new OspfInterfaceImpl()), is(true));
|
||||
ospfLsdb.initializeDb();
|
||||
assertThat(ospfLsdb.getAllLsaHeaders(true, true).size(), is(5));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,7 +233,7 @@ public class OspfLsdbImplTest {
|
||||
* Tests addLSA() method.
|
||||
*/
|
||||
@Test
|
||||
public void testAddLSA() throws Exception {
|
||||
public void testAddLsa() throws Exception {
|
||||
routerLsa.setLsType(1);
|
||||
assertThat(ospfLsdb.addLsa(routerLsa, false, new OspfInterfaceImpl()), is(true));
|
||||
networkLsa.setLsType(2);
|
||||
@ -380,7 +377,7 @@ public class OspfLsdbImplTest {
|
||||
* Tests isNewerOrSameLsa() method.
|
||||
*/
|
||||
@Test
|
||||
public void testIsNewerorSameLSA() throws Exception {
|
||||
public void testIsNewerorSameLsa() throws Exception {
|
||||
lsaWrapper = new LsaWrapperImpl();
|
||||
opaqueLsaHeader1 = new OpaqueLsaHeader();
|
||||
opaqueLsaHeader1.setLsType(1);
|
||||
|
||||
@ -33,8 +33,8 @@
|
||||
|
||||
<modules>
|
||||
<module>api</module>
|
||||
<!--module>ctl</module-->
|
||||
<!--module>protocol</module-->
|
||||
<module>ctl</module>
|
||||
<module>protocol</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
~ Copyright 2014 Open Networking Laboratory
|
||||
~ 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.
|
||||
@ -28,7 +28,7 @@
|
||||
<artifactId>onos-ospf-protocol</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<description>ONOS Ospf controller protocol</description>
|
||||
<description>ONOS OSPF controller protocol</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.onosproject</groupId>
|
||||
|
||||
@ -136,7 +136,7 @@ public class NetworkLsa extends LsaHeader {
|
||||
byte[] lsaMessage = null;
|
||||
|
||||
byte[] lsaHeader = getLsaHeaderAsByteArray();
|
||||
byte[] lsaBody = getLSABodyAsByteArray();
|
||||
byte[] lsaBody = getLsaBodyAsByteArray();
|
||||
lsaMessage = Bytes.concat(lsaHeader, lsaBody);
|
||||
|
||||
return lsaMessage;
|
||||
@ -148,7 +148,7 @@ public class NetworkLsa extends LsaHeader {
|
||||
* @return LSA body as byte array
|
||||
* @throws OspfParseException might throws exception while parsing packet
|
||||
*/
|
||||
public byte[] getLSABodyAsByteArray() throws OspfParseException {
|
||||
public byte[] getLsaBodyAsByteArray() throws OspfParseException {
|
||||
List<Byte> bodyLst = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the different types of OSPF Packets.
|
||||
*/
|
||||
package org.onosproject.ospf.protocol.ospfpacket;
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the different types of OSPF Packets.
|
||||
*/
|
||||
package org.onosproject.ospf.protocol.ospfpacket;
|
||||
|
||||
@ -13,36 +13,184 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.onosproject.ospf.protocol.util;
|
||||
package org.onosproject.ospf.protocol.ospfpacket.types;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.onlab.packet.Ip4Address;
|
||||
import org.onosproject.ospf.exceptions.OspfParseException;
|
||||
import org.onosproject.ospf.protocol.ospfpacket.OspfPacketHeader;
|
||||
import org.onosproject.ospf.protocol.ospfpacket.subtype.LsRequestPacket;
|
||||
import org.onosproject.ospf.protocol.util.OspfPacketType;
|
||||
import org.onosproject.ospf.protocol.util.OspfUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Representation of different OSPF packet types.
|
||||
* Representation of an OSPF Link State Request packet.
|
||||
* Link State Request packets are OSPF packet type 3. After exchanging
|
||||
* database description packets with a neighboring router, a router may
|
||||
* find that parts of its link-state database are out-of-date. The
|
||||
* Link State Request packet is used to request the pieces of the
|
||||
* neighbor's database that are more up-to-date.
|
||||
*/
|
||||
public enum OspfPacketType {
|
||||
public class LsRequest extends OspfPacketHeader {
|
||||
/*
|
||||
0 1 2 3
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Version # | 3 | Packet length |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Router ID |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Area ID |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Checksum | AuType |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Authentication |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Authentication |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| LS type |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Link State ID |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Advertising Router |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| ... |
|
||||
|
||||
HELLO(1),
|
||||
DD(2),
|
||||
LSREQUEST(3),
|
||||
LSUPDATE(4),
|
||||
LSAACK(5);
|
||||
|
||||
private int value;
|
||||
LsRequest Message Format
|
||||
REFERENCE : RFC 2328
|
||||
*/
|
||||
private static final Logger log = LoggerFactory.getLogger(LsRequest.class);
|
||||
private List<LsRequestPacket> linkStateRequests = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates instance of OSPF packet types.
|
||||
*
|
||||
* @param value
|
||||
* Creates an instance of link state request packet.
|
||||
*/
|
||||
OspfPacketType(int value) {
|
||||
this.value = value;
|
||||
public LsRequest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
* Creates an instance of link state request packet.
|
||||
*
|
||||
* @return value
|
||||
* @param ospfHeader OSPF header instance.
|
||||
*/
|
||||
public int value() {
|
||||
return value;
|
||||
public LsRequest(OspfPacketHeader ospfHeader) {
|
||||
populateHeader(ospfHeader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds link state request.
|
||||
*
|
||||
* @param lsRequestPacket ls request packet instance
|
||||
*/
|
||||
public void addLinkStateRequests(LsRequestPacket lsRequestPacket) {
|
||||
if (!linkStateRequests.contains(lsRequestPacket)) {
|
||||
linkStateRequests.add(lsRequestPacket);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets link state request packet instance.
|
||||
*
|
||||
* @return link state request packet instance
|
||||
*/
|
||||
public List<LsRequestPacket> getLinkStateRequests() {
|
||||
return linkStateRequests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OspfPacketType ospfMessageType() {
|
||||
return OspfPacketType.LSREQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(ChannelBuffer channelBuffer) throws OspfParseException {
|
||||
|
||||
while (channelBuffer.readableBytes() >= OspfUtil.LSREQUEST_LENGTH) {
|
||||
LsRequestPacket lsRequestPacket = new LsRequestPacket();
|
||||
lsRequestPacket.setLsType(channelBuffer.readInt());
|
||||
byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES];
|
||||
channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
|
||||
lsRequestPacket.setLinkStateId(Ip4Address.valueOf(tempByteArray).toString());
|
||||
tempByteArray = new byte[OspfUtil.FOUR_BYTES];
|
||||
channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES);
|
||||
lsRequestPacket.setOwnRouterId(Ip4Address.valueOf(tempByteArray).toString());
|
||||
|
||||
this.addLinkStateRequests(lsRequestPacket);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] asBytes() {
|
||||
byte[] lsrMessage = null;
|
||||
byte[] lsrHeader = getLsrHeaderAsByteArray();
|
||||
byte[] lsrBody = getLsrBodyAsByteArray();
|
||||
lsrMessage = Bytes.concat(lsrHeader, lsrBody);
|
||||
|
||||
return lsrMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets LS request packet header as byte array.
|
||||
*
|
||||
* @return LS request packet header as byte array
|
||||
*/
|
||||
public byte[] getLsrHeaderAsByteArray() {
|
||||
List<Byte> headerLst = new ArrayList<>();
|
||||
|
||||
try {
|
||||
headerLst.add((byte) this.ospfVersion());
|
||||
headerLst.add((byte) this.ospfType());
|
||||
headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.ospfPacLength())));
|
||||
headerLst.addAll(Bytes.asList(this.routerId().toOctets()));
|
||||
headerLst.addAll(Bytes.asList(this.areaId().toOctets()));
|
||||
headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.checksum())));
|
||||
headerLst.addAll(Bytes.asList(OspfUtil.convertToTwoBytes(this.authType())));
|
||||
//Authentication is 0 always. Total 8 bytes consist of zero
|
||||
byte[] auth = new byte[OspfUtil.EIGHT_BYTES];
|
||||
headerLst.addAll(Bytes.asList(auth));
|
||||
} catch (Exception e) {
|
||||
log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
|
||||
return Bytes.toArray(headerLst);
|
||||
}
|
||||
|
||||
return Bytes.toArray(headerLst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets LS request packet body as byte array.
|
||||
*
|
||||
* @return LS request packet body as byte array
|
||||
*/
|
||||
public byte[] getLsrBodyAsByteArray() {
|
||||
List<Byte> bodyLst = new ArrayList<>();
|
||||
|
||||
try {
|
||||
for (LsRequestPacket lsrPacket : linkStateRequests) {
|
||||
bodyLst.addAll(Bytes.asList(OspfUtil.convertToFourBytes(lsrPacket.lsType())));
|
||||
bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsrPacket.linkStateId()).getAddress()));
|
||||
bodyLst.addAll(Bytes.asList(InetAddress.getByName(lsrPacket.ownRouterId()).getAddress()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("Error::getLsrBodyAsByteArray {}", e.getMessage());
|
||||
return Bytes.toArray(bodyLst);
|
||||
}
|
||||
|
||||
return Bytes.toArray(bodyLst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(getClass())
|
||||
.omitNullValues()
|
||||
.add("linkStateRequests", linkStateRequests)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -181,9 +181,9 @@ public class LsUpdate extends OspfPacketHeader {
|
||||
addLsa(asbrSummaryLsa);
|
||||
break;
|
||||
case OspfParameters.SUMMARY:
|
||||
SummaryLsa summaryLSA = new SummaryLsa(header);
|
||||
summaryLSA.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
|
||||
addLsa(summaryLSA);
|
||||
SummaryLsa summaryLsa = new SummaryLsa(header);
|
||||
summaryLsa.readFrom(channelBuffer.readBytes(lsaLength - OspfUtil.LSA_HEADER_LENGTH));
|
||||
addLsa(summaryLsa);
|
||||
break;
|
||||
case OspfParameters.EXTERNAL_LSA:
|
||||
ExternalLsa externalLsa = new ExternalLsa(header);
|
||||
|
||||
@ -97,7 +97,7 @@ public class UnreservedBandwidthTest {
|
||||
* Tests getLinkSubTypeTlvBodyAsByteArray() method.
|
||||
*/
|
||||
@Test
|
||||
public void testGetLinkSubTypeTLVBodyAsByteArray() throws Exception {
|
||||
public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
|
||||
result = unreservedBandwidth.getLinkSubTypeTlvBodyAsByteArray();
|
||||
assertThat(result, is(notNullValue()));
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ public class RouterTlvTest {
|
||||
* Tests getTlvBodyAsByteArray() method.
|
||||
*/
|
||||
@Test(expected = Exception.class)
|
||||
public void testGetTLVBodyAsByteArray() throws Exception {
|
||||
public void testGetTlvBodyAsByteArray() throws Exception {
|
||||
result = rtlv.getTlvBodyAsByteArray();
|
||||
assertThat(result, is(notNullValue()));
|
||||
}
|
||||
@ -124,4 +124,4 @@ public class RouterTlvTest {
|
||||
public void testToString() throws Exception {
|
||||
assertThat(rtlv.toString(), is(notNullValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -164,7 +164,7 @@ public class NetworkLsaTest {
|
||||
networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
|
||||
networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2"));
|
||||
networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3"));
|
||||
result1 = networkLsa.getLSABodyAsByteArray();
|
||||
result1 = networkLsa.getLsaBodyAsByteArray();
|
||||
assertThat(result1, is(notNullValue()));
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ public class NetworkLsaTest {
|
||||
networkLsa.addAttachedRouter(Ip4Address.valueOf("1.1.1.1"));
|
||||
networkLsa.addAttachedRouter(Ip4Address.valueOf("2.2.2.2"));
|
||||
networkLsa.addAttachedRouter(Ip4Address.valueOf("3.3.3.3"));
|
||||
result1 = networkLsa.getLSABodyAsByteArray();
|
||||
result1 = networkLsa.getLsaBodyAsByteArray();
|
||||
assertThat(result1, is(notNullValue()));
|
||||
}
|
||||
|
||||
|
||||
@ -43,9 +43,9 @@ public class OspfMessageReaderTest {
|
||||
-86, 8, -64, -88, -86, 8};
|
||||
private final byte[] packet4 = {1, 1, 1, 1, 2, 4, 1, 36, -64, -88, -86, 3, 0,
|
||||
0, 0, 1, 54, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
|
||||
2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0
|
||||
, 0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86
|
||||
, 0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0,
|
||||
2, 2, 1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0,
|
||||
0, 1, 58, -100, 0, 48, 2, 0, 0, 2, -64, -88, -86,
|
||||
0, -1, -1, -1, 0, 3, 0, 0, 10, -64, -88, -86, 0,
|
||||
-1, -1, -1, 0, 3, 0, 0, 10, 0, 3, 2, 5, 80, -44,
|
||||
16, 0, -64, -88, -86, 2, -128, 0, 0, 1, 42, 73, 0,
|
||||
36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0, 0, 0, 0,
|
||||
@ -55,8 +55,8 @@ public class OspfMessageReaderTest {
|
||||
3, 2, 5, -64, -126, 120, 0, -64, -88, -86, 2, -128, 0,
|
||||
0, 1, -45, 25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0,
|
||||
-64, -88, -86, 2, -128, 0, 0, 1, 55, 8, 0, 36, -1, -1
|
||||
, -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
-64, -88, -86, 2, -128, 0, 0, 1, 55, 8, 0, 36, -1, -1,
|
||||
-1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
3, 2, 5, -64, -88, 1, 0, -64, -88, -86, 2, -128, 0, 0,
|
||||
1, 44, 18, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -64, -88, -84, 0, -64,
|
||||
@ -101,4 +101,4 @@ public class OspfMessageReaderTest {
|
||||
assertThat(ospfMessageReader, is(notNullValue()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,17 +95,6 @@ public class LsAcknowledgeTest {
|
||||
assertThat(lsAck, is(notNullValue()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests ospfMessageType() getter method.
|
||||
*/
|
||||
@Test
|
||||
public void testGetOSPFMessageType() throws Exception {
|
||||
ospfPacketType = lsAck.ospfMessageType();
|
||||
assertThat(ospfPacketType, is(notNullValue()));
|
||||
assertThat(ospfPacketType, is(OspfPacketType.LSAACK));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ospfMessageType() getter method.
|
||||
*/
|
||||
|
||||
@ -102,7 +102,7 @@ public class LsUpdateTest {
|
||||
private SummaryLsa ospflsa2;
|
||||
private AsbrSummaryLsa ospflsa3;
|
||||
private ExternalLsa ospflsa4;
|
||||
private Vector<OspfLsa> listLSA = new Vector();
|
||||
private Vector<OspfLsa> listLsa = new Vector();
|
||||
private List lsa;
|
||||
private int result;
|
||||
private OspfPacketType ospfMessageType;
|
||||
@ -151,7 +151,7 @@ public class LsUpdateTest {
|
||||
ospflsa2 = null;
|
||||
ospflsa3 = null;
|
||||
ospflsa4 = null;
|
||||
listLSA.clear();
|
||||
listLsa.clear();
|
||||
lsa = null;
|
||||
ospfMessageType = null;
|
||||
ospfPacketHeader = null;
|
||||
@ -325,13 +325,13 @@ public class LsUpdateTest {
|
||||
byte[] lsUpdatePacket = {0, 0, 0, 7, 0, 2, 2,
|
||||
1, -64, -88, -86, 3, -64, -88, -86, 3, -128, 0, 0, 1, 58,
|
||||
-100, 0, 48, 2, 0, 0, 2, -64, -88, -86, 0, -1, -1, -1, 0,
|
||||
3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10
|
||||
, 0, 3, 2, 5, 80, -44, 16, 0, -64, -88, -86, 2, -128, 0, 0
|
||||
, 1, 42, 73, 0, 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -108, 121, -85, 0, -64, -88
|
||||
, -86, 2, -128, 0, 0, 1, 52, -91, 0, 36, -1, -1, -1, 0,
|
||||
-128, 0, 0, 20, -64, -88, -86, 1, 0, 0, 0, 0, 0, 3, 2, 5
|
||||
, -64, -126, 120, 0, -64, -88, -86, 2, -128, 0, 0, 1, -45,
|
||||
3, 0, 0, 10, -64, -88, -86, 0, -1, -1, -1, 0, 3, 0, 0, 10,
|
||||
0, 3, 2, 5, 80, -44, 16, 0, -64, -88, -86, 2, -128, 0, 0,
|
||||
1, 42, 73, 0, 36, -1, -1, -1, -1, -128, 0, 0, 20, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 3, 2, 5, -108, 121, -85, 0, -64, -88,
|
||||
-86, 2, -128, 0, 0, 1, 52, -91, 0, 36, -1, -1, -1, 0,
|
||||
-128, 0, 0, 20, -64, -88, -86, 1, 0, 0, 0, 0, 0, 3, 2, 5,
|
||||
-64, -126, 120, 0, -64, -88, -86, 2, -128, 0, 0, 1, -45,
|
||||
25, 0, 36, -1, -1, -1, 0, -128, 0, 0, 20, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 3, 2, 5, -64, -88, 0, 0, -64, -88, -86, 2,
|
||||
-128, 0, 0, 1, 55, 8, 0, 36, -1, -1, -1, 0, -128, 0, 0,
|
||||
|
||||
@ -295,8 +295,8 @@ public class OspfUtilTest {
|
||||
48, 0, 0, 0, 2, 1, 1, 1, 1, 10, 10, 10, 7, 1, 0, 0, 10, 10, 10, 10, 0, -1, -1, -1,
|
||||
0, 3, 0, 0, 10, 0, 10, 66, 10, 1, 0, 0, 1, 7, 7, 7, 7, -128, 0, 0, 1, -64, 79, 0,
|
||||
116, 0, 1, 0, 4, 0, 0, 0, 0, 0, 2, 0, 84, 0, 1, 0, 1, 1, 0, 0, 0, 0, 2, 0, 4, 10,
|
||||
10, 10, 0, 0, 5, 0, 4, 0, 0, 0, 0, 0, 6, 0, 4, 73, -104, -106, -128, 0, 7, 0, 4, 73
|
||||
, -104, -106, -128, 0, 8, 0, 32, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106,
|
||||
10, 10, 0, 0, 5, 0, 4, 0, 0, 0, 0, 0, 6, 0, 4, 73, -104, -106, -128, 0, 7, 0, 4, 73,
|
||||
-104, -106, -128, 0, 8, 0, 32, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106,
|
||||
-128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128, 73, -104, -106, -128,
|
||||
73, -104, -106, -128, 0, 9, 0, 4, 0, 0, 0, 0};
|
||||
channelBuffer = ChannelBuffers.copiedBuffer(header);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user