pg: fix pcap packet type when writing pcap file

- fixes incorrect pcap packet type for packet
  generator interfaces configured in ip mode.
- corrects pcap file decode for pg output files
- fixes scapy versions > 2.4.3 which now appear to
  use the packet type in the pcap file header which
  had been ignored in earlier versions

Type: fix

Change-Id: Idb1e3f8fbc7ca938fb5d2aaa72365e333c0ea2e9
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h
index 6d5b25b..bede747 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -306,6 +306,15 @@
   PG_MODE_IP6,
 } pg_interface_mode_t;
 
+always_inline pcap_packet_type_t
+pg_intf_mode_to_pcap_packet_type (pg_interface_mode_t mode)
+{
+  if ((mode == PG_MODE_IP4) || (mode == PG_MODE_IP6))
+    return PCAP_PACKET_TYPE_ip;
+  else
+    return PCAP_PACKET_TYPE_ethernet;
+}
+
 typedef struct
 {
   /* TX lock */