How to support two version of structure definition in one asn.1 file

StackOverflow https://stackoverflow.com/questions/17989783

  •  04-06-2022
  •  | 
  •  

문제

I've a problem while defining one structure in an asn.1 source file (test.asn1 for example).

It has the following definition for protocol version 1:

PolicyControlDiagnostics ::= ENUMERATED
{
    policy    (1),
    policyControl  (2),
    policyControlResumed    (3)
}

Then we have requirement to support version 2. In protocol version 2, some fields changed but the structure name keeps unchanged. For example, the variable policy changed to mytestpolicy, policyControl changed to mytestpolicyControl. Meanwhile the structure name PolicyControlDiagnostics was the same both in version 1 and version 2.

PolicyControlDiagnostics ::= ENUMERATED
{
    mytestpolicy  (1),
    mytestpolicyControl  (2),
    policyControlResumed    (3)
}

When I try to produce C routines for BER encoding, decoding use snac, it complains:

file "test.asn1", line 632: ERROR - type PolicyControlDiagnostics is multiply defined.

Could you help me to resolve this error? Thanks.

도움이 되었습니까?

해결책

If you are trying to have the same enumerated name in the same ASN.1 module, this is not permitted. If you have two separate ASN.1 modules which are different versions of the same specification, each of which has some types with the same names, some ASN.1 compilers will automatically disambiguate the conflicting names for you.

Having the same type name twice in the same ASN.1 module is not permitted, but having two versions of a module (with some differences between them) is permitted. Backward compatibility between those two modules needs the guidance of an ASN.1 expert in order to avoid interoperability problems.

An excellent place to try your ASN.1 specifications to see what it valid is the free online compiler and runtime at http://asn1-playground.oss.com.

다른 팁

The error says it all. You cannot have two definitions for a type. The names used in the ENUMERATED can be changed without consequence for BER encodings (XER encodings might be impacted; I'd have to look that up). Thus, the two definitions are equivalent and you can just pick one.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top