-
Cedric Roux authored
aper_put_nsnnwn() and aper_get_nsnnwn() were wrong. All the places where they were used are modified, if needed. The functions aper_get_constrained_whole_number() and aper_put_constrained_whole_number() are introduced. They don't cover all cases, very big numbers are not supported. The sample ASN.1 file and C program at the end show some issues. For sequence-of, APER decoding fails and the XER output after APER encode/decode is: ----------- xer after encode/decode: <ListOfInt> <INTEGER>1</INTEGER> <INTEGER>259</INTEGER> </ListOfInt> ----------- instead of: ----------- xer after encode/decode: <ListOfInt> <INTEGER>1</INTEGER> <INTEGER>2</INTEGER> <INTEGER>3</INTEGER> </ListOfInt> ----------- For the enum test, we have: ----------- aper ue lost[1]: d4 ----------- instead of: ----------- aper ue lost[1]: 95 ----------- And APER decoding fails. For the choice test, we see: ----------- aper snssai[3]: 80 01 00 ----------- instead of: ----------- aper snssai[3]: 84 01 00 ----------- And XER after encode/decode is wrong. To generate C code from the ASN.1 file, asn1c is run as: asn1c -pdu=all -fno-include-deps -fcompound-names -gen-UPER -no-gen-BER -no-gen-JER -no-gen-OER -gen-APER -no-gen-example ASN.1 file: ----------- Test DEFINITIONS AUTOMATIC TAGS ::= BEGIN TestCond-Type ::= CHOICE{ gBR ENUMERATED {true, ...}, aMBR ENUMERATED {true, ...}, isStat ENUMERATED {true, ...}, isCatM ENUMERATED {true, ...}, rSRP ENUMERATED {true, ...}, rSRQ ENUMERATED {true, ...}, ..., ul-rSRP ENUMERATED {true, ...}, cQI ENUMERATED {true, ...}, fiveQI ENUMERATED {true, ...}, qCI ENUMERATED {true, ...}, sNSSAI ENUMERATED {true, ...} } CauseRadioNetwork ::= ENUMERATED { handover-desirable-for-radio-reasons, time-critical-handover, resource-optimisation-handover, reduce-load-in-serving-cell, partial-handover, unknown-new-eNB-UE-X2AP-ID, unknown-old-eNB-UE-X2AP-ID, unknown-pair-of-UE-X2AP-ID, ho-target-not-allowed, tx2relocoverall-expiry, trelocprep-expiry, cell-not-available, no-radio-resources-available-in-target-cell, invalid-MME-GroupID, unknown-MME-Code, encryption-and-or-integrity-protection-algorithms-not-supported, reportCharacteristicsEmpty, noReportPeriodicity, existingMeasurementID, unknown-eNB-Measurement-ID, measurement-temporarily-not-available, unspecified, ..., load-balancing, handover-optimisation, value-out-of-allowed-range, multiple-E-RAB-ID-instances, switch-off-ongoing, not-supported-QCI-value, measurement-not-supported-for-the-object, tDCoverall-expiry, tDCprep-expiry, action-desirable-for-radio-reasons, reduce-load, resource-optimisation, time-critical-action, target-not-allowed, no-radio-resources-available, invalid-QoS-combination, encryption-algorithms-not-supported, procedure-cancelled, rRM-purpose, improve-user-bit-rate, user-inactivity, radio-connection-with-UE-lost, failure-in-the-radio-interface-procedure, bearer-option-not-supported, mCG-Mobility, sCG-Mobility, count-reaches-max-value, unknown-old-en-gNB-UE-X2AP-ID, pDCP-Overload } ListOfInt ::= SEQUENCE (SIZE (3)) OF INTEGER END ----------- C program: ----------- void test(void *v, int is_aper, char *name, void *t) { unsigned char b[128]; asn_enc_rval_t r = asn_encode_to_buffer(NULL, is_aper ? ATS_ALIGNED_BASIC_PER : ATS_UNALIGNED_BASIC_PER, t, v, b, sizeof(b)); if (r.encoded <= 0) printf("error\n"); else printf("ok\n"); printf("%s %s[%ld]:", is_aper ? "aper" : "uper", name, r.encoded); for (int i = 0; i < r.encoded; i++) printf(" %2.2x", b[i]); printf("\n"); void *ret = NULL; asn_dec_rval_t d = asn_decode(NULL, is_aper ? ATS_ALIGNED_BASIC_PER : ATS_UNALIGNED_BASIC_PER, t, &ret, b, r.encoded); if (d.consumed != r.encoded) printf("error\n"); else printf("ok\n"); printf("xer of input:\n"); xer_fprint(stdout, t, v); printf("xer after encode/decode:\n"); xer_fprint(stdout, t, ret); } int main(void) { /* test sequence of */ ListOfInt_t l = { 0 }; long val[3] = { 1, 2, 3 }; asn_sequence_add(&l.list, &val[0]); asn_sequence_add(&l.list, &val[1]); asn_sequence_add(&l.list, &val[2]); test(&l, 1, "sequence-of (size 3)", &asn_DEF_ListOfInt); test(&l, 0, "sequence-of (size 3)", &asn_DEF_ListOfInt); /* test enum */ CauseRadioNetwork_t v; v = CauseRadioNetwork_radio_connection_with_UE_lost; test(&v, 1, "ue lost", &asn_DEF_CauseRadioNetwork); test(&v, 0, "ue lost", &asn_DEF_CauseRadioNetwork); v = CauseRadioNetwork_cell_not_available; test(&v, 1, "no cell", &asn_DEF_CauseRadioNetwork); test(&v, 0, "no cell", &asn_DEF_CauseRadioNetwork); /* test choice */ TestCond_Type_t w; w.present = TestCond_Type_PR_sNSSAI; w.choice.sNSSAI = TestCond_Type__sNSSAI_true; test(&w, 1, "snssai", &asn_DEF_TestCond_Type); test(&w, 0, "snssai", &asn_DEF_TestCond_Type); w.present = TestCond_Type_PR_gBR; w.choice.sNSSAI = TestCond_Type__gBR_true; test(&w, 1, "gbr", &asn_DEF_TestCond_Type); test(&w, 0, "gbr", &asn_DEF_TestCond_Type); return 0; } -----------
ee6458b2