use warnings;
use strict;
use Data::Dumper;
use Net::Libdnet;
my $addr; # IP address
my $interf_ref; # hash reference to the NIC interface structure
my %interf_hash; # hash with the interface structure referenced as $interf_ref
$addr = '10.100.20.1'; # gateway IP addr
$interf_ref = Net::Libdnet::intf_get_dst($addr); # Net::Libdnet::intf_get_dst() -- retrieves the configuration for the best interface with which to reach the specified destination IP address
print Data::Dumper->Dump([\$interf_ref], [qw(interface)]);
$addr = '10.100.20.69'; # my IP addr
$interf_ref = Net::Libdnet::intf_get_src($addr); # Net::Libdnet::intf_get_src() -- retrieves the configuration for the interface with the specified source IP address.
print Data::Dumper->Dump([\$interf_ref], [qw(interface)]);
$interf_ref = Net::Libdnet::intf_get('eth0'); # Net::Libdnet::intf_get() -- retrieves an interface configuration entry, keyed on name
%interf_hash = %{$interf_ref};
print Data::Dumper->Dump([\%interf_hash], [qw(interface_eth0)]);
print "Key value: ", $interf_hash{'mtu'}, "\n";
print "Key value: ", ${$interf_ref}{'link_addr'}, "\n";
$interf_ref = Net::Libdnet::intf_get('eth1');
print Data::Dumper->Dump([\$interf_ref], [qw(interface_eth1)]);
$interf_ref = Net::Libdnet::intf_get('eth2');
print Data::Dumper->Dump([\$interf_ref], [qw(interface_eth2)]);
system('pause');
exit(0);
####
Net::Frame::Device: updateFromDefault: unable to get dnet
- or -
Net::Frame::Device: updateFromDev: unable to get dnet
- or -
Net::Frame::Device: updateFromTarget: unable to get dnet
####
cpan> install Net::Libdnet
Net-Libdnet-0.98/
...
Configuring G/GO/GOMOR/Net-Libdnet-0.98.tar.gz with Makefile.PL
Note (probably harmless): No library found for -ldnet
...
Libdnet.xs:37:18: dnet.h: No such file or directory
In file included from Libdnet.xs:77:
c/intf_entry.c: In function `intf_c2sv':
c/intf_entry.c:38: error: dereferencing pointer to incomplete type
c/intf_entry.c:39: error: dereferencing pointer to incomplete type
c/intf_entry.c:40: error: dereferencing pointer to incomplete type
c/intf_entry.c:41: error: dereferencing pointer to incomplete type
c/intf_entry.c:42: error: dereferencing pointer to incomplete type
c/intf_entry.c:44: error: dereferencing pointer to incomplete type
...
dmake.exe: Error code 129, while making 'Libdnet.o'
GOMOR/Net-Libdnet-0.98.tar.gz
C:\ACTIVE~1\site\bin\dmake.exe -- NOT OK
Failed during this command:
GOMOR/Net-Libdnet-0.98.tar.gz : make NO