Fixed pom.xml issues and build issues. Corrected checkstyle issues
Change-Id: I90744f53e40f417ffe7ae62ffe138eea7a489bc0
diff --git a/protocols/ospf/api/pom.xml b/protocols/ospf/api/pom.xml
index a7b243b..5ace5f7 100755
--- a/protocols/ospf/api/pom.xml
+++ b/protocols/ospf/api/pom.xml
@@ -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>
diff --git a/protocols/ospf/ctl/pom.xml b/protocols/ospf/ctl/pom.xml
index 454837e..54e043e 100755
--- a/protocols/ospf/ctl/pom.xml
+++ b/protocols/ospf/ctl/pom.xml
@@ -33,27 +33,9 @@
<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>
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
index 2c33ed5..5a0ca82 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaImpl.java
@@ -729,8 +729,8 @@
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")) {
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
index aac1322..3bb5dce 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandler.java
@@ -258,7 +258,7 @@
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 @@
if (message instanceof OspfMessage) {
OspfMessage ospfMessage = (OspfMessage) message;
log.debug("OspfChannelHandler::OspfMessages received...!!");
- processOSPFMessage(ospfMessage, ctx);
+ processOspfMessage(ospfMessage, ctx);
}
}
@@ -280,8 +280,8 @@
* @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;
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
index 0d284bf..77a0d53 100755
--- a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/OspfNbrImpl.java
@@ -1046,8 +1046,7 @@
//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;
}
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImplTest.java
index 6c58238..9ed3677 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImplTest.java
@@ -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,18 +104,13 @@
*/
@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();
assertThat(result, is(notNullValue()));
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
index f7b40fa..bb957b9 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfAreaImplTest.java
@@ -186,22 +186,22 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
index 4285d90..743867a 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/area/OspfInterfaceImplTest.java
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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);
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
index 8c2e969..aeb7131 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfInterfaceChannelHandlerTest.java
@@ -104,8 +104,8 @@
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 @@
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 @@
}
/**
- * 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
ospfAreaAddressRange.setMask("mask");
return ospfAreaAddressRange;
}
-
}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
index 753ad6c..9482f19 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfMessageDecoderTest.java
@@ -47,8 +47,8 @@
-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 @@
socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
channelBuffer = ChannelBuffers.copiedBuffer(hellopacket);
assertThat(ospfMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue()));
-
-
}
}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
index 8d08220..1c29155 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/impl/OspfNbrImplTest.java
@@ -33,7 +33,6 @@
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.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 @@
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);
}
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImplTest.java
index b8d95c7..29bc6b3 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImplTest.java
@@ -91,7 +91,7 @@
* 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 @@
* Tests isSentReplyForOlderLsa() method.
*/
@Test
- public void testIsSentReplyForOlderLSA() throws Exception {
+ public void testIsSentReplyForOlderLsa() throws Exception {
lsaWrapper.setSentReplyForOlderLsa(true);
assertThat(lsaWrapper.isSentReplyForOlderLsa(), is(true));
}
@@ -231,15 +231,6 @@
}
/**
- * Tests isCheckAge() setter method.
- */
- @Test
- public void testIsSentReplyForOlderLsa() throws Exception {
- lsaWrapper.setIsSequenceRollOver(true);
- assertThat(lsaWrapper.isSequenceRollOver(), is(true));
- }
-
- /**
* Tests isSentReplyForOlderLsa() getter method.
*/
@Test
diff --git a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImplTest.java b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImplTest.java
index 272344d..6ecfb00 100755
--- a/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImplTest.java
+++ b/protocols/ospf/ctl/src/test/java/org/onosproject/ospf/controller/lsdb/OspfLsdbImplTest.java
@@ -65,8 +65,6 @@
opaqueLsa10 = new OpaqueLsa10(new OpaqueLsaHeader());
opaqueLsa11 = new OpaqueLsa11(new OpaqueLsaHeader());
externalLsa = new ExternalLsa(new LsaHeader());
-
-
}
@After
@@ -130,7 +128,6 @@
assertThat(ospfLsdb.addLsa(externalLsa, false, new OspfInterfaceImpl()), is(true));
ospfLsdb.initializeDb();
assertThat(ospfLsdb.getAllLsaHeaders(true, true).size(), is(5));
-
}
/**
@@ -236,7 +233,7 @@
* 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 @@
* Tests isNewerOrSameLsa() method.
*/
@Test
- public void testIsNewerorSameLSA() throws Exception {
+ public void testIsNewerorSameLsa() throws Exception {
lsaWrapper = new LsaWrapperImpl();
opaqueLsaHeader1 = new OpaqueLsaHeader();
opaqueLsaHeader1.setLsType(1);
diff --git a/protocols/ospf/pom.xml b/protocols/ospf/pom.xml
index 1a29f8b..b37086c 100755
--- a/protocols/ospf/pom.xml
+++ b/protocols/ospf/pom.xml
@@ -33,8 +33,8 @@
<modules>
<module>api</module>
- <!--module>ctl</module-->
- <!--module>protocol</module-->
+ <module>ctl</module>
+ <module>protocol</module>
</modules>
</project>
diff --git a/protocols/ospf/protocol/pom.xml b/protocols/ospf/protocol/pom.xml
index 606450e..cdfb64b 100644
--- a/protocols/ospf/protocol/pom.xml
+++ b/protocols/ospf/protocol/pom.xml
@@ -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>
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
index 07465b2..8dbe3a3 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsa.java
@@ -136,7 +136,7 @@
byte[] lsaMessage = null;
byte[] lsaHeader = getLsaHeaderAsByteArray();
- byte[] lsaBody = getLSABodyAsByteArray();
+ byte[] lsaBody = getLsaBodyAsByteArray();
lsaMessage = Bytes.concat(lsaHeader, lsaBody);
return lsaMessage;
@@ -148,7 +148,7 @@
* @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 {
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java
index 592020d..e7e0e8e 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/package-info.java
@@ -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;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
index 636d1b6..f1940df 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsRequest.java
@@ -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();
}
}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
index e9c80e2..41ab3da 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdate.java
@@ -181,9 +181,9 @@
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);
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java
index 0357ea1..cc21712 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/linksubtype/UnreservedBandwidthTest.java
@@ -97,7 +97,7 @@
* Tests getLinkSubTypeTlvBodyAsByteArray() method.
*/
@Test
- public void testGetLinkSubTypeTLVBodyAsByteArray() throws Exception {
+ public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception {
result = unreservedBandwidth.getLinkSubTypeTlvBodyAsByteArray();
assertThat(result, is(notNullValue()));
}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java
index 9a3d10e..e946ec0 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/tlvtypes/RouterTlvTest.java
@@ -112,7 +112,7 @@
* 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 void testToString() throws Exception {
assertThat(rtlv.toString(), is(notNullValue()));
}
-}
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java
index ecbd449..d2f1a2c 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/lsa/types/NetworkLsaTest.java
@@ -164,7 +164,7 @@
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 @@
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()));
}
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
index 8b1d089..8d11f11 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/OspfMessageReaderTest.java
@@ -43,9 +43,9 @@
-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 @@
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 @@
assertThat(ospfMessageReader, is(notNullValue()));
}
-}
+}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
index dd5af91..efbcce7 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsAcknowledgeTest.java
@@ -95,17 +95,6 @@
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.
*/
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
index 8d48099..9607bc1 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/ospfpacket/types/LsUpdateTest.java
@@ -102,7 +102,7 @@
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 @@
ospflsa2 = null;
ospflsa3 = null;
ospflsa4 = null;
- listLSA.clear();
+ listLsa.clear();
lsa = null;
ospfMessageType = null;
ospfPacketHeader = null;
@@ -325,13 +325,13 @@
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,
diff --git a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
index 750a08d..ccc64f3 100644
--- a/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
+++ b/protocols/ospf/protocol/src/test/java/org/onosproject/ospf/protocol/util/OspfUtilTest.java
@@ -295,8 +295,8 @@
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);