Examples of JPacket


Examples of org.jnetpcap.packet.JPacket

   *           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

Examples of org.jnetpcap.packet.JPacket

   *
   * @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

Examples of org.jnetpcap.packet.JPacket

   *
   * @return header's stored checksum
   */
  @Field(length = 4 * BYTE, format = "%x", display = "FCS")
  public long checksum() {
    final JPacket packet = getPacket();
    packet.order(ByteOrder.BIG_ENDIAN);
    return packet.getUInt(getPostfixOffset());
  }
View Full Code Here

Examples of org.jnetpcap.packet.JPacket

  public long calculateChecksum() {
    if (getPostfixLength() < 4) {
      return 0L;
    }
   
    final JPacket packet = getPacket();
    return Checksum.crc32IEEE802(packet, 0, packet.size() - 4);
  }
View Full Code Here

Examples of org.jnetpcap.packet.JPacket

   *
   * @return header's stored checksum
   */
  @Field(length = 4 * BYTE, format = "%x", display = "FCS")
  public long checksum() {
    final JPacket packet = getPacket();
    packet.order(ByteOrder.BIG_ENDIAN);
    return packet.getUInt(getPostfixOffset());
  }
View Full Code Here

Examples of org.jnetpcap.packet.JPacket

  public boolean checksum(long crc) {
    if (getPostfixLength() < 4) {
      return false;
    }

    final JPacket packet = getPacket();
    packet.order(ByteOrder.BIG_ENDIAN);

    packet.setUInt(packet.size() - 4, crc);

    return true;
  }
View Full Code Here

Examples of org.jnetpcap.packet.JPacket

   *
   * @return the long
   */
  public long calculateChecksum() {

    final JPacket packet = getPacket();
    return Checksum.crc32IEEE802(packet, 0, getHeaderLength()
        + getPayloadLength());
  }
View Full Code Here

Examples of org.jnetpcap.packet.JPacket

   *
   * @throws IOException
   *           Signals that an I/O exception has occurred.
   */
  public void test1() throws IOException {
    JPacket packet = getPcapPacket(HTTP, 5);

    JFormatter out = new TextFormatter(System.out);

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

Examples of org.jnetpcap.packet.JPacket

     * Packet extends JBuffer. The packet object is the one that is already
     * created for the scanner in the Pcap.loop call and is already peered. This
     * is better approach than getting the buffer with: JBuffer b = new
     * JBuffer(Type.POINTER); scan.scan_buf(b);
     */
    JPacket packet = scan.scan_packet();

    /*
     * Thats good
     */
    int offset = scan.scan_offset();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.