Commit 6af78bbd authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu Committed by Mouse

Fix code generated from ASN.1 of F1AP v15.4.0 failed to be compiled

ProtocolExtensionField.c generated from the following excerpt from ASN.1 of F1AP v15.4.0 :

RRC-Version ::= SEQUENCE {
    latest-RRC-Version BIT STRING (SIZE(3)),
    iE-Extensions      ProtocolExtensionContainer { { RRC-Version-ExtIEs } } OPTIONAL}

RRC-Version-ExtIEs F1AP-PROTOCOL-EXTENSION ::= {
    {ID id-latest-RRC-Version-Enhanced CRITICALITY ignore EXTENSION OCTET STRING (SIZE(3)) PRESENCE optional },
    ...
}

failed to be compiled because asn_PER_memb_OCTET_STRING_SIZE_3__constr_31 is not generated.

The reason is constraints of types used in information object sets are not processed in asn1fix() stage
so it's constraint, i.e. (SIZE(3)) in this case, is not generated.

With this fix, OCTET STRING (SIZE(3)) used in ASN.1 of F1AP v15.4.0 can be correctly processed
and generated code can be compiled.

However, this fix does not work for all sorts of types.

For example, if information object refer to a type like this : SEQUENCE (SIZE(3)) OF INTEGER
it will be failed to compiled because asn_IOS_RRC_Version_ExtIEs_1_rows[] refers to non-existing
asn_DEF_SEQUENCE_OF.
parent 1b8943a2
......@@ -283,6 +283,26 @@ asn1f_fix_module__phase_2(arg_t *arg) {
ret = asn1f_recurse_expr(arg, asn1f_check_constraints);
RET2RVAL(ret, rvalue);
if (expr->ioc_table) {
for (size_t rn = 0; rn < expr->ioc_table->rows; rn++) {
for (size_t cn = 0; cn < expr->ioc_table->row[rn]->columns; cn++) {
if (!expr->ioc_table->row[rn]->column[cn].value) {
continue;
}
arg->expr = expr->ioc_table->row[rn]->column[cn].value;
ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_defaults);
RET2RVAL(ret, rvalue);
ret = asn1f_recurse_expr(arg, asn1f_resolve_constraints);
RET2RVAL(ret, rvalue);
ret = asn1f_recurse_expr(arg, asn1f_check_constraints);
RET2RVAL(ret, rvalue);
}
}
arg->expr = expr;
}
/*
* Uniquely tag each inner type.
*/
......
......@@ -516,6 +516,21 @@ memb_value_constraint_4(const asn_TYPE_descriptor_t *td, const void *sptr,
static int
memb_OCTET_STRING_5__constraint_9(const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if(1 /* No applicable constraints whatsoever */) {
(void)st; /* Unused variable */
/* Nothing is here. See below */
}
return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
}
......@@ -616,6 +631,13 @@ static asn_per_constraints_t asn_PER_memb_value_constr_6 CC_NOTUSED = {
};
#endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
#if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
static asn_per_constraints_t asn_PER_memb_OCTET_STRING_5__constr_10 CC_NOTUSED = {
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
{ APC_SEMI_CONSTRAINED, -1, -1, 0, 0 } /* (SIZE(0..MAX)) */,
0, 0 /* No PER value map */
};
#endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
#if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
static asn_per_constraints_t asn_PER_memb_id_constr_8 CC_NOTUSED = {
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
......
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