1Interface::Simple(3) User Contributed Perl Documentation Interface::Simple(3)
2
3
4
6 IO::Interface::Simple - Perl extension for access to network card
7 configuration 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 $interface = IO::Interface::Simple->new('eth0')
46 Given an interface name, new() creates an interface object.
47
48 @iflist = IO::Interface::Simple->interfaces;
49 Returns a list of active interface objects.
50
51 $interface = IO::Interface::Simple->new_from_address('192.168.0.1')
52 Returns the interface object corresponding to the given address.
53
54 $interface = IO::Interface::Simple->new_from_index(2)
55 Returns the interface object corresponding to the given numeric
56 index. This is only supported on BSD-ish platforms.
57
58 Object Methods
59 $name = $interface->name
60 Get the name of the interface. The interface object is also
61 overloaded so that if you use it in a string context it is the same
62 as calling name().
63
64 $index = $interface->index
65 Get the index of the interface. This is only supported on BSD-like
66 platforms.
67
68 $addr = $interface->address([$newaddr])
69 Get or set the interface's address.
70
71 $addr = $interface->broadcast([$newaddr])
72 Get or set the interface's broadcast address.
73
74 $addr = $interface->netmask([$newmask])
75 Get or set the interface's netmask.
76
77 $addr = $interface->hwaddr([$newaddr])
78 Get or set the interface's hardware address.
79
80 $addr = $interface->mtu([$newmtu])
81 Get or set the interface's MTU.
82
83 $addr = $interface->metric([$newmetric])
84 Get or set the interface's metric.
85
86 $flags = $interface->flags([$newflags])
87 Get or set the interface's flags. These can be ANDed with the IFF
88 constants exported by IO::Interface or Net::Interface in order to
89 interrogate the state and capabilities of the interface. However,
90 it is probably more convenient to use the broken-out methods listed
91 below.
92
93 $flag = $interface->is_running([$newflag])
94 $flag = $interface->is_broadcast([$newflag])
95 $flag = $interface->is_pt2pt([$newflag])
96 $flag = $interface->is_loopback([$newflag])
97 $flag = $interface->is_promiscuous([$newflag])
98 $flag = $interface->is_multicast([$newflag])
99 $flag = $interface->is_notrailers([$newflag])
100 $flag = $interface->is_noarp([$newflag])
101 Get or set the corresponding configuration parameters. Note that
102 the operating system may not let you set some of these.
103
105 Lincoln Stein <lstein@cshl.org>
106
107 This module is distributed under the same license as Perl itself.
108
110 perl, IO::Socket, IO::Multicast), IO::Interface, Net::Interface
111
112
113
114perl v5.12.0 2007-01-22 Interface::Simple(3)