oer_decoder.h 2.01 KB
Newer Older
Lev Walkin's avatar
Lev Walkin committed
1 2 3 4
/*
 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
 * Redistribution and modifications are permitted subject to BSD license.
 */
Lev Walkin's avatar
Lev Walkin committed
5 6
#ifndef	OER_DECODER_H
#define	OER_DECODER_H
Lev Walkin's avatar
Lev Walkin committed
7 8

#include <asn_application.h>
Lev Walkin's avatar
Lev Walkin committed
9
#include <oer_support.h>
Lev Walkin's avatar
Lev Walkin committed
10 11 12 13 14 15 16 17 18 19 20

#ifdef __cplusplus
extern "C" {
#endif

struct asn_TYPE_descriptor_s;	/* Forward declaration */
struct asn_codec_ctx_s;		/* Forward declaration */

/*
 * The Octet Encoding Rules (OER, X.696 08/2015) decoder for any given type.
 * This function may be invoked directly by the application.
21
 * Parses CANONICAL-OER and BASIC-OER.
Lev Walkin's avatar
Lev Walkin committed
22
 */
Lev Walkin's avatar
Lev Walkin committed
23
asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
Lev Walkin's avatar
Lev Walkin committed
24 25 26 27 28 29 30 31 32
	struct asn_TYPE_descriptor_s *type_descriptor,
	void **struct_ptr,	/* Pointer to a target structure's pointer */
	const void *buffer,	/* Data to be decoded */
	size_t size		/* Size of that buffer */
	);

/*
 * Type of generic function which decodes the byte stream into the structure.
 */
Lev Walkin's avatar
Lev Walkin committed
33
typedef asn_dec_rval_t(oer_type_decoder_f)(
Lev Walkin's avatar
Lev Walkin committed
34
    const struct asn_codec_ctx_s *opt_codec_ctx,
Lev Walkin's avatar
Lev Walkin committed
35
    struct asn_TYPE_descriptor_s *type_descriptor,
Lev Walkin's avatar
Lev Walkin committed
36
    const asn_oer_constraints_t *constraints,
Lev Walkin's avatar
Lev Walkin committed
37 38 39
    void **struct_ptr,
    const void *buf_ptr,
    size_t size);
Lev Walkin's avatar
Lev Walkin committed
40

Lev Walkin's avatar
Lev Walkin committed
41 42 43 44 45 46 47
/*
 * Swallow the Open Type (X.696 (08/2015), #30) into /dev/null.
 * RETURN VALUES:
 *       0:     More data expected than bufptr contains.
 *      -1:     Fatal error deciphering length.
 *      >0:     Number of bytes used from bufptr.
 */
Lev Walkin's avatar
Lev Walkin committed
48
ssize_t oer_open_type_skip(const void *bufptr, size_t size);
Lev Walkin's avatar
Lev Walkin committed
49 50 51 52 53 54 55 56

/*
 * Read the Open Type (X.696 (08/2015), #30).
 * RETURN VALUES:
 *       0:     More data expected than bufptr contains.
 *      -1:     Fatal error deciphering length.
 *      >0:     Number of bytes used from bufptr.
 */
Lev Walkin's avatar
Lev Walkin committed
57
ssize_t oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
Lev Walkin's avatar
Lev Walkin committed
58 59 60 61 62
                          struct asn_TYPE_descriptor_s *td,
                          asn_oer_constraints_t *constraints, void **struct_ptr,
                          const void *bufptr, size_t size);


Lev Walkin's avatar
Lev Walkin committed
63 64 65 66
#ifdef __cplusplus
}
#endif

Lev Walkin's avatar
Lev Walkin committed
67
#endif	/* OER_DECODER_H */