Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to decode S1 message #111

Open
AuthenticEshkinKot opened this issue Aug 1, 2016 · 9 comments
Open

Unable to decode S1 message #111

AuthenticEshkinKot opened this issue Aug 1, 2016 · 9 comments

Comments

@AuthenticEshkinKot
Copy link

AuthenticEshkinKot commented Aug 1, 2016

Hi,
Some time ago I've needed help with 3GPP TS 36.413 v.12.6.0 parsing and now I've got trouble with its message decoding.
I've got some network dump with S1 message of type InitiatingMessage . ASN.1 description of this type can be found in S1AP-PDU-Descriptions, in 3GPP TS 36.413 v.12.6.0. The message is (in hex format, coded with PER):

00 0a 40 27 00 00 04 00 50 40 02 6b 80 00 2b 40 06 05 80 fb 0a 6e aa 00 6d 40 01 00 00 2e 40 0b 00 00 2f 40 06 00 52 f0 11 15 1d

I'm trying to decode its binary representation using asn1c decode example with "ber_decode" replaced by "uper_decode" and I've got segfault. Detailed steps to reproduce:

  1. Clone this repo
  2. Apply patch add support for parsing Information Object and Information Object Set. #99
  3. Parse 3GPP TS 36.413 .asn files with "-gen-PER" flag
  4. Copypaste asn1c decode example, replace "ber_decode" with "uper_decode", replace Rectangle with InitiatingMessage
  5. Build decoder
  6. Execute it with name of binary file
@velichkov
Copy link
Contributor

Hi @AuthenticEshkinKot,

and I've got segfault.

Could you run it through gdb and provide the backtrace.

replace "ber_decode" with "uper_decode"

3GPP TS 36.413 uses Aligned PER and not Unaligned PER (uper)

9.4 Message Transfer Syntax
S1AP shall use the ASN.1 Basic Packed Encoding Rules (BASIC-PER) Aligned Variant as transfer syntax as specified in ITU-T Rec. X.691 [4].

Please read again the second part of my comment in #108

Have a look at openairinterface or osmo-iuh projects, they use a modified version of asn1c that adds aligned per support and some scripts to workaround Information Object Classes

@AuthenticEshkinKot
Copy link
Author

AuthenticEshkinKot commented Aug 2, 2016

Hi, @velichkov

Could you run it through gdb and provide the backtrace.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x00000000004166b3 in SEQUENCE_decode_uper (opt_codec_ctx=0x7fffffffd760, td=0x6f1500 <asn_DEF_InitiatingMessage>, constraints=0x0, sptr=0x7fffffffd7d8, pd=0x7fffffffd720) at /home/username/s1_asn.1/c_files_work/constr_SEQUENCE.c:1122
#2 0x0000000000450d73 in uper_decode (opt_codec_ctx=0x7fffffffd760, td=0x6f1500 <asn_DEF_InitiatingMessage>, sptr=0x7fffffffd7d8, buffer=0x7fffffffd7e0, size=26, skip_bits=0, unused_bits=0) at /home/username/s1_asn.1/c_files_work/per_decoder.c:79
#3 0x00000000004882e5 in main (ac=2, av=0x7fffffffdce8) at main.c:37

At main.c:37 - rval = uper_decode(0, &asn_DEF_InitiatingMessage, (void **)&initMsg, buf, size, 0, 0);

3GPP TS 36.413 uses Aligned PER and not Unaligned PER (uper)

Yes, I know. I've searched for "per_decode" or "aper_decode" or something similar and found nothing. But I am pretty sure that function for Aligned PER exists. Could you provide its name?

Please read again the second part of my comment in #108

I've tried them yesterday - both projects unable to parse .asn, falling with error:
ASN.1 grammar parse error near line 119 (token "id-Bearers-SubjectToStatusTransfer-Item"): syntax error, unexpected TOK_identifier, expecting '}'
Cannot parse "/home/username/s1_asn.1/S1AP-IEs.asn"

@AuthenticEshkinKot
Copy link
Author

@velichkov
I forgot to mention, that I turned on debug messages in asn1c and as I can see, it successfully parses "procedureCode" and "criticality" fields of "InitiatingMessage" and crashes on "value".

@velichkov
Copy link
Contributor

Hi @AuthenticEshkinKot,

Yes, I know. I've searched for "per_decode" or "aper_decode" or something similar and found nothing. But I am pretty sure that function for Aligned PER exists. Could you provide its name?

Unfortunately it does not exist. If you look at the OAI and osmocom versions you will see that they have added APER but this modifications are not yet merged to the master nor to the #99 versions.

I've tried them yesterday - both projects unable to parse .asn, falling with error:
ASN.1 grammar parse error near line 119 (token "id-Bearers-SubjectToStatusTransfer-Item"): syntax error, unexpected TOK_identifier, expecting '}'
Cannot parse "/home/username/s1_asn.1/S1AP-IEs.asn"

That's because the master, OAI and osmocom versions does not support Information Object Classes and that's why you are seeing similar errors. You need a version that supports both APER and Information Object classes but such version dose not exist yet.

@AuthenticEshkinKot
Copy link
Author

Thank you, @velichkov! I'll try to merge it.

@AuthenticEshkinKot
Copy link
Author

I've merged it, but I'm not sure about correctness. Anyway, I've tested it on 20-30 examples and everything was OK. Now I am planning to run it through some automatic tests in coming weeks.

@kevinchychen
Copy link

Hi @AuthenticEshkinKot,

Would you mind sharing the source code that you merged fro S1AP with me?

Grateful if you car share it with me.

@AuthenticEshkinKot
Copy link
Author

Hi @kevinchychen
I'll make pull request to this repo as soon as I can, probably in next few days.

@AuthenticEshkinKot
Copy link
Author

@kevinchychen
As I promised, I've made pull request #115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants