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

Comparing Convert-BER-XS/XS.pm (file contents):
Revision 1.31 by root, Sat Apr 20 15:49:04 2019 UTC vs.
Revision 1.34 by root, Sat Apr 20 18:38:33 2019 UTC

134 134
135Constants only relevant to SNMP. These are the tag values used by SNMP in 135Constants only relevant to SNMP. These are the tag values used by SNMP in
136the C<ASN_APPLICATION> namespace and have the exact numerical value as in 136the C<ASN_APPLICATION> namespace and have the exact numerical value as in
137BER/RFC 2578. 137BER/RFC 2578.
138 138
139 SNMP_IPADDRESS SNMP_COUNTER32 SNMP_UNSIGNED32 SNMP_TIMETICKS SNMP_OPAQUE SNMP_COUNTER64 139 SNMP_IPADDRESS SNMP_COUNTER32 SNMP_UNSIGNED32 SNMP_GAUGE32
140 SNMP_TIMETICKS SNMP_OPAQUE SNMP_COUNTER64
140 141
141=item C<:decode> 142=item C<:decode>
142 143
143C<ber_decode> and the match helper functions: 144C<ber_decode> and the match helper functions:
144 145
146 ber_decode ber-decode_prefix
145 ber_decode ber_is ber_is_seq ber_is_int ber_is_oid 147 ber_is ber_is_seq ber_is_int ber_is_oid
146 148
147=item C<:encode> 149=item C<:encode>
148 150
149C<ber_encode> and the construction helper functions: 151C<ber_encode> and the construction helper functions:
150 152
151 ber_encode ber_int 153 ber_encode
154 ber_int
152 155
153=back 156=back
154 157
155=head2 ASN.1/BER/DER/... BASICS 158=head2 ASN.1/BER/DER/... BASICS
156 159
252 255
253=head2 DECODING AND ENCODING 256=head2 DECODING AND ENCODING
254 257
255=over 258=over
256 259
257=item $tuple = ber_decoded $bindata[, $profile] 260=item $tuple = ber_decode $bindata[, $profile]
258 261
259Decodes binary BER data in C<$bindata> and returns the resulting BER 262Decodes binary BER data in C<$bindata> and returns the resulting BER
260tuple. Croaks on any decoding error, so the returned C<$tuple> is always 263tuple. Croaks on any decoding error, so the returned C<$tuple> is always
261valid. 264valid.
262 265
274 $tuple = ber_decode $data; 277 $tuple = ber_decode $data;
275 278
276Example: as above, but use the provided SNMP profile. 279Example: as above, but use the provided SNMP profile.
277 280
278 $tuple = ber_encode $data, $Convert::BER::XS::SNMP_PROFILE; 281 $tuple = ber_encode $data, $Convert::BER::XS::SNMP_PROFILE;
282
283=item ($tuple, $bytes) = ber_decode_prefix $bindata[, $profile]
284
285Works like C<ber_decode>, except it doesn't croak when there is data after
286the BER data, but instead returns the decoded value and the number of
287bytes it decoded.
288
289This is useful when you have BER data at the start of a buffer and other
290data after, and you need to find the length.
291
292Also, since BER is self-delimited, this can be used to decode multiple BER
293values joined together.
279 294
280=item $bindata = ber_encode $tuple[, $profile] 295=item $bindata = ber_encode $tuple[, $profile]
281 296
282Encodes the BER tuple into a BER/DER data structure. AS with 297Encodes the BER tuple into a BER/DER data structure. AS with
283Cyber_decode>, an optional profile can be given. 298Cyber_decode>, an optional profile can be given.
417 BER_TYPE_BYTES BER_TYPE_UTF8 BER_TYPE_UCS2 BER_TYPE_UCS4 BER_TYPE_INT 432 BER_TYPE_BYTES BER_TYPE_UTF8 BER_TYPE_UCS2 BER_TYPE_UCS4 BER_TYPE_INT
418 BER_TYPE_OID BER_TYPE_RELOID BER_TYPE_NULL BER_TYPE_BOOL BER_TYPE_REAL 433 BER_TYPE_OID BER_TYPE_RELOID BER_TYPE_NULL BER_TYPE_BOOL BER_TYPE_REAL
419 BER_TYPE_IPADDRESS BER_TYPE_CROAK 434 BER_TYPE_IPADDRESS BER_TYPE_CROAK
420 )], 435 )],
421 const_snmp => [qw( 436 const_snmp => [qw(
422 SNMP_IPADDRESS SNMP_COUNTER32 SNMP_UNSIGNED32 SNMP_TIMETICKS SNMP_OPAQUE SNMP_COUNTER64 437 SNMP_IPADDRESS SNMP_COUNTER32 SNMP_GAUGE32 SNMP_UNSIGNED32
438 SNMP_TIMETICKS SNMP_OPAQUE SNMP_COUNTER64
423 )], 439 )],
424 decode => [qw( 440 decode => [qw(
425 ber_decode 441 ber_decode ber_decode_prefix
426 ber_is ber_is_seq ber_is_int ber_is_oid 442 ber_is ber_is_seq ber_is_int ber_is_oid
427 )], 443 )],
428 encode => [qw( 444 encode => [qw(
429 ber_encode 445 ber_encode
430 ber_int 446 ber_int
634Constructed strings are decoded just fine, but there should be a way to 650Constructed strings are decoded just fine, but there should be a way to
635join them for convenience. 651join them for convenience.
636 652
637REAL values are not supported and will currently croak. 653REAL values are not supported and will currently croak.
638 654
655The encoder and decoder tend to accept more formats than should be
656strictly supported.
657
639This module has undergone little to no testing so far. 658This module has undergone little to no testing so far.
640 659
641=head2 ITHREADS SUPPORT 660=head2 ITHREADS SUPPORT
642 661
643This module is unlikely to work when the (officially discouraged) ithreads 662This module is unlikely to work when the (officially discouraged) ithreads

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines