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:

  1. asn1c -fcompound-names -findirect-choice -fincludes-quoted -fno-include-deps -pdu=all 38413-f20.txt -D .
  2. 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)

Most upvoted comments

@mouse07410,

this brought to mind another thought. How hard would it be to add support for CONTAINING?

That’s not an easy task in my opinion.

I probably should open another issue for that…

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 XER output of ./converter-example -p PDUSessionResourceSetupRequestTransfer -iaper message.aper after applying the workaround and regenerating the code.

<PDUSessionResourceSetupRequestTransfer>
    <protocolIEs>
        <PDUSessionResourceSetupRequestTransferIEs>
            <id>130</id>
            <criticality><reject/></criticality>
            <value>
                <PDUSessionAggregateMaximumBitRate>
                    <pDUSessionAggregateMaximumBitRateDL>2000000</pDUSessionAggregateMaximumBitRateDL>
                    <pDUSessionAggregateMaximumBitRateUL>4000000</pDUSessionAggregateMaximumBitRateUL>
                </PDUSessionAggregateMaximumBitRate>
            </value>
        </PDUSessionResourceSetupRequestTransferIEs>
        <PDUSessionResourceSetupRequestTransferIEs>
            <id>134</id>
            <criticality><reject/></criticality>
            <value>
                <PDUSessionType><ipv4/></PDUSessionType>
            </value>
        </PDUSessionResourceSetupRequestTransferIEs>
        <PDUSessionResourceSetupRequestTransferIEs>
            <id>139</id>
            <criticality><reject/></criticality>
            <value>
                <UPTransportLayerInformation>
                    <gTPTunnel>
                        <transportLayerAddress>
                            0001000101000110000100000001000000111111111111100000000000000000
                            0000000000000000000000000000000000000000000000000000000000000000
                            00010001010001100001000000010000
                        </transportLayerAddress>
                        <gTP-TEID>40 01 01 05</gTP-TEID>
                    </gTPTunnel>
                </UPTransportLayerInformation>
            </value>
        </PDUSessionResourceSetupRequestTransferIEs>
        <PDUSessionResourceSetupRequestTransferIEs>
            <id>136</id>
            <criticality><reject/></criticality>
            <value>
                <QosFlowSetupRequestList>
                    <QosFlowSetupRequestItem>
                        <qosFlowIdentifier>5</qosFlowIdentifier>
                        <qosFlowLevelQosParameters>
                            <qosCharacteristics>
                                <nonDynamic5QI>
                                    <fiveQI>5</fiveQI>
                                </nonDynamic5QI>
                            </qosCharacteristics>
                            <allocationAndRetentionPriority>
                                <priorityLevelARP>9</priorityLevelARP>
                                <pre-emptionCapability><shall-not-trigger-pre-emption/></pre-emptionCapability>
                                <pre-emptionVulnerability><not-pre-emptable/></pre-emptionVulnerability>
                            </allocationAndRetentionPriority>
                        </qosFlowLevelQosParameters>
                    </QosFlowSetupRequestItem>
                </QosFlowSetupRequestList>
            </value>
        </PDUSessionResourceSetupRequestTransferIEs>
    </protocolIEs>
</PDUSessionResourceSetupRequestTransfer>