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.37 by root, Sun Apr 21 00:36:19 2019 UTC vs.
Revision 1.43 by root, Sun Apr 21 01:58:14 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) = @_;
538 my $type = _re const_ber_type => $profile->get ($ber->[BER_CLASS], $ber->[BER_TAG]); 540 my $type = _re const_ber_type => $profile->get ($ber->[BER_CLASS], $ber->[BER_TAG]);
539 my $data = $ber->[BER_DATA]; 541 my $data = $ber->[BER_DATA];
540 542
541 if ($profile == $SNMP_PROFILE and $ber->[BER_CLASS] == ASN_APPLICATION) { 543 if ($profile == $SNMP_PROFILE and $ber->[BER_CLASS] == ASN_APPLICATION) {
542 $tag = _re const_snmp => $ber->[BER_TAG]; 544 $tag = _re const_snmp => $ber->[BER_TAG];
543 $asn = 1; 545 } elsif (!$asn) {
546 $tag = "$class ($tag)";
544 } 547 }
545
546 $asn or $tag = "$class ($tag)";
547 548
548 $class =~ s/^ASN_//; 549 $class =~ s/^ASN_//;
549 $tag =~ s/^(ASN_|SNMP_)//; 550 $tag =~ s/^(ASN_|SNMP_)//;
550 $type =~ s/^BER_TYPE_//; 551 $type =~ s/^BER_TYPE_//;
551 552
552 if ($ber->[BER_FLAGS]) { 553 if ($ber->[BER_FLAGS]) {
553 printf "$indent%-16.16s %-6.6s CONSTRUCTED\n", $tag, lc $type; 554 printf "$indent%-16.16s %-6.6s CONSTRUCTED\n", $tag, lc $type;
554 &_ber_dump ($_, $profile, "$indent| ") 555 &_ber_dump ($_, $profile, "$indent| ")
555 for @$data; 556 for @$data;
556 } else { 557 } else {
557 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) {
558 # assume binary 559 # assume binary
559 $data = unpack "H*", $data; 560 $data = unpack "H*", $data;
560 substr $data, 40, 1e9, "..." if 40 < length $data;
561 } else { 561 } else {
562 $data =~ s/[^\x20-\x7e]/./g; 562 $data =~ s/[^\x20-\x7e]/./g;
563 $data = "\"$data\"" if $type =~ /string/i; 563 $data = "\"$data\"" if $type =~ /string/i || !length $data;
564 substr $data, 40, 1e9, "..." if 40 < length $data;
565 } 564 }
565
566 substr $data, 40, 1e9, "..." if 40 < length $data;
566 567
567 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;
568 } 569 }
569 } 570 }
570} 571}
736 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER64 , BER_TYPE_INT); 737 $SNMP_PROFILE->set (ASN_APPLICATION, SNMP_COUNTER64 , BER_TYPE_INT);
737 738
738=head2 LIMITATIONS/NOTES 739=head2 LIMITATIONS/NOTES
739 740
740This module can only en-/decode 64 bit signed and unsigned integers, and 741This module can only en-/decode 64 bit signed and unsigned integers, and
741only when your perl supports those. 742only when your perl supports those. So no UUID OIDs for now.
742 743
743This module does not generally care about ranges, i.e. it will happily 744This module does not generally care about ranges, i.e. it will happily
744de-/encode 64 bit integers into an C<ASN_INTEGER> value, or a negative 745de-/encode 64 bit integers into an C<ASN_INTEGER> value, or a negative
745number into an C<SNMP_COUNTER64>. 746number into an C<SNMP_COUNTER64>.
746 747

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines