line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SNMP::Mixin::IpCidrRouteTable; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
218362
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
93
|
|
4
|
4
|
|
|
4
|
|
12
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
109
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# store this package name in a handy variable, |
8
|
|
|
|
|
|
|
# used for unambiguous prefix of mixin attributes |
9
|
|
|
|
|
|
|
# storage in object hash |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
my $prefix = __PACKAGE__; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# this module import config |
15
|
|
|
|
|
|
|
# |
16
|
4
|
|
|
4
|
|
13
|
use Carp (); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
57
|
|
17
|
4
|
|
|
4
|
|
751
|
use Net::SNMP qw(oid_lex_sort); |
|
4
|
|
|
|
|
49934
|
|
|
4
|
|
|
|
|
363
|
|
18
|
4
|
|
|
4
|
|
510
|
use Net::SNMP::Mixin::Util qw/idx2val push_error get_init_slot/; |
|
4
|
|
|
|
|
8625
|
|
|
4
|
|
|
|
|
29
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# this module export config |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
my @mixin_methods; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
BEGIN { |
26
|
4
|
|
|
4
|
|
1098
|
@mixin_methods = (qw/ get_ip_cidr_route_table /); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
4
|
|
|
|
|
27
|
use Sub::Exporter -setup => { |
30
|
|
|
|
|
|
|
exports => [@mixin_methods], |
31
|
|
|
|
|
|
|
groups => { default => [@mixin_methods], }, |
32
|
4
|
|
|
4
|
|
16
|
}; |
|
4
|
|
|
|
|
6
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# SNMP oid constants used in this module |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# from IP Forwarding Table MIB, RFC 2096 |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
use constant { |
40
|
4
|
|
|
|
|
1981
|
IP_CIDR_ROUTE_TABLE => '1.3.6.1.2.1.4.24.4', |
41
|
|
|
|
|
|
|
IP_CIDR_ROUTE_ENTRY => '1.3.6.1.2.1.4.24.4.1', |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
IP_CIDR_ROUTE_DEST => '1.3.6.1.2.1.4.24.4.1.1', |
44
|
|
|
|
|
|
|
IP_CIDR_ROUTE_MASK => '1.3.6.1.2.1.4.24.4.1.2', |
45
|
|
|
|
|
|
|
IP_CIDR_ROUTE_TOS => '1.3.6.1.2.1.4.24.4.1.3', |
46
|
|
|
|
|
|
|
IP_CIDR_ROUTE_NEXTHOP => '1.3.6.1.2.1.4.24.4.1.4', |
47
|
|
|
|
|
|
|
IP_CIDR_ROUTE_IFINDEX => '1.3.6.1.2.1.4.24.4.1.5', |
48
|
|
|
|
|
|
|
IP_CIDR_ROUTE_TYPE => '1.3.6.1.2.1.4.24.4.1.6', |
49
|
|
|
|
|
|
|
IP_CIDR_ROUTE_PROTO => '1.3.6.1.2.1.4.24.4.1.7', |
50
|
|
|
|
|
|
|
IP_CIDR_ROUTE_AGE => '1.3.6.1.2.1.4.24.4.1.8', |
51
|
|
|
|
|
|
|
IP_CIDR_ROUTE_INFO => '1.3.6.1.2.1.4.24.4.1.9', |
52
|
|
|
|
|
|
|
IP_CIDR_ROUTE_NEXTHOPAS => '1.3.6.1.2.1.4.24.4.1.10', |
53
|
|
|
|
|
|
|
IP_CIDR_ROUTE_METRIC1 => '1.3.6.1.2.1.4.24.4.1.11', |
54
|
|
|
|
|
|
|
IP_CIDR_ROUTE_METRIC2 => '1.3.6.1.2.1.4.24.4.1.12', |
55
|
|
|
|
|
|
|
IP_CIDR_ROUTE_METRIC3 => '1.3.6.1.2.1.4.24.4.1.13', |
56
|
|
|
|
|
|
|
IP_CIDR_ROUTE_METRIC4 => '1.3.6.1.2.1.4.24.4.1.14', |
57
|
|
|
|
|
|
|
IP_CIDR_ROUTE_METRIC5 => '1.3.6.1.2.1.4.24.4.1.15', |
58
|
|
|
|
|
|
|
IP_CIDR_ROUTE_STATUS => '1.3.6.1.2.1.4.24.4.1.16', |
59
|
4
|
|
|
4
|
|
1138
|
}; |
|
4
|
|
|
|
|
5
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# |
62
|
|
|
|
|
|
|
# the ipCidrRouteType enum |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
my %type_enum = ( |
65
|
|
|
|
|
|
|
1 => 'other', |
66
|
|
|
|
|
|
|
2 => 'reject', |
67
|
|
|
|
|
|
|
3 => 'local', |
68
|
|
|
|
|
|
|
4 => 'remote', |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
# the ipCidrRouteProto enum |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
my %proto_enum = ( |
75
|
|
|
|
|
|
|
1 => 'other', |
76
|
|
|
|
|
|
|
2 => 'local', |
77
|
|
|
|
|
|
|
3 => 'netmgmt', |
78
|
|
|
|
|
|
|
4 => 'icmp', |
79
|
|
|
|
|
|
|
5 => 'egp', |
80
|
|
|
|
|
|
|
6 => 'ggp', |
81
|
|
|
|
|
|
|
7 => 'hello', |
82
|
|
|
|
|
|
|
8 => 'rip', |
83
|
|
|
|
|
|
|
9 => 'is-is', |
84
|
|
|
|
|
|
|
10 => 'es-is', |
85
|
|
|
|
|
|
|
11 => 'ciscoIgrp', |
86
|
|
|
|
|
|
|
12 => 'bbnSpfIgp', |
87
|
|
|
|
|
|
|
13 => 'ospf', |
88
|
|
|
|
|
|
|
14 => 'bgp', |
89
|
|
|
|
|
|
|
15 => 'idpr', |
90
|
|
|
|
|
|
|
16 => 'ciscoEigrp', |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
# the ipCidrRouteStatus enum |
95
|
|
|
|
|
|
|
# |
96
|
|
|
|
|
|
|
my %status_enum = ( |
97
|
|
|
|
|
|
|
1 => 'active', |
98
|
|
|
|
|
|
|
2 => 'notInService', |
99
|
|
|
|
|
|
|
3 => 'notReady', |
100
|
|
|
|
|
|
|
4 => 'createAndGo', |
101
|
|
|
|
|
|
|
5 => 'createAndWait', |
102
|
|
|
|
|
|
|
6 => 'destroy', |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Net::SNMP::Mixin::IpCidrRouteTable - mixin class for the mib-II ipCidrRouteTable |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 VERSION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Version 0.05 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SYNOPSIS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
use Net::SNMP; |
120
|
|
|
|
|
|
|
use Net::SNMP::Mixin; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#... |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $session = Net::SNMP->session( -hostname => 'foo.bar.com' ); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
$session->mixer('Net::SNMP::Mixin::IpCidrRouteTable'); |
127
|
|
|
|
|
|
|
$session->init_mixins; |
128
|
|
|
|
|
|
|
snmp_dispatcher(); |
129
|
|
|
|
|
|
|
$session->init_ok(); |
130
|
|
|
|
|
|
|
die $session->errors if $session->errors; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my @routes = $session->get_ip_cidr_route_table(); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
foreach my $route (@routes) { |
135
|
|
|
|
|
|
|
my $dest = $route->{ipCidrRouteDest}; |
136
|
|
|
|
|
|
|
my $mask = $route->{ipCidrRouteMask}; |
137
|
|
|
|
|
|
|
my $tos = $route->{ipCidrRouteTos}; |
138
|
|
|
|
|
|
|
my $next_hop = $route->{ipCidrRouteNextHop}; |
139
|
|
|
|
|
|
|
my $if_index = $route->{ipCidrRouteIfIndex}; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
print "$dest/$mask/$tos/$next_hop => $if_index/$next_hop\n"; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 DESCRIPTION |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
A Net::SNMP mixin class for mib-II ipCidrRouteTable info. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 MIXIN METHODS |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 B<< OBJ->get_ip_cidr_route_table() >> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Returns a sorted list of mib-II ipCidrRouteTable entries. Every list element (route entry) is a hashref with the following fields and values: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
{ |
155
|
|
|
|
|
|
|
ipCidrRouteDest => IpAddress, # tbl index |
156
|
|
|
|
|
|
|
ipCidrRouteMask => IpAddress, # tbl index |
157
|
|
|
|
|
|
|
ipCidrRouteTos => Integer32, # tbl index |
158
|
|
|
|
|
|
|
ipCidrRouteNextHop => IpAddress, # tbl index |
159
|
|
|
|
|
|
|
ipCidrRouteIfIndex => Integer32, |
160
|
|
|
|
|
|
|
ipCidrRouteType => INTEGER, |
161
|
|
|
|
|
|
|
ipCidrRouteTypeString => String, # resolved enum |
162
|
|
|
|
|
|
|
ipCidrRouteProto => INTEGER, |
163
|
|
|
|
|
|
|
ipCidrRouteProtoString => String, # resolved enum |
164
|
|
|
|
|
|
|
ipCidrRouteAge => Integer32, |
165
|
|
|
|
|
|
|
ipCidrRouteInfo => OBJECT IDENTIFIER, |
166
|
|
|
|
|
|
|
ipCidrRouteNextHopAS => Integer32, |
167
|
|
|
|
|
|
|
ipCidrRouteMetric1 => Integer32, |
168
|
|
|
|
|
|
|
ipCidrRouteMetric2 => Integer32, |
169
|
|
|
|
|
|
|
ipCidrRouteMetric3 => Integer32, |
170
|
|
|
|
|
|
|
ipCidrRouteMetric4 => Integer32, |
171
|
|
|
|
|
|
|
ipCidrRouteMetric5 => Integer32, |
172
|
|
|
|
|
|
|
ipCidrRouteStatus => RowStatus, |
173
|
|
|
|
|
|
|
ipCidrRouteStatusString => String, # resolved enum |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub get_ip_cidr_route_table { |
179
|
1
|
|
|
1
|
1
|
19043
|
my $session = shift; |
180
|
1
|
|
|
|
|
4
|
my $agent = $session->hostname; |
181
|
|
|
|
|
|
|
|
182
|
1
|
50
|
|
|
|
6
|
Carp::croak "$agent: '$prefix' not initialized," |
183
|
|
|
|
|
|
|
unless $session->init_ok($prefix); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# stash for return values |
187
|
0
|
|
|
|
|
0
|
my @route_tbl; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
my ( |
190
|
0
|
|
|
|
|
0
|
$ipCidrRouteDest, $ipCidrRouteMask, |
191
|
|
|
|
|
|
|
$ipCidrRouteTos, $ipCidrRouteNextHop, |
192
|
|
|
|
|
|
|
$ipCidrRouteIfIndex, $ipCidrRouteType, |
193
|
|
|
|
|
|
|
$ipCidrRouteTypeString, $ipCidrRouteProto, |
194
|
|
|
|
|
|
|
$ipCidrRouteProtoString, $ipCidrRouteAge, |
195
|
|
|
|
|
|
|
$ipCidrRouteInfo, $ipCidrRouteNextHopAS, |
196
|
|
|
|
|
|
|
$ipCidrRouteMetric1, $ipCidrRouteMetric2, |
197
|
|
|
|
|
|
|
$ipCidrRouteMetric3, $ipCidrRouteMetric4, |
198
|
|
|
|
|
|
|
$ipCidrRouteMetric5, $ipCidrRouteStatus, |
199
|
|
|
|
|
|
|
$ipCidrRouteStatusString, |
200
|
|
|
|
|
|
|
); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
# |
203
|
|
|
|
|
|
|
# index is ipCidrRouteDest,ipCidrRouteMask,ipCidrRouteTos,ipCidrRouteNextHop |
204
|
|
|
|
|
|
|
# |
205
|
0
|
|
|
|
|
0
|
foreach |
206
|
0
|
|
|
|
|
0
|
my $idx ( oid_lex_sort keys %{ $session->{$prefix}{ipCidrRouteDest} } ) |
207
|
|
|
|
|
|
|
{ |
208
|
0
|
|
|
|
|
0
|
$ipCidrRouteDest = $session->{$prefix}{ipCidrRouteDest}{$idx}; |
209
|
0
|
|
|
|
|
0
|
$ipCidrRouteMask = $session->{$prefix}{ipCidrRouteMask}{$idx}; |
210
|
0
|
|
|
|
|
0
|
$ipCidrRouteTos = $session->{$prefix}{ipCidrRouteTos}{$idx}; |
211
|
0
|
|
|
|
|
0
|
$ipCidrRouteNextHop = $session->{$prefix}{ipCidrRouteNextHop}{$idx}; |
212
|
0
|
|
|
|
|
0
|
$ipCidrRouteIfIndex = $session->{$prefix}{ipCidrRouteIfIndex}{$idx}; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
0
|
|
|
0
|
$ipCidrRouteType = $session->{$prefix}{ipCidrRouteType}{$idx} || -1; |
215
|
0
|
|
0
|
|
|
0
|
$ipCidrRouteTypeString = $type_enum{$ipCidrRouteType} || 'unknown'; |
216
|
|
|
|
|
|
|
|
217
|
0
|
|
0
|
|
|
0
|
$ipCidrRouteProto = $session->{$prefix}{ipCidrRouteProto}{$idx} || -1; |
218
|
0
|
|
0
|
|
|
0
|
$ipCidrRouteProtoString = $proto_enum{$ipCidrRouteProto} || 'unknown'; |
219
|
|
|
|
|
|
|
|
220
|
0
|
|
|
|
|
0
|
$ipCidrRouteAge = $session->{$prefix}{ipCidrRouteAge}{$idx}; |
221
|
0
|
|
|
|
|
0
|
$ipCidrRouteInfo = $session->{$prefix}{ipCidrRouteInfo}{$idx}; |
222
|
0
|
|
|
|
|
0
|
$ipCidrRouteNextHopAS = $session->{$prefix}{ipCidrRouteNextHopAS}{$idx}; |
223
|
0
|
|
|
|
|
0
|
$ipCidrRouteMetric1 = $session->{$prefix}{ipCidrRouteMetric1}{$idx}; |
224
|
0
|
|
|
|
|
0
|
$ipCidrRouteMetric2 = $session->{$prefix}{ipCidrRouteMetric2}{$idx}; |
225
|
0
|
|
|
|
|
0
|
$ipCidrRouteMetric3 = $session->{$prefix}{ipCidrRouteMetric3}{$idx}; |
226
|
0
|
|
|
|
|
0
|
$ipCidrRouteMetric4 = $session->{$prefix}{ipCidrRouteMetric4}{$idx}; |
227
|
0
|
|
|
|
|
0
|
$ipCidrRouteMetric5 = $session->{$prefix}{ipCidrRouteMetric5}{$idx}; |
228
|
|
|
|
|
|
|
|
229
|
0
|
|
0
|
|
|
0
|
$ipCidrRouteStatus = $session->{$prefix}{ipCidrRouteStatus}{$idx} || -1; |
230
|
0
|
|
0
|
|
|
0
|
$ipCidrRouteStatusString = $status_enum{$ipCidrRouteStatus} || 'unknown'; |
231
|
|
|
|
|
|
|
|
232
|
0
|
|
|
|
|
0
|
push @route_tbl, |
233
|
|
|
|
|
|
|
{ |
234
|
|
|
|
|
|
|
ipCidrRouteDest => $ipCidrRouteDest, |
235
|
|
|
|
|
|
|
ipCidrRouteMask => $ipCidrRouteMask, |
236
|
|
|
|
|
|
|
ipCidrRouteTos => $ipCidrRouteTos, |
237
|
|
|
|
|
|
|
ipCidrRouteNextHop => $ipCidrRouteNextHop, |
238
|
|
|
|
|
|
|
ipCidrRouteIfIndex => $ipCidrRouteIfIndex, |
239
|
|
|
|
|
|
|
ipCidrRouteType => $ipCidrRouteType, |
240
|
|
|
|
|
|
|
ipCidrRouteTypeString => $ipCidrRouteTypeString, |
241
|
|
|
|
|
|
|
ipCidrRouteProto => $ipCidrRouteProto, |
242
|
|
|
|
|
|
|
ipCidrRouteProtoString => $ipCidrRouteProtoString, |
243
|
|
|
|
|
|
|
ipCidrRouteAge => $ipCidrRouteAge, |
244
|
|
|
|
|
|
|
ipCidrRouteInfo => $ipCidrRouteInfo, |
245
|
|
|
|
|
|
|
ipCidrRouteNextHopAS => $ipCidrRouteNextHopAS, |
246
|
|
|
|
|
|
|
ipCidrRouteMetric1 => $ipCidrRouteMetric1, |
247
|
|
|
|
|
|
|
ipCidrRouteMetric2 => $ipCidrRouteMetric2, |
248
|
|
|
|
|
|
|
ipCidrRouteMetric3 => $ipCidrRouteMetric3, |
249
|
|
|
|
|
|
|
ipCidrRouteMetric4 => $ipCidrRouteMetric4, |
250
|
|
|
|
|
|
|
ipCidrRouteMetric5 => $ipCidrRouteMetric5, |
251
|
|
|
|
|
|
|
ipCidrRouteStatus => $ipCidrRouteStatus, |
252
|
|
|
|
|
|
|
ipCidrRouteStatusString => $ipCidrRouteStatusString, |
253
|
|
|
|
|
|
|
}; |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
0
|
|
|
|
|
0
|
return @route_tbl; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 INITIALIZATION |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 B<< OBJ->_init($reload) >> |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Fetch the mib-II ipCidrRouteTable from the host. Don't call this method direct! |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=cut |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
# |
268
|
|
|
|
|
|
|
# due to the asynchron nature, we don't know what init job is really the last, we decrement |
269
|
|
|
|
|
|
|
# the value after each callback |
270
|
|
|
|
|
|
|
# |
271
|
4
|
|
|
4
|
|
19
|
use constant THIS_INIT_JOBS => 1; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
1855
|
|
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub _init { |
274
|
4
|
|
|
4
|
|
6470
|
my ( $session, $reload ) = @_; |
275
|
4
|
|
|
|
|
10
|
my $agent = $session->hostname; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
die "$agent: $prefix already initialized and reload not forced.\n" |
278
|
|
|
|
|
|
|
if exists get_init_slot($session)->{$prefix} |
279
|
4
|
50
|
66
|
|
|
18
|
&& get_init_slot($session)->{$prefix} == 0 |
|
|
|
33
|
|
|
|
|
280
|
|
|
|
|
|
|
&& not $reload; |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# set number of async init jobs for proper initialization |
283
|
4
|
|
|
|
|
86
|
get_init_slot($session)->{$prefix} = THIS_INIT_JOBS; |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# populate the object with needed mib values |
286
|
|
|
|
|
|
|
# |
287
|
|
|
|
|
|
|
# initialize the object for ipCidrRouteTable infos |
288
|
4
|
|
|
|
|
33
|
_fetch_ip_cidr_route_tbl($session); |
289
|
4
|
100
|
|
|
|
25
|
return if $session->error; |
290
|
|
|
|
|
|
|
|
291
|
2
|
|
|
|
|
12
|
return 1; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head1 PRIVATE METHODS |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Only for developers or maintainers. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head2 B<< _fetch_ip_cidr_route_tbl($session) >> |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
Fetch the ipCidrRouteTable once during object initialization. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=cut |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub _fetch_ip_cidr_route_tbl { |
305
|
4
|
|
|
4
|
|
6
|
my $session = shift; |
306
|
4
|
|
|
|
|
4
|
my $result; |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# fetch the ipCidrRouteTable |
309
|
4
|
100
|
|
|
|
22
|
$result = $session->get_table( |
310
|
|
|
|
|
|
|
-baseoid => IP_CIDR_ROUTE_TABLE, |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
# define callback if in nonblocking mode |
313
|
|
|
|
|
|
|
$session->nonblocking ? ( -callback => \&_ip_cidr_route_tbl_cb ) : (), |
314
|
|
|
|
|
|
|
); |
315
|
|
|
|
|
|
|
|
316
|
4
|
100
|
|
|
|
2007684
|
unless ( defined $result ) { |
317
|
2
|
50
|
|
|
|
19
|
if (my $err_msg = $session->error) { |
318
|
2
|
|
|
|
|
29
|
push_error($session, "$prefix: $err_msg"); |
319
|
|
|
|
|
|
|
}; |
320
|
2
|
|
|
|
|
62
|
return; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
# in nonblocking mode the callback will be called asynchronously |
324
|
2
|
50
|
|
|
|
7
|
return 1 if $session->nonblocking; |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
# ok we are in synchronous mode, call the result mangling function |
327
|
|
|
|
|
|
|
# by hand |
328
|
0
|
|
|
|
|
0
|
_ip_cidr_route_tbl_cb($session); |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=head2 B<< _ip_cidr_route_tbl_cb($session) >> |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
The callback for _fetch_ip_cidr_route_tbl(). |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=cut |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub _ip_cidr_route_tbl_cb { |
339
|
2
|
|
|
2
|
|
2004080
|
my $session = shift; |
340
|
2
|
|
|
|
|
11
|
my $vbl = $session->var_bind_list; |
341
|
|
|
|
|
|
|
|
342
|
2
|
50
|
|
|
|
23
|
unless ( defined $vbl ) { |
343
|
2
|
50
|
|
|
|
10
|
if (my $err_msg = $session->error) { |
344
|
2
|
|
|
|
|
25
|
push_error($session, "$prefix: $err_msg"); |
345
|
|
|
|
|
|
|
}; |
346
|
2
|
|
|
|
|
47
|
return; |
347
|
|
|
|
|
|
|
} |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
# build parallel hashes, keys are the index: |
350
|
|
|
|
|
|
|
# |
351
|
|
|
|
|
|
|
# ipCidrRouteDest,ipCidrRouteMask,ipCidrRouteTos,ipCidrRouteNextHop |
352
|
|
|
|
|
|
|
# |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteDest} = |
355
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_DEST, undef, undef, ); |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteMask} = |
358
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_MASK, undef, undef, ); |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteTos} = |
361
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_TOS, undef, undef, ); |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteNextHop} = |
364
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_NEXTHOP, undef, undef, ); |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteIfIndex} = |
367
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_IFINDEX, undef, undef, ); |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteType} = |
370
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_TYPE, undef, undef, ); |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteProto} = |
373
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_PROTO, undef, undef, ); |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteAge} = |
376
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_AGE, undef, undef, ); |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteInfo} = |
379
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_INFO, undef, undef, ); |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteNextHopAS} = |
382
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_NEXTHOPAS, undef, undef, ); |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteMetric1} = |
385
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_METRIC1, undef, undef, ); |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteMetric2} = |
388
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_METRIC2, undef, undef, ); |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteMetric3} = |
391
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_METRIC3, undef, undef, ); |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteMetric4} = |
394
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_METRIC4, undef, undef, ); |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteMetric5} = |
397
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_METRIC5, undef, undef, ); |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
$session->{$prefix}{ipCidrRouteStatus} = |
400
|
0
|
|
|
|
|
|
idx2val( $vbl, IP_CIDR_ROUTE_STATUS, undef, undef, ); |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
# this init job is finished |
403
|
0
|
|
|
|
|
|
get_init_slot($session)->{$prefix}--; |
404
|
|
|
|
|
|
|
|
405
|
0
|
|
|
|
|
|
return 1; |
406
|
|
|
|
|
|
|
} |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
unless ( caller() ) { |
409
|
|
|
|
|
|
|
print "$prefix compiles and initializes successful.\n"; |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=head1 SEE ALSO |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
L<< Net::SNMP::Mixin >> |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
=head1 REQUIREMENTS |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
L<< Net::SNMP >>, L<< Net::SNMP::Mixin >> |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=head1 BUGS, PATCHES & FIXES |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
There are no known bugs at the time of this release. However, if you spot a bug or are experiencing difficulties that are not explained within the POD documentation, please submit a bug to the RT system (see link below). However, it would help greatly if you are able to pinpoint problems or even supply a patch. |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
Fixes are dependant upon their severity and my availablity. Should a fix not be forthcoming, please feel free to (politely) remind me by sending an email to gaissmai@cpan.org . |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
RT: http://rt.cpan.org/Public/Dist/Display.html?Name=Net-SNMP-Mixin-IpCidrRouteTable |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
=head1 AUTHOR |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
Karl Gaissmaier |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
Copyright 2011-2016 Karl Gaissmaier, all rights reserved. |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
438
|
|
|
|
|
|
|
under the same terms as Perl itself. |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=cut |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
1; |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
# vim: sw=2 |