2 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
\r
3 * Redistribution and modifications are permitted subject to BSD license.
\r
5 #include <asn_internal.h>
\r
6 #include <constr_CHOICE.h>
\r
7 #include <per_opentype.h>
\r
10 * Number of bytes left for this structure.
\r
11 * (ctx->left) indicates the number of bytes _transferred_ for the structure.
\r
12 * (size) contains the number of bytes in the buffer passed.
\r
14 #define LEFT ((size<(size_t)ctx->left)?size:(size_t)ctx->left)
\r
17 * If the subprocessor function returns with an indication that it wants
\r
18 * more data, it may well be a fatal decoding problem, because the
\r
19 * size is constrained by the <TLV>'s L, even if the buffer size allows
\r
20 * reading more data.
\r
21 * For example, consider the buffer containing the following TLVs:
\r
22 * <T:5><L:1><V> <T:6>...
\r
23 * The TLV length clearly indicates that one byte is expected in V, but
\r
24 * if the V processor returns with "want more data" even if the buffer
\r
25 * contains way more data than the V processor have seen.
\r
27 #define SIZE_VIOLATION (ctx->left >= 0 && (size_t)ctx->left <= size)
\r
30 * This macro "eats" the part of the buffer which is definitely "consumed",
\r
31 * i.e. was correctly converted into local representation or rightfully skipped.
\r
34 #define ADVANCE(num_bytes) do { \
\r
35 size_t num = num_bytes; \
\r
36 ptr = ((const char *)ptr) + num;\
\r
38 if(ctx->left >= 0) \
\r
40 consumed_myself += num; \
\r
44 * Switch to the next phase of parsing.
\r
47 #define NEXT_PHASE(ctx) do { \
\r
53 * Return a standardized complex structure.
\r
56 #define RETURN(_code) do { \
\r
57 rval.code = _code; \
\r
58 rval.consumed = consumed_myself;\
\r
63 * See the definitions.
\r
65 static unsigned _fetch_present_idx(const void *struct_ptr, unsigned off,
\r
67 static void _set_present_idx(void *sptr, unsigned offset, unsigned size,
\r
69 static const void *_get_member_ptr(const asn_TYPE_descriptor_t *,
\r
70 const void *sptr, asn_TYPE_member_t **elm,
\r
74 * Tags are canonically sorted in the tag to member table.
\r
77 _search4tag(const void *ap, const void *bp) {
\r
78 const asn_TYPE_tag2member_t *a = (const asn_TYPE_tag2member_t *)ap;
\r
79 const asn_TYPE_tag2member_t *b = (const asn_TYPE_tag2member_t *)bp;
\r
81 int a_class = BER_TAG_CLASS(a->el_tag);
\r
82 int b_class = BER_TAG_CLASS(b->el_tag);
\r
84 if(a_class == b_class) {
\r
85 ber_tlv_tag_t a_value = BER_TAG_VALUE(a->el_tag);
\r
86 ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag);
\r
88 if(a_value == b_value)
\r
90 else if(a_value < b_value)
\r
94 } else if(a_class < b_class) {
\r
102 * The decoder of the CHOICE type.
\r
105 CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
\r
106 const asn_TYPE_descriptor_t *td, void **struct_ptr,
\r
107 const void *ptr, size_t size, int tag_mode) {
\r
109 * Bring closer parts of structure description.
\r
111 const asn_CHOICE_specifics_t *specs =
\r
112 (const asn_CHOICE_specifics_t *)td->specifics;
\r
113 asn_TYPE_member_t *elements = td->elements;
\r
116 * Parts of the structure being constructed.
\r
118 void *st = *struct_ptr; /* Target structure. */
\r
119 asn_struct_ctx_t *ctx; /* Decoder context */
\r
121 ber_tlv_tag_t tlv_tag; /* T from TLV */
\r
122 ssize_t tag_len; /* Length of TLV's T */
\r
123 asn_dec_rval_t rval; /* Return code from subparsers */
\r
125 ssize_t consumed_myself = 0; /* Consumed bytes from ptr */
\r
127 ASN_DEBUG("Decoding %s as CHOICE", td->name);
\r
130 * Create the target structure if it is not present already.
\r
133 st = *struct_ptr = CALLOC(1, specs->struct_size);
\r
140 * Restore parsing context.
\r
142 ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
\r
145 * Start to parse where left previously
\r
147 switch(ctx->phase) {
\r
151 * Check that the set of tags associated with given structure
\r
152 * perfectly fits our expectations.
\r
155 if(tag_mode || td->tags_count) {
\r
156 rval = ber_check_tags(opt_codec_ctx, td, ctx, ptr, size,
\r
157 tag_mode, -1, &ctx->left, 0);
\r
158 if(rval.code != RC_OK) {
\r
159 ASN_DEBUG("%s tagging check failed: %d",
\r
160 td->name, rval.code);
\r
164 if(ctx->left >= 0) {
\r
165 /* ?Substracted below! */
\r
166 ctx->left += rval.consumed;
\r
168 ADVANCE(rval.consumed);
\r
175 ASN_DEBUG("Structure consumes %ld bytes, buffer %ld",
\r
176 (long)ctx->left, (long)size);
\r
181 * Fetch the T from TLV.
\r
183 tag_len = ber_fetch_tag(ptr, LEFT, &tlv_tag);
\r
184 ASN_DEBUG("In %s CHOICE tag length %d", td->name, (int)tag_len);
\r
186 case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE);
\r
188 case -1: RETURN(RC_FAIL);
\r
192 const asn_TYPE_tag2member_t *t2m;
\r
193 asn_TYPE_tag2member_t key;
\r
195 key.el_tag = tlv_tag;
\r
196 t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
\r
197 specs->tag2el, specs->tag2el_count,
\r
198 sizeof(specs->tag2el[0]), _search4tag);
\r
201 * Found the element corresponding to the tag.
\r
204 ctx->step = t2m->el_no;
\r
206 } else if(specs->ext_start == -1) {
\r
207 ASN_DEBUG("Unexpected tag %s "
\r
208 "in non-extensible CHOICE %s",
\r
209 ber_tlv_tag_string(tlv_tag), td->name);
\r
212 /* Skip this tag */
\r
215 ASN_DEBUG("Skipping unknown tag %s",
\r
216 ber_tlv_tag_string(tlv_tag));
\r
218 skip = ber_skip_length(opt_codec_ctx,
\r
219 BER_TLV_CONSTRUCTED(ptr),
\r
220 (const char *)ptr + tag_len,
\r
224 case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE);
\r
226 case -1: RETURN(RC_FAIL);
\r
229 ADVANCE(skip + tag_len);
\r
237 * Read in the element.
\r
240 asn_TYPE_member_t *elm;/* CHOICE's element */
\r
241 void *memb_ptr; /* Pointer to the member */
\r
242 void **memb_ptr2; /* Pointer to that pointer */
\r
244 elm = &elements[ctx->step];
\r
247 * Compute the position of the member inside a structure,
\r
248 * and also a type of containment (it may be contained
\r
249 * as pointer or using inline inclusion).
\r
251 if(elm->flags & ATF_POINTER) {
\r
252 /* Member is a pointer to another structure */
\r
253 memb_ptr2 = (void **)((char *)st + elm->memb_offset);
\r
256 * A pointer to a pointer
\r
257 * holding the start of the structure
\r
259 memb_ptr = (char *)st + elm->memb_offset;
\r
260 memb_ptr2 = &memb_ptr;
\r
262 /* Set presence to be able to free it properly at any time */
\r
263 _set_present_idx(st, specs->pres_offset,
\r
264 specs->pres_size, ctx->step + 1);
\r
266 * Invoke the member fetch routine according to member's type
\r
268 rval = elm->type->op->ber_decoder(opt_codec_ctx, elm->type,
\r
269 memb_ptr2, ptr, LEFT, elm->tag_mode);
\r
270 switch(rval.code) {
\r
273 case RC_WMORE: /* More data expected */
\r
274 if(!SIZE_VIOLATION) {
\r
275 ADVANCE(rval.consumed);
\r
279 case RC_FAIL: /* Fatal error */
\r
281 } /* switch(rval) */
\r
283 ADVANCE(rval.consumed);
\r
290 ASN_DEBUG("CHOICE %s Leftover: %ld, size = %ld, tm=%d, tc=%d",
\r
291 td->name, (long)ctx->left, (long)size,
\r
292 tag_mode, td->tags_count);
\r
294 if(ctx->left > 0) {
\r
296 * The type must be fully decoded
\r
297 * by the CHOICE member-specific decoder.
\r
303 && !(tag_mode || td->tags_count)) {
\r
305 * This is an untagged CHOICE.
\r
306 * It doesn't contain nothing
\r
307 * except for the member itself, including all its tags.
\r
308 * The decoding is completed.
\r
315 * Read in the "end of data chunks"'s.
\r
317 while(ctx->left < 0) {
\r
320 tl = ber_fetch_tag(ptr, LEFT, &tlv_tag);
\r
322 case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE);
\r
324 case -1: RETURN(RC_FAIL);
\r
328 * Expected <0><0>...
\r
330 if(((const uint8_t *)ptr)[0] == 0) {
\r
336 } else if(((const uint8_t *)ptr)[1] == 0) {
\r
338 * Correctly finished with <0><0>.
\r
345 ASN_DEBUG("Unexpected continuation in %s",
\r
355 /* No meaningful work here */
\r
363 CHOICE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
\r
364 int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
\r
366 const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
\r
367 asn_TYPE_member_t *elm; /* CHOICE element */
\r
368 asn_enc_rval_t erval = {0,0,0};
\r
369 const void *memb_ptr;
\r
370 size_t computed_size = 0;
\r
373 if(!sptr) ASN__ENCODE_FAILED;
\r
375 ASN_DEBUG("%s %s as CHOICE",
\r
376 cb?"Encoding":"Estimating", td->name);
\r
378 present = _fetch_present_idx(sptr,
\r
379 specs->pres_offset, specs->pres_size);
\r
382 * If the structure was not initialized, it cannot be encoded:
\r
383 * can't deduce what to encode in the choice type.
\r
385 if(present == 0 || present > td->elements_count) {
\r
386 if(present == 0 && td->elements_count == 0) {
\r
387 /* The CHOICE is empty?! */
\r
389 ASN__ENCODED_OK(erval);
\r
391 ASN__ENCODE_FAILED;
\r
395 * Seek over the present member of the structure.
\r
397 elm = &td->elements[present-1];
\r
398 if(elm->flags & ATF_POINTER) {
\r
400 *(const void *const *)((const char *)sptr + elm->memb_offset);
\r
401 if(memb_ptr == 0) {
\r
402 if(elm->optional) {
\r
404 ASN__ENCODED_OK(erval);
\r
406 /* Mandatory element absent */
\r
407 ASN__ENCODE_FAILED;
\r
410 memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
\r
414 * If the CHOICE itself is tagged EXPLICIT:
\r
415 * T ::= [2] EXPLICIT CHOICE { ... }
\r
416 * Then emit the appropriate tags.
\r
418 if(tag_mode == 1 || td->tags_count) {
\r
420 * For this, we need to pre-compute the member.
\r
424 /* Encode member with its tag */
\r
425 erval = elm->type->op->der_encoder(elm->type, memb_ptr,
\r
426 elm->tag_mode, elm->tag, 0, 0);
\r
427 if(erval.encoded == -1)
\r
430 /* Encode CHOICE with parent or my own tag */
\r
431 ret = der_write_tags(td, erval.encoded, tag_mode, 1, tag,
\r
434 ASN__ENCODE_FAILED;
\r
435 computed_size += ret;
\r
439 * Encode the single underlying member.
\r
441 erval = elm->type->op->der_encoder(elm->type, memb_ptr,
\r
442 elm->tag_mode, elm->tag, cb, app_key);
\r
443 if(erval.encoded == -1)
\r
446 ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)",
\r
447 (long)erval.encoded, (long)computed_size);
\r
449 erval.encoded += computed_size;
\r
455 CHOICE_outmost_tag(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
\r
456 const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
\r
459 assert(tag_mode == 0); (void)tag_mode;
\r
460 assert(tag == 0); (void)tag;
\r
463 * Figure out which CHOICE element is encoded.
\r
465 present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
\r
467 if(present > 0 && present <= td->elements_count) {
\r
468 const asn_TYPE_member_t *elm = &td->elements[present-1];
\r
469 const void *memb_ptr;
\r
471 if(elm->flags & ATF_POINTER) {
\r
472 memb_ptr = *(const void * const *)
\r
473 ((const char *)ptr + elm->memb_offset);
\r
475 memb_ptr = (const void *)
\r
476 ((const char *)ptr + elm->memb_offset);
\r
479 return asn_TYPE_outmost_tag(elm->type, memb_ptr,
\r
480 elm->tag_mode, elm->tag);
\r
482 return (ber_tlv_tag_t)-1;
\r
487 CHOICE_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
\r
488 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
\r
489 const asn_CHOICE_specifics_t *specs =
\r
490 (const asn_CHOICE_specifics_t *)td->specifics;
\r
494 ASN__CTFAIL(app_key, td, sptr,
\r
495 "%s: value not given (%s:%d)",
\r
496 td->name, __FILE__, __LINE__);
\r
501 * Figure out which CHOICE element is encoded.
\r
503 present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
\r
504 if(present > 0 && present <= td->elements_count) {
\r
505 asn_TYPE_member_t *elm = &td->elements[present-1];
\r
506 const void *memb_ptr;
\r
508 if(elm->flags & ATF_POINTER) {
\r
509 memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
\r
513 ASN__CTFAIL(app_key, td, sptr,
\r
514 "%s: mandatory CHOICE element %s absent (%s:%d)",
\r
515 td->name, elm->name, __FILE__, __LINE__);
\r
519 memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
\r
522 if(elm->encoding_constraints.general_constraints) {
\r
523 return elm->encoding_constraints.general_constraints(elm->type, memb_ptr,
\r
524 ctfailcb, app_key);
\r
526 return elm->type->encoding_constraints.general_constraints(elm->type,
\r
527 memb_ptr, ctfailcb, app_key);
\r
530 ASN__CTFAIL(app_key, td, sptr,
\r
531 "%s: no CHOICE element given (%s:%d)",
\r
532 td->name, __FILE__, __LINE__);
\r
538 #define XER_ADVANCE(num_bytes) do { \
\r
539 size_t num = num_bytes; \
\r
540 buf_ptr = (const void *)(((const char *)buf_ptr) + num); \
\r
542 consumed_myself += num; \
\r
546 * Decode the XER (XML) data.
\r
549 CHOICE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
\r
550 const asn_TYPE_descriptor_t *td, void **struct_ptr,
\r
551 const char *opt_mname, const void *buf_ptr, size_t size) {
\r
553 * Bring closer parts of structure description.
\r
555 const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
\r
556 const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
\r
559 * Parts of the structure being constructed.
\r
561 void *st = *struct_ptr; /* Target structure. */
\r
562 asn_struct_ctx_t *ctx; /* Decoder context */
\r
564 asn_dec_rval_t rval; /* Return value of a decoder */
\r
565 ssize_t consumed_myself = 0; /* Consumed bytes from ptr */
\r
566 size_t edx; /* Element index */
\r
569 * Create the target structure if it is not present already.
\r
572 st = *struct_ptr = CALLOC(1, specs->struct_size);
\r
573 if(st == 0) RETURN(RC_FAIL);
\r
577 * Restore parsing context.
\r
579 ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
\r
580 if(ctx->phase == 0 && !*xml_tag)
\r
581 ctx->phase = 1; /* Skip the outer tag checking phase */
\r
584 * Phases of XER/XML processing:
\r
585 * Phase 0: Check that the opening tag matches our expectations.
\r
586 * Phase 1: Processing body and reacting on closing tag.
\r
587 * Phase 2: Processing inner type.
\r
588 * Phase 3: Only waiting for closing tag.
\r
589 * Phase 4: Skipping unknown extensions.
\r
590 * Phase 5: PHASED OUT
\r
592 for(edx = ctx->step; ctx->phase <= 4;) {
\r
593 pxer_chunk_type_e ch_type; /* XER chunk type */
\r
594 ssize_t ch_size; /* Chunk size */
\r
595 xer_check_tag_e tcv; /* Tag check value */
\r
596 asn_TYPE_member_t *elm;
\r
599 * Go inside the member.
\r
601 if(ctx->phase == 2) {
\r
602 asn_dec_rval_t tmprval;
\r
603 void *memb_ptr; /* Pointer to the member */
\r
604 void **memb_ptr2; /* Pointer to that pointer */
\r
605 unsigned old_present;
\r
607 elm = &td->elements[edx];
\r
609 if(elm->flags & ATF_POINTER) {
\r
610 /* Member is a pointer to another structure */
\r
611 memb_ptr2 = (void **)((char *)st
\r
612 + elm->memb_offset);
\r
614 memb_ptr = (char *)st + elm->memb_offset;
\r
615 memb_ptr2 = &memb_ptr;
\r
618 /* Start/Continue decoding the inner member */
\r
619 tmprval = elm->type->op->xer_decoder(opt_codec_ctx,
\r
620 elm->type, memb_ptr2, elm->name,
\r
622 XER_ADVANCE(tmprval.consumed);
\r
623 ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d",
\r
624 elm->type->name, tmprval.code);
\r
625 old_present = _fetch_present_idx(st,
\r
626 specs->pres_offset, specs->pres_size);
\r
627 assert(old_present == 0 || old_present == edx + 1);
\r
628 /* Record what we've got */
\r
629 _set_present_idx(st,
\r
630 specs->pres_offset, specs->pres_size, edx + 1);
\r
631 if(tmprval.code != RC_OK)
\r
632 RETURN(tmprval.code);
\r
637 /* No need to wait for closing tag; special mode. */
\r
638 if(ctx->phase == 3 && !*xml_tag) {
\r
639 ctx->phase = 5; /* Phase out */
\r
644 * Get the next part of the XML stream.
\r
646 ch_size = xer_next_token(&ctx->context, buf_ptr, size, &ch_type);
\r
647 if(ch_size == -1) {
\r
653 case PXER_COMMENT: /* Got XML comment */
\r
654 case PXER_TEXT: /* Ignore free-standing text */
\r
655 XER_ADVANCE(ch_size); /* Skip silently */
\r
658 break; /* Check the rest down there */
\r
662 tcv = xer_check_tag(buf_ptr, ch_size, xml_tag);
\r
663 ASN_DEBUG("XER/CHOICE checked [%c%c%c%c] vs [%s], tcv=%d",
\r
664 ch_size>0?((const uint8_t *)buf_ptr)[0]:'?',
\r
665 ch_size>1?((const uint8_t *)buf_ptr)[1]:'?',
\r
666 ch_size>2?((const uint8_t *)buf_ptr)[2]:'?',
\r
667 ch_size>3?((const uint8_t *)buf_ptr)[3]:'?',
\r
670 /* Skip the extensions section */
\r
671 if(ctx->phase == 4) {
\r
672 ASN_DEBUG("skip_unknown(%d, %ld)",
\r
673 tcv, (long)ctx->left);
\r
674 switch(xer_skip_unknown(tcv, &ctx->left)) {
\r
682 XER_ADVANCE(ch_size);
\r
692 break; /* No CHOICE? */
\r
694 if(ctx->phase != 3)
\r
696 XER_ADVANCE(ch_size);
\r
697 ctx->phase = 5; /* Phase out */
\r
700 if(ctx->phase == 0) {
\r
701 XER_ADVANCE(ch_size);
\r
702 ctx->phase = 1; /* Processing body phase */
\r
706 case XCT_UNKNOWN_OP:
\r
707 case XCT_UNKNOWN_BO:
\r
709 if(ctx->phase != 1)
\r
710 break; /* Really unexpected */
\r
713 * Search which inner member corresponds to this tag.
\r
715 for(edx = 0; edx < td->elements_count; edx++) {
\r
716 elm = &td->elements[edx];
\r
717 tcv = xer_check_tag(buf_ptr,ch_size,elm->name);
\r
722 * Process this member.
\r
727 case XCT_UNKNOWN_OP:
\r
728 case XCT_UNKNOWN_BO:
\r
731 edx = td->elements_count;
\r
732 break; /* Phase out */
\r
736 if(edx != td->elements_count)
\r
739 /* It is expected extension */
\r
740 if(specs->ext_start != -1) {
\r
741 ASN_DEBUG("Got anticipated extension");
\r
743 * Check for (XCT_BOTH or XCT_UNKNOWN_BO)
\r
744 * By using a mask. Only record a pure
\r
747 if(tcv & XCT_CLOSING) {
\r
748 /* Found </extension> without body */
\r
749 ctx->phase = 3; /* Terminating */
\r
752 ctx->phase = 4; /* Skip ...'s */
\r
754 XER_ADVANCE(ch_size);
\r
763 ASN_DEBUG("Unexpected XML tag [%c%c%c%c] in CHOICE [%s]"
\r
764 " (ph=%d, tag=%s)",
\r
765 ch_size>0?((const uint8_t *)buf_ptr)[0]:'?',
\r
766 ch_size>1?((const uint8_t *)buf_ptr)[1]:'?',
\r
767 ch_size>2?((const uint8_t *)buf_ptr)[2]:'?',
\r
768 ch_size>3?((const uint8_t *)buf_ptr)[3]:'?',
\r
769 td->name, ctx->phase, xml_tag);
\r
773 ctx->phase = 5; /* Phase out, just in case */
\r
779 CHOICE_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
\r
780 enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
\r
782 const asn_CHOICE_specifics_t *specs =
\r
783 (const asn_CHOICE_specifics_t *)td->specifics;
\r
784 asn_enc_rval_t er = {0,0,0};
\r
785 unsigned present = 0;
\r
788 ASN__ENCODE_FAILED;
\r
791 * Figure out which CHOICE element is encoded.
\r
793 present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
\r
795 if(present == 0 || present > td->elements_count) {
\r
796 ASN__ENCODE_FAILED;
\r
798 asn_enc_rval_t tmper = {0,0,0};
\r
799 asn_TYPE_member_t *elm = &td->elements[present-1];
\r
800 const void *memb_ptr = NULL;
\r
801 const char *mname = elm->name;
\r
802 unsigned int mlen = strlen(mname);
\r
804 if(elm->flags & ATF_POINTER) {
\r
806 *(const void *const *)((const char *)sptr + elm->memb_offset);
\r
807 if(!memb_ptr) ASN__ENCODE_FAILED;
\r
809 memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
\r
814 if(!(flags & XER_F_CANONICAL)) ASN__TEXT_INDENT(1, ilevel);
\r
815 ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
\r
817 tmper = elm->type->op->xer_encoder(elm->type, memb_ptr,
\r
818 ilevel + 1, flags, cb, app_key);
\r
819 if(tmper.encoded == -1) return tmper;
\r
820 er.encoded += tmper.encoded;
\r
822 ASN__CALLBACK3("</", 2, mname, mlen, ">", 1);
\r
825 if(!(flags & XER_F_CANONICAL)) ASN__TEXT_INDENT(1, ilevel - 1);
\r
827 ASN__ENCODED_OK(er);
\r
829 ASN__ENCODE_FAILED;
\r
833 CHOICE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
\r
834 const asn_TYPE_descriptor_t *td,
\r
835 const asn_per_constraints_t *constraints, void **sptr,
\r
836 asn_per_data_t *pd) {
\r
837 const asn_CHOICE_specifics_t *specs =
\r
838 (const asn_CHOICE_specifics_t *)td->specifics;
\r
840 const asn_per_constraint_t *ct;
\r
841 asn_TYPE_member_t *elm; /* CHOICE's element */
\r
847 if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
\r
848 ASN__DECODE_FAILED;
\r
851 * Create the target structure if it is not present already.
\r
854 st = *sptr = CALLOC(1, specs->struct_size);
\r
855 if(!st) ASN__DECODE_FAILED;
\r
858 if(constraints) ct = &constraints->value;
\r
859 else if(td->encoding_constraints.per_constraints) ct = &td->encoding_constraints.per_constraints->value;
\r
862 if(ct && ct->flags & APC_EXTENSIBLE) {
\r
863 value = per_get_few_bits(pd, 1);
\r
864 if(value < 0) ASN__DECODE_STARVED;
\r
865 if(value) ct = 0; /* Not restricted */
\r
868 if(ct && ct->range_bits >= 0) {
\r
869 value = per_get_few_bits(pd, ct->range_bits);
\r
870 if(value < 0) ASN__DECODE_STARVED;
\r
871 ASN_DEBUG("CHOICE %s got index %d in range %d",
\r
872 td->name, value, ct->range_bits);
\r
873 if(value > ct->upper_bound)
\r
874 ASN__DECODE_FAILED;
\r
876 if(specs->ext_start == -1)
\r
877 ASN__DECODE_FAILED;
\r
878 value = uper_get_nsnnwn(pd);
\r
879 if(value < 0) ASN__DECODE_STARVED;
\r
880 value += specs->ext_start;
\r
881 if((unsigned)value >= td->elements_count)
\r
882 ASN__DECODE_FAILED;
\r
885 /* Adjust if canonical order is different from natural order */
\r
886 if(specs->from_canonical_order) {
\r
887 ASN_DEBUG("CHOICE presence from wire %d", value);
\r
888 value = specs->from_canonical_order[value];
\r
889 ASN_DEBUG("CHOICE presence index effective %d", value);
\r
892 /* Set presence to be able to free it later */
\r
893 _set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
\r
895 elm = &td->elements[value];
\r
896 if(elm->flags & ATF_POINTER) {
\r
897 /* Member is a pointer to another structure */
\r
898 memb_ptr2 = (void **)((char *)st + elm->memb_offset);
\r
900 memb_ptr = (char *)st + elm->memb_offset;
\r
901 memb_ptr2 = &memb_ptr;
\r
903 ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name);
\r
905 if(ct && ct->range_bits >= 0) {
\r
906 rv = elm->type->op->uper_decoder(opt_codec_ctx, elm->type,
\r
907 elm->encoding_constraints.per_constraints, memb_ptr2, pd);
\r
909 rv = uper_open_type_get(opt_codec_ctx, elm->type,
\r
910 elm->encoding_constraints.per_constraints, memb_ptr2, pd);
\r
913 if(rv.code != RC_OK)
\r
914 ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d",
\r
915 elm->name, td->name, rv.code);
\r
920 CHOICE_encode_uper(const asn_TYPE_descriptor_t *td,
\r
921 const asn_per_constraints_t *constraints, const void *sptr,
\r
922 asn_per_outp_t *po) {
\r
923 const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
\r
924 asn_TYPE_member_t *elm; /* CHOICE's element */
\r
925 const asn_per_constraint_t *ct;
\r
926 const void *memb_ptr;
\r
930 if(!sptr) ASN__ENCODE_FAILED;
\r
932 ASN_DEBUG("Encoding %s as CHOICE", td->name);
\r
934 if(constraints) ct = &constraints->value;
\r
935 else if(td->encoding_constraints.per_constraints)
\r
936 ct = &td->encoding_constraints.per_constraints->value;
\r
939 present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
\r
942 * If the structure was not initialized properly, it cannot be encoded:
\r
943 * can't deduce what to encode in the choice type.
\r
945 if(present == 0 || present > td->elements_count)
\r
946 ASN__ENCODE_FAILED;
\r
950 ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present);
\r
952 /* Adjust if canonical order is different from natural order */
\r
953 if(specs->to_canonical_order)
\r
954 present_enc = specs->to_canonical_order[present];
\r
956 present_enc = present;
\r
958 if(ct && ct->range_bits >= 0) {
\r
959 if(present_enc < ct->lower_bound
\r
960 || present_enc > ct->upper_bound) {
\r
961 if(ct->flags & APC_EXTENSIBLE) {
\r
963 "CHOICE member %d (enc %d) is an extension (%ld..%ld)",
\r
964 present, present_enc, ct->lower_bound, ct->upper_bound);
\r
965 if(per_put_few_bits(po, 1, 1))
\r
966 ASN__ENCODE_FAILED;
\r
968 ASN__ENCODE_FAILED;
\r
973 if(ct && ct->flags & APC_EXTENSIBLE) {
\r
974 ASN_DEBUG("CHOICE member %d (enc %d) is not an extension (%ld..%ld)",
\r
975 present, present_enc, ct->lower_bound, ct->upper_bound);
\r
976 if(per_put_few_bits(po, 0, 1))
\r
977 ASN__ENCODE_FAILED;
\r
981 elm = &td->elements[present];
\r
982 ASN_DEBUG("CHOICE member \"%s\" %d (as %d)", elm->name, present,
\r
984 if(elm->flags & ATF_POINTER) {
\r
985 /* Member is a pointer to another structure */
\r
987 *(const void *const *)((const char *)sptr + elm->memb_offset);
\r
988 if(!memb_ptr) ASN__ENCODE_FAILED;
\r
990 memb_ptr = (const char *)sptr + elm->memb_offset;
\r
993 if(ct && ct->range_bits >= 0) {
\r
994 if(per_put_few_bits(po, present_enc, ct->range_bits))
\r
995 ASN__ENCODE_FAILED;
\r
997 return elm->type->op->uper_encoder(
\r
998 elm->type, elm->encoding_constraints.per_constraints, memb_ptr, po);
\r
1000 asn_enc_rval_t rval = {0,0,0};
\r
1001 if(specs->ext_start == -1) ASN__ENCODE_FAILED;
\r
1002 if(uper_put_nsnnwn(po, present_enc - specs->ext_start))
\r
1003 ASN__ENCODE_FAILED;
\r
1004 if(uper_open_type_put(elm->type,
\r
1005 elm->encoding_constraints.per_constraints,
\r
1007 ASN__ENCODE_FAILED;
\r
1009 ASN__ENCODED_OK(rval);
\r
1014 CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
\r
1015 const asn_TYPE_descriptor_t *td,
\r
1016 const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
\r
1017 const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
\r
1018 asn_dec_rval_t rv;
\r
1019 const asn_per_constraint_t *ct;
\r
1020 asn_TYPE_member_t *elm; /* CHOICE's element */
\r
1026 if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
\r
1027 ASN__DECODE_FAILED;
\r
1030 * Create the target structure if it is not present already.
\r
1033 st = *sptr = CALLOC(1, specs->struct_size);
\r
1034 if(!st) ASN__DECODE_FAILED;
\r
1037 if(constraints) ct = &constraints->value;
\r
1038 else if(td->encoding_constraints.per_constraints)
\r
1039 ct = &td->encoding_constraints.per_constraints->value;
\r
1042 if(ct && ct->flags & APC_EXTENSIBLE) {
\r
1043 value = per_get_few_bits(pd, 1);
\r
1044 if(value < 0) ASN__DECODE_STARVED;
\r
1045 if(value) ct = 0; /* Not restricted */
\r
1048 if(ct && ct->range_bits >= 0) {
\r
1049 value = per_get_few_bits(pd, ct->range_bits);
\r
1050 if(value < 0) ASN__DECODE_STARVED;
\r
1051 ASN_DEBUG("CHOICE %s got index %d in range %d",
\r
1052 td->name, value, ct->range_bits);
\r
1053 if(value > ct->upper_bound)
\r
1054 ASN__DECODE_FAILED;
\r
1056 if(specs->ext_start == -1)
\r
1057 ASN__DECODE_FAILED;
\r
1058 value = uper_get_nsnnwn(pd);
\r
1059 if(value < 0) ASN__DECODE_STARVED;
\r
1060 value += specs->ext_start;
\r
1061 if((unsigned)value >= td->elements_count)
\r
1062 ASN__DECODE_FAILED;
\r
1065 /* Adjust if canonical order is different from natural order */
\r
1066 if(specs->from_canonical_order)
\r
1067 value = specs->from_canonical_order[value];
\r
1069 /* Set presence to be able to free it later */
\r
1070 _set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
\r
1072 elm = &td->elements[value];
\r
1073 if(elm->flags & ATF_POINTER) {
\r
1074 /* Member is a pointer to another structure */
\r
1075 memb_ptr2 = (void **)((char *)st + elm->memb_offset);
\r
1077 memb_ptr = (char *)st + elm->memb_offset;
\r
1078 memb_ptr2 = &memb_ptr;
\r
1080 ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name);
\r
1082 if(ct && ct->range_bits >= 0) {
\r
1083 rv = elm->type->op->aper_decoder(opt_codec_ctx, elm->type,
\r
1084 elm->encoding_constraints.per_constraints, memb_ptr2, pd);
\r
1086 rv = uper_open_type_get(opt_codec_ctx, elm->type,
\r
1087 elm->encoding_constraints.per_constraints, memb_ptr2, pd);
\r
1090 if(rv.code != RC_OK)
\r
1091 ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d",
\r
1092 elm->name, td->name, rv.code);
\r
1097 CHOICE_encode_aper(const asn_TYPE_descriptor_t *td,
\r
1098 const asn_per_constraints_t *constraints,
\r
1099 const void *sptr, asn_per_outp_t *po) {
\r
1100 const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
\r
1101 const asn_TYPE_member_t *elm; /* CHOICE's element */
\r
1102 const asn_per_constraint_t *ct;
\r
1103 const void *memb_ptr;
\r
1106 if(!sptr) ASN__ENCODE_FAILED;
\r
1108 ASN_DEBUG("Encoding %s as CHOICE using ALIGNED PER", td->name);
\r
1110 if(constraints) ct = &constraints->value;
\r
1111 else if(td->encoding_constraints.per_constraints)
\r
1112 ct = &td->encoding_constraints.per_constraints->value;
\r
1115 present = _fetch_present_idx(sptr,
\r
1116 specs->pres_offset, specs->pres_size);
\r
1119 * If the structure was not initialized properly, it cannot be encoded:
\r
1120 * can't deduce what to encode in the choice type.
\r
1122 if(present <= 0 || (unsigned)present > td->elements_count)
\r
1123 ASN__ENCODE_FAILED;
\r
1127 /* Adjust if canonical order is different from natural order */
\r
1128 if(specs->to_canonical_order)
\r
1129 present = specs->to_canonical_order[present];
\r
1131 ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present);
\r
1133 if(ct && ct->range_bits >= 0) {
\r
1134 if(present < ct->lower_bound
\r
1135 || present > ct->upper_bound) {
\r
1136 if(ct->flags & APC_EXTENSIBLE) {
\r
1137 if(per_put_few_bits(po, 1, 1))
\r
1138 ASN__ENCODE_FAILED;
\r
1140 ASN__ENCODE_FAILED;
\r
1145 if(ct && ct->flags & APC_EXTENSIBLE) {
\r
1146 if(per_put_few_bits(po, 0, 1))
\r
1147 ASN__ENCODE_FAILED;
\r
1150 elm = &td->elements[present];
\r
1151 if(elm->flags & ATF_POINTER) {
\r
1152 /* Member is a pointer to another structure */
\r
1153 memb_ptr = *(const void *const *)((const char *)sptr + elm->memb_offset);
\r
1154 if(!memb_ptr) ASN__ENCODE_FAILED;
\r
1156 memb_ptr = (const char *)sptr + elm->memb_offset;
\r
1159 if(ct && ct->range_bits >= 0) {
\r
1160 if(per_put_few_bits(po, present, ct->range_bits))
\r
1161 ASN__ENCODE_FAILED;
\r
1163 return elm->type->op->aper_encoder(elm->type, elm->encoding_constraints.per_constraints,
\r
1166 asn_enc_rval_t rval = {0,0,0};
\r
1167 if(specs->ext_start == -1)
\r
1168 ASN__ENCODE_FAILED;
\r
1170 if(aper_put_nsnnwn(po, ct->range_bits, present - specs->ext_start))
\r
1171 ASN__ENCODE_FAILED;
\r
1173 if(aper_open_type_put(elm->type, elm->encoding_constraints.per_constraints,
\r
1175 ASN__ENCODE_FAILED;
\r
1177 ASN__ENCODED_OK(rval);
\r
1182 CHOICE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
\r
1183 asn_app_consume_bytes_f *cb, void *app_key) {
\r
1184 const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
\r
1187 if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
\r
1190 * Figure out which CHOICE element is encoded.
\r
1192 present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
\r
1195 * Print that element.
\r
1197 if(present > 0 && present <= td->elements_count) {
\r
1198 asn_TYPE_member_t *elm = &td->elements[present-1];
\r
1199 const void *memb_ptr;
\r
1201 if(elm->flags & ATF_POINTER) {
\r
1202 memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
\r
1203 if(!memb_ptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
\r
1205 memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
\r
1208 /* Print member's name and stuff */
\r
1210 if(cb(elm->name, strlen(elm->name), app_key) < 0
\r
1211 || cb(": ", 2, app_key) < 0)
\r
1215 return elm->type->op->print_struct(elm->type, memb_ptr, ilevel,
\r
1218 return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
\r
1223 CHOICE_free(const asn_TYPE_descriptor_t *td, void *ptr,
\r
1224 enum asn_struct_free_method method) {
\r
1225 const asn_CHOICE_specifics_t *specs =
\r
1226 (const asn_CHOICE_specifics_t *)td->specifics;
\r
1232 ASN_DEBUG("Freeing %s as CHOICE", td->name);
\r
1235 * Figure out which CHOICE element is encoded.
\r
1237 present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
\r
1240 * Free that element.
\r
1242 if(present > 0 && present <= td->elements_count) {
\r
1243 asn_TYPE_member_t *elm = &td->elements[present-1];
\r
1246 if(elm->flags & ATF_POINTER) {
\r
1247 memb_ptr = *(void **)((char *)ptr + elm->memb_offset);
\r
1249 ASN_STRUCT_FREE(*elm->type, memb_ptr);
\r
1251 memb_ptr = (void *)((char *)ptr + elm->memb_offset);
\r
1252 ASN_STRUCT_FREE_CONTENTS_ONLY(*elm->type, memb_ptr);
\r
1257 case ASFM_FREE_EVERYTHING:
\r
1260 case ASFM_FREE_UNDERLYING:
\r
1262 case ASFM_FREE_UNDERLYING_AND_RESET:
\r
1263 memset(ptr, 0, specs->struct_size);
\r
1270 * The following functions functions offer protection against -fshort-enums,
\r
1271 * compatible with little- and big-endian machines.
\r
1272 * If assertion is triggered, either disable -fshort-enums, or add an entry
\r
1273 * here with the ->pres_size of your target stracture.
\r
1274 * Unless the target structure is packed, the ".present" member
\r
1275 * is guaranteed to be aligned properly. ASN.1 compiler itself does not
\r
1276 * produce packed code.
\r
1279 _fetch_present_idx(const void *struct_ptr, unsigned pres_offset,
\r
1280 unsigned pres_size) {
\r
1281 const void *present_ptr;
\r
1284 present_ptr = ((const char *)struct_ptr) + pres_offset;
\r
1286 switch(pres_size) {
\r
1287 case sizeof(int): present = *(const unsigned int *)present_ptr; break;
\r
1288 case sizeof(short): present = *(const unsigned short *)present_ptr; break;
\r
1289 case sizeof(char): present = *(const unsigned char *)present_ptr; break;
\r
1291 /* ANSI C mandates enum to be equivalent to integer */
\r
1292 assert(pres_size != sizeof(int));
\r
1293 return 0; /* If not aborted, pass back safe value */
\r
1300 _set_present_idx(void *struct_ptr, unsigned pres_offset, unsigned pres_size,
\r
1301 unsigned present) {
\r
1302 void *present_ptr;
\r
1303 present_ptr = ((char *)struct_ptr) + pres_offset;
\r
1305 switch(pres_size) {
\r
1306 case sizeof(int): *(unsigned int *)present_ptr = present; break;
\r
1307 case sizeof(short): *(unsigned short *)present_ptr = present; break;
\r
1308 case sizeof(char): *(unsigned char *)present_ptr = present; break;
\r
1310 /* ANSI C mandates enum to be equivalent to integer */
\r
1311 assert(pres_size != sizeof(int));
\r
1315 static const void *
\r
1316 _get_member_ptr(const asn_TYPE_descriptor_t *td, const void *sptr,
\r
1317 asn_TYPE_member_t **elm_ptr, unsigned *present_out) {
\r
1318 const asn_CHOICE_specifics_t *specs =
\r
1319 (const asn_CHOICE_specifics_t *)td->specifics;
\r
1329 * Figure out which CHOICE element is encoded.
\r
1331 present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
\r
1332 *present_out = present;
\r
1335 * The presence index is intentionally 1-based to avoid
\r
1336 * treating zeroed structure as a valid one.
\r
1338 if(present > 0 && present <= td->elements_count) {
\r
1339 asn_TYPE_member_t *const elm = &td->elements[present - 1];
\r
1340 const void *memb_ptr;
\r
1342 if(elm->flags & ATF_POINTER) {
\r
1344 *(const void *const *)((const char *)sptr + elm->memb_offset);
\r
1346 memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
\r
1358 CHOICE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) {
\r
1359 asn_TYPE_member_t *aelm;
\r
1360 asn_TYPE_member_t *belm;
\r
1361 unsigned apresent = 0;
\r
1362 unsigned bpresent = 0;
\r
1363 const void *amember = _get_member_ptr(td, aptr, &aelm, &apresent);
\r
1364 const void *bmember = _get_member_ptr(td, bptr, &belm, &bpresent);
\r
1366 if(amember && bmember) {
\r
1367 if(apresent == bpresent) {
\r
1368 assert(aelm == belm);
\r
1369 return aelm->type->op->compare_struct(aelm->type, amember, bmember);
\r
1370 } else if(apresent < bpresent) {
\r
1375 } else if(!amember) {
\r
1383 * Return the 1-based choice variant presence index.
\r
1384 * Returns 0 in case of error.
\r
1387 CHOICE_variant_get_presence(const asn_TYPE_descriptor_t *td, const void *sptr) {
\r
1388 const asn_CHOICE_specifics_t *specs =
\r
1389 (const asn_CHOICE_specifics_t *)td->specifics;
\r
1390 return _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
\r
1394 * Sets or resets the 1-based choice variant presence index.
\r
1395 * In case a previous index is not zero, the currently selected structure
\r
1396 * member is freed and zeroed-out first.
\r
1397 * Returns 0 on success and -1 on error.
\r
1400 CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td, void *sptr,
\r
1401 unsigned present) {
\r
1402 const asn_CHOICE_specifics_t *specs =
\r
1403 (const asn_CHOICE_specifics_t *)td->specifics;
\r
1404 unsigned old_present;
\r
1410 if(present > td->elements_count)
\r
1414 _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
\r
1415 if(present == old_present)
\r
1418 if(old_present != 0) {
\r
1419 assert(old_present <= td->elements_count);
\r
1420 ASN_STRUCT_RESET(*td, sptr);
\r
1423 _set_present_idx(sptr, specs->pres_offset, specs->pres_size, present);
\r
1429 asn_random_fill_result_t
\r
1430 CHOICE_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
\r
1431 const asn_encoding_constraints_t *constr,
\r
1432 size_t max_length) {
\r
1433 const asn_CHOICE_specifics_t *specs =
\r
1434 (const asn_CHOICE_specifics_t *)td->specifics;
\r
1435 asn_random_fill_result_t res;
\r
1436 asn_random_fill_result_t result_failed = {ARFILL_FAILED, 0};
\r
1437 asn_random_fill_result_t result_skipped = {ARFILL_SKIPPED, 0};
\r
1438 const asn_TYPE_member_t *elm;
\r
1440 void *memb_ptr; /* Pointer to the member */
\r
1441 void **memb_ptr2; /* Pointer to that pointer */
\r
1444 if(max_length == 0) return result_skipped;
\r
1449 st = CALLOC(1, specs->struct_size);
\r
1451 return result_failed;
\r
1455 present = asn_random_between(1, td->elements_count);
\r
1456 elm = &td->elements[present - 1];
\r
1458 if(elm->flags & ATF_POINTER) {
\r
1459 /* Member is a pointer to another structure */
\r
1460 memb_ptr2 = (void **)((char *)st + elm->memb_offset);
\r
1462 memb_ptr = (char *)st + elm->memb_offset;
\r
1463 memb_ptr2 = &memb_ptr;
\r
1466 res = elm->type->op->random_fill(elm->type, memb_ptr2,
\r
1467 &elm->encoding_constraints, max_length);
\r
1468 _set_present_idx(st, specs->pres_offset, specs->pres_size, present);
\r
1469 if(res.code == ARFILL_OK) {
\r
1473 ASN_STRUCT_RESET(*td, st);
\r
1475 ASN_STRUCT_FREE(*td, st);
\r
1483 asn_TYPE_operation_t asn_OP_CHOICE = {
\r
1487 CHOICE_decode_ber,
\r
1488 CHOICE_encode_der,
\r
1489 CHOICE_decode_xer,
\r
1490 CHOICE_encode_xer,
\r
1491 #ifdef ASN_DISABLE_OER_SUPPORT
\r
1495 CHOICE_decode_oer,
\r
1496 CHOICE_encode_oer,
\r
1497 #endif /* ASN_DISABLE_OER_SUPPORT */
\r
1498 #ifdef ASN_DISABLE_PER_SUPPORT
\r
1504 CHOICE_decode_uper,
\r
1505 CHOICE_encode_uper,
\r
1506 CHOICE_decode_aper,
\r
1507 CHOICE_encode_aper,
\r
1508 #endif /* ASN_DISABLE_PER_SUPPORT */
\r
1509 CHOICE_random_fill,
\r
1510 CHOICE_outmost_tag
\r