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.38 by root, Sun Apr 21 00:39:26 2019 UTC vs.
Revision 1.45 by root, Sun Apr 21 02:45:12 2019 UTC

505 | | SEQUENCE 505 | | SEQUENCE
506 | | | SEQUENCE 506 | | | SEQUENCE
507 | | | | OID oid 1.3.6.1.2.1.1.3.0 507 | | | | OID oid 1.3.6.1.2.1.1.3.0
508 | | | | TIMETICKS int 638085796 508 | | | | TIMETICKS int 638085796
509 509
510=back
511
510=cut 512=cut
511 513
512# reverse enum, very slow and ugly hack 514# reverse enum, very slow and ugly hack
513sub _re { 515sub _re {
514 my ($export_tag, $value) = @_; 516 my ($export_tag, $value) = @_;
551 if ($ber->[BER_FLAGS]) { 553 if ($ber->[BER_FLAGS]) {
552 printf "$indent%-16.16s %-6.6s CONSTRUCTED\n", $tag, lc $type; 554 printf "$indent%-16.16s %-6.6s CONSTRUCTED\n", $tag, lc $type;
553 &_ber_dump ($_, $profile, "$indent| ") 555 &_ber_dump ($_, $profile, "$indent| ")
554 for @$data; 556 for @$data;
555 } else { 557 } else {
556 if ($data =~ y/\x20-\x7e//c > 10 or $data =~ /\x00./s) { 558 if ($data =~ y/\x20-\x7e//c / (length $data || 1) > 0.2 or $data =~ /\x00./s) {
557 # assume binary 559 # assume binary
558 $data = unpack "H*", $data; 560 $data = unpack "H*", $data;
559 substr $data, 40, 1e9, "..." if 40 < length $data;
560 } else { 561 } else {
561 $data =~ s/[^\x20-\x7e]/./g; 562 $data =~ s/[^\x20-\x7e]/./g;
562 $data = "\"$data\"" if $type =~ /string/i; 563 $data = "\"$data\"" if $type =~ /string/i || !length $data;
563 substr $data, 40, 1e9, "..." if 40 < length $data;
564 } 564 }
565
566 substr $data, 40, 1e9, "..." if 40 < length $data;
565 567
566 printf "$indent%-16.16s %-6.6s %s\n", $tag, lc $type, $data; 568 printf "$indent%-16.16s %-6.6s %s\n", $tag, lc $type, $data;
567 } 569 }
568 } 570 }
569} 571}
639 641
640Returns the BER type mapped to the given C<$class>/C<$tag> combination. 642Returns the BER type mapped to the given C<$class>/C<$tag> combination.
641 643
642=back 644=back
643 645
644=head2 BER TYPES 646=head2 BER Types
645 647
646This lists the predefined BER types - you can map any C<CLASS>/C<TAG> 648This lists the predefined BER types. BER types are formatters used
647combination to any C<BER_TYPE_*>. 649internally to format and encode BER values. You can assign any C<BER_TYPE>
650to any C<CLASS>/C<TAG> combination tgo change how that tag is decoded or
651encoded.
648 652
649=over 653=over
650 654
651=item C<BER_TYPE_BYTES> 655=item C<BER_TYPE_BYTES>
652 656
735 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER64 , BER_TYPE_INT); 739 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER64 , BER_TYPE_INT);
736 740
737=head2 LIMITATIONS/NOTES 741=head2 LIMITATIONS/NOTES
738 742
739This module can only en-/decode 64 bit signed and unsigned integers, and 743This module can only en-/decode 64 bit signed and unsigned integers, and
740only when your perl supports those. 744only when your perl supports those. So no UUID OIDs for now.
741 745
742This 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
743de-/encode 64 bit integers into an C<ASN_INTEGER> value, or a negative 747de-/encode 64 bit integers into an C<ASN_INTEGER> value, or a negative
744number into an C<SNMP_COUNTER64>. 748number into an C<SNMP_COUNTER64>.
745 749
746OBJECT IDENTIFIEERs cannot have unlimited length, although the limit is 750OBJECT IDENTIFIEERs cannot have unlimited length, although the limit is
747much larger than e.g. the one imposed by SNMP or other protocols,a nd is 751much larger than e.g. the one imposed by SNMP or other protocols, and is
748about 4kB. 752about 4kB.
749 753
750Indefinite length encoding is not supported. 754Indefinite length encoding is not supported.
751 755
752Constructed strings are decoded just fine, but there should be a way to 756Constructed strings are decoded just fine, but there should be a way to
753join them for convenience. 757join them for convenience.
754 758
755REAL values are not supported and will currently croak. 759REAL values are not supported and will currently croak.
756 760
757The encoder and decoder tend to accept more formats than should be 761The encoder and decoder tend to accept more formats than should be
758strictly supported. 762strictly supported - security sensitive applications are strongly advised
763to review the code first.
759 764
760This module has undergone little to no testing so far. 765This module has undergone little to no testing so far.
761 766
762=head2 ITHREADS SUPPORT 767=head2 ITHREADS SUPPORT
763 768

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines