Commit 904e65b8 authored by Lev Walkin's avatar Lev Walkin

more distinction

parent 239143ee
...@@ -673,7 +673,8 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -673,7 +673,8 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
continue; continue;
} }
/* Fall through */ /* Fall through */
case XCT_UNEXPECTED: case XCT_UNKNOWN_OP:
case XCT_UNKNOWN_BO:
if(ctx->phase != 1) if(ctx->phase != 1)
break; /* Really unexpected */ break; /* Really unexpected */
...@@ -693,9 +694,9 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -693,9 +694,9 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ctx->step = edx; ctx->step = edx;
ctx->phase = 2; ctx->phase = 2;
break; break;
case XCT_UNEXPECTED: case XCT_UNKNOWN_OP:
case XCT_UNKNOWN_BO:
continue; continue;
case XCT_CLOSING:
default: default:
edx = td->elements_count; edx = td->elements_count;
break; /* Phase out */ break; /* Phase out */
...@@ -704,6 +705,16 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -704,6 +705,16 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
} }
if(edx != td->elements_count) if(edx != td->elements_count)
continue; continue;
/* It is expected extension */
if(specs->extensible) {
ASN_DEBUG("Got anticipated extension, "
"but NOT IMPLEMENTED YET");
/*
* TODO: implement skipping of extensions
*/
}
/* Fall through */ /* Fall through */
default: default:
break; break;
......
...@@ -623,6 +623,7 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -623,6 +623,7 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ssize_t consumed_myself = 0; /* Consumed bytes from ptr */ ssize_t consumed_myself = 0; /* Consumed bytes from ptr */
int xer_state; /* XER low level parsing context */ int xer_state; /* XER low level parsing context */
int edx; /* Element index */ int edx; /* Element index */
int edx_end;
/* /*
* Create the target structure if it is not present already. * Create the target structure if it is not present already.
...@@ -649,6 +650,7 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -649,6 +650,7 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ssize_t ch_size; /* Chunk size */ ssize_t ch_size; /* Chunk size */
xer_check_tag_e tcv; /* Tag check value */ xer_check_tag_e tcv; /* Tag check value */
asn_TYPE_member_t *elm; asn_TYPE_member_t *elm;
int n;
/* /*
* Go inside the inner member of a sequence. * Go inside the inner member of a sequence.
...@@ -740,9 +742,8 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -740,9 +742,8 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
continue; continue;
} }
/* Fall through */ /* Fall through */
case XCT_UNEXPECTED: { case XCT_UNKNOWN_OP:
int edx_end; case XCT_UNKNOWN_BO:
int n;
ASN_DEBUG("XER/SEQUENCE: tcv=%d, ph=%d", ASN_DEBUG("XER/SEQUENCE: tcv=%d, ph=%d",
tcv, ctx->phase); tcv, ctx->phase);
...@@ -754,6 +755,8 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -754,6 +755,8 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
* Search which member corresponds to this tag. * Search which member corresponds to this tag.
*/ */
edx_end = edx + elements[edx].optional + 1; edx_end = edx + elements[edx].optional + 1;
if(edx_end > td->elements_count)
edx_end = td->elements_count;
for(n = edx; n < edx_end; n++) { for(n = edx; n < edx_end; n++) {
elm = &td->elements[n]; elm = &td->elements[n];
tcv = xer_check_tag(buf_ptr,ch_size,elm->name); tcv = xer_check_tag(buf_ptr,ch_size,elm->name);
...@@ -766,18 +769,29 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -766,18 +769,29 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ctx->step = edx = n; ctx->step = edx = n;
ctx->phase = 2; ctx->phase = 2;
break; break;
case XCT_UNEXPECTED: case XCT_UNKNOWN_OP:
case XCT_UNKNOWN_BO:
continue; continue;
case XCT_CLOSING:
default: default:
n = edx_end; n = edx_end;
break; /* Phase out */ break; /* Phase out */
} }
break; break;
} }
if(n == edx_end) break; if(n != edx_end)
continue; continue;
}
/* It is expected extension */
if(IN_EXTENSION_GROUP(specs,
edx + elements[edx].optional)) {
ASN_DEBUG("Got anticipated extension at %d, "
"but NOT IMPLEMENTED YET", edx);
/*
* TODO: implement skipping of extensions
*/
}
/* Fall through */
default: default:
break; break;
} }
......
...@@ -714,7 +714,8 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -714,7 +714,8 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
continue; continue;
} }
/* Fall through */ /* Fall through */
case XCT_UNEXPECTED: case XCT_UNKNOWN_OP:
case XCT_UNKNOWN_BO:
ASN_DEBUG("XER/SET: tcv=%d, ph=%d", tcv, ctx->phase); ASN_DEBUG("XER/SET: tcv=%d, ph=%d", tcv, ctx->phase);
if(ctx->phase != 1) if(ctx->phase != 1)
...@@ -735,9 +736,9 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -735,9 +736,9 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
ctx->step = edx; ctx->step = edx;
ctx->phase = 2; ctx->phase = 2;
break; break;
case XCT_UNEXPECTED: case XCT_UNKNOWN_OP:
case XCT_UNKNOWN_BO:
continue; continue;
case XCT_CLOSING:
default: default:
edx = td->elements_count; edx = td->elements_count;
break; /* Phase out */ break; /* Phase out */
...@@ -746,6 +747,16 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -746,6 +747,16 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
} }
if(edx != td->elements_count) if(edx != td->elements_count)
continue; continue;
/* It is expected extension */
if(specs->extensible) {
ASN_DEBUG("Got anticipated extension, "
"but NOT IMPLEMENTED YET");
/*
* TODO: implement skipping of extensions
*/
}
/* Fall through */ /* Fall through */
default: default:
break; break;
......
...@@ -577,7 +577,8 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -577,7 +577,8 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
continue; continue;
} }
/* Fall through */ /* Fall through */
case XCT_UNEXPECTED: case XCT_UNKNOWN_OP:
case XCT_UNKNOWN_BO:
ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase); ASN_DEBUG("XER/SET OF: tcv=%d, ph=%d", tcv, ctx->phase);
if(ctx->phase != 1) if(ctx->phase != 1)
...@@ -595,8 +596,6 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ...@@ -595,8 +596,6 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
*/ */
ctx->phase = 2; ctx->phase = 2;
continue; continue;
case XCT_UNEXPECTED:
case XCT_CLOSING:
default: default:
break; /* Phase out */ break; /* Phase out */
} }
......
...@@ -137,12 +137,13 @@ xer_check_tag(const void *buf_ptr, int size, const char *need_tag) { ...@@ -137,12 +137,13 @@ xer_check_tag(const void *buf_ptr, int size, const char *need_tag) {
return ct; return ct;
} }
} }
return XCT_UNEXPECTED; return (XCT__UNK__MASK | ct);
} }
if(b == 0) if(b == 0)
return XCT_BROKEN; /* Embedded 0 in buf?! */ return XCT_BROKEN; /* Embedded 0 in buf?! */
} }
if(*need_tag) return XCT_UNEXPECTED; if(*need_tag)
return (XCT__UNK__MASK | ct);
return ct; return ct;
} }
...@@ -272,7 +273,7 @@ xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, ...@@ -272,7 +273,7 @@ xer_decode_general(asn_codec_ctx_t *opt_codec_ctx,
ADVANCE(ch_size); ADVANCE(ch_size);
ctx->phase = 2; /* Phase out */ ctx->phase = 2; /* Phase out */
RETURN(RC_OK); RETURN(RC_OK);
case XCT_UNEXPECTED: case XCT_UNKNOWN_BO:
if(!ctx->phase) break; if(!ctx->phase) break;
/* /*
* Certain tags in the body may be expected. * Certain tags in the body may be expected.
......
...@@ -70,11 +70,14 @@ ssize_t xer_next_token(int *stateContext, void *buffer, size_t size, ...@@ -70,11 +70,14 @@ ssize_t xer_next_token(int *stateContext, void *buffer, size_t size,
* This function checks the buffer against the tag name is expected to occur. * This function checks the buffer against the tag name is expected to occur.
*/ */
typedef enum xer_check_tag { typedef enum xer_check_tag {
XCT_BROKEN, /* The tag is broken */ XCT_BROKEN = 0, /* The tag is broken */
XCT_UNEXPECTED, /* The tag is fine, but unexpected */ XCT_OPENING = 1, /* This is the <opening> tag */
XCT_OPENING, /* This is the opening <tag> */ XCT_CLOSING = 2, /* This is the </closing> tag */
XCT_CLOSING, /* This is the closing </tag> */ XCT_BOTH = 3, /* This is the <modified/> tag */
XCT_BOTH, /* This is the opening and closing tag <tag/> */ XCT__UNK__MASK = 4, /* Mask of everything unexpected */
XCT_UNKNOWN_OP = 5, /* Unexpected <opening> tag */
XCT_UNKNOWN_CL = 6, /* Unexpected </closing> tag */
XCT_UNKNOWN_BO = 7, /* Unexpected <modified/> tag */
} xer_check_tag_e; } xer_check_tag_e;
xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, xer_check_tag_e xer_check_tag(const void *buf_ptr, int size,
const char *need_tag); const char *need_tag);
......
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