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
69353a32
Commit
69353a32
authored
Jul 25, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test that we ignore size constraints on not-known-multipler character string (utf8string)
parent
1d76f3c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
984 additions
and
12 deletions
+984
-12
asn1c/tests/check-src/check-137.-gen-OER.c
asn1c/tests/check-src/check-137.-gen-OER.c
+7
-6
tests/136-oer-long-OK.asn1.-Pgen-OER
tests/136-oer-long-OK.asn1.-Pgen-OER
+580
-0
tests/137-oer-string-OK.asn1
tests/137-oer-string-OK.asn1
+6
-6
tests/137-oer-string-OK.asn1.-Pgen-OER
tests/137-oer-string-OK.asn1.-Pgen-OER
+391
-0
No files found.
asn1c/tests/check-src/check-137.-gen-OER.c
View file @
69353a32
...
...
@@ -19,14 +19,15 @@ int main() {
memset
(
&
source
,
0
,
sizeof
(
source
));
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
ia5
,
"foo"
,
3
);
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
u
tf8
,
"bar"
,
3
);
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
universal
,
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
unc_
ia5
,
"foo"
,
3
);
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
u
nc_utf8
,
"bar-whatever"
,
12
);
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
un
c_un
iversal
,
"
\0\0\0
b
\0\0\0
a
\0\0\0
z"
,
12
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
ia5
,
"ab"
,
2
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
utf8
,
"cd"
,
2
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
universal
,
"
\0\0\0
e
\0\0\0
f"
,
8
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
con_ia5
,
"ab"
,
2
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
con_utf8
,
"cd-whatever"
,
11
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
con_universal
,
"
\0\0\0
e
\0\0\0
f"
,
8
);
asn_enc_rval_t
er
=
oer_encode_to_buffer
(
&
asn_DEF_T
,
0
,
&
source
,
tmpbuf
,
sizeof
(
tmpbuf
));
...
...
tests/136-oer-long-OK.asn1.-Pgen-OER
0 → 100644
View file @
69353a32
/*** <<< INCLUDES [T] >>> ***/
#include <NativeInteger.h>
#include <INTEGER.h>
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [T] >>> ***/
typedef struct T {
long unsigned8;
long unsigned16;
long unsigned16stack;
long unsigned16stack_ext;
INTEGER_t unsigned33;
long *minmax /* OPTIONAL */;
/*
* This type is extensible,
* possible extensions are below.
*/
long *signed8 /* DEFAULT 3 */;
long *signed16;
long *signed16stack;
long *signed16stack_ext;
long *signed32;
INTEGER_t *signed33ext;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} T_t;
/*** <<< FUNC-DECLS [T] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_T;
/*** <<< CODE [T] >>> ***/
static int
memb_unsigned8_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 255)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_unsigned16_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 65535)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_unsigned16stack_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 255)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_unsigned16stack_ext_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= 0 && value <= 255)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_unsigned33_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const INTEGER_t *st = (const INTEGER_t *)sptr;
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if(asn_INTEGER2long(st, &value)) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value too large (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if((value >= 0 && value <= 5000000000)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_minmax_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if(1 /* No applicable constraints whatsoever */) {
/* Nothing is here. See below */
}
return td->check_constraints(td, sptr, ctfailcb, app_key);
}
static int
memb_signed8_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= -128 && value <= 127)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_signed16_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= -32768 && value <= 32767)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_signed16stack_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= -128 && value <= 127)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_signed16stack_ext_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= -128 && value <= 127)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_signed32_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
value = *(const long *)sptr;
if((value >= -2000000000 && value <= 2000000000)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_signed33ext_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const INTEGER_t *st = (const INTEGER_t *)sptr;
long value;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if(asn_INTEGER2long(st, &value)) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value too large (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if((value >= -4000000000 && value <= 4000000000)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*** <<< CTDEFS [T] >>> ***/
static asn_oer_constraints_t asn_OER_memb_unsigned8_constr_2 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, 0, 255 } /* (0..255) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_unsigned16_constr_3 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, 0, 65535 } /* (0..65535) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_unsigned16stack_constr_4 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, 0, 255 } /* (0..255) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_unsigned16stack_ext_constr_5 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, 0, 255 } /* (0..255,...) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_unsigned33_constr_6 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, 0, 5000000000 } /* (0..5000000000) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_minmax_constr_7 GCC_NOTUSED = {
{ 0, 0, 0 },
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_signed8_constr_9 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, -128, 127 } /* (-128..127) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_signed16_constr_10 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, -32768, 32767 } /* (-32768..32767) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_signed16stack_constr_11 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, -128, 127 } /* (-128..127) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_signed16stack_ext_constr_12 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, -128, 127 } /* (-128..127,...) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_signed32_constr_13 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, -2000000000, 2000000000 } /* (-2000000000..2000000000) */,
{ 0, 0, 0 }};
static asn_oer_constraints_t asn_OER_memb_signed33ext_constr_14 GCC_NOTUSED = {
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, -4000000000, 4000000000 } /* (-4000000000..4000000000,...) */,
{ 0, 0, 0 }};
/*** <<< STAT-DEFS [T] >>> ***/
static int asn_DFL_9_set_3(int set_value, void **sptr) {
long *st = *sptr;
if(!st) {
if(!set_value) return -1; /* Not a default value */
st = (*sptr = CALLOC(1, sizeof(*st)));
if(!st) return -1;
}
if(set_value) {
/* Install default value 3 */
*st = 3;
return 0;
} else {
/* Test default value 3 */
return (*st == 3);
}
}
static asn_TYPE_member_t asn_MBR_T_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct T, unsigned8),
.tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_unsigned8_constraint_1,
.oer_constraints = &asn_OER_memb_unsigned8_constr_2,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unsigned8"
},
{ ATF_NOFLAGS, 0, offsetof(struct T, unsigned16),
.tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_unsigned16_constraint_1,
.oer_constraints = &asn_OER_memb_unsigned16_constr_3,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unsigned16"
},
{ ATF_NOFLAGS, 0, offsetof(struct T, unsigned16stack),
.tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_unsigned16stack_constraint_1,
.oer_constraints = &asn_OER_memb_unsigned16stack_constr_4,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unsigned16stack"
},
{ ATF_NOFLAGS, 0, offsetof(struct T, unsigned16stack_ext),
.tag = (ASN_TAG_CLASS_CONTEXT | (15 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_unsigned16stack_ext_constraint_1,
.oer_constraints = &asn_OER_memb_unsigned16stack_ext_constr_5,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unsigned16stack-ext"
},
{ ATF_NOFLAGS, 0, offsetof(struct T, unsigned33),
.tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_INTEGER,
.memb_constraints = memb_unsigned33_constraint_1,
.oer_constraints = &asn_OER_memb_unsigned33_constr_6,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unsigned33"
},
{ ATF_POINTER, 7, offsetof(struct T, minmax),
.tag = (ASN_TAG_CLASS_CONTEXT | (6 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_minmax_constraint_1,
.oer_constraints = &asn_OER_memb_minmax_constr_7,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "minmax"
},
{ ATF_POINTER, 6, offsetof(struct T, signed8),
.tag = (ASN_TAG_CLASS_CONTEXT | (10 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_signed8_constraint_1,
.oer_constraints = &asn_OER_memb_signed8_constr_9,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = asn_DFL_9_set_3, /* DEFAULT 3 */
.name = "signed8"
},
{ ATF_POINTER, 5, offsetof(struct T, signed16),
.tag = (ASN_TAG_CLASS_CONTEXT | (11 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_signed16_constraint_1,
.oer_constraints = &asn_OER_memb_signed16_constr_10,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "signed16"
},
{ ATF_POINTER, 4, offsetof(struct T, signed16stack),
.tag = (ASN_TAG_CLASS_CONTEXT | (12 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_signed16stack_constraint_1,
.oer_constraints = &asn_OER_memb_signed16stack_constr_11,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "signed16stack"
},
{ ATF_POINTER, 3, offsetof(struct T, signed16stack_ext),
.tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_signed16stack_ext_constraint_1,
.oer_constraints = &asn_OER_memb_signed16stack_ext_constr_12,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "signed16stack-ext"
},
{ ATF_POINTER, 2, offsetof(struct T, signed32),
.tag = (ASN_TAG_CLASS_CONTEXT | (7 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_NativeInteger,
.memb_constraints = memb_signed32_constraint_1,
.oer_constraints = &asn_OER_memb_signed32_constr_13,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "signed32"
},
{ ATF_POINTER, 1, offsetof(struct T, signed33ext),
.tag = (ASN_TAG_CLASS_CONTEXT | (8 << 2)),
.tag_mode = -1, /* IMPLICIT tag at current level */
.type = &asn_DEF_INTEGER,
.memb_constraints = memb_signed33ext_constraint_1,
.oer_constraints = &asn_OER_memb_signed33ext_constr_14,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "signed33ext"
},
};
static const int asn_MAP_T_oms_1[] = { 5, 6, 7, 8, 9, 10, 11 };
static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* unsigned8 */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* unsigned16 */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* unsigned16stack */
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 4, 0, 0 }, /* unsigned33 */
{ (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 9, 0, 0 }, /* signed16stack-ext */
{ (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 5, 0, 0 }, /* minmax */
{ (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 10, 0, 0 }, /* signed32 */
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 11, 0, 0 }, /* signed33ext */
{ (ASN_TAG_CLASS_CONTEXT | (10 << 2)), 6, 0, 0 }, /* signed8 */
{ (ASN_TAG_CLASS_CONTEXT | (11 << 2)), 7, 0, 0 }, /* signed16 */
{ (ASN_TAG_CLASS_CONTEXT | (12 << 2)), 8, 0, 0 }, /* signed16stack */
{ (ASN_TAG_CLASS_CONTEXT | (15 << 2)), 3, 0, 0 } /* unsigned16stack-ext */
};
static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
sizeof(struct T),
offsetof(struct T, _asn_ctx),
asn_MAP_T_tag2el_1,
12, /* Count of tags in the map */
asn_MAP_T_oms_1, /* Optional members */
1, 6, /* Root/Additions */
5, /* Start extensions */
13 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_T = {
"T",
"T",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
SEQUENCE_decode_oer,
SEQUENCE_encode_oer,
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_T_tags_1,
sizeof(asn_DEF_T_tags_1)
/sizeof(asn_DEF_T_tags_1[0]), /* 1 */
asn_DEF_T_tags_1, /* Same as above */
sizeof(asn_DEF_T_tags_1)
/sizeof(asn_DEF_T_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_T_1,
12, /* Elements count */
&asn_SPC_T_specs_1 /* Additional specs */
};
tests/137-oer-string-OK.asn1
View file @
69353a32
...
...
@@ -13,14 +13,14 @@ BEGIN
T ::= SEQUENCE {
unconstrained SEQUENCE {
ia5 IA5String,
utf8 UTF8String,
universal UniversalString
unc-
ia5 IA5String,
u
nc-u
tf8 UTF8String,
un
c-un
iversal UniversalString
},
constrained SEQUENCE {
ia5 IA5String (SIZE(2..2)),
utf8 UTF8String (SIZE(2)),
universal UniversalString (SIZE(2 | 2))
con-
ia5 IA5String (SIZE(2..2)),
con-
utf8 UTF8String (SIZE(2)),
con-
universal UniversalString (SIZE(2 | 2))
}
}
...
...
tests/137-oer-string-OK.asn1.-Pgen-OER
0 → 100644
View file @
69353a32
/*** <<< INCLUDES [T] >>> ***/
#include <IA5String.h>
#include <UTF8String.h>
#include <UniversalString.h>
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [T] >>> ***/
typedef struct T {
struct unconstrained {
IA5String_t unc_ia5;
UTF8String_t unc_utf8;
UniversalString_t unc_universal;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} unconstrained;
struct constrained {
IA5String_t con_ia5;
UTF8String_t con_utf8;
UniversalString_t con_universal;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} constrained;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} T_t;
/*** <<< FUNC-DECLS [T] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_T;
/*** <<< CTABLES [T] >>> ***/
static int check_permitted_alphabet_7(const void *sptr) {
/* The underlying type is IA5String */
const IA5String_t *st = (const IA5String_t *)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;
}
static int check_permitted_alphabet_9(const void *sptr) {
/* The underlying type is UniversalString */
const UniversalString_t *st = (const UniversalString_t *)sptr;
const uint8_t *ch = st->buf;
const uint8_t *end = ch + st->size;
if(st->size % 4) return -1; /* (size%4)! */
for(; ch < end; ch += 4) {
uint32_t cv = (ch[0] << 24)
| (ch[1] << 16)
| (ch[2] << 8)
| ch[3];
if(!(1 /* Constraint matches natural range of cv */)) return -1;
}
return 0;
}
/*** <<< CODE [T] >>> ***/
static int
memb_con_ia5_constraint_6(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const IA5String_t *st = (const IA5String_t *)sptr;
size_t size;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
size = st->size;
if((size == 2)
&& !check_permitted_alphabet_7(st)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_con_utf8_constraint_6(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const UTF8String_t *st = (const UTF8String_t *)sptr;
size_t size;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
size = UTF8String_length(st);
if((ssize_t)size < 0) {
ASN__CTFAIL(app_key, td, sptr,
"%s: UTF-8: broken encoding (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
if((size == 2)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static int
memb_con_universal_constraint_6(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const UniversalString_t *st = (const UniversalString_t *)sptr;
size_t size;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
size = st->size >> 2; /* 4 byte per character */
if((size == 2)
&& !check_permitted_alphabet_9(st)) {
/* Constraint check succeeded */
return 0;
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
/*** <<< CTDEFS [T] >>> ***/
static asn_oer_constraints_t asn_OER_memb_con_ia5_constr_7 GCC_NOTUSED = {
{ 0, 0, 0 },
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, 2, 2 } /* (SIZE(2..2)) */};
static asn_oer_constraints_t asn_OER_memb_con_utf8_constr_8 GCC_NOTUSED = {
{ 0, 0, 0 },
{ 0, 0, 0 } /* (SIZE(2..2)) */};
static asn_oer_constraints_t asn_OER_memb_con_universal_constr_9 GCC_NOTUSED = {
{ 0, 0, 0 },
{ AOC_HAS_LOWER_BOUND | AOC_HAS_UPPER_BOUND, 2, 2 } /* (SIZE(2..2)) */};
/*** <<< STAT-DEFS [T] >>> ***/
static asn_TYPE_member_t asn_MBR_unconstrained_2[] = {
{ ATF_NOFLAGS, 0, offsetof(struct unconstrained, unc_ia5),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
.tag_mode = 0,
.type = &asn_DEF_IA5String,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* No OER visible constraints */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unc-ia5"
},
{ ATF_NOFLAGS, 0, offsetof(struct unconstrained, unc_utf8),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
.tag_mode = 0,
.type = &asn_DEF_UTF8String,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* No OER visible constraints */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unc-utf8"
},
{ ATF_NOFLAGS, 0, offsetof(struct unconstrained, unc_universal),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)),
.tag_mode = 0,
.type = &asn_DEF_UniversalString,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* No OER visible constraints */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unc-universal"
},
};
static const ber_tlv_tag_t asn_DEF_unconstrained_tags_2[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_unconstrained_tag2el_2[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), 1, 0, 0 }, /* unc-utf8 */
{ (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), 0, 0, 0 }, /* unc-ia5 */
{ (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)), 2, 0, 0 } /* unc-universal */
};
static asn_SEQUENCE_specifics_t asn_SPC_unconstrained_specs_2 = {
sizeof(struct unconstrained),
offsetof(struct unconstrained, _asn_ctx),
asn_MAP_unconstrained_tag2el_2,
3, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_unconstrained_2 = {
"unconstrained",
"unconstrained",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
SEQUENCE_decode_oer,
SEQUENCE_encode_oer,
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_unconstrained_tags_2,
sizeof(asn_DEF_unconstrained_tags_2)
/sizeof(asn_DEF_unconstrained_tags_2[0]), /* 1 */
asn_DEF_unconstrained_tags_2, /* Same as above */
sizeof(asn_DEF_unconstrained_tags_2)
/sizeof(asn_DEF_unconstrained_tags_2[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_unconstrained_2,
3, /* Elements count */
&asn_SPC_unconstrained_specs_2 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_constrained_6[] = {
{ ATF_NOFLAGS, 0, offsetof(struct constrained, con_ia5),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
.tag_mode = 0,
.type = &asn_DEF_IA5String,
.memb_constraints = memb_con_ia5_constraint_6,
.oer_constraints = &asn_OER_memb_con_ia5_constr_7,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "con-ia5"
},
{ ATF_NOFLAGS, 0, offsetof(struct constrained, con_utf8),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
.tag_mode = 0,
.type = &asn_DEF_UTF8String,
.memb_constraints = memb_con_utf8_constraint_6,
.oer_constraints = &asn_OER_memb_con_utf8_constr_8,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "con-utf8"
},
{ ATF_NOFLAGS, 0, offsetof(struct constrained, con_universal),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)),
.tag_mode = 0,
.type = &asn_DEF_UniversalString,
.memb_constraints = memb_con_universal_constraint_6,
.oer_constraints = &asn_OER_memb_con_universal_constr_9,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "con-universal"
},
};
static const ber_tlv_tag_t asn_DEF_constrained_tags_6[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_constrained_tag2el_6[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), 1, 0, 0 }, /* con-utf8 */
{ (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), 0, 0, 0 }, /* con-ia5 */
{ (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)), 2, 0, 0 } /* con-universal */
};
static asn_SEQUENCE_specifics_t asn_SPC_constrained_specs_6 = {
sizeof(struct constrained),
offsetof(struct constrained, _asn_ctx),
asn_MAP_constrained_tag2el_6,
3, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_constrained_6 = {
"constrained",
"constrained",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
SEQUENCE_decode_oer,
SEQUENCE_encode_oer,
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_constrained_tags_6,
sizeof(asn_DEF_constrained_tags_6)
/sizeof(asn_DEF_constrained_tags_6[0]), /* 1 */
asn_DEF_constrained_tags_6, /* Same as above */
sizeof(asn_DEF_constrained_tags_6)
/sizeof(asn_DEF_constrained_tags_6[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_constrained_6,
3, /* Elements count */
&asn_SPC_constrained_specs_6 /* Additional specs */
};
static asn_TYPE_member_t asn_MBR_T_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct T, unconstrained),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = &asn_DEF_unconstrained_2,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* No OER visible constraints */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "unconstrained"
},
{ ATF_NOFLAGS, 0, offsetof(struct T, constrained),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = &asn_DEF_constrained_6,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* No OER visible constraints */
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "constrained"
},
};
static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 1 }, /* unconstrained */
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, -1, 0 } /* constrained */
};
static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
sizeof(struct T),
offsetof(struct T, _asn_ctx),
asn_MAP_T_tag2el_1,
2, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_T = {
"T",
"T",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
SEQUENCE_decode_oer,
SEQUENCE_encode_oer,
0, 0, /* No PER support, use "-gen-PER" to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_T_tags_1,
sizeof(asn_DEF_T_tags_1)
/sizeof(asn_DEF_T_tags_1[0]), /* 1 */
asn_DEF_T_tags_1, /* Same as above */
sizeof(asn_DEF_T_tags_1)
/sizeof(asn_DEF_T_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_T_1,
2, /* Elements count */
&asn_SPC_T_specs_1 /* Additional specs */
};
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