Package org.jnetpcap.nio

Examples of org.jnetpcap.nio.JBuffer


  /**
   * Test scanner exception with j buffer.
   */
  public void testScannerExceptionWithJBuffer() {
   
    JBuffer buf = new JBuffer(data);
    JMemoryPacket mem = new JMemoryPacket(buf);

    assertNotNull(mem);

    mem.scan(JProtocol.ETHERNET_ID);
View Full Code Here


  /**
   * Test scanner exception with ij buffer.
   */
  public void testScannerExceptionWithIJBuffer() {
   
    JBuffer buf = new JBuffer(data);
    JMemoryPacket mem = new JMemoryPacket(JProtocol.ETHERNET_ID, buf);

    assertNotNull(mem);
  }
View Full Code Here

    limit = position;
    position = start;

    this.setInt(0, count);

    JBuffer b = new JBuffer(limit);
    b.order(ByteOrder.nativeOrder());
    this.transferTo(b, 0, limit, 0);

    // Resize to smaller
    setSize(limit);

    records = new Record[count];

    Iterator it = iterator();
    for (int i = 0; i < count && it.hasNext(); i++) {
      records[i] = new Record();
      records[i].header = new PcapHeader(JMemory.POINTER);
      records[i].packet = new JBuffer(JMemory.POINTER);

      it.next(records[i].header, records[i].packet);
    }
  }
View Full Code Here

    ip.checksum(Checksum.inChecksum(ip, 0, ip.size()));
    System.out.println(packet.getState().toDebugString());
   
    System.out.printf("crc=0x%X\n", Checksum.inChecksum(ip, 0, ip.size()));
   
    JBuffer b = new JBuffer(4);
   
    b.order(ByteOrder.LITTLE_ENDIAN);
    b.setUInt(0, 0x14010100)
    System.out.printf("0x%X\n%s", 0x14010100, b.toHexdump());
   
    b.order(ByteOrder.BIG_ENDIAN);
    b.setUInt(0, 0x14010100)
    System.out.printf("0x%X\n%s", 0x14010100, b.toHexdump());
  }
View Full Code Here

    Sigar sig = new Sigar();
    long pid = sig.getPid();
    ProcMem pm = new ProcMem();
    long base = 0;

    final JBuffer buf =
        new JBuffer(FormatUtils.toByteArray(""
            + "0007e914 78a20010 7b812445 080045c0"
            + "00280005 0000ff11 70e7c0a8 62dec0a8"
            + "65e906a5 06a50014 e04ac802 000c0002"
            + "00000002 00060000 00000000"
           
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//
//           
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
//            + "00000002 00060000 00000000 00000000"
           
        ));
    final PcapHeader header = new PcapHeader(buf.size(), buf.size());
    PcapPacket packet = new PcapPacket(header, buf);
   
    System.out.printf("injected packet size=%d bytes\n", buf.size());

    for (int i = 0; i < COUNT; i++) {
      PcapUtils.injectLoop(10000, JProtocol.ETHERNET_ID,
          new PcapPacketHandler<String>() {
View Full Code Here

    Sigar sig = new Sigar();
    long pid = sig.getPid();
    ProcMem pm = new ProcMem();
    long base = 0;

    final JBuffer buf =
        new JBuffer(FormatUtils.toByteArray(""
            + "0007e914 78a20010 7b812445 080045c0"
            + "00280005 0000ff11 70e7c0a8 62dec0a8"
            + "65e906a5 06a50014 e04ac802 000c0002"
            + "00000002 00060000 00000000"

        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        //
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        //
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        //
        //
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"
        // + "00000002 00060000 00000000 00000000"

            ));
    final PcapHeader header = new PcapHeader(buf.size(), buf.size());
    PcapPacket packet = new PcapPacket(header, buf);

    System.out.printf("injected packet size=%d bytes\n", buf.size());

    for (int i = 0; i < COUNT; i++) {
      PcapUtils.injectLoop(1000,
          JProtocol.ETHERNET_ID,
          new PcapPacketHandler<String>() {
View Full Code Here

    JPacket packet = TestUtils.getPcapPacket(HTTP, 5);

    JPayloadAccessor ip = packet.getHeader(new Ip4());
    assertNotNull(ip);

    JBuffer buffer = ip.peerPayloadTo(new JBuffer(JMemory.Type.POINTER));
    assertEquals(0x00, buffer.getUByte(0));
    assertEquals(0x50, buffer.getUByte(1));
    assertEquals(0x0d, buffer.getUByte(487 - 34));
    assertEquals(0x0a, buffer.getUByte(488 - 34));

//    System.out.println(buffer.toHexdump());
    assertEquals(489 - 34, buffer.size());
  }
View Full Code Here

    JPacket packet = TestUtils.getPcapPacket(HTTP, 5);

    JPayloadAccessor ip = packet.getHeader(new Ip4());
    assertNotNull(ip);

    JBuffer buffer = ip.transferPayloadTo(new JBuffer(489 - 34));
    assertEquals(0x00, buffer.getUByte(0));
    assertEquals(0x50, buffer.getUByte(1));
    assertEquals(0x0d, buffer.getUByte(487 - 34));
    assertEquals(0x0a, buffer.getUByte(488 - 34));

//    System.out.println(buffer.toHexdump());
    assertEquals(489 - 34, buffer.size());
  }
View Full Code Here

   * {@link org.jnetpcap.packet.PcapPacket#PcapPacket(org.jnetpcap.nio.JBuffer)}.
   */
  public final void testPcapPacketJBuffer() {
    packet = TestUtils.getPcapPacket("tests/test-l2tp.pcap", 0);

    JBuffer b = new JBuffer(packet.getTotalSize());
    packet.transferStateAndDataTo(b);

    packet2 = new PcapPacket(b);

    assertEquals(packet.size(), packet2.size());
View Full Code Here

    // 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

TOP

Related Classes of org.jnetpcap.nio.JBuffer

Copyright © 2018 www.massapicom. 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.