Examples of pcap_pkthdr


Examples of org.pcap4j.core.NativeMappings.pcap_pkthdr

  public Packet getNextPacket() throws NotOpenException {
    if (!open) {
      throw new NotOpenException();
    }

    pcap_pkthdr header = new pcap_pkthdr();
    header.setAutoSynch(false);
    Pointer packet;
    if (!handleLock.readLock().tryLock()) {
      throw new NotOpenException();
    }
    try {
      if (!open) {
        throw new NotOpenException();
      }
      packet = NativeMappings.pcap_next(handle, header);
    } finally {
      handleLock.readLock().unlock();
    }

    if (packet != null) {
      Pointer headerP = header.getPointer();
      timestampsInts.set(pcap_pkthdr.getTvSec(headerP).longValue());
      timestampsMicros.set(pcap_pkthdr.getTvUsec(headerP).intValue());
      byte[] ba = packet.getByteArray(0, pcap_pkthdr.getCaplen(headerP));
      return PacketFactories.getFactory(Packet.class, DataLinkType.class)
               .newInstance(ba, 0, ba.length, dlt);
View Full Code Here

Examples of org.pcap4j.core.NativeMappings.pcap_pkthdr

    }
    if (!open) {
      throw new NotOpenException();
    }

    pcap_pkthdr header = new pcap_pkthdr();
    header.len = header.caplen = packet.length();
    header.ts = new timeval();
    header.ts.tv_sec = new NativeLong(timestampSec);
    header.ts.tv_usec = new NativeLong(timestampMicros);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.