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
20dc6247
Commit
20dc6247
authored
Aug 27, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new tests
parent
9a1736da
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
952 additions
and
0 deletions
+952
-0
tests/tests-asn1c-compiler/146-ios-parameterization-per-OK.asn1
...tests-asn1c-compiler/146-ios-parameterization-per-OK.asn1
+34
-0
tests/tests-asn1c-compiler/146-ios-parameterization-per-OK.asn1.-Pgen-PER
...c-compiler/146-ios-parameterization-per-OK.asn1.-Pgen-PER
+317
-0
tests/tests-asn1c-compiler/147-inherit-per-constraints-OK.asn1
.../tests-asn1c-compiler/147-inherit-per-constraints-OK.asn1
+22
-0
tests/tests-asn1c-compiler/147-inherit-per-constraints-OK.asn1.-Pgen-OER
...1c-compiler/147-inherit-per-constraints-OK.asn1.-Pgen-OER
+287
-0
tests/tests-asn1c-compiler/147-inherit-per-constraints-OK.asn1.-Pgen-PER
...1c-compiler/147-inherit-per-constraints-OK.asn1.-Pgen-PER
+292
-0
No files found.
tests/tests-asn1c-compiler/146-ios-parameterization-per-OK.asn1
0 → 100755
View file @
20dc6247
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .146
ModuleInformationObjectParameterizationPER
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 146 }
DEFINITIONS ::=
BEGIN
MYID ::= CLASS {
&id INTEGER UNIQUE,
&Type
} WITH SYNTAX {&Type IDENTIFIED BY &id}
RegionalExtension MYID ::= {
{INTEGER IDENTIFIED BY 1} |
{BOOLEAN IDENTIFIED BY 2},
...
}
Message ::= SEQUENCE {
content SpecializedContent {{RegionalExtension}}
}
SpecializedContent {MYID : Set} ::= SEQUENCE {
id MYID.&id({Set}),
value MYID.&Type({Set}{@id})
}
END
tests/tests-asn1c-compiler/146-ios-parameterization-per-OK.asn1.-Pgen-PER
0 → 100644
View file @
20dc6247
/*** <<< INCLUDES [Message] >>> ***/
#include "SpecializedContent.h"
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Message] >>> ***/
typedef struct Message {
SpecializedContent_30P0_t content;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Message_t;
/*** <<< FUNC-DECLS [Message] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Message;
/*** <<< STAT-DEFS [Message] >>> ***/
static asn_TYPE_member_t asn_MBR_Message_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Message, content),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
.tag_mode = 0,
.type = &asn_DEF_SpecializedContent_30P0,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* No PER visible constraints */
.default_value = 0,
.name = "content"
},
};
static const ber_tlv_tag_t asn_DEF_Message_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Message_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* content */
};
static asn_SEQUENCE_specifics_t asn_SPC_Message_specs_1 = {
sizeof(struct Message),
offsetof(struct Message, _asn_ctx),
.tag2el = asn_MAP_Message_tag2el_1,
.tag2el_count = 1, /* 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_Message = {
"Message",
"Message",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
asn_DEF_Message_tags_1,
sizeof(asn_DEF_Message_tags_1)
/sizeof(asn_DEF_Message_tags_1[0]), /* 1 */
asn_DEF_Message_tags_1, /* Same as above */
sizeof(asn_DEF_Message_tags_1)
/sizeof(asn_DEF_Message_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Message_1,
1, /* Elements count */
&asn_SPC_Message_specs_1 /* Additional specs */
};
/*** <<< INCLUDES [SpecializedContent] >>> ***/
#include <NativeInteger.h>
#include <ANY.h>
#include <asn_ioc.h>
#include <OPEN_TYPE.h>
#include <BOOLEAN.h>
#include <constr_CHOICE.h>
#include <constr_SEQUENCE.h>
/*** <<< DEPS [SpecializedContent] >>> ***/
typedef enum value_PR {
value_PR_NOTHING, /* No components present */
value_PR_INTEGER,
value_PR_BOOLEAN
} value_PR;
/*** <<< TYPE-DECLS [SpecializedContent] >>> ***/
typedef struct SpecializedContent_30P0 {
long id;
struct value {
value_PR present;
union value_u {
long INTEGER;
BOOLEAN_t BOOLEAN;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} value;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} SpecializedContent_30P0_t;
/*** <<< FUNC-DECLS [SpecializedContent] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_SpecializedContent_30P0;
extern asn_SEQUENCE_specifics_t asn_SPC_SpecializedContent_30P0_specs_1;
extern asn_TYPE_member_t asn_MBR_SpecializedContent_30P0_1[2];
/*** <<< IOC-TABLES [SpecializedContent] >>> ***/
static const long asn_VAL_1_1 = 1;
static const long asn_VAL_2_2 = 2;
static const asn_ioc_cell_t asn_IOS_RegionalExtension_1_rows[] = {
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_1_1 },
{ "&Type", ,
{ "&id", aioc__value, &asn_DEF_NativeInteger, &asn_VAL_2_2 },
{ "&Type",
};
static const asn_ioc_set_t asn_IOS_RegionalExtension_1[] = {
2, 2, asn_IOS_RegionalExtension_1_rows
};
/*** <<< CODE [SpecializedContent] >>> ***/
static int
memb_id_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 asn_type_selector_result_t
select_value_type(const asn_TYPE_descriptor_t *parent_type, const void *parent_sptr) {
asn_type_selector_result_t result = {0, 0};
const asn_ioc_set_t *itable = asn_IOS_RegionalExtension_1;
size_t constraining_column = 0; /* &id */
size_t for_column = 1; /* &Type */
size_t row;
const long *constraining_value = (const long *)((const char *)parent_sptr + offsetof(struct SpecializedContent_30P0, id));
for(row=0; row < itable->rows_count; row++) {
const asn_ioc_cell_t *constraining_cell = &itable->rows[row * itable->columns_count + constraining_column];
const asn_ioc_cell_t *type_cell = &itable->rows[row * itable->columns_count + for_column];
if(constraining_cell->type_descriptor->op->compare_struct(constraining_cell->type_descriptor, constraining_value, constraining_cell->value_sptr) == 0) {
result.type_descriptor = type_cell->type_descriptor;
result.presence_index = row + 1;
break;
}
}
return result;
}
static int
memb_value_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);
}
/*** <<< CTDEFS [SpecializedContent] >>> ***/
static asn_per_constraints_t asn_PER_memb_id_constr_2 GCC_NOTUSED = {
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
static asn_per_constraints_t asn_PER_memb_value_constr_3 GCC_NOTUSED = {
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
/*** <<< STAT-DEFS [SpecializedContent] >>> ***/
static asn_TYPE_member_t asn_MBR_value_3[] = {
{ ATF_NOFLAGS, 0, offsetof(struct value, choice.INTEGER),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* No PER visible constraints */
.default_value = 0,
.name = "INTEGER"
},
{ ATF_NOFLAGS, 0, offsetof(struct value, choice.BOOLEAN),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
.tag_mode = 0,
.type = &asn_DEF_BOOLEAN,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* No PER visible constraints */
.default_value = 0,
.name = "BOOLEAN"
},
};
static const unsigned asn_MAP_value_cmap_3[] = { 1, 0 };
static const asn_TYPE_tag2member_t asn_MAP_value_tag2el_3[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 1, 0, 0 }, /* BOOLEAN */
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* INTEGER */
};
static asn_CHOICE_specifics_t asn_SPC_value_specs_3 = {
sizeof(struct value),
offsetof(struct value, _asn_ctx),
offsetof(struct value, present),
sizeof(((struct value *)0)->present),
.tag2el = asn_MAP_value_tag2el_3,
.tag2el_count = 2, /* Count of tags in the map */
.canonical_order = asn_MAP_value_cmap_3, /* Canonically sorted */
.ext_start = -1 /* Extensions start */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_value_3 = {
"value",
"value",
&asn_OP_OPEN_TYPE,
OPEN_TYPE_constraint,
0, /* No effective tags (pointer) */
0, /* No effective tags (count) */
0, /* No tags (pointer) */
0, /* No tags (count) */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_value_3,
2, /* Elements count */
&asn_SPC_value_specs_3 /* Additional specs */
};
asn_TYPE_member_t asn_MBR_SpecializedContent_30P0_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct SpecializedContent_30P0, id),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = memb_id_constraint_1,
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = &asn_PER_memb_id_constr_2,
.default_value = 0,
.name = "id"
},
{ ATF_OPEN_TYPE | ATF_NOFLAGS, 0, offsetof(struct SpecializedContent_30P0, value),
.tag = -1 /* Ambiguous tag (ANY?) */,
.tag_mode = 0,
.type = &asn_DEF_value_3,
.type_selector = select_value_type,
.memb_constraints = memb_value_constraint_1,
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = &asn_PER_memb_value_constr_3,
.default_value = 0,
.name = "value"
},
};
static const ber_tlv_tag_t asn_DEF_SpecializedContent_30P0_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_SpecializedContent_30P0_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* id */
};
asn_SEQUENCE_specifics_t asn_SPC_SpecializedContent_30P0_specs_1 = {
sizeof(struct SpecializedContent_30P0),
offsetof(struct SpecializedContent_30P0, _asn_ctx),
.tag2el = asn_MAP_SpecializedContent_30P0_tag2el_1,
.tag2el_count = 1, /* 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_SpecializedContent_30P0 = {
"SpecializedContent",
"SpecializedContent",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
asn_DEF_SpecializedContent_30P0_tags_1,
sizeof(asn_DEF_SpecializedContent_30P0_tags_1)
/sizeof(asn_DEF_SpecializedContent_30P0_tags_1[0]), /* 1 */
asn_DEF_SpecializedContent_30P0_tags_1, /* Same as above */
sizeof(asn_DEF_SpecializedContent_30P0_tags_1)
/sizeof(asn_DEF_SpecializedContent_30P0_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_SpecializedContent_30P0_1,
2, /* Elements count */
&asn_SPC_SpecializedContent_30P0_specs_1 /* Additional specs */
};
tests/tests-asn1c-compiler/147-inherit-per-constraints-OK.asn1
0 → 100644
View file @
20dc6247
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .147
ModuleInheritPERConstraints
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 147 }
DEFINITIONS ::=
BEGIN
Short ::= INTEGER (0..65535)
Alias ::= Short
Soo ::= SEQUENCE {
foo INTEGER (0..65535),
bar Short,
baz Alias
}
END
tests/tests-asn1c-compiler/147-inherit-per-constraints-OK.asn1.-Pgen-OER
0 → 100644
View file @
20dc6247
/*** <<< INCLUDES [Short] >>> ***/
#include <NativeInteger.h>
/*** <<< TYPE-DECLS [Short] >>> ***/
typedef long Short_t;
/*** <<< FUNC-DECLS [Short] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Short;
asn_struct_free_f Short_free;
asn_struct_print_f Short_print;
asn_constr_check_f Short_constraint;
ber_type_decoder_f Short_decode_ber;
der_type_encoder_f Short_encode_der;
xer_type_decoder_f Short_decode_xer;
xer_type_encoder_f Short_encode_xer;
oer_type_decoder_f Short_decode_oer;
oer_type_encoder_f Short_encode_oer;
/*** <<< CODE [Short] >>> ***/
int
Short_constraint(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;
}
}
/*
* This type is implemented using NativeInteger,
* so here we adjust the DEF accordingly.
*/
/*** <<< CTDEFS [Short] >>> ***/
static asn_oer_constraints_t asn_OER_type_Short_constr_1 GCC_NOTUSED = {
{ 2, 1 } /* (0..65535) */,
-1};
/*** <<< STAT-DEFS [Short] >>> ***/
static const ber_tlv_tag_t asn_DEF_Short_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_Short = {
"Short",
"Short",
&asn_OP_NativeInteger,
Short_constraint,
asn_DEF_Short_tags_1,
sizeof(asn_DEF_Short_tags_1)
/sizeof(asn_DEF_Short_tags_1[0]), /* 1 */
asn_DEF_Short_tags_1, /* Same as above */
sizeof(asn_DEF_Short_tags_1)
/sizeof(asn_DEF_Short_tags_1[0]), /* 1 */
&asn_OER_type_Short_constr_1,
0, /* No PER visible constraints */
0, 0, /* No members */
0 /* No specifics */
};
/*** <<< INCLUDES [Alias] >>> ***/
#include "Short.h"
/*** <<< TYPE-DECLS [Alias] >>> ***/
typedef Short_t Alias_t;
/*** <<< FUNC-DECLS [Alias] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Alias;
asn_struct_free_f Alias_free;
asn_struct_print_f Alias_print;
asn_constr_check_f Alias_constraint;
ber_type_decoder_f Alias_decode_ber;
der_type_encoder_f Alias_encode_der;
xer_type_decoder_f Alias_decode_xer;
xer_type_encoder_f Alias_encode_xer;
oer_type_decoder_f Alias_decode_oer;
oer_type_encoder_f Alias_encode_oer;
/*** <<< CODE [Alias] >>> ***/
int
Alias_constraint(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;
}
}
/*
* This type is implemented using Short,
* so here we adjust the DEF accordingly.
*/
/*** <<< STAT-DEFS [Alias] >>> ***/
static const ber_tlv_tag_t asn_DEF_Alias_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_Alias = {
"Alias",
"Alias",
&asn_OP_NativeInteger,
Alias_constraint,
asn_DEF_Alias_tags_1,
sizeof(asn_DEF_Alias_tags_1)
/sizeof(asn_DEF_Alias_tags_1[0]), /* 1 */
asn_DEF_Alias_tags_1, /* Same as above */
sizeof(asn_DEF_Alias_tags_1)
/sizeof(asn_DEF_Alias_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
0, 0, /* No members */
0 /* No specifics */
};
/*** <<< INCLUDES [Soo] >>> ***/
#include <NativeInteger.h>
#include "Short.h"
#include "Alias.h"
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Soo] >>> ***/
typedef struct Soo {
long foo;
Short_t bar;
Alias_t baz;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Soo_t;
/*** <<< FUNC-DECLS [Soo] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Soo;
/*** <<< CODE [Soo] >>> ***/
static int
memb_foo_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;
}
}
/*** <<< CTDEFS [Soo] >>> ***/
static asn_oer_constraints_t asn_OER_memb_foo_constr_2 GCC_NOTUSED = {
{ 2, 1 } /* (0..65535) */,
-1};
/*** <<< STAT-DEFS [Soo] >>> ***/
static asn_TYPE_member_t asn_MBR_Soo_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Soo, foo),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = memb_foo_constraint_1,
.oer_constraints = &asn_OER_memb_foo_constr_2,
.per_constraints = 0, /* PER is not compiled, use -gen-PER */
.default_value = 0,
.name = "foo"
},
{ ATF_NOFLAGS, 0, offsetof(struct Soo, bar),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Short,
.type_selector = 0,
.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 = "bar"
},
{ ATF_NOFLAGS, 0, offsetof(struct Soo, baz),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Alias,
.type_selector = 0,
.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 = "baz"
},
};
static const ber_tlv_tag_t asn_DEF_Soo_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Soo_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 2 }, /* foo */
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, -1, 1 }, /* bar */
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 2, -2, 0 } /* baz */
};
static asn_SEQUENCE_specifics_t asn_SPC_Soo_specs_1 = {
sizeof(struct Soo),
offsetof(struct Soo, _asn_ctx),
.tag2el = asn_MAP_Soo_tag2el_1,
.tag2el_count = 3, /* 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_Soo = {
"Soo",
"Soo",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
asn_DEF_Soo_tags_1,
sizeof(asn_DEF_Soo_tags_1)
/sizeof(asn_DEF_Soo_tags_1[0]), /* 1 */
asn_DEF_Soo_tags_1, /* Same as above */
sizeof(asn_DEF_Soo_tags_1)
/sizeof(asn_DEF_Soo_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Soo_1,
3, /* Elements count */
&asn_SPC_Soo_specs_1 /* Additional specs */
};
tests/tests-asn1c-compiler/147-inherit-per-constraints-OK.asn1.-Pgen-PER
0 → 100644
View file @
20dc6247
/*** <<< INCLUDES [Short] >>> ***/
#include <NativeInteger.h>
/*** <<< TYPE-DECLS [Short] >>> ***/
typedef long Short_t;
/*** <<< FUNC-DECLS [Short] >>> ***/
extern asn_per_constraints_t asn_PER_type_Short_constr_1;
extern asn_TYPE_descriptor_t asn_DEF_Short;
asn_struct_free_f Short_free;
asn_struct_print_f Short_print;
asn_constr_check_f Short_constraint;
ber_type_decoder_f Short_decode_ber;
der_type_encoder_f Short_encode_der;
xer_type_decoder_f Short_decode_xer;
xer_type_encoder_f Short_encode_xer;
per_type_decoder_f Short_decode_uper;
per_type_encoder_f Short_encode_uper;
/*** <<< CODE [Short] >>> ***/
int
Short_constraint(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;
}
}
/*
* This type is implemented using NativeInteger,
* so here we adjust the DEF accordingly.
*/
/*** <<< CTDEFS [Short] >>> ***/
asn_per_constraints_t asn_PER_type_Short_constr_1 GCC_NOTUSED = {
{ APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
/*** <<< STAT-DEFS [Short] >>> ***/
static const ber_tlv_tag_t asn_DEF_Short_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_Short = {
"Short",
"Short",
&asn_OP_NativeInteger,
Short_constraint,
asn_DEF_Short_tags_1,
sizeof(asn_DEF_Short_tags_1)
/sizeof(asn_DEF_Short_tags_1[0]), /* 1 */
asn_DEF_Short_tags_1, /* Same as above */
sizeof(asn_DEF_Short_tags_1)
/sizeof(asn_DEF_Short_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
&asn_PER_type_Short_constr_1,
0, 0, /* No members */
0 /* No specifics */
};
/*** <<< INCLUDES [Alias] >>> ***/
#include "Short.h"
/*** <<< TYPE-DECLS [Alias] >>> ***/
typedef Short_t Alias_t;
/*** <<< FUNC-DECLS [Alias] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Alias;
asn_struct_free_f Alias_free;
asn_struct_print_f Alias_print;
asn_constr_check_f Alias_constraint;
ber_type_decoder_f Alias_decode_ber;
der_type_encoder_f Alias_encode_der;
xer_type_decoder_f Alias_decode_xer;
xer_type_encoder_f Alias_encode_xer;
per_type_decoder_f Alias_decode_uper;
per_type_encoder_f Alias_encode_uper;
/*** <<< CODE [Alias] >>> ***/
int
Alias_constraint(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;
}
}
/*
* This type is implemented using Short,
* so here we adjust the DEF accordingly.
*/
/*** <<< STAT-DEFS [Alias] >>> ***/
static const ber_tlv_tag_t asn_DEF_Alias_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_Alias = {
"Alias",
"Alias",
&asn_OP_NativeInteger,
Alias_constraint,
asn_DEF_Alias_tags_1,
sizeof(asn_DEF_Alias_tags_1)
/sizeof(asn_DEF_Alias_tags_1[0]), /* 1 */
asn_DEF_Alias_tags_1, /* Same as above */
sizeof(asn_DEF_Alias_tags_1)
/sizeof(asn_DEF_Alias_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
0, 0, /* No members */
0 /* No specifics */
};
/*** <<< INCLUDES [Soo] >>> ***/
#include <NativeInteger.h>
#include "Short.h"
#include "Alias.h"
#include <constr_SEQUENCE.h>
/*** <<< TYPE-DECLS [Soo] >>> ***/
typedef struct Soo {
long foo;
Short_t bar;
Alias_t baz;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} Soo_t;
/*** <<< FUNC-DECLS [Soo] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_Soo;
/*** <<< CODE [Soo] >>> ***/
static int
memb_foo_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;
}
}
/*** <<< CTDEFS [Soo] >>> ***/
static asn_per_constraints_t asn_PER_memb_foo_constr_2 GCC_NOTUSED = {
{ APC_CONSTRAINED, 16, 16, 0, 65535 } /* (0..65535) */,
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
0, 0 /* No PER value map */
};
/*** <<< STAT-DEFS [Soo] >>> ***/
static asn_TYPE_member_t asn_MBR_Soo_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct Soo, foo),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_NativeInteger,
.type_selector = 0,
.memb_constraints = memb_foo_constraint_1,
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = &asn_PER_memb_foo_constr_2,
.default_value = 0,
.name = "foo"
},
{ ATF_NOFLAGS, 0, offsetof(struct Soo, bar),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Short,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* No PER visible constraints */
.default_value = 0,
.name = "bar"
},
{ ATF_NOFLAGS, 0, offsetof(struct Soo, baz),
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
.tag_mode = 0,
.type = &asn_DEF_Alias,
.type_selector = 0,
.memb_constraints = 0, /* Defer constraints checking to the member type */
.oer_constraints = 0, /* OER is not compiled, use -gen-OER */
.per_constraints = 0, /* No PER visible constraints */
.default_value = 0,
.name = "baz"
},
};
static const ber_tlv_tag_t asn_DEF_Soo_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_Soo_tag2el_1[] = {
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 2 }, /* foo */
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, -1, 1 }, /* bar */
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 2, -2, 0 } /* baz */
};
static asn_SEQUENCE_specifics_t asn_SPC_Soo_specs_1 = {
sizeof(struct Soo),
offsetof(struct Soo, _asn_ctx),
.tag2el = asn_MAP_Soo_tag2el_1,
.tag2el_count = 3, /* 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_Soo = {
"Soo",
"Soo",
&asn_OP_SEQUENCE,
SEQUENCE_constraint,
asn_DEF_Soo_tags_1,
sizeof(asn_DEF_Soo_tags_1)
/sizeof(asn_DEF_Soo_tags_1[0]), /* 1 */
asn_DEF_Soo_tags_1, /* Same as above */
sizeof(asn_DEF_Soo_tags_1)
/sizeof(asn_DEF_Soo_tags_1[0]), /* 1 */
0, /* No OER visible constraints */
0, /* No PER visible constraints */
asn_MBR_Soo_1,
3, /* Elements count */
&asn_SPC_Soo_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