… | |
… | |
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 || 1) > 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; |