Title: Message
Hi,
 
    First in short the possible ASN.1 descriptions (that comes to my mind) for your question -
 

A ::= SEQUENCE
{
    a1    BOOLEAN,
    a2    BOOLEAN,
    a3    BOOLEAN,
    a4    BOOLEAN
}
 
or if your are very particular about the usage of an integer to represent the same then -
 

A ::= SEQUENCE
{
    a1    INTEGER(0..1),
    a2    INTEGER(0..1),
    a3    INTEGER(0..1),
    a4    INTEGER(0..1)
}
 
    I would like to add this comment at this point. The bit-fields is a fancy feature of the C-language, useful to describe data structures with a bit-wise breakup. Many times the generated code when handling bit-fields is much slower. The flexibility is provided for cases where its absolutely mandatory to use the same. I hope such is the requirement you have.
 
    As for the following - "Will the encoding in ASN.1 use any optimization techniques for instance representing the struct in a single byte ?". There is a differentiation that we need to be clear about. First hand, the encoding and the structure are independent. Represention of the structure in 1 byte does not ensure encoding in a single byte nor vice versa. The data-structure requirements are purely based on the application implementing the protocol and where it is deployed. The data-structure representation is left at the mercy of the complier used to generate the code (structures, encoder and decoder), and the flexibility provided by the same.
 
    I believe that you must be aware of this but just in case, PER encoding (as its name suggests) generates the most packed encoding possible. The data structure and the length of the encoding does not have any relation at all. Hope this clears you questions.

Regards
Ramaswamy R
To deny our instincts, is to deny the very thing that makes us human - Mouse (The Matrix)

Disclaimer:

This message and any attachment(s) contained here are information that is confidential, proprietary to HCL Technologies and its customers. Contents may be privileged or otherwise protected by law. The information is solely intended for the individual or the entity it is addressed to. If you are not the intended recipient of this message, you are not authorized to read, forward, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, May 28, 2004 7:18 PM
To: [EMAIL PROTECTED]
Subject: [ASN.1] C bit fields representation in ASN.1

Hi,
 
How would I be able to represent the following in ASN.1 ?
C structure:
 
struct A
{
    unsigned a1:1;
    unsigned a2:1;
    unsigned a3:1;
    unsigned a4:1;
}
 
Will the encoding in ASN.1 use any optimization techniques for instance representing the struct
in a single byte ?
 
Thanks,
Aparna

Reply via email to