asn.1 parser in C/Python

后端 未结 7 2209
借酒劲吻你
借酒劲吻你 2021-02-02 00:41

I am looking for a solution to parse asn.1 spec files and generate a decoder from those.

Ideally I would like to work with Python modules, but if nothing is available I

7条回答
  •  不要未来只要你来
    2021-02-02 00:57

    I have done a similar job using asn1c and building around it a Pyrex extension. The wrapped structure is described in 3GPP TS 32.401.

    With Pyrex you can write a wrapper thick enough to convert between native Python data types and the correct ASN.1 representations (wrapper generators, such SWIG, tend to not perform complex operations on the type). The wrapper I wrote also tracked the ownership of the underlying C data structures (e.g. accessing to a sub-structure, a Python object was returned, but there was no copy of the underlying data, only reference sharing).

    The wrapper was eventually written in a kind of semi-automatic way, but because that has been my only job with ASN.1 I never did the step of completely automatize the code generation.

    You can try to use other Python-C wrappers and perform a completely automatic conversion: the job would be less, but then you would move complexity (and repetitive error-prone operations) to the structure users: for this reason I preferred the Pyrex way. asn1c was definitely a good choice.

提交回复
热议问题