vvoodrovv
vvoodrovv

Reputation: 478

asn1c keeps using long instead of INTEGER_t but I don't ask it for that

Let I have an asn:

A ::= SEQUENCE {
    a INTEGER (0 .. 255),       
    b INTEGER (0 .. 255),       
    c INTEGER (0 .. 65535),     
    d INTEGER (0 .. 65535),
    e [0] INTEGER (0 ..255) OPTIONAL, 
    f[1] INTEGER (0 .. 63) OPTIONAL 
}

I compile it WITHOUT fnative-types, but code looks like

typedef struct A{
long     a;
long     b;
long     c;
long     d;
long    *e/* OPTIONAL */;
long    *f/* OPTIONAL */;

/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} A_t; 

Why so? It causes long DER byte sequence

Upvotes: 3

Views: 420

Answers (2)

user3076105
user3076105

Reputation: 416

To force structure creation by asn1c, use it with the -fwide-types option.

Upvotes: 1

bazza
bazza

Reputation: 8414

Depending on the ASN.1 compiler you're using you may be able to specify the C variable types used for structure fields.

In the Objective Systems toolset you can have an XML configuration file which is input to the compiler along with your ASN.1 schema. That allows you to tell the ASN.1 compiler what sort of integer should be used for a, b, c, etc.

Upvotes: 0

Related Questions