line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SNMP::HostInfo::IpNetToMediaEntry;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::SNMP::HostInfo::IpNetToMediaEntry - An entry in the ipNetToMediaTable of a MIB-II host
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Net::SNMP::HostInfo;
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$host = shift || 'localhost';
|
12
|
|
|
|
|
|
|
$hostinfo = Net::SNMP::HostInfo->new(Hostname => $host);
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
print "\nNet To Media Table:\n";
|
15
|
|
|
|
|
|
|
printf "%-3s %-15s %-17s %s\n",
|
16
|
|
|
|
|
|
|
qw/If NetAddress PhysAddress Type/;
|
17
|
|
|
|
|
|
|
for $entry ($hostinfo->ipNetToMediaTable) {
|
18
|
|
|
|
|
|
|
printf "%-3s %-15s %-17s %s\n",
|
19
|
|
|
|
|
|
|
$entry->ipNetToMediaIfIndex,
|
20
|
|
|
|
|
|
|
$entry->ipNetToMediaNetAddress,
|
21
|
|
|
|
|
|
|
$entry->ipNetToMediaPhysAddress,
|
22
|
|
|
|
|
|
|
$entry->ipNetToMediaType;
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
"Each entry contains one IpAddress to `physical'
|
28
|
|
|
|
|
|
|
address equivalence."
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut
|
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
21
|
use 5.006;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
46
|
|
33
|
1
|
|
|
1
|
|
13
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
42
|
|
34
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
6
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
496
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#our $VERSION = '0.01';
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $AUTOLOAD;
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %oids = (
|
43
|
|
|
|
|
|
|
ipNetToMediaIfIndex => '1.3.6.1.2.1.4.22.1.1',
|
44
|
|
|
|
|
|
|
ipNetToMediaPhysAddress => '1.3.6.1.2.1.4.22.1.2',
|
45
|
|
|
|
|
|
|
ipNetToMediaNetAddress => '1.3.6.1.2.1.4.22.1.3',
|
46
|
|
|
|
|
|
|
ipNetToMediaType => '1.3.6.1.2.1.4.22.1.4',
|
47
|
|
|
|
|
|
|
);
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my %decodedObjects = (
|
50
|
|
|
|
|
|
|
ipNetToMediaType => { qw/1 other 2 invalid 3 dynamic 4 static/ },
|
51
|
|
|
|
|
|
|
);
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Preloaded methods go here.
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub new
|
62
|
|
|
|
|
|
|
{
|
63
|
0
|
|
|
0
|
0
|
|
my $class = shift;
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my %args = @_;
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $self = {};
|
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
$self->{_session} = $args{Session};
|
70
|
0
|
|
|
|
|
|
$self->{_decode} = $args{Decode};
|
71
|
0
|
|
|
|
|
|
$self->{_index} = $args{Index};
|
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
bless $self, $class;
|
74
|
0
|
|
|
|
|
|
return $self;
|
75
|
|
|
|
|
|
|
}
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item ipNetToMediaIfIndex
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
"The interface on which this entry's equivalence
|
80
|
|
|
|
|
|
|
is effective. The interface identified by a
|
81
|
|
|
|
|
|
|
particular value of this index is the same
|
82
|
|
|
|
|
|
|
interface as identified by the same value of
|
83
|
|
|
|
|
|
|
ifIndex."
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item ipNetToMediaPhysAddress
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
"The media-dependent `physical' address."
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item ipNetToMediaNetAddress
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
"The IpAddress corresponding to the media-
|
92
|
|
|
|
|
|
|
dependent `physical' address."
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item ipNetToMediaType
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
"The type of mapping.
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Setting this object to the value invalid(2) has
|
99
|
|
|
|
|
|
|
the effect of invalidating the corresponding entry
|
100
|
|
|
|
|
|
|
in the ipNetToMediaTable. That is, it effectively
|
101
|
|
|
|
|
|
|
dissasociates the interface identified with said
|
102
|
|
|
|
|
|
|
entry from the mapping identified with said entry.
|
103
|
|
|
|
|
|
|
It is an implementation-specific matter as to
|
104
|
|
|
|
|
|
|
whether the agent removes an invalidated entry
|
105
|
|
|
|
|
|
|
from the table. Accordingly, management stations
|
106
|
|
|
|
|
|
|
must be prepared to receive tabular information
|
107
|
|
|
|
|
|
|
from agents that corresponds to entries not
|
108
|
|
|
|
|
|
|
currently in use. Proper interpretation of such
|
109
|
|
|
|
|
|
|
entries requires examination of the relevant
|
110
|
|
|
|
|
|
|
ipNetToMediaType object."
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Possible values are:
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
other(1),
|
115
|
|
|
|
|
|
|
invalid(2),
|
116
|
|
|
|
|
|
|
dynamic(3),
|
117
|
|
|
|
|
|
|
static(4)
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=back
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub AUTOLOAD
|
124
|
|
|
|
|
|
|
{
|
125
|
0
|
|
|
0
|
|
|
my $self = shift;
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
|
return if $AUTOLOAD =~ /DESTROY$/;
|
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
my ($name) = $AUTOLOAD =~ /::([^:]+)$/;
|
131
|
|
|
|
|
|
|
#print "Called $name\n";
|
132
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if (!exists $oids{$name}) {
|
134
|
0
|
|
|
|
|
|
croak "Can't locate object method '$name'";
|
135
|
|
|
|
|
|
|
}
|
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
my $oid = $oids{$name} . '.' . $self->{_index};
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#print "Trying $oid\n";
|
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my $response = $self->{_session}->get_request($oid);
|
142
|
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
|
if ($response) {
|
144
|
0
|
|
|
|
|
|
my $value = $response->{$oid};
|
145
|
|
|
|
|
|
|
|
146
|
0
|
0
|
0
|
|
|
|
if ($self->{_decode} &&
|
|
|
|
0
|
|
|
|
|
147
|
|
|
|
|
|
|
exists $decodedObjects{$name} &&
|
148
|
|
|
|
|
|
|
exists $decodedObjects{$name}{$value}) {
|
149
|
0
|
|
|
|
|
|
return $decodedObjects{$name}{$value}."($value)";
|
150
|
|
|
|
|
|
|
} else {
|
151
|
0
|
0
|
0
|
|
|
|
if ($self->{_decode} && $name eq "ipNetToMediaPhysAddress") {
|
152
|
0
|
|
|
|
|
|
$value =~ s/^0x(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)(\w\w)$/$1-$2-$3-$4-$5-$6/;
|
153
|
|
|
|
|
|
|
}
|
154
|
0
|
|
|
|
|
|
return $value;
|
155
|
|
|
|
|
|
|
}
|
156
|
|
|
|
|
|
|
} else {
|
157
|
0
|
|
|
|
|
|
return undef;
|
158
|
|
|
|
|
|
|
}
|
159
|
|
|
|
|
|
|
}
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1;
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__END__
|