Fixed pom.xml issues and build issues. Corrected checkstyle issues

Change-Id: I90744f53e40f417ffe7ae62ffe138eea7a489bc0
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);