| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SNMP::Insight::MIB; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#ABSTRACT: Base role for MIBs |
|
4
|
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
17517
|
use Moose::Role; |
|
|
6
|
|
|
|
|
355820
|
|
|
|
6
|
|
|
|
|
40
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001'; #TRIAL VERSION: |
|
8
|
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
25573
|
use namespace::autoclean; |
|
|
6
|
|
|
|
|
1119
|
|
|
|
6
|
|
|
|
|
41
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
requires 'session'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _mib_read_scalar { |
|
14
|
12
|
|
|
12
|
|
20
|
my ( $self, $oid, $munger ) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
12
|
|
|
|
|
317
|
my $v = $self->session->get_scalar($oid); |
|
17
|
12
|
50
|
|
|
|
34018
|
$munger and $v = $munger->($v); |
|
18
|
12
|
|
|
|
|
33
|
return $v; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _mib_read_tablerow { |
|
22
|
22
|
|
|
22
|
|
56
|
my ( $self, $oid, $munger ) = @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
22
|
|
|
|
|
927
|
my $row = $self->session->get_subtree($oid); |
|
25
|
|
|
|
|
|
|
|
|
26
|
22
|
|
|
|
|
164430
|
foreach (@$row) { |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Don't optimize this RE! |
|
29
|
44
|
50
|
|
|
|
994
|
$_->[0] =~ /^$oid\.(.*)/ and $_->[0] = $1; |
|
30
|
44
|
100
|
|
|
|
146
|
$munger and $_->[1] = $munger->( $_->[1] ); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
22
|
|
|
|
|
110
|
return $row; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _mib_read_table { |
|
37
|
1
|
|
|
1
|
|
2
|
my ( $self, $index, $columns ) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
2
|
my $table = {}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# TODO index handling |
|
42
|
|
|
|
|
|
|
# if ( ! $self->can($index) ) { |
|
43
|
|
|
|
|
|
|
# carp "Cannot find index $index"; |
|
44
|
|
|
|
|
|
|
# } |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
4
|
for my $col (@$columns) { |
|
47
|
22
|
|
|
|
|
178
|
my $col_values = $self->$col(); |
|
48
|
22
|
|
|
|
|
195
|
foreach my $pair (@$col_values) { |
|
49
|
44
|
|
|
|
|
501
|
$table->{ $pair->[0] }->{$col} = $pair->[1]; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
7
|
return $table; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub munge_bool { |
|
57
|
0
|
|
|
0
|
1
|
0
|
my $bool = shift; |
|
58
|
0
|
|
|
|
|
0
|
my @ARR = qw ( nop false true); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
return $ARR[$bool]; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub munge_ipaddress { |
|
64
|
0
|
|
|
0
|
1
|
0
|
my $ip = shift; |
|
65
|
0
|
|
|
|
|
0
|
return join( '.', unpack( 'C4', $ip ) ); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub munge_macaddress { |
|
69
|
2
|
|
|
2
|
1
|
6
|
my $mac = shift; |
|
70
|
2
|
100
|
|
|
|
11
|
$mac or return ""; |
|
71
|
1
|
|
|
|
|
11
|
$mac = join( ':', map { sprintf "%02x", $_ } unpack( 'C*', $mac ) ); |
|
|
15
|
|
|
|
|
41
|
|
|
72
|
1
|
50
|
|
|
|
13
|
return $mac if $mac =~ /^([0-9A-F][0-9A-F]:){5}[0-9A-F][0-9A-F]$/i; |
|
73
|
1
|
|
|
|
|
7
|
return "ERROR"; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub munge_octet2hex { |
|
77
|
0
|
|
|
0
|
1
|
|
my $oct = shift; |
|
78
|
0
|
|
|
|
|
|
return join( '', map { sprintf "%x", $_ } unpack( 'C*', $oct ) ); |
|
|
0
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Local Variables: |
|
84
|
|
|
|
|
|
|
# mode: cperl |
|
85
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
|
86
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
|
87
|
|
|
|
|
|
|
# cperl-indent-parens-as-block: t |
|
88
|
|
|
|
|
|
|
# End: |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=pod |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 NAME |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
SNMP::Insight::MIB - Base role for MIBs |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 VERSION |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
version 0.001 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 munge_bool() |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Takes a BOOLEAN and makes it a nop|true|false string |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 munge_ipaddress() |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Takes a binary IP and makes it dotted ASCII |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 munge_macaddress() |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Takes an octet stream (HEX-STRING) and returns a colon separated ASCII hex |
|
115
|
|
|
|
|
|
|
string. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 munge_octet2hex() |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Takes a binary octet stream and returns an ASCII hex string |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Gabriele Mambrini <g.mambrini@gmail.com> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Gabriele Mambrini. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
130
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |