Net::Pcap::FindDevice - find the "best" network device for sniffing
use Net::Pcap; use Net::Pcap::FindDevice; my $device = find_device($ARGV); my $pcap = Net::Pcap::open_live($device, 128000, -1, 500, \$err);
This module exports only one subroutine,
find_device, which employs a dwimish method to find a network device suitable for sniffing with Net::Pcap.
Finds a good Net::Pcap device based on some criteria:
If the parameter given is a regular expression, is used to scan the names and descriptions of the Net::Pcap device list. The name of the first matching element is returned.
If a Net::Pcap device matching the stringified parameter exists, it is returned. If there exists no matching device for the scalar,
undef is returned.
If there is only one network device, the name of that device is returned.
If there is only one device left after removing all network devices with IP address 127.0.0.1, the name of that device is returned.
The name of the device with the default gateway (if any) is returned.
Otherwise it gives up and returns
Returns all interfaces that have the ip
IP. The value of
IP must be given as a string of four numbers.
This method is not exported by default so you need to call it fully specified as
Max Maischein (firstname.lastname@example.org)
Copyright (C) 2005 Max Maischein. All Rights Reserved.
This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Net::Pcap, ethereal, the Alsace in autumn