I am trying to learn how to use PCAP libraries. So started on my windows Vista Enterprise laptop with wireless connection. No wired connection on the PC. To start with i want to get the network IPAddress and subnet mask. Eventually able to build the programme by cut&paste from all the perl experts articles:
use Net::Pcap;
my $dev = Net::Pcap::lookupdev( \$err );
if ( defined $err ) {
die "Unable to determine network device for monitoring - ", $err;
}
@devs = Net::Pcap::findalldevs(\$err);
foreach (@devs)
{
$dev= $_ ;
print "$_ \n";
my ( $addr, $net, $mask );
if ( Net::Pcap::lookupnet( $dev, \$net, \$mask, \$err ) )
{die "Unable to look up device information for ", $dev, " - "
+, $err; }
print "Device : $dev, Network Address : $net, NetMask : $mask \n"
+;
}
And the output is:
------------------
C:\Perl\Data>..\bin\perl Pcap-102.pl
\Device\NPF_{A6DECF92-8A65-40B8-BFDC-214D19DA6F37}
Device : \Device\NPF_{A6DECF92-8A65-40B8-BFDC-214D19DA6F37}, Network A
+ddress : 2604000768, NetMask : 4294967040
\Device\NPF_{8A8505C7-56D7-4D83-B18E-85957B77C060}
Device : \Device\NPF_{8A8505C7-56D7-4D83-B18E-85957B77C060}, Network A
+ddress : 3232238080, NetMask : 4294967040
\Device\NPF_{B44D4BF3-170A-4772-BF08-B03EB1739C5C}
Device : \Device\NPF_{B44D4BF3-170A-4772-BF08-B03EB1739C5C}, Network A
+ddress : 0, NetMask : 0
\Device\NPF_{691970A7-D403-46AD-BC01-1628915ED58A}
Device : \Device\NPF_{691970A7-D403-46AD-BC01-1628915ED58A}, Network A
+ddress : 0, NetMask : 4278190080
C:\Perl\Data>
-----------------
While my actual Wireless network adapter settings on the PC are:
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . : hsd1.ca.comcast.net.
Description . . . . . . . . . . . : Intel(R) WiFi Link 5300 AGN
Physical Address. . . . . . . . . : 00-21-6A-17-F1-56
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::11f2:d913:3057:da24%13(Pr
+eferred)
IPv4 Address. . . . . . . . . . . : 192.168.10.103(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Tuesday, January 01, 2013 8:20:
+58 PM
Lease Expires . . . . . . . . . . : Wednesday, January 02, 2013 2:3
+3:19 AM
Default Gateway . . . . . . . . . : 192.168.10.1
DHCP Server . . . . . . . . . . . : 192.168.10.1
DHCPv6 IAID . . . . . . . . . . . : 234889578
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-11-D6-E3-9D-00-25-B
+3-2E-25-5A
DNS Servers . . . . . . . . . . . : 202.148.200.3
NetBIOS over Tcpip. . . . . . . . : Enabled
---------------
Is not the function call "lookupdev" supposed to find the active Network adapter?
Is not the wireless adapter, part of the "findalldevs()" ?
Does windows OS need different PCAP functions?
I did read couple of similar questions but answers not in full. Thought may be i should post the question again.
Thanks
Simbha