Package org.jnetpcap.packet

Examples of org.jnetpcap.packet.JMemoryPacket$JMemoryHeader


  /**
   * Test802dot3 trailer.
   */
  public void test802dot3Trailer() {
    JPacket packet =
        new JMemoryPacket(JProtocol.IEEE_802DOT3_ID,
            VariousInMemoryPackets.PACKET_2_TRAILER);
   
//    System.out.println(packet.getHeader(new IEEE802dot3()));
    System.out.println(packet);
    System.out.println(packet.getState().toDebugString());
  }
View Full Code Here


    String data =
        " 01 00 5e 00  00 16 00 03  ff 2a 7a 6c  08 00 46 00"
            + " 00 28 d7 04  00 00 01 02  ac fa c0 a8  00 12 e0 00"
            + " 00 16 94 04  00 00 22 00  ea 03 00 00  00 01 04 00"
            + " 00 00 ef ff  ff fa 00 00  00 00 00 00             ";
    JMemoryPacket packet = new JMemoryPacket(JProtocol.ETHERNET_ID, data);
    Ip4 ip = new Ip4();
    Ip4.RouterAlert alert = new Ip4.RouterAlert();
   
    assertTrue(packet.hasHeader(ip));
    assertTrue(ip.hasSubHeader(alert));

    System.out.println(alert);
  }
View Full Code Here

  /**
   * Test scanner exception with byte array.
   */
  public void testScannerExceptionWithByteArray() {
   
    JMemoryPacket mem = new JMemoryPacket(data);

    assertNotNull(mem);

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

  /**
   * Test scanner exception with i byte array.
   */
  public void testScannerExceptionWithIByteArray() {
   
    JMemoryPacket mem = new JMemoryPacket(JProtocol.ETHERNET_ID, data);

    assertNotNull(mem);
  }
View Full Code Here

   * 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

  public void testScannerExceptionWithByteBuffer() throws PeeringException {
   
    ByteBuffer buf = ByteBuffer.allocateDirect(data.length);
    buf.put(data).clear();

    JMemoryPacket mem = new JMemoryPacket(buf);

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

  public void testScannerExceptionWithIByteBuffer() throws PeeringException {
   
    ByteBuffer buf = ByteBuffer.allocateDirect(data.length);
    buf.put(data).clear();

    JMemoryPacket mem = new JMemoryPacket(JProtocol.ETHERNET_ID, buf);

    assertNotNull(mem);

  }
View Full Code Here

  /**
   * Test1.
   */
  public void test1() {
   
    JMemoryPacket packet = new JMemoryPacket(64);
    packet.order(ByteOrder.BIG_ENDIAN);
    packet.setUShort(0 + 12, 0x800);
    packet.setUByte(14 + 0, 0x45);
    System.out.println(packet.toHexdump());
    packet.setUByte(14 + 9, 0x11); //UDP
    System.out.println(packet.toHexdump());
    packet.scan(JProtocol.ETHERNET_ID);
    Ethernet eth = packet.getHeader(new Ethernet());
    Ip4 ip = packet.getHeader(new Ip4());
    Udp udp = packet.getHeader(new Udp());
//    udp.transferFrom(getFakeData(1460)); //Generate Random bytes
    eth.destination(new byte[] {(byte) 0xaa, 0x0c, 0x08, 11, 22, 33});
    eth.source(new byte[] {(byte) 0xaa, 0x0c, 0x08, 11, 22, 34});
    ip.flags(0);
    ip.tos(0);
    ip.source(new byte[] {(byte) 192, (byte) 168, 18, (byte) 218});
    ip.setByteArray(16, new byte[] {(byte) 192,(byte) 168, 18, (byte) 219});
   
    ip.checksum(0);
    System.out.printf("crc=0x%X ip.len=%d\n", Checksum.inChecksum(ip, 0, ip.size()), ip.size());
    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);
   
View Full Code Here

            + "00 40 d8 d5 40 00 40 06 2f 80 55 5e 40 14 c3 1d "
            + "d9 d2 00 6e 06 86 c4 53 d9 dd 7c e1 ce 2c 50 18 "
            + "16 d0 73 4b 00 00 2b 4f 4b 20 50 61 73 73 77 6f "
            + "72 64 20 72 65 71 75 69 72 65 64 2e 0d 0a";
   
    JMemoryPacket p = new JMemoryPacket(JProtocol.ETHERNET_ID, packetData);
    TextFormatter.getDefault().setResolveAddresses(true);
    System.out.println(p);
  }
View Full Code Here

TOP

Related Classes of org.jnetpcap.packet.JMemoryPacket$JMemoryHeader

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.