Package org.jnetpcap.packet

Examples of org.jnetpcap.packet.JPacket$State


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


   *
   * @throws IOException
   *           Signals that an I/O exception has occurred.
   */
  public void test1() throws IOException {
    JPacket packet =
        TestUtils.getPcapPacket("tests/test-icmp-recordroute-opt.pcap", 0);
    assertNotNull(packet);

    TextFormatter out = new TextFormatter(System.out);
    out.format(packet);

    System.out.println(packet.toString());

    System.out.println(packet.getState().toHexdump());
    System.out.println(packet.getState().toDebugString());
  }
View Full Code Here

  /**
   * _test1.
   */
  public void _test1() {

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

    MyHeader my = new MyHeader();

    if (packet.hasHeader(my) && my.version() == 4) {
      System.out.printf("found it id=%d\n", my.getId());

      System.out.println(packet.toString());
    } else {
      System.out.printf("not found id=%d\n", my.getId());
    }
  }
View Full Code Here

      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);
      JFormatter out = new TextFormatter(System.out);
      out.format(ip, Detail.MULTI_LINE_FULL_DETAIL);
    }

  }
View Full Code Here

  /**
   * Test peer to j buffer.
   */
  public void testPeerToJBuffer() {
    assertNotNull(VariousInMemoryPackets.PACKET_1);
    JPacket packet = new JMemoryPacket(VariousInMemoryPackets.PACKET_1);
    packet.scan(Ethernet.ID);
   
    System.out.println(packet);
  }
View Full Code Here

   *           Signals that an I/O exception has occurred.
   */
  public void testTextFormatter() throws IOException {
    JFormatter out = new TextFormatter(OUT);
   
    JPacket packet = TestUtils.getPcapPacket("tests/test-vlan.pcap", 0);
    try {
      out.format(packet);
     
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

   *           Signals that an I/O exception has occurred.
   */
  public void testXmlFormatter() throws IOException {
    JFormatter out = new XmlFormatter(OUT);
   
    JPacket packet = TestUtils.getPcapPacket("tests/test-afs.pcap", 0);

    out.format(packet);
  }
View Full Code Here

   *           Signals that an I/O exception has occurred.
   */
  public void testXmlIp4RecordRouteOpt() throws IOException {
    JFormatter out = new XmlFormatter(OUT);
   
    JPacket packet = TestUtils.getPcapPacket("tests/test-icmp-recordroute-opt.pcap", 0);

    out.format(packet);
  }
View Full Code Here

   *           Signals that an I/O exception has occurred.
   */
  public void testSubHeader() throws IOException {
    JFormatter out = new TextFormatter(OUT);
   
    JPacket packet = TestUtils.getPcapPacket("tests/test-afs.pcap", 0);

    out.format(packet);
  }
View Full Code Here

   *
   * @throws UnknownHostException
   *           the unknown host exception
   */
  public void testSendPacketUsingJBuffer() throws UnknownHostException {
    JPacket packet =
        new JMemoryPacket(JProtocol.ETHERNET_ID,
            "0016b6c13cb10021 5db0456c08004500 "
                + "00340e8e40008006 9c54c0a80165d822 "
                + "b5b1c1cf005020ce 4303000000008002 "
                + "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
    StringBuilder errbuf = new StringBuilder(); // For any error msgs
    /***************************************************************************
 
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.