Improve the resiliency of the packet deserialization code.

Packet deserializers now check for malformed input while reading the byte
stream. Deserializers are re-implemented as functions that take a byte array
and return a packet object. The old IPacket.deserialize(...) methods have been
deprecated with the goal of eventually moving to immutable packet objects.
Unit tests have been implemented for all Deserializer functions.

ONOS-1589

Change-Id: I9073d5e6e7991e15d43830cfd810989256b71c56
diff --git a/src/main/java/org/onosproject/segmentrouting/IcmpHandler.java b/src/main/java/org/onosproject/segmentrouting/IcmpHandler.java
index b3da8dc..0f8fa59 100644
--- a/src/main/java/org/onosproject/segmentrouting/IcmpHandler.java
+++ b/src/main/java/org/onosproject/segmentrouting/IcmpHandler.java
@@ -15,8 +15,6 @@
  */
 package org.onosproject.segmentrouting;
 
-import java.nio.ByteBuffer;
-import java.util.List;
 import org.onlab.packet.Ethernet;
 import org.onlab.packet.ICMP;
 import org.onlab.packet.IPv4;
@@ -33,6 +31,9 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.nio.ByteBuffer;
+import java.util.List;
+
 import static com.google.common.base.Preconditions.checkNotNull;
 
 public class IcmpHandler {
@@ -109,7 +110,7 @@
         icmpReplyIpv4.setTtl((byte) 64);
         icmpReplyIpv4.setChecksum((short) 0);
 
-        ICMP icmpReply = (ICMP) icmpRequestIpv4.getPayload().clone();
+        ICMP icmpReply = new ICMP();
         icmpReply.setIcmpType(ICMP.TYPE_ECHO_REPLY);
         icmpReply.setIcmpCode(ICMP.SUBTYPE_ECHO_REPLY);
         icmpReply.setChecksum((short) 0);