Commit 3e478edc authored by Lev Walkin's avatar Lev Walkin

removed special case

parent 302f9fd9
......@@ -169,24 +169,22 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* From the place where we've left it previously,
* try to decode the next member from the list of
* this structure's elements.
* (ctx->step) stores the member being processed
* between invocations and the microphase {0,1} of parsing
* that member:
* step = (2 * <member_number> + <microphase>).
* Note, however, that the elements in BER may arrive out of
* Note that elements in BER may arrive out of
* order, yet DER mandates that they shall arive in the
* canonical order of their tags. So, there is a room
* for optimization.
*/
for(edx = (ctx->step >> 1); edx < td->elements_count;
ctx->step = (ctx->step & ~1) + 2,
edx = (ctx->step >> 1)) {
for(;; ctx->step = 0) {
asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key;
void *memb_ptr; /* Pointer to the member */
void **memb_ptr2; /* Pointer to that pointer */
ssize_t tag_len; /* Length of TLV's T */
if(ctx->step & 1)
if(ctx->step & 1) {
edx = ctx->step >> 1;
goto microphase2;
}
/*
* MICROPHASE 1: Synchronize decoding.
......@@ -226,16 +224,6 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
}
}
if(BER_TAGS_EQUAL(tlv_tag, elements[edx].tag)) {
/*
* The elements seem to go in order.
* This is not particularly strange,
* but is not strongly anticipated either.
*/
} else {
asn_TYPE_tag2member_t *t2m;
asn_TYPE_tag2member_t key;
key.el_tag = tlv_tag;
(void *)t2m = bsearch(&key,
specs->tag2el, specs->tag2el_count,
......@@ -245,7 +233,9 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* Found the element corresponding to the tag.
*/
edx = t2m->el_no;
ctx->step = 2 * edx;
ctx->step = (edx << 1) + 1;
ASN_DEBUG("Got tag %s (%s), edx %d",
ber_tlv_tag_string(tlv_tag), td->name, edx);
} else if(specs->extensible == 0) {
ASN_DEBUG("Unexpected tag %s "
"in non-extensible SET %s",
......@@ -269,16 +259,12 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
}
ADVANCE(skip + tag_len);
ctx->step -= 2;
edx--;
continue; /* Try again with the next tag */
}
}
/*
* MICROPHASE 2: Invoke the member-specific decoder.
*/
ctx->step |= 1; /* Confirm entering next microphase */
microphase2:
/*
......@@ -375,8 +361,9 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(specs->extensible == 0 || ctx->phase == 4) {
ASN_DEBUG("Unexpected continuation "
"of a non-extensible type %s",
td->name);
"of a non-extensible type %s "
"(ptr=%02x)",
td->name, *(uint8_t *)ptr);
RETURN(RC_FAIL);
}
......
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