diff --git a/examples/sample.source.1609.2/Makefile b/examples/sample.source.1609.2/Makefile index c335ec9c..b57dc688 100644 --- a/examples/sample.source.1609.2/Makefile +++ b/examples/sample.source.1609.2/Makefile @@ -287,6 +287,7 @@ ASN_MODULE_SOURCES+=NativeInteger_oer.c ASN_MODULE_SOURCES+=NativeEnumerated_oer.c ASN_MODULE_SOURCES+=constr_SEQUENCE_oer.c ASN_MODULE_SOURCES+=constr_CHOICE_oer.c +ASN_MODULE_SOURCES+=constr_SET_OF_oer.c ASN_CONVERTER_SOURCES+=pdu_collection.c diff --git a/skeletons/Makefile.am b/skeletons/Makefile.am index 3cc18f4e..4b36622f 100644 --- a/skeletons/Makefile.am +++ b/skeletons/Makefile.am @@ -72,6 +72,7 @@ libasn1cskeletons_la_SOURCES = \ constr_SEQUENCE_OF.c constr_SEQUENCE_OF.h \ constr_SET.c constr_SET.h \ constr_SET_OF.c constr_SET_OF.h \ + constr_SET_OF_oer.c \ constr_TYPE.c constr_TYPE.h \ constraints.c constraints.h \ der_encoder.c der_encoder.h \ diff --git a/skeletons/NativeInteger_oer.c b/skeletons/NativeInteger_oer.c index 08cb6a68..25794e25 100644 --- a/skeletons/NativeInteger_oer.c +++ b/skeletons/NativeInteger_oer.c @@ -41,23 +41,23 @@ NativeInteger_decode_oer(asn_codec_ctx_t *opt_codec_ctx, if(specs && specs->field_unsigned) { unsigned long ul; - if(asn_INTEGER2ulong(&tmpint, &ul) != 0) { - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - rval.code = RC_FAIL; - rval.consumed = 0; - return rval; - } else { + int ok = asn_INTEGER2ulong(&tmpint, &ul) == 0; + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + if(ok) { *native = ul; + } else { + rval.code = RC_FAIL; + return rval; } } else { long l; - if(asn_INTEGER2long(&tmpint, &l) != 0) { - ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); - rval.code = RC_FAIL; - rval.consumed = 0; - return rval; - } else { + int ok = asn_INTEGER2long(&tmpint, &l) == 0; + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint); + if(ok) { *native = l; + } else { + rval.code = RC_FAIL; + return rval; } } diff --git a/skeletons/constr_CHOICE_oer.c b/skeletons/constr_CHOICE_oer.c index b14e6cfb..a0feaa0a 100644 --- a/skeletons/constr_CHOICE_oer.c +++ b/skeletons/constr_CHOICE_oer.c @@ -15,6 +15,7 @@ #undef RETURN #define RETURN(_code) \ do { \ + asn_dec_rval_t rval; \ rval.code = _code; \ rval.consumed = consumed_myself; \ return rval; \ @@ -38,7 +39,12 @@ ctx->phase++; \ ctx->step = 0; \ } while(0) - +#undef SET_PHASE +#define SET_PHASE(ctx, value) \ + do { \ + ctx->phase = value; \ + ctx->step = 0; \ + } while(0) /* * Tags are canonically sorted in the tag to member table. @@ -136,8 +142,6 @@ CHOICE_decode_oer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void *st = *struct_ptr; /* Target structure. */ asn_struct_ctx_t *ctx; /* Decoder context */ - asn_dec_rval_t rval; /* Return code from subparsers */ - ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ (void)constraints; @@ -196,7 +200,9 @@ CHOICE_decode_oer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, RETURN(RC_FAIL); } else { /* Skip open type extension */ - ASN_DEBUG("Not implemented skipping open type extension"); + ASN_DEBUG( + "Not implemented skipping open type extension for tag %s", + ber_tlv_tag_string(tlv_tag)); RETURN(RC_FAIL); } } while(0); @@ -204,10 +210,12 @@ CHOICE_decode_oer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ADVANCE(tag_len); } + /* Fall through */ case 1: { asn_TYPE_member_t *elm = &elements[ctx->step]; /* CHOICE's element */ void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ + asn_dec_rval_t rval; /* * Compute the position of the member inside a structure, @@ -240,8 +248,22 @@ CHOICE_decode_oer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, elm->oer_constraints, memb_ptr2, ptr, size); rval.consumed += consumed_myself; + switch(rval.code) { + case RC_OK: + NEXT_PHASE(ctx); + case RC_WMORE: + break; + case RC_FAIL: + SET_PHASE(ctx, 3); /* => 3 */ + } return rval; } + case 2: + /* Already decoded everything */ + RETURN(RC_OK); + case 3: + /* Failed to decode, after all */ + RETURN(RC_FAIL); } RETURN(RC_FAIL); diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c index 617dc2eb..d267c3f8 100644 --- a/skeletons/constr_SEQUENCE_OF.c +++ b/skeletons/constr_SEQUENCE_OF.c @@ -220,8 +220,8 @@ asn_TYPE_operation_t asn_OP_SEQUENCE_OF = { 0, 0, #else - 0, - 0, + SEQUENCE_OF_decode_oer, + SEQUENCE_OF_encode_oer, #endif /* ASN_DISABLE_OER_SUPPORT */ #ifdef ASN_DISABLE_PER_SUPPORT 0, diff --git a/skeletons/constr_SEQUENCE_OF.h b/skeletons/constr_SEQUENCE_OF.h index d0a09ebb..22d816bb 100644 --- a/skeletons/constr_SEQUENCE_OF.h +++ b/skeletons/constr_SEQUENCE_OF.h @@ -23,6 +23,8 @@ extern "C" { #define SEQUENCE_OF_decode_ber SET_OF_decode_ber #define SEQUENCE_OF_decode_xer SET_OF_decode_xer #define SEQUENCE_OF_decode_uper SET_OF_decode_uper +#define SEQUENCE_OF_decode_oer SET_OF_decode_oer +#define SEQUENCE_OF_encode_oer SET_OF_encode_oer der_type_encoder_f SEQUENCE_OF_encode_der; xer_type_encoder_f SEQUENCE_OF_encode_xer; per_type_encoder_f SEQUENCE_OF_encode_uper; diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c index b4b8bb10..f2a711bd 100644 --- a/skeletons/constr_SET_OF.c +++ b/skeletons/constr_SET_OF.c @@ -981,8 +981,13 @@ asn_TYPE_operation_t asn_OP_SET_OF = { SET_OF_encode_der, SET_OF_decode_xer, SET_OF_encode_xer, +#ifdef ASN_DISABLE_OER_SUPPORT 0, 0, +#else + SET_OF_decode_oer, + SET_OF_decode_oer, +#endif #ifdef ASN_DISABLE_PER_SUPPORT 0, 0, diff --git a/skeletons/constr_SET_OF.h b/skeletons/constr_SET_OF.h index a6bfb3c6..8b516110 100644 --- a/skeletons/constr_SET_OF.h +++ b/skeletons/constr_SET_OF.h @@ -2,8 +2,8 @@ * Copyright (c) 2003 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ -#ifndef _CONSTR_SET_OF_H_ -#define _CONSTR_SET_OF_H_ +#ifndef CONSTR_SET_OF_H +#define CONSTR_SET_OF_H #include @@ -12,14 +12,14 @@ extern "C" { #endif typedef const struct asn_SET_OF_specifics_s { - /* - * Target structure description. - */ - int struct_size; /* Size of the target structure. */ - int ctx_offset; /* Offset of the asn_struct_ctx_t member */ + /* + * Target structure description. + */ + unsigned struct_size; /* Size of the target structure. */ + unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */ - /* XER-specific stuff */ - int as_XMLValueList; /* The member type must be encoded like this */ + /* XER-specific stuff */ + int as_XMLValueList; /* The member type must be encoded like this */ } asn_SET_OF_specifics_t; /* @@ -33,6 +33,8 @@ ber_type_decoder_f SET_OF_decode_ber; der_type_encoder_f SET_OF_encode_der; xer_type_decoder_f SET_OF_decode_xer; xer_type_encoder_f SET_OF_encode_xer; +oer_type_decoder_f SET_OF_decode_oer; +oer_type_encoder_f SET_OF_encode_oer; per_type_decoder_f SET_OF_decode_uper; per_type_encoder_f SET_OF_encode_uper; extern asn_TYPE_operation_t asn_OP_SET_OF; @@ -41,4 +43,4 @@ extern asn_TYPE_operation_t asn_OP_SET_OF; } #endif -#endif /* _CONSTR_SET_OF_H_ */ +#endif /* CONSTR_SET_OF_H */ diff --git a/skeletons/file-dependencies b/skeletons/file-dependencies index dc82eb82..d9a48d8e 100644 --- a/skeletons/file-dependencies +++ b/skeletons/file-dependencies @@ -78,5 +78,6 @@ NativeInteger_oer.c NativeEnumerated_oer.c constr_SEQUENCE_oer.c constr_CHOICE_oer.c +constr_SET_OF_oer.c CODEC-PER: # THIS IS A SPECIAL SECTION