org.jnetpcap.packet.analysis
Interface JAnalyze

All Known Implementing Classes:
Pcap, WinPcap

public interface JAnalyze

Capture, decode and analyze stream of packets. This interface provides methods that allow a capture of certain amount of packets. Have the packets decoded using jNetPcap's packet scanner and analyzed using JRegistry registered protocol analyzers.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Method Summary
 int analyze()
          Captures packets, decodes each header using a native scanner and analyzes the packet stream.
 int analyze(int count)
          Captures packets, decodes each header using a native scanner and analyzes the packet stream.
<T> int
analyze(int count, JPacketHandler<T> handler, T user)
          Captures packets, decodes each header using a native scanner and analyzes the packet stream.
<T> int
analyze(JPacketHandler<T> handler, T user)
          Captures packets, decodes each header using a native scanner and analyzes the packet stream.
 

Method Detail

analyze

int analyze()
Captures packets, decodes each header using a native scanner and analyzes the packet stream. Packets are analyzed using protocol analyzers registered with JRegistry. No user packet handler is registered. Captured packet will be consumed, but they will be analyzed. The user will have to register a protocol specific handler with a protocol. Here is an example:
 HttpAnalyzer analyzer = JRegistry.getAnalyzer(HttpAnalyzer.class);
 analyzer.add(new HttpHandler() {
 
        // Handle processed http headers
        public void processHttp(Http http) {
        }
 });
 
The protocol specific listener has to be registered with the analyzer before the call to Pcap.analyze method.

This method invokes pcap capture to grab infinate amount of packets, or until the capture source is closed.

Returns:
Total number of packets that were captured. The count does not include new packets that were generated by analyzers.

analyze

int analyze(int count)
Captures packets, decodes each header using a native scanner and analyzes the packet stream. Packets are analyzed using protocol analyzers registered with JRegistry. No user packet handler is registered. Captured packet will be consumed, but they will be analyzed. The user will have to register a protocol specific handler with a protocol. Here is an example:
 HttpAnalyzer analyzer = JRegistry.getAnalyzer(HttpAnalyzer.class);
 analyzer.add(new HttpHandler() {
 
        // Handle processed http headers
        public void processHttp(Http http) {
        }
 });
 
The protocol specific listener has to be registered with the analyzer before the call to Pcap.analyze method.

Parameters:
count - max number of packets to capture before returning
Returns:
Total number of packets that were captured. The count does not include new packets that were generated by analyzers.

analyze

<T> int analyze(JPacketHandler<T> handler,
                T user)
Captures packets, decodes each header using a native scanner and analyzes the packet stream. Packets are analyzed using protocol analyzers registered with JRegistry.

Analyzer's capture infinate amount of packets or until the capture source is closed.

Type Parameters:
T - type for user object passed to the packet handler
Parameters:
handler - user packet handler that will receive all captured packets
user - user object of type
Returns:
Total number of packets that were captured. The count does not include new packets that were generated by analyzers.

analyze

<T> int analyze(int count,
                JPacketHandler<T> handler,
                T user)
Captures packets, decodes each header using a native scanner and analyzes the packet stream. Packets are analyzed using protocol analyzers registered with JRegistry.

Type Parameters:
T - type for user object passed to the packet handler
Parameters:
count - max number of packets to capture before returning
handler - user packet handler that will receive all captured packets
user - user object of type
Returns:
Total number of packets that were captured. The count does not include new packets that were generated by analyzers.