ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-SNMP-XS/XS.pm
Revision: 1.4
Committed: Thu Apr 9 04:37:05 2009 UTC (15 years, 1 month ago) by root
Branch: MAIN
Changes since 1.3: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
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.3 This currently reduces decode time by a factor of four for typical bulk
19     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.1 =back
42    
43     =cut
44    
45     package Net::SNMP::XS;
46    
47     use strict qw(vars subs);
48     no warnings;
49    
50     use Guard;
51    
52     use Net::SNMP::PDU ();
53     use Net::SNMP::Message ();
54     use Net::SNMP::MessageProcessing ();
55    
56     our $VERSION;
57     our $old_prepare;
58    
59     BEGIN {
60     $VERSION = '0.01';
61    
62     $old_prepare = \&Net::SNMP::MessageProcessing::prepare_data_elements;
63    
64     # this overrides many methods inside
65     require XSLoader;
66     XSLoader::load Net::SNMP::XS, $VERSION;
67     }
68    
69     sub Net::SNMP::MessageProcessing::prepare_data_elements {
70     my ($self, $msg) = @_;
71    
72     set_msg $msg, $msg->{_buffer};
73     scope_guard \&clr_msg;
74     &$old_prepare
75     }
76    
77     {
78     package Net::SNMP::Message;
79    
80 root 1.3 Net::SNMP::XS::set_type INTEGER , \&_process_integer32;
81     Net::SNMP::XS::set_type OCTET_STRING , \&_process_octet_string;
82     Net::SNMP::XS::set_type NULL , \&_process_null;
83     Net::SNMP::XS::set_type OBJECT_IDENTIFIER, \&_process_object_identifier;
84     Net::SNMP::XS::set_type SEQUENCE , \&_process_sequence;
85     Net::SNMP::XS::set_type IPADDRESS , \&_process_ipaddress;
86     Net::SNMP::XS::set_type COUNTER , \&_process_counter;
87     Net::SNMP::XS::set_type GAUGE , \&_process_gauge;
88     Net::SNMP::XS::set_type TIMETICKS , \&_process_timeticks;
89     Net::SNMP::XS::set_type OPAQUE , \&_process_opaque;
90     Net::SNMP::XS::set_type COUNTER64 , \&_process_counter64;
91     Net::SNMP::XS::set_type NOSUCHOBJECT , \&_process_nosuchobject;
92     Net::SNMP::XS::set_type NOSUCHINSTANCE , \&_process_nosuchinstance;
93     Net::SNMP::XS::set_type ENDOFMIBVIEW , \&_process_endofmibview;
94     Net::SNMP::XS::set_type GET_REQUEST , \&_process_get_request;
95     Net::SNMP::XS::set_type GET_NEXT_REQUEST , \&_process_get_next_request;
96     Net::SNMP::XS::set_type GET_RESPONSE , \&_process_get_response;
97     Net::SNMP::XS::set_type SET_REQUEST , \&_process_set_request;
98     Net::SNMP::XS::set_type TRAP , \&_process_trap;
99     Net::SNMP::XS::set_type GET_BULK_REQUEST , \&_process_get_bulk_request;
100     Net::SNMP::XS::set_type INFORM_REQUEST , \&_process_inform_request;
101     Net::SNMP::XS::set_type SNMPV2_TRAP , \&_process_v2_trap;
102     Net::SNMP::XS::set_type REPORT , \&_process_report;
103 root 1.1 }
104    
105     1;
106    
107     =head1 AUTHOR
108    
109     Marc Lehmann <schmorp@schmorp.de>
110     http://home.schmorp.de/
111    
112     =cut
113