ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-SNMP-XS/XS.pm
(Generate patch)

Comparing Net-SNMP-XS/XS.pm (file contents):
Revision 1.7 by root, Sat Apr 11 04:22:49 2009 UTC vs.
Revision 1.8 by root, Sat Apr 11 06:24:18 2009 UTC

27 27
28=item only leading dots for oids are supported 28=item only leading dots for oids are supported
29 29
30=item error messages will be simpler/different 30=item error messages will be simpler/different
31 31
32=item oid components are limited to unsigned 32 bit integers
33
34=item translation will be ignored (all values will be delivered "raw") 32=item translation will be ignored (all values will be delivered "raw")
35 33
36=item a moderately modern (>= C99) C compiler is required 34=item a moderately modern (>= C99) C compiler is required
37 35
38=item only tested with 5.10, no intentions to port to older perls 36=item only tested with 5.10, no intentions to port to older perls
50use strict qw(vars subs); 48use strict qw(vars subs);
51no warnings; 49no warnings;
52 50
53use Guard; 51use Guard;
54 52
53use Net::SNMP ();
55use Net::SNMP::PDU (); 54use Net::SNMP::PDU ();
56use Net::SNMP::Message (); 55use Net::SNMP::Message ();
57use Net::SNMP::MessageProcessing (); 56use Net::SNMP::MessageProcessing ();
58 57
59our $VERSION; 58our $VERSION;
75 set_msg $msg, $msg->{_buffer}; 74 set_msg $msg, $msg->{_buffer};
76 scope_guard \&clr_msg; 75 scope_guard \&clr_msg;
77 &$old_prepare 76 &$old_prepare
78} 77}
79 78
79package Net::SNMP::Message;
80
81Net::SNMP::XS::set_type INTEGER , \&_process_integer32;
82Net::SNMP::XS::set_type OCTET_STRING , \&_process_octet_string;
83Net::SNMP::XS::set_type NULL , \&_process_null;
84Net::SNMP::XS::set_type OBJECT_IDENTIFIER, \&_process_object_identifier;
85Net::SNMP::XS::set_type SEQUENCE , \&_process_sequence;
86Net::SNMP::XS::set_type IPADDRESS , \&_process_ipaddress;
87Net::SNMP::XS::set_type COUNTER , \&_process_counter;
88Net::SNMP::XS::set_type GAUGE , \&_process_gauge;
89Net::SNMP::XS::set_type TIMETICKS , \&_process_timeticks;
90Net::SNMP::XS::set_type OPAQUE , \&_process_opaque;
91Net::SNMP::XS::set_type COUNTER64 , \&_process_counter64;
92Net::SNMP::XS::set_type NOSUCHOBJECT , \&_process_nosuchobject;
93Net::SNMP::XS::set_type NOSUCHINSTANCE , \&_process_nosuchinstance;
94Net::SNMP::XS::set_type ENDOFMIBVIEW , \&_process_endofmibview;
95Net::SNMP::XS::set_type GET_REQUEST , \&_process_get_request;
96Net::SNMP::XS::set_type GET_NEXT_REQUEST , \&_process_get_next_request;
97Net::SNMP::XS::set_type GET_RESPONSE , \&_process_get_response;
98Net::SNMP::XS::set_type SET_REQUEST , \&_process_set_request;
99Net::SNMP::XS::set_type TRAP , \&_process_trap;
100Net::SNMP::XS::set_type GET_BULK_REQUEST , \&_process_get_bulk_request;
101Net::SNMP::XS::set_type INFORM_REQUEST , \&_process_inform_request;
102Net::SNMP::XS::set_type SNMPV2_TRAP , \&_process_v2_trap;
103Net::SNMP::XS::set_type REPORT , \&_process_report;
104
105package Net::SNMP::PDU;
106
107# var_bind_list hardcodes oid_lext_sort. *sigh*
108# we copy it 1:1, except for using oid_lex_sort.
109
110sub var_bind_list
80{ 111{
81 package Net::SNMP::Message; 112 my ($this, $vbl, $types) = @_;
82 113
83 Net::SNMP::XS::set_type INTEGER , \&_process_integer32; 114 return if defined($this->{_error});
84 Net::SNMP::XS::set_type OCTET_STRING , \&_process_octet_string; 115
85 Net::SNMP::XS::set_type NULL , \&_process_null; 116 if (@_ > 1) {
86 Net::SNMP::XS::set_type OBJECT_IDENTIFIER, \&_process_object_identifier; 117 # The VarBindList HASH is being updated from an external
87 Net::SNMP::XS::set_type SEQUENCE , \&_process_sequence; 118 # source. We need to update the VarBind names ARRAY to
88 Net::SNMP::XS::set_type IPADDRESS , \&_process_ipaddress; 119 # correspond to the new keys of the HASH. If the updated
89 Net::SNMP::XS::set_type COUNTER , \&_process_counter; 120 # information is valid, we will use lexicographical ordering
90 Net::SNMP::XS::set_type GAUGE , \&_process_gauge; 121 # for the ARRAY entries since we do not have a PDU to use
91 Net::SNMP::XS::set_type TIMETICKS , \&_process_timeticks; 122 # to determine the ordering. The ASN.1 types HASH is also
92 Net::SNMP::XS::set_type OPAQUE , \&_process_opaque; 123 # updated here if a cooresponding HASH is passed. We double
93 Net::SNMP::XS::set_type COUNTER64 , \&_process_counter64; 124 # check the mapping by populating the hash with the keys of
94 Net::SNMP::XS::set_type NOSUCHOBJECT , \&_process_nosuchobject; 125 # the VarBindList HASH.
95 Net::SNMP::XS::set_type NOSUCHINSTANCE , \&_process_nosuchinstance; 126
96 Net::SNMP::XS::set_type ENDOFMIBVIEW , \&_process_endofmibview; 127 if (!defined($vbl) || (ref($vbl) ne 'HASH')) {
97 Net::SNMP::XS::set_type GET_REQUEST , \&_process_get_request; 128
98 Net::SNMP::XS::set_type GET_NEXT_REQUEST , \&_process_get_next_request; 129 $this->{_var_bind_list} = undef;
99 Net::SNMP::XS::set_type GET_RESPONSE , \&_process_get_response; 130 $this->{_var_bind_names} = [];
100 Net::SNMP::XS::set_type SET_REQUEST , \&_process_set_request; 131 $this->{_var_bind_types} = undef;
101 Net::SNMP::XS::set_type TRAP , \&_process_trap; 132
102 Net::SNMP::XS::set_type GET_BULK_REQUEST , \&_process_get_bulk_request; 133 } else {
103 Net::SNMP::XS::set_type INFORM_REQUEST , \&_process_inform_request; 134
104 Net::SNMP::XS::set_type SNMPV2_TRAP , \&_process_v2_trap; 135 $this->{_var_bind_list} = $vbl;
105 Net::SNMP::XS::set_type REPORT , \&_process_report; 136
137 @{$this->{_var_bind_names}} = Net::SNMP::oid_lex_sort keys %$vbl;
138
139 if (!defined($types) || (ref($types) ne 'HASH')) {
140 $types = {};
141 }
142
143 map {
144 $this->{_var_bind_types}->{$_} =
145 exists($types->{$_}) ? $types->{$_} : undef;
146 } keys(%{$vbl});
147
148 }
149
150 }
151
152 $this->{_var_bind_list};
106} 153}
107 154
1081; 1551;
109 156
110=head1 AUTHOR 157=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines