line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SNMP::HostInfo::IpRouteEntry;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Net::SNMP::HostInfo::IpRouteEntry - An entry in the ipRouteTable 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 "\nRoute Table:\n";
|
15
|
|
|
|
|
|
|
printf "%-15s %-15s %-15s %-11s %-10s %-3s %-3s\n",
|
16
|
|
|
|
|
|
|
qw/Dest Mask NextHop Type Proto If Cost/;
|
17
|
|
|
|
|
|
|
for $route ($hostinfo->ipRouteTable) {
|
18
|
|
|
|
|
|
|
printf "%-15s %-15s %-15s %-11s %-10s %-3s %-3s\n",
|
19
|
|
|
|
|
|
|
$route->ipRouteDest,
|
20
|
|
|
|
|
|
|
$route->ipRouteMask,
|
21
|
|
|
|
|
|
|
$route->ipRouteNextHop,
|
22
|
|
|
|
|
|
|
$route->ipRouteType,
|
23
|
|
|
|
|
|
|
$route->ipRouteProto,
|
24
|
|
|
|
|
|
|
$route->ipRouteIfIndex,
|
25
|
|
|
|
|
|
|
$route->ipRouteMetric1;
|
26
|
|
|
|
|
|
|
}
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
"A route to a particular destination."
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut
|
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
19
|
use 5.006;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
35
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
36
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
5
|
use Carp;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1257
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#our $VERSION = '0.01';
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $AUTOLOAD;
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my %oids = (
|
45
|
|
|
|
|
|
|
ipRouteDest => '1.3.6.1.2.1.4.21.1.1',
|
46
|
|
|
|
|
|
|
ipRouteIfIndex => '1.3.6.1.2.1.4.21.1.2',
|
47
|
|
|
|
|
|
|
ipRouteMetric1 => '1.3.6.1.2.1.4.21.1.3',
|
48
|
|
|
|
|
|
|
ipRouteMetric2 => '1.3.6.1.2.1.4.21.1.4',
|
49
|
|
|
|
|
|
|
ipRouteMetric3 => '1.3.6.1.2.1.4.21.1.5',
|
50
|
|
|
|
|
|
|
ipRouteMetric4 => '1.3.6.1.2.1.4.21.1.6',
|
51
|
|
|
|
|
|
|
ipRouteNextHop => '1.3.6.1.2.1.4.21.1.7',
|
52
|
|
|
|
|
|
|
ipRouteType => '1.3.6.1.2.1.4.21.1.8',
|
53
|
|
|
|
|
|
|
ipRouteProto => '1.3.6.1.2.1.4.21.1.9',
|
54
|
|
|
|
|
|
|
ipRouteAge => '1.3.6.1.2.1.4.21.1.10',
|
55
|
|
|
|
|
|
|
ipRouteMask => '1.3.6.1.2.1.4.21.1.11',
|
56
|
|
|
|
|
|
|
ipRouteMetric5 => '1.3.6.1.2.1.4.21.1.12',
|
57
|
|
|
|
|
|
|
ipRouteInfo => '1.3.6.1.2.1.4.21.1.13',
|
58
|
|
|
|
|
|
|
);
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my %decodedObjects = (
|
61
|
|
|
|
|
|
|
ipRouteType => { qw/1 other 2 invalid 3 direct 4 indirect/ },
|
62
|
|
|
|
|
|
|
ipRouteProto => { qw/1 other
|
63
|
|
|
|
|
|
|
2 local
|
64
|
|
|
|
|
|
|
3 netmgmt
|
65
|
|
|
|
|
|
|
4 icmp
|
66
|
|
|
|
|
|
|
5 egp
|
67
|
|
|
|
|
|
|
6 ggp
|
68
|
|
|
|
|
|
|
7 hello
|
69
|
|
|
|
|
|
|
8 rip
|
70
|
|
|
|
|
|
|
9 is-is
|
71
|
|
|
|
|
|
|
10 es-is
|
72
|
|
|
|
|
|
|
11 ciscoIgrp
|
73
|
|
|
|
|
|
|
12 bbnSpfIgp
|
74
|
|
|
|
|
|
|
13 ospf
|
75
|
|
|
|
|
|
|
14 bgp/ },
|
76
|
|
|
|
|
|
|
);
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Preloaded methods go here.
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub new
|
87
|
|
|
|
|
|
|
{
|
88
|
0
|
|
|
0
|
0
|
|
my $class = shift;
|
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my %args = @_;
|
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $self = {};
|
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
$self->{_session} = $args{Session};
|
95
|
0
|
|
|
|
|
|
$self->{_decode} = $args{Decode};
|
96
|
0
|
|
|
|
|
|
$self->{_index} = $args{Index};
|
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
bless $self, $class;
|
99
|
0
|
|
|
|
|
|
return $self;
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item ipRouteDest
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
"The destination IP address of this route. An
|
105
|
|
|
|
|
|
|
entry with a value of 0.0.0.0 is considered a
|
106
|
|
|
|
|
|
|
default route. Multiple routes to a single
|
107
|
|
|
|
|
|
|
destination can appear in the table, but access to
|
108
|
|
|
|
|
|
|
such multiple entries is dependent on the table-
|
109
|
|
|
|
|
|
|
access mechanisms defined by the network
|
110
|
|
|
|
|
|
|
management protocol in use."
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item ipRouteIfIndex
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
"The index value which uniquely identifies the
|
115
|
|
|
|
|
|
|
local interface through which the next hop of this
|
116
|
|
|
|
|
|
|
route should be reached. The interface identified
|
117
|
|
|
|
|
|
|
by a particular value of this index is the same
|
118
|
|
|
|
|
|
|
interface as identified by the same value of
|
119
|
|
|
|
|
|
|
ifIndex."
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item ipRouteMetric1
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
"The primary routing metric for this route. The
|
124
|
|
|
|
|
|
|
semantics of this metric are determined by the
|
125
|
|
|
|
|
|
|
routing-protocol specified in the route's
|
126
|
|
|
|
|
|
|
ipRouteProto value. If this metric is not used,
|
127
|
|
|
|
|
|
|
its value should be set to -1."
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item ipRouteMetric2
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
"An alternate routing metric for this route. The
|
132
|
|
|
|
|
|
|
semantics of this metric are determined by the
|
133
|
|
|
|
|
|
|
routing-protocol specified in the route's
|
134
|
|
|
|
|
|
|
ipRouteProto value. If this metric is not used,
|
135
|
|
|
|
|
|
|
its value should be set to -1."
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item ipRouteMetric3
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
"An alternate routing metric for this route. The
|
140
|
|
|
|
|
|
|
semantics of this metric are determined by the
|
141
|
|
|
|
|
|
|
routing-protocol specified in the route's
|
142
|
|
|
|
|
|
|
ipRouteProto value. If this metric is not used,
|
143
|
|
|
|
|
|
|
its value should be set to -1."
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item ipRouteMetric4
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
"An alternate routing metric for this route. The
|
148
|
|
|
|
|
|
|
semantics of this metric are determined by the
|
149
|
|
|
|
|
|
|
routing-protocol specified in the route's
|
150
|
|
|
|
|
|
|
ipRouteProto value. If this metric is not used,
|
151
|
|
|
|
|
|
|
its value should be set to -1."
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item ipRouteNextHop
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
"The IP address of the next hop of this route.
|
156
|
|
|
|
|
|
|
(In the case of a route bound to an interface
|
157
|
|
|
|
|
|
|
which is realized via a broadcast media, the value
|
158
|
|
|
|
|
|
|
of this field is the agent's IP address on that
|
159
|
|
|
|
|
|
|
interface.)"
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item ipRouteType
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
"The type of route. Note that the values
|
164
|
|
|
|
|
|
|
direct(3) and indirect(4) refer to the notion of
|
165
|
|
|
|
|
|
|
direct and indirect routing in the IP
|
166
|
|
|
|
|
|
|
architecture.
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Setting this object to the value invalid(2) has
|
169
|
|
|
|
|
|
|
the effect of invalidating the corresponding entry
|
170
|
|
|
|
|
|
|
in the ipRouteTable object. That is, it
|
171
|
|
|
|
|
|
|
effectively dissasociates the destination
|
172
|
|
|
|
|
|
|
identified with said entry from the route
|
173
|
|
|
|
|
|
|
identified with said entry. It is an
|
174
|
|
|
|
|
|
|
implementation-specific matter as to whether the
|
175
|
|
|
|
|
|
|
agent removes an invalidated entry from the table.
|
176
|
|
|
|
|
|
|
Accordingly, management stations must be prepared
|
177
|
|
|
|
|
|
|
to receive tabular information from agents that
|
178
|
|
|
|
|
|
|
corresponds to entries not currently in use.
|
179
|
|
|
|
|
|
|
Proper interpretation of such entries requires
|
180
|
|
|
|
|
|
|
examination of the relevant ipRouteType object."
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Possible values are:
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
other(1),
|
185
|
|
|
|
|
|
|
invalid(2),
|
186
|
|
|
|
|
|
|
direct(3),
|
187
|
|
|
|
|
|
|
indirect(4)
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item ipRouteProto
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
"The routing mechanism via which this route was
|
192
|
|
|
|
|
|
|
learned. Inclusion of values for gateway routing
|
193
|
|
|
|
|
|
|
protocols is not intended to imply that hosts
|
194
|
|
|
|
|
|
|
should support those protocols."
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Possible values are:
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
other(1),
|
199
|
|
|
|
|
|
|
local(2),
|
200
|
|
|
|
|
|
|
netmgmt(3),
|
201
|
|
|
|
|
|
|
icmp(4),
|
202
|
|
|
|
|
|
|
egp(5),
|
203
|
|
|
|
|
|
|
ggp(6),
|
204
|
|
|
|
|
|
|
hello(7),
|
205
|
|
|
|
|
|
|
rip(8),
|
206
|
|
|
|
|
|
|
is-is(9),
|
207
|
|
|
|
|
|
|
es-is(10),
|
208
|
|
|
|
|
|
|
ciscoIgrp(11),
|
209
|
|
|
|
|
|
|
bbnSpfIgp(12),
|
210
|
|
|
|
|
|
|
ospf(13),
|
211
|
|
|
|
|
|
|
bgp(14)
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item ipRouteAge
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
"The number of seconds since this route was last
|
216
|
|
|
|
|
|
|
updated or otherwise determined to be correct.
|
217
|
|
|
|
|
|
|
Note that no semantics of `too old' can be implied
|
218
|
|
|
|
|
|
|
except through knowledge of the routing protocol
|
219
|
|
|
|
|
|
|
by which the route was learned."
|
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item ipRouteMask
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
"Indicate the mask to be logical-ANDed with the
|
224
|
|
|
|
|
|
|
destination address before being compared to the
|
225
|
|
|
|
|
|
|
value in the ipRouteDest field. For those systems
|
226
|
|
|
|
|
|
|
that do not support arbitrary subnet masks, an
|
227
|
|
|
|
|
|
|
agent constructs the value of the ipRouteMask by
|
228
|
|
|
|
|
|
|
determining whether the value of the correspondent
|
229
|
|
|
|
|
|
|
ipRouteDest field belong to a class-A, B, or C
|
230
|
|
|
|
|
|
|
network, and then using one of:
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
mask network
|
233
|
|
|
|
|
|
|
255.0.0.0 class-A
|
234
|
|
|
|
|
|
|
255.255.0.0 class-B
|
235
|
|
|
|
|
|
|
255.255.255.0 class-C
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
If the value of the ipRouteDest is 0.0.0.0 (a
|
238
|
|
|
|
|
|
|
default route), then the mask value is also
|
239
|
|
|
|
|
|
|
0.0.0.0. It should be noted that all IP routing
|
240
|
|
|
|
|
|
|
subsystems implicitly use this mechanism."
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item ipRouteMetric5
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
"An alternate routing metric for this route. The
|
245
|
|
|
|
|
|
|
semantics of this metric are determined by the
|
246
|
|
|
|
|
|
|
routing-protocol specified in the route's
|
247
|
|
|
|
|
|
|
ipRouteProto value. If this metric is not used,
|
248
|
|
|
|
|
|
|
its value should be set to -1."
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item ipRouteInfo
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
"A reference to MIB definitions specific to the
|
253
|
|
|
|
|
|
|
particular routing protocol which is responsible
|
254
|
|
|
|
|
|
|
for this route, as determined by the value
|
255
|
|
|
|
|
|
|
specified in the route's ipRouteProto value. If
|
256
|
|
|
|
|
|
|
this information is not present, its value should
|
257
|
|
|
|
|
|
|
be set to the OBJECT IDENTIFIER { 0 0 }, which is
|
258
|
|
|
|
|
|
|
a syntatically valid object identifier, and any
|
259
|
|
|
|
|
|
|
conformant implementation of ASN.1 and BER must be
|
260
|
|
|
|
|
|
|
able to generate and recognize this value."
|
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=back
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=cut
|
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub AUTOLOAD
|
267
|
|
|
|
|
|
|
{
|
268
|
0
|
|
|
0
|
|
|
my $self = shift;
|
269
|
|
|
|
|
|
|
|
270
|
0
|
0
|
|
|
|
|
return if $AUTOLOAD =~ /DESTROY$/;
|
271
|
|
|
|
|
|
|
|
272
|
0
|
|
|
|
|
|
my ($name) = $AUTOLOAD =~ /::([^:]+)$/;
|
273
|
|
|
|
|
|
|
#print "Called $name\n";
|
274
|
|
|
|
|
|
|
|
275
|
0
|
0
|
|
|
|
|
if (!exists $oids{$name}) {
|
276
|
0
|
|
|
|
|
|
croak "Can't locate object method '$name'";
|
277
|
|
|
|
|
|
|
}
|
278
|
|
|
|
|
|
|
|
279
|
0
|
|
|
|
|
|
my $oid = $oids{$name} . '.' . $self->{_index};
|
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
#print "Trying $oid\n";
|
282
|
|
|
|
|
|
|
|
283
|
0
|
|
|
|
|
|
my $response = $self->{_session}->get_request($oid);
|
284
|
|
|
|
|
|
|
|
285
|
0
|
0
|
|
|
|
|
if ($response) {
|
286
|
0
|
|
|
|
|
|
my $value = $response->{$oid};
|
287
|
|
|
|
|
|
|
|
288
|
0
|
0
|
0
|
|
|
|
if ($self->{_decode} &&
|
|
|
|
0
|
|
|
|
|
289
|
|
|
|
|
|
|
exists $decodedObjects{$name} &&
|
290
|
|
|
|
|
|
|
exists $decodedObjects{$name}{$value}) {
|
291
|
0
|
|
|
|
|
|
return $decodedObjects{$name}{$value}."($value)";
|
292
|
|
|
|
|
|
|
} else {
|
293
|
0
|
|
|
|
|
|
return $value;
|
294
|
|
|
|
|
|
|
}
|
295
|
|
|
|
|
|
|
} else {
|
296
|
0
|
|
|
|
|
|
return undef;
|
297
|
|
|
|
|
|
|
}
|
298
|
|
|
|
|
|
|
}
|
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
1;
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
__END__
|