| 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.4 |
=item only leading dots for oids are supported |
| 26 |
root |
1.1 |
|
| 27 |
|
|
=item error handling is currently broken (but parse errors will be detected) |
| 28 |
|
|
|
| 29 |
root |
1.3 |
=item error messages will be simpler/different |
| 30 |
|
|
|
| 31 |
root |
1.1 |
=item oid components are limited to unsigned 32 bit integers |
| 32 |
|
|
|
| 33 |
|
|
=item translation will be ignored (all values will be delivered "raw") |
| 34 |
|
|
|
| 35 |
root |
1.2 |
=item a 64 bit perl is required |
| 36 |
|
|
|
| 37 |
|
|
=item a moderately modern (>= C99) C compiler is required |
| 38 |
|
|
|
| 39 |
|
|
=item only tested with 5.10 |
| 40 |
|
|
|
| 41 |
root |
1.5 |
=item duplicate OIDs are not supported |
| 42 |
|
|
|
| 43 |
|
|
=item REPORT PDUs are not supported |
| 44 |
|
|
|
| 45 |
root |
1.1 |
=back |
| 46 |
|
|
|
| 47 |
|
|
=cut |
| 48 |
|
|
|
| 49 |
|
|
package Net::SNMP::XS; |
| 50 |
|
|
|
| 51 |
|
|
use strict qw(vars subs); |
| 52 |
|
|
no warnings; |
| 53 |
|
|
|
| 54 |
|
|
use Guard; |
| 55 |
|
|
|
| 56 |
|
|
use Net::SNMP::PDU (); |
| 57 |
|
|
use Net::SNMP::Message (); |
| 58 |
|
|
use Net::SNMP::MessageProcessing (); |
| 59 |
|
|
|
| 60 |
|
|
our $VERSION; |
| 61 |
|
|
our $old_prepare; |
| 62 |
|
|
|
| 63 |
|
|
BEGIN { |
| 64 |
|
|
$VERSION = '0.01'; |
| 65 |
|
|
|
| 66 |
|
|
$old_prepare = \&Net::SNMP::MessageProcessing::prepare_data_elements; |
| 67 |
|
|
|
| 68 |
|
|
# this overrides many methods inside |
| 69 |
|
|
require XSLoader; |
| 70 |
|
|
XSLoader::load Net::SNMP::XS, $VERSION; |
| 71 |
|
|
} |
| 72 |
|
|
|
| 73 |
|
|
sub Net::SNMP::MessageProcessing::prepare_data_elements { |
| 74 |
|
|
my ($self, $msg) = @_; |
| 75 |
|
|
|
| 76 |
|
|
set_msg $msg, $msg->{_buffer}; |
| 77 |
|
|
scope_guard \&clr_msg; |
| 78 |
|
|
&$old_prepare |
| 79 |
|
|
} |
| 80 |
|
|
|
| 81 |
|
|
{ |
| 82 |
|
|
package Net::SNMP::Message; |
| 83 |
|
|
|
| 84 |
root |
1.3 |
Net::SNMP::XS::set_type INTEGER , \&_process_integer32; |
| 85 |
|
|
Net::SNMP::XS::set_type OCTET_STRING , \&_process_octet_string; |
| 86 |
|
|
Net::SNMP::XS::set_type NULL , \&_process_null; |
| 87 |
|
|
Net::SNMP::XS::set_type OBJECT_IDENTIFIER, \&_process_object_identifier; |
| 88 |
|
|
Net::SNMP::XS::set_type SEQUENCE , \&_process_sequence; |
| 89 |
|
|
Net::SNMP::XS::set_type IPADDRESS , \&_process_ipaddress; |
| 90 |
|
|
Net::SNMP::XS::set_type COUNTER , \&_process_counter; |
| 91 |
|
|
Net::SNMP::XS::set_type GAUGE , \&_process_gauge; |
| 92 |
|
|
Net::SNMP::XS::set_type TIMETICKS , \&_process_timeticks; |
| 93 |
|
|
Net::SNMP::XS::set_type OPAQUE , \&_process_opaque; |
| 94 |
|
|
Net::SNMP::XS::set_type COUNTER64 , \&_process_counter64; |
| 95 |
|
|
Net::SNMP::XS::set_type NOSUCHOBJECT , \&_process_nosuchobject; |
| 96 |
|
|
Net::SNMP::XS::set_type NOSUCHINSTANCE , \&_process_nosuchinstance; |
| 97 |
|
|
Net::SNMP::XS::set_type ENDOFMIBVIEW , \&_process_endofmibview; |
| 98 |
|
|
Net::SNMP::XS::set_type GET_REQUEST , \&_process_get_request; |
| 99 |
|
|
Net::SNMP::XS::set_type GET_NEXT_REQUEST , \&_process_get_next_request; |
| 100 |
|
|
Net::SNMP::XS::set_type GET_RESPONSE , \&_process_get_response; |
| 101 |
|
|
Net::SNMP::XS::set_type SET_REQUEST , \&_process_set_request; |
| 102 |
|
|
Net::SNMP::XS::set_type TRAP , \&_process_trap; |
| 103 |
|
|
Net::SNMP::XS::set_type GET_BULK_REQUEST , \&_process_get_bulk_request; |
| 104 |
|
|
Net::SNMP::XS::set_type INFORM_REQUEST , \&_process_inform_request; |
| 105 |
|
|
Net::SNMP::XS::set_type SNMPV2_TRAP , \&_process_v2_trap; |
| 106 |
|
|
Net::SNMP::XS::set_type REPORT , \&_process_report; |
| 107 |
root |
1.1 |
} |
| 108 |
|
|
|
| 109 |
|
|
1; |
| 110 |
|
|
|
| 111 |
|
|
=head1 AUTHOR |
| 112 |
|
|
|
| 113 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
| 114 |
|
|
http://home.schmorp.de/ |
| 115 |
|
|
|
| 116 |
|
|
=cut |
| 117 |
|
|
|