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.50 by root, Sun Apr 21 23:10:55 2019 UTC vs.
Revision 1.55 by root, Tue Apr 23 21:20:25 2019 UTC

108 BER_CLASS BER_TAG BER_FLAGS BER_DATA 108 BER_CLASS BER_TAG BER_FLAGS BER_DATA
109 109
110=item C<:const_asn> 110=item C<:const_asn>
111 111
112ASN class values (these are C<0>, C<1>, C<2> and C<3>, respectively - 112ASN class values (these are C<0>, C<1>, C<2> and C<3>, respectively -
113exactly thw two topmost bits from the identifier octet shifted 6 bits to 113exactly the two topmost bits from the identifier octet shifted 6 bits to
114the right): 114the right):
115 115
116 ASN_UNIVERSAL ASN_APPLICATION ASN_CONTEXT ASN_PRIVATE 116 ASN_UNIVERSAL ASN_APPLICATION ASN_CONTEXT ASN_PRIVATE
117 117
118ASN tag values (some of which are aliases, such as C<ASN_OID>). Their 118ASN tag values (some of which are aliases, such as C<ASN_OID>). Their
296Also, since BER is self-delimited, this can be used to decode multiple BER 296Also, since BER is self-delimited, this can be used to decode multiple BER
297values joined together. 297values joined together.
298 298
299=item $bindata = ber_encode $tuple[, $profile] 299=item $bindata = ber_encode $tuple[, $profile]
300 300
301Encodes the BER tuple into a BER/DER data structure. AS with 301Encodes the BER tuple into a BER/DER data structure. As with
302Cyber_decode>, an optional profile can be given. 302Cyber_decode>, an optional profile can be given.
303 303
304The encoded data should be both BER and DER ("shortest form") compliant 304The encoded data should be both BER and DER ("shortest form") compliant
305unless the input says otherwise (e.g. it uses constructed strings). 305unless the input says otherwise (e.g. it uses constructed strings).
306 306
412use Exporter qw(import); 412use Exporter qw(import);
413 413
414our $VERSION; 414our $VERSION;
415 415
416BEGIN { 416BEGIN {
417 $VERSION = 1.1; 417 $VERSION = 1.11;
418 XSLoader::load __PACKAGE__, $VERSION; 418 XSLoader::load __PACKAGE__, $VERSION;
419} 419}
420 420
421our %EXPORT_TAGS = ( 421our %EXPORT_TAGS = (
422 const_index => [qw( 422 const_index => [qw(
468 468
469$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_IPADDRESS , BER_TYPE_IPADDRESS); 469$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_IPADDRESS , BER_TYPE_IPADDRESS);
470$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER32 , BER_TYPE_INT); 470$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER32 , BER_TYPE_INT);
471$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_UNSIGNED32, BER_TYPE_INT); 471$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_UNSIGNED32, BER_TYPE_INT);
472$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_TIMETICKS , BER_TYPE_INT); 472$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_TIMETICKS , BER_TYPE_INT);
473$SNMP_PROFILE->set (ASN_APPLICATION, SNMP_OPAQUE , BER_TYPE_IPADDRESS);
474 473
475=head2 DEBUGGING 474=head2 DEBUGGING
476 475
477To aid debugging, you cna call the C<ber_dump> function to print a "nice" 476To aid debugging, you cna call the C<ber_dump> function to print a "nice"
478representation to STDOUT. 477representation to STDOUT.
479 478
480=over 479=over
481 480
482=item ber_dump $tuple[, $profile[, $prefix]] 481=item ber_dump $tuple[, $profile[, $prefix]]
483 482
484In addition to specifying the BER C<$tuple> to dump, youc an also specify 483In addition to specifying the BER C<$tuple> to dump, you can also specify
485a C<$profile> and a C<$prefix> string that is printed in front of each line. 484a C<$profile> and a C<$prefix> string that is printed in front of each line.
486 485
487If C<$profile> is C<$Convert::BER::XS::SNMP_PROFILE>, then C<ber_dump> 486If C<$profile> is C<$Convert::BER::XS::SNMP_PROFILE>, then C<ber_dump>
488will try to improve its output for SNMP data. 487will try to improve its output for SNMP data.
489 488
558 if ($data =~ y/\x20-\x7e//c / (length $data || 1) > 0.2 or $data =~ /\x00./s) { 557 if ($data =~ y/\x20-\x7e//c / (length $data || 1) > 0.2 or $data =~ /\x00./s) {
559 # assume binary 558 # assume binary
560 $data = unpack "H*", $data; 559 $data = unpack "H*", $data;
561 } else { 560 } else {
562 $data =~ s/[^\x20-\x7e]/./g; 561 $data =~ s/[^\x20-\x7e]/./g;
563 $data = "\"$data\"" if $type =~ /string/i || !length $data; 562 $data = "\"$data\"" if $tag =~ /string/i || !length $data;
564 } 563 }
565 564
566 substr $data, 40, 1e9, "..." if 40 < length $data; 565 substr $data, 40, 1e9, "..." if 40 < length $data;
567 566
568 printf "$indent%-16.16s %-6.6s %s\n", $tag, lc $type, $data; 567 printf "$indent%-16.16s %-6.6s %s\n", $tag, lc $type, $data;
733 732
734 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_IPADDRESS , BER_TYPE_IPADDRESS); 733 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_IPADDRESS , BER_TYPE_IPADDRESS);
735 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER32 , BER_TYPE_INT); 734 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER32 , BER_TYPE_INT);
736 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_UNSIGNED32, BER_TYPE_INT); 735 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_UNSIGNED32, BER_TYPE_INT);
737 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_TIMETICKS , BER_TYPE_INT); 736 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_TIMETICKS , BER_TYPE_INT);
738 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_OPAQUE , BER_TYPE_IPADDRESS); 737 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_OPAQUE , BER_TYPE_BYTES);
739 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER64 , BER_TYPE_INT); 738 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER64 , BER_TYPE_INT);
740 739
741=head2 LIMITATIONS/NOTES 740=head2 LIMITATIONS/NOTES
742 741
743This module can only en-/decode 64 bit signed and unsigned integers, and 742This module can only en-/decode 64 bit signed and unsigned integers, and
744only when your perl supports those. So no UUID OIDs for now (unless you 743only when your perl supports those. So no UUID OIDs for now (unless you
745map the C<OBJECT IDENTIFIER> tag to something other than C<BER_TYPE_OID>). 744map the C<OBJECT IDENTIFIER> tag to something other than C<BER_TYPE_OID>).
746 745
747This module does not generally care about ranges, i.e. it will happily 746This module does not generally care about ranges, i.e. it will happily
748de-/encode 64 bit integers into an C<ASN_INTEGER> value, or a negative 747de-/encode 64 bit integers into an C<SNMP_UNSIGNED32> value, or a negative
749number into an C<SNMP_COUNTER64>. 748number into an C<SNMP_COUNTER64>.
750 749
751OBJECT IDENTIFIEERs cannot have unlimited length, although the limit is 750OBJECT IDENTIFIEERs cannot have unlimited length, although the limit is
752much larger than e.g. the one imposed by SNMP or other protocols, and is 751much larger than e.g. the one imposed by SNMP or other protocols, and is
753about 4kB. 752about 4kB.
754 753
755Indefinite length encoding is not supported.
756
757Constructed strings are decoded just fine, but there should be a way to 754Constructed strings are decoded just fine, but there should be a way to
758join them for convenience. 755join them for convenience.
759 756
760REAL values are not supported and will currently croak. 757REAL values are not supported and will currently croak.
761 758
762The encoder and decoder tend to accept more formats than should be
763strictly supported - security sensitive applications are strongly advised
764to review the code first.
765
766This module has undergone little to no testing so far.
767
768=head2 ITHREADS SUPPORT 759=head2 ITHREADS SUPPORT
769 760
770This module is unlikely to work when the (officially discouraged) ithreads 761This module is unlikely to work when the (officially discouraged) ithreads
771are in use. 762are in use.
772 763

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines