Enhanced SIM for E2AP v1 for TS UC
[sim/e2-interface.git] / e2sim / e2apv1sim / ASN1c / oer_decoder.h
1 /*
2  * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef OER_DECODER_H
6 #define OER_DECODER_H
7
8 #include <asn_application.h>
9 #include <oer_support.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 struct asn_TYPE_descriptor_s;   /* Forward declaration */
16 struct asn_codec_ctx_s;         /* Forward declaration */
17
18 /*
19  * The Octet Encoding Rules (OER, X.696 08/2015) decoder for any given type.
20  * This function may be invoked directly by the application.
21  * Parses CANONICAL-OER and BASIC-OER.
22  */
23 asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
24         const struct asn_TYPE_descriptor_s *type_descriptor,
25         void **struct_ptr,      /* Pointer to a target structure's pointer */
26         const void *buffer,     /* Data to be decoded */
27         size_t size             /* Size of that buffer */
28         );
29
30 /*
31  * Type of generic function which decodes the byte stream into the structure.
32  */
33 typedef asn_dec_rval_t(oer_type_decoder_f)(
34     const struct asn_codec_ctx_s *opt_codec_ctx,
35     const struct asn_TYPE_descriptor_s *type_descriptor,
36     const asn_oer_constraints_t *constraints,
37     void **struct_ptr,
38     const void *buf_ptr,
39     size_t size);
40
41 /*
42  * Swallow the Open Type (X.696 (08/2015), #30) into /dev/null.
43  * RETURN VALUES:
44  *      -1:     Fatal error deciphering length.
45  *       0:     More data expected than bufptr contains.
46  *      >0:     Number of bytes used from bufptr.
47  */
48 ssize_t oer_open_type_skip(const void *bufptr, size_t size);
49
50 /*
51  * Read the Open Type (X.696 (08/2015), #30).
52  * RETURN VALUES:
53  *       0:     More data expected than bufptr contains.
54  *      -1:     Fatal error deciphering length.
55  *      >0:     Number of bytes used from bufptr.
56  */
57 ssize_t oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
58                           const struct asn_TYPE_descriptor_s *td,
59                           const asn_oer_constraints_t *constraints,
60                           void **struct_ptr, const void *bufptr, size_t size);
61
62 /*
63  * Length-prefixed buffer decoding for primitive types.
64  */
65 oer_type_decoder_f oer_decode_primitive;
66
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif  /* OER_DECODER_H */