NAME
AnyEvent::Pcap - Net::Pcap wrapper with AnyEvent
SYNOPSIS
use AnyEvent::Pcap;
my $a_pcap = AnyEvent::Pcap->new(
device => "eth0",
filter => "tcp port 80",
packet_handler => sub {
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);
# 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", # Default is NULL filter => "tcp port 80", # set your coderef packet_handler => sub { 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>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.