| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBD::Sys::Plugin::Any::NetIfconfigWrapper; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2557
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
91
|
|
|
4
|
3
|
|
|
3
|
|
22
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
99
|
|
|
5
|
3
|
|
|
3
|
|
15
|
use vars qw($VERSION @colNames); |
|
|
3
|
|
|
|
|
11
|
|
|
|
3
|
|
|
|
|
155
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
15
|
use base qw(DBD::Sys::Table); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1448
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=pod |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
DBD::Sys::Plugin::Any::NetIfconfigWrapper - provides a table containing the known network interfaces |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$netifs = $dbh->selectall_hashref("select * from netint", "interface"); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$VERSION = "0.02"; |
|
20
|
|
|
|
|
|
|
=head1 ISA |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
DBD::Sys::Plugin::Any::NetIfconfigWrapper |
|
23
|
|
|
|
|
|
|
ISA DBD::Sys::Table |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $haveNetIfconfigWrapper; |
|
28
|
|
|
|
|
|
|
my $haveNetAddrIP; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
@colNames = qw(interface address_family address netmask broadcast hwaddress flags_bin flags); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This module provides the table C which contains the network |
|
35
|
|
|
|
|
|
|
interfaces configured on a host and it's assigned addresses. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 COLUMNS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head3 interface |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Interface name (e.g. eth0, em0, ...) |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head3 address_family |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Address family of following address |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head3 address |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The address of the interface (addresses are unique, interfaces can have |
|
50
|
|
|
|
|
|
|
multiple addresses). |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head3 netmask |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Netmask of the address above. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 broadcast |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Broadcast address for network address |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head3 hwaddress |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Hardware address (MAC number) of the interface NIC. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head3 flags_bin |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Binary representation of the interface flags (at least I or I). |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head3 flags |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Comma separated list of the flags. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 get_table_name |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returns 'netint'. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
4
|
|
|
4
|
1
|
12
|
sub get_table_name() { return 'netint'; } |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 get_col_names |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns the column names of the table as named in L |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
0
|
1
|
|
sub get_col_names() { @colNames } |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 get_primary_key |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns 'address'. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
0
|
1
|
|
sub get_primary_key() { return [qw(interface address_family address)]; } |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 get_priority |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns 200 to let L dominate. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
1
|
|
sub get_priority() { return 200; } |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 collect_data |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Retrieves the data from L and put it into fetchable rows. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub collect_data() |
|
113
|
|
|
|
|
|
|
{ |
|
114
|
0
|
|
|
0
|
1
|
|
my @data; |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
unless ( defined($haveNetIfconfigWrapper) ) |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
0
|
|
|
|
|
|
$haveNetIfconfigWrapper = 0; |
|
119
|
0
|
|
|
|
|
|
eval { |
|
120
|
0
|
|
|
|
|
|
require Net::Ifconfig::Wrapper; |
|
121
|
0
|
|
|
|
|
|
$haveNetIfconfigWrapper = 1; |
|
122
|
|
|
|
|
|
|
}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
unless ( defined($haveNetAddrIP) ) |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
0
|
|
|
|
|
|
$haveNetAddrIP = 0; |
|
128
|
0
|
|
|
|
|
|
eval { |
|
129
|
0
|
|
|
|
|
|
require NetAddr::IP; |
|
130
|
0
|
|
|
|
|
|
$haveNetAddrIP = 1; |
|
131
|
|
|
|
|
|
|
}; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
if ($haveNetIfconfigWrapper) |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
0
|
0
|
|
|
|
|
my $info = Net::Ifconfig::Wrapper::Ifconfig( 'list', '', '', '' ) or return []; |
|
137
|
0
|
|
|
|
|
|
foreach my $interface ( keys %$info ) |
|
138
|
|
|
|
|
|
|
{ |
|
139
|
0
|
|
|
|
|
|
my $ifdata = $info->{$interface}; |
|
140
|
0
|
0
|
|
|
|
|
if ( exists $ifdata->{inet} ) |
|
141
|
|
|
|
|
|
|
{ |
|
142
|
0
|
|
|
|
|
|
while ( my ( $addr, $netmask ) = each %{ $ifdata->{inet} } ) |
|
|
0
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
{ |
|
144
|
0
|
|
|
|
|
|
my $bcast; |
|
145
|
0
|
0
|
|
|
|
|
if ($haveNetAddrIP) |
|
146
|
|
|
|
|
|
|
{ |
|
147
|
|
|
|
|
|
|
# XXX let's see what happens when Net::Ifconfig::Wrapper::Ifconfig delivers IPv6 addresses ... |
|
148
|
0
|
|
|
|
|
|
my $ip = NetAddr::IP->new( $addr, $netmask ); |
|
149
|
0
|
|
|
|
|
|
$bcast = $ip->broadcast(); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
push( |
|
153
|
0
|
0
|
|
|
|
|
@data, |
|
154
|
|
|
|
|
|
|
[ |
|
155
|
|
|
|
|
|
|
$interface, 'inet', $addr, $netmask, $bcast, $ifdata->{ether}, |
|
156
|
|
|
|
|
|
|
$ifdata->{status}, ( $ifdata->{status} ? '' : '' ) |
|
157
|
|
|
|
|
|
|
] |
|
158
|
|
|
|
|
|
|
); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
else |
|
162
|
|
|
|
|
|
|
{ |
|
163
|
0
|
0
|
|
|
|
|
push( |
|
164
|
|
|
|
|
|
|
@data, |
|
165
|
|
|
|
|
|
|
[ |
|
166
|
|
|
|
|
|
|
$interface, undef, undef, undef, undef, $ifdata->{ether}, |
|
167
|
|
|
|
|
|
|
$ifdata->{status}, ( $ifdata->{status} ? '' : '' ) |
|
168
|
|
|
|
|
|
|
] |
|
169
|
|
|
|
|
|
|
); |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
return \@data; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 PREREQUISITES |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
The module L is required to provide data for the table. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 AUTHOR |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Jens Rehsack Alexander Breibach |
|
185
|
|
|
|
|
|
|
CPAN ID: REHSACK |
|
186
|
|
|
|
|
|
|
rehsack@cpan.org alexander.breibach@googlemail.com |
|
187
|
|
|
|
|
|
|
http://www.rehsack.de/ |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
192
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
195
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 SUPPORT |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Free support can be requested via regular CPAN bug-tracking system. There is |
|
200
|
|
|
|
|
|
|
no guaranteed reaction time or solution time, but it's always tried to give |
|
201
|
|
|
|
|
|
|
accept or reject a reported ticket within a week. It depends on business load. |
|
202
|
|
|
|
|
|
|
That doesn't mean that ticket via rt aren't handles as soon as possible, |
|
203
|
|
|
|
|
|
|
that means that soon depends on how much I have to do. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Business and commercial support should be acquired from the authors via |
|
206
|
|
|
|
|
|
|
preferred freelancer agencies. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
1; |
|
211
|
|
|
|
|
|
|
|