changeset 712:d243915067e7

PcapFileHeader.isFormatSupported
author Devel 1
date Wed, 29 Nov 2017 12:36:57 +0100
parents de7f825fdde4
children c25ef52d9d7c
files stress-tester/src/main/java/com/passus/st/reader/pcap/PcapFileHeader.java
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/pcap/PcapFileHeader.java	Wed Nov 29 12:13:10 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/reader/pcap/PcapFileHeader.java	Wed Nov 29 12:36:57 2017 +0100
@@ -45,6 +45,13 @@
         this.byteOrder = fileByteOrder;
     }
 
+    public static boolean isFormatSupported(byte[] buffer) {
+        int magicBE = DataHelper.BIG_ENDIAN.getInt4(buffer, 0);
+        int magicLE = DataHelper.LITTLE_ENDIAN.getInt4(buffer, 0);
+        return magicBE == MAGIC_FORMAT_PLAIN || magicLE == MAGIC_FORMAT_PLAIN
+                || magicBE == MAGIC_FORMAT_NANO || magicLE == MAGIC_FORMAT_NANO;
+    }
+
     public static PcapFileHeader decode(byte[] buffer) {
         ByteOrder fileByteOrder = getFileByteOrder(buffer[0]);
         DataHelper mbu = DataHelper.get(fileByteOrder);