Convert-ASN1-asn1c
view release on metacpan or search on metacpan
lib/Convert/ASN1/asn1c.pm view on Meta::CPAN
return $text;
}
=head2 $values = decode('pduname', $pdu);
The decode function takes the name of a template (the directory where to find
those templates can be modified with set_templatedir($dir)) and a binary pdu.
It will match the variables in the template against the decoded binary pdu and
return a reference to a hash which contains these values.
For each variable $myvalue the hash will contain four keys:
=head3 $values->{'myvalue'}
The decoded value if we could "guess" myvalues type because it was
specified as i.e. INTEGER or BIT STRING in the asn1 pdu.
=head3 $values->{'myvalue_orig'}
The original value as it was found in the unber -p output. Note that these
values are still xml-encoded. To decode them you can use this modules
decode_-functions or write your own decoders if the provided ones are not
sufficient.
=head3 $values->{'myvalue_length'}
lib/Convert/ASN1/asn1c.pm view on Meta::CPAN
my @stack;
my @varpos;
# try to find the packet description
my @lines = read_file(File::Spec->catfile($self->{'_templatedir'}, $pduname));
# we will parse the packet description
# to find out which "nodes" in the tag tree are interesting for us
# and we will construct a list of those interesting nodes (and how to "reach" them,
# i.e. which parent nodes they are located under. In the second step we will
# iterate over the decoded ASN data, if we are in an inetersting leaf we will decode it's value.
foreach (@lines) {
if (m/<C .*?T=\"(.*?)\"/) { push @stack, $1; }
if (m/<\/C /) { pop @stack; }
if (m/<P .*?T=\"(.*?)\"/) { push @stack, $1; }
while (m/(\$.+?)("|<| |>)/gc) {
my $varname = $1;
if ($varname !~ m/_length$/) {
push(@varpos, $varname . ":" . join('|', @stack));
}
lib/Convert/ASN1/asn1c.pm view on Meta::CPAN
my @stack;
my @varpos;
# try to find the packet description
my @lines = split(/\n/, $xml_template);
# we will parse the packet description
# to find out which "nodes" in the tag tree are interesting for us
# and we will construct a list of those interesting nodes (and how to "reach" them,
# i.e. which parent nodes they are located under. In the second step we will
# iterate over the decoded ASN data, if we are in an inetersting leaf we will decode it's value.
foreach (@lines) {
if (m/<C .*?T=\"(.*?)\"/) { push @stack, $1; }
if (m/<\/C /) { pop @stack; }
if (m/<P .*?T=\"(.*?)\"/) { push @stack, $1; }
while (m/(\$.+?)("|<| |>)/gc) {
my $varname = $1;
if ($varname !~ m/_length$/) {
push(@varpos, $varname . ":" . join('|', @stack));
}
( run in 0.305 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )