ITS
ber_tlv_length.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef _BER_TLV_LENGTH_H_
6 #define _BER_TLV_LENGTH_H_
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 typedef ssize_t ber_tlv_len_t;
13 
14 /*
15  * This function tries to fetch the length of the BER TLV value and place it
16  * in *len_r.
17  * RETURN VALUES:
18  * 0: More data expected than bufptr contains.
19  * -1: Fatal error deciphering length.
20  * >0: Number of bytes used from bufptr.
21  * On return with >0, len_r is constrained as -1..MAX, where -1 mean
22  * that the value is of indefinite length.
23  */
24 ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
25  ber_tlv_len_t *len_r);
26 
27 /*
28  * This function expects bufptr to be positioned over L in TLV.
29  * It returns number of bytes occupied by L and V together, suitable
30  * for skipping. The function properly handles indefinite length.
31  * RETURN VALUES:
32  * Standard {-1,0,>0} convention.
33  */
34 ssize_t ber_skip_length(
35  struct asn_codec_ctx_s *opt_codec_ctx, /* optional context */
36  int _is_constructed, const void *bufptr, size_t size);
37 
38 /*
39  * This function serializes the length (L from TLV) in DER format.
40  * It always returns number of bytes necessary to represent the length,
41  * it is a caller's responsibility to check the return value
42  * against the supplied buffer's size.
43  */
44 size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size);
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif /* _BER_TLV_LENGTH_H_ */
size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size)
ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size, ber_tlv_len_t *len_r)
ssize_t ber_skip_length(struct asn_codec_ctx_s *opt_codec_ctx, int _is_constructed, const void *bufptr, size_t size)
ssize_t ber_tlv_len_t