asn1c/tests/136-oer-long-OK.asn1.-Pgen-OER

581 lines
17 KiB
Plaintext

/*** <<< 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 */
};