import org.pcap4j.util.MacAddress;
import java.io.PrintWriter;
+import java.math.BigInteger;
import java.util.*;
/**
PcapPacket lowerBound, PcapPacket upperBound) {
List<PcapPacket> listBounds = new ArrayList<>();
+ // Just return the lower and upper bounds when their values are the same --- faster
+ if (lowerBound.length() == upperBound.length()) {
+ listBounds.add(0, lowerBound);
+ listBounds.add(1, upperBound);
+ return listBounds;
+ }
// Iterate over PcapPacket one by one
for(List<List<PcapPacket>> listOfListPcapPacket : corePointRange) {
List<PcapPacket> listCorePointLowerBound = listOfListPcapPacket.get(0);
// Sequence index starts from 0
signatures.remove(sequenceIndex);
}
+
+ /**
+ * Convert a String MAC address into a byte array.
+ *
+ * @param macAddress A String that contains a MAC address to be converted into byte array.
+ */
+ public static byte[] stringToByteMacAddress(String macAddress) {
+
+ BigInteger biMacAddress = new BigInteger(macAddress, 16);
+ byte[] byteMacAddress = biMacAddress.toByteArray();
+ // Return from 1 to 6 since element 0 is 0 because of using BigInteger's method.
+ return Arrays.copyOfRange(byteMacAddress, 1, 7);
+ }
}