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
8a99bf71
Commit
8a99bf71
authored
Sep 10, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new tests for constraint processing logic
parent
c3e29404
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
20 deletions
+154
-20
tests/50-constraint-OK.asn1
tests/50-constraint-OK.asn1
+3
-0
tests/50-constraint-OK.asn1.-EFprint-constraints
tests/50-constraint-OK.asn1.-EFprint-constraints
+0
-0
tests/50-constraint-OK.asn1.-P
tests/50-constraint-OK.asn1.-P
+151
-20
No files found.
tests/50-constraint-OK.asn1
View file @
8a99bf71
...
...
@@ -16,6 +16,7 @@ BEGIN
Int3 ::= Int2 (MIN..ten) -- Means (0..10)
Int4 ::= Int3 (5..MAX,...,1..4) -- Means (5..10,...,1..4)
Int5 ::= Int4 (MIN..5) -- Means (5)
-- Int6 ::= INTEGER (Int5) -- -- Not yet supported
ten Int1 ::= other-ten
other-ten Int2 ::= 10
...
...
@@ -28,6 +29,8 @@ BEGIN
-- Means (SIZE(0..20 | 25..30))
Str3 ::= Str2 (SIZE(10..27))(FROM("ABC"|"def"))
-- (SIZE(10..20,25..27))(FROM("ABCdef"))
Str4 ::= IA5String ("ABCD"|SIZE(4))
-- Not PER-visible
PER-Visible ::= IA5String (FROM("A".."F"))
PER-Visible-2 ::= PER-Visible (FROM("E".."F")) -- Means (FROM("EF"))
...
...
tests/50-constraint-OK.asn1.-EFprint-constraints
View file @
8a99bf71
No preview for this file type
tests/50-constraint-OK.asn1.-P
View file @
8a99bf71
...
...
@@ -1084,6 +1084,137 @@ asn1_TYPE_descriptor_t asn1_DEF_Str3 = {
};
/*** <<< INCLUDES [Str4] >>> ***/
#include <IA5String.h>
/*** <<< TYPE-DECLS [Str4] >>> ***/
typedef IA5String_t Str4_t;
/*** <<< FUNC-DECLS [Str4] >>> ***/
extern asn1_TYPE_descriptor_t asn1_DEF_Str4;
asn_constr_check_f Str4_constraint;
ber_type_decoder_f Str4_decode_ber;
der_type_encoder_f Str4_encode_der;
asn_struct_print_f Str4_print;
asn_struct_free_f Str4_free;
/*** <<< CTABLES [Str4] >>> ***/
static int check_permitted_alphabet_3(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
const uint8_t *end = ch + st->size;
for(; ch < end; ch++) {
uint8_t cv = *ch;
if(!(cv <= 127)) return -1;
}
return 0;
}
/*** <<< CODE [Str4] >>> ***/
int
Str4_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
const IA5String_t *st = sptr;
if(!sptr) {
_ASN_ERRLOG(app_errlog, app_key,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if(!check_permitted_alphabet_3(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_ERRLOG(app_errlog, app_key,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*
* This type is implemented using IA5String,
* so adjust the DEF appropriately.
*/
static void
Str4_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
td->ber_decoder = asn1_DEF_IA5String.ber_decoder;
td->der_encoder = asn1_DEF_IA5String.der_encoder;
td->free_struct = asn1_DEF_IA5String.free_struct;
td->print_struct = asn1_DEF_IA5String.print_struct;
td->last_tag_form = asn1_DEF_IA5String.last_tag_form;
td->elements = asn1_DEF_IA5String.elements;
td->elements_count = asn1_DEF_IA5String.elements_count;
td->specifics = asn1_DEF_IA5String.specifics;
}
ber_dec_rval_t
Str4_decode_ber(asn1_TYPE_descriptor_t *td,
void **structure, void *bufptr, size_t size, int tag_mode) {
Str4_inherit_TYPE_descriptor(td);
return td->ber_decoder(td, structure,
bufptr, size, tag_mode);
}
der_enc_rval_t
Str4_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) {
Str4_inherit_TYPE_descriptor(td);
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
}
int
Str4_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
Str4_inherit_TYPE_descriptor(td);
return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
}
void
Str4_free(asn1_TYPE_descriptor_t *td,
void *struct_ptr, int contents_only) {
Str4_inherit_TYPE_descriptor(td);
td->free_struct(td, struct_ptr, contents_only);
}
/*** <<< STAT-DEFS [Str4] >>> ***/
static ber_tlv_tag_t asn1_DEF_Str4_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (22 << 2))
};
asn1_TYPE_descriptor_t asn1_DEF_Str4 = {
"Str4",
Str4_constraint,
Str4_decode_ber,
Str4_encode_der,
Str4_print,
Str4_free,
0, /* Use generic outmost tag fetcher */
asn1_DEF_Str4_tags,
sizeof(asn1_DEF_Str4_tags)
/sizeof(asn1_DEF_Str4_tags[0]), /* 1 */
1, /* Tags to skip */
-0, /* Unknown yet */
0, 0, /* No members */
0 /* No specifics */
};
/*** <<< INCLUDES [PER-Visible] >>> ***/
#include <IA5String.h>
...
...
@@ -1104,7 +1235,7 @@ asn_struct_free_f PER_Visible_free;
/*** <<< CTABLES [PER-Visible] >>> ***/
static int check_permitted_alphabet_
3
(const void *sptr) {
static int check_permitted_alphabet_
4
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1134,7 +1265,7 @@ PER_Visible_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(!check_permitted_alphabet_
3
(sptr)) {
if(!check_permitted_alphabet_
4
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1235,7 +1366,7 @@ asn_struct_free_f PER_Visible_2_free;
/*** <<< CTABLES [PER-Visible-2] >>> ***/
static int check_permitted_alphabet_
4
(const void *sptr) {
static int check_permitted_alphabet_
5
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1265,7 +1396,7 @@ PER_Visible_2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(!check_permitted_alphabet_
4
(sptr)) {
if(!check_permitted_alphabet_
5
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1366,7 +1497,7 @@ asn_struct_free_f Not_PER_Visible_1_free;
/*** <<< CTABLES [Not-PER-Visible-1] >>> ***/
static int check_permitted_alphabet_
5
(const void *sptr) {
static int check_permitted_alphabet_
6
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1396,7 +1527,7 @@ Not_PER_Visible_1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(!check_permitted_alphabet_
5
(sptr)) {
if(!check_permitted_alphabet_
6
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1497,7 +1628,7 @@ asn_struct_free_f Not_PER_Visible_2_free;
/*** <<< CTABLES [Not-PER-Visible-2] >>> ***/
static int check_permitted_alphabet_
6
(const void *sptr) {
static int check_permitted_alphabet_
7
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1527,7 +1658,7 @@ Not_PER_Visible_2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(!check_permitted_alphabet_
6
(sptr)) {
if(!check_permitted_alphabet_
7
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1628,7 +1759,7 @@ asn_struct_free_f Not_PER_Visible_3_free;
/*** <<< CTABLES [Not-PER-Visible-3] >>> ***/
static int check_permitted_alphabet_
7
(const void *sptr) {
static int check_permitted_alphabet_
8
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1658,7 +1789,7 @@ Not_PER_Visible_3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(!check_permitted_alphabet_
7
(sptr)) {
if(!check_permitted_alphabet_
8
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1759,7 +1890,7 @@ asn_struct_free_f SIZE_but_not_FROM_free;
/*** <<< CTABLES [SIZE-but-not-FROM] >>> ***/
static int check_permitted_alphabet_
8
(const void *sptr) {
static int check_permitted_alphabet_
9
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1792,7 +1923,7 @@ SIZE_but_not_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
size = st->size;
if((size >= 1 && size <= 4)
&& !check_permitted_alphabet_
8
(sptr)) {
&& !check_permitted_alphabet_
9
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -1893,7 +2024,7 @@ asn_struct_free_f SIZE_and_FROM_free;
/*** <<< CTABLES [SIZE-and-FROM] >>> ***/
static int check_permitted_alphabet_
9
(const void *sptr) {
static int check_permitted_alphabet_
10
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -1926,7 +2057,7 @@ SIZE_and_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
size = st->size;
if((size >= 1 && size <= 4)
&& !check_permitted_alphabet_
9
(sptr)) {
&& !check_permitted_alphabet_
10
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -2027,7 +2158,7 @@ asn_struct_free_f Neither_SIZE_nor_FROM_free;
/*** <<< CTABLES [Neither-SIZE-nor-FROM] >>> ***/
static int check_permitted_alphabet_1
0
(const void *sptr) {
static int check_permitted_alphabet_1
1
(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -2057,7 +2188,7 @@ Neither_SIZE_nor_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
}
if(!check_permitted_alphabet_1
0
(sptr)) {
if(!check_permitted_alphabet_1
1
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
@@ -2158,7 +2289,7 @@ asn_struct_free_f Utf8_3_free;
/*** <<< CTABLES [Utf8-3] >>> ***/
static int permitted_alphabet_table_1
1
[128] = {
static int permitted_alphabet_table_1
2
[128] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */
...
...
@@ -2169,8 +2300,8 @@ static int permitted_alphabet_table_11[128] = {
1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* pqrstuvwxyz */
};
static int check_permitted_alphabet_1
1
(const void *sptr) {
int *table = permitted_alphabet_table_1
1
;
static int check_permitted_alphabet_1
2
(const void *sptr) {
int *table = permitted_alphabet_table_1
2
;
/* The underlying type is UTF8String */
const UTF8String_t *st = sptr;
const uint8_t *ch = st->buf;
...
...
@@ -2205,7 +2336,7 @@ Utf8_3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
if(size == (size_t)-1) return -1;
if((size >= 1 && size <= 2)
&& !check_permitted_alphabet_1
1
(sptr)) {
&& !check_permitted_alphabet_1
2
(sptr)) {
/* Constraint check succeeded */
return 0;
} else {
...
...
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