Commit 5432bee1 authored by Cedric Roux's avatar Cedric Roux
Browse files

apply patch OPENAIR_DIR/openair3/S1AP/MESSAGES/ASN1/asn1cpatch.p0

parent f65e9377
......@@ -111,6 +111,8 @@ main(int ac, char **av) {
asn1_compiler_flags &= ~A1C_LINK_SKELETONS;
} else if(strcmp(optarg, "link-skeletons") == 0) {
asn1_compiler_flags |= A1C_LINK_SKELETONS;
} else if(strcmp(optarg, "have_native64") == 0) {
asn1_compiler_flags |= A1C_HAVE_NATIVE_64;
} else {
fprintf(stderr, "-f%s: Invalid argument\n", optarg);
exit(EX_USAGE);
......@@ -471,6 +473,7 @@ usage(const char *av0) {
" -fno-include-deps Do not generate courtesy #includes for dependencies\n"
" -funnamed-unions Enable unnamed unions in structures\n"
" -fwide-types Use INTEGER_t instead of \"long\" by default, etc.\n"
" -fhave_native64 Use int64_t/uint64_t for target platform\n"
"\n"
" -gen-PER Generate PER support code\n"
......
......@@ -775,4 +775,8 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *ctx, asn_TYPE_descripto
asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void *sptr, asn_per_outp_t *po) { asn_enc_rval_t er = { 0, 0, 0 }; (void)td; (void)cts; (void)sptr; (void)po; return er; }
asn_dec_rval_t OCTET_STRING_decode_aper(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void **sptr, asn_per_data_t *pd) { asn_dec_rval_t rv = { 0, 0 }; (void)ctx; (void)td; (void)cts; (void)sptr; (void)pd; return rv; }
asn_enc_rval_t OCTET_STRING_encode_aper(asn_TYPE_descriptor_t *td, asn_per_constraints_t *cts, void *sptr, asn_per_outp_t *po) { asn_enc_rval_t er = { 0, 0, 0 }; (void)td; (void)cts; (void)sptr; (void)po; return er; }
size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size) { (void)chunk_buf; (void)chunk_size; return 0; }
......@@ -25,6 +25,8 @@ This directory contains a few examples.
UserPlane Location Protocol decoder. Before trying to compile, read the
README file in that directory.
The clyx2asn1.pl script can be used to extract ASN.1 data from LyX editor files.
The crfc2asn1.pl script can be used to extract ASN.1 data from RFC texts.
For instance, it is used to extract X.509, MEGACO, and LDAPv3 ASN.1 modules
from the corresponding RFC texts (rfc3280.txt, rfc3525.txt, rfc4211.txt).
......
......@@ -1242,6 +1242,8 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("td->xer_encoder = asn_DEF_%s.xer_encoder;\n", type_name);
OUT("td->uper_decoder = asn_DEF_%s.uper_decoder;\n", type_name);
OUT("td->uper_encoder = asn_DEF_%s.uper_encoder;\n", type_name);
OUT("td->aper_decoder = asn_DEF_%s.aper_decoder;\n", type_name);
OUT("td->aper_encoder = asn_DEF_%s.aper_encoder;\n", type_name);
if(!terminal && !tags_count) {
OUT("/* The next four lines are here because of -fknown-extern-type */\n");
OUT("td->tags = asn_DEF_%s.tags;\n", type_name);
......@@ -1394,6 +1396,38 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
);
OUT("}\n");
OUT("\n");
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("asn_enc_rval_t\n");
OUT("%s", p);
if(HIDE_INNER_DEFS) OUT("_%d", expr->_type_unique_index);
OUT("_encode_aper(asn_TYPE_descriptor_t *td,\n");
INDENTED(
OUT("\tasn_per_constraints_t *constraints,\n");
OUT("\tvoid *structure, asn_per_outp_t *per_out) {\n");
OUT("%s_%d_inherit_TYPE_descriptor(td);\n",
p, expr->_type_unique_index);
OUT("return td->aper_encoder(td, constraints, structure, per_out);\n");
);
OUT("}\n");
OUT("\n");
p = MKID(expr);
if(HIDE_INNER_DEFS) OUT("static ");
OUT("asn_dec_rval_t\n");
OUT("%s", p);
if(HIDE_INNER_DEFS) OUT("_%d", expr->_type_unique_index);
OUT("_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,\n");
INDENTED(
OUT("\tasn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) {\n");
OUT("%s_%d_inherit_TYPE_descriptor(td);\n",
p, expr->_type_unique_index);
OUT("return td->aper_decoder(opt_codec_ctx, td, constraints, structure, per_data);\n");
);
OUT("}\n");
OUT("\n");
}
REDIR(OT_FUNC_DECLS);
......@@ -1415,6 +1449,8 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
if(arg->flags & A1C_GEN_PER) {
OUT("per_type_decoder_f %s_decode_uper;\n", p);
OUT("per_type_encoder_f %s_encode_uper;\n", p);
OUT("per_type_decoder_f %s_decode_aper;\n", p);
OUT("per_type_encoder_f %s_encode_aper;\n", p);
}
}
......@@ -1670,12 +1706,11 @@ emit_tag2member_map(arg_t *arg, tag2el_t *tag2el, int tag2el_count, const char *
OUT("%d, ", tag2el[i].el_no);
OUT("%d, ", tag2el[i].toff_first);
OUT("%d ", tag2el[i].toff_last);
OUT("}%s /* %s",
OUT("}%s /* %s at %d */\n",
(i + 1 < tag2el_count) ? "," : "",
tag2el[i].from_expr->Identifier);
if(arg->flags & A1C_LINE_REFS)
OUT("at %d", tag2el[i].from_expr->_lineno);
OUT(" */\n");
tag2el[i].from_expr->Identifier,
tag2el[i].from_expr->_lineno
);
}
OUT("};\n");
......@@ -2111,19 +2146,22 @@ static int
try_inline_default(arg_t *arg, asn1p_expr_t *expr, int out) {
int save_target = arg->target->target;
asn1p_expr_type_e etype = expr_get_type(arg, expr);
int fits_long = 0;
// int fits_long = 0;
enum asn1c_fitslong_e fits = FL_NOTFIT;
switch(etype) {
case ASN_BASIC_BOOLEAN:
fits_long = 1;
// fits_long = 1;
fits = FL_FITS_SIGNED;
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
if(expr->marker.default_value == NULL
|| expr->marker.default_value->type != ATV_INTEGER)
break;
if(!fits_long)
fits_long = asn1c_type_fits_long(arg, expr)!=FL_NOTFIT;
if(fits_long && !expr->marker.default_value->value.v_integer)
if(fits == FL_NOTFIT)
// fits_long = asn1c_type_fits_long(arg, expr)!=FL_NOTFIT;
fits = asn1c_type_fits_long(arg, expr);
if(fits != FL_NOTFIT && !expr->marker.default_value->value.v_integer)
expr->marker.flags &= ~EM_INDIRECT;
if(!out) {
OUT("asn_DFL_%d_set_%" PRIdASN
......@@ -2150,7 +2188,7 @@ try_inline_default(arg_t *arg, asn1p_expr_t *expr, int out) {
INDENT(+1);
OUT("/* Install default value %" PRIdASN " */\n",
expr->marker.default_value->value.v_integer);
if(fits_long) {
if(fits != FL_NOTFIT) {
OUT("*st = ");
OINT(expr->marker.default_value->value.v_integer);
OUT(";\n");
......@@ -2165,7 +2203,7 @@ try_inline_default(arg_t *arg, asn1p_expr_t *expr, int out) {
INDENT(+1);
OUT("/* Test default value %" PRIdASN " */\n",
expr->marker.default_value->value.v_integer);
if(fits_long) {
if(fits != FL_NOTFIT) {
OUT("return (*st == %" PRIdASN ");\n",
expr->marker.default_value->value.v_integer);
} else {
......@@ -2455,8 +2493,12 @@ emit_type_DEF(arg_t *arg, asn1p_expr_t *expr, enum tvm_compat tv_mode, int tags_
if(arg->flags & A1C_GEN_PER) {
FUNCREF(decode_uper);
FUNCREF(encode_uper);
FUNCREF(decode_aper);
FUNCREF(encode_aper);
} else {
OUT("0, 0,\t/* No PER support, "
OUT("0, 0,\t/* No UPER support, "
"use \"-gen-PER\" to enable */\n");
OUT("0, 0,\t/* No APER support, "
"use \"-gen-PER\" to enable */\n");
}
......
......@@ -35,6 +35,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
int alphabet_table_compiled;
int produce_st = 0;
int ulong_optimize = 0;
enum asn1c_fitslong_e fits = FL_NOTFIT;
ct = expr->combined_constraints;
if(ct == NULL)
......@@ -74,7 +75,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
switch(etype) {
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
if(asn1c_type_fits_long(arg, arg->expr) == FL_NOTFIT)
fits = asn1c_type_fits_long(arg, arg->expr);
if(fits == FL_NOTFIT)
produce_st = 1;
break;
case ASN_BASIC_REAL:
......@@ -103,13 +105,19 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
switch(etype) {
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
if(native_long_sign(r_value) >= 0) {
ulong_optimize = ulong_optimization(etype, r_size, r_value);
if(!ulong_optimize) {
OUT("unsigned long value;\n");
}
if(fits == FL_FITS_INT64) {
OUT("int64_t value;\n");
} else if(fits == FL_FITS_UINT64) {
OUT("uint64_t value;\n");
} else {
OUT("long value;\n");
if(native_long_sign(r_value) >= 0) {
ulong_optimize = ulong_optimization(etype, r_size, r_value);
if(!ulong_optimize) {
OUT("unsigned long value;\n");
}
} else {
OUT("long value;\n");
}
}
break;
case ASN_BASIC_REAL:
......@@ -603,13 +611,19 @@ emit_size_determination_code(arg_t *arg, asn1p_expr_type_e etype) {
static int
emit_value_determination_code(arg_t *arg, asn1p_expr_type_e etype, asn1cnst_range_t *r_value) {
enum asn1c_fitslong_e fits = FL_NOTFIT;
switch(etype) {
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
if(asn1c_type_fits_long(arg, arg->expr) == FL_FITS_UNSIGN) {
fits = asn1c_type_fits_long(arg, arg->expr);
if(fits == FL_FITS_INT64) {
OUT("value = *(const int64_t *)sptr;\n");
} else if(fits == FL_FITS_UINT64) {
OUT("value = *(const uint64_t *)sptr;\n");
} else if(fits == FL_FITS_UNSIGN) {
OUT("value = *(const unsigned long *)sptr;\n");
} else if(asn1c_type_fits_long(arg, arg->expr) != FL_NOTFIT) {
} else if(fits != FL_NOTFIT) {
OUT("value = *(const long *)sptr;\n");
} else {
/*
......
......@@ -158,6 +158,7 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
asn1p_expr_t *terminal;
int stdname = 0;
char *typename;
enum asn1c_fitslong_e fits;
/* Rewind to the topmost parent expression */
if((top_parent = expr->parent_expr))
......@@ -213,15 +214,20 @@ asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) {
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
case ASN_BASIC_REAL:
fits = asn1c_type_fits_long(arg, expr);
if((expr->expr_type == ASN_BASIC_REAL
&& !(arg->flags & A1C_USE_WIDE_TYPES))
|| asn1c_type_fits_long(arg, expr)) {
|| (fits != FL_NOTFIT)) {
switch(_format) {
case TNF_CTYPE:
case TNF_RSAFE:
if(expr->expr_type == ASN_BASIC_REAL)
return "double";
else if(asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN)
else if (fits == FL_FITS_INT64)
return "int64_t";
else if (fits == FL_FITS_UINT64)
return "uint64_t";
else if(fits == FL_FITS_UNSIGN)
return "unsigned long";
else
return "long";
......@@ -377,11 +383,33 @@ asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr) {
/* Special case for unsigned */
if(left.type == ARE_VALUE
&& left.value >= 0
&& right.type == ARE_VALUE
&& right.type == ARE_VALUE
&& right.value > 2147483647
&& right.value <= 4294967295UL)
return FL_FITS_UNSIGN;
/* Special for native 64 bits integer option */
if (arg->flags & A1C_HAVE_NATIVE_64) {
// printf("left.value %lld right.value %lld\n", left.value, right.value);
if(left.type == ARE_VALUE
&& left.value >= 0
&& right.type == ARE_VALUE
&& right.value > 9223372036854775807LL
&& right.value <= 18446744073709551615ULL)
return FL_FITS_UINT64;
if(left.type == ARE_VALUE
&& left.value < -2147483648
&& left.value >= -9223372036854775808LL
&& right.type == ARE_VALUE
&& right.value > 2147483647
&& right.value <= 9223372036854775807LL)
return FL_FITS_INT64;
if(left.type == ARE_VALUE
&& left.value >= 0
&& right.type == ARE_VALUE
&& right.value > 4294967295UL
&& right.value <= 9223372036854775807LL)
return FL_FITS_INT64;
}
/* If some fixed value is outside of target range, not fit */
if(left.type == ARE_VALUE
......
......@@ -36,6 +36,8 @@ char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format);
*/
enum asn1c_fitslong_e {
FL_NOTFIT,
FL_FITS_INT64,
FL_FITS_UINT64,
FL_FITS_SIGNED,
FL_FITS_UNSIGN,
FL_PRESUMED,
......
......@@ -117,16 +117,24 @@ int asn1c_compiled_output(arg_t *arg, const char *fmt, ...);
* Format LONG_MIN according to C90 rules.
*/
#define OINT(iv) do { \
if(iv == (-2147483647L - 1)) \
if(iv > 4294967295U) \
OUT("%" PRIdASN"ULL", iv); \
else if(iv > 2147483647L) \
OUT("%" PRIdASN"U", iv); \
else if(iv == (-2147483647L - 1)) \
OUT("(-2147483647L - 1)"); \
else \
else \
OUT("%" PRIdASN, iv); \
} while(0)
#define OINTS(iv) do { \
if(iv == (-2147483647L - 1)) \
if(iv > 4294967295U) \
OUT("%" PRIdASN"ULL", iv); \
else if(iv > 2147483647L) \
OUT("%" PRIdASN"U", iv); \
else if(iv == (-2147483647L - 1)) \
OUT("(-2147483647L - 1)"); \
else \
else \
OUT("% " PRIdASN, iv); \
} while(0)
......
......@@ -77,7 +77,14 @@ enum asn1c_flags {
* -fline-refs
* Include ASN.1 module's line numbers in comments.
*/
A1C_LINE_REFS = 0x20000
A1C_LINE_REFS = 0x20000,
/*
* -fhave_native64
* Assume target platform has native 64bits support and generate types using
* int64_t or uint64_t whereas possible
*/
A1C_HAVE_NATIVE_64 = 0x40000
};
/*
......
......@@ -21,7 +21,10 @@ asn_TYPE_descriptor_t asn_DEF_ANY = {
OCTET_STRING_encode_der,
OCTET_STRING_decode_xer_hex,
ANY_encode_xer,
0, 0,
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
0, /* Use generic outmost tag fetcher */
0, 0, 0, 0,
0, /* No PER visible constraints */
......@@ -87,6 +90,37 @@ ANY_fromType(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr) {
return 0;
}
int
ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr) {
uint8_t *buffer = NULL;
ssize_t erval;
if(!st || !td) {
errno = EINVAL;
return -1;
}
if(!sptr) {
if(st->buf) FREEMEM(st->buf);
st->size = 0;
return 0;
}
erval = aper_encode_to_new_buffer(td, td->per_constraints, sptr, (void**)&buffer);
if(erval == -1) {
if(buffer) FREEMEM(buffer);
return -1;
}
assert((size_t)erval > 0);
if(st->buf) FREEMEM(st->buf);
st->buf = buffer;
st->size = erval;
return 0;
}
ANY_t *
ANY_new_fromType(asn_TYPE_descriptor_t *td, void *sptr) {
ANY_t tmp;
......@@ -111,6 +145,30 @@ ANY_new_fromType(asn_TYPE_descriptor_t *td, void *sptr) {
}
}
ANY_t *
ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr) {
ANY_t tmp;
ANY_t *st;
if(!td || !sptr) {
errno = EINVAL;
return 0;
}
memset(&tmp, 0, sizeof(tmp));
if(ANY_fromType_aper(&tmp, td, sptr)) return 0;
st = (ANY_t *)CALLOC(1, sizeof(ANY_t));
if(st) {
*st = tmp;
return st;
} else {
FREEMEM(tmp.buf);
return 0;
}
}
int
ANY_to_type(ANY_t *st, asn_TYPE_descriptor_t *td, void **struct_ptr) {
asn_dec_rval_t rval;
......@@ -138,6 +196,33 @@ ANY_to_type(ANY_t *st, asn_TYPE_descriptor_t *td, void **struct_ptr) {
}
}
int
ANY_to_type_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void **struct_ptr) {
asn_dec_rval_t rval;
void *newst = 0;
if(!st || !td || !struct_ptr) {
errno = EINVAL;
return -1;
}
if(st->buf == 0) {
/* Nothing to convert, make it empty. */
*struct_ptr = (void *)0;
return 0;
}
rval = aper_decode(0, td, (void **)&newst, st->buf, st->size, 0, 0);
if(rval.code == RC_OK) {
*struct_ptr = newst;
return 0;
} else {
/* Remove possibly partially decoded data. */
ASN_STRUCT_FREE(*td, newst);
return -1;
}
}
static int ANY__consume_bytes(const void *buffer, size_t size, void *key) {
struct _callback_arg *arg = (struct _callback_arg *)key;
......
......@@ -32,10 +32,13 @@ xer_type_encoder_f ANY_encode_xer;
/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
int ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr);
ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
ANY_t *ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr);
/* Convert the contents of the ANY type into the specified type. */
int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
int ANY_to_type_aper(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \
......
......@@ -29,6 +29,8 @@ asn_TYPE_descriptor_t asn_DEF_BIT_STRING = {
BIT_STRING_encode_xer,
OCTET_STRING_decode_uper, /* Unaligned PER decoder */
OCTET_STRING_encode_uper, /* Unaligned PER encoder */
OCTET_STRING_decode_aper, /* Aligned PER decoder */
OCTET_STRING_encode_aper, /* Aligned PER encoder */
0, /* Use generic outmost tag fetcher */
asn_DEF_BIT_STRING_tags,
sizeof(asn_DEF_BIT_STRING_tags)
......
......@@ -35,6 +35,8 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
BMPString_encode_xer, /* Convert to UTF-8 */
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper, /* Aligned PER decoder */
OCTET_STRING_encode_aper, /* Aligned PER encoder */
0, /* Use generic outmost tag fetcher */
asn_DEF_BMPString_tags,
sizeof(asn_DEF_BMPString_tags)
......
......@@ -24,6 +24,8 @@ asn_TYPE_descriptor_t asn_DEF_BOOLEAN = {
BOOLEAN_encode_xer,
BOOLEAN_decode_uper, /* Unaligned PER decoder */
BOOLEAN_encode_uper, /* Unaligned PER encoder */
BOOLEAN_decode_aper, /* Aligned PER decoder */
BOOLEAN_encode_aper, /* Aligned PER encoder */
0, /* Use generic outmost tag fetcher */
asn_DEF_BOOLEAN_tags,
sizeof(asn_DEF_BOOLEAN_tags) / sizeof(asn_DEF_BOOLEAN_tags[0]),
......@@ -264,6 +266,35 @@ BOOLEAN_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
return rv;
}
asn_dec_rval_t
BOOLEAN_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rv;
BOOLEAN_t *st = (BOOLEAN_t *)*sptr;
(void)opt_codec_ctx;
(void)constraints;
if(!st) {
st = (BOOLEAN_t *)(*sptr = MALLOC(sizeof(*st)));
if(!st) _ASN_DECODE_FAILED;
}
/*
* Extract a single bit
*/
switch(per_get_few_bits(pd, 1)) {
case 1: *st = 1; break;
case 0: *st = 0; break;
case -1: default: _ASN_DECODE_STARVED;
}
ASN_DEBUG("%s decoded as %s", td->name, *st ? "TRUE" : "FALSE");
rv.code = RC_OK;
rv.consumed = 1;
return rv;
}
asn_enc_rval_t
BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
......@@ -280,3 +311,18 @@ BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
_ASN_ENCODED_OK(er);
}
asn_enc_rval_t
BOOLEAN_encode_aper(asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) {
const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
asn_enc_rval_t er;
(void)constraints;
if(!st) _ASN_ENCODE_FAILED;
per_put_few_bits(po, *st ? 1 : 0, 1);
_ASN_ENCODED_OK(er);
}
......@@ -28,6 +28,8 @@ xer_type_decoder_f BOOLEAN_decode_xer;
xer_type_encoder_f BOOLEAN_encode_xer;
per_type_decoder_f BOOLEAN_decode_uper;
per_type_encoder_f BOOLEAN_encode_uper;
per_type_decoder_f BOOLEAN_decode_aper;
per_type_encoder_f BOOLEAN_encode_aper;
#ifdef __cplusplus
}
......
......@@ -26,6 +26,8 @@ asn_TYPE_descriptor_t asn_DEF_ENUMERATED = {
INTEGER_encode_xer,
ENUMERATED_decode_uper, /* Unaligned PER decoder */
ENUMERATED_encode_uper, /* Unaligned PER encoder */
ENUMERATED_decode_aper, /* Aligned PER decoder */
ENUMERATED_encode_aper, /* Aligned PER encoder */
0, /* Use generic outmost tag fetcher */
asn_DEF_ENUMERATED_tags,
sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]),
......@@ -57,6 +59,27 @@ ENUMERATED_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td
return rval;
}
asn_dec_rval_t
ENUMERATED_decode_aper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rval;
ENUMERATED_t *st = (ENUMERATED_t *)*sptr;
long value;
void *vptr = &value;
if(!st) {
st = (ENUMERATED_t *)(*sptr = CALLOC(1, sizeof(*st)));
if(!st) _ASN_DECODE_FAILED;
}
rval = NativeEnumerated_decode_aper(opt_codec_ctx, td, constraints,
(void **)&vptr, pd);
if(rval.code == RC_OK)
if(asn_long2INTEGER(st, value))
rval.code = RC_FAIL;
return rval;
}
asn_enc_rval_t