Package org.jnetpcap.protocol.network

Examples of org.jnetpcap.protocol.network.Ip4$Timestamp$Entry


    Pcap pcap = Pcap.openOffline(TestTcpIp.VLAN, errbuf);

    assertNotNull(errbuf.toString(), pcap);

    pcap.loop(Pcap.LOOP_INFINATE, new PcapPacketHandler<String>() {
      Ip4 ip = new Ip4();

      Icmp icmp = new Icmp();

      public void nextPacket(PcapPacket packet, String user) {
View Full Code Here


      // System.out.printf("flags=%x\n", eth.getState().getFlags());
      assertNotSame(JHeader.State.FLAG_HEADER_FRAGMENTED, (eth.getState()
          .getFlags() & JHeader.State.FLAG_HEADER_FRAGMENTED));
    }

    Ip4 ip = new Ip4();
    if (packet.hasHeader(ip)) {
      // System.out.println(ip);
      // System.out.printf("flags=%x\n", ip.getState().getFlags());
      assertEquals(JHeader.State.FLAG_HEADER_FRAGMENTED, (ip.getState()
          .getFlags() & JHeader.State.FLAG_HEADER_FRAGMENTED));
    }

    Icmp icmp = new Icmp();
    if (packet.hasHeader(icmp)) {
View Full Code Here

    if (packet.hasHeader(eth)) {
      assertFalse(eth.isFragmented());
    }

    Ip4 ip = new Ip4();
    if (packet.hasHeader(ip)) {
      assertTrue(ip.isFragmented());
    }

    Icmp icmp = new Icmp();
    if (packet.hasHeader(icmp)) {
      assertTrue(ip.isFragmented());
    }

  }
View Full Code Here

    // }
    // FormatUtils.createPcapFile(TEMP_CAP, data);

    // System.out.println(packet);
    System.out.println(packet.getHeader(new Ethernet()));
    System.out.println(packet.getHeader(new Ip4()));
    System.out.println(packet.getHeader(new Udp()));
    System.out.println(packet.getState().toDebugString());

  }
View Full Code Here

    PcapPacket packet = TestUtils.getPcapPacket("tests/test-afs.pcap", 29 - 1);

    System.out.println(packet.toHexdump(128, false, false, true));
    System.out.println(packet.getState().toDebugString());

    Ip4 ip = new Ip4();
    Icmp icmp = new Icmp(); // Need an instance so we can check on sub header
    Icmp.DestinationUnreachable unreach = new Icmp.DestinationUnreachable();

    assertTrue(packet.hasHeader(Ethernet.ID));
    assertTrue(packet.hasHeader(JProtocol.IP4_ID, 0));
    assertTrue(packet.hasHeader(icmp));
    assertTrue(icmp.hasSubHeader(IcmpType.DESTINATION_UNREACHABLE.getId()));
    assertTrue(icmp.hasSubHeader(unreach));
    assertTrue(packet.hasHeader(ip, 1));
    assertTrue(packet.hasHeader(Udp.ID));
    assertTrue(packet.hasHeader(Payload.ID));

    // Check specific values
    assertEquals(3, icmp.type());
    assertEquals(3, icmp.code());
    assertEquals(0x2731, icmp.checksum());
    assertEquals(0, unreach.reserved());

    assertEquals(0x8724, ip.checksum());
    assertEquals(440, ip.length());

    // Devil's advocate
    assertFalse(icmp.hasSubHeader(IcmpType.ECHO_REPLY.getId()));
    assertFalse(icmp.hasSubHeader(IcmpType.PARAM_PROBLEM.getId()));
View Full Code Here

   *
   * @throws IOException
   *           Signals that an I/O exception has occurred.
   */
  public void testSubHeaderAccess() throws IOException {
    Ip4 ip = new Ip4();
    Ip4.Timestamp ts = new Ip4.Timestamp();
    Ip4.LooseSourceRoute lsroute = new Ip4.LooseSourceRoute();
    Ip4.StrictSourceRoute ssroute = new Ip4.StrictSourceRoute();
    Ip4.RecordRoute record = new Ip4.RecordRoute();

    JPacket packet =
        TestUtils.getPcapPacket("tests/test-icmp-recordroute-opt.pcap", 0);

    JFormatter out = new TextFormatter();
    out.format(packet);
   
    assertNotNull(packet);
    assertTrue(packet.hasHeader(ip));
    assertTrue(ip.hasSubHeaders());
    assertFalse(ip.hasSubHeader(lsroute));
    assertFalse(ip.hasSubHeader(ssroute));
    assertFalse(ip.hasSubHeader(ts));
   
    assertTrue(ip.hasSubHeader(record));
    assertEquals(9, record.addressCount());
   
    byte[] b = record.address(0);
    assertNotNull(b);
    assertEquals(4, b.length);
    assertEquals(-64, b[0]); // 192 in unsinged int
    assertEquals(-88, b[1]); // 168 in unsigned int
    assertEquals(1, b[2]);   // 1
    assertEquals(13, b[3])// 13
   
    assertNotNull(packet);
    assertTrue(packet.hasHeader(ip));
    assertTrue(ip.hasSubHeaders());
    assertFalse(ip.hasSubHeader(lsroute));
    assertFalse(ip.hasSubHeader(ssroute));
    assertFalse(ip.hasSubHeader(ts));
   
    assertTrue(ip.hasSubHeader(record));
    assertEquals(9, record.addressCount());
   
    /*
     * Now do it a second time without resetting the packet
     */
 
View Full Code Here

  /**
   * Test syntax text.
   */
  public void testSyntaxText() {
    Ip4 ip = new Ip4();
    Ip4.Timestamp ts = new Ip4.Timestamp();
    Ip4.LooseSourceRoute lsroute = new Ip4.LooseSourceRoute();
    Ip4.StrictSourceRoute ssroute = new Ip4.StrictSourceRoute();
    Ip4.RecordRoute record = new Ip4.RecordRoute();

    JPacket packet =
        TestUtils.getPcapPacket("tests/test-icmp-recordroute-opt.pcap", 0);

    if (packet.hasHeader(ip) && ip.hasSubHeaders()) {

      if (ip.hasSubHeader(lsroute)) {
        System.out.println("LooseSource");
      }

      if (ip.hasSubHeader(ssroute)) {
        System.out.println("StrictSource");
      }

      if (ip.hasSubHeader(ts)) {
        System.out.println("Timestamp");
      }
     
      if (ip.hasSubHeader(record)) {
        System.out.println("RecordRoute");
      }

    }
  }
View Full Code Here

    for (JField field : fields) {
      System.out.printf("field=%s\n", field.toString());
    }

    Ip4 ip = new Ip4();

    JPacket packet = TestUtils.getPcapPacket("tests/test-afs.pcap", 0);

    if (packet.hasHeader(JProtocol.IP4_ID)) {
      ip = packet.getHeader(ip);
View Full Code Here

    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

TOP

Related Classes of org.jnetpcap.protocol.network.Ip4$Timestamp$Entry

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.