NAME

Net::Pcap::FindDevice - find the "best" network device for sniffing

SYNOPSIS

  use Net::Pcap;
  use Net::Pcap::FindDevice;

  my $device = find_device($ARGV[0]);

  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.

find_device DEVICE

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 undef.

interfaces_from_ip IP

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

  Net::Pcap::FindDevice::interfaces_from_ip('127.0.0.1')

AUTHOR

Max Maischein (corion@cpan.org)

COPYRIGHT

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.

SEE ALSO

Net::Pcap, ethereal, the Alsace in autumn