--- Convert-BER-XS/XS.pm 2019/04/20 14:53:29 1.23 +++ Convert-BER-XS/XS.pm 2019/04/20 14:59:26 1.24 @@ -191,7 +191,7 @@ [ASN_UNIVERSAL, ASN_INTEGER32, 0, 177] # the integer 177 [ASN_UNIVERSAL, ASN_OCTET_STRING, 0, "john"] # the string "john" [ASN_UNIVERSAL, ASN_OID, 0, "1.3.6.133"] # some OID - [ASN_UNIVERSAL, ASN_SEQUENCE, 1, [ [ASN_UNIVERSAL... # a sequencE + [ASN_UNIVERSAL, ASN_SEQUENCE, 1, [ [ASN_UNIVERSAL... # a sequence To avoid non-descriptive hardcoded array index numbers, this module defines symbolic constants to access these members: C, @@ -220,23 +220,22 @@ for C) and a private namespace (C). The meaning of the I depends on the namespace, and defines a -(partial) interpretation of the data value. For example, right now, SNMP -application namespace knowledge ix hardcoded into this module, so it -knows that SNMP C values need to be decoded into actual perl -integers. +(partial) interpretation of the data value. For example, SNMP defines +extra tags in the C namespace, and to take full advantage +of these, you need to tell this module how to handle those via profiles. The most common tags in the C namespace are C, C, C, C, C, C, C and C. -The most common tags in SNMP's C namespace -are C, C, C, -C, C and C. +The most common tags in SNMP's C namespace are +C, C, C and +C. -The I flag is really just a boolean - if it is false, the +The I flag is really just a boolean - if it is false, the value is "primitive" and contains no subvalues, kind of like a -non-reference perl scalar. IF it is true, then the value is "constructed" +non-reference perl scalar. If it is true, then the value is "constructed" which just means it contains a list of subvalues which this module will en-/decode as BER tuples themselves. @@ -255,15 +254,24 @@ =over -=item $tuple = ber_decoded $bindata +=item $tuple = ber_decoded $bindata[, $profile] Decodes binary BER data in C<$bindata> and returns the resulting BER tuple. Croaks on any decoding error, so the returned C<$tuple> is always valid. -=item $bindata = ber_encode $tuple +How tags are interpreted is defined by the second argument, which must +be a C object. If it is missing, the default +profile will be used (C<$Convert::BER::XS::DEFAULT_PROFILE>). + +In addition to rolling your own, this module provides a +C<$Convert::BER::XS::SNMP_PROFILE> that knows about the additional SNMP +types. -Encodes the BER tuple into a BER/DER data structure. +=item $bindata = ber_encode $tuple[, $profile] + +Encodes the BER tuple into a BER/DER data structure. AS with +Cyber_decode>, an optional profile can be given. =back @@ -271,23 +279,23 @@ Working with a 4-tuple for every value can be annoying. Or, rather, I annoying. To reduce this a bit, this module defines a number of helper -functions, both to match BER tuples and to conmstruct BER tuples: +functions, both to match BER tuples and to construct BER tuples: =head3 MATCH HELPERS -Thse functions accept a BER tuple as first argument and either paertially +These functions accept a BER tuple as first argument and either partially or fully match it. They often come in two forms, one which exactly matches a value, and one which only matches the type and returns the value. They do check whether valid tuples are passed in and croak otherwise. As a ease-of-use exception, they usually also accept C instead of a -tuple reference. in which case they silently fail to match. +tuple reference, in which case they silently fail to match. =over =item $bool = ber_is $tuple, $class, $tag, $constructed, $data -This takes a BER C<$tuple> and matches its elements agains the privded +This takes a BER C<$tuple> and matches its elements against the provided values, all of which are optional - values that are either missing or C will be ignored, the others will be matched exactly (e.g. as if you used C<==> or C (for C<$data>)).