1Interface::Simple(3) User Contributed Perl Documentation Interface::Simple(3)
2
3
4
6 IO::Interface::Simple - Perl extension for access to network card con‐
7 figuration information
8
10 use IO::Interface::Simple;
11
12 my $if1 = IO::Interface::Simple->new('eth0');
13 my $if2 = IO::Interface::Simple->new_from_address('127.0.0.1');
14 my $if3 = IO::Interface::Simple->new_from_index(1);
15
16 my @interfaces = IO::Interface::Simple->interfaces;
17
18 for my $if (@interfaces) {
19 print "interface = $if\n";
20 print "addr = ",$if->address,"\n",
21 "broadcast = ",$if->broadcast,"\n",
22 "netmask = ",$if->netmask,"\n",
23 "dstaddr = ",$if->dstaddr,"\n",
24 "hwaddr = ",$if->hwaddr,"\n",
25 "mtu = ",$if->mtu,"\n",
26 "metric = ",$if->metric,"\n",
27 "index = ",$if->index,"\n";
28
29 print "is running\n" if $if->is_running;
30 print "is broadcast\n" if $if->is_broadcast;
31 print "is p-to-p\n" if $if->is_pt2pt;
32 print "is loopback\n" if $if->is_loopback;
33 print "is promiscuous\n" if $if->is_promiscuous;
34 print "is multicast\n" if $if->is_multicast;
35 print "is notrailers\n" if $if->is_notrailers;
36 print "is noarp\n" if $if->is_noarp;
37 }
38
40 IO::Interface::Simple allows you to interrogate and change network
41 interfaces. It has overlapping functionality with Net::Interface, but
42 might compile and run on more platforms.
43
44 Class Methods
45
46 $interface = IO::Interface::Simple->new('eth0')
47 Given an interface name, new() creates an interface object.
48
49 @iflist = IO::Interface::Simple->interfaces;
50 Returns a list of active interface objects.
51
52 $interface = IO::Interface::Simple->new_from_address('192.168.0.1')
53 Returns the interface object corresponding to the given address.
54
55 $interface = IO::Interface::Simple->new_from_index(2)
56 Returns the interface object corresponding to the given numeric
57 index. This is only supported on BSD-ish platforms.
58
59 Object Methods
60
61 $name = $interface->name
62 Get the name of the interface. The interface object is also over‐
63 loaded so that if you use it in a string context it is the same as
64 calling name().
65
66 $index = $interface->index
67 Get the index of the interface. This is only supported on BSD-like
68 platforms.
69
70 $addr = $interface->address([$newaddr])
71 Get or set the interface's address.
72
73 $addr = $interface->broadcast([$newaddr])
74 Get or set the interface's broadcast address.
75
76 $addr = $interface->netmask([$newmask])
77 Get or set the interface's netmask.
78
79 $addr = $interface->hwaddr([$newaddr])
80 Get or set the interface's hardware address.
81
82 $addr = $interface->mtu([$newmtu])
83 Get or set the interface's MTU.
84
85 $addr = $interface->metric([$newmetric])
86 Get or set the interface's metric.
87
88 $flags = $interface->flags([$newflags])
89 Get or set the interface's flags. These can be ANDed with the IFF
90 constants exported by IO::Interface or Net::Interface in order to
91 interrogate the state and capabilities of the interface. However,
92 it is probably more convenient to use the broken-out methods listed
93 below.
94
95 $flag = $interface->is_running([$newflag])
96 $flag = $interface->is_broadcast([$newflag])
97 $flag = $interface->is_pt2pt([$newflag])
98 $flag = $interface->is_loopback([$newflag])
99 $flag = $interface->is_promiscuous([$newflag])
100 $flag = $interface->is_multicast([$newflag])
101 $flag = $interface->is_notrailers([$newflag])
102 $flag = $interface->is_noarp([$newflag])
103 Get or set the corresponding configuration parameters. Note that
104 the operating system may not let you set some of these.
105
107 Lincoln Stein <lstein@cshl.org>
108
109 This module is distributed under the same license as Perl itself.
110
112 perl, IO::Socket, IO::Multicast), IO::Interface, Net::Interface
113
114
115
116perl v5.8.8 2007-01-22 Interface::Simple(3)