jNetPcap 1.X

jNetPcap 1.X module: libpcap and packet decoder

Official release 1.3.a1 (alpha1) is released

Pcap.nextEx

Pcap.nextExPcapPacket
package org.jnetpcap.examples;

import org.jnetpcap.Pcap;
import org.jnetpcap.PcapHeader;
import org.jnetpcap.nio.JBuffer;
import org.jnetpcap.nio.JMemory;
import org.jnetpcap.packet.JRegistry;
import org.jnetpcap.packet.PcapPacket;
import org.jnetpcap.packet.format.FormatUtils;
import org.jnetpcap.protocol.lan.Ethernet;
import org.jnetpcap.protocol.network.Ip4;

/**
 * This example opens up a capture file found in jNetPcap's installation
 * directory for of the "source" distribution package and iterates over every
 * packet. The example also demonstrates how to property peer
 * PcapHeader, JBuffer and initialize a new
 * PcapPacket object which will contain a copy of the peered
 * packet and header data. The libpcap provide header and data are stored in
 * libpcap private memory buffer, which will be overriden with each iteration of
 * the loop. Therefore we use the constructor in PcapPacket to
 * allocate new memory to store header and packet buffer data and perform the
 * copy. The we
 * 
 * @author Mark Bednarczyk
 * @author Sly Technologies, Inc.
 */
public class NextExExample {

	/**
	 * Start of our example.
	 * 
	 * @param args
	 *          ignored
	 */
	public static void main(String[] args) {
		final String FILE_NAME = "tests/test-l2tp.pcap";
		StringBuilder errbuf = new StringBuilder(); // For any error msgs

		/***************************************************************************

Fast PcapDumper API

Pcap

1.1 - Getting Around

org
  +-> jnetcap - this is the main libpcap wrapper package. It contains
      +         all of the API for accessing libpcap functionality.
      |         These classes and methods do very little of their own
      |         logic and simply pass your requests over to native
      |         libpcap which handles those the requested actions.
      |
      +-> winpcap - extension to libpcap wrapper that provides WinPcap 
      |          functions. This is operating system dependent package
      |          and you must use WinPcap.isSupported()JBufferJConfig
Syndicate content