Comments (24)
@velichkov and @jkalmar , this issue might have been addressed in my commit : brchiu@0a75241 , 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.
from asn1c.
Hi @brchiu,
Just tested it using your branch and it works like a charm. Many thanks.
from asn1c.
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 vlm#310
from asn1c.
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>
from asn1c.
@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...
from asn1c.
@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!
from asn1c.
Hi @jkalmar,
It seems that there is some bug because I'm not able to decode message the asn1c just encoded.
Could you provide the message in XER
format? The problem could be in the APER
encode functions so it's useful to have the message in both APER
and XER
formats.
I'm able to reproduce the problem using the converter-example
that asn1c
generates. Here are all the steps.
asn1c -fcompound-names -findirect-choice -fincludes-quoted -fno-include-deps -pdu=all 38413-f20.txt
export CFLAGS="-DASN_EMIT_DEBUG=1 -g3 -O0" #or add these CFLAGS in converter-example.mk
make -f converter-example.mk
xxd -r <<EOF >PDUSessionResourceSetupRequestTransfer.aper
00000000: 00 00 04 00 82 00 08 08 1e 84 80 20 3d 09 00 00
00000010: 86 00 01 00 00 8b 00 1a 09 f0 11 46 10 10 3f fe
00000020: 00 00 00 00 00 00 00 00 00 00 11 46 10 10 40 01
00000030: 01 05 00 88 00 07 00 05 00 00 05 20 00
EOF
./converter-example -d -p PDUSessionResourceSetupRequestTransfer -iaper PDUSessionResourceSetupRequestTransfer.aper
from asn1c.
The APER encode function is OK, I have checked it and it generate the same output as when using Nokalva online tool. Also Nokalva online can decode the hex correctly.
This is what Nokalva outputs for the hex data:
https://gist.github.com/jkalmar/5a3a3c763a4bba7c22e7bf904e789676
from asn1c.
Ok, that's good to know, but still could you please print it as XER as this could facilitate debugging.
It seems that in PDUSessionResourceSetupRequestTransfer the QosFlowSetupRequestList is the troubling element.
What happens if you remove the QosFlowSetupRequestList element, doe it encode and then decode correctly?
from asn1c.
I have tried it and if I remove the QosFlowSetupRequestList then it decode it correctly.
Currently I can't provide XER but tomorrow I will try to provide it and also I will provide you filled PDUSessionResourceSetupRequestTransfer
struct in C so you can encode it easily.
from asn1c.
Hi @jkalmar,
There is a bug - the elements count is not calculated correctly when there are two IE elements with different IDs but with the same type (UPTransportLayerInformation
in this case). A possible dirty workaround is
--- a/38413-f20.txt
+++ b/38413-f20.txt
@@ -2116,10 +2116,11 @@ PDUSessionResourceSetupRequestTransfer ::= SEQUENCE {
...
}
+UPTransportLayerInformation1 ::= UPTransportLayerInformation
PDUSessionResourceSetupRequestTransferIEs NGAP-PROTOCOL-IES ::= {
{ ID id-PDUSessionAggregateMaximumBitRate CRITICALITY reject TYPE PDUSessionAggregateMaximumBitRate PRESENCE optional }|
{ ID id-UL-NGU-UP-TNLInformation CRITICALITY reject TYPE UPTransportLayerInformation PRESENCE mandatory }|
- { ID id-AdditionalUL-NGU-UP-TNLInformation CRITICALITY reject TYPE UPTransportLayerInformation PRESENCE optional }|
+ { ID id-AdditionalUL-NGU-UP-TNLInformation CRITICALITY reject TYPE UPTransportLayerInformation1 PRESENCE optional }|
{ ID id-DataForwardingNotPossible CRITICALITY reject TYPE DataForwardingNotPossible PRESENCE optional }|
{ ID id-PDUSessionType CRITICALITY reject TYPE PDUSessionType PRESENCE mandatory }|
{ ID id-SecurityIndication CRITICALITY reject TYPE SecurityIndication PRESENCE optional }|
The ProtocolIE-Field.c
is generated by asn1c
5026 asn_TYPE_descriptor_t asn_DEF_value_116 = {
5027 "value",
5028 "value",
5029 &asn_OP_OPEN_TYPE,
5030 0, /* No effective tags (pointer) */
5031 0, /* No effective tags (count) */
5032 0, /* No tags (pointer) */
5033 0, /* No tags (count) */
5034 { 0, 0, OPEN_TYPE_constraint },
5035 asn_MBR_value_116,
5036 7, /* Elements count */
5037 &asn_SPC_value_specs_116 /* Additional specs */
5038 };
And here the elements count is 7 but it should be 8. This line is generated here
asn1c/libasn1compiler/asn1c_C.c
Lines 3200 to 3201 in 4233a4f
<PDUSessionResourceSetupRequestTransfer> <protocolIEs> <SEQUENCE> <id>130</id>
Replace SEQUENCE
with PDUSessionResourceSetupRequestTransferIEs
and try again. Not sure which one is correct XER
and at the moment I don't have time to check the specification.
from asn1c.
There is a similar problem with OER decoding (update: turned out that OER encoder was broken, and produced undecodable output)
$ ./converter-example -dd -p PDUSessionResourceSetupRequestTransfer -ioer tmp-t1.oer 2>&1 | tee oer-debug.txt
AD: Processing tmp-t1.oer
AD: Decoding 71 bytes
OER SEQUENCE PDUSessionResourceSetupRequestTransfer Decoding PHASE 0 (constr_SEQUENCE_oer.c:131)
Expecting preamble bits 1 for PDUSessionResourceSetupRequestTransfer (including 1 extension bits) (constr_SEQUENCE_oer.c:135)
OER SEQUENCE PDUSessionResourceSetupRequestTransfer Decoding PHASE 1 (Root) (constr_SEQUENCE_oer.c:156)
Decoding PDUSessionResourceSetupRequestTransfer->protocolIEs (constr_SEQUENCE_oer.c:164)
OER SET OF ProtocolIE-Container Decoding PHASE 1 (constr_SET_OF_oer.c:171)
OER SEQUENCE PDUSessionResourceSetupRequestTransferIEs Decoding PHASE 0 (constr_SEQUENCE_oer.c:131)
Expecting preamble bits 0 for PDUSessionResourceSetupRequestTransferIEs (including 0 extension bits) (constr_SEQUENCE_oer.c:135)
OER SEQUENCE PDUSessionResourceSetupRequestTransferIEs Decoding PHASE 1 (Root) (constr_SEQUENCE_oer.c:156)
Decoding PDUSessionResourceSetupRequestTransferIEs->id (constr_SEQUENCE_oer.c:164)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Decoding PDUSessionResourceSetupRequestTransferIEs->criticality (constr_SEQUENCE_oer.c:164)
Decoding PDUSessionResourceSetupRequestTransferIEs->value (constr_SEQUENCE_oer.c:164)
OER SEQUENCE PDUSessionAggregateMaximumBitRate Decoding PHASE 0 (constr_SEQUENCE_oer.c:131)
Expecting preamble bits 2 for PDUSessionAggregateMaximumBitRate (including 1 extension bits) (constr_SEQUENCE_oer.c:135)
OER SEQUENCE PDUSessionAggregateMaximumBitRate Decoding PHASE 1 (Root) (constr_SEQUENCE_oer.c:156)
Decoding PDUSessionAggregateMaximumBitRate->pDUSessionAggregateMaximumBitRateDL (constr_SEQUENCE_oer.c:164)
Decoding PDUSessionAggregateMaximumBitRate->pDUSessionAggregateMaximumBitRateUL (constr_SEQUENCE_oer.c:164)
Decoding PDUSessionAggregateMaximumBitRate->iE-Extensions (constr_SEQUENCE_oer.c:164)
[PER got 1<= 1 bits => span 1 +0[2..2]:00 (0) => 0x0] (asn_bit_data.c:139)
OER SEQUENCE PDUSessionAggregateMaximumBitRate Decoding PHASE 2 (constr_SEQUENCE_oer.c:245)
OER SEQUENCE PDUSessionResourceSetupRequestTransferIEs Decoding PHASE 2 (constr_SEQUENCE_oer.c:245)
OER SEQUENCE PDUSessionResourceSetupRequestTransferIEs Decoding PHASE 0 (constr_SEQUENCE_oer.c:131)
Expecting preamble bits 0 for PDUSessionResourceSetupRequestTransferIEs (including 0 extension bits) (constr_SEQUENCE_oer.c:135)
OER SEQUENCE PDUSessionResourceSetupRequestTransferIEs Decoding PHASE 1 (Root) (constr_SEQUENCE_oer.c:156)
Decoding PDUSessionResourceSetupRequestTransferIEs->id (constr_SEQUENCE_oer.c:164)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Decoding PDUSessionResourceSetupRequestTransferIEs->criticality (constr_SEQUENCE_oer.c:164)
Failed to decode element Criticality (NativeEnumerated_oer.c:68)
Decoding failed at element PDUSessionResourceSetupRequestTransferIEs "criticality" (constr_SEQUENCE_oer.c:222)
Freeing PDUSessionResourceSetupRequestTransferIEs as SEQUENCE (constr_SEQUENCE.c:994)
Freeing ProtocolIE-ID as INTEGER (1, 0x7f9e27402d60, Native) (NativeInteger.c:429)
Freeing Criticality as INTEGER (1, 0x7f9e27402d68, Native) (NativeInteger.c:429)
Freeing value as CHOICE (constr_CHOICE.c:1230)
Decoding failed at element PDUSessionResourceSetupRequestTransfer "protocolIEs" (constr_SEQUENCE_oer.c:222)
AD: decode(0) consumed 1+0b (71), code 2
AD: Clean up partially decoded PDUSessionResourceSetupRequestTransfer
Freeing PDUSessionResourceSetupRequestTransfer as SEQUENCE (constr_SEQUENCE.c:994)
Freeing PDUSessionResourceSetupRequestTransferIEs as SEQUENCE (constr_SEQUENCE.c:994)
Freeing ProtocolIE-ID as INTEGER (1, 0x7f9e27402c90, Native) (NativeInteger.c:429)
Freeing Criticality as INTEGER (1, 0x7f9e27402c98, Native) (NativeInteger.c:429)
Freeing value as CHOICE (constr_CHOICE.c:1230)
Freeing PDUSessionAggregateMaximumBitRate as SEQUENCE (constr_SEQUENCE.c:994)
Freeing BitRate as a primitive type (asn_codecs_prim.c:125)
Freeing BitRate as a primitive type (asn_codecs_prim.c:125)
AD: ofp 1, no=1, oo=0, dbl=0
tmp-t1.oer: Decode failed past byte 1: Input processing error
$
Also, when doing chain-conversion, the tail 0000
seems to get missing from the resulting XER encoding (see in the end of the attached file - APER->UPER->XER, compared result with output of APER->XER):
diff -cw t1.xer tmp-t1.xer
*** t1.xer 2019-03-21 11:37:41.000000000 -0400
--- tmp-t1.xer 2019-03-21 13:55:00.000000000 -0400
***************
*** 26,32 ****
<transportLayerAddress>
0001000101000110000100000001000000111111111111100000000000000000
0000000000000000000000000000000000000000000000000000000000000000
! 00010001010001100001000000010000
</transportLayerAddress>
<gTP-TEID>40 01 01 05</gTP-TEID>
</gTPTunnel>
--- 26,32 ----
<transportLayerAddress>
0001000101000110000100000001000000111111111111100000000000000000
0000000000000000000000000000000000000000000000000000000000000000
! 0001000101000110000100000001
</transportLayerAddress>
<gTP-TEID>40 01 01 05</gTP-TEID>
</gTPTunnel>
from asn1c.
Update to OER problem:
This is what Nokalva thinks about OER encoding generated by asn1c
:
OSS ASN-1Step Version 8.2
Copyright (C) 2017 OSS Nokalva, Inc. All rights reserved.
This product is licensed for use by "OSS Nokalva, Inc."
C0043I: 0 error messages, 0 warning messages and 0 informatory messages issued.
ASN1STEP: Decoding PDU #287 :
PDUSessionResourceSetupRequestTransfer SEQUENCE
protocolIEs SEQUENCE OF
SEQUENCE
id ProtocolIE-ID INTEGER [length = 2]
130
criticality Criticality ENUMERATED [length = 1]
0
value PDUSessionAggregateMaximumBitRate SEQUENCE
pDUSessionAggregateMaximumBitRateDL BitRate INTEGER [length = 3]
2000000
pDUSessionAggregateMaximumBitRateUL BitRate INTEGER [length = 3]
4000000
SEQUENCE
id ProtocolIE-ID INTEGER [length = 2]
128
criticality Criticality ENUMERATED [length = 0]
0
value OpenType [length = 0]
<no content>
SEQUENCE
id ProtocolIE-ID INTEGER [length = 2]
5376
criticality Criticality ENUMERATED [length = 1]
17
D0081S: End of input reached before message was fully decoded; check field 'value' (type: OpenType) of element #3 (type: SEQUENCE) of field 'protocolIEs' (type: SEQUENCE OF) of PDU #287 'PDUSessionResourceSetupRequestTransfer'.
S0012E: Decoding of PDU #287 failed with the return code '4'.
Here's the HEX of the OER encoding:
0001040082001000031e8480033d09000086000a00008b00808000150011
4610103ffe00000000000000000000114610104001010500880010010100
0105008000010500090000
Here's the XER from which the OER was generated:
<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>
from asn1c.
@velichkov @brchiu it looks like the problem is OER encoding - asn1c
decodes this PDU that's OER-encoded by Nokalva just fine. Here are the OER files.
From asn1c
:
0001040082001000031e8480033d09000086000a00008b00808000150011
4610103ffe00000000000000000000114610104001010500880010010100
0105008000010500090000
From Nokalva:
0001040082000900031e8480033d09000086000100008b001c8000150011
4610103ffe0000000000000000000011461010400101050088000e010100
0105008000010500090000
The difference in in one byte only (7th, counting from 1). The wrong one has 8200
1000
, and the correct one has 8200
0900
. Do you understand OER enough to figure what seems to be causing this error?
Update: since the error is in the encoding, here's the debug log of the encoding process:
tmp-t1.oer.log.txt
Update 2: UPER encoding is also wrong - look at byte 24:
From asn1c
:
00020041016000001e8480000007a1200010c00800045832136228c20207
ffc00000000000000000000228c202
8002020a0
1100300028000148000
From Nokalva:
00020041016000001e8480000007a1200010c0080004583413e228c20207
ffc00000000000000000000228c202
08002020a0
01100300028000148000
asn1c
-produced encoding misses two 0
s. As a result of this error, the correct value
<transportLayerAddress>
0001000101000110000100000001000000111111111111100000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00010001010001100001000000010000
</transportLayerAddress>
gets decoded instead into
<transportLayerAddress>
0001000101000110000100000001000000111111111111100000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0001000101000110000100000001
</transportLayerAddress>
note two missing bytes at the end of the address.
from asn1c.
Oh, and @brchiu your fix that resolves APER problem has been merged into my vlm_master
. Thank you!
from asn1c.
From asn1c:
000104008200
1000031e8480033d09000086000a00008b00808000150011
4610103ffe00000000000000000000114610104001010500880010010100
0105008000010500090000From Nokalva:
0001040082000900031e8480033d09000086000100008b001c8000150011
4610103ffe0000000000000000000011461010400101050088000e010100
0105008000010500090000The difference in in one byte only (7th, counting from 1). The wrong one has 82001000, and the >correct one has 82000900.
There are three more differences that I underlined and struck out in the above quote.
Do you understand OER enough to figure what seems to be causing this >error?
I don't have any OER experience but to me the 09
, 01
, 1c
and 0e
bytes in the correct message looks like lengths
From Rec. ITU-T X.696 (08/2015)
30 Encoding of open type values
NOTE – An open type is an ASN.1 type that can take any abstract value of any ASN.1 type. Each value of an open type consists of:
a) a contained type; and
b) a value of the contained type.The encoding of an open type value shall consist of a length determinant (see 8.6) followed by a series of octets, which are the encoding of the value of the contained type.
20 Encoding of choice values
20.1 The encoding of a value of a choice type shall consist of the encoding of the outermost tag of the type of the chosen alternative as specified in 8.7, followed by the encoding of the value of the chosen alternative.
So I think using CHOICE_encode_oer to encode Open Types is incorrect and the reason for the above differences
Line 23 in 86b0541
from asn1c.
...I think using CHOICE_encode_oer to encode Open Types is incorrect and the reason for the above differences...
@velichkov Sounds very reasonable - thanks for investigating this. What would be a solution in your opinion? It appears that one should copy CHOICE_encode_oer
to OPEN_TYPE_encode_oer
, and replace encoding of the outermost tag with the encoding of length, leaving the actual data encoding the same?
from asn1c.
What would be a solution in your opinion? It appears that one should copy CHOICE_encode_oer to OPEN_TYPE_encode_oer, and replace encoding of the outermost tag with the encoding of length, leaving the actual data encoding the same?
Yes, something like this, also look how uper_open_type_put
and aper_open_type_put
are implemented.
Also, when doing chain-conversion, the tail 0000 seems to get missing from the resulting XER encoding
(see in the end of the attached file - APER->UPER->XER, compared result with output of APER->XER):
You don't need to do a chain-conversion to reproduce this. The minimal reproducible test case is
$ cat TransportLayerAddress.xer
<TransportLayerAddress>
0001000101000110000100000001000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000
</TransportLayerAddress>
$ ./converter-example -p TransportLayerAddress -ixer TransportLayerAddress.xer -oper > TransportLayerAddress.uper
$ xxd TransportLayerAddress.uper
00000000: 0d88 a308 08 .....
$ ./converter-example -p TransportLayerAddress -iper TransportLayerAddress.uper -oxer
<TransportLayerAddress>
0001000101000110000100000001
</TransportLayerAddress>
All the trailing 0 bits get removed and this was implemented in a5b0288
from asn1c.
All the trailing 0 bits get removed and this was implemented in a5b0288
@velichkov but is it correct??? It doesn't make much sense to, e.g., truncate IP address 192.168.1.100
to 192.168.1.1
?
Do you know why was that commit introduced? Do you think it should be reverted (because of the above problem)?
from asn1c.
@velichkov but is it correct???
The specification is quite complex. From Rec. ITU-T X.691 (08/2015)
16 Encoding the bitstring type
...
16.2 Where there are no PER-visible constraints and Rec. ITU-T X.680 | ISO/IEC 8824-1, 22.7, applies the value shall be encoded with no trailing 0 bits (note that this means that a value with no 1 bits is always encoded as an empty bit string).
16.3 Where there is a PER-visible constraint and Rec. ITU-T X.680 | ISO/IEC 8824-1, 22.7, applies (i.e. the bitstring type is defined with a "NamedBitList"), the value shall be encoded with trailing 0 bits added or removed as necessary to ensure that the size of the transmitted value is the smallest size capable of carrying this value and satisfies the effective size constraint.
...
16.6 If the type is extensible for PER encodings (see 10.3.9), then a bit-field consisting of a single bit shall be added to the field-list. The bit shall be set to 1 if the length of this encoding is not within the range of the extension root, and zero otherwise. In the former case, 16.11 shall be invoked to add the length as a semi-constrained whole number to the field-list, followed by the bitstring value. In the latter case the length and value shall be encoded as if no extension is present in the constraint.
...
16.11 If 16.8-16.10 do not apply, the bitstring shall be placed in a bit-field (octet-aligned in the ALIGNED variant) of length "n" bits and the procedures of 11.9 shall be invoked to add this bit-field (octet-aligned in the ALIGNED variant) of "n" bits to the field-list, preceded by a length determinant equal to "n" bits as a constrained whole number if "ub" is set and is less than 64K or as a semi-constrained whole number if "ub" is unset. "lb" is as determined above.
NOTE – Fragmentation applies for unconstrained or large "ub" after 16K, 32K, 48K or 64K bits.
From Rec. ITU-T X.680 (08/2015)
22.7 When a "NamedBitList" is used in defining a bitstring type ASN.1 encoding rules are free to add (or remove) arbitrarily any trailing 0 bits to (or from) values that are being encoded or decoded. Application designers should therefore ensure that different semantics are not associated with such values which differ only in the number of trailing 0 bits.
TransportLayerAddress ::= BIT STRING (SIZE(1..160, ...))
In this particular case TransportLayerAddress
does not contains NamedBitList
so I think that the 22.7
should not apply and as a consequence 16.3
(and 16.2
) should not apply as well but I could be wrong. I believe that 16.6
shell be applied and there is nothing about trailing 0 bits in it.
It doesn't make much sense to, e.g., truncate IP address 192.168.1.100 to 192.168.1.1?
I agree.
Do you know why was that commit introduced?
I don't know.
Do you think it should be reverted (because of the above problem)?
No, if encoding in this particular case is incorrect then it should be enhanced as obviously there are cases when the BIT STRING
values should be encoded without trailing 0 bits.
from asn1c.
@velichkov it looks like the encoder screwed up here. This is a "normal" regular BIT STRING
, and it should've been left "unmolested".
How do we fix it?
from asn1c.
@velichkov @mouse07410 I am working on to decode the 5G NGAP payload using mouse07410/asn1c compiler.
I failed to decode PDUSessionResourceSetupRequestTransfer contents. The workaround fix you mentioned is also not helping to solve the problem.
Are there any other latest fixes needed to solve the PDUSessionResourceSetupRequestTransfer decoding?
Steps followed:
- Downloaded the compiler code from : https://github.com/mouse07410/asn1c
- asn1c -fcompound-names -findirect-choice -fincludes-quoted -fno-include-deps -pdu=all -S ../skeletons/ /root/asn1/combined-NGAP-backup.asn
ASN files from https://github.com/wireshark/wireshark/tree/master/epan/dissectors/asn1/ngap
-
I used my own test file to decode the below hex dump. (aper_decode)
-
Hex dump :
char buf[] = {0x00,0x1d,0x00,0x80,0x80,0x00,0x00,0x03,0x00,0x0a,0x00,0x02,0x00,0x00,0x00,0x55,0x00,0x02,0x00,0x00,0x00,0x4a,0x00,0x6d,0x00,0x40,0x05,0x3b,0x7e,0x02,0xac,0x33,0x8e,0xa5,0x02,0x7e,0x00,0x68,0x01,0x00,0x2c,0x2e,0x05,0x01,0xc2,0x11,0x00,0x09,0x01,0x00,0x06,0x31,0x20,0x00,0x00,0xff,0x01,0x06,0x01,0x00,0x01,0x01,0x00,0x01,0x29,0x05,0x01,0x32,0x00,0x00,0x01,0x25,0x0c,0x07,0x67,0x69,0x67,0x61,0x6d,0x6f,0x6e,0x03,0x63,0x6f,0x6d,0x12,0x05,0x00,0x00,0x2b,0x00,0x00,0x04,0x00,0x82,0x00,0x06,0x04,0x03,0xe8,0x10,0x03,0xe8,0x00,0x8b,0x00,0x0a,0x01,0xf0,0x0a,0x32,0x02,0x0a,0x00,0x00,0x00,0x01,0x00,0x86,0x00,0x01,0x00,0x00,0x88,0x00,0x07,0x00,0x01,0x00,0x00,0x05,0x00,0x00} -
decoder routine :
NGAP_PDU_t *pdusess=0;
aper_decode(0, &asn_DEF_NGAP_PDU, (void **)&pdusess, buf, sizeof(buf),0 ,0);
asn_fprint(stdout, &asn_DEF_NGAP_PDU, pdusess);
Output:
CALLING aper_decode
[PER got 1<=1064 bits => span 1 +0[1..1064]:00 (1063) => 0x0] (asn_bit_data.c:139)
[PER got 2<=1063 bits => span 3 +0[3..1064]:00 (1061) => 0x0] (asn_bit_data.c:139)
CHOICE NGAP-PDU got index 0 in range 2 (constr_CHOICE.c:1052)
Discovered CHOICE NGAP-PDU encodes initiatingMessage (constr_CHOICE.c:1080)
Decoding InitiatingMessage as SEQUENCE (APER) (constr_SEQUENCE.c:1509)
Decoding member "procedureCode" in InitiatingMessage (constr_SEQUENCE.c:1599)
Decoding NativeInteger ProcedureCode (APER) (NativeInteger.c:334)
Integer with range 8 bits (INTEGER.c:865)
Aligning 5 bits (per_support.c:317)
[PER got 5<=1061 bits => span 8 +0[8..1064]:00 (1056) => 0x0] (asn_bit_data.c:139)
[PER got 8<=1056 bits => span 16 +1[8..1056]:1d (1048) => 0x1d] (asn_bit_data.c:139)
Got value 29 + low 0 (INTEGER.c:926)
NativeInteger ProcedureCode got value 29 (NativeInteger.c:351)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Decoding member "criticality" in InitiatingMessage (constr_SEQUENCE.c:1599)
Decoding Criticality as NativeEnumerated (NativeEnumerated.c:255)
[PER got 2<=1048 bits => span 18 +2[2..1048]:00 (1046) => 0x0] (asn_bit_data.c:139)
Decoded Criticality = 0 (NativeEnumerated.c:293)
Decoding member "value" in InitiatingMessage (constr_SEQUENCE.c:1599)
Getting open type PDUSessionResourceSetupRequest... (per_opentype.c:412)
Aligning 6 bits (per_support.c:317)
[PER got 6<=1046 bits => span 24 +2[8..1048]:00 (1040) => 0x0] (asn_bit_data.c:139)
[PER got 8<=1040 bits => span 32 +3[8..1040]:80 (1032) => 0x80] (asn_bit_data.c:139)
[PER got 8<=1032 bits => span 40 +4[8..1032]:80 (1024) => 0x80] (asn_bit_data.c:139)
[PER got 24<=1024 bits => span 64 +5[24..1024]:00 (1000) => 0x3] (asn_bit_data.c:139)
[PER got 24<=1000 bits => span 88 +8[24..1000]:00 (976) => 0xa00] (asn_bit_data.c:139)
[PER got 24<=976 bits => span 112 +11[24..976]:02 (952) => 0x20000] (asn_bit_data.c:139)
[PER got 24<=952 bits => span 136 +14[24..952]:00 (928) => 0x5500] (asn_bit_data.c:139)
[PER got 24<=928 bits => span 160 +1[24..928]:02 (904) => 0x20000] (asn_bit_data.c:139)
[PER got 24<=904 bits => span 184 +4[24..904]:00 (880) => 0x4a00] (asn_bit_data.c:139)
[PER got 24<=880 bits => span 208 +7[24..880]:6d (856) => 0x6d0040] (asn_bit_data.c:139)
[PER got 24<=856 bits => span 232 +10[24..856]:05 (832) => 0x53b7e] (asn_bit_data.c:139)
[PER got 24<=832 bits => span 256 +13[24..832]:02 (808) => 0x2ac33] (asn_bit_data.c:139)
[PER got 24<=808 bits => span 280 +0[24..808]:8e (784) => 0x8ea502] (asn_bit_data.c:139)
[PER got 24<=784 bits => span 304 +3[24..784]:7e (760) => 0x7e0068] (asn_bit_data.c:139)
[PER got 24<=760 bits => span 328 +6[24..760]:01 (736) => 0x1002c] (asn_bit_data.c:139)
[PER got 24<=736 bits => span 352 +9[24..736]:2e (712) => 0x2e0501] (asn_bit_data.c:139)
[PER got 24<=712 bits => span 376 +12[24..712]:c2 (688) => 0xc21100] (asn_bit_data.c:139)
[PER got 24<=688 bits => span 400 +15[24..688]:09 (664) => 0x90100] (asn_bit_data.c:139)
[PER got 24<=664 bits => span 424 +2[24..664]:06 (640) => 0x63120] (asn_bit_data.c:139)
[PER got 24<=640 bits => span 448 +5[24..640]:00 (616) => 0xff] (asn_bit_data.c:139)
[PER got 24<=616 bits => span 472 +8[24..616]:01 (592) => 0x10601] (asn_bit_data.c:139)
[PER got 24<=592 bits => span 496 +11[24..592]:00 (568) => 0x101] (asn_bit_data.c:139)
[PER got 24<=568 bits => span 520 +14[24..568]:00 (544) => 0x129] (asn_bit_data.c:139)
[PER got 24<=544 bits => span 544 +1[24..544]:05 (520) => 0x50132] (asn_bit_data.c:139)
[PER got 24<=520 bits => span 568 +4[24..520]:00 (496) => 0x1] (asn_bit_data.c:139)
[PER got 24<=496 bits => span 592 +7[24..496]:25 (472) => 0x250c07] (asn_bit_data.c:139)
[PER got 24<=472 bits => span 616 +10[24..472]:67 (448) => 0x676967] (asn_bit_data.c:139)
[PER got 24<=448 bits => span 640 +13[24..448]:61 (424) => 0x616d6f] (asn_bit_data.c:139)
[PER got 24<=424 bits => span 664 +0[24..424]:6e (400) => 0x6e0363] (asn_bit_data.c:139)
[PER got 24<=400 bits => span 688 +3[24..400]:6f (376) => 0x6f6d12] (asn_bit_data.c:139)
[PER got 24<=376 bits => span 712 +6[24..376]:05 (352) => 0x50000] (asn_bit_data.c:139)
[PER got 24<=352 bits => span 736 +9[24..352]:2b (328) => 0x2b0000] (asn_bit_data.c:139)
[PER got 24<=328 bits => span 760 +12[24..328]:04 (304) => 0x40082] (asn_bit_data.c:139)
[PER got 24<=304 bits => span 784 +15[24..304]:00 (280) => 0x604] (asn_bit_data.c:139)
[PER got 24<=280 bits => span 808 +2[24..280]:03 (256) => 0x3e810] (asn_bit_data.c:139)
[PER got 24<=256 bits => span 832 +5[24..256]:03 (232) => 0x3e800] (asn_bit_data.c:139)
[PER got 24<=232 bits => span 856 +8[24..232]:8b (208) => 0x8b000a] (asn_bit_data.c:139)
[PER got 24<=208 bits => span 880 +11[24..208]:01 (184) => 0x1f00a] (asn_bit_data.c:139)
[PER got 24<=184 bits => span 904 +14[24..184]:32 (160) => 0x32020a] (asn_bit_data.c:139)
[PER got 24<=160 bits => span 928 +1[24..160]:00 (136) => 0x0] (asn_bit_data.c:139)
[PER got 24<=136 bits => span 952 +4[24..136]:01 (112) => 0x10086] (asn_bit_data.c:139)
[PER got 24<=112 bits => span 976 +7[24..112]:00 (88) => 0x100] (asn_bit_data.c:139)
[PER got 24<=88 bits => span 1000 +10[24..88]:00 (64) => 0x8800] (asn_bit_data.c:139)
[PER got 24<=64 bits => span 1024 +13[24..64]:07 (40) => 0x70001] (asn_bit_data.c:139)
[PER got 24<=40 bits => span 1048 +0[24..40]:00 (16) => 0x5] (asn_bit_data.c:139)
[PER got 16<=16 bits => span 1064 +3[16..16]:00 (0) => 0x0] (asn_bit_data.c:139)
Getting open type PDUSessionResourceSetupRequest encoded in 128 bytes (per_opentype.c:438)
Decoding PDUSessionResourceSetupRequest as SEQUENCE (APER) (constr_SEQUENCE.c:1509)
[PER got 1<=1024 bits => span 1 +0[1..1024]:00 (1023) => 0x0] (asn_bit_data.c:139)
Decoding member "protocolIEs" in PDUSessionResourceSetupRequest (constr_SEQUENCE.c:1599)
getting nsnnwn with range 65536 (per_support.c:378)
Aligning 7 bits (per_support.c:317)
[PER got 7<=1023 bits => span 8 +0[8..1024]:00 (1016) => 0x0] (asn_bit_data.c:139)
[PER got 16<=1016 bits => span 24 +1[16..1016]:00 (1000) => 0x3] (asn_bit_data.c:139)
Preparing to fetch 3+0 elements from ProtocolIE-Container (constr_SET_OF.c:1236)
SET OF PDUSessionResourceSetupRequestIEs decoding (constr_SET_OF.c:1255)
Decoding PDUSessionResourceSetupRequestIEs as SEQUENCE (APER) (constr_SEQUENCE.c:1509)
Decoding member "id" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Decoding NativeInteger ProtocolIE-ID (APER) (NativeInteger.c:334)
Integer with range 16 bits (INTEGER.c:865)
[PER got 16<=1000 bits => span 40 +3[16..1000]:00 (984) => 0xa] (asn_bit_data.c:139)
Got value 10 + low 0 (INTEGER.c:926)
NativeInteger ProtocolIE-ID got value 10 (NativeInteger.c:351)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Decoding member "criticality" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Decoding Criticality as NativeEnumerated (NativeEnumerated.c:255)
[PER got 2<=984 bits => span 42 +5[2..984]:00 (982) => 0x0] (asn_bit_data.c:139)
Decoded Criticality = 0 (NativeEnumerated.c:293)
Decoding member "value" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Getting open type AMF-UE-NGAP-ID... (per_opentype.c:412)
Aligning 6 bits (per_support.c:317)
[PER got 6<=982 bits => span 48 +5[8..984]:00 (976) => 0x0] (asn_bit_data.c:139)
[PER got 8<=976 bits => span 56 +6[8..976]:02 (968) => 0x2] (asn_bit_data.c:139)
[PER got 16<=968 bits => span 72 +7[16..968]:00 (952) => 0x0] (asn_bit_data.c:139)
Getting open type AMF-UE-NGAP-ID encoded in 2 bytes (per_opentype.c:438)
Integer with range 40 bits (INTEGER.c:865)
Can encode 40 (5 bytes) in 3 bits (INTEGER.c:879)
[PER got 3<=16 bits => span 3 +0[3..16]:00 (13) => 0x0] (asn_bit_data.c:139)
Got length 1 (INTEGER.c:886)
Aligning 5 bits (per_support.c:317)
[PER got 5<=13 bits => span 8 +0[8..16]:00 (8) => 0x0] (asn_bit_data.c:139)
[PER got 8<= 8 bits => span 16 +1[8..8]:00 (0) => 0x0] (asn_bit_data.c:139)
Got value 0 + low 0 (INTEGER.c:902)
No padding (per_opentype.c:464)
ProtocolIE-Container SET OF PDUSessionResourceSetupRequestIEs decoded 0, 0x558f3b671810 (constr_SET_OF.c:1259)
SET OF PDUSessionResourceSetupRequestIEs decoding (constr_SET_OF.c:1255)
Decoding PDUSessionResourceSetupRequestIEs as SEQUENCE (APER) (constr_SEQUENCE.c:1509)
Decoding member "id" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Decoding NativeInteger ProtocolIE-ID (APER) (NativeInteger.c:334)
Integer with range 16 bits (INTEGER.c:865)
[PER got 16<=952 bits => span 88 +9[16..952]:00 (936) => 0x55] (asn_bit_data.c:139)
Got value 85 + low 0 (INTEGER.c:926)
NativeInteger ProtocolIE-ID got value 85 (NativeInteger.c:351)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Decoding member "criticality" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Decoding Criticality as NativeEnumerated (NativeEnumerated.c:255)
[PER got 2<=936 bits => span 90 +11[2..936]:00 (934) => 0x0] (asn_bit_data.c:139)
Decoded Criticality = 0 (NativeEnumerated.c:293)
Decoding member "value" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Getting open type RAN-UE-NGAP-ID... (per_opentype.c:412)
Aligning 6 bits (per_support.c:317)
[PER got 6<=934 bits => span 96 +11[8..936]:00 (928) => 0x0] (asn_bit_data.c:139)
[PER got 8<=928 bits => span 104 +12[8..928]:02 (920) => 0x2] (asn_bit_data.c:139)
[PER got 16<=920 bits => span 120 +13[16..920]:00 (904) => 0x0] (asn_bit_data.c:139)
Getting open type RAN-UE-NGAP-ID encoded in 2 bytes (per_opentype.c:438)
Decoding NativeInteger RAN-UE-NGAP-ID (APER) (NativeInteger.c:334)
Integer with range 32 bits (INTEGER.c:865)
Can encode 32 (4 bytes) in 2 bits (INTEGER.c:879)
[PER got 2<=16 bits => span 2 +0[2..16]:00 (14) => 0x0] (asn_bit_data.c:139)
Got length 1 (INTEGER.c:886)
Aligning 6 bits (per_support.c:317)
[PER got 6<=14 bits => span 8 +0[8..16]:00 (8) => 0x0] (asn_bit_data.c:139)
[PER got 8<= 8 bits => span 16 +1[8..8]:00 (0) => 0x0] (asn_bit_data.c:139)
Got value 0 + low 0 (INTEGER.c:902)
NativeInteger RAN-UE-NGAP-ID got value 0 (NativeInteger.c:351)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
No padding (per_opentype.c:464)
ProtocolIE-Container SET OF PDUSessionResourceSetupRequestIEs decoded 0, 0x558f3b6718f0 (constr_SET_OF.c:1259)
SET OF PDUSessionResourceSetupRequestIEs decoding (constr_SET_OF.c:1255)
Decoding PDUSessionResourceSetupRequestIEs as SEQUENCE (APER) (constr_SEQUENCE.c:1509)
Decoding member "id" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Decoding NativeInteger ProtocolIE-ID (APER) (NativeInteger.c:334)
Integer with range 16 bits (INTEGER.c:865)
[PER got 16<=904 bits => span 136 +15[16..904]:00 (888) => 0x4a] (asn_bit_data.c:139)
Got value 74 + low 0 (INTEGER.c:926)
NativeInteger ProtocolIE-ID got value 74 (NativeInteger.c:351)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
Decoding member "criticality" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Decoding Criticality as NativeEnumerated (NativeEnumerated.c:255)
[PER got 2<=888 bits => span 138 +1[2..888]:00 (886) => 0x0] (asn_bit_data.c:139)
Decoded Criticality = 0 (NativeEnumerated.c:293)
Decoding member "value" in PDUSessionResourceSetupRequestIEs (constr_SEQUENCE.c:1599)
Getting open type PDUSessionResourceSetupListSUReq... (per_opentype.c:412)
Aligning 6 bits (per_support.c:317)
[PER got 6<=886 bits => span 144 +1[8..888]:00 (880) => 0x0] (asn_bit_data.c:139)
[PER got 8<=880 bits => span 152 +2[8..880]:6d (872) => 0x6d] (asn_bit_data.c:139)
[PER got 24<=872 bits => span 176 +3[24..872]:00 (848) => 0x4005] (asn_bit_data.c:139)
[PER got 24<=848 bits => span 200 +6[24..848]:3b (824) => 0x3b7e02] (asn_bit_data.c:139)
[PER got 24<=824 bits => span 224 +9[24..824]:ac (800) => 0xac338e] (asn_bit_data.c:139)
[PER got 24<=800 bits => span 248 +12[24..800]:a5 (776) => 0xa5027e] (asn_bit_data.c:139)
[PER got 24<=776 bits => span 272 +15[24..776]:00 (752) => 0x6801] (asn_bit_data.c:139)
[PER got 24<=752 bits => span 296 +2[24..752]:00 (728) => 0x2c2e] (asn_bit_data.c:139)
[PER got 24<=728 bits => span 320 +5[24..728]:05 (704) => 0x501c2] (asn_bit_data.c:139)
[PER got 24<=704 bits => span 344 +8[24..704]:11 (680) => 0x110009] (asn_bit_data.c:139)
[PER got 24<=680 bits => span 368 +11[24..680]:01 (656) => 0x10006] (asn_bit_data.c:139)
[PER got 24<=656 bits => span 392 +14[24..656]:31 (632) => 0x312000] (asn_bit_data.c:139)
[PER got 24<=632 bits => span 416 +1[24..632]:00 (608) => 0xff01] (asn_bit_data.c:139)
[PER got 24<=608 bits => span 440 +4[24..608]:06 (584) => 0x60100] (asn_bit_data.c:139)
[PER got 24<=584 bits => span 464 +7[24..584]:01 (560) => 0x10100] (asn_bit_data.c:139)
[PER got 24<=560 bits => span 488 +10[24..560]:01 (536) => 0x12905] (asn_bit_data.c:139)
[PER got 24<=536 bits => span 512 +13[24..536]:01 (512) => 0x13200] (asn_bit_data.c:139)
[PER got 24<=512 bits => span 536 +0[24..512]:00 (488) => 0x125] (asn_bit_data.c:139)
[PER got 24<=488 bits => span 560 +3[24..488]:0c (464) => 0xc0767] (asn_bit_data.c:139)
[PER got 24<=464 bits => span 584 +6[24..464]:69 (440) => 0x696761] (asn_bit_data.c:139)
[PER got 24<=440 bits => span 608 +9[24..440]:6d (416) => 0x6d6f6e] (asn_bit_data.c:139)
[PER got 24<=416 bits => span 632 +12[24..416]:03 (392) => 0x3636f] (asn_bit_data.c:139)
[PER got 24<=392 bits => span 656 +15[24..392]:6d (368) => 0x6d1205] (asn_bit_data.c:139)
[PER got 24<=368 bits => span 680 +2[24..368]:00 (344) => 0x2b] (asn_bit_data.c:139)
[PER got 24<=344 bits => span 704 +5[24..344]:00 (320) => 0x4] (asn_bit_data.c:139)
[PER got 24<=320 bits => span 728 +8[24..320]:00 (296) => 0x8200] (asn_bit_data.c:139)
[PER got 24<=296 bits => span 752 +11[24..296]:06 (272) => 0x60403] (asn_bit_data.c:139)
[PER got 24<=272 bits => span 776 +14[24..272]:e8 (248) => 0xe81003] (asn_bit_data.c:139)
[PER got 24<=248 bits => span 800 +1[24..248]:e8 (224) => 0xe8008b] (asn_bit_data.c:139)
[PER got 24<=224 bits => span 824 +4[24..224]:00 (200) => 0xa01] (asn_bit_data.c:139)
[PER got 24<=200 bits => span 848 +7[24..200]:f0 (176) => 0xf00a32] (asn_bit_data.c:139)
[PER got 24<=176 bits => span 872 +10[24..176]:02 (152) => 0x20a00] (asn_bit_data.c:139)
[PER got 24<=152 bits => span 896 +13[24..152]:00 (128) => 0x1] (asn_bit_data.c:139)
[PER got 24<=128 bits => span 920 +0[24..128]:00 (104) => 0x8600] (asn_bit_data.c:139)
[PER got 24<=104 bits => span 944 +3[24..104]:01 (80) => 0x10000] (asn_bit_data.c:139)
[PER got 24<=80 bits => span 968 +6[24..80]:88 (56) => 0x880007] (asn_bit_data.c:139)
[PER got 24<=56 bits => span 992 +9[24..56]:00 (32) => 0x100] (asn_bit_data.c:139)
[PER got 24<=32 bits => span 1016 +12[24..32]:00 (8) => 0x500] (asn_bit_data.c:139)
[PER got 8<= 8 bits => span 1024 +15[8..8]:00 (0) => 0x0] (asn_bit_data.c:139)
Getting open type PDUSessionResourceSetupListSUReq encoded in 109 bytes (per_opentype.c:438)
getting nsnnwn with range 256 (per_support.c:378)
[PER got 8<=872 bits => span 8 +0[8..872]:00 (864) => 0x0] (asn_bit_data.c:139)
Preparing to fetch 0+1 elements from PDUSessionResourceSetupListSUReq (constr_SET_OF.c:1236)
SET OF PDUSessionResourceSetupItemSUReq decoding (constr_SET_OF.c:1255)
Decoding PDUSessionResourceSetupItemSUReq as SEQUENCE (APER) (constr_SEQUENCE.c:1509)
[PER got 1<=864 bits => span 9 +1[1..864]:40 (863) => 0x0] (asn_bit_data.c:139)
[PER got 2<=863 bits => span 11 +1[3..864]:40 (861) => 0x2] (asn_bit_data.c:139)
Read in presence bitmap for PDUSessionResourceSetupItemSUReq of 2 bits (80..) (constr_SEQUENCE.c:1532)
Decoding member "pDUSessionID" in PDUSessionResourceSetupItemSUReq (constr_SEQUENCE.c:1599)
Decoding NativeInteger PDUSessionID (APER) (NativeInteger.c:334)
Integer with range 8 bits (INTEGER.c:865)
Aligning 5 bits (per_support.c:317)
[PER got 5<=861 bits => span 16 +1[8..864]:40 (856) => 0x0] (asn_bit_data.c:139)
[PER got 8<=856 bits => span 24 +2[8..856]:05 (848) => 0x5] (asn_bit_data.c:139)
Got value 5 + low 0 (INTEGER.c:926)
NativeInteger PDUSessionID got value 5 (NativeInteger.c:351)
Freeing INTEGER as a primitive type (asn_codecs_prim.c:125)
[PER got 1<= 2 bits => span 1 +0[1..2]:80 (1) => 0x1] (asn_bit_data.c:139)
Member PDUSessionResourceSetupItemSUReq->pDUSessionNAS-PDU is optional, p=1 (1->2) (constr_SEQUENCE.c:1581)
Decoding member "pDUSessionNAS-PDU" in PDUSessionResourceSetupItemSUReq (constr_SEQUENCE.c:1599)
PER Decoding non-extensible size 0 .. 0 bits -1 (OCTET_STRING.c:1728)
[PER got 8<=848 bits => span 32 +3[8..848]:3b (840) => 0x3b] (asn_bit_data.c:139)
Got PER length eb -1, len 59, once (NAS-PDU) (OCTET_STRING.c:1803)
Expanding 59 characters into (0..255):8 (OCTET_STRING.c:1225)
[PER got 24<=840 bits => span 56 +4[24..840]:7e (816) => 0x7e02ac] (asn_bit_data.c:139)
[PER got 24<=816 bits => span 80 +7[24..816]:33 (792) => 0x338ea5] (asn_bit_data.c:139)
[PER got 24<=792 bits => span 104 +10[24..792]:02 (768) => 0x27e00] (asn_bit_data.c:139)
[PER got 24<=768 bits => span 128 +13[24..768]:68 (744) => 0x680100] (asn_bit_data.c:139)
[PER got 24<=744 bits => span 152 +0[24..744]:2c (720) => 0x2c2e05] (asn_bit_data.c:139)
[PER got 24<=720 bits => span 176 +3[24..720]:01 (696) => 0x1c211] (asn_bit_data.c:139)
[PER got 24<=696 bits => span 200 +6[24..696]:00 (672) => 0x901] (asn_bit_data.c:139)
[PER got 24<=672 bits => span 224 +9[24..672]:00 (648) => 0x631] (asn_bit_data.c:139)
[PER got 24<=648 bits => span 248 +12[24..648]:20 (624) => 0x200000] (asn_bit_data.c:139)
[PER got 24<=624 bits => span 272 +15[24..624]:ff (600) => 0xff0106] (asn_bit_data.c:139)
[PER got 24<=600 bits => span 296 +2[24..600]:01 (576) => 0x10001] (asn_bit_data.c:139)
[PER got 24<=576 bits => span 320 +5[24..576]:01 (552) => 0x10001] (asn_bit_data.c:139)
[PER got 24<=552 bits => span 344 +8[24..552]:29 (528) => 0x290501] (asn_bit_data.c:139)
[PER got 24<=528 bits => span 368 +11[24..528]:32 (504) => 0x320000] (asn_bit_data.c:139)
[PER got 24<=504 bits => span 392 +14[24..504]:01 (480) => 0x1250c] (asn_bit_data.c:139)
[PER got 24<=480 bits => span 416 +1[24..480]:07 (456) => 0x76769] (asn_bit_data.c:139)
[PER got 24<=456 bits => span 440 +4[24..456]:67 (432) => 0x67616d] (asn_bit_data.c:139)
[PER got 24<=432 bits => span 464 +7[24..432]:6f (408) => 0x6f6e03] (asn_bit_data.c:139)
[PER got 24<=408 bits => span 488 +10[24..408]:63 (384) => 0x636f6d] (asn_bit_data.c:139)
[PER got 16<=384 bits => span 504 +13[16..384]:12 (368) => 0x1205] (asn_bit_data.c:139)
Decoding member "s-NSSAI" in PDUSessionResourceSetupItemSUReq (constr_SEQUENCE.c:1599)
Decoding S-NSSAI as SEQUENCE (APER) (constr_SEQUENCE.c:1509)
[PER got 1<=368 bits => span 505 +15[1..368]:00 (367) => 0x0] (asn_bit_data.c:139)
[PER got 2<=367 bits => span 507 +15[3..368]:00 (365) => 0x0] (asn_bit_data.c:139)
Read in presence bitmap for S-NSSAI of 2 bits (0..) (constr_SEQUENCE.c:1532)
Decoding member "sST" in S-NSSAI (constr_SEQUENCE.c:1599)
PER Decoding non-extensible size 1 .. 1 bits 0 (OCTET_STRING.c:1728)
Decoding OCTET STRING size 1 (OCTET_STRING.c:1762)
Expanding 1 characters into (0..0):8 (OCTET_STRING.c:1225)
[PER got 8<=365 bits => span 515 +15[11..368]:00 (357) => 0x0] (asn_bit_data.c:139)
[PER got 1<= 2 bits => span 1 +0[1..2]:00 (1) => 0x0] (asn_bit_data.c:139)
Member S-NSSAI->sD is optional, p=0 (1->2) (constr_SEQUENCE.c:1581)
[PER got 1<= 1 bits => span 2 +0[2..2]:00 (0) => 0x0] (asn_bit_data.c:139)
Member S-NSSAI->iE-Extensions is optional, p=0 (2->2) (constr_SEQUENCE.c:1581)
Decoding member "pDUSessionResourceSetupRequestTransfer" in PDUSessionResourceSetupItemSUReq (constr_SEQUENCE.c:1599)
PER Decoding non-extensible size 0 .. 0 bits -1 (OCTET_STRING.c:1728)
Aligning 5 bits (per_support.c:317)
[PER got 5<=357 bits => span 520 +0[8..360]:00 (352) => 0x0] (asn_bit_data.c:139)
[PER got 8<=352 bits => span 528 +1[8..352]:2b (344) => 0x2b] (asn_bit_data.c:139)
Got PER length eb -1, len 43, once (OCTET STRING) (OCTET_STRING.c:1803)
Expanding 43 characters into (0..0):8 (OCTET_STRING.c:1225)
[PER got 24<=344 bits => span 552 +2[24..344]:00 (320) => 0x4] (asn_bit_data.c:139)
[PER got 24<=320 bits => span 576 +5[24..320]:00 (296) => 0x8200] (asn_bit_data.c:139)
[PER got 24<=296 bits => span 600 +8[24..296]:06 (272) => 0x60403] (asn_bit_data.c:139)
[PER got 24<=272 bits => span 624 +11[24..272]:e8 (248) => 0xe81003] (asn_bit_data.c:139)
[PER got 24<=248 bits => span 648 +14[24..248]:e8 (224) => 0xe8008b] (asn_bit_data.c:139)
[PER got 24<=224 bits => span 672 +1[24..224]:00 (200) => 0xa01] (asn_bit_data.c:139)
[PER got 24<=200 bits => span 696 +4[24..200]:f0 (176) => 0xf00a32] (asn_bit_data.c:139)
[PER got 24<=176 bits => span 720 +7[24..176]:02 (152) => 0x20a00] (asn_bit_data.c:139)
[PER got 24<=152 bits => span 744 +10[24..152]:00 (128) => 0x1] (asn_bit_data.c:139)
[PER got 24<=128 bits => span 768 +13[24..128]:00 (104) => 0x8600] (asn_bit_data.c:139)
[PER got 24<=104 bits => span 792 +0[24..104]:01 (80) => 0x10000] (asn_bit_data.c:139)
[PER got 24<=80 bits => span 816 +3[24..80]:88 (56) => 0x880007] (asn_bit_data.c:139)
[PER got 24<=56 bits => span 840 +6[24..56]:00 (32) => 0x100] (asn_bit_data.c:139)
[PER got 24<=32 bits => span 864 +9[24..32]:00 (8) => 0x500] (asn_bit_data.c:139)
[PER got 8<= 8 bits => span 872 +12[8..8]:00 (0) => 0x0] (asn_bit_data.c:139)
[PER got 1<= 1 bits => span 2 +0[2..2]:80 (0) => 0x0] (asn_bit_data.c:139)
Member PDUSessionResourceSetupItemSUReq->iE-Extensions is optional, p=0 (2->2) (constr_SEQUENCE.c:1581)
PDUSessionResourceSetupListSUReq SET OF PDUSessionResourceSetupItemSUReq decoded 0, 0x558f3b671ab0 (constr_SET_OF.c:1259)
Decoded PDUSessionResourceSetupListSUReq as SET OF (constr_SET_OF.c:1278)
No padding (per_opentype.c:464)
ProtocolIE-Container SET OF PDUSessionResourceSetupRequestIEs decoded 0, 0x558f3b6719a0 (constr_SET_OF.c:1259)
Decoded ProtocolIE-Container as SET OF (constr_SET_OF.c:1278)
No padding (per_opentype.c:464)
PER decoding consumed 1064, counted 1064 (per_decoder.c:177)
Error code -1686289136 consumed 0
NGAP_PDU message
InitiatingMessage ::= {
procedureCode: 29
criticality: 0 (reject)
value: PDUSessionResourceSetupRequest ::= {
protocolIEs: ProtocolIE-Container ::= {
PDUSessionResourceSetupRequestIEs ::= {
id: 10
criticality: 0 (reject)
value: 0
}
PDUSessionResourceSetupRequestIEs ::= {
id: 85
criticality: 0 (reject)
value: 0
}
PDUSessionResourceSetupRequestIEs ::= {
id: 74
criticality: 0 (reject)
value: PDUSessionResourceSetupListSUReq ::= {
PDUSessionResourceSetupItemSUReq ::= {
pDUSessionID: 5
pDUSessionNAS-PDU:
7E 02 AC 33 8E A5 02 7E 00 68 01 00 2C 2E 05 01
C2 11 00 09 01 00 06 31 20 00 00 FF 01 06 01 00
01 01 00 01 29 05 01 32 00 00 01 25 0C 07 67 69
67 61 6D 6F 6E 03 63 6F 6D 12 05
s-NSSAI: S-NSSAI ::= {
sST: 00
}
pDUSessionResourceSetupRequestTransfer:
00 00 04 00 82 00 06 04 03 E8 10 03 E8 00 8B 00
0A 01 F0 0A 32 02 0A 00 00 00 01 00 86 00 01 00
00 88 00 07 00 01 00 00 05 00 00
}
}
}
}
}
}
from asn1c.
Hi @RakeshMuthusamy,
I am working on to decode the 5G NGAP payload using mouse07410/asn1c compiler.
Are you working on an open source project?
I failed to decode PDUSessionResourceSetupRequestTransfer contents.
What do you mean by "failed to decode"? The output you have provided does not indicate any failures.
The workaround fix you mentioned is also not helping to solve the problem.
Are there any other latest fixes needed to solve the PDUSessionResourceSetupRequestTransfer decoding?
Not any that I'm aware of.
Steps followed:
1. Downloaded the compiler code from : https://github.com/mouse07410/asn1c 2. asn1c -fcompound-names -findirect-choice -fincludes-quoted -fno-include-deps -pdu=all -S ../skeletons/ /root/asn1/combined-NGAP-backup.asn
ASN files from https://github.com/wireshark/wireshark/tree/master/epan/dissectors/asn1/ngap
Could you provide combined-NGAP-backup.asn
as there is not such file at this URL?
1. I used my own test file to decode the below hex dump. (aper_decode) 2. Hex dump : char buf[] = {0x00,0x1d,0x00,0x80,0x80,0x00,0x00,0x03,0x00,0x0a,0x00,0x02,0x00,0x00,0x00,0x55,0x00,0x02,0x00,0x00,0x00,0x4a,0x00,0x6d,0x00,0x40,0x05,0x3b,0x7e,0x02,0xac,0x33,0x8e,0xa5,0x02,0x7e,0x00,0x68,0x01,0x00,0x2c,0x2e,0x05,0x01,0xc2,0x11,0x00,0x09,0x01,0x00,0x06,0x31,0x20,0x00,0x00,0xff,0x01,0x06,0x01,0x00,0x01,0x01,0x00,0x01,0x29,0x05,0x01,0x32,0x00,0x00,0x01,0x25,0x0c,0x07,0x67,0x69,0x67,0x61,0x6d,0x6f,0x6e,0x03,0x63,0x6f,0x6d,0x12,0x05,0x00,0x00,0x2b,0x00,0x00,0x04,0x00,0x82,0x00,0x06,0x04,0x03,0xe8,0x10,0x03,0xe8,0x00,0x8b,0x00,0x0a,0x01,0xf0,0x0a,0x32,0x02,0x0a,0x00,0x00,0x00,0x01,0x00,0x86,0x00,0x01,0x00,0x00,0x88,0x00,0x07,0x00,0x01,0x00,0x00,0x05,0x00,0x00}
Are you sure that this is a valid APER encoded message? Where do you get this message from?
3. decoder routine : NGAP_PDU_t *pdusess=0; aper_decode(0, &asn_DEF_NGAP_PDU, (void **)&pdusess, buf, sizeof(buf),0 ,0); asn_fprint(stdout, &asn_DEF_NGAP_PDU, pdusess);
You need to check aper_decode
return value.
Output:
CALLING aper_decode
.....
Decoded ProtocolIE-Container as SET OF (constr_SET_OF.c:1278)
No padding (per_opentype.c:464)
PER decoding consumed 1064, counted 1064 (per_decoder.c:177)
Could you use markdown to format your messages and also upload big outputs as files somewhere and provide only links here. Such long posts as yours make the discussion really hard to follow.
Error code -1686289136 consumed 0
This line is not printed by asn1c's code or at least I can't find where this is printed. Make sure you initialize your variables.
pDUSessionResourceSetupRequestTransfer:
00 00 04 00 82 00 06 04 03 E8 10 03 E8 00 8B 00
0A 01 F0 0A 32 02 0A 00 00 00 01 00 86 00 01 00
00 88 00 07 00 01 00 00 05 00 00
From NGAP-IEs.asn
pDUSessionResourceSetupRequestTransfer OCTET STRING (CONTAINING PDUSessionResourceSetupRequestTransfer),
pDUSessionResourceSetupRequestTransfer
is defined as OCTEST STRING so it won't be decoded automatically. You need to call aper_decode
second time with the above hex (taken from the corresponding pdusess
member)
The XER
you've provided is only available in the email, probably github has truncated your message as it was too long.
from asn1c.
Yeah... I forgot...
But it would be truly great if CONTAINING
could be supported.
I think it applies only to OCTET STRING
, as no other type would serve as an encapsulation for another?
from asn1c.
Related Issues (20)
- Unable to decode lte rrc UE-EUTRA-Capability message HOT 2
- Consider adding AUTOMATIC TAGS after module NR-RRC-Definitions DEFINITIONS, or manually tag components in NR-RRC-Definitions.asn HOT 3
- Newie questions HOT 2
- Decode base64 UPER encoded string HOT 1
- Problem parsing ISO-TS-19091-addgrp-C-2018.asn HOT 2
- CHOICE_decode_aper result was wrong when decoding an extension CHOICE HOT 2
- uper_open_type_skip bug HOT 2
- Buffer overflow in ASN.1 deserializer HOT 12
- Bug with JUNKTEST with Random values on MSYS2 and Cygwin HOT 1
- Decode expectedUEBehaviour IE failed HOT 1
- Type with (size) constraint HOT 4
- Join LFC? HOT 1
- Output from encoding an OpenType extension is wrong (APER) HOT 5
- Help debugging "Segmentation fault (core dumped)" HOT 7
- Problem compiling. HOT 4
- Question about v1.0.0. HOT 1
- Problem compiling: contains no objects HOT 4
- APER encoding failed on a 32-bit machine HOT 8
- INTEGER_decode_aper decode failed for 3GPP 38.473 f1ap ASN HOT 4
- Using fuzzing with asn1c HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asn1c.