After spending few hours of time, I figured that it can't be done by modifying the asn file. It can only be done by editing the .h and .c files generated by compiling asn file.
Question
I have a small asn1 code:
---------------------ASN1 FILE------------------------------
RectangleModule1 DEFINITIONS ::=
BEGIN
Rectangle ::= SEQUENCE (SIZE(1..10)) OF SEQUENCE {
item CHOICE {
height INTEGER,
width IA5String
} --# UNTAGGED
}
END
When I compile it with asn1c, it gives me the Rectangle.c and Rectangle.h files. The output of Rectangle looks like this:
-----------------------Rectangle.h------------------------------
/* Dependencies */
typedef enum item_PR {
item_PR_NOTHING, /* No components present */
item_PR_height,
item_PR_width
} item_PR;
/* Rectangle */
typedef struct Rectangle {
A_SEQUENCE_OF(struct Member {
struct item {
item_PR present;
union item_u {
long height;
IA5String_t width;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} item;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} ) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Rectangle_t;
but I wanted my output to look like this:
/* Dependencies */
typedef enum item_PR_sl {
item_PR_NOTHING_sl, /* No components present */
item_PR_height_sl,
item_PR_width_sl
} item_PR_sl;
/* Rectangle */
typedef struct Rectangle {
A_SEQUENCE_OF(struct Member {
struct item_sl {
item_PR_sl present;
union item_u_sl {
long height;
IA5String_t width;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} item;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} ) list;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Rectangle_t;
i.e., _sl to be concatenated to item fields. I was unable to do this by changing the asn file. I don't know how the constr_CHOICE
and constr_SEQUENCE
are working. Any help would be appreciated.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow