vlm / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
1.03k stars 553 forks source link

Constraint check is failing for a 40bit unsigned integer #449

Open srikanta-lekha opened 2 years ago

srikanta-lekha commented 2 years ago

Hi,

I am trying to encode a 40bit unsigned integer.

Constraint generated by ASN compiler: asn_per_constraints_t asn_PER_type_NGAP_AMF_UE_NGAP_ID_constr_1 CC_NOTUSED = { { APC_CONSTRAINED, 40, -1, 0, 1099511627775 } / (0..1099511627775) /, { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 / No PER value map / };

By using Size-specific conversion helpers available in INTEGER.h I could able to fill its value. But when I tried to encode it using "aper_encode_to_buffer()", constraint check is failing.

What I observed is :


/*

here upper_bound is of type long, and tries to store 1099511627775. So the per constraint value becomes: (gdb) p *td->encoding_constraints.per_constraints $5 = {value = {flags = APC_CONSTRAINED, range_bits = 40, effective_bits = -1, lower_bound = 0, upper_bound = -1}, size = {flags = APC_UNCONSTRAINED, range_bits = -1, effective_bits = -1, lower_bound = 0, upper_bound = 0}, value2code = 0, code2value = 0}

Since the upper bound becomes -1, every time asn encoding is failing.

Could you please help me to resolve this. Please let me know if you need more information.

Thanks in advance.

PabloVicedoFivecomm commented 6 months ago

Hello, I am facing the same issue. Did you find a solution?

srikanta-lekha commented 6 months ago

Hi, I re-generated ASN files by using latest ASN compiler. In the newly generated file data type became "long long".

/*

PabloVicedoFivecomm commented 6 months ago

Thank you, guess I will have to build the newest version