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
Hide 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
...
@@ -25,6 +25,7 @@ BEGIN
Name ::= SEQUENCE OF RelativeDistinguishedName
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
END
tests/39-sequence-of-OK.asn1.-P
View file @
2e3055da
...
@@ -29,46 +29,54 @@ typedef struct T {
...
@@ -29,46 +29,54 @@ typedef struct T {
/*** <<< STAT-DEFS [T] >>> ***/
/*** <<< STAT-DEFS [T] >>> ***/
static asn1_SET_OF_element_t asn1_DEF_collection_elements[] = {
static asn1_TYPE_member_t asn1_MBR_collection[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
{ 0, 0,
(void *)&asn1_DEF_T2 },
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
};
.tag_mode = 0,
static ber_tlv_tag_t asn1_DEF_collection_tags[] = {
.type = (void *)&asn1_DEF_T2,
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
.memb_constraints = 0, /* Defer to actual type */
};
.name = ""
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 = {
"collection",
SEQUENCE_OF_constraint,
SEQUENCE_OF_decode_ber,
SEQUENCE_OF_encode_der,
SEQUENCE_OF_print,
SEQUENCE_OF_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_collection_tags,
sizeof(asn1_DEF_collection_tags)
/sizeof(asn1_DEF_collection_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
&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"
},
},
{ offsetof(struct T, collection), 0,
};
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
static ber_tlv_tag_t asn1_DEF_collection_tags[] = {
0,
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
(void *)&asn1_DEF_collection,
};
"collection"
static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = {
sizeof(struct collection),
offsetof(struct collection, _ber_dec_ctx),
};
asn1_TYPE_descriptor_t asn1_DEF_collection = {
"collection",
SEQUENCE_OF_constraint,
SEQUENCE_OF_decode_ber,
SEQUENCE_OF_encode_der,
SEQUENCE_OF_print,
SEQUENCE_OF_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_collection_tags,
sizeof(asn1_DEF_collection_tags)
/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_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"
},
{ 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[] = {
static ber_tlv_tag_t asn1_DEF_T_tags[] = {
...
@@ -81,8 +89,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T_tag2el[] = {
...
@@ -81,8 +89,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T_tag2el[] = {
static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = {
sizeof(struct T),
sizeof(struct T),
offsetof(struct T, _ber_dec_ctx),
offsetof(struct T, _ber_dec_ctx),
asn1_DEF_T_elements,
2, /* Elements count */
asn1_DEF_T_tag2el,
asn1_DEF_T_tag2el,
2, /* Count of tags in the map */
2, /* Count of tags in the map */
-1, /* Start extensions */
-1, /* Start extensions */
...
@@ -101,6 +107,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T = {
...
@@ -101,6 +107,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T = {
/sizeof(asn1_DEF_T_tags[0]), /* 1 */
/sizeof(asn1_DEF_T_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
1, /* Whether CONSTRUCTED */
asn1_MBR_T,
2, /* Elements count */
&asn1_DEF_T_specs /* Additional specs */
&asn1_DEF_T_specs /* Additional specs */
};
};
...
@@ -128,18 +136,20 @@ typedef struct T2 {
...
@@ -128,18 +136,20 @@ typedef struct T2 {
/*** <<< STAT-DEFS [T2] >>> ***/
/*** <<< STAT-DEFS [T2] >>> ***/
static asn1_SEQUENCE_element_t asn1_DEF_T2_elements[] = {
static asn1_TYPE_member_t asn1_MBR_T2[] = {
{ offsetof(struct T2, flag), 0,
{ 0, offsetof(struct T2, flag),
(ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
0,
.tag_mode = 0,
(void *)&asn1_DEF_BOOLEAN,
.type = (void *)&asn1_DEF_BOOLEAN,
"flag"
.memb_constraints = 0, /* Defer to actual type */
.name = "flag"
},
},
{ offsetof(struct T2, str), 0,
{ 0, offsetof(struct T2, str),
(ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
0,
.tag_mode = 0,
(void *)&asn1_DEF_UTF8String,
.type = (void *)&asn1_DEF_UTF8String,
"str"
.memb_constraints = 0, /* Defer to actual type */
.name = "str"
},
},
};
};
static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
...
@@ -152,8 +162,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T2_tag2el[] = {
...
@@ -152,8 +162,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T2_tag2el[] = {
static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = {
static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = {
sizeof(struct T2),
sizeof(struct T2),
offsetof(struct T2, _ber_dec_ctx),
offsetof(struct T2, _ber_dec_ctx),
asn1_DEF_T2_elements,
2, /* Elements count */
asn1_DEF_T2_tag2el,
asn1_DEF_T2_tag2el,
2, /* Count of tags in the map */
2, /* Count of tags in the map */
-1, /* Start extensions */
-1, /* Start extensions */
...
@@ -172,6 +180,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = {
...
@@ -172,6 +180,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = {
/sizeof(asn1_DEF_T2_tags[0]), /* 1 */
/sizeof(asn1_DEF_T2_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
1, /* Whether CONSTRUCTED */
asn1_MBR_T2,
2, /* Elements count */
&asn1_DEF_T2_specs /* Additional specs */
&asn1_DEF_T2_specs /* Additional specs */
};
};
tests/42-real-life-OK.asn1
View file @
2e3055da
...
@@ -21,7 +21,7 @@ BEGIN
...
@@ -21,7 +21,7 @@ BEGIN
*/
*/
LogLine ::= SEQUENCE {
LogLine ::= SEQUENCE {
line-digest IA5String, -- Log line normal form
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
...
@@ -30,7 +30,7 @@ BEGIN
* or a range between two samples.
* or a range between two samples.
*/
*/
VariablePartSet ::= SEQUENCE {
VariablePartSet ::= SEQUENCE {
vparts SEQUENCE (0..MAX) OF VariablePart, -- {123,321}
vparts SEQUENCE
SIZE
(0..MAX) OF VariablePart, -- {123,321}
resolution ActionItem
resolution ActionItem
}
}
...
@@ -39,7 +39,7 @@ BEGIN
...
@@ -39,7 +39,7 @@ BEGIN
*/
*/
VariablePart ::= CHOICE {
VariablePart ::= CHOICE {
-- A set of acceptable values
-- A set of acceptable values
vset SET (1..MAX) OF VisibleString,
vset SET
SIZE
(1..MAX) OF VisibleString,
-- A range of acceptable values
-- A range of acceptable values
vrange SEQUENCE {
vrange SEQUENCE {
from VisibleString,
from VisibleString,
...
...
tests/42-real-life-OK.asn1.-EF
View file @
2e3055da
...
@@ -7,18 +7,18 @@ BEGIN
...
@@ -7,18 +7,18 @@ BEGIN
LogLine ::= SEQUENCE {
LogLine ::= SEQUENCE {
line-digest IA5String,
line-digest IA5String,
varsets SEQUENCE OF VariablePartSet,
varsets SEQUENCE
SIZE(1..MAX)
OF VariablePartSet,
...
...
}
}
VariablePartSet ::= SEQUENCE {
VariablePartSet ::= SEQUENCE {
vparts SEQUENCE OF VariablePart,
vparts SEQUENCE
SIZE(0..MAX)
OF VariablePart,
resolution ActionItem,
resolution ActionItem,
...
...
}
}
VariablePart ::= CHOICE {
VariablePart ::= CHOICE {
vset SET OF VisibleString,
vset SET
SIZE(1..MAX)
OF VisibleString,
vrange SEQUENCE {
vrange SEQUENCE {
from VisibleString,
from VisibleString,
to 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
This diff is collapsed.
Click to expand it.
tests/46-redefine-OK.asn1.-PR
View file @
2e3055da
...
@@ -18,26 +18,7 @@ der_type_encoder_f PrimitiveType_encode_der;
...
@@ -18,26 +18,7 @@ der_type_encoder_f PrimitiveType_encode_der;
asn_struct_print_f PrimitiveType_print;
asn_struct_print_f PrimitiveType_print;
asn_struct_free_f PrimitiveType_free;
asn_struct_free_f PrimitiveType_free;
/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
/*** <<< CODE [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 */
};
int
int
PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
@@ -54,19 +35,21 @@ 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.
* so adjust the DEF appropriately.
*/
*/
static void
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->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder;
td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
td->free_struct = asn1_DEF_OCTET_STRING.free_struct;
td->free_struct = asn1_DEF_OCTET_STRING.free_struct;
td->print_struct = asn1_DEF_OCTET_STRING.print_struct;
td->print_struct = asn1_DEF_OCTET_STRING.print_struct;
td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form;
td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form;
td->specifics = asn1_DEF_OCTET_STRING.specifics;
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
ber_dec_rval_t
PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
void **structure, void *bufptr, size_t size, int tag_mode) {
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,
return td->ber_decoder(td, structure,
bufptr, size, tag_mode);
bufptr, size, tag_mode);
}
}
...
@@ -75,25 +58,48 @@ der_enc_rval_t
...
@@ -75,25 +58,48 @@ der_enc_rval_t
PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
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);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
}
int
int
PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
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);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
}
void
void
PrimitiveType_free(asn1_TYPE_descriptor_t *td,
PrimitiveType_free(asn1_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
void *struct_ptr, int contents_only) {
inherit_TYPE_descriptor(td);
PrimitiveType_
inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
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] >>> ***/
/*** <<< INCLUDES [ConstructedType] >>> ***/
#include <PrimitiveType.h>
#include <PrimitiveType.h>
...
@@ -115,12 +121,13 @@ typedef struct ConstructedType {
...
@@ -115,12 +121,13 @@ typedef struct ConstructedType {
/*** <<< STAT-DEFS [ConstructedType] >>> ***/
/*** <<< STAT-DEFS [ConstructedType] >>> ***/
static asn1_SEQUENCE_element_t asn1_DEF_ConstructedType_elements[] = {
static asn1_TYPE_member_t asn1_MBR_ConstructedType[] = {
{ offsetof(struct ConstructedType, field), 0,
{ 0, offsetof(struct ConstructedType, field),
(ASN_TAG_CLASS_CONTEXT | (5 << 2)),
.tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)),
-1, /* IMPLICIT tag at current level */
.tag_mode = -1, /* IMPLICIT tag at current level */
(void *)&asn1_DEF_PrimitiveType,
.type = (void *)&asn1_DEF_PrimitiveType,
"field"
.memb_constraints = 0, /* Defer to actual type */
.name = "field"
},
},
};
};
static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = {
static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = {
...
@@ -132,8 +139,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = {
...
@@ -132,8 +139,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = {
static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
sizeof(struct ConstructedType),
sizeof(struct ConstructedType),
offsetof(struct ConstructedType, _ber_dec_ctx),
offsetof(struct ConstructedType, _ber_dec_ctx),
asn1_DEF_ConstructedType_elements,
1, /* Elements count */
asn1_DEF_ConstructedType_tag2el,
asn1_DEF_ConstructedType_tag2el,
1, /* Count of tags in the map */
1, /* Count of tags in the map */
-1, /* Start extensions */
-1, /* Start extensions */
...
@@ -152,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = {
...
@@ -152,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = {
/sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */
/sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
1, /* Whether CONSTRUCTED */
asn1_MBR_ConstructedType,
1, /* Elements count */
&asn1_DEF_ConstructedType_specs /* Additional specs */
&asn1_DEF_ConstructedType_specs /* Additional specs */
};
};
...
@@ -175,26 +182,7 @@ der_type_encoder_f T_encode_der;
...
@@ -175,26 +182,7 @@ der_type_encoder_f T_encode_der;
asn_struct_print_f T_print;
asn_struct_print_f T_print;
asn_struct_free_f T_free;
asn_struct_free_f T_free;
/*** <<< STAT-DEFS [T] >>> ***/
/*** <<< CODE [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 */
};
int
int
T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
...
@@ -211,19 +199,21 @@ 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.
* so adjust the DEF appropriately.
*/
*/
static void
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->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
td->free_struct = asn1_DEF_ConstructedType.free_struct;
td->free_struct = asn1_DEF_ConstructedType.free_struct;
td->print_struct = asn1_DEF_ConstructedType.print_struct;
td->print_struct = asn1_DEF_ConstructedType.print_struct;
td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
td->specifics = asn1_DEF_ConstructedType.specifics;
td->elements = asn1_DEF_ConstructedType.elements;
td->elements_count = asn1_DEF_ConstructedType.elements_count;
td->specifics = asn1_DEF_ConstructedType.specifics;
}
}
ber_dec_rval_t
ber_dec_rval_t
T_decode_ber(asn1_TYPE_descriptor_t *td,
T_decode_ber(asn1_TYPE_descriptor_t *td,
void **structure, void *bufptr, size_t size, int tag_mode) {
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,
return td->ber_decoder(td, structure,
bufptr, size, tag_mode);
bufptr, size, tag_mode);
}
}
...
@@ -232,21 +222,44 @@ der_enc_rval_t
...
@@ -232,21 +222,44 @@ der_enc_rval_t
T_encode_der(asn1_TYPE_descriptor_t *td,
T_encode_der(asn1_TYPE_descriptor_t *td,
void *structure, int tag_mode, ber_tlv_tag_t tag,
void *structure, int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
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);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
}
int
int
T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
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);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
}
void
void
T_free(asn1_TYPE_descriptor_t *td,
T_free(asn1_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
void *struct_ptr, int contents_only) {
inherit_TYPE_descriptor(td);
T_
inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
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 {
...
@@ -35,12 +35,13 @@ typedef struct T1 {
/*** <<< STAT-DEFS [T1] >>> ***/
/*** <<< STAT-DEFS [T1] >>> ***/
static asn1_SET_element_t asn1_DEF_T1_elements[] = {
static asn1_TYPE_member_t asn1_MBR_T1[] = {
{ offsetof(struct T1, i), 0,
{ 0, offsetof(struct T1, i),
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
.tag_mode = 0,
(void *)&asn1_DEF_INTEGER,
.type = (void *)&asn1_DEF_INTEGER,
"i"
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
},
};
};
static ber_tlv_tag_t asn1_DEF_T1_tags[] = {
static ber_tlv_tag_t asn1_DEF_T1_tags[] = {
...
@@ -56,8 +57,6 @@ static asn1_SET_specifics_t asn1_DEF_T1_specs = {
...
@@ -56,8 +57,6 @@ static asn1_SET_specifics_t asn1_DEF_T1_specs = {
sizeof(struct T1),
sizeof(struct T1),
offsetof(struct T1, _ber_dec_ctx),
offsetof(struct T1, _ber_dec_ctx),
offsetof(struct T1, _presence_map),
offsetof(struct T1, _presence_map),
asn1_DEF_T1_elements,
1, /* Elements count */
asn1_DEF_T1_tag2el,
asn1_DEF_T1_tag2el,
1, /* Count of tags in the map */
1, /* Count of tags in the map */
1, /* Whether extensible */
1, /* Whether extensible */
...
@@ -76,6 +75,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T1 = {
...
@@ -76,6 +75,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T1 = {
/sizeof(asn1_DEF_T1_tags[0]), /* 1 */
/sizeof(asn1_DEF_T1_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
1, /* Whether CONSTRUCTED */
asn1_MBR_T1,
1, /* Elements count */
&asn1_DEF_T1_specs /* Additional specs */
&asn1_DEF_T1_specs /* Additional specs */
};
};
...
@@ -116,12 +117,13 @@ typedef struct T2 {
...
@@ -116,12 +117,13 @@ typedef struct T2 {
/*** <<< STAT-DEFS [T2] >>> ***/
/*** <<< STAT-DEFS [T2] >>> ***/
static asn1_SET_element_t asn1_DEF_T2_elements[] = {
static asn1_TYPE_member_t asn1_MBR_T2[] = {
{ offsetof(struct T2, i), 0,
{ 0, offsetof(struct T2, i),
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
.tag_mode = 0,
(void *)&asn1_DEF_INTEGER,
.type = (void *)&asn1_DEF_INTEGER,
"i"
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
},
};
};
static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
static ber_tlv_tag_t asn1_DEF_T2_tags[] = {
...
@@ -137,8 +139,6 @@ static asn1_SET_specifics_t asn1_DEF_T2_specs = {
...
@@ -137,8 +139,6 @@ static asn1_SET_specifics_t asn1_DEF_T2_specs = {
sizeof(struct T2),
sizeof(struct T2),
offsetof(struct T2, _ber_dec_ctx),
offsetof(struct T2, _ber_dec_ctx),
offsetof(struct T2, _presence_map),
offsetof(struct T2, _presence_map),
asn1_DEF_T2_elements,
1, /* Elements count */
asn1_DEF_T2_tag2el,
asn1_DEF_T2_tag2el,
1, /* Count of tags in the map */
1, /* Count of tags in the map */
1, /* Whether extensible */
1, /* Whether extensible */
...
@@ -157,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = {
...
@@ -157,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = {
/sizeof(asn1_DEF_T2_tags[0]), /* 1 */
/sizeof(asn1_DEF_T2_tags[0]), /* 1 */
1, /* Tags to skip */
1, /* Tags to skip */
1, /* Whether CONSTRUCTED */
1, /* Whether CONSTRUCTED */
asn1_MBR_T2,
1, /* Elements count */
&asn1_DEF_T2_specs /* Additional specs */
&asn1_DEF_T2_specs /* Additional specs */
};
};
...
@@ -194,12 +196,13 @@ typedef struct T3 {
...
@@ -194,12 +196,13 @@ typedef struct T3 {
/*** <<< STAT-DEFS [T3] >>> ***/
/*** <<< STAT-DEFS [T3] >>> ***/
static asn1_CHOICE_element_t asn1_DEF_T3_elements[] = {
static asn1_TYPE_member_t asn1_MBR_T3[] = {
{ offsetof(struct T3, choice.i), 0,
{ 0, offsetof(struct T3, choice.i),
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
.tag_mode = 0,
(void *)&asn1_DEF_INTEGER,
.type = (void *)&asn1_DEF_INTEGER,
"i"
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
},
};
};
static asn1_TYPE_tag2member_t asn1_DEF_T3_tag2el[] = {
static asn1_TYPE_tag2member_t asn1_DEF_T3_tag2el[] = {
...
@@ -210,8 +213,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T3_specs = {
...
@@ -210,8 +213,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T3_specs = {
offsetof(struct T3, _ber_dec_ctx),
offsetof(struct T3, _ber_dec_ctx),
offsetof(struct T3, present),
offsetof(struct T3, present),
sizeof(((struct T3 *)0)->present),
sizeof(((struct T3 *)0)->present),
asn1_DEF_T3_elements,
1, /* Elements count */
asn1_DEF_T3_tag2el,
asn1_DEF_T3_tag2el,
1, /* Count of tags in the map */
1, /* Count of tags in the map */
1 /* Whether extensible */
1 /* Whether extensible */
...
@@ -228,6 +229,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T3 = {
...
@@ -228,6 +229,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T3 = {
0, /* No explicit tags (count) */
0, /* No explicit tags (count) */
0, /* Tags to skip */
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
1, /* Whether CONSTRUCTED */
asn1_MBR_T3,
1, /* Elements count */
&asn1_DEF_T3_specs /* Additional specs */
&asn1_DEF_T3_specs /* Additional specs */
};
};
...
@@ -265,12 +268,13 @@ typedef struct T4 {
...
@@ -265,12 +268,13 @@ typedef struct T4 {
/*** <<< STAT-DEFS [T4] >>> ***/
/*** <<< STAT-DEFS [T4] >>> ***/
static asn1_CHOICE_element_t asn1_DEF_T4_elements[] = {
static asn1_TYPE_member_t asn1_MBR_T4[] = {
{ offsetof(struct T4, choice.i), 0,
{ 0, offsetof(struct T4, choice.i),
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
0,
.tag_mode = 0,
(void *)&asn1_DEF_INTEGER,
.type = (void *)&asn1_DEF_INTEGER,
"i"
.memb_constraints = 0, /* Defer to actual type */
.name = "i"
},
},
};
};
static asn1_TYPE_tag2member_t asn1_DEF_T4_tag2el[] = {
static asn1_TYPE_tag2member_t asn1_DEF_T4_tag2el[] = {
...
@@ -281,8 +285,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T4_specs = {
...
@@ -281,8 +285,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T4_specs = {
offsetof(struct T4, _ber_dec_ctx),
offsetof(struct T4, _ber_dec_ctx),
offsetof(struct T4, present),
offsetof(struct T4, present),
sizeof(((struct T4 *)0)->present),
sizeof(((struct T4 *)0)->present),
asn1_DEF_T4_elements,
1, /* Elements count */
asn1_DEF_T4_tag2el,
asn1_DEF_T4_tag2el,
1, /* Count of tags in the map */
1, /* Count of tags in the map */
1 /* Whether extensible */
1 /* Whether extensible */
...
@@ -299,6 +301,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T4 = {
...
@@ -299,6 +301,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T4 = {
0, /* No explicit tags (count) */
0, /* No explicit tags (count) */
0, /* Tags to skip */
0, /* Tags to skip */
1, /* Whether CONSTRUCTED */
1, /* Whether CONSTRUCTED */
asn1_MBR_T4,
1, /* Elements count */
&asn1_DEF_T4_specs /* Additional specs */
&asn1_DEF_T4_specs /* Additional specs */
};
};
tests/50-constraint-OK.asn1
View file @
2e3055da
...
@@ -39,4 +39,8 @@ BEGIN
...
@@ -39,4 +39,8 @@ BEGIN
SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD"))
SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD"))
Neither-SIZE-nor-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
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