Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
2e3055da
Commit
2e3055da
authored
Aug 20, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new meaning of life
parent
5253da42
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
766 additions
and
606 deletions
+766
-606
tests/19-param-OK.asn1
tests/19-param-OK.asn1
+2
-1
tests/39-sequence-of-OK.asn1.-P
tests/39-sequence-of-OK.asn1.-P
+64
-54
tests/42-real-life-OK.asn1
tests/42-real-life-OK.asn1
+3
-3
tests/42-real-life-OK.asn1.-EF
tests/42-real-life-OK.asn1.-EF
+3
-3
tests/42-real-life-OK.asn1.-PR
tests/42-real-life-OK.asn1.-PR
+384
-266
tests/44-choice-in-sequence-OK.asn1.-P
tests/44-choice-in-sequence-OK.asn1.-P
+187
-177
tests/46-redefine-OK.asn1.-PR
tests/46-redefine-OK.asn1.-PR
+83
-70
tests/47-set-ext-OK.asn1.-P
tests/47-set-ext-OK.asn1.-P
+36
-32
tests/50-constraint-OK.asn1
tests/50-constraint-OK.asn1
+4
-0
tests/50-constraint-OK.asn1.-EFprint-constraints
tests/50-constraint-OK.asn1.-EFprint-constraints
+0
-0
No files found.
tests/19-param-OK.asn1
View file @
2e3055da
...
...
@@ -25,6 +25,7 @@ BEGIN
Name ::= SEQUENCE OF RelativeDistinguishedName
RelativeDistinguishedName ::= SET SIZE (1..MAX) OF IA5String
RelativeDistinguishedName ::= SET SIZE (1..MAX) OF
IA5String (FROM("A".."Z"|"a".."z"|"0-9"|",-."))
END
tests/39-sequence-of-OK.asn1.-P
View file @
2e3055da
...
...
@@ -29,19 +29,23 @@ typedef struct T {
/*** <<< STAT-DEFS [T] >>> ***/
static asn1_SET_OF_element_t asn1_DEF_collection_elements[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
(void *)&asn1_DEF_T2 },
};
static ber_tlv_tag_t asn1_DEF_collection_tags[] = {
static asn1_TYPE_member_t asn1_MBR_collection[] = {
{ 0, 0,
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_T2,
.memb_constraints = 0, /* Defer to actual type */
.name = ""
},
};
static ber_tlv_tag_t asn1_DEF_collection_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = {
};
static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = {
sizeof(struct collection),
offsetof(struct collection, _ber_dec_ctx),
asn1_DEF_collection_elements
};
asn1_TYPE_descriptor_t asn1_DEF_collection = {
};
asn1_TYPE_descriptor_t asn1_DEF_collection = {
"collection",
SEQUENCE_OF_constraint,
SEQUENCE_OF_decode_ber,
...
...
@@ -54,21 +58,25 @@ typedef struct T {
/sizeof(asn1_DEF_collection_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_collection,
1, /* Single element */
&asn1_DEF_collection_specs /* Additional specs */
};
static asn1_SEQUENCE_element_t asn1_DEF_T_elements[] = {
{ offsetof(struct T, int), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"int"
};
static asn1_TYPE_member_t asn1_MBR_T[] = {
{ 0, offsetof(struct T, int),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_INTEGER,
.memb_constraints = 0, /* Defer to actual type */
.name = "int"
},
{ offsetof(struct T, collection), 0,
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
0,
(void *)&asn1_DEF_collection,
"collection"
{ 0, offsetof(struct T, collection),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_collection,
.memb_constraints = 0, /* Defer to actual type */
.name = "collection"
},
};
static ber_tlv_tag_t asn1_DEF_T_tags[] = {
...
...
@@ -81,8 +89,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T_tag2el[] = {
static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
sizeof(struct T),
offsetof(struct T, _ber_dec_ctx),
asn1_DEF_T_elements,
2, /* Elements count */
asn1_DEF_T_tag2el,
2, /* Count of tags in the map */
-1, /* Start extensions */
...
...
@@ -101,6 +107,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T = {
/sizeof(asn1_DEF_T_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_T,
2, /* Elements count */
&asn1_DEF_T_specs /* Additional specs */
};
...
...
@@ -128,18 +136,20 @@ typedef struct T2 {
/*** <<< STAT-DEFS [T2] >>> ***/
static asn1_SEQUENCE_element_t asn1_DEF_T2_elements[] = {
{ offsetof(struct T2, flag), 0,
(ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
0,
(void *)&asn1_DEF_BOOLEAN,
"flag"
static asn1_TYPE_member_t asn1_MBR_T2[] = {
{ 0, offsetof(struct T2, flag),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_BOOLEAN,
.memb_constraints = 0, /* Defer to actual type */
.name = "flag"
},
{ offsetof(struct T2, str), 0,
(ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
0,
(void *)&asn1_DEF_UTF8String,
"str"
{ 0, offsetof(struct T2, str),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_UTF8String,
.memb_constraints = 0, /* Defer to actual type */
.name = "str"
},
};
static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
...
...
@@ -152,8 +162,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T2_tag2el[] = {
static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = {
sizeof(struct T2),
offsetof(struct T2, _ber_dec_ctx),
asn1_DEF_T2_elements,
2, /* Elements count */
asn1_DEF_T2_tag2el,
2, /* Count of tags in the map */
-1, /* Start extensions */
...
...
@@ -172,6 +180,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = {
/sizeof(asn1_DEF_T2_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_T2,
2, /* Elements count */
&asn1_DEF_T2_specs /* Additional specs */
};
tests/42-real-life-OK.asn1
View file @
2e3055da
...
...
@@ -21,7 +21,7 @@ BEGIN
*/
LogLine ::= SEQUENCE {
line-digest IA5String, -- Log line normal form
varsets SEQUENCE (1..MAX) OF VariablePartSet
varsets SEQUENCE
SIZE
(1..MAX) OF VariablePartSet
}
/*
...
...
@@ -30,7 +30,7 @@ BEGIN
* or a range between two samples.
*/
VariablePartSet ::= SEQUENCE {
vparts SEQUENCE (0..MAX) OF VariablePart, -- {123,321}
vparts SEQUENCE
SIZE
(0..MAX) OF VariablePart, -- {123,321}
resolution ActionItem
}
...
...
@@ -39,7 +39,7 @@ BEGIN
*/
VariablePart ::= CHOICE {
-- A set of acceptable values
vset SET (1..MAX) OF VisibleString,
vset SET
SIZE
(1..MAX) OF VisibleString,
-- A range of acceptable values
vrange SEQUENCE {
from VisibleString,
...
...
tests/42-real-life-OK.asn1.-EF
View file @
2e3055da
...
...
@@ -7,18 +7,18 @@ BEGIN
LogLine ::= SEQUENCE {
line-digest IA5String,
varsets SEQUENCE OF VariablePartSet,
varsets SEQUENCE
SIZE(1..MAX)
OF VariablePartSet,
...
}
VariablePartSet ::= SEQUENCE {
vparts SEQUENCE OF VariablePart,
vparts SEQUENCE
SIZE(0..MAX)
OF VariablePart,
resolution ActionItem,
...
}
VariablePart ::= CHOICE {
vset SET OF VisibleString,
vset SET
SIZE(1..MAX)
OF VisibleString,
vrange SEQUENCE {
from VisibleString,
to VisibleString,
...
...
tests/42-real-life-OK.asn1.-PR
View file @
2e3055da
This diff is collapsed.
Click to expand it.
tests/44-choice-in-sequence-OK.asn1.-P
View file @
2e3055da
...
...
@@ -7,23 +7,23 @@
/*** <<< DEPS [T] >>> ***/
typedef enum b_PR {
typedef enum b_PR {
b_PR_NOTHING, /* No components present */
b_PR_c,
b_PR_d,
b_PR_e,
b_PR_h,
} b_PR;
typedef enum e_PR {
} b_PR;
typedef enum e_PR {
e_PR_NOTHING, /* No components present */
e_PR_f,
e_PR_g,
} e_PR;
typedef enum h_PR {
} e_PR;
typedef enum h_PR {
h_PR_NOTHING, /* No components present */
h_PR_i,
h_PR_j,
} h_PR;
} h_PR;
extern asn1_TYPE_descriptor_t asn1_DEF_T;
/*** <<< TYPE-DECLS [T] >>> ***/
...
...
@@ -68,36 +68,36 @@ typedef struct T {
/*** <<< STAT-DEFS [T] >>> ***/
static asn1_CHOICE_element_t asn1_DEF_e_elements[] = {
{ offsetof(struct e, choice.f), 0,
(ASN_TAG_CLASS_PRIVATE | (7 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_NULL,
"f"
static asn1_TYPE_member_t asn1_MBR_e[] = {
{ 0, offsetof(struct e, choice.f),
.tag = (ASN_TAG_CLASS_PRIVATE | (7 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_NULL,
.memb_constraints = 0, /* Defer to actual type */
.name = "f"
},
{ offsetof(struct e, choice.g), 0,
(ASN_TAG_CLASS_PRIVATE | (8 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_NULL,
"g"
{ 0, offsetof(struct e, choice.g),
.tag = (ASN_TAG_CLASS_PRIVATE | (8 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_NULL,
.memb_constraints = 0, /* Defer to actual type */
.name = "g"
},
};
static asn1_TYPE_tag2member_t asn1_DEF_e_tag2el[] = {
};
static asn1_TYPE_tag2member_t asn1_DEF_e_tag2el[] = {
{ (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 0, 0, 0 }, /* f at 20 */
{ (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 1, 0, 0 }, /* g at 21 */
};
static asn1_CHOICE_specifics_t asn1_DEF_e_specs = {
};
static asn1_CHOICE_specifics_t asn1_DEF_e_specs = {
sizeof(struct e),
offsetof(struct e, _ber_dec_ctx),
offsetof(struct e, present),
sizeof(((struct e *)0)->present),
asn1_DEF_e_elements,
2, /* Elements count */
asn1_DEF_e_tag2el,
2, /* Count of tags in the map */
0 /* Whether extensible */
};
asn1_TYPE_descriptor_t asn1_DEF_e = {
};
asn1_TYPE_descriptor_t asn1_DEF_e = {
"e",
CHOICE_constraint,
CHOICE_decode_ber,
...
...
@@ -109,39 +109,41 @@ typedef struct T {
0, /* No explicit tags (count) */
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_e,
2, /* Elements count */
&asn1_DEF_e_specs /* Additional specs */
};
};
static asn1_CHOICE_element_t asn1_DEF_h_elements[] = {
{ offsetof(struct h, choice.i), 0,
(ASN_TAG_CLASS_PRIVATE | (1 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_NULL,
"i"
static asn1_TYPE_member_t asn1_MBR_h[] = {
{ 0, offsetof(struct h, choice.i),
.tag = (ASN_TAG_CLASS_PRIVATE | (1 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_NULL,
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
{ offsetof(struct h, choice.j), 0,
(ASN_TAG_CLASS_PRIVATE | (2 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_NULL,
"j"
{ 0, offsetof(struct h, choice.j),
.tag = (ASN_TAG_CLASS_PRIVATE | (2 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_NULL,
.memb_constraints = 0, /* Defer to actual type */
.name = "j"
},
};
static asn1_TYPE_tag2member_t asn1_DEF_h_tag2el[] = {
};
static asn1_TYPE_tag2member_t asn1_DEF_h_tag2el[] = {
{ (ASN_TAG_CLASS_PRIVATE | (1 << 2)), 0, 0, 0 }, /* i at 24 */
{ (ASN_TAG_CLASS_PRIVATE | (2 << 2)), 1, 0, 0 }, /* j at 25 */
};
static asn1_CHOICE_specifics_t asn1_DEF_h_specs = {
};
static asn1_CHOICE_specifics_t asn1_DEF_h_specs = {
sizeof(struct h),
offsetof(struct h, _ber_dec_ctx),
offsetof(struct h, present),
sizeof(((struct h *)0)->present),
asn1_DEF_h_elements,
2, /* Elements count */
asn1_DEF_h_tag2el,
2, /* Count of tags in the map */
0 /* Whether extensible */
};
asn1_TYPE_descriptor_t asn1_DEF_h = {
};
asn1_TYPE_descriptor_t asn1_DEF_h = {
"h",
CHOICE_constraint,
CHOICE_decode_ber,
...
...
@@ -153,54 +155,58 @@ typedef struct T {
0, /* No explicit tags (count) */
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_h,
2, /* Elements count */
&asn1_DEF_h_specs /* Additional specs */
};
};
static asn1_CHOICE_element_t asn1_DEF_b_elements[] = {
{ offsetof(struct b, choice.c), 0,
(ASN_TAG_CLASS_PRIVATE | (5 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_NULL,
"c"
static asn1_TYPE_member_t asn1_MBR_b[] = {
{ 0, offsetof(struct b, choice.c),
.tag = (ASN_TAG_CLASS_PRIVATE | (5 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_NULL,
.memb_constraints = 0, /* Defer to actual type */
.name = "c"
},
{ offsetof(struct b, choice.d), 0,
(ASN_TAG_CLASS_PRIVATE | (6 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_NULL,
"d"
{ 0, offsetof(struct b, choice.d),
.tag = (ASN_TAG_CLASS_PRIVATE | (6 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_NULL,
.memb_constraints = 0, /* Defer to actual type */
.name = "d"
},
{ offsetof(struct b, choice.e), 0,
-1 /* Ambiguous tag (CHOICE?) */,
0,
(void *)&asn1_DEF_e,
"e"
{ 0, offsetof(struct b, choice.e),
.tag = -1 /* Ambiguous tag (CHOICE?) */,
.tag_mode = 0,
.type = (void *)&asn1_DEF_e,
.memb_constraints = 0, /* Defer to actual type */
.name = "e"
},
{ offsetof(struct b, choice.h), 0,
(ASN_TAG_CLASS_PRIVATE | (9 << 2)),
+1, /* EXPLICIT tag at current level */
(void *)&asn1_DEF_h,
"h"
{ 0, offsetof(struct b, choice.h),
.tag = (ASN_TAG_CLASS_PRIVATE | (9 << 2)),
.tag_mode = +1, /* EXPLICIT tag at current level */
.type = (void *)&asn1_DEF_h,
.memb_constraints = 0, /* Defer to actual type */
.name = "h"
},
};
static asn1_TYPE_tag2member_t asn1_DEF_b_tag2el[] = {
};
static asn1_TYPE_tag2member_t asn1_DEF_b_tag2el[] = {
{ (ASN_TAG_CLASS_PRIVATE | (5 << 2)), 0, 0, 0 }, /* c at 17 */
{ (ASN_TAG_CLASS_PRIVATE | (6 << 2)), 1, 0, 0 }, /* d at 18 */
{ (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 2, 0, 0 }, /* f at 20 */
{ (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 2, 0, 0 }, /* g at 21 */
{ (ASN_TAG_CLASS_PRIVATE | (9 << 2)), 3, 0, 0 }, /* h at 24 */
};
static asn1_CHOICE_specifics_t asn1_DEF_b_specs = {
};
static asn1_CHOICE_specifics_t asn1_DEF_b_specs = {
sizeof(struct b),
offsetof(struct b, _ber_dec_ctx),
offsetof(struct b, present),
sizeof(((struct b *)0)->present),
asn1_DEF_b_elements,
4, /* Elements count */
asn1_DEF_b_tag2el,
5, /* Count of tags in the map */
0 /* Whether extensible */
};
asn1_TYPE_descriptor_t asn1_DEF_b = {
};
asn1_TYPE_descriptor_t asn1_DEF_b = {
"b",
CHOICE_constraint,
CHOICE_decode_ber,
...
...
@@ -212,21 +218,25 @@ typedef struct T {
0, /* No explicit tags (count) */
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_b,
4, /* Elements count */
&asn1_DEF_b_specs /* Additional specs */
};
};
static asn1_SEQUENCE_element_t asn1_DEF_T_elements[] = {
{ offsetof(struct T, a), 0,
(ASN_TAG_CLASS_PRIVATE | (2 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_NULL,
"a"
static asn1_TYPE_member_t asn1_MBR_T[] = {
{ 0, offsetof(struct T, a),
.tag = (ASN_TAG_CLASS_PRIVATE | (2 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_NULL,
.memb_constraints = 0, /* Defer to actual type */
.name = "a"
},
{ offsetof(struct T, b), 0,
-1 /* Ambiguous tag (CHOICE?) */,
0,
(void *)&asn1_DEF_b,
"b"
{ 0, offsetof(struct T, b),
.tag = -1 /* Ambiguous tag (CHOICE?) */,
.tag_mode = 0,
.type = (void *)&asn1_DEF_b,
.memb_constraints = 0, /* Defer to actual type */
.name = "b"
},
};
static ber_tlv_tag_t asn1_DEF_T_tags[] = {
...
...
@@ -243,8 +253,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T_tag2el[] = {
static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
sizeof(struct T),
offsetof(struct T, _ber_dec_ctx),
asn1_DEF_T_elements,
2, /* Elements count */
asn1_DEF_T_tag2el,
6, /* Count of tags in the map */
-1, /* Start extensions */
...
...
@@ -263,6 +271,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T = {
/sizeof(asn1_DEF_T_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_T,
2, /* Elements count */
&asn1_DEF_T_specs /* Additional specs */
};
tests/46-redefine-OK.asn1.-PR
View file @
2e3055da
...
...
@@ -18,26 +18,7 @@ der_type_encoder_f PrimitiveType_encode_der;
asn_struct_print_f PrimitiveType_print;
asn_struct_free_f PrimitiveType_free;
/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
};
asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = {
"PrimitiveType",
PrimitiveType_constraint,
PrimitiveType_decode_ber,
PrimitiveType_encode_der,
PrimitiveType_print,
PrimitiveType_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_PrimitiveType_tags,
sizeof(asn1_DEF_PrimitiveType_tags)
/sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */
1, /* Tags to skip */
-0, /* Unknown yet */
0 /* No specifics */
};
/*** <<< CODE [PrimitiveType] >>> ***/
int
PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
...
@@ -54,19 +35,21 @@ PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
* so adjust the DEF appropriately.
*/
static void
inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
PrimitiveType_
inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder;
td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
td->free_struct = asn1_DEF_OCTET_STRING.free_struct;
td->print_struct = asn1_DEF_OCTET_STRING.print_struct;
td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form;
td->elements = asn1_DEF_OCTET_STRING.elements;
td->elements_count = asn1_DEF_OCTET_STRING.elements_count;
td->specifics = asn1_DEF_OCTET_STRING.specifics;
}
ber_dec_rval_t
PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
void **structure, void *bufptr, size_t size, int tag_mode) {
inherit_TYPE_descriptor(td);
PrimitiveType_
inherit_TYPE_descriptor(td);
return td->ber_decoder(td, structure,
bufptr, size, tag_mode);
}
...
...
@@ -75,25 +58,48 @@ der_enc_rval_t
PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
inherit_TYPE_descriptor(td);
PrimitiveType_
inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
int
PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
inherit_TYPE_descriptor(td);
PrimitiveType_
inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
void
PrimitiveType_free(asn1_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
inherit_TYPE_descriptor(td);
PrimitiveType_
inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
};
asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = {
"PrimitiveType",
PrimitiveType_constraint,
PrimitiveType_decode_ber,
PrimitiveType_encode_der,
PrimitiveType_print,
PrimitiveType_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_PrimitiveType_tags,
sizeof(asn1_DEF_PrimitiveType_tags)
/sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */
1, /* Tags to skip */
-0, /* Unknown yet */
0, 0, /* No members */
0 /* No specifics */
};
/*** <<< INCLUDES [ConstructedType] >>> ***/
#include <PrimitiveType.h>
...
...
@@ -115,12 +121,13 @@ typedef struct ConstructedType {
/*** <<< STAT-DEFS [ConstructedType] >>> ***/
static asn1_SEQUENCE_element_t asn1_DEF_ConstructedType_elements[] = {
{ offsetof(struct ConstructedType, field), 0,
(ASN_TAG_CLASS_CONTEXT | (5 << 2)),
-1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_PrimitiveType,
"field"
static asn1_TYPE_member_t asn1_MBR_ConstructedType[] = {
{ 0, offsetof(struct ConstructedType, field),
.tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = (void *)&asn1_DEF_PrimitiveType,
.memb_constraints = 0, /* Defer to actual type */
.name = "field"
},
};
static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = {
...
...
@@ -132,8 +139,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = {
static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
sizeof(struct ConstructedType),
offsetof(struct ConstructedType, _ber_dec_ctx),
asn1_DEF_ConstructedType_elements,
1, /* Elements count */
asn1_DEF_ConstructedType_tag2el,
1, /* Count of tags in the map */
-1, /* Start extensions */
...
...
@@ -152,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = {
/sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_ConstructedType,
1, /* Elements count */
&asn1_DEF_ConstructedType_specs /* Additional specs */
};
...
...
@@ -175,26 +182,7 @@ der_type_encoder_f T_encode_der;
asn_struct_print_f T_print;
asn_struct_free_f T_free;
/*** <<< STAT-DEFS [T] >>> ***/
static ber_tlv_tag_t asn1_DEF_T_tags[] = {
(ASN_TAG_CLASS_CONTEXT | (3 << 2))
};
asn1_TYPE_descriptor_t asn1_DEF_T = {
"T",
T_constraint,
T_decode_ber,
T_encode_der,
T_print,
T_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_T_tags,
sizeof(asn1_DEF_T_tags)
/sizeof(asn1_DEF_T_tags[0]), /* 1 */
1, /* Tags to skip */
-0, /* Unknown yet */
0 /* No specifics */
};
/*** <<< CODE [T] >>> ***/
int
T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
...
@@ -211,19 +199,21 @@ T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
* so adjust the DEF appropriately.
*/
static void
inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
T_
inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
td->free_struct = asn1_DEF_ConstructedType.free_struct;
td->print_struct = asn1_DEF_ConstructedType.print_struct;
td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
td->elements = asn1_DEF_ConstructedType.elements;
td->elements_count = asn1_DEF_ConstructedType.elements_count;
td->specifics = asn1_DEF_ConstructedType.specifics;
}
ber_dec_rval_t
T_decode_ber(asn1_TYPE_descriptor_t *td,
void **structure, void *bufptr, size_t size, int tag_mode) {
inherit_TYPE_descriptor(td);
T_
inherit_TYPE_descriptor(td);
return td->ber_decoder(td, structure,
bufptr, size, tag_mode);
}
...
...
@@ -232,21 +222,44 @@ der_enc_rval_t
T_encode_der(asn1_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
inherit_TYPE_descriptor(td);
T_
inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
int
T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
inherit_TYPE_descriptor(td);
T_
inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
void
T_free(asn1_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
inherit_TYPE_descriptor(td);
T_
inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
/*** <<< STAT-DEFS [T] >>> ***/
static ber_tlv_tag_t asn1_DEF_T_tags[] = {
(ASN_TAG_CLASS_CONTEXT | (3 << 2))
};
asn1_TYPE_descriptor_t asn1_DEF_T = {
"T",
T_constraint,
T_decode_ber,
T_encode_der,
T_print,
T_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_T_tags,
sizeof(asn1_DEF_T_tags)
/sizeof(asn1_DEF_T_tags[0]), /* 1 */
1, /* Tags to skip */
-0, /* Unknown yet */
0, 0, /* Defined elsewhere */
0 /* No specifics */
};
tests/47-set-ext-OK.asn1.-P
View file @
2e3055da
...
...
@@ -35,12 +35,13 @@ typedef struct T1 {
/*** <<< STAT-DEFS [T1] >>> ***/
static asn1_SET_element_t asn1_DEF_T1_elements[] = {
{ offsetof(struct T1, i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
static asn1_TYPE_member_t asn1_MBR_T1[] = {
{ 0, offsetof(struct T1, i),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_INTEGER,
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
};
static ber_tlv_tag_t asn1_DEF_T1_tags[] = {
...
...
@@ -56,8 +57,6 @@ static asn1_SET_specifics_t asn1_DEF_T1_specs = {
sizeof(struct T1),
offsetof(struct T1, _ber_dec_ctx),
offsetof(struct T1, _presence_map),
asn1_DEF_T1_elements,
1, /* Elements count */
asn1_DEF_T1_tag2el,
1, /* Count of tags in the map */
1, /* Whether extensible */
...
...
@@ -76,6 +75,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T1 = {
/sizeof(asn1_DEF_T1_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_T1,
1, /* Elements count */
&asn1_DEF_T1_specs /* Additional specs */
};
...
...
@@ -116,12 +117,13 @@ typedef struct T2 {
/*** <<< STAT-DEFS [T2] >>> ***/
static asn1_SET_element_t asn1_DEF_T2_elements[] = {
{ offsetof(struct T2, i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
static asn1_TYPE_member_t asn1_MBR_T2[] = {
{ 0, offsetof(struct T2, i),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_INTEGER,
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
};
static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
...
...
@@ -137,8 +139,6 @@ static asn1_SET_specifics_t asn1_DEF_T2_specs = {
sizeof(struct T2),
offsetof(struct T2, _ber_dec_ctx),
offsetof(struct T2, _presence_map),
asn1_DEF_T2_elements,
1, /* Elements count */
asn1_DEF_T2_tag2el,
1, /* Count of tags in the map */
1, /* Whether extensible */
...
...
@@ -157,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = {
/sizeof(asn1_DEF_T2_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_T2,
1, /* Elements count */
&asn1_DEF_T2_specs /* Additional specs */
};
...
...
@@ -194,12 +196,13 @@ typedef struct T3 {
/*** <<< STAT-DEFS [T3] >>> ***/
static asn1_CHOICE_element_t asn1_DEF_T3_elements[] = {
{ offsetof(struct T3, choice.i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
static asn1_TYPE_member_t asn1_MBR_T3[] = {
{ 0, offsetof(struct T3, choice.i),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_INTEGER,
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
};
static asn1_TYPE_tag2member_t asn1_DEF_T3_tag2el[] = {
...
...
@@ -210,8 +213,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T3_specs = {
offsetof(struct T3, _ber_dec_ctx),
offsetof(struct T3, present),
sizeof(((struct T3 *)0)->present),
asn1_DEF_T3_elements,
1, /* Elements count */
asn1_DEF_T3_tag2el,
1, /* Count of tags in the map */
1 /* Whether extensible */
...
...
@@ -228,6 +229,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T3 = {
0, /* No explicit tags (count) */
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_T3,
1, /* Elements count */
&asn1_DEF_T3_specs /* Additional specs */
};
...
...
@@ -265,12 +268,13 @@ typedef struct T4 {
/*** <<< STAT-DEFS [T4] >>> ***/
static asn1_CHOICE_element_t asn1_DEF_T4_elements[] = {
{ offsetof(struct T4, choice.i), 0,
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
(void *)&asn1_DEF_INTEGER,
"i"
static asn1_TYPE_member_t asn1_MBR_T4[] = {
{ 0, offsetof(struct T4, choice.i),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = (void *)&asn1_DEF_INTEGER,
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
};
static asn1_TYPE_tag2member_t asn1_DEF_T4_tag2el[] = {
...
...
@@ -281,8 +285,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T4_specs = {
offsetof(struct T4, _ber_dec_ctx),
offsetof(struct T4, present),
sizeof(((struct T4 *)0)->present),
asn1_DEF_T4_elements,
1, /* Elements count */
asn1_DEF_T4_tag2el,
1, /* Count of tags in the map */
1 /* Whether extensible */
...
...
@@ -299,6 +301,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T4 = {
0, /* No explicit tags (count) */
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
asn1_MBR_T4,
1, /* Elements count */
&asn1_DEF_T4_specs /* Additional specs */
};
tests/50-constraint-OK.asn1
View file @
2e3055da
...
...
@@ -39,4 +39,8 @@ BEGIN
SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD"))
Neither-SIZE-nor-FROM ::= PER-Visible (SIZE(1..4) | FROM("ABCD",...))
Utf8-3 ::= Utf8-2 (FROM("A".."Z"|"a".."z"))
Utf8-2 ::= Utf8-1 (SIZE(1..2))
Utf8-1 ::= UTF8String
END
tests/50-constraint-OK.asn1.-EFprint-constraints
View file @
2e3055da
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment