Commit 755cadaa authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu Committed by Mouse

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 140cdbec
......@@ -1029,15 +1029,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;
}
}
}
}
}
......
......@@ -1776,3 +1776,28 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
&asn_SPC_EXTERNAL_specs_1 /* Additional specs */
};
/*** <<< asn_constant.h >>> ***/
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
*/
#ifndef _ASN_CONSTANT_H
#define _ASN_CONSTANT_H
#ifdef __cplusplus
extern "C" {
#endif
#define min_val_C_1_2 (1)
#define max_val_C_1_2 (2)
#define min_val_FConstr (0)
#define max_val_FConstr (4)
#ifdef __cplusplus
}
#endif
#endif /* _ASN_CONSTANT_H */
......@@ -740,6 +740,8 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
extern "C" {
#endif
#define min_val_ConstrainedInteger (0)
#define max_val_ConstrainedInteger (32767)
#define primMessage (1)
#define cplxMessage (2)
......
......@@ -598,3 +598,26 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
&asn_SPC_EXTERNAL_specs_1 /* Additional specs */
};
/*** <<< asn_constant.h >>> ***/
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
*/
#ifndef _ASN_CONSTANT_H
#define _ASN_CONSTANT_H
#ifdef __cplusplus
extern "C" {
#endif
#define min_val_Short (0)
#define max_val_Short (65535)
#ifdef __cplusplus
}
#endif
#endif /* _ASN_CONSTANT_H */
......@@ -612,3 +612,26 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
&asn_SPC_EXTERNAL_specs_1 /* Additional specs */
};
/*** <<< asn_constant.h >>> ***/
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
*/
#ifndef _ASN_CONSTANT_H
#define _ASN_CONSTANT_H
#ifdef __cplusplus
extern "C" {
#endif
#define min_val_Short (0)
#define max_val_Short (65535)
#ifdef __cplusplus
}
#endif
#endif /* _ASN_CONSTANT_H */
......@@ -1272,6 +1272,8 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
extern "C" {
#endif
#define min_val_PacketId (0)
#define max_val_PacketId (65535)
#define max_items (256)
......
......@@ -1677,3 +1677,46 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
&asn_SPC_EXTERNAL_specs_1 /* Additional specs */
};
/*** <<< asn_constant.h >>> ***/
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
*/
#ifndef _ASN_CONSTANT_H
#define _ASN_CONSTANT_H
#ifdef __cplusplus
extern "C" {
#endif
#define min_val_CN_IntegerMinMax (-123)
#define max_val_CN_IntegerMinMax (321)
#define min_val_CN_IntegerMinLow (-123)
#define max_val_CN_IntegerMinLow (1)
#define min_val_NO_IntegerMinHigh (-123)
#define max_val_NO_IntegerMinHigh (3000000000)
#define min_val_NO_IntegerLowHigh (1)
#define max_val_NO_IntegerLowHigh (3000000000)
#define min_val_CN_IntegerLowMax (1)
#define max_val_CN_IntegerLowMax (321)
#define min_val_NO_IntegerHighMax (3000000000)
#define max_val_NO_IntegerHighMax (321)
#define min_val_NO_IntegerLowestMax (-3000000000)
#define max_val_NO_IntegerLowestMax (321)
#define min_val_NO_IntegerOutRange (3000000000)
#define max_val_NO_IntegerOutRange (3000000001)
#define min_val_OK_IntegerInRange1 (-100)
#define max_val_OK_IntegerInRange1 (100)
#define min_val_OK_IntegerInRange3 (-2147483648)
#define max_val_OK_IntegerInRange3 (2147483647)
#define min_val_NO_IntegerInRange6 (0)
#define max_val_NO_IntegerInRange6 (4294967295)
#ifdef __cplusplus
}
#endif
#endif /* _ASN_CONSTANT_H */
......@@ -1692,3 +1692,46 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
&asn_SPC_EXTERNAL_specs_1 /* Additional specs */
};
/*** <<< asn_constant.h >>> ***/
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
*/
#ifndef _ASN_CONSTANT_H
#define _ASN_CONSTANT_H
#ifdef __cplusplus
extern "C" {
#endif
#define min_val_CN_IntegerMinMax (-123)
#define max_val_CN_IntegerMinMax (321)
#define min_val_CN_IntegerMinLow (-123)
#define max_val_CN_IntegerMinLow (1)
#define min_val_NO_IntegerMinHigh (-123)
#define max_val_NO_IntegerMinHigh (3000000000)
#define min_val_NO_IntegerLowHigh (1)
#define max_val_NO_IntegerLowHigh (3000000000)
#define min_val_CN_IntegerLowMax (1)
#define max_val_CN_IntegerLowMax (321)
#define min_val_NO_IntegerHighMax (3000000000)
#define max_val_NO_IntegerHighMax (321)
#define min_val_NO_IntegerLowestMax (-3000000000)
#define max_val_NO_IntegerLowestMax (321)
#define min_val_NO_IntegerOutRange (3000000000)
#define max_val_NO_IntegerOutRange (3000000001)
#define min_val_OK_IntegerInRange1 (-100)
#define max_val_OK_IntegerInRange1 (100)
#define min_val_OK_IntegerInRange3 (-2147483648)
#define max_val_OK_IntegerInRange3 (2147483647)
#define min_val_NO_IntegerInRange6 (0)
#define max_val_NO_IntegerInRange6 (4294967295)
#ifdef __cplusplus
}
#endif
#endif /* _ASN_CONSTANT_H */
......@@ -1911,3 +1911,46 @@ asn_TYPE_descriptor_t asn_DEF_EXTERNAL = {
&asn_SPC_EXTERNAL_specs_1 /* Additional specs */
};
/*** <<< asn_constant.h >>> ***/
/*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
*/
#ifndef _ASN_CONSTANT_H
#define _ASN_CONSTANT_H
#ifdef __cplusplus
extern "C" {
#endif
#define min_val_CN_IntegerMinMax (-123)
#define max_val_CN_IntegerMinMax (321)
#define min_val_CN_IntegerMinLow (-123)
#define max_val_CN_IntegerMinLow (1)
#define min_val_NO_IntegerMinHigh (-123)
#define max_val_NO_IntegerMinHigh (3000000000)
#define min_val_NO_IntegerLowHigh (1)
#define max_val_NO_IntegerLowHigh (3000000000)
#define min_val_CN_IntegerLowMax (1)
#define max_val_CN_IntegerLowMax (321)
#define min_val_NO_IntegerHighMax (3000000000)
#define max_val_NO_IntegerHighMax (321)
#define min_val_NO_IntegerLowestMax (-3000000000)
#define max_val_NO_IntegerLowestMax (321)
#define min_val_NO_IntegerOutRange (3000000000)
#define max_val_NO_IntegerOutRange (3000000001)
#define min_val_OK_IntegerInRange1 (-100)
#define max_val_OK_IntegerInRange1 (100)
#define min_val_OK_IntegerInRange3 (-2147483648)
#define max_val_OK_IntegerInRange3 (2147483647)
#define min_val_NO_IntegerInRange6 (0)
#define max_val_NO_IntegerInRange6 (4294967295)
#ifdef __cplusplus
}
#endif
#endif /* _ASN_CONSTANT_H */
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