asn1c: Can encode but fails to decode 5g N2 38.413 Dec version
Hi,
I’m working on 5g N2 interface and using your asn1c.
It seems that there is some bug because I’m not able to decode message the asn1c just encoded.
The ASN file is this: 38413-f20.txt
The message: PDUSessionResourceSetupRequestTransfer
The resulting hex is this:
00000400820008081e8480203d09000086000100008b001a09f0114610103ffe0000000000000000000011461010400101050088000700050000052000
as file that can be put into converter-example.c:
in.txt
as C array:
char theData[] = { 0x00, 0x00, 0x04, 0x00, 0x82, 0x00, 0x08, 0x08, 0x1e, 0x84, 0x80, 0x20, 0x3d, 0x09, 0x00, 0x00, 0x86, 0x00, 0x01, 0x00, 0x00, 0x8b, 0x00, 0x1a, 0x09, 0xf0, 0x11, 0x46, 0x10, 0x10, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x46, 0x10, 0x10, 0x40, 0x01, 0x01, 0x05, 0x00, 0x88, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x05, 0x20, 0x00 };
The whole program: https://gist.github.com/jkalmar/963cf317a9ba58f9d64396fee394c657
You can build the sample with:
- asn1c -fcompound-names -findirect-choice -fincludes-quoted -fno-include-deps -pdu=all 38413-f20.txt -D .
- with following cmake file: CMakeLists.txt
Or you can also build the above program.
It seems that in PDUSessionResourceSetupRequestTransfer the QosFlowSetupRequestList is the troubling element.
You can see the log from run with PDU=PDUSessionResourceSetupRequestTransfer ASN_EMIT_DEBUG=1 here: https://gist.github.com/jkalmar/a3ff06aa64162de90a0105ff8a198fa1
check lines: 270, 272, 277
I have debugged it and found out that the error happens in constr_CHOICE.c:1408
Breakpoint 1, CHOICE_variant_set_presence (td=0x53ef50 <asn_DEF_value_116>, sptr=0x552840, present=8) at /home/jkalmar/projects/5g/app/constr_CHOICE.c:1409
(gdb) p present $1 = 8
(gdb) p td->elements_count $2 = 7
Could you please check this I have testet the code on GCC 4.8.4, GCC 7.2.1 and GCC 8.3.1 on Centos7 and on OpenSuse Tumbleweed and also tried clang 7.0.1 and the result was the same.
Thank you for your help
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 25 (10 by maintainers)
@mouse07410,
That’s not an easy task in my opinion.
There is already one in the vlm repo https://github.com/vlm/asn1c/issues/310
Hi @brchiu,
Just tested it using your branch and it works like a charm. Many thanks.
@velichkov and @jkalmar , this issue might have been addressed in my commit : https://github.com/brchiu/asn1c/commit/0a7524184f16e7093990a31d8d4db487a16e5782 , you can use the velichkov_s1ap_plus_option_group (https://github.com/brchiu/asn1c/tree/velichkov_s1ap_plus_option_group ) branch of my fork to have a trial.
@velichkov Thanks for your response.
Yes. I have to decode couple of NGAP payloads for my analysis.
Initially i thought the aper_decode function recursively decodes all the fields. thanks for let me know about the OCTET STRING decoding procedure.
I called aper_decode() with pDUSessionResourceSetupRequestTransfer hex dump and it successfully decodes it. Thanks for your help!
@velichkov, this brought to mind another thought. How hard would it be to add support for
CONTAINING?I probably should open another issue for that…
And here is the
XERoutput of./converter-example -p PDUSessionResourceSetupRequestTransfer -iaper message.aperafter applying the workaround and regenerating the code.