-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,043 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/*- | ||
* Copyright (c) 2003, 2005 Lev Walkin <[email protected]>. All rights reserved. | ||
* Copyright (c) 2003, 2005, 2006 Lev Walkin <[email protected]>. | ||
* All rights reserved. | ||
* Redistribution and modifications are permitted subject to BSD license. | ||
*/ | ||
#include <asn_internal.h> | ||
|
@@ -24,6 +25,7 @@ asn_TYPE_descriptor_t asn_DEF_ENUMERATED = { | |
INTEGER_decode_xer, /* This is temporary! */ | ||
INTEGER_encode_xer, | ||
ENUMERATED_decode_uper, /* Unaligned PER decoder */ | ||
ENUMERATED_encode_uper, /* Unaligned PER encoder */ | ||
0, /* Use generic outmost tag fetcher */ | ||
asn_DEF_ENUMERATED_tags, | ||
sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]), | ||
|
@@ -54,3 +56,16 @@ ENUMERATED_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td | |
rval.code = RC_FAIL; | ||
return rval; | ||
} | ||
|
||
asn_enc_rval_t | ||
ENUMERATED_encode_uper(asn_TYPE_descriptor_t *td, | ||
asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { | ||
ENUMERATED_t *st = (ENUMERATED_t *)sptr; | ||
long value; | ||
|
||
if(asn_INTEGER2long(st, &value)) | ||
_ASN_ENCODE_FAILED; | ||
|
||
return NativeEnumerated_encode_uper(td, constraints, &value, po); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*- | ||
* Copyright (c) 2003, 2004, 2005 Lev Walkin <[email protected]>. | ||
* Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin <[email protected]>. | ||
* All rights reserved. | ||
* Redistribution and modifications are permitted subject to BSD license. | ||
*/ | ||
|
@@ -25,6 +25,7 @@ asn_TYPE_descriptor_t asn_DEF_INTEGER = { | |
INTEGER_decode_xer, | ||
INTEGER_encode_xer, | ||
INTEGER_decode_uper, /* Unaligned PER decoder */ | ||
INTEGER_encode_uper, /* Unaligned PER encoder */ | ||
0, /* Use generic outmost tag fetcher */ | ||
asn_DEF_INTEGER_tags, | ||
sizeof(asn_DEF_INTEGER_tags) / sizeof(asn_DEF_INTEGER_tags[0]), | ||
|
@@ -530,6 +531,78 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, | |
return rval; | ||
} | ||
|
||
asn_enc_rval_t | ||
INTEGER_encode_uper(asn_TYPE_descriptor_t *td, | ||
asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { | ||
asn_enc_rval_t er; | ||
INTEGER_t *st = (INTEGER_t *)sptr; | ||
const uint8_t *buf; | ||
const uint8_t *end; | ||
asn_per_constraint_t *ct; | ||
long value = 0; | ||
|
||
if(!st || st->size == 0) _ASN_ENCODE_FAILED; | ||
|
||
if(!constraints) constraints = td->per_constraints; | ||
ct = constraints ? &constraints->value : 0; | ||
|
||
er.encoded = 0; | ||
|
||
if(ct) { | ||
int inext = 0; | ||
if(asn_INTEGER2long(st, &value)) | ||
_ASN_ENCODE_FAILED; | ||
/* Check proper range */ | ||
if(ct->flags & APC_SEMI_CONSTRAINED) { | ||
if(value < ct->lower_bound) | ||
inext = 1; | ||
} else if(ct->range_bits >= 0) { | ||
if(value < ct->lower_bound | ||
|| value > ct->upper_bound) | ||
inext = 1; | ||
} | ||
ASN_DEBUG("Value %ld (%02x/%d) lb %ld ub %ld %s", | ||
value, st->buf[0], st->size, | ||
ct->lower_bound, ct->upper_bound, | ||
inext ? "ext" : "fix"); | ||
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; | ||
} | ||
} | ||
|
||
|
||
/* X.691, #12.2.2 */ | ||
if(ct && ct->range_bits >= 0) { | ||
/* #10.5.6 */ | ||
ASN_DEBUG("Encoding integer with range %d bits", | ||
ct->range_bits); | ||
if(per_put_few_bits(po, value - ct->lower_bound, | ||
ct->range_bits)) | ||
_ASN_ENCODE_FAILED; | ||
_ASN_ENCODED_OK(er); | ||
} | ||
|
||
if(ct && ct->lower_bound) { | ||
ASN_DEBUG("Adjust lower bound to %ld", ct->lower_bound); | ||
/* TODO: adjust lower bound */ | ||
_ASN_ENCODE_FAILED; | ||
} | ||
|
||
for(buf = st->buf, end = st->buf + st->size; buf < end;) { | ||
ssize_t mayEncode = uper_put_length(po, end - buf); | ||
if(mayEncode < 0) | ||
_ASN_ENCODE_FAILED; | ||
if(per_put_many_bits(po, buf, 8 * mayEncode)) | ||
_ASN_ENCODE_FAILED; | ||
} | ||
|
||
_ASN_ENCODED_OK(er); | ||
} | ||
|
||
int | ||
asn_INTEGER2long(const INTEGER_t *iptr, long *lptr) { | ||
uint8_t *b, *end; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/*- | ||
* Copyright (c) 2004, 2005 Lev Walkin <[email protected]>. All rights reserved. | ||
* Copyright (c) 2004, 2005, 2006 Lev Walkin <[email protected]>. | ||
* All rights reserved. | ||
* Redistribution and modifications are permitted subject to BSD license. | ||
*/ | ||
/* | ||
|
@@ -22,6 +23,7 @@ extern asn_TYPE_descriptor_t asn_DEF_NativeEnumerated; | |
|
||
xer_type_encoder_f NativeEnumerated_encode_xer; | ||
per_type_decoder_f NativeEnumerated_decode_uper; | ||
per_type_encoder_f NativeEnumerated_encode_uper; | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
Oops, something went wrong.