mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
97 stars 71 forks source link

parse parameterized Type failed #106

Open EliotCao opened 2 years ago

EliotCao commented 2 years ago

I use asn1c to generate C code from an asn file, but I got such warning and errors:

I use asn1c to generate C code from an asn file, but I got such warning and errors:

FATAL: Type ScmsPdu-Scoped expects specialization from ScmsPdu-Scoped at line 33 in ./test3.asn
FATAL: Cannot find type "<Type>" in constraints at line 38 in ./test3.asn
FATAL: Type ScmsPdu-Scoped expects specialization from ScmsPdu-Scoped at line 33 in ./test3.asn
FATAL: Cannot find type "<Type>" in constraints at line 38 in ./test3.asn
FATAL: Type ScmsPdu-Scoped expects specialization from ScmsPdu-Scoped at line 33 in ./test3.asn
FATAL: Cannot find type "<Type>" in constraints at line 38 in ./test3.asn

And these is my asn content:

TEST3
DEFINITIONS AUTOMATIC TAGS ::= BEGIN

  Uint8  ::= INTEGER (0..255)                  -- (hex)

  RaAcaCertRequest ::= OCTET STRING(SIZE(32))
  AcaRaCertResponse ::= OCTET STRING(SIZE(48))

  AcaRaInterfacePdu ::= CHOICE {
    raAcaCertRequest   RaAcaCertRequest,
    acaRaCertResponse  AcaRaCertResponse,
    ...
  }

  ScmsPdu ::= SEQUENCE {
    version  Uint8 (1),
    content  CHOICE {
      aca-ra  AcaRaInterfacePdu,
      ...
    }
  }

  ScmsPdu-Scoped {Pdu} ::= ScmsPdu (WITH COMPONENTS {
    ...,
    content (CONSTRAINED BY {
      Pdu
    })
  })

  ScopedCertificateRequest ::= ScmsPdu (
    ScmsPdu-Scoped {
      AcaRaInterfacePdu (WITH COMPONENTS {
        raAcaCertRequest
      })
    }
  )

END

Thank you very much and look forward to your reply!

mouse07410 commented 2 years ago

In general, this free ASN.1 compiler doesn't do too well with complicated kludgy twisted modern perversions of ASN.1 language.

I'll try to take a look at your example, but can tell you immediately that it's probably beyond my level of competence.

DanyaFilatov commented 1 year ago

Perhaps too late, but anyway. Just modify the Ieee1609Dot2Dot1Protocol.asn as

--***************************************************************************--
--                            Certificate Requests                           --
--***************************************************************************--

  ScmsPdu-RaAcaCertRequest ::= ScmsPdu-Scoped {
    AcaRaInterfacePdu (WITH COMPONENTS {
      raAcaCertRequest
    })
  }
  ScmsPdu-EeEcaCertRequest ::= ScmsPdu-Scoped {
    EcaEeInterfacePdu (WITH COMPONENTS {
      eeEcaCertRequest
    })
  } 
  ScmsPdu-EeRaCertRequest ::= ScmsPdu-Scoped {
    EeRaInterfacePdu (WITH COMPONENTS {
      eeRaCertRequest
    })
  }
  ScmsPdu-EeRaSuccessorEnrollmentCertRequest ::= ScmsPdu-Scoped {
    EeRaInterfacePdu (WITH COMPONENTS {
      eeRaSuccessorEnrollmentCertRequest
    })
  }

/**
 * @brief This structure defines the all certificate request structures as a
 * scoped version of the ScmsPdu.
 */
ScopedCertificateRequest ::= ScmsPdu (
  ScmsPdu-RaAcaCertRequest | ScmsPdu-EeEcaCertRequest | 
  ScmsPdu-EeRaCertRequest  | ScmsPdu-EeRaSuccessorEnrollmentCertRequest
)