2 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
\r
3 * Redistribution and modifications are permitted subject to BSD license.
\r
5 #ifndef _BER_TLV_LENGTH_H_
\r
6 #define _BER_TLV_LENGTH_H_
\r
12 typedef ssize_t ber_tlv_len_t;
\r
15 * This function tries to fetch the length of the BER TLV value and place it
\r
18 * 0: More data expected than bufptr contains.
\r
19 * -1: Fatal error deciphering length.
\r
20 * >0: Number of bytes used from bufptr.
\r
21 * On return with >0, len_r is constrained as -1..MAX, where -1 mean
\r
22 * that the value is of indefinite length.
\r
24 ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
\r
25 ber_tlv_len_t *len_r);
\r
28 * This function expects bufptr to be positioned over L in TLV.
\r
29 * It returns number of bytes occupied by L and V together, suitable
\r
30 * for skipping. The function properly handles indefinite length.
\r
32 * Standard {-1,0,>0} convention.
\r
34 ssize_t ber_skip_length(
\r
35 const struct asn_codec_ctx_s *opt_codec_ctx, /* optional context */
\r
36 int _is_constructed, const void *bufptr, size_t size);
\r
39 * This function serializes the length (L from TLV) in DER format.
\r
40 * It always returns number of bytes necessary to represent the length,
\r
41 * it is a caller's responsibility to check the return value
\r
42 * against the supplied buffer's size.
\r
44 size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size);
\r
50 #endif /* _BER_TLV_LENGTH_H_ */
\r