1 |
root |
1.1 |
=head1 NAME |
2 |
|
|
|
3 |
|
|
Net::SNMP::XS - speed up Net::SNMP by decoding in XS, with limitations |
4 |
|
|
|
5 |
|
|
=head1 SYNOPSIS |
6 |
|
|
|
7 |
|
|
use Net::SNMP::XS; |
8 |
|
|
|
9 |
|
|
# loading it is enough, there are no public symbols |
10 |
|
|
|
11 |
|
|
=head1 DESCRIPTION |
12 |
|
|
|
13 |
|
|
This module tries to speed up Net::SNMP response packet decoding. |
14 |
|
|
|
15 |
|
|
It does this by overriding a few selected internal method by (almost) |
16 |
|
|
equivalent XS methods. |
17 |
|
|
|
18 |
root |
1.5 |
This currently reduces decode time by a factor of ten for typical bulk |
19 |
root |
1.3 |
responses. |
20 |
root |
1.1 |
|
21 |
|
|
There are currently the following limitations when using this module: |
22 |
|
|
|
23 |
|
|
=over 4 |
24 |
|
|
|
25 |
root |
1.6 |
=item overriding internal functions might cause the module to |
26 |
|
|
malfunction with future versions of Net::SNMP |
27 |
|
|
|
28 |
root |
1.4 |
=item only leading dots for oids are supported |
29 |
root |
1.1 |
|
30 |
root |
1.3 |
=item error messages will be simpler/different |
31 |
|
|
|
32 |
root |
1.1 |
=item oid components are limited to unsigned 32 bit integers |
33 |
|
|
|
34 |
|
|
=item translation will be ignored (all values will be delivered "raw") |
35 |
|
|
|
36 |
root |
1.2 |
=item a 64 bit perl is required |
37 |
|
|
|
38 |
|
|
=item a moderately modern (>= C99) C compiler is required |
39 |
|
|
|
40 |
|
|
=item only tested with 5.10 |
41 |
|
|
|
42 |
root |
1.5 |
=item duplicate OIDs are not supported |
43 |
|
|
|
44 |
|
|
=item REPORT PDUs are not supported |
45 |
|
|
|
46 |
root |
1.1 |
=back |
47 |
|
|
|
48 |
|
|
=cut |
49 |
|
|
|
50 |
|
|
package Net::SNMP::XS; |
51 |
|
|
|
52 |
|
|
use strict qw(vars subs); |
53 |
|
|
no warnings; |
54 |
|
|
|
55 |
|
|
use Guard; |
56 |
|
|
|
57 |
|
|
use Net::SNMP::PDU (); |
58 |
|
|
use Net::SNMP::Message (); |
59 |
|
|
use Net::SNMP::MessageProcessing (); |
60 |
|
|
|
61 |
|
|
our $VERSION; |
62 |
|
|
our $old_prepare; |
63 |
|
|
|
64 |
|
|
BEGIN { |
65 |
|
|
$VERSION = '0.01'; |
66 |
|
|
|
67 |
|
|
$old_prepare = \&Net::SNMP::MessageProcessing::prepare_data_elements; |
68 |
|
|
|
69 |
|
|
# this overrides many methods inside |
70 |
|
|
require XSLoader; |
71 |
|
|
XSLoader::load Net::SNMP::XS, $VERSION; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
sub Net::SNMP::MessageProcessing::prepare_data_elements { |
75 |
|
|
my ($self, $msg) = @_; |
76 |
|
|
|
77 |
|
|
set_msg $msg, $msg->{_buffer}; |
78 |
|
|
scope_guard \&clr_msg; |
79 |
|
|
&$old_prepare |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
{ |
83 |
|
|
package Net::SNMP::Message; |
84 |
|
|
|
85 |
root |
1.3 |
Net::SNMP::XS::set_type INTEGER , \&_process_integer32; |
86 |
|
|
Net::SNMP::XS::set_type OCTET_STRING , \&_process_octet_string; |
87 |
|
|
Net::SNMP::XS::set_type NULL , \&_process_null; |
88 |
|
|
Net::SNMP::XS::set_type OBJECT_IDENTIFIER, \&_process_object_identifier; |
89 |
|
|
Net::SNMP::XS::set_type SEQUENCE , \&_process_sequence; |
90 |
|
|
Net::SNMP::XS::set_type IPADDRESS , \&_process_ipaddress; |
91 |
|
|
Net::SNMP::XS::set_type COUNTER , \&_process_counter; |
92 |
|
|
Net::SNMP::XS::set_type GAUGE , \&_process_gauge; |
93 |
|
|
Net::SNMP::XS::set_type TIMETICKS , \&_process_timeticks; |
94 |
|
|
Net::SNMP::XS::set_type OPAQUE , \&_process_opaque; |
95 |
|
|
Net::SNMP::XS::set_type COUNTER64 , \&_process_counter64; |
96 |
|
|
Net::SNMP::XS::set_type NOSUCHOBJECT , \&_process_nosuchobject; |
97 |
|
|
Net::SNMP::XS::set_type NOSUCHINSTANCE , \&_process_nosuchinstance; |
98 |
|
|
Net::SNMP::XS::set_type ENDOFMIBVIEW , \&_process_endofmibview; |
99 |
|
|
Net::SNMP::XS::set_type GET_REQUEST , \&_process_get_request; |
100 |
|
|
Net::SNMP::XS::set_type GET_NEXT_REQUEST , \&_process_get_next_request; |
101 |
|
|
Net::SNMP::XS::set_type GET_RESPONSE , \&_process_get_response; |
102 |
|
|
Net::SNMP::XS::set_type SET_REQUEST , \&_process_set_request; |
103 |
|
|
Net::SNMP::XS::set_type TRAP , \&_process_trap; |
104 |
|
|
Net::SNMP::XS::set_type GET_BULK_REQUEST , \&_process_get_bulk_request; |
105 |
|
|
Net::SNMP::XS::set_type INFORM_REQUEST , \&_process_inform_request; |
106 |
|
|
Net::SNMP::XS::set_type SNMPV2_TRAP , \&_process_v2_trap; |
107 |
|
|
Net::SNMP::XS::set_type REPORT , \&_process_report; |
108 |
root |
1.1 |
} |
109 |
|
|
|
110 |
|
|
1; |
111 |
|
|
|
112 |
|
|
=head1 AUTHOR |
113 |
|
|
|
114 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
115 |
|
|
http://home.schmorp.de/ |
116 |
|
|
|
117 |
|
|
=cut |
118 |
|
|
|