Package org.jnetpcap.protocol.network

Examples of org.jnetpcap.protocol.network.Ip4$StreamId


    JFormatter out = new TextFormatter(OUT);
    out.setResolveAddresses(false);

    PcapPacket packet = TestUtils.getPcapPacket("tests/test-http-jpeg.pcap", 5);

    Ip4 ip = new Ip4();
    Ethernet eth = new Ethernet();
    if (packet.hasHeader(eth)) {
      out.format(eth);
    }
    if (packet.hasHeader(ip)) {
View Full Code Here


    JFormatter out = new TextFormatter(OUT);
    out.setResolveAddresses(true);

    PcapPacket packet = TestUtils.getPcapPacket("tests/test-http-jpeg.pcap", 5);

    Ip4 ip = new Ip4();
    Ethernet eth = new Ethernet();
    if (packet.hasHeader(eth)) {
      out.format(eth);
    }
    if (packet.hasHeader(ip)) {
View Full Code Here

   * starting offset of payload for IP header is 0x22 (34) bytes into the packet.
   */
  public void testJPayloadAccessorGetPayload() {
    JPacket packet = TestUtils.getPcapPacket(HTTP, 5);

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

    byte[] buffer = ip.getPayload();
    assertEquals(0x00, buffer[0]);
    assertEquals(0x50, buffer[1]);
View Full Code Here

   * starting offset of payload for IP header is 0x22 (34) bytes into the packet.
   */
  public void testJPayloadAccessorTransferPayloadToByteArray() {
    JPacket packet = TestUtils.getPcapPacket(HTTP, 5);

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

    byte[] buffer = ip.transferPayloadTo(new byte[489 - 34]);
    assertEquals(0x00, buffer[0]);
    assertEquals(0x50, buffer[1]);
View Full Code Here

   * starting offset of payload for IP header is 0x22 (34) bytes into the packet.
   */
  public void testJPayloadAccessorPeerPayloadToJBuffer() {
    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));
View Full Code Here

   * starting offset of payload for IP header is 0x22 (34) bytes into the packet.
   */
  public void testJPayloadAccessorTransferPayloadToJBuffer() {
    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));
View Full Code Here

                + "2000d94300000204 05b4010303020101 " + "0402");

    InetAddress dst = InetAddress.getByName("201.1.1.1");
    InetAddress src = InetAddress.getByName("192.168.1.1");

    Ip4 ip = packet.getHeader(new Ip4());
    Tcp tcp = packet.getHeader(new Tcp());

    ip.destination(dst.getAddress());
    ip.source(src.getAddress());

    ip.checksum(ip.calculateChecksum());
    tcp.checksum(tcp.calculateChecksum());
    packet.scan(Ethernet.ID);

    System.out.println(packet);
    List<PcapIf> alldevs = new ArrayList<PcapIf>(); // Will be filled with NICs
View Full Code Here

TOP

Related Classes of org.jnetpcap.protocol.network.Ip4$StreamId

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.