NAME
AnyEvent::Pcap - Net::Pcap wrapper with AnyEvent
SYNOPSIS
use AnyEvent::Pcap;
my $a_pcap;
$a_pcap = AnyEvent::Pcap->new(
device => "eth0",
filter => "tcp port 80",
timeout => 1000,
packet_handler => sub {
my $io = pop;
while (@_) {
my $header = shift;
my $packet = shift;
# you can use utils to get an NetPacket::TCP object.
my $tcp = $a_pcap->utils->extract_tcp_packet($packet);
# or ...
$tcp = AnyEvent::Pcap::Utils->extract_tcp_packet($packet);
# do something....
}
}
);
$a_pcap->run();
AnyEvent->condvar->recv;
DESCRIPTION
AnyEvent::Pcap is a Net::Pcap wrapper with AnyEvent.
Also you can use its utils to get NetPacket::IP or NetPacket::TCP object.
METHODS
- new([%args]);
-
my %args = ( # It will be filled up Net::Pcap::pcap_lookupdev() by default device => "eth0", # It also could be "file:/path/to/file" to load from a saved dump device => "samples/ping-ietf-20pk-le.dmp", # Default is NULL filter => "tcp port 80", # How much time to wait before flushing pcap buffer # Default is 0 (unlimited) timeout => 1000, # set your coderef packet_handler => sub { my $io = pop; # get first pair.... my $header = shift; my $packet = shift; # do something.... } ); my $a_pcap = AnyEvent::Pcap->new(%args);
Cteate and return new AnyEvent::Pcap object .
- utils()
-
my $a_pcap = AnyEvent::Pcap->new; my $utils = $a_pcap->utils;
You can get an utilty for packet handling. See AnyEvent::Pcap::Utils.
- run()
-
my $a_pcap = AnyEvent::Pcap->new(%args); $a_pcap->run; AnyEvent->condvar->recv;
Running AnyEvent loop.
accessor methods
AUTHOR
Takeshi Miki <miki@cpan.org>
CONTRIBUTORS
Sébastien Aperghis-Tramoni <sebastien at aperghis.net>
Sergei Zhmylev <zhmylove@cpan.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 226:
Non-ASCII character seen before =encoding in 'Sébastien'. Assuming UTF-8