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.36 by root, Sun Apr 21 00:36:11 2019 UTC vs.
Revision 1.39 by root, Sun Apr 21 00:41:31 2019 UTC

477To aid debugging, you cna call the C<ber_dump> function to print a "nice" 477To aid debugging, you cna call the C<ber_dump> function to print a "nice"
478representation to STDOUT. 478representation to STDOUT.
479 479
480=over 480=over
481 481
482=item Convert::BER::XS::ber_dump $tuple[, $profile[, $prefix]] 482=item ber_dump $tuple[, $profile[, $prefix]]
483 483
484In addition to specifying the BER C<$tuple> to dump, youc an also specify 484In addition to specifying the BER C<$tuple> to dump, youc an also specify
485a C<$profile> and a C<$prefix> string that is printed in front of each line. 485a C<$profile> and a C<$prefix> string that is printed in front of each line.
486 486
487If C<$profile> is C<$Convert::BER::XS::SNMP_PROFILE>, then C<ber_dump> 487If C<$profile> is C<$Convert::BER::XS::SNMP_PROFILE>, then C<ber_dump>
538 my $type = _re const_ber_type => $profile->get ($ber->[BER_CLASS], $ber->[BER_TAG]); 538 my $type = _re const_ber_type => $profile->get ($ber->[BER_CLASS], $ber->[BER_TAG]);
539 my $data = $ber->[BER_DATA]; 539 my $data = $ber->[BER_DATA];
540 540
541 if ($profile == $SNMP_PROFILE and $ber->[BER_CLASS] == ASN_APPLICATION) { 541 if ($profile == $SNMP_PROFILE and $ber->[BER_CLASS] == ASN_APPLICATION) {
542 $tag = _re const_snmp => $ber->[BER_TAG]; 542 $tag = _re const_snmp => $ber->[BER_TAG];
543 $asn = 1; 543 } elsif (!$asn) {
544 $tag = "$class ($tag)";
544 } 545 }
545
546 $asn or $tag = "$class ($tag)";
547 546
548 $class =~ s/^ASN_//; 547 $class =~ s/^ASN_//;
549 $tag =~ s/^(ASN_|SNMP_)//; 548 $tag =~ s/^(ASN_|SNMP_)//;
550 $type =~ s/^BER_TYPE_//; 549 $type =~ s/^BER_TYPE_//;
551 550
552 if ($ber->[BER_FLAGS]) { 551 if ($ber->[BER_FLAGS]) {
553 printf "$indent%-16.16s %-6.6s CONSTRUCTED\n", $tag, lc $type; 552 printf "$indent%-16.16s %-6.6s CONSTRUCTED\n", $tag, lc $type;
554 &_ber_dump ($_, $profile, "$indent| ") 553 &_ber_dump ($_, $profile, "$indent| ")
555 for @$data; 554 for @$data;
556 } else { 555 } else {
557 if ($data =~ y/\x20-\x7e//c > 10 or $data =~ /\x00./s) { 556 if ($data =~ y/\x20-\x7e//c / length $data > 0.2 or $data =~ /\x00./s) {
558 # assume binary 557 # assume binary
559 $data = unpack "H*", $data; 558 $data = unpack "H*", $data;
560 substr $data, 40, 1e9, "..." if 40 < length $data; 559 substr $data, 40, 1e9, "..." if 40 < length $data;
561 } else { 560 } else {
562 $data =~ s/[^\x20-\x7e]/./g; 561 $data =~ s/[^\x20-\x7e]/./g;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines