P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
381 stars 132 forks source link

Issue while Parsing MMTelChargingDataTypes.MMTelServiceRecord #183

Closed atiftariq01 closed 2 years ago

atiftariq01 commented 2 years ago

below issue found into (MMTelServiceRecord.mMTelRecord.recordExtensions.item.information) using

from pycrate_asn1dir.CDR import *

MMtel=MMTelChargingDataTypes.MMTelServiceRecord

decoded_data=MMtel.from_ber(encoded_str)

OPEN._decode_ber_cont: MMTelServiceRecord.mMTelRecord.recordExtensions.item.information, unable to retrieve a table-looked up object

p1-bmu commented 2 years ago

How am I supposed to help you if you do not share any information to reproduce the issue ? And please explain what is exactly your issue. According to the library message, you are decoding an object for which the ASN.1 definition does not exist in the CDR ASN.1 modules. Should it be different ? What are you expecting as a result ?

So, at least, share the buffer that you want to decode and triggers this log (see https://github.com/P1sec/pycrate#filling-an-issue).

atiftariq01 commented 2 years ago

MTAS_1052820220216115750.zip i am trying to decode attached MMtel record with below asn grammar. same grammar works with .Net code and python ans1tools but not working with pycrate as getting above error. can you please help me on it ? pycrate-master\pycrate_asn1dir\3GPP_CDR_3229\MMTelChargingDataTypes.asn MMTelChargingDataTypesasn.zip

i am using python 3.7 and pycrate latest 0.53 ###################################################### below is code ###################################################### from pycrate_asn1dir.CDR import *

import base64

from binascii import hexlify, unhexlify

MMtel=MMTelChargingDataTypes.MMTelServiceRecord

MMtel.get_proto()

ber_path_file=r"MTAS_1052820220216115750.ber"

with open(ber_path_file, 'rb') as f: encoded_str = f.read()

decoded_data=MMtel.from_ber(encoded_str)

Error:

OPEN._decode_ber_cont: MMTelServiceRecord.mMTelRecord.recordExtensions.item.information, unable to retrieve a table-looked up object

p1-bmu commented 2 years ago

I'll check the data you are providing, thanks for this. But again, the message you get while decoding is not an error message ; it just says an OPEN object is not fully defined into the ASN.1 schema. Does the value returned by your .Net tool or Python asn1tools differ from what you obtain with pycrate ?

atiftariq01 commented 2 years ago

yes .Net returns value and pycrate failing to produce output. Thank You

p1-bmu commented 2 years ago

This is how your buffer is decoded by pycrate:

mMTelRecord : {
  recordType 83 -- mMTelRecord --,
  role-of-Node originating,
  nodeAddress domainName : "chr-mu00-vmtas01.ims.mnc006.mcc422.3gppnetwork.org",
  session-Id "chr-mu00-vmtas01.ims.mnc006.mcc422.3gppnetwork.org;383005;4184094139;6669;81;0;sip:+96877389100@ims.mnc006.mcc422.3gppnetwork.org",
  list-Of-Calling-Party-Address {
    tEL-URI : "tel:+96877389100",
    sIP-URI : "sip:+96877389100@ims.mnc006.mcc422.3gppnetwork.org"
  },
  called-Party-Address tEL-URI : "tel:+96891952012;npdi;rn=+968-D92",
  recordSequenceNumber 3,
  iMS-Charging-Identifier '627330302D7669626366303130322E696D732E6D6E633030362E6D63632D313634342D3939383133322D3733393138322D323534'H -- bs00-vibcf0102.ims.mnc006.mcc-1644-998132-739182-254 --,
  recordExtensions {
    {
      identifier {0 4 0 127 0 5 2 2 0 0 0 2 0 1},
      significance TRUE,
      information '3146A03C0C0F2B672E6572696373736F6E2E6D6D740C2975726E25334175726E2D37253341336770702D736572766963652E696D732E696373692E6D6D74656CB6068301008C0102'H
    }
  },
  serviceContextID "006.422.12.32275@3gpp.org",
  list-of-subscription-ID {
    {
      subscriptionIDType eND-USER-SIP-URI,
      subscriptionIDData "sip:+96877389100@ims.mnc006.mcc422.3gppnetwork.org"
    }
  },
  outgoingSessionId "p65541t1644998132m951110c6669s4"
}

The log you have printed at decoding says the content of recordExtensions.item.information is not known and cannot be decoded further. As this is an extension, one can guess it may be a proprietary / vendor extension, which is not defined in the 3GPP provided ASN.1 schema.

From your code snippet, if you want to get the value from the object after calling from_ber(), you need to call get_val(). Please read the wiki: https://github.com/P1sec/pycrate/wiki/Using-the-pycrate-asn1-runtime

atiftariq01 commented 2 years ago

can you please share code you used to decode file ? Grateful for your help

p1-bmu commented 2 years ago

Everything is explained in the wiki. Just read it.

atiftariq01 commented 2 years ago

Got it !!!!!! Really Thank You !!!!!!!!!!!!!!!!!!! :) :) :)