Commit c098de20 authored by Nikolaos Koutsianas's avatar Nikolaos Koutsianas Committed by Mouse

aper decoder can ignore unknown open types in a sequence and continue with next ones

parent 314778a2
......@@ -94,6 +94,14 @@ asn_enc_rval_t OPEN_TYPE_encode_aper(
const asn_TYPE_descriptor_t *type_descriptor,
const asn_per_constraints_t *constraints, const void *struct_ptr,
asn_per_outp_t *per_output);
int OPEN_TYPE_aper_is_unknown_type(
const asn_TYPE_descriptor_t *td,
void *sptr,
const asn_TYPE_member_t *elm);
asn_dec_rval_t OPEN_TYPE_aper_unknown_type_discard_bytes(
asn_per_data_t *pd);
#endif /* !defined(ASN_DISABLE_APER_SUPPORT) */
extern asn_TYPE_operation_t asn_OP_OPEN_TYPE;
......
......@@ -117,3 +117,58 @@ OPEN_TYPE_encode_aper(const asn_TYPE_descriptor_t *td,
er.encoded = 0;
ASN__ENCODED_OK(er);
}
int OPEN_TYPE_aper_is_unknown_type(const asn_TYPE_descriptor_t *td, void *sptr, const asn_TYPE_member_t *elm) {
asn_type_selector_result_t selected;
if(!elm->type_selector) {
return 1;
}
else {
selected = elm->type_selector(td, sptr);
if(!selected.presence_index) {
return 1;
}
}
return 0;
}
asn_dec_rval_t
OPEN_TYPE_aper_unknown_type_discard_bytes (asn_per_data_t *pd) {
#define ASN_DUMMY_BYTES 256
unsigned char dummy[ASN_DUMMY_BYTES], *dummy_ptr = NULL;
ssize_t bytes;
int repeat;
asn_dec_rval_t rv;
rv.consumed = 0;
rv.code = RC_FAIL;
do {
bytes = aper_get_length(pd, -1, -1, &repeat);
if (bytes > 10 * ASN_DUMMY_BYTES)
{
return rv;
}
else if (bytes > ASN_DUMMY_BYTES)
{
dummy_ptr = CALLOC(1, bytes);
if (!dummy_ptr)
return rv;
}
per_get_many_bits(pd, (dummy_ptr ? dummy_ptr : dummy), 0, bytes << 3);
if (dummy_ptr)
{
FREEMEM(dummy_ptr);
dummy_ptr = NULL;
}
} while (repeat);
rv.code = RC_OK;
return rv;
#undef ASN_DUMMY_BYTES
}
......@@ -130,6 +130,11 @@ SEQUENCE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
ASN_DEBUG("Decoding member \"%s\" in %s", elm->name, td->name);
if(elm->flags & ATF_OPEN_TYPE) {
if (OPEN_TYPE_aper_is_unknown_type(td, st, elm)) {
rv = OPEN_TYPE_aper_unknown_type_discard_bytes(pd);
FREEMEM(opres);
return rv;
}
rv = OPEN_TYPE_aper_get(opt_codec_ctx, td, st, elm, pd);
} else {
rv = elm->type->op->aper_decoder(opt_codec_ctx, elm->type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment