@Test public void testOpenOfflineWithTimestampPrecision() throws Exception { if (!Boolean.getBoolean(Constants.ENABLE_TIMESTAMP_PRECISION_TESTS_KEY)) { return; } PcapHandle phNano = Pcaps.openOffline( "src/test/resources/org/pcap4j/core/" + "PcapsTest.testOpenOfflineWithTimestampPrecision.pcap", TimestampPrecision.NANO); phNano.getNextRawPacket(); assertEquals(1434220771517L, phNano.getTimestamp().getTime()); assertEquals(517995677, phNano.getTimestamp().getNanos()); phNano.close(); PcapHandle phMicro = Pcaps.openOffline( "src/test/resources/org/pcap4j/core/" + "PcapsTest.testOpenOfflineWithTimestampPrecision.pcap", TimestampPrecision.MICRO); phMicro.getNextRawPacket(); System.out.println(phMicro.getTimestamp().getTime()); System.out.println(phMicro.getTimestamp().getNanos()); assertEquals(1434220771517L, phMicro.getTimestamp().getTime()); assertEquals(517995000, phMicro.getTimestamp().getNanos()); phMicro.close(); }
public static PcapHandle openOffline(String filePath) throws PcapNativeException { if (filePath == null) { StringBuilder sb = new StringBuilder(); sb.append("filePath: ").append(filePath); throw new NullPointerException(sb.toString()); } PcapErrbuf errbuf = new PcapErrbuf(); Pointer handle = NativeMappings.pcap_open_offline(filePath, errbuf); if (handle == null || errbuf.length() != 0) { throw new PcapNativeException(errbuf.toString()); } return new PcapHandle(handle, TimestampPrecision.MICRO); }
Pcaps { public static PcapHandle openOffline(String filePath) throws PcapNativeException { if (filePath == null) { StringBuilder sb = new StringBuilder(); sb.append("filePath: ").append(filePath); throw new NullPointerException(sb.toString()); } PcapErrbuf errbuf = new PcapErrbuf(); Pointer handle = NativeMappings.pcap_open_offline(filePath, errbuf); if (handle == null || errbuf.length() != 0) { throw new PcapNativeException(errbuf.toString()); } return new PcapHandle(handle, TimestampPrecision.MICRO); } }
Pcaps { public static PcapHandle openOffline(String filePath) throws PcapNativeException { if (filePath == null) { StringBuilder sb = new StringBuilder(); sb.append("filePath: ").append(filePath); throw new NullPointerException(sb.toString()); } PcapErrbuf errbuf = new PcapErrbuf(); Pointer handle = NativeMappings.pcap_open_offline(filePath, errbuf); if (handle == null || errbuf.length() != 0) { throw new PcapNativeException(errbuf.toString()); } return new PcapHandle(handle, TimestampPrecision.MICRO); } private  Pcaps(); }
Pcaps { public static PcapHandle openOffline(String filePath) throws PcapNativeException { if (filePath == null) { StringBuilder sb = new StringBuilder(); sb.append("filePath: ").append(filePath); throw new NullPointerException(sb.toString()); } PcapErrbuf errbuf = new PcapErrbuf(); Pointer handle = NativeMappings.pcap_open_offline(filePath, errbuf); if (handle == null || errbuf.length() != 0) { throw new PcapNativeException(errbuf.toString()); } return new PcapHandle(handle, TimestampPrecision.MICRO); } private  Pcaps(); static List<PcapNetworkInterface> findAllDevs(); static PcapNetworkInterface getDevByAddress(InetAddress addr); static PcapNetworkInterface getDevByName(String name); static String lookupDev(); static Inet4NetworkAddress lookupNet(String devName); static PcapHandle openOffline(String filePath); static PcapHandle openOffline(String filePath, TimestampPrecision precision); static PcapHandle openDead(DataLinkType dlt, int snaplen); static PcapHandle openDead(DataLinkType dlt, int snaplen, TimestampPrecision precision); static BpfProgram compileFilter(
      int snaplen,
      DataLinkType dlt,
      String bpfExpression,
      BpfCompileMode mode,
      Inet4Address netmask); static DataLinkType dataLinkNameToVal(String name); static String dataLinkTypeToName(DataLinkType dlt); static String dataLinkValToName(int dataLinkVal); static String dataLinkTypeToDescription(DataLinkType dlt); static String dataLinkValToDescription(int dataLinkVal); static String strError(int error); static String libVersion(); static String toBpfString(InetAddress inetAddr); static String toBpfString(MacAddress macAddr); }
Pcaps { public static PcapHandle openOffline(String filePath) throws PcapNativeException { if (filePath == null) { StringBuilder sb = new StringBuilder(); sb.append("filePath: ").append(filePath); throw new NullPointerException(sb.toString()); } PcapErrbuf errbuf = new PcapErrbuf(); Pointer handle = NativeMappings.pcap_open_offline(filePath, errbuf); if (handle == null || errbuf.length() != 0) { throw new PcapNativeException(errbuf.toString()); } return new PcapHandle(handle, TimestampPrecision.MICRO); } private  Pcaps(); static List<PcapNetworkInterface> findAllDevs(); static PcapNetworkInterface getDevByAddress(InetAddress addr); static PcapNetworkInterface getDevByName(String name); static String lookupDev(); static Inet4NetworkAddress lookupNet(String devName); static PcapHandle openOffline(String filePath); static PcapHandle openOffline(String filePath, TimestampPrecision precision); static PcapHandle openDead(DataLinkType dlt, int snaplen); static PcapHandle openDead(DataLinkType dlt, int snaplen, TimestampPrecision precision); static BpfProgram compileFilter(
      int snaplen,
      DataLinkType dlt,
      String bpfExpression,
      BpfCompileMode mode,
      Inet4Address netmask); static DataLinkType dataLinkNameToVal(String name); static String dataLinkTypeToName(DataLinkType dlt); static String dataLinkValToName(int dataLinkVal); static String dataLinkTypeToDescription(DataLinkType dlt); static String dataLinkValToDescription(int dataLinkVal); static String strError(int error); static String libVersion(); static String toBpfString(InetAddress inetAddr); static String toBpfString(MacAddress macAddr);  }