blob: 3150b5c1875b56ede7de79d755946bfbcdaa9f60 [file] [log] [blame]
Lev Walkincc159472017-07-06 08:26:36 -07001/*
2 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
Lev Walkind88bea92017-07-20 11:21:30 +03005#ifndef OER_ENCODER_H
6#define OER_ENCODER_H
Lev Walkincc159472017-07-06 08:26:36 -07007
8#include <asn_application.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14struct asn_TYPE_descriptor_s; /* Forward declaration */
15
16/*
17 * The Octet Encoding Rules (OER, X.696 08/2015) encoder for any type.
18 * This function may be invoked directly by the application.
Lev Walkin28647742017-09-12 11:07:06 -070019 * Produces CANONICAL-OER output compatible with CANONICAL-OER
20 * and BASIC-OER decoders.
Lev Walkincc159472017-07-06 08:26:36 -070021 */
22asn_enc_rval_t oer_encode(struct asn_TYPE_descriptor_s *type_descriptor,
Lev Walkin4558ad02017-07-10 05:21:30 -070023 void *struct_ptr, /* Structure to be encoded */
24 asn_app_consume_bytes_f *consume_bytes_cb,
25 void *app_key /* Arbitrary callback argument */
26 );
Lev Walkincc159472017-07-06 08:26:36 -070027
28/* A variant of oer_encode() which encodes data into the pre-allocated buffer */
29asn_enc_rval_t oer_encode_to_buffer(
Lev Walkin4558ad02017-07-10 05:21:30 -070030 struct asn_TYPE_descriptor_s *type_descriptor,
Lev Walkin494fb702017-08-07 20:07:00 -070031 const asn_oer_constraints_t *constraints,
Lev Walkin4558ad02017-07-10 05:21:30 -070032 void *struct_ptr, /* Structure to be encoded */
33 void *buffer, /* Pre-allocated buffer */
34 size_t buffer_size /* Initial buffer size (maximum) */
35 );
Lev Walkincc159472017-07-06 08:26:36 -070036
37/*
38 * Type of the generic OER encoder.
39 */
Lev Walkin4558ad02017-07-10 05:21:30 -070040typedef asn_enc_rval_t(oer_type_encoder_f)(
41 struct asn_TYPE_descriptor_s *type_descriptor,
Lev Walkin494fb702017-08-07 20:07:00 -070042 const asn_oer_constraints_t *constraints,
Lev Walkin4558ad02017-07-10 05:21:30 -070043 void *struct_ptr, /* Structure to be encoded */
44 asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
45 void *app_key /* Arbitrary callback argument */
46 );
Lev Walkincc159472017-07-06 08:26:36 -070047
48
Lev Walkinb5b524b2017-10-13 03:14:03 -070049/*
50 * Length-prefixed buffer encoding for primitive types.
51 */
52oer_type_encoder_f oer_encode_primitive;
53
Lev Walkincc159472017-07-06 08:26:36 -070054#ifdef __cplusplus
55}
56#endif
57
Lev Walkind88bea92017-07-20 11:21:30 +030058#endif /* OER_ENCODER_H */