Commit 99acedd0 authored by Cedric Roux's avatar Cedric Roux
Browse files

Merge branch 'enhancement-i18-asn1c-from-gitlab' into 'develop'

download asn1c from oai gitlab

We need to test at least one attach by the UEs of the test setup, to check that the local asn1c is the same as the one from github we used so far.

I don't think we need to do lots of traffic, it's only about control plane (rrc, s1ap).

And of course see if compilation is still ok.

See merge request !40
parents 7abe45d7 f4e97b50
......@@ -397,13 +397,9 @@ install_asn1c_from_source(){
asn1_install_log=$OPENAIR_DIR/cmake_targets/log/asn1c_install_log.txt
echo_info "\nInstalling ASN1. The log file for ASN1 installation is here: $asn1_install_log "
(
$SUDO rm -rf /tmp/asn1c-r1516
svn co https://github.com/vlm/asn1c/trunk /tmp/asn1c-r1516 -r 1516
cd /tmp/asn1c-r1516
patch -p0 < $OPENAIR_DIR/openair3/S1AP/MESSAGES/ASN1/asn1cpatch.p0
patch -p0 < $OPENAIR_DIR/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_2.p0
patch -p0 < $OPENAIR_DIR/openair2/RRC/LITE/MESSAGES/asn1c/asn1cpatch.p0
patch -p0 < $OPENAIR_DIR/openair3/S1AP/MESSAGES/ASN1/asn1cpatch_3.p0
$SUDO rm -rf /tmp/asn1c
git clone https://gitlab.eurecom.fr/oai/asn1c.git /tmp/asn1c
cd /tmp/asn1c
./configure
make -j`nproc`
$SUDO make install
......
Index: skeletons/per_opentype.c
===================================================================
--- skeletons/per_opentype.c (revision 1516)
+++ skeletons/per_opentype.c (working copy)
@@ -277,7 +306,7 @@
(void)constraints;
(void)sptr;
- while(per_get_few_bits(pd, 24) >= 0);
+ while(per_get_few_bits(pd, 1 /*24*/) >= 0);
rv.code = RC_OK;
rv.consumed = pd->moved;
Index: asn1c/unber.c
===================================================================
--- asn1c/unber.c (revision 1516)
+++ asn1c/unber.c (working copy)
@@ -775,4 +775,8 @@
asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void *sptr, asn_per_outp_t *po) { asn_enc_rval_t er = { 0, 0, 0 }; (void)td; (void)cts; (void)sptr; (void)po; return er; }
+asn_dec_rval_t OCTET_STRING_decode_aper(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void **sptr, asn_per_data_t *pd) { asn_dec_rval_t rv = { 0, 0 }; (void)ctx; (void)td; (void)cts; (void)sptr; (void)pd; return rv; }
+
+asn_enc_rval_t OCTET_STRING_encode_aper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void *sptr, asn_per_outp_t *po) { asn_enc_rval_t er = { 0, 0, 0 }; (void)td; (void)cts; (void)sptr; (void)po; return er; }
+
size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size) { (void)chunk_buf; (void)chunk_size; return 0; }
Index: asn1c/asn1c.c
===================================================================
--- asn1c/asn1c.c (revision 1516)
+++ asn1c/asn1c.c (working copy)
@@ -111,6 +111,8 @@
asn1_compiler_flags &= ~A1C_LINK_SKELETONS;
} else if(strcmp(optarg, "link-skeletons") == 0) {
asn1_compiler_flags |= A1C_LINK_SKELETONS;
+ } else if(strcmp(optarg, "have_native64") == 0) {
+ asn1_compiler_flags |= A1C_HAVE_NATIVE_64;
} else {
fprintf(stderr, "-f%s: Invalid argument\n", optarg);
exit(EX_USAGE);
@@ -471,6 +473,7 @@
" -fno-include-deps Do not generate courtesy #includes for dependencies\n"
" -funnamed-unions Enable unnamed unions in structures\n"
" -fwide-types Use INTEGER_t instead of \"long\" by default, etc.\n"
+" -fhave_native64 Use int64_t/uint64_t for target platform\n"
"\n"
" -gen-PER Generate PER support code\n"
Index: examples/README
===================================================================
--- examples/README (revision 1516)
+++ examples/README (working copy)
@@ -25,6 +25,8 @@
UserPlane Location Protocol decoder. Before trying to compile, read the
README file in that directory.
+The clyx2asn1.pl script can be used to extract ASN.1 data from LyX editor files.
+
The crfc2asn1.pl script can be used to extract ASN.1 data from RFC texts.
For instance, it is used to extract X.509, MEGACO, and LDAPv3 ASN.1 modules
from the corresponding RFC texts (rfc3280.txt, rfc3525.txt, rfc4211.txt).
Index: skeletons/UTF8String.c
===================================================================
--- skeletons/UTF8String.c (revision 1516)
+++ skeletons/UTF8String.c (working copy)
@@ -25,6 +25,8 @@
OCTET_STRING_encode_xer_utf8,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper,
+ OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
asn_DEF_UTF8String_tags,
sizeof(asn_DEF_UTF8String_tags)
Index: skeletons/constr_TYPE.h
===================================================================
--- skeletons/constr_TYPE.h (revision 1516)
+++ skeletons/constr_TYPE.h (working copy)
@@ -99,6 +99,8 @@
xer_type_encoder_f *xer_encoder; /* [Canonical] XER encoder */
per_type_decoder_f *uper_decoder; /* Unaligned PER decoder */
per_type_encoder_f *uper_encoder; /* Unaligned PER encoder */
+ per_type_decoder_f *aper_decoder; /* Aligned PER decoder */
+ per_type_encoder_f *aper_encoder; /* Aligned PER encoder */
/***********************************************************************
* Internally useful members. Not to be used by applications directly. *
Index: skeletons/RELATIVE-OID.c
===================================================================
--- skeletons/RELATIVE-OID.c (revision 1516)
+++ skeletons/RELATIVE-OID.c (working copy)
@@ -28,6 +28,8 @@
RELATIVE_OID_encode_xer,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper,
+ OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
asn_DEF_RELATIVE_OID_tags,
sizeof(asn_DEF_RELATIVE_OID_tags)
Index: skeletons/per_encoder.c
===================================================================
--- skeletons/per_encoder.c (revision 1516)
+++ skeletons/per_encoder.c (working copy)
@@ -4,6 +4,7 @@
static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
+static asn_enc_rval_t aper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
asn_enc_rval_t
uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
return uper_encode_internal(td, 0, sptr, cb, app_key);
@@ -41,6 +42,18 @@
return uper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key);
}
+asn_enc_rval_t
+aper_encode_to_buffer(asn_TYPE_descriptor_t *td, void *sptr, void *buffer, size_t buffer_size) {
+ enc_to_buf_arg key;
+
+ key.buffer = buffer;
+ key.left = buffer_size;
+
+ if(td) ASN_DEBUG("Encoding \"%s\" using ALIGNED PER", td->name);
+
+ return aper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key);
+}
+
typedef struct enc_dyn_arg {
void *buffer;
size_t length;
@@ -93,6 +106,35 @@
}
}
+ssize_t
+aper_encode_to_new_buffer(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, void **buffer_r) {
+ asn_enc_rval_t er;
+ enc_dyn_arg key;
+
+ memset(&key, 0, sizeof(key));
+
+ er = aper_encode_internal(td, constraints, sptr, encode_dyn_cb, &key);
+ switch(er.encoded) {
+ case -1:
+ FREEMEM(key.buffer);
+ return -1;
+ case 0:
+ FREEMEM(key.buffer);
+ key.buffer = MALLOC(1);
+ if(key.buffer) {
+ *(char *)key.buffer = '\0';
+ *buffer_r = key.buffer;
+ return 1;
+ } else {
+ return -1;
+ }
+ default:
+ *buffer_r = key.buffer;
+ ASN_DEBUG("Complete encoded in %ld bits", (long)er.encoded);
+ return ((er.encoded + 7) >> 3);
+ }
+}
+
/*
* Internally useful functions.
*/
@@ -115,6 +157,23 @@
return po->outper(po->tmpspace, buf - po->tmpspace, po->op_key);
}
+static int
+_aper_encode_flush_outp(asn_per_outp_t *po) {
+ uint8_t *buf;
+
+ if(po->nboff == 0 && po->buffer == po->tmpspace)
+ return 0;
+
+ buf = po->buffer + (po->nboff >> 3);
+ /* Make sure we account for the last, partially filled */
+ if(po->nboff & 0x07) {
+ buf[0] &= 0xff << (8 - (po->nboff & 0x07));
+ buf++;
+ }
+
+ return po->outper(po->tmpspace, buf - po->tmpspace, po->op_key);
+}
+
static asn_enc_rval_t
uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
asn_per_outp_t po;
@@ -149,3 +208,37 @@
return er;
}
+static asn_enc_rval_t
+aper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
+ asn_per_outp_t po;
+ asn_enc_rval_t er;
+
+ /*
+ * Invoke type-specific encoder.
+ */
+ if(!td || !td->aper_encoder)
+ _ASN_ENCODE_FAILED; /* PER is not compiled in */
+
+ po.buffer = po.tmpspace;
+ po.nboff = 0;
+ po.nbits = 8 * sizeof(po.tmpspace);
+ po.outper = cb;
+ po.op_key = app_key;
+ po.flushed_bytes = 0;
+
+ er = td->aper_encoder(td, constraints, sptr, &po);
+ if(er.encoded != -1) {
+ size_t bits_to_flush;
+
+ bits_to_flush = ((po.buffer - po.tmpspace) << 3) + po.nboff;
+
+ /* Set number of bits encoded to a firm value */
+ er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
+
+ if(_aper_encode_flush_outp(&po))
+ _ASN_ENCODE_FAILED;
+ }
+
+ return er;
+}
+
Index: skeletons/NumericString.c
===================================================================
--- skeletons/NumericString.c (revision 1516)
+++ skeletons/NumericString.c (working copy)
@@ -49,6 +49,8 @@
OCTET_STRING_encode_xer_utf8,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper,
+ OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
asn_DEF_NumericString_tags,
sizeof(asn_DEF_NumericString_tags)
Index: skeletons/per_encoder.h
===================================================================
--- skeletons/per_encoder.h (revision 1516)
+++ skeletons/per_encoder.h (working copy)
@@ -38,6 +38,12 @@
size_t buffer_size /* Initial buffer size (max) */
);
+asn_enc_rval_t aper_encode_to_buffer(
+ struct asn_TYPE_descriptor_s *type_descriptor,
+ void *struct_ptr, /* Structure to be encoded */
+ void *buffer, /* Pre-allocated buffer */
+ size_t buffer_size /* Initial buffer size (max) */
+);
/*
* A variant of uper_encode_to_buffer() which allocates buffer itself.
* Returns the number of bytes in the buffer or -1 in case of failure.
@@ -52,6 +58,11 @@
void **buffer_r /* Buffer allocated and returned */
);
+ssize_t
+aper_encode_to_new_buffer(struct asn_TYPE_descriptor_s *td,
+ asn_per_constraints_t *constraints,
+ void *sptr,
+ void **buffer_r);
/*
* Type of the generic PER encoder function.
*/
Index: skeletons/T61String.c
===================================================================
--- skeletons/T61String.c (revision 1516)
+++ skeletons/T61String.c (working copy)
@@ -24,6 +24,8 @@
OCTET_STRING_encode_xer,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper,
+ OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
asn_DEF_T61String_tags,
sizeof(asn_DEF_T61String_tags)
Index: skeletons/TeletexString.c
===================================================================
--- skeletons/TeletexString.c (revision 1516)
+++ skeletons/TeletexString.c (working copy)
@@ -24,6 +24,8 @@
OCTET_STRING_encode_xer,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper,
+ OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
asn_DEF_TeletexString_tags,
sizeof(asn_DEF_TeletexString_tags)
Index: skeletons/BMPString.c
===================================================================
--- skeletons/BMPString.c (revision 1516)
+++ skeletons/BMPString.c (working copy)
@@ -35,6 +35,8 @@
BMPString_encode_xer, /* Convert to UTF-8 */
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper, /* Aligned PER decoder */
+ OCTET_STRING_encode_aper, /* Aligned PER encoder */
0, /* Use generic outmost tag fetcher */
asn_DEF_BMPString_tags,
sizeof(asn_DEF_BMPString_tags)
Index: skeletons/ObjectDescriptor.c
===================================================================
--- skeletons/ObjectDescriptor.c (revision 1516)
+++ skeletons/ObjectDescriptor.c (working copy)
@@ -24,6 +24,8 @@
OCTET_STRING_encode_xer_utf8,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper,
+ OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
asn_DEF_ObjectDescriptor_tags,
sizeof(asn_DEF_ObjectDescriptor_tags)
Index: skeletons/PrintableString.c
===================================================================
--- skeletons/PrintableString.c (revision 1516)
+++ skeletons/PrintableString.c (working copy)
@@ -59,6 +59,8 @@
OCTET_STRING_encode_xer_utf8,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
+ OCTET_STRING_decode_aper,
+ OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
asn_DEF_PrintableString_tags,
sizeof(asn_DEF_PrintableString_tags)
Index: skeletons/constr_SET_OF.c
===================================================================
--- skeletons/constr_SET_OF.c (revision 1516)
+++ skeletons/constr_SET_OF.c (working copy)
@@ -34,7 +34,7 @@
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
- ptr = ((const void *)ptr) + num;\
+ ptr = ((const char *)ptr) + num;\
size -= num; \
if(ctx->left >= 0) \
ctx->left -= num; \
@@ -100,7 +100,7 @@
/*
* Restore parsing context.
*/
- ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
+ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Start to parse where left previously
@@ -457,7 +457,7 @@
#undef XER_ADVANCE
#define XER_ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
- buf_ptr = ((const void *)buf_ptr) + num;\
+ buf_ptr = ((const char *)buf_ptr) + num;\
size -= num; \
consumed_myself += num; \
} while(0)
@@ -505,7 +505,7 @@
/*
* Restore parsing context.
*/
- ctx = (asn_struct_ctx_t *)((void *)st + specs->ctx_offset);
+ ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
/*
* Phases of XER/XML processing:
@@ -627,7 +627,7 @@
t->buffer = p;
t->size = newsize;
}
- memcpy((void *)t->buffer + t->offset, buffer, size);
+ memcpy((char *)t->buffer + t->offset, buffer, size);
t->offset += size;
return 0;
}
@@ -809,7 +809,7 @@
asn_set_empty(list); /* Remove (list->array) */
specs = (asn_SET_OF_specifics_t *)td->specifics;
- ctx = (asn_struct_ctx_t *)((void *)ptr + specs->ctx_offset);
+ ctx = (asn_struct_ctx_t *)((char *)ptr + specs->ctx_offset);
if(ctx->ptr) {
ASN_STRUCT_FREE(*elm->type, ctx->ptr);
ctx->ptr = 0;
@@ -884,7 +884,7 @@
if(!st) {
st = *sptr = CALLOC(1, specs->struct_size);
if(!st) _ASN_DECODE_FAILED;
- }
+ }
list = _A_SET_FROM_VOID(st);
/* Figure out which constraints to use */
@@ -901,7 +901,7 @@
if(ct && ct->effective_bits >= 0) {
/* X.691, #19.5: No length determinant */
nelems = per_get_few_bits(pd, ct->effective_bits);
- ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s",
+ ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s",
(long)nelems, ct->lower_bound, td->name);
if(nelems < 0) _ASN_DECODE_STARVED;
nelems += ct->lower_bound;
@@ -951,3 +951,91 @@
return rv;
}
+asn_dec_rval_t
+SET_OF_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+ asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
+ asn_dec_rval_t rv;
+ asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
+ asn_TYPE_member_t *elm = td->elements; /* Single one */
+ void *st = *sptr;
+ asn_anonymous_set_ *list;
+ asn_per_constraint_t *ct;
+ int repeat = 0;
+ ssize_t nelems;
+
+ if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
+ _ASN_DECODE_FAILED;
+
+ /*
+ * Create the target structure if it is not present already.
+ */
+ if(!st) {
+ st = *sptr = CALLOC(1, specs->struct_size);
+ if(!st) _ASN_DECODE_FAILED;
+ }
+ list = _A_SET_FROM_VOID(st);
+
+ /* Figure out which constraints to use */
+ if(constraints) ct = &constraints->size;
+ else if(td->per_constraints) ct = &td->per_constraints->size;
+ else ct = 0;
+
+ if(ct && ct->flags & APC_EXTENSIBLE) {
+ int value = per_get_few_bits(pd, 1);
+ if(value < 0) _ASN_DECODE_STARVED;
+ if(value) ct = 0; /* Not restricted! */
+ }
+
+ if(ct && ct->effective_bits >= 0) {
+ /* X.691, #19.5: No length determinant */
+// nelems = per_get_few_bits(pd, ct->effective_bits);
+ nelems = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound);
+ ASN_DEBUG("Preparing to fetch %ld+%"PRIdMAX" elements from %s",
+ (long)nelems, ct->lower_bound, td->name);
+ if(nelems < 0) _ASN_DECODE_STARVED;
+ nelems += ct->lower_bound;
+ } else {
+ nelems = -1;
+ }
+
+ do {
+ int i;
+ if(nelems < 0) {
+ nelems = aper_get_length(pd, ct ? ct->upper_bound - ct->lower_bound + 1 : -1,
+ ct ? ct->effective_bits : -1, &repeat);
+ ASN_DEBUG("Got to decode %d elements (eff %d)",
+ (int)nelems, (int)ct ? ct->effective_bits : -1);
+ if(nelems < 0) _ASN_DECODE_STARVED;
+ }
+
+ for(i = 0; i < nelems; i++) {
+ void *ptr = 0;
+ ASN_DEBUG("SET OF %s decoding", elm->type->name);
+ rv = elm->type->aper_decoder(opt_codec_ctx, elm->type,
+ elm->per_constraints, &ptr, pd);
+ ASN_DEBUG("%s SET OF %s decoded %d, %p",
+ td->name, elm->type->name, rv.code, ptr);
+ if(rv.code == RC_OK) {
+ if(ASN_SET_ADD(list, ptr) == 0)
+ continue;
+ ASN_DEBUG("Failed to add element into %s",
+ td->name);
+ /* Fall through */
+ rv.code = RC_FAIL;
+ } else {
+ ASN_DEBUG("Failed decoding %s of %s (SET OF)",
+ elm->type->name, td->name);
+ }
+ if(ptr) ASN_STRUCT_FREE(*elm->type, ptr);
+ return rv;
+ }
+
+ nelems = -1; /* Allow uper_get_length() */
+ } while(repeat);
+
+ ASN_DEBUG("Decoded %s as SET OF", td->name);
+
+ rv.code = RC_OK;
+ rv.consumed = 0;
+ return rv;
+}
Index: skeletons/NULL.c
===================================================================
--- skeletons/NULL.c (revision 1516)
+++ skeletons/NULL.c (working copy)
@@ -25,6 +25,8 @@
NULL_encode_xer,
NULL_decode_uper, /* Unaligned PER decoder */
NULL_encode_uper, /* Unaligned PER encoder */
+ NULL_decode_aper, /* Aligned PER decoder */
+ NULL_encode_aper, /* Aligned PER encoder */
0, /* Use generic outmost tag fetcher */
asn_DEF_NULL_tags,
sizeof(asn_DEF_NULL_tags) / sizeof(asn_DEF_NULL_tags[0]),
@@ -135,6 +137,34 @@
return rv;
}
+asn_dec_rval_t
+NULL_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+ asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
+ asn_dec_rval_t rv;
+
+ (void)opt_codec_ctx;
+ (void)td;
+ (void)constraints;
+ (void)pd;
+
+ if(!*sptr) {
+ *sptr = MALLOC(sizeof(NULL_t));
+ if(*sptr) {
+ *(NULL_t *)*sptr = 0;
+ } else {
+ _ASN_DECODE_FAILED;
+ }
+ }
+
+ /*
+ * NULL type does not have content octets.
+ */
+
+ rv.code = RC_OK;
+ rv.consumed = 0;
+ return rv;
+}
+
asn_enc_rval_t
NULL_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints,
void *sptr, asn_per_outp_t *po) {
@@ -148,3 +178,17 @@
er.encoded = 0;
_ASN_ENCODED_OK(er);
}
+
+asn_enc_rval_t
+NULL_encode_aper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints,
+ void *sptr, asn_per_outp_t *po) {
+ asn_enc_rval_t er;
+
+ (void)td;
+ (void)constraints;
+ (void)sptr;
+ (void)po;
+
+ er.encoded = 0;
+ _ASN_ENCODED_OK(er);
+}
Index: skeletons/per_decoder.c
===================================================================
--- skeletons/per_decoder.c (revision 1516)
+++ skeletons/per_decoder.c (working copy)
@@ -37,6 +37,35 @@
}
asn_dec_rval_t
+aper_decode_complete(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size) {
+ asn_dec_rval_t rval;
+
+ rval = aper_decode(opt_codec_ctx, td, sptr, buffer, size, 0, 0);
+ if(rval.consumed) {
+ /*
+ * We've always given 8-aligned data,
+ * so convert bits to integral bytes.
+ */
+ rval.consumed += 7;
+ rval.consumed >>= 3;
+ } else if(rval.code == RC_OK) {
+ if(size) {
+ if(((const uint8_t *)buffer)[0] == 0) {
+ rval.consumed = 1; /* 1 byte */
+ } else {
+ ASN_DEBUG("Expecting single zeroed byte");
+ rval.code = RC_FAIL;
+ }
+ } else {
+ /* Must contain at least 8 bits. */
+ rval.code = RC_WMORE;
+ }
+ }
+
+ return rval;
+}
+
+asn_dec_rval_t
uper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size, int skip_bits, int unused_bits) {
asn_codec_ctx_t s_codec_ctx;
asn_dec_rval_t rval;
@@ -91,3 +120,57 @@
return rval;
}
+asn_dec_rval_t
+aper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size, int skip_bits, int unused_bits) {
+ asn_codec_ctx_t s_codec_ctx;