Prism has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use Net::PcapUtils; use NetPacket::IP; use NetPacket::TCP; use NetPacket::Ethernet; Net::PcapUtils::loop(\&packets, FILTER=>"tcp"); sub packets{ my($user_data, $hdr, $pkt) = @_; my $eth_data = NetPacket::Ethernet::strip($pkt); my $np_data = NetPacket::Ethernet->decode($pkt); my $ip = NetPacket::IP->decode($eth_data); my $tcp = NetPacket::TCP->decode($ip->{'data'}); $i++; print "($i) Packet Captured:\n"; print "ip/port:: $ip->{'src_ip'}:$tcp->{'src_port'} --> $ip +->{'dest_ip'}:$tcp->{'dest_port'}\n"; print "mac:: $np_data->{'src_mac'} --> $np_data->{'dest +_mac'}\n\n"; }
Retitled by davido.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to both send and receive in a Net::PcapUtils loop?
by NetWallah (Canon) on Jan 05, 2005 at 01:50 UTC | |
by Prism (Initiate) on Jan 05, 2005 at 17:01 UTC |