Commit efd2af41 authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Add min and max value of INTEGER(min..max) to asn_constant.h

For the following ASN.1 excerpt, the value of these Types will
be checked against its valid range in their corresponding
constraint functions.

DRB-Identity ::= INTEGER(1..32)
RSRP-Range   ::= INTEGER(0..97)
RSRQ-Range   ::= INTEGER(0..34)

Sometime it is convenient for application being aware of these
min and max values.

This commit generate the following macro defintions in
asn_constant.h :

\#define min_val_DRB_Identity (1)
\#define max_val_DRB_Identity (32)
\#define min_val_RSRP_Range (0)
\#define max_val_RSRP_Range (97)
\#define min_val_RSRQ_Range (0)
\#define max_val_RSRQ_Range (34)
parent d64be68b
......@@ -968,15 +968,30 @@ generate_constant_collection(arg_t *arg) {
TQ_FOR(mod, &(arg->asn->modules), mod_next) {
TQ_FOR(arg->expr, &(mod->members), next) {
if(arg->expr->meta_type != AMT_VALUE)
if(arg->expr->expr_type != ASN_BASIC_INTEGER)
continue;
if(arg->expr->expr_type == ASN_BASIC_INTEGER) {
if(arg->expr->meta_type == AMT_VALUE) {
abuf_printf(buf, "#define %s (%s)\n",
asn1c_make_identifier(AMI_USE_PREFIX, arg->expr, 0),
asn1p_itoa(arg->expr->value->value.v_integer));
empty_file = 0;
}
if(arg->expr->meta_type == AMT_TYPE) {
if(arg->expr->constraints) {
if(arg->expr->constraints->el_count == 1 &&
arg->expr->constraints->elements[0]->type == ACT_EL_RANGE) {
abuf_printf(buf, "#define min_val_%s (%s)\n",
asn1c_make_identifier(AMI_USE_PREFIX, arg->expr, 0),
asn1p_itoa(arg->expr->constraints->elements[0]->range_start->value.v_integer));
abuf_printf(buf, "#define max_val_%s (%s)\n",
asn1c_make_identifier(AMI_USE_PREFIX, arg->expr, 0),
asn1p_itoa(arg->expr->constraints->elements[0]->range_stop->value.v_integer));
empty_file = 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