org.jnetstream.packet
Interface PacketListener


public interface PacketListener

Allows an interested observer to monitor packet reads, writes, inserts, deletions and packet modifications.

 LiveCapture capture = Captures.openLive();
 capture.addPacketListener(new PacketListener() {
   public void processReadPacket(Capture source, Packet packet) {
     System.out.println("New packet"); 
   }
   // ... and so on
 });
 
Also can be registered as follows:
 Captures.registerListener(new CaptureListener() {
   public void processOpenCapture(Capture source) {
     source.registerPacketListener(new PacketListener() {
       // ... and so on
     });
   }
   
   public void processCloseCapture(Capture source) {
     // All listeners are automatically removed after the capture session is closed
   }
 });
 

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Method Summary
 void processAddPacket(Capture source, Packet packet)
          A new packet has been added or inserted.
 void processPacketChange(Capture source, Packet packet)
          Notifies that the packet data buffer has been changed, and possibly the internal structure of the packet has been altered as a result.
 void processReadPacket(Capture source, Packet packet)
          Notifies the listener that new packet has been captured or read from a file.
 void processRemovePacket(Capture source, Packet packet)
          A packet has been deleted from the capture session, i.e.
 void processWritePacket(Capture source, Packet packet)
          Notifies the listener that a new packet has been written to a capture session, either a file or possibly the raw network.
 

Method Detail

processReadPacket

void processReadPacket(Capture source,
                       Packet packet)
Notifies the listener that new packet has been captured or read from a file.

Parameters:
source - source capture session that captured the packet
packet - packet that captured

processWritePacket

void processWritePacket(Capture source,
                        Packet packet)
Notifies the listener that a new packet has been written to a capture session, either a file or possibly the raw network.

Parameters:
source - source capture that the packet was written to
packet - the packet that was written

processAddPacket

void processAddPacket(Capture source,
                      Packet packet)
A new packet has been added or inserted.

Parameters:
source - source capture that the packet was added to
packet - the packet that was added

processRemovePacket

void processRemovePacket(Capture source,
                         Packet packet)
A packet has been deleted from the capture session, i.e. from a file.

Parameters:
source - source capture that the packet was deleted from
packet - the packet that was deleted

processPacketChange

void processPacketChange(Capture source,
                         Packet packet)
Notifies that the packet data buffer has been changed, and possibly the internal structure of the packet has been altered as a result.

Parameters:
source - source capture the packet is bound to, could be null for newly created packets that are not bound to a session
packet - the packet that had its buffer modified