Commit 2a5ea088 authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Merge APER implementation from mouse07410's repository

parent 34df4e57
......@@ -1433,12 +1433,14 @@ asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) {
OUT("xer_type_decoder_f %s_decode_xer;\n", p);
OUT("xer_type_encoder_f %s_encode_xer;\n", p);
if(arg->flags & A1C_GEN_OER) {
OUT("oer_type_decoder_f %s_decode_oer;\n", p);
OUT("oer_type_encoder_f %s_encode_oer;\n", p);
OUT("oer_type_decoder_f %s_decode_oer;\n", p);
OUT("oer_type_encoder_f %s_encode_oer;\n", p);
}
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_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);
}
}
......
......@@ -27,10 +27,12 @@ asn_TYPE_operation_t asn_OP_ANY = {
0,
#endif /* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
0, 0,
0, 0, 0, 0,
#else
ANY_decode_uper,
ANY_encode_uper,
ANY_decode_aper,
ANY_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
0, /* Random fill is not defined for ANY type */
0 /* Use generic outmost tag fetcher */
......
......@@ -29,6 +29,8 @@ der_type_encoder_f ANY_encode_der;
xer_type_encoder_f ANY_encode_xer;
per_type_decoder_f ANY_decode_uper;
per_type_encoder_f ANY_encode_uper;
per_type_decoder_f ANY_decode_aper;
per_type_encoder_f ANY_encode_aper;
#define ANY_free OCTET_STRING_free
#define ANY_print OCTET_STRING_print
......
......@@ -35,9 +35,13 @@ asn_TYPE_operation_t asn_OP_BIT_STRING = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
BIT_STRING_decode_uper, /* Unaligned PER decoder */
BIT_STRING_encode_uper, /* Unaligned PER encoder */
OCTET_STRING_decode_aper, /* Aligned PER decoder */
OCTET_STRING_encode_aper, /* Aligned PER encoder */
#endif /* ASN_DISABLE_PER_SUPPORT */
BIT_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -38,6 +38,8 @@ asn_random_fill_f BIT_STRING_random_fill;
#define BIT_STRING_decode_ber OCTET_STRING_decode_ber
#define BIT_STRING_encode_der OCTET_STRING_encode_der
#define BIT_STRING_decode_xer OCTET_STRING_decode_xer_binary
#define BIT_STRING_decode_aper OCTET_STRING_decode_aper
#define BIT_STRING_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -41,9 +41,13 @@ asn_TYPE_operation_t asn_OP_BMPString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -29,6 +29,8 @@ xer_type_encoder_f BMPString_encode_xer;
#define BMPString_encode_der OCTET_STRING_encode_der
#define BMPString_decode_uper OCTET_STRING_decode_uper
#define BMPString_encode_uper OCTET_STRING_encode_uper
#define BMPString_decode_aper OCTET_STRING_decode_aper
#define BMPString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -30,9 +30,13 @@ asn_TYPE_operation_t asn_OP_BOOLEAN = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
BOOLEAN_decode_uper, /* Unaligned PER decoder */
BOOLEAN_encode_uper, /* Unaligned PER encoder */
BOOLEAN_decode_aper, /* Aligned PER decoder */
BOOLEAN_encode_aper, /* Aligned PER encoder */
#endif /* ASN_DISABLE_PER_SUPPORT */
BOOLEAN_random_fill,
0 /* Use generic outmost tag fetcher */
......@@ -310,6 +314,59 @@ BOOLEAN_encode_uper(const asn_TYPE_descriptor_t *td,
ASN__ENCODED_OK(er);
}
asn_dec_rval_t
BOOLEAN_decode_aper(const asn_codec_ctx_t *opt_codec_ctx, const asn_TYPE_descriptor_t *td,
const 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;
(void)td;
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_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const 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);
}
#endif /* ASN_DISABLE_PER_SUPPORT */
#ifndef ASN_DISABLE_OER_SUPPORT
......
......@@ -30,6 +30,8 @@ oer_type_decoder_f BOOLEAN_decode_oer;
oer_type_encoder_f BOOLEAN_encode_oer;
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;
xer_type_decoder_f BOOLEAN_decode_xer;
xer_type_encoder_f BOOLEAN_encode_xer;
asn_random_fill_f BOOLEAN_random_fill;
......
......@@ -20,7 +20,7 @@ asn_TYPE_operation_t asn_OP_ENUMERATED = {
INTEGER_compare, /* Implemented in terms of INTEGER */
ber_decode_primitive,
INTEGER_encode_der, /* Implemented in terms of INTEGER */
INTEGER_decode_xer, /* This is temporary! */
INTEGER_decode_xer, /* This is temporary! */
INTEGER_encode_xer,
#ifdef ASN_DISABLE_OER_SUPPORT
0,
......@@ -32,9 +32,13 @@ asn_TYPE_operation_t asn_OP_ENUMERATED = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
ENUMERATED_decode_uper, /* Unaligned PER decoder */
ENUMERATED_encode_uper, /* Unaligned PER encoder */
ENUMERATED_decode_uper, /* Unaligned PER decoder */
ENUMERATED_encode_uper, /* Unaligned PER encoder */
ENUMERATED_decode_aper, /* Aligned PER decoder */
ENUMERATED_encode_aper, /* Aligned PER encoder */
#endif /* ASN_DISABLE_PER_SUPPORT */
ENUMERATED_random_fill,
0 /* Use generic outmost tag fetcher */
......@@ -138,4 +142,39 @@ ENUMERATED_encode_uper(const asn_TYPE_descriptor_t *td,
return NativeEnumerated_encode_uper(td, constraints, &value, po);
}
asn_dec_rval_t
ENUMERATED_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const 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
ENUMERATED_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const ENUMERATED_t *st = (const ENUMERATED_t *)sptr;
long value;
if(asn_INTEGER2long(st, &value))
ASN__ENCODE_FAILED;
return NativeEnumerated_encode_aper(td, constraints, &value, po);
}
#endif /* ASN_DISABLE_PER_SUPPORT */
......@@ -20,6 +20,8 @@ oer_type_decoder_f ENUMERATED_decode_oer;
oer_type_encoder_f ENUMERATED_encode_oer;
per_type_decoder_f ENUMERATED_decode_uper;
per_type_encoder_f ENUMERATED_encode_uper;
per_type_decoder_f ENUMERATED_decode_aper;
per_type_encoder_f ENUMERATED_encode_aper;
#define ENUMERATED_free ASN__PRIMITIVE_TYPE_free
#define ENUMERATED_print INTEGER_print
......
......@@ -30,9 +30,13 @@ asn_TYPE_operation_t asn_OP_GeneralString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -26,6 +26,8 @@ extern asn_TYPE_operation_t asn_OP_GeneralString;
#define GeneralString_encode_xer OCTET_STRING_encode_xer
#define GeneralString_decode_uper OCTET_STRING_decode_uper
#define GeneralString_encode_uper OCTET_STRING_encode_uper
#define GeneralString_decode_aper OCTET_STRING_decode_aper
#define GeneralString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -191,9 +191,13 @@ asn_TYPE_operation_t asn_OP_GeneralizedTime = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
GeneralizedTime_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -28,6 +28,8 @@ asn_random_fill_f GeneralizedTime_random_fill;
#define GeneralizedTime_decode_xer OCTET_STRING_decode_xer_utf8
#define GeneralizedTime_decode_uper OCTET_STRING_decode_uper
#define GeneralizedTime_encode_uper OCTET_STRING_encode_uper
#define GeneralizedTime_decode_aper OCTET_STRING_decode_aper
#define GeneralizedTime_encode_aper OCTET_STRING_encode_aper
/***********************
* Some handy helpers. *
......
......@@ -30,9 +30,13 @@ asn_TYPE_operation_t asn_OP_GraphicString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -26,6 +26,8 @@ extern asn_TYPE_operation_t asn_OP_GraphicString;
#define GraphicString_encode_xer OCTET_STRING_encode_xer
#define GraphicString_decode_uper OCTET_STRING_decode_uper
#define GraphicString_encode_uper OCTET_STRING_encode_uper
#define GraphicString_decode_aper OCTET_STRING_decode_aper
#define GraphicString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -35,9 +35,13 @@ asn_TYPE_operation_t asn_OP_IA5String = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -30,6 +30,8 @@ asn_constr_check_f IA5String_constraint;
#define IA5String_encode_xer OCTET_STRING_encode_xer_utf8
#define IA5String_decode_uper OCTET_STRING_decode_uper
#define IA5String_encode_uper OCTET_STRING_encode_uper
#define IA5String_decode_aper OCTET_STRING_decode_aper
#define IA5String_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
This diff is collapsed.
......@@ -47,6 +47,8 @@ oer_type_decoder_f INTEGER_decode_oer;
oer_type_encoder_f INTEGER_encode_oer;
per_type_decoder_f INTEGER_decode_uper;
per_type_encoder_f INTEGER_encode_uper;
per_type_decoder_f INTEGER_decode_aper;
per_type_encoder_f INTEGER_encode_aper;
asn_random_fill_f INTEGER_random_fill;
/***********************************
......@@ -73,6 +75,8 @@ int asn_INTEGER2long(const INTEGER_t *i, long *l);
int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
int asn_long2INTEGER(INTEGER_t *i, long l);
int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
int asn_int642INTEGER(INTEGER_t *i, int64_t l);
int asn_uint642INTEGER(INTEGER_t *i, uint64_t l);
/* A version of strtol/strtoimax(3) with nicer error reporting. */
enum asn_strtox_result_e {
......
......@@ -35,9 +35,13 @@ asn_TYPE_operation_t asn_OP_ISO646String = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -27,6 +27,8 @@ extern asn_TYPE_operation_t asn_OP_ISO646String;
#define ISO646String_encode_xer OCTET_STRING_encode_xer_utf8
#define ISO646String_decode_uper OCTET_STRING_decode_uper
#define ISO646String_encode_uper OCTET_STRING_encode_uper
#define ISO646String_decode_aper OCTET_STRING_decode_aper
#define ISO646String_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -31,9 +31,13 @@ asn_TYPE_operation_t asn_OP_NULL = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
NULL_decode_uper, /* Unaligned PER decoder */
NULL_encode_uper, /* Unaligned PER encoder */
NULL_decode_aper, /* Aligned PER decoder */
NULL_encode_aper, /* Aligned PER encoder */
#endif /* ASN_DISABLE_PER_SUPPORT */
NULL_random_fill,
0 /* Use generic outmost tag fetcher */
......@@ -222,6 +226,51 @@ NULL_encode_uper(const asn_TYPE_descriptor_t *td,
ASN__ENCODED_OK(er);
}
asn_dec_rval_t
NULL_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rv;
(void)opt_codec_ctx;
(void)td;
(void)constraints;
(void)pd;
if(!*sptr) {
*sptr = MALLOC(sizeof(NULL_t));
if(*sptr) {
*(NULL_t *)*sptr = 0;
} else {
ASN__DECODE_FAILED;
}
}
/*
* NULL type does not have content octets.
*/
rv.code = RC_OK;
rv.consumed = 0;
return rv;
}
asn_enc_rval_t
NULL_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
asn_enc_rval_t er;
(void)td;
(void)constraints;
(void)sptr;
(void)po;
er.encoded = 0;
ASN__ENCODED_OK(er);
}
#endif /* ASN_DISABLE_PER_SUPPORT */
asn_random_fill_result_t
......
......@@ -30,6 +30,8 @@ oer_type_decoder_f NULL_decode_oer;
oer_type_encoder_f NULL_encode_oer;
per_type_decoder_f NULL_decode_uper;
per_type_encoder_f NULL_encode_uper;
per_type_decoder_f NULL_decode_aper;
per_type_encoder_f NULL_encode_aper;
asn_random_fill_f NULL_random_fill;
#define NULL_free BOOLEAN_free
......
......@@ -36,9 +36,13 @@ asn_TYPE_operation_t asn_OP_NativeEnumerated = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
NativeEnumerated_decode_uper,
NativeEnumerated_encode_uper,
NativeEnumerated_decode_aper,
NativeEnumerated_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
NativeEnumerated_random_fill,
0 /* Use generic outmost tag fetcher */
......@@ -224,3 +228,140 @@ NativeEnumerated_encode_uper(const asn_TYPE_descriptor_t *td,
ASN__ENCODED_OK(er);
}
asn_dec_rval_t
NativeEnumerated_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
void **sptr, asn_per_data_t *pd) {
const asn_INTEGER_specifics_t *specs = (const asn_INTEGER_specifics_t *)td->specifics;
asn_dec_rval_t rval = { RC_OK, 0 };
long *native = (long *)*sptr;
const asn_per_constraint_t *ct;
long value;
(void)opt_codec_ctx;
if(constraints) ct = &constraints->value;
else if(td->encoding_constraints.per_constraints)
ct = &td->encoding_constraints.per_constraints->value;
else ASN__DECODE_FAILED; /* Mandatory! */
if(!specs) ASN__DECODE_FAILED;
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
if(!native) ASN__DECODE_FAILED;
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
if(ct->flags & APC_EXTENSIBLE) {
int inext = per_get_few_bits(pd, 1);
if(inext < 0) ASN__DECODE_STARVED;
if(inext) ct = 0;
}
/* Deal with APER padding */
if(ct && ct->upper_bound >= 255) {
int padding = 0;
padding = (8 - (pd->moved % 8)) % 8;
ASN_DEBUG("For NativeEnumerated %s,offset= %lu Padding bits = %d", td->name, pd->moved, padding);
ASN_DEBUG("For NativeEnumerated %s, upper bound = %lu", td->name, ct->upper_bound);
if(padding > 0)
per_get_few_bits(pd, padding);
}
if(ct && ct->range_bits >= 0) {
value = per_get_few_bits(pd, ct->range_bits);
if(value < 0) ASN__DECODE_STARVED;
if(value >= (specs->extension
? specs->extension - 1 : specs->map_count))
ASN__DECODE_FAILED;
} else {
if(!specs->extension)
ASN__DECODE_FAILED;
/*
* X.691, #10.6: normally small non-negative whole number;
*/
value = uper_get_nsnnwn(pd);
if(value < 0) ASN__DECODE_STARVED;
value += specs->extension - 1;
if(value >= specs->map_count)
ASN__DECODE_FAILED;
}
*native = specs->value2enum[value].nat_value;
ASN_DEBUG("Decoded %s = %ld", td->name, *native);
return rval;
}
asn_enc_rval_t
NativeEnumerated_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const asn_INTEGER_specifics_t *specs = (const asn_INTEGER_specifics_t *)td->specifics;
asn_enc_rval_t er;
long native, value;
const asn_per_constraint_t *ct;
int inext = 0;
asn_INTEGER_enum_map_t key;
asn_INTEGER_enum_map_t *kf;
if(!sptr) ASN__ENCODE_FAILED;
if(!specs) ASN__ENCODE_FAILED;
if(constraints) ct = &constraints->value;
else if(td->encoding_constraints.per_constraints)
ct = &td->encoding_constraints.per_constraints->value;
else ASN__ENCODE_FAILED; /* Mandatory! */
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
er.encoded = 0;
native = *(const long *)sptr;
if(native < 0) ASN__ENCODE_FAILED;
key.nat_value = native;
kf = bsearch(&key, specs->value2enum, specs->map_count,
sizeof(key), NativeEnumerated__compar_value2enum);
if(!kf) {
ASN_DEBUG("No element corresponds to %ld", native);
ASN__ENCODE_FAILED;
}
value = kf - specs->value2enum;
if(ct->range_bits >= 0) {
int cmpWith = specs->extension
? specs->extension - 1 : specs->map_count;
if(value >= cmpWith)
inext = 1;
}
if(ct->flags & APC_EXTENSIBLE) {
if(per_put_few_bits(po, inext, 1))
ASN__ENCODE_FAILED;
if(inext) ct = 0;
} else if(inext) {
ASN__ENCODE_FAILED;
}
if(ct && ct->range_bits >= 0) {
if(per_put_few_bits(po, value, ct->range_bits))
ASN__ENCODE_FAILED;
ASN__ENCODED_OK(er);
}
if(!specs->extension)
ASN__ENCODE_FAILED;
/*
* X.691, #10.6: normally small non-negative whole number;
*/
ASN_DEBUG("value = %ld, ext = %d, inext = %d, res = %ld",
value, specs->extension, inext,
value - (inext ? (specs->extension - 1) : 0));
if(uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0)))
ASN__ENCODE_FAILED;
ASN__ENCODED_OK(er);
}
......@@ -26,6 +26,8 @@ oer_type_decoder_f NativeEnumerated_decode_oer;
oer_type_encoder_f NativeEnumerated_encode_oer;
per_type_decoder_f NativeEnumerated_decode_uper;
per_type_encoder_f NativeEnumerated_encode_uper;
per_type_decoder_f NativeEnumerated_decode_aper;
per_type_encoder_f NativeEnumerated_encode_aper;
#define NativeEnumerated_free NativeInteger_free
#define NativeEnumerated_print NativeInteger_print
......
......@@ -37,9 +37,13 @@ asn_TYPE_operation_t asn_OP_NativeInteger = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
NativeInteger_decode_uper, /* Unaligned PER decoder */
NativeInteger_encode_uper, /* Unaligned PER encoder */
NativeInteger_decode_aper, /* Aligned PER decoder */
NativeInteger_encode_aper, /* Aligned PER encoder */
#endif /* ASN_DISABLE_PER_SUPPORT */
NativeInteger_random_fill,
0 /* Use generic outmost tag fetcher */
......@@ -315,6 +319,68 @@ NativeInteger_encode_uper(const asn_TYPE_descriptor_t *td,
return er;
}
asn_dec_rval_t
NativeInteger_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
const asn_INTEGER_specifics_t *specs = (const asn_INTEGER_specifics_t *)td->specifics;
asn_dec_rval_t rval;
long *native = (long *)*sptr;
INTEGER_t tmpint;
void *tmpintptr = &tmpint;
(void)opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name);
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
if(!native) ASN__DECODE_FAILED;
}
memset(&tmpint, 0, sizeof tmpint);
rval = INTEGER_decode_aper(opt_codec_ctx, td, constraints,
&tmpintptr, pd);
if(rval.code == RC_OK) {
if((specs&&specs->field_unsigned)
? asn_INTEGER2ulong(&tmpint, (unsigned long *)native)
: asn_INTEGER2long(&tmpint, native))
rval.code = RC_FAIL;
else
ASN_DEBUG("NativeInteger %s got value %ld",
td->name, *native);
}
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return rval;
}
asn_enc_rval_t
NativeInteger_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const asn_INTEGER_specifics_t *specs = (const asn_INTEGER_specifics_t *)td->specifics;
asn_enc_rval_t er;
long native;
INTEGER_t tmpint;
if(!sptr) ASN__ENCODE_FAILED;
native = *(const long *)sptr;
ASN_DEBUG("Encoding NativeInteger %s %ld (APER)", td->name, native);
memset(&tmpint, 0, sizeof(tmpint));
if((specs&&specs->field_unsigned)
? asn_ulong2INTEGER(&tmpint, (unsigned long)native)
: asn_long2INTEGER(&tmpint, native))
ASN__ENCODE_FAILED;
er = INTEGER_encode_aper(td, constraints, &tmpint, po);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return er;
}
#endif /* ASN_DISABLE_PER_SUPPORT */
/*
......
......@@ -33,6 +33,8 @@ oer_type_decoder_f NativeInteger_decode_oer;
oer_type_encoder_f NativeInteger_encode_oer;
per_type_decoder_f NativeInteger_decode_uper;
per_type_encoder_f NativeInteger_encode_uper;
per_type_decoder_f NativeInteger_decode_aper;
per_type_encoder_f NativeInteger_encode_aper;
asn_random_fill_f NativeInteger_random_fill;
#define NativeInteger_constraint asn_generic_no_constraint
......
......@@ -58,9 +58,13 @@ asn_TYPE_operation_t asn_OP_NativeReal = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
NativeReal_decode_uper,
NativeReal_encode_uper,
NativeReal_decode_aper,
NativeReal_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
NativeReal_random_fill,
0 /* Use generic outmost tag fetcher */
......@@ -262,6 +266,72 @@ NativeReal_encode_uper(const asn_TYPE_descriptor_t *td,
return erval;
}
asn_dec_rval_t
NativeReal_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
void **dbl_ptr, asn_per_data_t *pd) {
double *Dbl = (double *)*dbl_ptr;
asn_dec_rval_t rval;
REAL_t tmp;
void *ptmp = &tmp;
int ret;
(void)constraints;
/*
* If the structure is not there, allocate it.
*/
if(Dbl == NULL) {
*dbl_ptr = CALLOC(1, sizeof(*Dbl));
Dbl = (double *)*dbl_ptr;
if(Dbl == NULL)
ASN__DECODE_FAILED;
}
memset(&tmp, 0, sizeof(tmp));
rval = OCTET_STRING_decode_aper(opt_codec_ctx, td, NULL,
&ptmp, pd);
if(rval.code != RC_OK) {
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_REAL, &tmp);
return rval;
}
ret = asn_REAL2double(&tmp, Dbl);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_REAL, &tmp);
if(ret) ASN__DECODE_FAILED;
return rval;
}
asn_enc_rval_t
NativeReal_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
double Dbl = *(const double *)sptr;
asn_enc_rval_t erval;
REAL_t tmp;
(void)constraints;
/* Prepare a temporary clean structure */
memset(&tmp, 0, sizeof(tmp));
if(asn_double2REAL(&tmp, Dbl))
ASN__ENCODE_FAILED;
/* Encode a DER REAL */
erval = OCTET_STRING_encode_aper(td, NULL, &tmp, po);
if(erval.encoded == -1)
erval.structure_ptr = sptr;
/* Free possibly allocated members of the temporary structure */
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_REAL, &tmp);
return erval;
}
#endif /* ASN_DISABLE_PER_SUPPORT */
#ifndef ASN_DISABLE_OER_SUPPORT
......
......@@ -31,6 +31,8 @@ ber_type_decoder_f NativeReal_decode_ber;
der_type_encoder_f NativeReal_encode_der;
per_type_decoder_f NativeReal_decode_uper;
per_type_encoder_f NativeReal_encode_uper;
per_type_decoder_f NativeReal_decode_aper;
per_type_encoder_f NativeReal_encode_aper;
oer_type_decoder_f NativeReal_decode_oer;
oer_type_encoder_f NativeReal_encode_oer;
xer_type_decoder_f NativeReal_decode_xer;
......
......@@ -55,9 +55,13 @@ asn_TYPE_operation_t asn_OP_NumericString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -27,6 +27,8 @@ asn_constr_check_f NumericString_constraint;
#define NumericString_encode_xer OCTET_STRING_encode_xer_utf8
#define NumericString_decode_uper OCTET_STRING_decode_uper
#define NumericString_encode_uper OCTET_STRING_encode_uper
#define NumericString_decode_aper OCTET_STRING_decode_aper
#define NumericString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -33,9 +33,13 @@ asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OBJECT_IDENTIFIER_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -36,6 +36,8 @@ asn_random_fill_f OBJECT_IDENTIFIER_random_fill;
#define OBJECT_IDENTIFIER_encode_oer oer_encode_primitive
#define OBJECT_IDENTIFIER_decode_uper OCTET_STRING_decode_uper
#define OBJECT_IDENTIFIER_encode_uper OCTET_STRING_encode_uper
#define OBJECT_IDENTIFIER_decode_aper OCTET_STRING_decode_aper
#define OBJECT_IDENTIFIER_encode_aper OCTET_STRING_encode_aper
/**********************************
* Some handy conversion routines *
......
This diff is collapsed.
......@@ -36,6 +36,8 @@ oer_type_decoder_f OCTET_STRING_decode_oer;
oer_type_encoder_f OCTET_STRING_encode_oer;
per_type_decoder_f OCTET_STRING_decode_uper;
per_type_encoder_f OCTET_STRING_encode_uper;
per_type_decoder_f OCTET_STRING_decode_aper;
per_type_encoder_f OCTET_STRING_encode_aper;
asn_random_fill_f OCTET_STRING_random_fill;
#define OCTET_STRING_constraint asn_generic_no_constraint
......
......@@ -18,13 +18,15 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = {
OPEN_TYPE_encode_xer,
0, 0, /* No OER support, use "-gen-OER" to enable */
#ifdef ASN_DISABLE_PER_SUPPORT
0, 0,
0, 0, 0, 0,
#else
OPEN_TYPE_decode_uper,
OPEN_TYPE_encode_uper,
OPEN_TYPE_decode_aper,
OPEN_TYPE_encode_aper,
#endif
0, /* Random fill is not supported for open type */
0, /* Use generic outmost tag fetcher */
0 /* Use generic outmost tag fetcher */
};
#undef ADVANCE
......
......@@ -20,6 +20,8 @@ extern "C" {
#define OPEN_TYPE_decode_xer NULL
#define OPEN_TYPE_encode_xer CHOICE_encode_xer
#define OPEN_TYPE_decode_uper NULL
#define OPEN_TYPE_decode_aper NULL
#define OPEN_TYPE_encode_aper CHOICE_encode_aper
extern asn_TYPE_operation_t asn_OP_OPEN_TYPE;
......
......@@ -30,9 +30,13 @@ asn_TYPE_operation_t asn_OP_ObjectDescriptor = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
0, /* Not supported for ObjectDescriptor */
0 /* Use generic outmost tag fetcher */
......
......@@ -25,6 +25,8 @@ extern asn_TYPE_operation_t asn_OP_ObjectDescriptor;
#define ObjectDescriptor_encode_xer OCTET_STRING_encode_xer_utf8
#define ObjectDescriptor_decode_uper OCTET_STRING_decode_uper
#define ObjectDescriptor_encode_uper OCTET_STRING_encode_uper
#define ObjectDescriptor_decode_aper OCTET_STRING_decode_aper
#define ObjectDescriptor_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -65,9 +65,13 @@ asn_TYPE_operation_t asn_OP_PrintableString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -27,6 +27,8 @@ asn_constr_check_f PrintableString_constraint;
#define PrintableString_encode_xer OCTET_STRING_encode_xer_utf8
#define PrintableString_decode_uper OCTET_STRING_decode_uper
#define PrintableString_encode_uper OCTET_STRING_encode_uper
#define PrintableString_decode_aper OCTET_STRING_decode_aper
#define PrintableString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -84,9 +84,13 @@ asn_TYPE_operation_t asn_OP_REAL = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
REAL_decode_uper,
REAL_encode_uper,
REAL_decode_aper,
REAL_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
REAL_random_fill,
0 /* Use generic outmost tag fetcher */
......@@ -946,6 +950,23 @@ REAL_encode_uper(const asn_TYPE_descriptor_t *td,
return OCTET_STRING_encode_uper(td, 0, sptr, po);
}
asn_dec_rval_t
REAL_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
void **sptr, asn_per_data_t *pd) {
(void)constraints; /* No PER visible constraints */
return OCTET_STRING_decode_aper(opt_codec_ctx, td, 0, sptr, pd);
}
asn_enc_rval_t
REAL_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
(void)constraints; /* No PER visible constraints */
return OCTET_STRING_encode_aper(td, 0, sptr, po);
}
#endif /* ASN_DISABLE_PER_SUPPORT */
asn_random_fill_result_t
......
......@@ -23,6 +23,8 @@ oer_type_decoder_f REAL_decode_oer;
oer_type_encoder_f REAL_encode_oer;
per_type_decoder_f REAL_decode_uper;
per_type_encoder_f REAL_encode_uper;
per_type_decoder_f REAL_decode_aper;
per_type_encoder_f REAL_encode_aper;
xer_type_decoder_f REAL_decode_xer;
xer_type_encoder_f REAL_encode_xer;
asn_random_fill_f REAL_random_fill;
......
......@@ -34,9 +34,13 @@ asn_TYPE_operation_t asn_OP_RELATIVE_OID = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
RELATIVE_OID_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -31,6 +31,8 @@ asn_random_fill_f RELATIVE_OID_random_fill;
#define RELATIVE_OID_encode_oer oer_encode_primitive
#define RELATIVE_OID_decode_uper OCTET_STRING_decode_uper
#define RELATIVE_OID_encode_uper OCTET_STRING_encode_uper
#define RELATIVE_OID_decode_aper OCTET_STRING_decode_aper
#define RELATIVE_OID_encode_aper OCTET_STRING_encode_aper
/**********************************
* Some handy conversion routines *
......
......@@ -30,9 +30,13 @@ asn_TYPE_operation_t asn_OP_T61String = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -26,6 +26,8 @@ extern asn_TYPE_operation_t asn_OP_T61String;
#define T61String_encode_xer OCTET_STRING_encode_xer
#define T61String_decode_uper OCTET_STRING_decode_uper
#define T61String_encode_uper OCTET_STRING_encode_uper
#define T61String_decode_aper OCTET_STRING_decode_aper
#define T61String_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -30,9 +30,13 @@ asn_TYPE_operation_t asn_OP_TeletexString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -26,6 +26,8 @@ extern asn_TYPE_operation_t asn_OP_TeletexString;
#define TeletexString_encode_xer OCTET_STRING_encode_xer
#define TeletexString_decode_uper OCTET_STRING_decode_uper
#define TeletexString_encode_uper OCTET_STRING_encode_uper
#define TeletexString_decode_aper OCTET_STRING_decode_aper
#define TeletexString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -46,9 +46,13 @@ asn_TYPE_operation_t asn_OP_UTCTime = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
UTCTime_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -28,6 +28,8 @@ asn_random_fill_f UTCTime_random_fill;
#define UTCTime_decode_xer OCTET_STRING_decode_xer_utf8
#define UTCTime_decode_uper OCTET_STRING_decode_uper
#define UTCTime_encode_uper OCTET_STRING_encode_uper
#define UTCTime_decode_aper OCTET_STRING_decode_aper
#define UTCTime_encode_aper OCTET_STRING_encode_aper
/***********************
* Some handy helpers. *
......
......@@ -31,9 +31,13 @@ asn_TYPE_operation_t asn_OP_UTF8String = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
UTF8String_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -29,6 +29,8 @@ asn_random_fill_f UTF8String_random_fill;
#define UTF8String_encode_xer OCTET_STRING_encode_xer_utf8
#define UTF8String_decode_uper OCTET_STRING_decode_uper
#define UTF8String_encode_uper OCTET_STRING_encode_uper
#define UTF8String_decode_aper OCTET_STRING_decode_aper
#define UTF8String_encode_aper OCTET_STRING_encode_aper
/*
* Returns length of the given UTF-8 string in characters,
......
......@@ -41,9 +41,13 @@ asn_TYPE_operation_t asn_OP_UniversalString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -28,6 +28,8 @@ xer_type_encoder_f UniversalString_encode_xer;
#define UniversalString_encode_der OCTET_STRING_encode_der
#define UniversalString_decode_uper OCTET_STRING_decode_uper
#define UniversalString_encode_uper OCTET_STRING_encode_uper
#define UniversalString_decode_aper OCTET_STRING_decode_aper
#define UniversalString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -30,9 +30,13 @@ asn_TYPE_operation_t asn_OP_VideotexString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper, /* Implemented in terms of OCTET STRING */
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -26,6 +26,8 @@ extern asn_TYPE_operation_t asn_OP_VideotexString;
#define VideotexString_encode_xer OCTET_STRING_encode_xer
#define VideotexString_decode_uper OCTET_STRING_decode_uper
#define VideotexString_encode_uper OCTET_STRING_encode_uper
#define VideotexString_decode_aper OCTET_STRING_decode_aper
#define VideotexString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -35,9 +35,13 @@ asn_TYPE_operation_t asn_OP_VisibleString = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
OCTET_STRING_decode_uper,
OCTET_STRING_encode_uper,
OCTET_STRING_decode_aper,
OCTET_STRING_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
OCTET_STRING_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -28,6 +28,8 @@ asn_constr_check_f VisibleString_constraint;
#define VisibleString_encode_xer OCTET_STRING_encode_xer
#define VisibleString_decode_uper OCTET_STRING_decode_uper
#define VisibleString_encode_uper OCTET_STRING_encode_uper
#define VisibleString_decode_aper OCTET_STRING_decode_aper
#define VisibleString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
......
......@@ -51,6 +51,8 @@ enum asn_transfer_syntax {
*/
ATS_UNALIGNED_BASIC_PER,
ATS_UNALIGNED_CANONICAL_PER,
ATS_ALIGNED_BASIC_PER,
ATS_ALIGNED_CANONICAL_PER,
/*
* X.693:
* XER: XML Encoding Rules.
......
......@@ -123,7 +123,7 @@ ber_skip_length(const asn_codec_ctx_t *opt_codec_ctx,
ptr = ((const char *)ptr) + tl + ll;
size -= tl + ll;
}
}
/* UNREACHABLE */
}
......
......@@ -1010,6 +1010,171 @@ CHOICE_encode_uper(const asn_TYPE_descriptor_t *td,
}
}
asn_dec_rval_t
CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
asn_dec_rval_t rv;
const asn_per_constraint_t *ct;
asn_TYPE_member_t *elm; /* CHOICE's element */
void *memb_ptr;
void **memb_ptr2;
void *st = *sptr;
int value;
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
ASN__DECODE_FAILED;
/*
* Create the target structure if it is not present already.
*/
if(!st) {
st = *sptr = CALLOC(1, specs->struct_size);
if(!st) ASN__DECODE_FAILED;
}
if(constraints) ct = &constraints->value;
else if(td->encoding_constraints.per_constraints)
ct = &td->encoding_constraints.per_constraints->value;
else ct = 0;
if(ct && ct->flags & APC_EXTENSIBLE) {
value = per_get_few_bits(pd, 1);
if(value < 0) ASN__DECODE_STARVED;
if(value) ct = 0; /* Not restricted */
}
if(ct && ct->range_bits >= 0) {
value = per_get_few_bits(pd, ct->range_bits);
if(value < 0) ASN__DECODE_STARVED;
ASN_DEBUG("CHOICE %s got index %d in range %d",
td->name, value, ct->range_bits);
if(value > ct->upper_bound)
ASN__DECODE_FAILED;
} else {
if(specs->ext_start == -1)
ASN__DECODE_FAILED;
value = uper_get_nsnnwn(pd);
if(value < 0) ASN__DECODE_STARVED;
value += specs->ext_start;
if((unsigned)value >= td->elements_count)
ASN__DECODE_FAILED;
}
/* Adjust if canonical order is different from natural order */
if(specs->from_canonical_order)
value = specs->from_canonical_order[value];
/* Set presence to be able to free it later */
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
elm = &td->elements[value];
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
} else {
memb_ptr = (char *)st + elm->memb_offset;
memb_ptr2 = &memb_ptr;
}
ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name);
if(ct && ct->range_bits >= 0) {
rv = elm->type->op->aper_decoder(opt_codec_ctx, elm->type,
elm->encoding_constraints.per_constraints, memb_ptr2, pd);
} else {
rv = uper_open_type_get(opt_codec_ctx, elm->type,
elm->encoding_constraints.per_constraints, memb_ptr2, pd);
}
if(rv.code != RC_OK)
ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d",
elm->name, td->name, rv.code);
return rv;
}
asn_enc_rval_t
CHOICE_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
const asn_TYPE_member_t *elm; /* CHOICE's element */
const asn_per_constraint_t *ct;
const void *memb_ptr;
int present;
if(!sptr) ASN__ENCODE_FAILED;
ASN_DEBUG("Encoding %s as CHOICE using ALIGNED PER", td->name);
if(constraints) ct = &constraints->value;
else if(td->encoding_constraints.per_constraints)
ct = &td->encoding_constraints.per_constraints->value;
else ct = 0;
present = _fetch_present_idx(sptr,
specs->pres_offset, specs->pres_size);
/*
* If the structure was not initialized properly, it cannot be encoded:
* can't deduce what to encode in the choice type.
*/
if(present <= 0 || (unsigned)present > td->elements_count)
ASN__ENCODE_FAILED;
else
present--;
/* Adjust if canonical order is different from natural order */
if(specs->to_canonical_order)
present = specs->to_canonical_order[present];
ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present);
if(ct && ct->range_bits >= 0) {
if(present < ct->lower_bound
|| present > ct->upper_bound) {
if(ct->flags & APC_EXTENSIBLE) {
if(per_put_few_bits(po, 1, 1))
ASN__ENCODE_FAILED;
} else {
ASN__ENCODE_FAILED;
}
ct = 0;
}
}
if(ct && ct->flags & APC_EXTENSIBLE) {
if(per_put_few_bits(po, 0, 1))
ASN__ENCODE_FAILED;
}
elm = &td->elements[present];
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
memb_ptr = *(const void *const *)((const char *)sptr + elm->memb_offset);
if(!memb_ptr) ASN__ENCODE_FAILED;
} else {
memb_ptr = (const char *)sptr + elm->memb_offset;
}
if(ct && ct->range_bits >= 0) {
if(per_put_few_bits(po, present, ct->range_bits))
ASN__ENCODE_FAILED;
return elm->type->op->aper_encoder(elm->type, elm->encoding_constraints.per_constraints,
memb_ptr, po);
} else {
asn_enc_rval_t rval;
if(specs->ext_start == -1)
ASN__ENCODE_FAILED;
if(aper_put_nsnnwn(po, ct->range_bits, present - specs->ext_start))
ASN__ENCODE_FAILED;
if(aper_open_type_put(elm->type, elm->encoding_constraints.per_constraints,
memb_ptr, po))
ASN__ENCODE_FAILED;
rval.encoded = 0;
ASN__ENCODED_OK(rval);
}
}
int
CHOICE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
......@@ -1331,9 +1496,13 @@ asn_TYPE_operation_t asn_OP_CHOICE = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
CHOICE_decode_uper,
CHOICE_encode_uper,
CHOICE_decode_aper,
CHOICE_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
CHOICE_random_fill,
CHOICE_outmost_tag
......
......@@ -51,6 +51,8 @@ oer_type_decoder_f CHOICE_decode_oer;
oer_type_encoder_f CHOICE_encode_oer;
per_type_decoder_f CHOICE_decode_uper;
per_type_encoder_f CHOICE_encode_uper;
per_type_decoder_f CHOICE_decode_aper;
per_type_encoder_f CHOICE_encode_aper;
asn_outmost_tag_f CHOICE_outmost_tag;
asn_random_fill_f CHOICE_random_fill;
extern asn_TYPE_operation_t asn_OP_CHOICE;
......
This diff is collapsed.
......@@ -56,6 +56,8 @@ oer_type_decoder_f SEQUENCE_decode_oer;
oer_type_encoder_f SEQUENCE_encode_oer;
per_type_decoder_f SEQUENCE_decode_uper;
per_type_encoder_f SEQUENCE_encode_uper;
per_type_decoder_f SEQUENCE_decode_aper;
per_type_encoder_f SEQUENCE_encode_aper;
asn_random_fill_f SEQUENCE_random_fill;
extern asn_TYPE_operation_t asn_OP_SEQUENCE;
......
......@@ -225,6 +225,76 @@ SEQUENCE_OF_encode_uper(const asn_TYPE_descriptor_t *td,
ASN__ENCODED_OK(er);
}
asn_enc_rval_t
SEQUENCE_OF_encode_aper(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
const asn_anonymous_sequence_ *list;
const asn_per_constraint_t *ct;
asn_enc_rval_t er;
asn_TYPE_member_t *elm = td->elements;
int seq;
if(!sptr) ASN__ENCODE_FAILED;
list = _A_CSEQUENCE_FROM_VOID(sptr);
er.encoded = 0;
ASN_DEBUG("Encoding %s as SEQUENCE OF size (%d) using ALIGNED PER", td->name, list->count);
if(constraints) ct = &constraints->size;
else if(td->encoding_constraints.per_constraints)
ct = &td->encoding_constraints.per_constraints->size;
else ct = 0;
/* If extensible constraint, check if size is in root */
if(ct) {
int not_in_root = (list->count < ct->lower_bound
|| list->count > ct->upper_bound);
ASN_DEBUG("lb %ld ub %ld %s",
ct->lower_bound, ct->upper_bound,
ct->flags & APC_EXTENSIBLE ? "ext" : "fix");
if(ct->flags & APC_EXTENSIBLE) {
/* Declare whether size is in extension root */
if(per_put_few_bits(po, not_in_root, 1))
ASN__ENCODE_FAILED;
if(not_in_root) ct = 0;
} else if(not_in_root && ct->effective_bits >= 0)
ASN__ENCODE_FAILED;
}
if(ct && ct->effective_bits >= 0) {
/* X.691, #19.5: No length determinant */
/* if(per_put_few_bits(po, list->count - ct->lower_bound,
ct->effective_bits))
ASN__ENCODE_FAILED;
*/
if (aper_put_length(po, ct->upper_bound - ct->lower_bound + 1, list->count - ct->lower_bound) < 0)
ASN__ENCODE_FAILED;
}
for(seq = -1; seq < list->count;) {
ssize_t mayEncode;
if(seq < 0) seq = 0;
if(ct && ct->effective_bits >= 0) {
mayEncode = list->count;
} else {
mayEncode = aper_put_length(po, -1, list->count - seq);
if(mayEncode < 0) ASN__ENCODE_FAILED;
}
while(mayEncode--) {
void *memb_ptr = list->array[seq++];
if(!memb_ptr) ASN__ENCODE_FAILED;
er = elm->type->op->aper_encoder(elm->type,
elm->encoding_constraints.per_constraints, memb_ptr, po);
if(er.encoded == -1)
ASN__ENCODE_FAILED;
}
}
ASN__ENCODED_OK(er);
}
#endif /* ASN_DISABLE_PER_SUPPORT */
int
......@@ -274,9 +344,13 @@ asn_TYPE_operation_t asn_OP_SEQUENCE_OF = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
SEQUENCE_OF_decode_uper, /* Same as SET OF decoder */
SEQUENCE_OF_encode_uper,
SEQUENCE_OF_decode_aper,
SEQUENCE_OF_encode_aper,
#endif /* ASN_DISABLE_PER_SUPPORT */
SEQUENCE_OF_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -20,6 +20,7 @@ asn_struct_compare_f SEQUENCE_OF_compare;
der_type_encoder_f SEQUENCE_OF_encode_der;
xer_type_encoder_f SEQUENCE_OF_encode_xer;
per_type_encoder_f SEQUENCE_OF_encode_uper;
per_type_encoder_f SEQUENCE_OF_encode_aper;
extern asn_TYPE_operation_t asn_OP_SEQUENCE_OF;
#define SEQUENCE_OF_free SET_OF_free
......@@ -27,9 +28,10 @@ extern asn_TYPE_operation_t asn_OP_SEQUENCE_OF;
#define SEQUENCE_OF_constraint SET_OF_constraint
#define SEQUENCE_OF_decode_ber SET_OF_decode_ber
#define SEQUENCE_OF_decode_xer SET_OF_decode_xer
#define SEQUENCE_OF_decode_uper SET_OF_decode_uper
#define SEQUENCE_OF_decode_oer SET_OF_decode_oer
#define SEQUENCE_OF_encode_oer SET_OF_encode_oer
#define SEQUENCE_OF_decode_uper SET_OF_decode_uper
#define SEQUENCE_OF_decode_aper SET_OF_decode_aper
#define SEQUENCE_OF_random_fill SET_OF_random_fill
#ifdef __cplusplus
......
......@@ -1073,6 +1073,8 @@ asn_TYPE_operation_t asn_OP_SET = {
0, /* SET_encode_oer */
0, /* SET_decode_uper */
0, /* SET_encode_uper */
0, /* SET_decode_aper */
0, /* SET_encode_aper */
SET_random_fill,
0 /* Use generic outmost tag fetcher */
};
......
......@@ -1097,6 +1097,95 @@ SET_OF_encode_uper(const asn_TYPE_descriptor_t *td,
}
}
asn_dec_rval_t
SET_OF_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rv;
const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
const asn_TYPE_member_t *elm = td->elements; /* Single one */
void *st = *sptr;
asn_anonymous_set_ *list;
const asn_per_constraint_t *ct;
int repeat = 0;
ssize_t nelems;
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
ASN__DECODE_FAILED;
/*
* Create the target structure if it is not present already.
*/
if(!st) {
st = *sptr = CALLOC(1, specs->struct_size);
if(!st) ASN__DECODE_FAILED;
}
list = _A_SET_FROM_VOID(st);
/* Figure out which constraints to use */
if(constraints) ct = &constraints->size;
else if(td->encoding_constraints.per_constraints)
ct = &td->encoding_constraints.per_constraints->size;
else ct = 0;
if(ct && ct->flags & APC_EXTENSIBLE) {
int value = per_get_few_bits(pd, 1);
if(value < 0) ASN__DECODE_STARVED;
if(value) ct = 0; /* Not restricted! */
}
if(ct && ct->effective_bits >= 0) {
/* X.691, #19.5: No length determinant */
nelems = aper_get_nsnnwn(pd, ct->upper_bound - ct->lower_bound);
ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s",
(long)nelems, ct->lower_bound, td->name);
if(nelems < 0) ASN__DECODE_STARVED;
nelems += ct->lower_bound;
} else {
nelems = -1;
}
do {
int i;
if(nelems < 0) {
nelems = aper_get_length(pd, ct ? ct->upper_bound - ct->lower_bound + 1 : -1,
ct ? ct->effective_bits : -1, &repeat);
ASN_DEBUG("Got to decode %d elements (eff %d)",
(int)nelems, (int)(ct ? ct->effective_bits : -1));
if(nelems < 0) ASN__DECODE_STARVED;
}
for(i = 0; i < nelems; i++) {
void *ptr = 0;
ASN_DEBUG("SET OF %s decoding", elm->type->name);
rv = elm->type->op->aper_decoder(opt_codec_ctx, elm->type,
elm->encoding_constraints.per_constraints, &ptr, pd);
ASN_DEBUG("%s SET OF %s decoded %d, %p",
td->name, elm->type->name, rv.code, ptr);
if(rv.code == RC_OK) {
if(ASN_SET_ADD(list, ptr) == 0)
continue;
ASN_DEBUG("Failed to add element into %s",
td->name);
/* Fall through */
rv.code = RC_FAIL;
} else {
ASN_DEBUG("Failed decoding %s of %s (SET OF)",
elm->type->name, td->name);
}
if(ptr) ASN_STRUCT_FREE(*elm->type, ptr);
return rv;
}
nelems = -1; /* Allow uper_get_length() */
} while(repeat);
ASN_DEBUG("Decoded %s as SET OF", td->name);
rv.code = RC_OK;
rv.consumed = 0;
return rv;
}
#endif /* ASN_DISABLE_PER_SUPPORT */
......@@ -1198,9 +1287,13 @@ asn_TYPE_operation_t asn_OP_SET_OF = {
#ifdef ASN_DISABLE_PER_SUPPORT
0,
0,
0,
0,
#else
SET_OF_decode_uper,
SET_OF_encode_uper,
SET_OF_decode_aper,
0, /* SET_OF_encode_aper */
#endif /* ASN_DISABLE_PER_SUPPORT */
SET_OF_random_fill,
0 /* Use generic outmost tag fetcher */
......
......@@ -37,6 +37,8 @@ oer_type_decoder_f SET_OF_decode_oer;
oer_type_encoder_f SET_OF_encode_oer;
per_type_decoder_f SET_OF_decode_uper;
per_type_encoder_f SET_OF_encode_uper;
per_type_decoder_f SET_OF_decode_aper;
per_type_encoder_f SET_OF_encode_aper;
asn_random_fill_f SET_OF_random_fill;
extern asn_TYPE_operation_t asn_OP_SET_OF;
......
......@@ -153,6 +153,8 @@ typedef struct asn_TYPE_operation_s {
oer_type_encoder_f *oer_encoder; /* Canonical OER encoder */
per_type_decoder_f *uper_decoder; /* Unaligned PER decoder */
per_type_encoder_f *uper_encoder; /* Unaligned PER encoder */
per_type_decoder_f *aper_decoder; /* Aligned PER decoder */
per_type_encoder_f *aper_encoder; /* Aligned PER encoder */
asn_random_fill_f *random_fill; /* Initialize with a random value */
asn_outmost_tag_f *outmost_tag; /* <optional, internal> */
} asn_TYPE_operation_t;
......
......@@ -146,6 +146,8 @@ static syntax_selector input_encodings[] = {
"Input is in OER (Octet Encoding Rules)"},
{"per", ATS_UNALIGNED_BASIC_PER, CODEC_OFFSET(uper_decoder),
"Input is in Unaligned PER (Packed Encoding Rules)"},
{"aper", ATS_ALIGNED_BASIC_PER, CODEC_OFFSET(aper_decoder),
"Input is in Aligned PER (Packed Encoding Rules)"},
{"xer", ATS_BASIC_XER, CODEC_OFFSET(xer_decoder),
"Input is in XER (XML Encoding Rules)"},
{0, ATS_INVALID, 0, 0}};
......@@ -157,6 +159,8 @@ static syntax_selector output_encodings[] = {
"Output as Canonical OER (Octet Encoding Rules)"},
{"per", ATS_UNALIGNED_CANONICAL_PER, CODEC_OFFSET(uper_encoder),
"Output as Unaligned PER (Packed Encoding Rules)"},
{"aper", ATS_ALIGNED_CANONICAL_PER, CODEC_OFFSET(aper_encoder),
"Output as Aligned PER (Packed Encoding Rules)"},
{"xer", ATS_BASIC_XER, CODEC_OFFSET(xer_encoder),
"Output as XER (XML Encoding Rules)"},
{"text", ATS_NONSTANDARD_PLAINTEXT, CODEC_OFFSET(print_struct),
......@@ -747,7 +751,9 @@ static void add_bytes_to_buffer(const void *data2add, size_t bytes) {
static int
is_syntax_PER(enum asn_transfer_syntax syntax) {
return (syntax == ATS_UNALIGNED_BASIC_PER
|| syntax == ATS_UNALIGNED_CANONICAL_PER);
|| syntax == ATS_UNALIGNED_CANONICAL_PER
|| syntax == ATS_ALIGNED_BASIC_PER
|| syntax == ATS_ALIGNED_CANONICAL_PER);
}
static int
......@@ -839,8 +845,12 @@ data_decode_from_file(enum asn_transfer_syntax isyntax, asn_TYPE_descriptor_t *p
rval.code = RC_FAIL;
rval.consumed = 0;
#else
rval = uper_decode(opt_codec_ctx, pduType, (void **)&structure,
i_bptr, i_size, 0, DynamicBuffer.unbits);
if(isyntax == ATS_UNALIGNED_BASIC_PER)
rval = uper_decode(opt_codec_ctx, pduType, (void **)&structure,
i_bptr, i_size, 0, DynamicBuffer.unbits);
else
rval = aper_decode(opt_codec_ctx, pduType, (void **)&structure,
i_bptr, i_size, 0, DynamicBuffer.unbits);
/* uper_decode() returns bits! */
ecbits = rval.consumed % 8; /* Bits consumed from the last byte */
rval.consumed >>= 3; /* Convert bits into bytes. */
......
......@@ -95,3 +95,87 @@ uper_decode(const asn_codec_ctx_t *opt_codec_ctx,
return rval;
}
asn_dec_rval_t
aper_decode_complete(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size) {
asn_dec_rval_t rval;
rval = aper_decode(opt_codec_ctx, td, sptr, buffer, size, 0, 0);
if(rval.consumed) {
/*
* We've always given 8-aligned data,
* so convert bits to integral bytes.
*/
rval.consumed += 7;
rval.consumed >>= 3;
} else if(rval.code == RC_OK) {
if(size) {
if(((const uint8_t *)buffer)[0] == 0) {
rval.consumed = 1; /* 1 byte */
} else {
ASN_DEBUG("Expecting single zeroed byte");
rval.code = RC_FAIL;
}
} else {
/* Must contain at least 8 bits. */
rval.code = RC_WMORE;
}
}
return rval;
}
asn_dec_rval_t
aper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size, int skip_bits, int unused_bits) {
asn_codec_ctx_t s_codec_ctx;
asn_dec_rval_t rval;
asn_per_data_t pd;
if(skip_bits < 0 || skip_bits > 7
|| unused_bits < 0 || unused_bits > 7
|| (unused_bits > 0 && !size))
ASN__DECODE_FAILED;
/*
* Stack checker requires that the codec context
* must be allocated on the stack.
*/
if(opt_codec_ctx) {
if(opt_codec_ctx->max_stack_size) {
s_codec_ctx = *opt_codec_ctx;
opt_codec_ctx = &s_codec_ctx;
}
} else {
/* If context is not given, be security-conscious anyway */
memset(&s_codec_ctx, 0, sizeof(s_codec_ctx));
s_codec_ctx.max_stack_size = ASN__DEFAULT_STACK_MAX;
opt_codec_ctx = &s_codec_ctx;
}
/* Fill in the position indicator */
memset(&pd, 0, sizeof(pd));
pd.buffer = (const uint8_t *)buffer;
pd.nboff = skip_bits;
pd.nbits = 8 * size - unused_bits; /* 8 is CHAR_BIT from <limits.h> */
if(pd.nboff > pd.nbits)
ASN__DECODE_FAILED;
/*
* Invoke type-specific decoder.
*/
if(!td->op->aper_decoder)
ASN__DECODE_FAILED; /* PER is not compiled in */
rval = td->op->aper_decoder(opt_codec_ctx, td, 0, sptr, &pd);
if(rval.code == RC_OK) {
/* Return the number of consumed bits */
rval.consumed = ((pd.buffer - (const uint8_t *)buffer) << 3)
+ pd.nboff - skip_bits;
ASN_DEBUG("PER decoding consumed %zu, counted %zu",
rval.consumed, pd.moved);
assert(rval.consumed == pd.moved);
} else {
/* PER codec is not a restartable */
rval.consumed = 0;
}
return rval;
}
......@@ -40,6 +40,29 @@ asn_dec_rval_t uper_decode(
int unused_bits /* Number of unused tailing bits, 0..7 */
);
/*
* Aligned PER decoder of a "complete encoding" as per X.691#10.1.
* On success, this call always returns (.consumed >= 1), in BITS, as per X.691#10.1.3.
*/
asn_dec_rval_t aper_decode_complete(struct asn_codec_ctx_s *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
void **struct_ptr, /* Pointer to a target structure's pointer */
const void *buffer, /* Data to be decoded */
size_t size /* Size of data buffer */
);
/*
* Aligned PER decoder of any ASN.1 type. May be invoked by the application.
* WARNING: This call returns the number of BITS read from the stream. Beware.
*/
asn_dec_rval_t aper_decode(struct asn_codec_ctx_s *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
void **struct_ptr, /* Pointer to a target structure's pointer */
const void *buffer, /* Data to be decoded */
size_t size, /* Size of data buffer */
int skip_bits, /* Number of unused leading bits, 0..7 */
int unused_bits /* Number of unused tailing bits, 0..7 */
);
/*
* Type of the type-specific PER decoder function.
......
......@@ -163,3 +163,112 @@ _uper_encode_flush_outp(asn_per_outp_t *po) {
return po->output(po->tmpspace, buf - po->tmpspace, po->op_key);
}
static asn_enc_rval_t aper_encode_internal(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *,
const void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
asn_enc_rval_t
aper_encode(const asn_TYPE_descriptor_t *td,
const void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
return aper_encode_internal(td, 0, sptr, cb, app_key);
}
asn_enc_rval_t
aper_encode_to_buffer(const asn_TYPE_descriptor_t *td,
const void *sptr, void *buffer, size_t buffer_size) {
enc_to_buf_arg key;
key.buffer = buffer;
key.left = buffer_size;
if(td) ASN_DEBUG("Encoding \"%s\" using ALIGNED PER", td->name);
return aper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key);
}
ssize_t
aper_encode_to_new_buffer(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, void **buffer_r) {
asn_enc_rval_t er;
enc_dyn_arg key;
memset(&key, 0, sizeof(key));
er = aper_encode_internal(td, constraints, sptr, encode_dyn_cb, &key);
switch(er.encoded) {
case -1:
FREEMEM(key.buffer);
return -1;
case 0:
FREEMEM(key.buffer);
key.buffer = MALLOC(1);
if(key.buffer) {
*(char *)key.buffer = '\0';
*buffer_r = key.buffer;
return 1;
} else {
return -1;
}
default:
*buffer_r = key.buffer;
ASN_DEBUG("Complete encoded in %ld bits", er.encoded);
return ((er.encoded + 7) >> 3);
}
}
static int
_aper_encode_flush_outp(asn_per_outp_t *po) {
uint8_t *buf;
if(po->nboff == 0 && po->buffer == po->tmpspace)
return 0;
buf = po->buffer + (po->nboff >> 3);
/* Make sure we account for the last, partially filled */
if(po->nboff & 0x07) {
buf[0] &= 0xff << (8 - (po->nboff & 0x07));
buf++;
}
if (po->output) {
return po->output(po->tmpspace, buf - po->tmpspace, po->op_key);
}
return 0;
}
static asn_enc_rval_t
aper_encode_internal(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
asn_per_outp_t po;
asn_enc_rval_t er;
/*
* Invoke type-specific encoder.
*/
if(!td || !td->op->aper_encoder)
ASN__ENCODE_FAILED; /* PER is not compiled in */
po.buffer = po.tmpspace;
po.nboff = 0;
po.nbits = 8 * sizeof(po.tmpspace);
po.output = cb;
po.op_key = app_key;
po.flushed_bytes = 0;
er = td->op->aper_encoder(td, constraints, sptr, &po);
if(er.encoded != -1) {
size_t bits_to_flush;
bits_to_flush = ((po.buffer - po.tmpspace) << 3) + po.nboff;
/* Set number of bits encoded to a firm value */
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
if(_aper_encode_flush_outp(&po))
ASN__ENCODE_FAILED;
}
return er;
}
......@@ -28,6 +28,13 @@ asn_enc_rval_t uper_encode(
void *app_key /* Arbitrary callback argument */
);
asn_enc_rval_t aper_encode(
const struct asn_TYPE_descriptor_s *type_descriptor,
const void *struct_ptr, /* Structure to be encoded */
asn_app_consume_bytes_f *consume_bytes_cb, /* Data collector */
void *app_key /* Arbitrary callback argument */
);
/*
* A variant of uper_encode() which encodes data into the existing buffer
* WARNING: This function returns the number of encoded bits in the .encoded
......@@ -41,6 +48,12 @@ asn_enc_rval_t uper_encode_to_buffer(
size_t buffer_size /* Initial buffer size (max) */
);
asn_enc_rval_t aper_encode_to_buffer(
const struct asn_TYPE_descriptor_s *type_descriptor,
const void *struct_ptr, /* Structure to be encoded */
void *buffer, /* Pre-allocated buffer */
size_t buffer_size /* Initial buffer size (max) */
);
/*
* A variant of uper_encode_to_buffer() which allocates buffer itself.
* Returns the number of bytes in the buffer or -1 in case of failure.
......@@ -55,6 +68,14 @@ ssize_t uper_encode_to_new_buffer(
void **buffer_r /* Buffer allocated and returned */
);
ssize_t
aper_encode_to_new_buffer(
const struct asn_TYPE_descriptor_s *td,
const asn_per_constraints_t *constraints,
const void *sptr,
void **buffer_r
);
/*
* Type of the generic PER encoder function.
*/
......
......@@ -295,7 +295,7 @@ uper_sot_suck(const asn_codec_ctx_t *ctx, const asn_TYPE_descriptor_t *td,
(void)constraints;
(void)sptr;
while(per_get_few_bits(pd, 24) >= 0);
while(per_get_few_bits(pd, 1) >= 0);
rv.code = RC_OK;
rv.consumed = pd->moved;
......@@ -394,3 +394,139 @@ per_skip_bits(asn_per_data_t *pd, int skip_nbits) {
}
return hasNonZeroBits;
}
static asn_dec_rval_t
aper_open_type_get_simple(const asn_codec_ctx_t *ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rv;
ssize_t chunk_bytes;
int repeat;
uint8_t *buf = 0;
size_t bufLen = 0;
size_t bufSize = 0;
asn_per_data_t spd;
size_t padding;
ASN__STACK_OVERFLOW_CHECK(ctx);
ASN_DEBUG("Getting open type %s...", td->name);
do {
chunk_bytes = aper_get_length(pd, -1, -1, &repeat);
if(chunk_bytes < 0) {
FREEMEM(buf);
ASN__DECODE_STARVED;
}
if(bufLen + chunk_bytes > bufSize) {
void *ptr;
bufSize = chunk_bytes + (bufSize << 2);
ptr = REALLOC(buf, bufSize);
if(!ptr) {
FREEMEM(buf);
ASN__DECODE_FAILED;
}
buf = ptr;
}
if(per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) {
FREEMEM(buf);
ASN__DECODE_STARVED;
}
bufLen += chunk_bytes;
} while(repeat);
ASN_DEBUG("Getting open type %s encoded in %ld bytes", td->name,
(long)bufLen);
memset(&spd, 0, sizeof(spd));
spd.buffer = buf;
spd.nbits = bufLen << 3;
ASN_DEBUG_INDENT_ADD(+4);
rv = td->op->aper_decoder(ctx, td, constraints, sptr, &spd);
ASN_DEBUG_INDENT_ADD(-4);
if(rv.code == RC_OK) {
/* Check padding validity */
padding = spd.nbits - spd.nboff;
if ((padding < 8 ||
/* X.691#10.1.3 */
(spd.nboff == 0 && spd.nbits == 8 && spd.buffer == buf)) &&
per_get_few_bits(&spd, padding) == 0) {
/* Everything is cool */
FREEMEM(buf);
return rv;
}
FREEMEM(buf);
if(padding >= 8) {
ASN_DEBUG("Too large padding %d in open type", (int)padding);
ASN__DECODE_FAILED;
} else {
ASN_DEBUG("Non-zero padding");
ASN__DECODE_FAILED;
}
} else {
FREEMEM(buf);
/* rv.code could be RC_WMORE, nonsense in this context */
rv.code = RC_FAIL; /* Noone would give us more */
}
return rv;
}
int
aper_open_type_put(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po) {
void *buf;
void *bptr;
ssize_t size;
size_t toGo;
ASN_DEBUG("Open type put %s ...", td->name);
size = aper_encode_to_new_buffer(td, constraints, sptr, &buf);
if(size <= 0) return -1;
for(bptr = buf, toGo = size; toGo;) {
ssize_t maySave = aper_put_length(po, -1, toGo);
if(maySave < 0) break;
if(per_put_many_bits(po, bptr, maySave * 8)) break;
bptr = (char *)bptr + maySave;
toGo -= maySave;
}
FREEMEM(buf);
if(toGo) return -1;
ASN_DEBUG("Open type put %s of length %ld + overhead (1byte?)",
td->name, size);
return 0;
}
asn_dec_rval_t
aper_open_type_get(const asn_codec_ctx_t *ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
void **sptr, asn_per_data_t *pd) {
return aper_open_type_get_simple(ctx, td, constraints, sptr, pd);
}
int
aper_open_type_skip(const asn_codec_ctx_t *ctx, asn_per_data_t *pd) {
asn_TYPE_descriptor_t s_td;
asn_dec_rval_t rv;
s_td.name = "<unknown extension>";
s_td.op->aper_decoder = uper_sot_suck;
rv = aper_open_type_get(ctx, &s_td, 0, 0, pd);
if(rv.code != RC_OK)
return -1;
else
return 0;
}
......@@ -25,6 +25,18 @@ int uper_open_type_put(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po);
asn_dec_rval_t aper_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
void **sptr, asn_per_data_t *pd);
int aper_open_type_skip(const asn_codec_ctx_t *opt_codec_ctx, asn_per_data_t *pd);
int aper_open_type_put(const asn_TYPE_descriptor_t *td,
const asn_per_constraints_t *constraints,
const void *sptr, asn_per_outp_t *po);
#ifdef __cplusplus
}
#endif
......
......@@ -293,3 +293,197 @@ per_long_range_unrebase(unsigned long inp, long lb, long ub, long *outp) {
return 0;
}
int32_t
aper_get_align(asn_per_data_t *pd) {
if(pd->nboff & 0x7) {
ASN_DEBUG("Aligning %ld bits", 8 - ((unsigned long)pd->nboff & 0x7));
return per_get_few_bits(pd, 8 - (pd->nboff & 0x7));
}
return 0;
}
ssize_t
aper_get_length(asn_per_data_t *pd, int range, int ebits, int *repeat) {
ssize_t value;
*repeat = 0;
if (range <= 65536 && range >= 0)
return aper_get_nsnnwn(pd, range);
if (aper_get_align(pd) < 0)
return -1;
if(ebits >= 0) return per_get_few_bits(pd, ebits);
value = per_get_few_bits(pd, 8);
if(value < 0) return -1;
if((value & 128) == 0) /* #10.9.3.6 */
return (value & 0x7F);
if((value & 64) == 0) { /* #10.9.3.7 */
value = ((value & 63) << 8) | per_get_few_bits(pd, 8);
if(value < 0) return -1;
return value;
}
value &= 63; /* this is "m" from X.691, #10.9.3.8 */
if(value < 1 || value > 4)
return -1;
*repeat = 1;
return (16384 * value);
}
ssize_t
aper_get_nslength(asn_per_data_t *pd) {
ssize_t length;
ASN_DEBUG("Getting normally small length");
if(per_get_few_bits(pd, 1) == 0) {
length = per_get_few_bits(pd, 6) + 1;
if(length <= 0) return -1;
ASN_DEBUG("l=%ld", length);
return length;
} else {
int repeat;
length = aper_get_length(pd, -1, -1, &repeat);
if(length >= 0 && !repeat) return length;
return -1; /* Error, or do not support >16K extensions */
}
}
ssize_t
aper_get_nsnnwn(asn_per_data_t *pd, int range) {
ssize_t value;
int bytes = 0;
ASN_DEBUG("getting nsnnwn with range %d", range);
if(range <= 255) {
int i;
if (range < 0) return -1;
/* 1 -> 8 bits */
for (i = 1; i <= 8; i++) {
int upper = 1 << i;
if (upper >= range)
break;
}
value = per_get_few_bits(pd, i);
return value;
} else if (range == 256){
/* 1 byte */
bytes = 1;
} else if (range <= 65536) {
/* 2 bytes */
bytes = 2;
} else {
return -1;
}
if (aper_get_align(pd) < 0)
return -1;
value = per_get_few_bits(pd, 8 * bytes);
return value;
}
int aper_put_align(asn_per_outp_t *po) {
if(po->nboff & 0x7) {
ASN_DEBUG("Aligning %ld bits", 8 - ((unsigned long)po->nboff & 0x7));
if(per_put_few_bits(po, 0x00, (8 - (po->nboff & 0x7))))
return -1;
}
return 0;
}
ssize_t
aper_put_length(asn_per_outp_t *po, int range, size_t length) {
ASN_DEBUG("APER put length %zu with range %d", length, range);
/* 10.9 X.691 Note 2 */
if (range <= 65536 && range >= 0)
return aper_put_nsnnwn(po, range, length);
if (aper_put_align(po) < 0)
return -1;
if(length <= 127) /* #10.9.3.6 */{
return per_put_few_bits(po, length, 8)
? -1 : (ssize_t)length;
}
else if(length < 16384) /* #10.9.3.7 */
return per_put_few_bits(po, length|0x8000, 16)
? -1 : (ssize_t)length;
length >>= 14;
if(length > 4) length = 4;
return per_put_few_bits(po, 0xC0 | length, 8)
? -1 : (ssize_t)(length << 14);
}
int
aper_put_nslength(asn_per_outp_t *po, size_t length) {
if(length <= 64) {
/* #10.9.3.4 */
if(length == 0) return -1;
return per_put_few_bits(po, length-1, 7) ? -1 : 0;
} else {
if(aper_put_length(po, -1, length) != (ssize_t)length) {
/* This might happen in case of >16K extensions */
return -1;
}
}
return 0;
}
int
aper_put_nsnnwn(asn_per_outp_t *po, int range, int number) {
int bytes;
ASN_DEBUG("aper put nsnnwn %d with range %d", number, range);
/* 10.5.7.1 X.691 */
if(range < 0) {
int i;
for (i = 1; ; i++) {
int bits = 1 << (8 * i);
if (number <= bits)
break;
}
bytes = i;
assert(i <= 4);
}
if(range <= 255) {
int i;
for (i = 1; i <= 8; i++) {
int bits = 1 << i;
if (range <= bits)
break;
}
return per_put_few_bits(po, number, i);
} else if(range == 256) {
bytes = 1;
} else if(range <= 65536) {
bytes = 2;
} else { /* Ranges > 64K */
int i;
for (i = 1; ; i++) {
int bits = 1 << (8 * i);
if (range <= bits)
break;
}
assert(i <= 4);
bytes = i;
}
if(aper_put_align(po) < 0) /* Aligning on octet */
return -1;
/* if(per_put_few_bits(po, bytes, 8))
return -1;
*/
return per_put_few_bits(po, number, 8 * bytes);
}
......@@ -48,15 +48,20 @@ typedef struct asn_bit_data_s asn_per_data_t;
ssize_t uper_get_length(asn_per_data_t *pd, int effective_bound_bits,
size_t lower_bound, int *repeat);
ssize_t aper_get_length(asn_per_data_t *pd, int range,
int effective_bound_bits, int *repeat);
/*
* Get the normally small length "n".
*/
ssize_t uper_get_nslength(asn_per_data_t *pd);
ssize_t aper_get_nslength(asn_per_data_t *pd);
/*
* Get the normally small non-negative whole number.
*/
ssize_t uper_get_nsnnwn(asn_per_data_t *pd);
ssize_t aper_get_nsnnwn(asn_per_data_t *pd, int range);
/* X.691-2008/11, #11.5.6 */
int uper_get_constrained_whole_number(asn_per_data_t *pd, unsigned long *v, int nbits);
......@@ -94,17 +99,27 @@ int uper_put_constrained_whole_number_u(asn_per_outp_t *po, unsigned long v, int
ssize_t uper_put_length(asn_per_outp_t *po, size_t whole_length,
int *opt_need_eom);
ssize_t aper_put_length(asn_per_outp_t *po, int range, size_t length);
/* Align the current bit position to octet bundary */
int aper_put_align(asn_per_outp_t *po);
int32_t aper_get_align(asn_per_data_t *pd);
/*
* Put the normally small length "n" to the Unaligned PER stream.
* Returns 0 or -1.
*/
int uper_put_nslength(asn_per_outp_t *po, size_t length);
int aper_put_nslength(asn_per_outp_t *po, size_t length);
/*
* Put the normally small non-negative whole number.
*/
int uper_put_nsnnwn(asn_per_outp_t *po, int n);
int aper_put_nsnnwn(asn_per_outp_t *po, int range, int number);
#ifdef __cplusplus
}
#endif
......
......@@ -20,6 +20,8 @@ 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;
per_type_decoder_f Short_decode_aper;
per_type_encoder_f Short_encode_aper;
/*** <<< CODE [Short] >>> ***/
......@@ -103,6 +105,8 @@ 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;
per_type_decoder_f Alias_decode_aper;
per_type_encoder_f Alias_encode_aper;
/*** <<< CODE [Alias] >>> ***/
......
......@@ -19,6 +19,8 @@ xer_type_decoder_f UnconstrainedREAL_decode_xer;
xer_type_encoder_f UnconstrainedREAL_encode_xer;
per_type_decoder_f UnconstrainedREAL_decode_uper;
per_type_encoder_f UnconstrainedREAL_encode_uper;
per_type_decoder_f UnconstrainedREAL_decode_aper;
per_type_encoder_f UnconstrainedREAL_encode_aper;
/*** <<< CODE [UnconstrainedREAL] >>> ***/
......@@ -68,6 +70,8 @@ xer_type_decoder_f WeirdlyConstrainedREAL_decode_xer;
xer_type_encoder_f WeirdlyConstrainedREAL_encode_xer;
per_type_decoder_f WeirdlyConstrainedREAL_decode_uper;
per_type_encoder_f WeirdlyConstrainedREAL_encode_uper;
per_type_decoder_f WeirdlyConstrainedREAL_decode_aper;
per_type_encoder_f WeirdlyConstrainedREAL_encode_aper;
/*** <<< CODE [WeirdlyConstrainedREAL] >>> ***/
......@@ -152,6 +156,8 @@ xer_type_decoder_f Indirect_IEEE_binary32_decode_xer;
xer_type_encoder_f Indirect_IEEE_binary32_encode_xer;
per_type_decoder_f Indirect_IEEE_binary32_decode_uper;
per_type_encoder_f Indirect_IEEE_binary32_encode_uper;
per_type_decoder_f Indirect_IEEE_binary32_decode_aper;
per_type_encoder_f Indirect_IEEE_binary32_encode_aper;
/*** <<< CODE [Indirect-IEEE-binary32] >>> ***/
......@@ -233,6 +239,8 @@ xer_type_decoder_f IEEE_binary32_w_decode_xer;
xer_type_encoder_f IEEE_binary32_w_encode_xer;
per_type_decoder_f IEEE_binary32_w_decode_uper;
per_type_encoder_f IEEE_binary32_w_encode_uper;
per_type_decoder_f IEEE_binary32_w_decode_aper;
per_type_encoder_f IEEE_binary32_w_encode_aper;
/*** <<< CODE [IEEE-binary32-w] >>> ***/
......@@ -314,6 +322,8 @@ xer_type_decoder_f IEEE_binary32_0w_decode_xer;
xer_type_encoder_f IEEE_binary32_0w_encode_xer;
per_type_decoder_f IEEE_binary32_0w_decode_uper;
per_type_encoder_f IEEE_binary32_0w_encode_uper;
per_type_decoder_f IEEE_binary32_0w_decode_aper;
per_type_encoder_f IEEE_binary32_0w_encode_aper;
/*** <<< CODE [IEEE-binary32-0w] >>> ***/
......@@ -395,6 +405,8 @@ xer_type_decoder_f IEEE_binary32_w0_decode_xer;
xer_type_encoder_f IEEE_binary32_w0_encode_xer;
per_type_decoder_f IEEE_binary32_w0_decode_uper;
per_type_encoder_f IEEE_binary32_w0_encode_uper;
per_type_decoder_f IEEE_binary32_w0_decode_aper;
per_type_encoder_f IEEE_binary32_w0_encode_aper;
/*** <<< CODE [IEEE-binary32-w0] >>> ***/
......@@ -475,6 +487,8 @@ xer_type_decoder_f IEEE_binary64_w_decode_xer;
xer_type_encoder_f IEEE_binary64_w_encode_xer;
per_type_decoder_f IEEE_binary64_w_decode_uper;
per_type_encoder_f IEEE_binary64_w_encode_uper;
per_type_decoder_f IEEE_binary64_w_decode_aper;
per_type_encoder_f IEEE_binary64_w_encode_aper;
/*** <<< CODE [IEEE-binary64-w] >>> ***/
......@@ -552,6 +566,8 @@ xer_type_decoder_f IEEE_binary64_0w_decode_xer;
xer_type_encoder_f IEEE_binary64_0w_encode_xer;
per_type_decoder_f IEEE_binary64_0w_decode_uper;
per_type_encoder_f IEEE_binary64_0w_encode_uper;
per_type_decoder_f IEEE_binary64_0w_decode_aper;
per_type_encoder_f IEEE_binary64_0w_encode_aper;
/*** <<< CODE [IEEE-binary64-0w] >>> ***/
......@@ -629,6 +645,8 @@ xer_type_decoder_f IEEE_binary64_w0_decode_xer;
xer_type_encoder_f IEEE_binary64_w0_encode_xer;
per_type_decoder_f IEEE_binary64_w0_decode_uper;
per_type_encoder_f IEEE_binary64_w0_encode_uper;
per_type_decoder_f IEEE_binary64_w0_decode_aper;
per_type_encoder_f IEEE_binary64_w0_encode_aper;
/*** <<< CODE [IEEE-binary64-w0] >>> ***/
......
......@@ -20,6 +20,8 @@ xer_type_decoder_f PacketId_decode_xer;
xer_type_encoder_f PacketId_encode_xer;
per_type_decoder_f PacketId_decode_uper;
per_type_encoder_f PacketId_encode_uper;
per_type_decoder_f PacketId_decode_aper;
per_type_encoder_f PacketId_encode_aper;
/*** <<< CODE [PacketId] >>> ***/
......@@ -112,6 +114,8 @@ xer_type_decoder_f Color_decode_xer;
xer_type_encoder_f Color_encode_xer;
per_type_decoder_f Color_decode_uper;
per_type_encoder_f Color_encode_uper;
per_type_decoder_f Color_decode_aper;
per_type_encoder_f Color_encode_aper;
/*** <<< CODE [Color] >>> ***/
......@@ -197,6 +201,8 @@ xer_type_decoder_f Valid_decode_xer;
xer_type_encoder_f Valid_encode_xer;
per_type_decoder_f Valid_decode_uper;
per_type_encoder_f Valid_encode_uper;
per_type_decoder_f Valid_decode_aper;
per_type_encoder_f Valid_encode_aper;
/*** <<< CODE [Valid] >>> ***/
......@@ -271,6 +277,8 @@ xer_type_decoder_f Packet_List_decode_xer;
xer_type_encoder_f Packet_List_encode_xer;
per_type_decoder_f Packet_List_decode_uper;
per_type_encoder_f Packet_List_encode_uper;
per_type_decoder_f Packet_List_decode_aper;
per_type_encoder_f Packet_List_encode_aper;
/*** <<< CODE [Packet-List] >>> ***/
......@@ -356,6 +364,8 @@ xer_type_decoder_f UpperLayer_List_41P0_decode_xer;
xer_type_encoder_f UpperLayer_List_41P0_encode_xer;
per_type_decoder_f UpperLayer_List_41P0_decode_uper;
per_type_encoder_f UpperLayer_List_41P0_encode_uper;
per_type_decoder_f UpperLayer_List_41P0_decode_aper;
per_type_encoder_f UpperLayer_List_41P0_encode_aper;
/*** <<< CODE [UpperLayer-List] >>> ***/
......@@ -515,6 +525,8 @@ xer_type_decoder_f SinglePacket_48P0_decode_xer;
xer_type_encoder_f SinglePacket_48P0_encode_xer;
per_type_decoder_f SinglePacket_48P0_decode_uper;
per_type_encoder_f SinglePacket_48P0_encode_uper;
per_type_decoder_f SinglePacket_48P0_decode_aper;
per_type_encoder_f SinglePacket_48P0_encode_aper;
/*** <<< CODE [SinglePacket] >>> ***/
......
......@@ -19,6 +19,8 @@ xer_type_decoder_f Int1_decode_xer;
xer_type_encoder_f Int1_encode_xer;
per_type_decoder_f Int1_decode_uper;
per_type_encoder_f Int1_encode_uper;
per_type_decoder_f Int1_decode_aper;
per_type_encoder_f Int1_encode_aper;
/*** <<< CODE [Int1] >>> ***/
......@@ -69,6 +71,8 @@ xer_type_decoder_f Int2_decode_xer;
xer_type_encoder_f Int2_encode_xer;
per_type_decoder_f Int2_decode_uper;
per_type_encoder_f Int2_encode_uper;
per_type_decoder_f Int2_decode_aper;
per_type_encoder_f Int2_encode_aper;
/*** <<< CODE [Int2] >>> ***/
......@@ -149,6 +153,8 @@ xer_type_decoder_f Int3_decode_xer;
xer_type_encoder_f Int3_encode_xer;
per_type_decoder_f Int3_decode_uper;
per_type_encoder_f Int3_encode_uper;
per_type_decoder_f Int3_decode_aper;
per_type_encoder_f Int3_encode_aper;
/*** <<< CODE [Int3] >>> ***/
......@@ -232,6 +238,8 @@ xer_type_decoder_f Int4_decode_xer;
xer_type_encoder_f Int4_encode_xer;
per_type_decoder_f Int4_decode_uper;
per_type_encoder_f Int4_encode_uper;
per_type_decoder_f Int4_decode_aper;
per_type_encoder_f Int4_encode_aper;
/*** <<< CODE [Int4] >>> ***/
......@@ -315,6 +323,8 @@ xer_type_decoder_f Int5_decode_xer;
xer_type_encoder_f Int5_encode_xer;
per_type_decoder_f Int5_decode_uper;
per_type_encoder_f Int5_encode_uper;
per_type_decoder_f Int5_decode_aper;
per_type_encoder_f Int5_encode_aper;
/*** <<< CODE [Int5] >>> ***/
......@@ -397,6 +407,8 @@ xer_type_decoder_f ExtensibleExtensions_decode_xer;
xer_type_encoder_f ExtensibleExtensions_encode_xer;
per_type_decoder_f ExtensibleExtensions_decode_uper;
per_type_encoder_f ExtensibleExtensions_encode_uper;
per_type_decoder_f ExtensibleExtensions_decode_aper;
per_type_encoder_f ExtensibleExtensions_encode_aper;
/*** <<< CODE [ExtensibleExtensions] >>> ***/
......@@ -480,6 +492,8 @@ xer_type_decoder_f Str1_decode_xer;
xer_type_encoder_f Str1_encode_xer;
per_type_decoder_f Str1_decode_uper;
per_type_encoder_f Str1_encode_uper;
per_type_decoder_f Str1_decode_aper;
per_type_encoder_f Str1_encode_aper;
/*** <<< CODE [Str1] >>> ***/
......@@ -538,6 +552,8 @@ xer_type_decoder_f Str2_decode_xer;
xer_type_encoder_f Str2_encode_xer;
per_type_decoder_f Str2_decode_uper;
per_type_encoder_f Str2_encode_uper;
per_type_decoder_f Str2_decode_aper;
per_type_encoder_f Str2_encode_aper;
/*** <<< CTABLES [Str2] >>> ***/
......@@ -638,6 +654,8 @@ xer_type_decoder_f Str3_decode_xer;
xer_type_encoder_f Str3_encode_xer;
per_type_decoder_f Str3_decode_uper;
per_type_encoder_f Str3_encode_uper;
per_type_decoder_f Str3_decode_aper;
per_type_encoder_f Str3_encode_aper;
/*** <<< CTABLES [Str3] >>> ***/
......@@ -763,6 +781,8 @@ xer_type_decoder_f Str4_decode_xer;
xer_type_encoder_f Str4_encode_xer;
per_type_decoder_f Str4_decode_uper;
per_type_encoder_f Str4_encode_uper;
per_type_decoder_f Str4_decode_aper;
per_type_encoder_f Str4_encode_aper;
/*** <<< CTABLES [Str4] >>> ***/
......@@ -861,6 +881,8 @@ xer_type_decoder_f PER_Visible_decode_xer;
xer_type_encoder_f PER_Visible_encode_xer;
per_type_decoder_f PER_Visible_decode_uper;
per_type_encoder_f PER_Visible_encode_uper;
per_type_decoder_f PER_Visible_decode_aper;
per_type_encoder_f PER_Visible_encode_aper;
/*** <<< CTABLES [PER-Visible] >>> ***/
......@@ -958,6 +980,8 @@ xer_type_decoder_f PER_Visible_2_decode_xer;
xer_type_encoder_f PER_Visible_2_encode_xer;
per_type_decoder_f PER_Visible_2_decode_uper;
per_type_encoder_f PER_Visible_2_encode_uper;
per_type_decoder_f PER_Visible_2_decode_aper;
per_type_encoder_f PER_Visible_2_encode_aper;
/*** <<< CTABLES [PER-Visible-2] >>> ***/
......@@ -1055,6 +1079,8 @@ xer_type_decoder_f Not_PER_Visible_1_decode_xer;
xer_type_encoder_f Not_PER_Visible_1_encode_xer;
per_type_decoder_f Not_PER_Visible_1_decode_uper;
per_type_encoder_f Not_PER_Visible_1_encode_uper;
per_type_decoder_f Not_PER_Visible_1_decode_aper;
per_type_encoder_f Not_PER_Visible_1_encode_aper;
/*** <<< CTABLES [Not-PER-Visible-1] >>> ***/
......@@ -1152,6 +1178,8 @@ xer_type_decoder_f Not_PER_Visible_2_decode_xer;
xer_type_encoder_f Not_PER_Visible_2_encode_xer;
per_type_decoder_f Not_PER_Visible_2_decode_uper;
per_type_encoder_f Not_PER_Visible_2_encode_uper;
per_type_decoder_f Not_PER_Visible_2_decode_aper;
per_type_encoder_f Not_PER_Visible_2_encode_aper;
/*** <<< CTABLES [Not-PER-Visible-2] >>> ***/
......@@ -1249,6 +1277,8 @@ xer_type_decoder_f Not_PER_Visible_3_decode_xer;
xer_type_encoder_f Not_PER_Visible_3_encode_xer;
per_type_decoder_f Not_PER_Visible_3_decode_uper;
per_type_encoder_f Not_PER_Visible_3_encode_uper;
per_type_decoder_f Not_PER_Visible_3_decode_aper;
per_type_encoder_f Not_PER_Visible_3_encode_aper;
/*** <<< CTABLES [Not-PER-Visible-3] >>> ***/
......@@ -1346,6 +1376,8 @@ xer_type_decoder_f SIZE_but_not_FROM_decode_xer;
xer_type_encoder_f SIZE_but_not_FROM_encode_xer;
per_type_decoder_f SIZE_but_not_FROM_decode_uper;
per_type_encoder_f SIZE_but_not_FROM_encode_uper;
per_type_decoder_f SIZE_but_not_FROM_decode_aper;
per_type_encoder_f SIZE_but_not_FROM_encode_aper;
/*** <<< CTABLES [SIZE-but-not-FROM] >>> ***/
......@@ -1446,6 +1478,8 @@ xer_type_decoder_f SIZE_and_FROM_decode_xer;
xer_type_encoder_f SIZE_and_FROM_encode_xer;
per_type_decoder_f SIZE_and_FROM_decode_uper;
per_type_encoder_f SIZE_and_FROM_encode_uper;
per_type_decoder_f SIZE_and_FROM_decode_aper;
per_type_encoder_f SIZE_and_FROM_encode_aper;
/*** <<< CTABLES [SIZE-and-FROM] >>> ***/
......@@ -1546,6 +1580,8 @@ xer_type_decoder_f Neither_SIZE_nor_FROM_decode_xer;
xer_type_encoder_f Neither_SIZE_nor_FROM_encode_xer;
per_type_decoder_f Neither_SIZE_nor_FROM_decode_uper;
per_type_encoder_f Neither_SIZE_nor_FROM_encode_uper;
per_type_decoder_f Neither_SIZE_nor_FROM_decode_aper;
per_type_encoder_f Neither_SIZE_nor_FROM_encode_aper;
/*** <<< CTABLES [Neither-SIZE-nor-FROM] >>> ***/
......@@ -1643,6 +1679,8 @@ xer_type_decoder_f Utf8_4_decode_xer;
xer_type_encoder_f Utf8_4_encode_xer;
per_type_decoder_f Utf8_4_decode_uper;
per_type_encoder_f Utf8_4_encode_uper;
per_type_decoder_f Utf8_4_decode_aper;
per_type_encoder_f Utf8_4_encode_aper;
/*** <<< CTABLES [Utf8-4] >>> ***/
......@@ -1734,6 +1772,8 @@ xer_type_decoder_f Utf8_3_decode_xer;
xer_type_encoder_f Utf8_3_encode_xer;
per_type_decoder_f Utf8_3_decode_uper;
per_type_encoder_f Utf8_3_encode_uper;
per_type_decoder_f Utf8_3_decode_aper;
per_type_encoder_f Utf8_3_encode_aper;
/*** <<< CTABLES [Utf8-3] >>> ***/
......@@ -1854,6 +1894,8 @@ xer_type_decoder_f Utf8_2_decode_xer;
xer_type_encoder_f Utf8_2_encode_xer;
per_type_decoder_f Utf8_2_decode_uper;
per_type_encoder_f Utf8_2_encode_uper;
per_type_decoder_f Utf8_2_decode_aper;
per_type_encoder_f Utf8_2_encode_aper;
/*** <<< CODE [Utf8-2] >>> ***/
......@@ -1943,6 +1985,8 @@ xer_type_decoder_f Utf8_1_decode_xer;
xer_type_encoder_f Utf8_1_encode_xer;
per_type_decoder_f Utf8_1_decode_uper;
per_type_encoder_f Utf8_1_encode_uper;
per_type_decoder_f Utf8_1_decode_aper;
per_type_encoder_f Utf8_1_encode_aper;
/*** <<< CODE [Utf8-1] >>> ***/
......@@ -1992,6 +2036,8 @@ xer_type_decoder_f VisibleIdentifier_decode_xer;
xer_type_encoder_f VisibleIdentifier_encode_xer;
per_type_decoder_f VisibleIdentifier_decode_uper;
per_type_encoder_f VisibleIdentifier_encode_uper;
per_type_decoder_f VisibleIdentifier_decode_aper;
per_type_encoder_f VisibleIdentifier_encode_aper;
/*** <<< CTABLES [VisibleIdentifier] >>> ***/
......@@ -2545,6 +2591,8 @@ xer_type_decoder_f Enum0_decode_xer;
xer_type_encoder_f Enum0_encode_xer;
per_type_decoder_f Enum0_decode_uper;
per_type_encoder_f Enum0_encode_uper;
per_type_decoder_f Enum0_decode_aper;
per_type_encoder_f Enum0_encode_aper;
/*** <<< CODE [Enum0] >>> ***/
......@@ -2626,6 +2674,8 @@ xer_type_decoder_f Enum1_decode_xer;
xer_type_encoder_f Enum1_encode_xer;
per_type_decoder_f Enum1_decode_uper;
per_type_encoder_f Enum1_encode_uper;
per_type_decoder_f Enum1_decode_aper;
per_type_encoder_f Enum1_encode_aper;
/*** <<< CODE [Enum1] >>> ***/
......@@ -2726,6 +2776,8 @@ xer_type_decoder_f Identifier_decode_xer;
xer_type_encoder_f Identifier_encode_xer;
per_type_decoder_f Identifier_decode_uper;
per_type_encoder_f Identifier_encode_uper;
per_type_decoder_f Identifier_decode_aper;
per_type_encoder_f Identifier_encode_aper;
/*** <<< CTABLES [Identifier] >>> ***/
......
......@@ -19,6 +19,8 @@ xer_type_decoder_f CN_IntegerUnlimited_decode_xer;
xer_type_encoder_f CN_IntegerUnlimited_encode_xer;
per_type_decoder_f CN_IntegerUnlimited_decode_uper;
per_type_encoder_f CN_IntegerUnlimited_encode_uper;
per_type_decoder_f CN_IntegerUnlimited_decode_aper;
per_type_encoder_f CN_IntegerUnlimited_encode_aper;
/*** <<< CODE [CN-IntegerUnlimited] >>> ***/
......@@ -68,6 +70,8 @@ xer_type_decoder_f CN_IntegerMinMax_decode_xer;
xer_type_encoder_f CN_IntegerMinMax_encode_xer;
per_type_decoder_f CN_IntegerMinMax_decode_uper;
per_type_encoder_f CN_IntegerMinMax_encode_uper;
per_type_decoder_f CN_IntegerMinMax_decode_aper;
per_type_encoder_f CN_IntegerMinMax_encode_aper;
/*** <<< CODE [CN-IntegerMinMax] >>> ***/
......@@ -144,6 +148,8 @@ xer_type_decoder_f CN_IntegerMinLow_decode_xer;
xer_type_encoder_f CN_IntegerMinLow_encode_xer;
per_type_decoder_f CN_IntegerMinLow_decode_uper;
per_type_encoder_f CN_IntegerMinLow_encode_uper;
per_type_decoder_f CN_IntegerMinLow_decode_aper;
per_type_encoder_f CN_IntegerMinLow_encode_aper;
/*** <<< CODE [CN-IntegerMinLow] >>> ***/
......@@ -226,6 +232,8 @@ xer_type_decoder_f NO_IntegerMinHigh_decode_xer;
xer_type_encoder_f NO_IntegerMinHigh_encode_xer;
per_type_decoder_f NO_IntegerMinHigh_decode_uper;
per_type_encoder_f NO_IntegerMinHigh_encode_uper;
per_type_decoder_f NO_IntegerMinHigh_decode_aper;
per_type_encoder_f NO_IntegerMinHigh_encode_aper;
/*** <<< CODE [NO-IntegerMinHigh] >>> ***/
......@@ -314,6 +322,8 @@ xer_type_decoder_f NO_IntegerLowHigh_decode_xer;
xer_type_encoder_f NO_IntegerLowHigh_encode_xer;
per_type_decoder_f NO_IntegerLowHigh_decode_uper;
per_type_encoder_f NO_IntegerLowHigh_encode_uper;
per_type_decoder_f NO_IntegerLowHigh_decode_aper;
per_type_encoder_f NO_IntegerLowHigh_encode_aper;
/*** <<< CODE [NO-IntegerLowHigh] >>> ***/
......@@ -401,6 +411,8 @@ xer_type_decoder_f CN_IntegerLowMax_decode_xer;
xer_type_encoder_f CN_IntegerLowMax_encode_xer;
per_type_decoder_f CN_IntegerLowMax_decode_uper;
per_type_encoder_f CN_IntegerLowMax_encode_uper;
per_type_decoder_f CN_IntegerLowMax_decode_aper;
per_type_encoder_f CN_IntegerLowMax_encode_aper;
/*** <<< CODE [CN-IntegerLowMax] >>> ***/
......@@ -488,6 +500,8 @@ xer_type_decoder_f NO_IntegerHighMax_decode_xer;
xer_type_encoder_f NO_IntegerHighMax_encode_xer;
per_type_decoder_f NO_IntegerHighMax_decode_uper;
per_type_encoder_f NO_IntegerHighMax_encode_uper;
per_type_decoder_f NO_IntegerHighMax_decode_aper;
per_type_encoder_f NO_IntegerHighMax_encode_aper;
/*** <<< CODE [NO-IntegerHighMax] >>> ***/
......@@ -576,6 +590,8 @@ xer_type_decoder_f NO_IntegerLowestMax_decode_xer;
xer_type_encoder_f NO_IntegerLowestMax_encode_xer;
per_type_decoder_f NO_IntegerLowestMax_decode_uper;
per_type_encoder_f NO_IntegerLowestMax_encode_uper;
per_type_decoder_f NO_IntegerLowestMax_decode_aper;
per_type_encoder_f NO_IntegerLowestMax_encode_aper;
/*** <<< CODE [NO-IntegerLowestMax] >>> ***/
......@@ -664,6 +680,8 @@ xer_type_decoder_f NO_IntegerOutRange_decode_xer;
xer_type_encoder_f NO_IntegerOutRange_encode_xer;
per_type_decoder_f NO_IntegerOutRange_decode_uper;
per_type_encoder_f NO_IntegerOutRange_encode_uper;
per_type_decoder_f NO_IntegerOutRange_decode_aper;
per_type_encoder_f NO_IntegerOutRange_encode_aper;
/*** <<< CODE [NO-IntegerOutRange] >>> ***/
......@@ -751,6 +769,8 @@ xer_type_decoder_f NO_IntegerOutValue_decode_xer;
xer_type_encoder_f NO_IntegerOutValue_encode_xer;
per_type_decoder_f NO_IntegerOutValue_decode_uper;
per_type_encoder_f NO_IntegerOutValue_encode_uper;
per_type_decoder_f NO_IntegerOutValue_decode_aper;
per_type_encoder_f NO_IntegerOutValue_encode_aper;
/*** <<< CODE [NO-IntegerOutValue] >>> ***/
......@@ -838,6 +858,8 @@ xer_type_decoder_f OK_IntegerInRange1_decode_xer;
xer_type_encoder_f OK_IntegerInRange1_encode_xer;
per_type_decoder_f OK_IntegerInRange1_decode_uper;
per_type_encoder_f OK_IntegerInRange1_encode_uper;
per_type_decoder_f OK_IntegerInRange1_decode_aper;
per_type_encoder_f OK_IntegerInRange1_encode_aper;
/*** <<< CODE [OK-IntegerInRange1] >>> ***/
......@@ -920,6 +942,8 @@ xer_type_decoder_f OK_IntegerInRange2_decode_xer;
xer_type_encoder_f OK_IntegerInRange2_encode_xer;
per_type_decoder_f OK_IntegerInRange2_decode_uper;
per_type_encoder_f OK_IntegerInRange2_encode_uper;
per_type_decoder_f OK_IntegerInRange2_decode_aper;
per_type_encoder_f OK_IntegerInRange2_encode_aper;
/*** <<< CODE [OK-IntegerInRange2] >>> ***/
......@@ -1002,6 +1026,8 @@ xer_type_decoder_f OK_IntegerInRange3_decode_xer;
xer_type_encoder_f OK_IntegerInRange3_encode_xer;
per_type_decoder_f OK_IntegerInRange3_decode_uper;
per_type_encoder_f OK_IntegerInRange3_encode_uper;
per_type_decoder_f OK_IntegerInRange3_decode_aper;
per_type_encoder_f OK_IntegerInRange3_encode_aper;
/*** <<< CODE [OK-IntegerInRange3] >>> ***/
......@@ -1084,6 +1110,8 @@ xer_type_decoder_f OK_IntegerInRange4_decode_xer;
xer_type_encoder_f OK_IntegerInRange4_encode_xer;
per_type_decoder_f OK_IntegerInRange4_decode_uper;
per_type_encoder_f OK_IntegerInRange4_encode_uper;
per_type_decoder_f OK_IntegerInRange4_decode_aper;
per_type_encoder_f OK_IntegerInRange4_encode_aper;
/*** <<< CODE [OK-IntegerInRange4] >>> ***/
......@@ -1166,6 +1194,8 @@ xer_type_decoder_f OK_IntegerInRange5_decode_xer;
xer_type_encoder_f OK_IntegerInRange5_encode_xer;
per_type_decoder_f OK_IntegerInRange5_decode_uper;
per_type_encoder_f OK_IntegerInRange5_encode_uper;
per_type_decoder_f OK_IntegerInRange5_decode_aper;
per_type_encoder_f OK_IntegerInRange5_encode_aper;
/*** <<< CODE [OK-IntegerInRange5] >>> ***/
......@@ -1248,6 +1278,8 @@ xer_type_decoder_f NO_IntegerInRange6_decode_xer;
xer_type_encoder_f NO_IntegerInRange6_encode_xer;
per_type_decoder_f NO_IntegerInRange6_decode_uper;
per_type_encoder_f NO_IntegerInRange6_encode_uper;
per_type_decoder_f NO_IntegerInRange6_decode_aper;
per_type_encoder_f NO_IntegerInRange6_encode_aper;
/*** <<< CODE [NO-IntegerInRange6] >>> ***/
......@@ -1333,6 +1365,8 @@ xer_type_decoder_f CN_IntegerEnumerated1_decode_xer;
xer_type_encoder_f CN_IntegerEnumerated1_encode_xer;
per_type_decoder_f CN_IntegerEnumerated1_decode_uper;
per_type_encoder_f CN_IntegerEnumerated1_encode_uper;
per_type_decoder_f CN_IntegerEnumerated1_decode_aper;
per_type_encoder_f CN_IntegerEnumerated1_encode_aper;
/*** <<< CODE [CN-IntegerEnumerated1] >>> ***/
......@@ -1389,6 +1423,8 @@ xer_type_decoder_f NO_IntegerEnumerated2_decode_xer;
xer_type_encoder_f NO_IntegerEnumerated2_encode_xer;
per_type_decoder_f NO_IntegerEnumerated2_decode_uper;
per_type_encoder_f NO_IntegerEnumerated2_encode_uper;
per_type_decoder_f NO_IntegerEnumerated2_decode_aper;
per_type_encoder_f NO_IntegerEnumerated2_encode_aper;
/*** <<< CODE [NO-IntegerEnumerated2] >>> ***/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment