Package org.jnetpcap.packet

Examples of org.jnetpcap.packet.JPacket$State


   *           the registry header errors
   */
  public void SKIPtestRip1() throws RegistryHeaderErrors {
    final int RIP1_ID = JRegistry.register(Rip1.class);
   
    JPacket packet = super.getPcapPacket(RIP_V1, 1 - 1);
   
    assertTrue(packet.hasHeader(RIP1_ID));
   
    Rip1 rip = new Rip1();
   
    System.out.println(packet);
   
View Full Code Here


  /**
   * Test ip4 cr c16 pkt1.
   */
  public void testIp4CRC16Pkt1() {

    JPacket packet = super.getPcapPacket(TestUtils.L2TP, 0);
    Ip4 ip = packet.getHeader(new Ip4());

    int computed = Checksum.inChecksum(ip, 0, ip.size());

    System.out.printf("1chunk=%x\n", computed);
    System.out.printf("shoudbe=%x checksum=%x\n", Checksum.inChecksumShouldBe(
View Full Code Here

  /**
   * Test ip4 cr c16 pkt2.
   */
  public void testIp4CRC16Pkt2() {

    JPacket packet = super.getPcapPacket(TestUtils.L2TP, 1);
    Ip4 ip = packet.getHeader(new Ip4());

    assertEquals(ip.calculateChecksum(), ip.checksum());
  }
View Full Code Here

  /**
   * Test ip4 cr c16 pkt50.
   */
  public void testIp4CRC16Pkt50() {

    JPacket packet = super.getPcapPacket(TestUtils.L2TP, 46 - 1);
    Ip4 ip = packet.getHeader(new Ip4());

    int crc;
    assertEquals(ip.checksum(), ip.calculateChecksum());

    // System.out.printf("ip.crc=%x computed=%x\n", ip.checksum(), crc);
View Full Code Here

  /**
   * Test ip4 fragment flag directly.
   */
  public void testIp4FragmentFlagDirectly() {
    JPacket packet = TestUtils.getPcapPacket(TestUtils.REASEMBLY, 1 - 1);
    Ethernet eth = new Ethernet();

    if (packet.hasHeader(eth)) {
      // System.out.println(eth);
      // 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)) {
      // System.out.println(icmp);
      // System.out.printf("flags=%x\n", icmp.getState().getFlags());
      assertEquals(JHeader.State.FLAG_HEADER_FRAGMENTED, (icmp.getState()
          .getFlags() & JHeader.State.FLAG_HEADER_FRAGMENTED));
    }
View Full Code Here

  /**
   * Test j header is fragmented.
   */
  public void testJHeaderIsFragmented() {
    JPacket packet = TestUtils.getPcapPacket(TestUtils.REASEMBLY, 1 - 1);
    Ethernet eth = new Ethernet();

    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

 
  /**
   * Test tcp options.
   */
  public void testTcpOptions() {
    JPacket packet = TestUtils.getPcapPacket(SMALL_IMAP, 1 - 1);
    System.out.println(packet.toString());
   
    Tcp tcp = packet.getHeader(new Tcp());
    Tcp.Timestamp ts = new Tcp.Timestamp();
   
    if (tcp.hasSubHeader(ts)) {
      System.out.printf("tsval=%d tsecr=%d%n", ts.tsval(), ts.tsecr());
    }
View Full Code Here

            + "31 04 69 61  67 72 03 6e  65 74 00 00  01 00 01 c0"
            + "17 00 06 00  01 00 00 2a  30 00 2f 05  70 64 6e 73"
            + "31 08 75 6c  74 72 61 64  6e 73 c0 1c  07 6b 67 72"
            + "61 75 65 72  c0 17 77 bf  dd f5 00 00  2a 30 00 00"
            + "0e 10 00 27  8d 00 00 01  51 80" + "";
    final JPacket packet = new JMemoryPacket(JProtocol.ETHERNET_ID, data);

    // final String TEMP_CAP = "tests/temp.pcap";
    // final File TEMP_CAP_FILE = new File(TEMP_CAP);
    // if (TEMP_CAP_FILE.exists()) {
    // TEMP_CAP_FILE.delete();
    // }
    // 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

  /**
   * Test rtp heuristics.
   */
  public void testRtpHeuristics() {

    JPacket packet = super.getPcapPacket(SIP_G711, 499 - 1);

    // System.out.println(JRegistry.toDebugString());
    System.out.println(packet.getState().toDebugString());
    System.out.println(packet);
    System.out.flush();

    assertNotNull(packet);
    assertTrue(packet.hasHeader(JProtocol.RTP_ID));
  }
View Full Code Here

    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));
   
View Full Code Here

TOP

Related Classes of org.jnetpcap.packet.JPacket$State

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.