Examples of JBuffer


Examples of org.jnetpcap.nio.JBuffer

    // System.out.println(packet2.toString());
   
  }
 
  public final void testPcapHeader() {
    JBuffer buffer = new JBuffer(VariousInMemoryPackets.PACKET_1); // Allocate buffer of 128 bytes
    PcapHeader hdr = new PcapHeader(buffer.size(), buffer.size());
    PcapPacket packet = new PcapPacket(JMemory.POINTER);
   
    packet.peer(buffer);
    packet.getCaptureHeader().peerTo(hdr, 0);
   
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

   */
  public void testNext() {
    Pcap pcap = Pcap.openOffline(fname, errbuf);
    try {
      PcapHeader header = new PcapHeader(); // allocated memory
      JBuffer buffer = new JBuffer(JMemory.Type.POINTER);

      buffer = pcap.next(header, buffer);

      assertNotNull(buffer);
      assertEquals(114, header.caplen());
      assertEquals(114, buffer.size());
    } finally {
      pcap.close();
    }
  }
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

   */
  public void testNextEx() {
    Pcap pcap = Pcap.openOffline(fname, errbuf);
    try {
      PcapHeader header = new PcapHeader(JMemory.Type.POINTER);
      JBuffer buffer = new JBuffer(JMemory.Type.POINTER);

      assertEquals(1, pcap.nextEx(header, buffer));

      assertEquals(114, header.caplen());
      assertEquals(114, buffer.size());

    } finally {
      pcap.close();
    }
  }
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

        public void nextPacket(
            PcapHeader header,
            JBuffer packet,
            Counter counter) {
          counter.inc();
          new JBuffer(packet.size()).transferFrom(packet);
        }
      });
    }
  }
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

        public void nextPacket(
            PcapHeader header,
            JBuffer packet,
            Counter counter) {
          counter.inc();
          new JBuffer(packet.size()).transferFrom(packet);
        }
      });
    }
  }
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

   *          data to be copied into the queue
   */
  public WinPcapSendQueue(byte[] data) {
    super(STRUCT_NAME, sizeof());

    this.buffer = new JBuffer(data.length);
    this.buffer.order(ByteOrder.nativeOrder()); // Force byte ordering

    this.buffer.setByteArray(0, data);
    setMaxLen(data.length);
    setLen(data.length);
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

   * @throws PeeringException
   *           the peering exception
   */
  public WinPcapSendQueue(ByteBuffer buffer) throws PeeringException {
    super(STRUCT_NAME, sizeof());
    this.buffer = new JBuffer(Type.POINTER);
    this.buffer.order(ByteOrder.nativeOrder()); // Force byte ordering

    if (buffer.isDirect() == false) {
      throw new IllegalArgumentException("Only direct buffers are accepted. "
          + "See ByteBuffer.allocateDirect method.");
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

   * @param size
   *          size of the queue in bytes
   */
  public WinPcapSendQueue(int size) {
    super(STRUCT_NAME, sizeof());
    this.buffer = new JBuffer(size);
    this.buffer.order(ByteOrder.nativeOrder()); // Force byte ordering

    setMaxLen(size);
    setLen(0);
    setBuffer(buffer);
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

   *          Also the queue has to be large enough to hold all of the data, or
   *          an exception will be thrown.
   * @return 0 (Pcap.OK) on success; exception thrown on failure
   */
  public int queue(PcapHeader header, byte[] data) {
    return queue(header, new JBuffer(data));
  }
View Full Code Here

Examples of org.jnetpcap.nio.JBuffer

   *          Also the queue has to be large enough to hold all of the data, or
   *          an exception will be thrown.
   * @return 0 (Pcap.OK) on success; exception thrown on failure
   */
  public int queue(PcapHeader header, ByteBuffer data) {
    return queue(header, new JBuffer(data));
  }
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.