Commit 6903380f authored by Lev Walkin's avatar Lev Walkin

generate oer only when requested

parent 6cd0d567
...@@ -23,6 +23,8 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = { ...@@ -23,6 +23,8 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = {
0, /* Use generic outmost tag fetcher */ 0, /* Use generic outmost tag fetcher */
}; };
#ifndef ASN_DISABLE_PER_SUPPORT
asn_dec_rval_t asn_dec_rval_t
OPEN_TYPE_uper_get(asn_codec_ctx_t *opt_codec_ctx, OPEN_TYPE_uper_get(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void *sptr, asn_TYPE_descriptor_t *td, void *sptr,
...@@ -90,79 +92,4 @@ OPEN_TYPE_uper_get(asn_codec_ctx_t *opt_codec_ctx, ...@@ -90,79 +92,4 @@ OPEN_TYPE_uper_get(asn_codec_ctx_t *opt_codec_ctx,
return rv; return rv;
} }
asn_dec_rval_t #endif /* ASN_DISABLE_PER_SUPPORT */
OPEN_TYPE_oer_get(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void *sptr, asn_TYPE_member_t *elm, const void *ptr,
size_t size) {
asn_type_selector_result_t selected;
void *memb_ptr; /* Pointer to the member */
void **memb_ptr2; /* Pointer to that pointer */
void *inner_value;
asn_dec_rval_t rv;
size_t ot_ret;
if(!(elm->flags & ATF_OPEN_TYPE) || !elm->type_selector) {
ASN__DECODE_FAILED;
}
selected = elm->type_selector(td, sptr);
if(!selected.presence_index) {
ASN__DECODE_FAILED;
}
/* Fetch the pointer to this member */
if(elm->flags & ATF_POINTER) {
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
} else {
memb_ptr = (char *)sptr + elm->memb_offset;
memb_ptr2 = &memb_ptr;
}
if(*memb_ptr2 != NULL) {
/* Make sure we reset the structure first before encoding */
if(CHOICE_variant_set_presence(selected.type_descriptor, *memb_ptr2, 0)
!= 0) {
ASN__DECODE_FAILED;
}
}
inner_value =
(char *)*memb_ptr2
+ elm->type->elements[selected.presence_index - 1].memb_offset;
ot_ret = oer_open_type_get(opt_codec_ctx, selected.type_descriptor, NULL,
&inner_value, ptr, size);
switch(ot_ret) {
default:
if(CHOICE_variant_set_presence(selected.type_descriptor, *memb_ptr2,
selected.presence_index)
== 0) {
rv.code = RC_OK;
rv.consumed = ot_ret;
return rv;
} else {
/* Oh, now a full-blown failure failure */
}
/* Fall through */
case -1:
rv.code = RC_FAIL;
rv.consumed = 0;
break;
case 0:
rv.code = RC_WMORE;
rv.consumed = 0;
break;
}
if(*memb_ptr2) {
asn_CHOICE_specifics_t *specs = selected.type_descriptor->specifics;
if(elm->flags & ATF_POINTER) {
ASN_STRUCT_FREE(*selected.type_descriptor, inner_value);
*memb_ptr2 = NULL;
} else {
ASN_STRUCT_FREE_CONTENTS_ONLY(*selected.type_descriptor,
inner_value);
memset(*memb_ptr2, 0, specs->struct_size);
}
}
return rv;
}
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <asn_internal.h> #include <asn_internal.h>
#include <OPEN_TYPE.h> #include <OPEN_TYPE.h>
#include <constr_CHOICE.h> #include <constr_CHOICE.h>
#include <oer_opentype.h>
#include <errno.h> #include <errno.h>
asn_dec_rval_t asn_dec_rval_t
......
...@@ -41,9 +41,16 @@ typedef struct asn_struct_ctx_s { ...@@ -41,9 +41,16 @@ typedef struct asn_struct_ctx_s {
#include <xer_encoder.h> /* Encoder into XER (XML, text) */ #include <xer_encoder.h> /* Encoder into XER (XML, text) */
#include <per_decoder.h> /* Packet Encoding Rules decoder */ #include <per_decoder.h> /* Packet Encoding Rules decoder */
#include <per_encoder.h> /* Packet Encoding Rules encoder */ #include <per_encoder.h> /* Packet Encoding Rules encoder */
#include <constraints.h> /* Subtype constraints support */
#ifdef ASN_DISABLE_OER_SUPPORT
typedef void (*oer_type_decoder_f)();
typedef void (*oer_type_encoder_f)();
typedef struct{} asn_oer_constraints_t;
#else
#include <oer_decoder.h> /* Octet Encoding Rules encoder */ #include <oer_decoder.h> /* Octet Encoding Rules encoder */
#include <oer_encoder.h> /* Octet Encoding Rules encoder */ #include <oer_encoder.h> /* Octet Encoding Rules encoder */
#include <constraints.h> /* Subtype constraints support */ #endif
/* /*
* Free the structure according to its specification. * Free the structure according to its specification.
......
...@@ -341,7 +341,11 @@ main(int ac, char *av[]) { ...@@ -341,7 +341,11 @@ main(int ac, char *av[]) {
DEBUG("Encoded in %ld bytes of DER", (long)erv.encoded); DEBUG("Encoded in %ld bytes of DER", (long)erv.encoded);
break; break;
case OUT_OER: case OUT_OER:
#ifdef ASN_DISABLE_OER_SUPPORT
erv.encoded = -1;
#else
erv = oer_encode(pduType, structure, write_out, stdout); erv = oer_encode(pduType, structure, write_out, stdout);
#endif
if(erv.encoded < 0) { if(erv.encoded < 0) {
fprintf(stderr, "%s: Cannot convert %s into oER\n", name, fprintf(stderr, "%s: Cannot convert %s into oER\n", name,
pduType->name); pduType->name);
...@@ -350,7 +354,11 @@ main(int ac, char *av[]) { ...@@ -350,7 +354,11 @@ main(int ac, char *av[]) {
DEBUG("Encoded in %ld bytes of OER", (long)erv.encoded); DEBUG("Encoded in %ld bytes of OER", (long)erv.encoded);
break; break;
case OUT_PER: case OUT_PER:
#ifdef ASN_DISABLE_PER_SUPPORT
erv.encoded = -1;
#else
erv = uper_encode(pduType, structure, write_out, stdout); erv = uper_encode(pduType, structure, write_out, stdout);
#endif
if(erv.encoded < 0) { if(erv.encoded < 0) {
fprintf(stderr, fprintf(stderr,
"%s: Cannot convert %s into Unaligned PER\n", name, "%s: Cannot convert %s into Unaligned PER\n", name,
...@@ -670,14 +678,23 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na ...@@ -670,14 +678,23 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
(void **)&structure, i_bptr, i_size); (void **)&structure, i_bptr, i_size);
break; break;
case INP_OER: case INP_OER:
#ifdef ASN_DISABLE_OER_SUPPORT
rval.code = RC_FAIL;
rval.consumed = 0;
#else
rval = oer_decode(opt_codec_ctx, pduType, rval = oer_decode(opt_codec_ctx, pduType,
(void **)&structure, i_bptr, i_size); (void **)&structure, i_bptr, i_size);
#endif
break; break;
case INP_XER: case INP_XER:
rval = xer_decode(opt_codec_ctx, pduType, rval = xer_decode(opt_codec_ctx, pduType,
(void **)&structure, i_bptr, i_size); (void **)&structure, i_bptr, i_size);
break; break;
case INP_PER: case INP_PER:
#ifdef ASN_DISABLE_PER_SUPPORT
rval.code = RC_FAIL;
rval.consumed = 0;
#else
if(opt_nopad) if(opt_nopad)
rval = uper_decode(opt_codec_ctx, pduType, rval = uper_decode(opt_codec_ctx, pduType,
(void **)&structure, i_bptr, i_size, 0, (void **)&structure, i_bptr, i_size, 0,
...@@ -685,6 +702,7 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na ...@@ -685,6 +702,7 @@ data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file, const char *na
else else
rval = uper_decode_complete(opt_codec_ctx, pduType, rval = uper_decode_complete(opt_codec_ctx, pduType,
(void **)&structure, i_bptr, i_size); (void **)&structure, i_bptr, i_size);
#endif
switch(rval.code) { switch(rval.code) {
case RC_OK: case RC_OK:
/* Fall through */ /* Fall through */
......
...@@ -59,9 +59,6 @@ constraints.h constraints.c # Subtype constraints support ...@@ -59,9 +59,6 @@ constraints.h constraints.c # Subtype constraints support
xer_support.h xer_support.c # XML parsing xer_support.h xer_support.c # XML parsing
xer_decoder.h xer_decoder.c # XER decoding support xer_decoder.h xer_decoder.c # XER decoding support
xer_encoder.h xer_encoder.c # XER encoding support xer_encoder.h xer_encoder.c # XER encoding support
oer_decoder.h oer_decoder.c # OER decoding support
oer_encoder.h oer_encoder.c # OER encoding support
oer_support.h oer_support.c # OER support
per_support.h per_support.c # PER parsing per_support.h per_support.c # PER parsing
per_decoder.h per_decoder.c # PER decoding support per_decoder.h per_decoder.c # PER decoding support
per_encoder.h per_encoder.c # PER encoding support per_encoder.h per_encoder.c # PER encoding support
...@@ -71,6 +68,10 @@ CONVERTER: # THIS IS A SPECIAL SECTION ...@@ -71,6 +68,10 @@ CONVERTER: # THIS IS A SPECIAL SECTION
converter-sample.c # A default name for sample transcoder converter-sample.c # A default name for sample transcoder
CODEC-OER: # THIS IS A SPECIAL SECTION CODEC-OER: # THIS IS A SPECIAL SECTION
oer_decoder.h oer_decoder.c # OER decoding support
oer_encoder.h oer_encoder.c # OER encoding support
oer_support.h oer_support.c # OER support
OPEN_TYPE.h OPEN_TYPE_oer.c
INTEGER_oer.c INTEGER_oer.c
OCTET_STRING_oer.c OCTET_STRING_oer.c
NativeInteger_oer.c NativeInteger_oer.c
......
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