asn1c/skeletons/ber_tlv_length.h

51 lines
1.5 KiB
C
Raw Permalink Normal View History

2004-06-03 03:38:44 +00:00
/*-
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _BER_TLV_LENGTH_H_
#define _BER_TLV_LENGTH_H_
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2004-06-03 03:38:44 +00:00
typedef ssize_t ber_tlv_len_t;
/*
* This function tries to fetch the length of the BER TLV value and place it
* in *len_r.
* RETURN VALUES:
* 0: More data expected than bufptr contains.
* -1: Fatal error deciphering length.
* >0: Number of bytes used from bufptr.
* On return with >0, len_r is constrained as -1..MAX, where -1 mean
* that the value is of indefinite length.
*/
2005-03-10 18:52:02 +00:00
ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
2004-06-03 03:38:44 +00:00
ber_tlv_len_t *len_r);
/*
* This function expects bufptr to be positioned over L in TLV.
* It returns number of bytes occupied by L and V together, suitable
* for skipping. The function properly handles indefinite length.
* RETURN VALUES:
* Standard {-1,0,>0} convention.
*/
ssize_t ber_skip_length(
struct asn_codec_ctx_s *opt_codec_ctx, /* optional context */
2005-03-10 18:52:02 +00:00
int _is_constructed, const void *bufptr, size_t size);
2004-06-03 03:38:44 +00:00
/*
* This function serializes the length (L from TLV) in DER format.
2004-09-24 20:59:13 +00:00
* It always returns number of bytes necessary to represent the length,
2004-06-03 03:38:44 +00:00
* it is a caller's responsibility to check the return value
* against the supplied buffer's size.
*/
2004-09-24 20:59:13 +00:00
size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size);
2004-06-03 03:38:44 +00:00
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
}
#endif
2004-06-03 03:38:44 +00:00
#endif /* _BER_TLV_LENGTH_H_ */