Handle packets that can't be deserialized properly.

Catch BufferUnderflowExceptions that occur while trying to deserialzed
Ethernet packet, and account for the fact that packets may not have been
deserialized correctly when using InboundPackets.

Addresses ONOS-605.

Change-Id: Ia7191e62a339125c9c4d3fe0cf63f9c33eb74cb5
diff --git a/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java b/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java
index 2ea6340..de1d6f0 100644
--- a/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java
+++ b/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java
@@ -16,6 +16,7 @@
 package org.onosproject.openflow.controller;
 
 
+import java.nio.BufferUnderflowException;
 import java.util.Collections;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -85,8 +86,12 @@
     @Override
     public Ethernet parsed() {
         Ethernet eth = new Ethernet();
-        eth.deserialize(pktin.getData(), 0, pktin.getTotalLen());
-        return eth;
+        try {
+            eth.deserialize(pktin.getData(), 0, pktin.getData().length);
+            return eth;
+        } catch (BufferUnderflowException e) {
+            return null;
+        }
     }
 
     @Override