.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::Frame::Device 3pm" .TH Net::Frame::Device 3pm 2024-05-04 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Net::Frame::Device \- get network device information and gateway .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Net::Frame::Device; \& \& # Get default values from system \& my $device = Net::Frame::Device\->new; \& \& # Get values from a specific device \& my $device2 = Net::Frame::Device\->new(dev => \*(Aqvmnet1\*(Aq); \& \& # Get values from a specific target \& my $device3 = Net::Frame::Device\->new(target => \*(Aq192.168.10.2\*(Aq); \& \& print "dev: ", $device\->dev, "\en"; \& print "mac: ", $device\->mac, "\en"; \& print "ip : ", $device\->ip, "\en"; \& print "ip6: ", $device\->ip6, "\en"; \& print "gatewayIp: ", $device\->gatewayIp, "\en" if $device\->gatewayIp; \& print "gatewayMac: ", $device\->gatewayMac, "\en" if $device\->gatewayMac; \& \& # Get values from a specific target \& my $device5 = Net::Frame::Device\->new(target6 => \*(Aq2001::1\*(Aq); \& \& print "dev: ", $device5\->dev, "\en"; \& print "mac: ", $device5\->mac, "\en"; \& print "ip6: ", $device5\->ip6, "\en"; \& print "gatewayIp6: ", $device5\->gatewayIp6, "\en" if $device5\->gatewayIp6; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module is used to get network information, and is especially useful when you want to do low-level network programming. .PP It also provides useful functions to lookup network MAC addresses. .SH ATTRIBUTES .IX Header "ATTRIBUTES" .IP \fBdev\fR 4 .IX Item "dev" The network device. undef if none found. .IP \fBip\fR 4 .IX Item "ip" The IPv4 address of \fBdev\fR. undef if none found. .IP \fBip6\fR 4 .IX Item "ip6" The IPv6 address of \fBdev\fR. undef if none found. .IP \fBmac\fR 4 .IX Item "mac" The MAC address of \fBdev\fR. undef if none found. .IP \fBsubnet\fR 4 .IX Item "subnet" The subnet of IPv4 address \fBip\fR. undef if none found. .IP \fBsubnet6\fR 4 .IX Item "subnet6" The subnet of IPv6 address \fBip6\fR. undef if none found. .IP \fBgatewayIp\fR 4 .IX Item "gatewayIp" The gateway IPv4 address. It defaults to default gateway that let you access Internet. If none found, or not required in the usage context, it defaults to undef. .IP \fBgatewayIp6\fR 4 .IX Item "gatewayIp6" The gateway IPv6 address. It defaults to default gateway that let you access Internet. If none found, or not required in the usage context, it defaults to undef. .IP \fBgatewayMac\fR 4 .IX Item "gatewayMac" The MAC address \fBgatewayIp\fR. See \fBlookupMac\fR method. .IP \fBgatewayMac6\fR 4 .IX Item "gatewayMac6" The MAC address \fBgatewayIp6\fR. See \fBlookupMac6\fR method. .IP \fBtarget\fR 4 .IX Item "target" This attribute is used when you want to detect which \fBdev\fR, \fBip\fR, \fBmac\fR attributes to use for a specific target. See \fBSYNOPSIS\fR. .IP \fBtarget6\fR 4 .IX Item "target6" This attribute is used when you want to detect which \fBdev\fR, \fBip6\fR, \fBmac\fR attributes to use for a specific target. See \fBSYNOPSIS\fR. .SH METHODS .IX Header "METHODS" .IP \fBnew\fR 4 .IX Item "new" .PD 0 .IP "\fBnew\fR (hash)" 4 .IX Item "new (hash)" .PD Object constructor. See \fBSYNOPSIS\fR for default values. .IP \fBupdateFromDefault\fR 4 .IX Item "updateFromDefault" Will update attributes according to the default interface that has access to Internet. .IP \fBupdateFromDev\fR 4 .IX Item "updateFromDev" .PD 0 .IP "\fBupdateFromDev\fR (dev)" 4 .IX Item "updateFromDev (dev)" .PD Will update attributes according to \fBdev\fR attribute, or if you specify 'dev' as a parameter, it will use it for updating (and will also set \fBdev\fR to this new value). .IP \fBupdateFromTarget\fR 4 .IX Item "updateFromTarget" .PD 0 .IP "\fBupdateFromTarget\fR (target)" 4 .IX Item "updateFromTarget (target)" .PD Will update attributes according to \fBtarget\fR attribute, or if you specify 'target' as a parameter, it will use it for updating (and will also set \fBtarget\fR to this new value). .IP \fBupdateFromTarget6\fR 4 .IX Item "updateFromTarget6" .PD 0 .IP "\fBupdateFromTarget6\fR (target6)" 4 .IX Item "updateFromTarget6 (target6)" .PD Will update attributes according to \fBtarget6\fR attribute, or if you specify 'target6' as a parameter, it will use it for updating (and will also set \fBtarget6\fR to this new value). .IP "\fBlookupMac\fR (IPv4 address, [ retry, timeout ])" 4 .IX Item "lookupMac (IPv4 address, [ retry, timeout ])" Will try to get the MAC address of the specified IPv4 address. First, it checks against ARP cache table. Then, verify the target is on the same subnet as we are, and if yes, it does the ARP request. If not on the same subnet, it tries to resolve the gateway MAC address (by using \fBgatewayIp\fR attribute). You can add optional parameters retry count and timeout in seconds. Returns undef on failure. .IP "\fBlookupMac6\fR (IPv6 address, [ retry, timeout ])" 4 .IX Item "lookupMac6 (IPv6 address, [ retry, timeout ])" Will try to get the MAC address of the specified IPv6 address (using ICMPv6). First, verify the target is on the same subnet as we are, and if yes, it does the ICMPv6 lookup request. If not on the same subnet, it tries to resolve the gateway MAC address (by using \fBgatewayIp6\fR attribute). You can add optional parameters retry count and timeout in seconds. Returns undef on failure. .IP \fBdebugDeviceList\fR 4 .IX Item "debugDeviceList" Just for debugging purposes, especially on Windows systems. .SH AUTHOR .IX Header "AUTHOR" Patrice Auffret .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (c) 2006\-2015, Patrice Auffret .PP You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.