Convert-BER-XS
view release on metacpan or search on metacpan
callers that rely on the default profile.
=item C<$Convert::BER::XS::SNMP_PROFILE>
A profile with mappings for SNMP-specific application tags added. This is
useful when de-/encoding SNMP data.
Example:
$ber = ber_decode $data, $Convert::BER::XS::SNMP_PROFILE;
=back
=head2 The Convert::BER::XS::Profile class
=over
=item $profile = new Convert::BER::XS::Profile
Create a new profile. The profile will be identical to the default
profile.
=item $profile->set ($class, $tag, $type)
Sets the mapping for the given C<$class>/C<$tag> combination to C<$type>,
which must be one of the C<BER_TYPE_*> constants.
Note that currently, the mapping is stored in a flat array, so large
values of C<$tag> will consume large amounts of memory.
Example:
$profile = new Convert::BER::XS::Profile;
$profile->set (ASN_APPLICATION, SNMP_COUNTER32, BER_TYPE_INT);
$ber = ber_decode $data, $profile;
=item $type = $profile->get ($class, $tag)
Returns the BER type mapped to the given C<$class>/C<$tag> combination.
=back
=head2 BER Types
This lists the predefined BER types. BER types are formatters used
internally to format and encode BER values. You can assign any C<BER_TYPE>
to any C<CLASS>/C<TAG> combination tgo change how that tag is decoded or
encoded.
=over
=item C<BER_TYPE_BYTES>
The raw octets of the value. This is the default type for unknown tags and
de-/encodes the value as if it were an octet string, i.e. by copying the
raw bytes.
=item C<BER_TYPE_UTF8>
Like C<BER_TYPE_BYTES>, but decodes the value as if it were a UTF-8 string
(without validation!) and encodes a perl unicode string into a UTF-8 BER
string.
=item C<BER_TYPE_UCS2>
Similar to C<BER_TYPE_UTF8>, but treats the BER value as UCS-2 encoded
string.
=item C<BER_TYPE_UCS4>
Similar to C<BER_TYPE_UTF8>, but treats the BER value as UCS-4 encoded
string.
=item C<BER_TYPE_INT>
Encodes and decodes a BER integer value to a perl integer scalar. This
should correctly handle 64 bit signed and unsigned values.
=item C<BER_TYPE_OID>
Encodes and decodes an OBJECT IDENTIFIER into dotted form without leading
dot, e.g. C<1.3.6.1.213>.
=item C<BER_TYPE_RELOID>
Same as C<BER_TYPE_OID> but uses relative object identifier
encoding: ASN.1 has this hack of encoding the first two OID components
into a single integer in a weird attempt to save an insignificant amount
of space in an otherwise wasteful encoding, and relative OIDs are
basically OIDs without this hack. The practical difference is that the
second component of an OID can only have the values 1..40, while relative
OIDs do not have this restriction.
=item C<BER_TYPE_NULL>
Decodes an C<ASN_NULL> value into C<undef>, and always encodes a
C<ASN_NULL> type, regardless of the perl value.
=item C<BER_TYPE_BOOL>
Decodes an C<ASN_BOOLEAN> value into C<0> or C<1>, and encodes a perl
boolean value into an C<ASN_BOOLEAN>.
=item C<BER_TYPE_REAL>
Decodes/encodes a BER real value. NOT IMPLEMENTED.
=item C<BER_TYPE_IPADDRESS>
Decodes/encodes a four byte string into an IPv4 dotted-quad address string
in Perl. Given the obsolete nature of this type, this is a low-effort
implementation that simply uses C<sprintf> and C<sscanf>-style conversion,
so it won't handle all string forms supported by C<inet_aton> for example.
=item C<BER_TYPE_CROAK>
Always croaks when encountered during encoding or decoding - the
default behaviour when encountering an unknown type is to treat it as
C<BER_TYPE_BYTES>. When you don't want that but instead prefer a hard
error for some types, then C<BER_TYPE_CROAK> is for you.
( run in 1.037 second using v1.01-cache-2.11-cpan-2398b32b56e )