--- Convert-BER-XS/XS.pm 2019/04/20 17:23:21 1.33 +++ Convert-BER-XS/XS.pm 2019/04/20 18:38:33 1.34 @@ -143,13 +143,15 @@ C and the match helper functions: - ber_decode ber_is ber_is_seq ber_is_int ber_is_oid + ber_decode ber-decode_prefix + ber_is ber_is_seq ber_is_int ber_is_oid =item C<:encode> C and the construction helper functions: - ber_encode ber_int + ber_encode + ber_int =back @@ -255,7 +257,7 @@ =over -=item $tuple = ber_decoded $bindata[, $profile] +=item $tuple = ber_decode $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 @@ -278,6 +280,18 @@ $tuple = ber_encode $data, $Convert::BER::XS::SNMP_PROFILE; +=item ($tuple, $bytes) = ber_decode_prefix $bindata[, $profile] + +Works like C, except it doesn't croak when there is data after +the BER data, but instead returns the decoded value and the number of +bytes it decoded. + +This is useful when you have BER data at the start of a buffer and other +data after, and you need to find the length. + +Also, since BER is self-delimited, this can be used to decode multiple BER +values joined together. + =item $bindata = ber_encode $tuple[, $profile] Encodes the BER tuple into a BER/DER data structure. AS with @@ -424,7 +438,7 @@ SNMP_TIMETICKS SNMP_OPAQUE SNMP_COUNTER64 )], decode => [qw( - ber_decode + ber_decode ber_decode_prefix ber_is ber_is_seq ber_is_int ber_is_oid )], encode => [qw(