diff options
author | Harald Welte <laforge@gnumonks.org> | 2015-08-31 08:56:53 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2015-08-31 09:35:13 +0200 |
commit | 41b85d5597119fa8105dc0641ffe5cd1bbae39b2 (patch) | |
tree | 1a425d76fafe089cca547eb9c79c6a9a631c34e2 /src/BOOLEAN.c | |
parent | f6b9173b02bfac093177cf6fd0f48ad56c5786c7 (diff) |
update to asn1c aper branch commit 6e00cbce7304a6972e82a12bb5fa82e41fa541be
which is closes to Lev Walkins master 62913d8b8e1eb96d74315ff748475ca818b69752
Diffstat (limited to 'src/BOOLEAN.c')
-rw-r--r-- | src/BOOLEAN.c | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/src/BOOLEAN.c b/src/BOOLEAN.c index 2c2bbcf..42374b8 100644 --- a/src/BOOLEAN.c +++ b/src/BOOLEAN.c @@ -9,7 +9,7 @@ /* * BOOLEAN basic type description. */ -static ber_tlv_tag_t asn_DEF_BOOLEAN_tags[] = { +static const ber_tlv_tag_t asn_DEF_BOOLEAN_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)) }; asn_TYPE_descriptor_t asn_DEF_BOOLEAN = { @@ -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]), @@ -161,10 +163,7 @@ BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun } return XPBD_BODY_CONSUMED; } else { - if(xer_is_whitespace(chunk_buf, chunk_size)) - return XPBD_NOT_BODY_IGNORE; - else - return XPBD_BROKEN_ENCODING; + return XPBD_BROKEN_ENCODING; } } @@ -267,18 +266,63 @@ 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, 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; + asn_enc_rval_t er = { 0, 0, 0 }; (void)constraints; if(!st) _ASN_ENCODE_FAILED; - per_put_few_bits(po, *st ? 1 : 0, 1); + if(per_put_few_bits(po, *st ? 1 : 0, 1)) + _ASN_ENCODE_FAILED; _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); +} |