mirror of https://gerrit.osmocom.org/asn1c
constness fixes, round-trip and fuzz-testing for CHOICE
This commit is contained in:
parent
37231fb195
commit
20696a4ff3
|
@ -771,10 +771,10 @@ decode_tlv_from_string(const char *datastring) {
|
|||
* Dummy functions.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
ber_check_tags(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
asn_struct_ctx_t *opt_ctx, const void *ptr, size_t size,
|
||||
int tag_mode, int last_tag_form, ber_tlv_len_t *last_length,
|
||||
int *opt_tlv_form) {
|
||||
ber_check_tags(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx,
|
||||
const void *ptr, size_t size, int tag_mode, int last_tag_form,
|
||||
ber_tlv_len_t *last_length, int *opt_tlv_form) {
|
||||
asn_dec_rval_t rv = {0, 0};
|
||||
(void)opt_codec_ctx;
|
||||
(void)td;
|
||||
|
@ -789,7 +789,7 @@ ber_check_tags(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
ssize_t
|
||||
der_write_tags(asn_TYPE_descriptor_t *td, size_t slen, int tag_mode,
|
||||
der_write_tags(const asn_TYPE_descriptor_t *td, size_t slen, int tag_mode,
|
||||
int last_tag_form, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
(void)td;
|
||||
|
|
|
@ -55,11 +55,10 @@ asn_TYPE_descriptor_t asn_DEF_ANY = {
|
|||
} while(0)
|
||||
|
||||
asn_enc_rval_t
|
||||
ANY_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
ANY_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
/*
|
||||
* Canonical XER-encoding of ANY type is not supported.
|
||||
*/
|
||||
|
@ -183,7 +182,8 @@ static int ANY__consume_bytes(const void *buffer, size_t size, void *key) {
|
|||
#ifndef ASN_DISABLE_PER_SUPPORT
|
||||
|
||||
asn_dec_rval_t
|
||||
ANY_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
ANY_decode_uper(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_OCTET_STRING_specifics_t *specs =
|
||||
|
@ -240,8 +240,8 @@ ANY_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
ANY_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
ANY_encode_uper(const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, const void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
const ANY_t *st = (const ANY_t *)sptr;
|
||||
asn_enc_rval_t er = {0, 0, 0};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_TYPE_ANY_H
|
||||
|
|
|
@ -61,9 +61,9 @@ asn_TYPE_descriptor_t asn_DEF_BIT_STRING = {
|
|||
* BIT STRING generic constraint.
|
||||
*/
|
||||
int
|
||||
BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
BIT_STRING_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
if((st->size == 0 && st->bits_unused)
|
||||
|
@ -89,10 +89,10 @@ static const char *_bit_pattern[16] = {
|
|||
};
|
||||
|
||||
asn_enc_rval_t
|
||||
BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
BIT_STRING_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
char scratch[128];
|
||||
char *p = scratch;
|
||||
char *scend = scratch + (sizeof(scratch) - 10);
|
||||
|
@ -151,9 +151,9 @@ cb_failed:
|
|||
* BIT STRING specific contents printer.
|
||||
*/
|
||||
int
|
||||
BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
BIT_STRING_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
char scratch[64];
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
uint8_t *buf;
|
||||
|
@ -316,9 +316,9 @@ static asn_per_constraint_t asn_DEF_BIT_STRING_constraint_size = {
|
|||
|
||||
asn_dec_rval_t
|
||||
BIT_STRING_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void **sptr,
|
||||
asn_per_data_t *pd) {
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void **sptr,
|
||||
asn_per_data_t *pd) {
|
||||
const asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
? (const asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_SPC_BIT_STRING_specs;
|
||||
|
@ -419,9 +419,9 @@ BIT_STRING_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
BIT_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
BIT_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints,
|
||||
const void *sptr, asn_per_outp_t *po) {
|
||||
const asn_OCTET_STRING_specifics_t *specs =
|
||||
td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_SPC_BIT_STRING_specs;
|
||||
|
@ -573,8 +573,7 @@ BIT_STRING_random_fill(const asn_TYPE_descriptor_t *td, void **sptr,
|
|||
0, sizeof(lengths) / sizeof(lengths[0]) - 1)];
|
||||
if(!constraints) constraints = &td->encoding_constraints;
|
||||
if(constraints->per_constraints) {
|
||||
const asn_per_constraint_t *pc =
|
||||
&td->encoding_constraints.per_constraints->size;
|
||||
const asn_per_constraint_t *pc = &constraints->per_constraints->size;
|
||||
if(pc->flags & APC_CONSTRAINED) {
|
||||
long suggested_upper_bound = pc->upper_bound < (ssize_t)max_length
|
||||
? pc->upper_bound
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _BIT_STRING_H_
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
#include <errno.h>
|
||||
|
||||
asn_dec_rval_t
|
||||
BIT_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
BIT_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
BIT_STRING_t *st = (BIT_STRING_t *)*sptr;
|
||||
|
@ -89,10 +90,11 @@ BIT_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
BIT_STRING_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
BIT_STRING_t *st = (BIT_STRING_t *)sptr;
|
||||
BIT_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
const void *sptr, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
asn_enc_rval_t erval = {0, 0, 0};
|
||||
const asn_oer_constraints_t *cts =
|
||||
constraints ? constraints : td->encoding_constraints.oer_constraints;
|
||||
|
|
|
@ -64,9 +64,8 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = {
|
|||
};
|
||||
|
||||
int
|
||||
BMPString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb,
|
||||
void *app_key) {
|
||||
BMPString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
|
@ -128,9 +127,9 @@ BMPString__dump(const BMPString_t *st,
|
|||
|
||||
asn_dec_rval_t
|
||||
BMPString_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
asn_dec_rval_t rc;
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
asn_dec_rval_t rc;
|
||||
|
||||
rc = OCTET_STRING_decode_xer_utf8(opt_codec_ctx, td, sptr, opt_mname,
|
||||
buf_ptr, size);
|
||||
|
@ -193,10 +192,10 @@ BMPString_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
BMPString_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
BMPString_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
|
@ -212,9 +211,9 @@ BMPString_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
}
|
||||
|
||||
int
|
||||
BMPString_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
BMPString_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BMPString_t *st = (const BMPString_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _BMPString_H_
|
||||
|
|
|
@ -55,10 +55,9 @@ asn_TYPE_descriptor_t asn_DEF_BOOLEAN = {
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
BOOLEAN_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void **bool_value, const void *buf_ptr, size_t size,
|
||||
int tag_mode) {
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)*bool_value;
|
||||
const asn_TYPE_descriptor_t *td, void **bool_value,
|
||||
const void *buf_ptr, size_t size, int tag_mode) {
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)*bool_value;
|
||||
asn_dec_rval_t rval;
|
||||
ber_tlv_len_t length;
|
||||
ber_tlv_len_t lidx;
|
||||
|
@ -117,13 +116,13 @@ BOOLEAN_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
BOOLEAN_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)sptr;
|
||||
BOOLEAN_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
|
||||
|
||||
erval.encoded = der_write_tags(td, 1, tag_mode, 0, tag, cb, app_key);
|
||||
erval.encoded = der_write_tags(td, 1, tag_mode, 0, tag, cb, app_key);
|
||||
if(erval.encoded == -1) {
|
||||
erval.failed_type = td;
|
||||
erval.structure_ptr = sptr;
|
||||
|
@ -153,8 +152,9 @@ BOOLEAN_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
* Decode the chunk of XML text encoding INTEGER.
|
||||
*/
|
||||
static enum xer_pbd_rval
|
||||
BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)sptr;
|
||||
BOOLEAN__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const void *chunk_buf, size_t chunk_size) {
|
||||
BOOLEAN_t *st = (BOOLEAN_t *)sptr;
|
||||
const char *p = (const char *)chunk_buf;
|
||||
|
||||
(void)td;
|
||||
|
@ -184,16 +184,15 @@ BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun
|
|||
|
||||
asn_dec_rval_t
|
||||
BOOLEAN_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
sptr, sizeof(BOOLEAN_t), opt_mname, buf_ptr, size,
|
||||
BOOLEAN__xer_body_decode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
BOOLEAN_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
BOOLEAN_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
|
||||
|
@ -216,9 +215,9 @@ cb_failed:
|
|||
}
|
||||
|
||||
int
|
||||
BOOLEAN_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
|
||||
BOOLEAN_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const BOOLEAN_t *st = (const BOOLEAN_t *)sptr;
|
||||
const char *buf;
|
||||
size_t buflen;
|
||||
|
||||
|
@ -261,7 +260,8 @@ BOOLEAN_free(const asn_TYPE_descriptor_t *td, void *ptr,
|
|||
#ifndef ASN_DISABLE_PER_SUPPORT
|
||||
|
||||
asn_dec_rval_t
|
||||
BOOLEAN_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
BOOLEAN_decode_uper(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;
|
||||
|
@ -294,8 +294,8 @@ BOOLEAN_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
|
||||
|
||||
asn_enc_rval_t
|
||||
BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
BOOLEAN_encode_uper(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 = { 0, 0, 0 };
|
||||
|
@ -318,8 +318,8 @@ BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
BOOLEAN_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
BOOLEAN_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er = { 1, 0, 0 };
|
||||
const BOOLEAN_t *st = sptr;
|
||||
|
@ -337,9 +337,9 @@ BOOLEAN_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
|
||||
asn_dec_rval_t
|
||||
BOOLEAN_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
asn_dec_rval_t ok = {RC_OK, 1};
|
||||
BOOLEAN_t *st;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _BOOLEAN_H_
|
||||
|
|
|
@ -57,7 +57,7 @@ asn_TYPE_descriptor_t asn_DEF_ENUMERATED = {
|
|||
|
||||
asn_dec_rval_t
|
||||
ENUMERATED_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
asn_dec_rval_t rval;
|
||||
|
@ -81,10 +81,11 @@ ENUMERATED_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
ENUMERATED_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
ENUMERATED_t *st = (ENUMERATED_t *)sptr;
|
||||
ENUMERATED_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
const void *sptr, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const ENUMERATED_t *st = sptr;
|
||||
long value;
|
||||
|
||||
if(asn_INTEGER2long(st, &value)) {
|
||||
|
@ -100,7 +101,7 @@ ENUMERATED_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
|
||||
asn_dec_rval_t
|
||||
ENUMERATED_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void **sptr,
|
||||
asn_per_data_t *pd) {
|
||||
asn_dec_rval_t rval;
|
||||
|
@ -124,10 +125,10 @@ ENUMERATED_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
ENUMERATED_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
ENUMERATED_t *st = (ENUMERATED_t *)sptr;
|
||||
ENUMERATED_encode_uper(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)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _ENUMERATED_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _GeneralString_H_
|
||||
|
|
|
@ -219,9 +219,10 @@ asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = {
|
|||
* Check that the time looks like the time.
|
||||
*/
|
||||
int
|
||||
GeneralizedTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
|
||||
GeneralizedTime_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb,
|
||||
void *app_key) {
|
||||
const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
|
||||
time_t tloc;
|
||||
|
||||
errno = EPERM; /* Just an unlikely error code */
|
||||
|
@ -237,10 +238,10 @@ GeneralizedTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
GeneralizedTime_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
GeneralizedTime_t *st = (GeneralizedTime_t *)sptr;
|
||||
GeneralizedTime_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
GeneralizedTime_t *st;
|
||||
asn_enc_rval_t erval;
|
||||
int fv, fd; /* seconds fraction value and number of digits */
|
||||
struct tm tm;
|
||||
|
@ -249,38 +250,38 @@ GeneralizedTime_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
/*
|
||||
* Encode as a canonical DER.
|
||||
*/
|
||||
errno = EPERM;
|
||||
tloc = asn_GT2time_frac(st, &fv, &fd, &tm, 1); /* Recognize time */
|
||||
if(tloc == -1 && errno != EPERM)
|
||||
/* Failed to recognize time. Fail completely. */
|
||||
errno = EPERM;
|
||||
tloc = asn_GT2time_frac((const GeneralizedTime_t *)sptr, &fv, &fd, &tm,
|
||||
1); /* Recognize time */
|
||||
if(tloc == -1 && errno != EPERM) {
|
||||
/* Failed to recognize time. Fail completely. */
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
st = asn_time2GT_frac(0, &tm, fv, fd, 1); /* Save time canonically */
|
||||
if(!st) ASN__ENCODE_FAILED; /* Memory allocation failure. */
|
||||
st = asn_time2GT_frac(0, &tm, fv, fd, 1); /* Save time canonically */
|
||||
if(!st) ASN__ENCODE_FAILED; /* Memory allocation failure. */
|
||||
|
||||
erval = OCTET_STRING_encode_der(td, st, tag_mode, tag, cb, app_key);
|
||||
erval = OCTET_STRING_encode_der(td, st, tag_mode, tag, cb, app_key);
|
||||
|
||||
FREEMEM(st->buf);
|
||||
FREEMEM(st);
|
||||
ASN_STRUCT_FREE(*td, st);
|
||||
|
||||
return erval;
|
||||
return erval;
|
||||
}
|
||||
|
||||
#ifndef ASN___INTERNAL_TEST_MODE
|
||||
|
||||
asn_enc_rval_t
|
||||
GeneralizedTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
GeneralizedTime_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
GeneralizedTime_t *gt;
|
||||
asn_enc_rval_t rv;
|
||||
int fv, fd; /* fractional parts */
|
||||
struct tm tm;
|
||||
|
||||
errno = EPERM;
|
||||
if(asn_GT2time_frac((GeneralizedTime_t *)sptr,
|
||||
if(asn_GT2time_frac((const GeneralizedTime_t *)sptr,
|
||||
&fv, &fd, &tm, 1) == -1
|
||||
&& errno != EPERM)
|
||||
ASN__ENCODE_FAILED;
|
||||
|
@ -301,9 +302,9 @@ GeneralizedTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
#endif /* ASN___INTERNAL_TEST_MODE */
|
||||
|
||||
int
|
||||
GeneralizedTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
|
||||
GeneralizedTime_print(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const GeneralizedTime_t *st = (const GeneralizedTime_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _GeneralizedTime_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _GraphicString_H_
|
||||
|
|
|
@ -58,9 +58,9 @@ asn_TYPE_descriptor_t asn_DEF_IA5String = {
|
|||
};
|
||||
|
||||
int
|
||||
IA5String_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const IA5String_t *st = (const IA5String_t *)sptr;
|
||||
IA5String_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const IA5String_t *st = (const IA5String_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _IA5String_H_
|
||||
|
|
|
@ -56,10 +56,12 @@ asn_TYPE_descriptor_t asn_DEF_INTEGER = {
|
|||
* Encode INTEGER type using DER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
INTEGER_t *st = (INTEGER_t *)sptr;
|
||||
INTEGER_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
asn_enc_rval_t rval;
|
||||
INTEGER_t effective_integer;
|
||||
|
||||
ASN_DEBUG("%s %s as INTEGER (tm=%d)",
|
||||
cb?"Encoding":"Estimating", td->name, tag_mode);
|
||||
|
@ -96,19 +98,23 @@ INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
/* Remove leading superfluous bytes from the integer */
|
||||
shift = buf - st->buf;
|
||||
if(shift) {
|
||||
uint8_t *nb = st->buf;
|
||||
uint8_t *end;
|
||||
union {
|
||||
const uint8_t *c_buf;
|
||||
uint8_t *nc_buf;
|
||||
} unconst;
|
||||
unconst.c_buf = st->buf;
|
||||
effective_integer.buf = unconst.nc_buf + shift;
|
||||
effective_integer.size = st->size - shift;
|
||||
|
||||
st->size -= shift; /* New size, minus bad bytes */
|
||||
end = nb + st->size;
|
||||
st = &effective_integer;
|
||||
}
|
||||
}
|
||||
|
||||
for(; nb < end; nb++, buf++)
|
||||
*nb = *buf;
|
||||
}
|
||||
|
||||
} /* if(1) */
|
||||
|
||||
return der_encode_primitive(td, sptr, tag_mode, tag, cb, app_key);
|
||||
rval = der_encode_primitive(td, sptr, tag_mode, tag, cb, app_key);
|
||||
if(rval.structure_ptr == &effective_integer) {
|
||||
rval.structure_ptr = sptr;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value(
|
||||
|
@ -194,12 +200,11 @@ INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_cons
|
|||
* INTEGER specific human-readable output.
|
||||
*/
|
||||
int
|
||||
INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
INTEGER_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
ssize_t ret;
|
||||
|
||||
(void)td;
|
||||
(void)ilevel;
|
||||
|
||||
if(!st || !st->buf)
|
||||
|
@ -311,8 +316,9 @@ INTEGER_st_prealloc(INTEGER_t *st, int min_size) {
|
|||
* Decode the chunk of XML text encoding INTEGER.
|
||||
*/
|
||||
static enum xer_pbd_rval
|
||||
INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
|
||||
INTEGER_t *st = (INTEGER_t *)sptr;
|
||||
INTEGER__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const void *chunk_buf, size_t chunk_size) {
|
||||
INTEGER_t *st = (INTEGER_t *)sptr;
|
||||
intmax_t dec_value;
|
||||
intmax_t hex_value = 0;
|
||||
const char *lp;
|
||||
|
@ -543,19 +549,18 @@ INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun
|
|||
|
||||
asn_dec_rval_t
|
||||
INTEGER_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
sptr, sizeof(INTEGER_t), opt_mname,
|
||||
buf_ptr, size, INTEGER__xer_body_decode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
INTEGER_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
|
@ -573,7 +578,8 @@ INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
#ifndef ASN_DISABLE_PER_SUPPORT
|
||||
|
||||
asn_dec_rval_t
|
||||
INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
INTEGER_decode_uper(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 =
|
||||
|
@ -689,13 +695,13 @@ INTEGER_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
INTEGER_encode_uper(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;
|
||||
INTEGER_t *st = (INTEGER_t *)sptr;
|
||||
const INTEGER_t *st = (const INTEGER_t *)sptr;
|
||||
const uint8_t *buf;
|
||||
const uint8_t *end;
|
||||
const asn_per_constraint_t *ct;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _INTEGER_H_
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
#include <errno.h>
|
||||
|
||||
asn_dec_rval_t
|
||||
INTEGER_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
INTEGER_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
|
@ -99,8 +100,8 @@ INTEGER_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
INTEGER_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
INTEGER_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const INTEGER_t *st = sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _ISO646String_H_
|
||||
|
|
|
@ -50,7 +50,7 @@ libasn1cskeletons_la_SOURCES = \
|
|||
OBJECT_IDENTIFIER.c OBJECT_IDENTIFIER.h \
|
||||
OCTET_STRING.c OCTET_STRING.h \
|
||||
OCTET_STRING_oer.c \
|
||||
OPEN_TYPE.c OPEN_TYPE.h \
|
||||
OPEN_TYPE.c OPEN_TYPE.h OPEN_TYPE_oer.c \
|
||||
ObjectDescriptor.c ObjectDescriptor.h \
|
||||
PrintableString.c PrintableString.h \
|
||||
REAL.c REAL.h \
|
||||
|
|
|
@ -52,10 +52,9 @@ asn_TYPE_descriptor_t asn_DEF_NULL = {
|
|||
};
|
||||
|
||||
asn_enc_rval_t
|
||||
NULL_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
NULL_encode_der(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode,
|
||||
ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
|
||||
erval.encoded = der_write_tags(td, 0, tag_mode, 0, tag, cb, app_key);
|
||||
if(erval.encoded == -1) {
|
||||
|
@ -67,10 +66,10 @@ NULL_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NULL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
NULL_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)td;
|
||||
(void)sptr;
|
||||
|
@ -86,8 +85,9 @@ NULL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
|
||||
|
||||
static enum xer_pbd_rval
|
||||
NULL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
|
||||
(void)td;
|
||||
NULL__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const void *chunk_buf, size_t chunk_size) {
|
||||
(void)td;
|
||||
(void)sptr;
|
||||
(void)chunk_buf; /* Going to be empty according to the rules below. */
|
||||
|
||||
|
@ -102,10 +102,9 @@ NULL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_b
|
|||
|
||||
asn_dec_rval_t
|
||||
NULL_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
sptr, sizeof(NULL_t), opt_mname, buf_ptr, size,
|
||||
NULL__xer_body_decode);
|
||||
}
|
||||
|
@ -119,10 +118,9 @@ NULL_compare(const asn_TYPE_descriptor_t *td, const void *a, const void *b) {
|
|||
}
|
||||
|
||||
int
|
||||
NULL_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
NULL_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(sptr) {
|
||||
|
@ -135,9 +133,10 @@ NULL_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
#ifndef ASN_DISABLE_OER_SUPPORT
|
||||
|
||||
asn_dec_rval_t
|
||||
NULL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
NULL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
asn_dec_rval_t rv = {RC_OK, 0};
|
||||
(void)opt_codec_ctx;
|
||||
(void)td;
|
||||
|
@ -149,8 +148,8 @@ NULL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NULL_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
NULL_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
|
||||
|
@ -170,7 +169,8 @@ NULL_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
#ifndef ASN_DISABLE_PER_SUPPORT
|
||||
|
||||
asn_dec_rval_t
|
||||
NULL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
NULL_decode_uper(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;
|
||||
|
@ -199,8 +199,8 @@ NULL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NULL_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
NULL_encode_uper(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;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_TYPE_NULL_H
|
||||
|
|
|
@ -57,8 +57,8 @@ asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = {
|
|||
};
|
||||
|
||||
asn_enc_rval_t
|
||||
NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags,
|
||||
NativeEnumerated_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
(const asn_INTEGER_specifics_t *)td->specifics;
|
||||
|
@ -87,10 +87,10 @@ NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
|
|||
|
||||
asn_dec_rval_t
|
||||
NativeEnumerated_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
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;
|
||||
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 = td->specifics;
|
||||
asn_dec_rval_t rval = { RC_OK, 0 };
|
||||
long *native = (long *)*sptr;
|
||||
const asn_per_constraint_t *ct;
|
||||
|
@ -154,9 +154,9 @@ NativeEnumerated__compar_value2enum(const void *ap, const void *bp) {
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
NativeEnumerated_encode_uper(const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints,
|
||||
void *sptr, asn_per_outp_t *po) {
|
||||
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;
|
||||
|
@ -178,7 +178,7 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
|
||||
er.encoded = 0;
|
||||
|
||||
native = *(long *)sptr;
|
||||
native = *(const long *)sptr;
|
||||
|
||||
key.nat_value = native;
|
||||
kf = bsearch(&key, specs->value2enum, specs->map_count,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
/*
|
||||
|
|
|
@ -31,7 +31,7 @@ asn__nativeenumerated_convert(const uint8_t *b, const uint8_t *end) {
|
|||
|
||||
asn_dec_rval_t
|
||||
NativeEnumerated_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void **nint_ptr, const void *ptr, size_t size) {
|
||||
asn_dec_rval_t rval = {RC_OK, 0};
|
||||
|
@ -99,9 +99,9 @@ NativeEnumerated_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
NativeEnumerated_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
NativeEnumerated_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void *sptr, asn_app_consume_bytes_f *cb,
|
||||
const void *sptr, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
long native;
|
||||
|
|
|
@ -62,8 +62,8 @@ asn_TYPE_descriptor_t asn_DEF_NativeInteger = {
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
NativeInteger_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) {
|
||||
const asn_TYPE_descriptor_t *td, void **nint_ptr,
|
||||
const void *buf_ptr, size_t size, int tag_mode) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
(const asn_INTEGER_specifics_t *)td->specifics;
|
||||
long *native = (long *)*nint_ptr;
|
||||
|
@ -147,11 +147,11 @@ NativeInteger_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode the NativeInteger using the standard INTEGER type DER encoder.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
unsigned long native = *(unsigned long *)ptr; /* Disable sign ext. */
|
||||
asn_enc_rval_t erval;
|
||||
NativeInteger_encode_der(const asn_TYPE_descriptor_t *sd, const void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
unsigned long native = *(const unsigned long *)ptr; /* Disable sign ext. */
|
||||
asn_enc_rval_t erval;
|
||||
INTEGER_t tmp;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN /* Opportunistic optimization */
|
||||
|
@ -173,10 +173,9 @@ NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr,
|
|||
|
||||
/* Encode fake INTEGER */
|
||||
erval = INTEGER_encode_der(sd, &tmp, tag_mode, tag, cb, app_key);
|
||||
if(erval.encoded == -1) {
|
||||
assert(erval.structure_ptr == &tmp);
|
||||
erval.structure_ptr = ptr;
|
||||
}
|
||||
if(erval.structure_ptr == &tmp) {
|
||||
erval.structure_ptr = ptr;
|
||||
}
|
||||
return erval;
|
||||
}
|
||||
|
||||
|
@ -185,8 +184,9 @@ NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr,
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
NativeInteger_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr,
|
||||
size_t size) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
(const asn_INTEGER_specifics_t *)td->specifics;
|
||||
asn_dec_rval_t rval;
|
||||
|
@ -226,9 +226,9 @@ NativeInteger_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
|
||||
|
||||
asn_enc_rval_t
|
||||
NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
NativeInteger_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
(const asn_INTEGER_specifics_t *)td->specifics;
|
||||
char scratch[32]; /* Enough for 64-bit int */
|
||||
|
@ -254,7 +254,7 @@ NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
|
||||
asn_dec_rval_t
|
||||
NativeInteger_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
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 =
|
||||
|
@ -290,9 +290,9 @@ NativeInteger_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
NativeInteger_encode_uper(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;
|
||||
|
@ -301,9 +301,9 @@ NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
|
||||
native = *(long *)sptr;
|
||||
native = *(const long *)sptr;
|
||||
|
||||
ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
|
||||
ASN_DEBUG("Encoding NativeInteger %s %ld (UPER)", td->name, native);
|
||||
|
||||
memset(&tmpint, 0, sizeof(tmpint));
|
||||
if((specs&&specs->field_unsigned)
|
||||
|
@ -321,8 +321,8 @@ NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
* INTEGER specific human-readable output.
|
||||
*/
|
||||
int
|
||||
NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
NativeInteger_print(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
(const asn_INTEGER_specifics_t *)td->specifics;
|
||||
const long *native = (const long *)sptr;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
/*
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
asn_dec_rval_t
|
||||
NativeInteger_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void **nint_ptr, const void *ptr, size_t size) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
|
@ -68,9 +68,10 @@ NativeInteger_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
NativeInteger_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
NativeInteger_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
const void *sptr, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const asn_INTEGER_specifics_t *specs =
|
||||
(const asn_INTEGER_specifics_t *)td->specifics;
|
||||
INTEGER_t tmpint;
|
||||
|
|
|
@ -91,7 +91,7 @@ static void NativeReal__network_swap(size_t float_size, const void *srcp,
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
NativeReal_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const void *buf_ptr, size_t size, int tag_mode) {
|
||||
asn_dec_rval_t rval;
|
||||
ber_tlv_len_t length;
|
||||
|
@ -172,9 +172,9 @@ NativeReal_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode the NativeReal using the standard REAL type DER encoder.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
NativeReal_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
NativeReal_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
double d = NativeReal__get_double(td, sptr);
|
||||
asn_enc_rval_t erval;
|
||||
REAL_t tmp;
|
||||
|
@ -205,10 +205,10 @@ NativeReal_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
NativeReal_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void **sptr,
|
||||
asn_per_data_t *pd) {
|
||||
asn_dec_rval_t rval;
|
||||
asn_dec_rval_t rval;
|
||||
double d;
|
||||
REAL_t tmp;
|
||||
void *ptmp = &tmp;
|
||||
|
@ -238,9 +238,9 @@ NativeReal_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode the NativeReal using the OCTET STRING PER encoder.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
NativeReal_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
NativeReal_encode_uper(const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints,
|
||||
const void *sptr, asn_per_outp_t *po) {
|
||||
double d = NativeReal__get_double(td, sptr);
|
||||
asn_enc_rval_t erval;
|
||||
REAL_t tmp;
|
||||
|
@ -272,9 +272,10 @@ NativeReal_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
NativeReal_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
NativeReal_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
const void *sptr, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
asn_enc_rval_t er = {0, 0, 0};
|
||||
|
||||
if(!constraints) constraints = td->encoding_constraints.oer_constraints;
|
||||
|
@ -335,9 +336,9 @@ NativeReal_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
|
||||
asn_dec_rval_t
|
||||
NativeReal_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
asn_dec_rval_t ok = {RC_OK, 0};
|
||||
double d;
|
||||
ssize_t len_len;
|
||||
|
@ -429,9 +430,9 @@ NativeReal_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
NativeReal_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
asn_dec_rval_t rval;
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
asn_dec_rval_t rval;
|
||||
REAL_t st = { 0, 0 };
|
||||
REAL_t *stp = &st;
|
||||
|
||||
|
@ -452,9 +453,9 @@ NativeReal_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
NativeReal_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
NativeReal_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
double d = NativeReal__get_double(td, sptr);
|
||||
asn_enc_rval_t er;
|
||||
|
||||
|
@ -470,10 +471,9 @@ NativeReal_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
* REAL specific human-readable output.
|
||||
*/
|
||||
int
|
||||
NativeReal_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
||||
(void)ilevel; /* Unused argument */
|
||||
NativeReal_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
||||
if(sptr) {
|
||||
double d = NativeReal__get_double(td, sptr);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
/*
|
||||
|
|
|
@ -78,9 +78,9 @@ asn_TYPE_descriptor_t asn_DEF_NumericString = {
|
|||
};
|
||||
|
||||
int
|
||||
NumericString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const NumericString_t *st = (const NumericString_t *)sptr;
|
||||
NumericString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const NumericString_t *st = (const NumericString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _NumericString_H_
|
||||
|
|
|
@ -56,9 +56,10 @@ asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = {
|
|||
};
|
||||
|
||||
int
|
||||
OBJECT_IDENTIFIER_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
OBJECT_IDENTIFIER_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb,
|
||||
void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
if(st->size < 1) {
|
||||
|
@ -182,8 +183,9 @@ OBJECT_IDENTIFIER__dump_body(const OBJECT_IDENTIFIER_t *st,
|
|||
}
|
||||
|
||||
static enum xer_pbd_rval
|
||||
OBJECT_IDENTIFIER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
|
||||
OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)sptr;
|
||||
OBJECT_IDENTIFIER__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const void *chunk_buf, size_t chunk_size) {
|
||||
OBJECT_IDENTIFIER_t *st = (OBJECT_IDENTIFIER_t *)sptr;
|
||||
const char *chunk_end = (const char *)chunk_buf + chunk_size;
|
||||
const char *endptr;
|
||||
asn_oid_arc_t s_arcs[10];
|
||||
|
@ -224,19 +226,19 @@ OBJECT_IDENTIFIER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const
|
|||
|
||||
asn_dec_rval_t
|
||||
OBJECT_IDENTIFIER_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr,
|
||||
size_t size) {
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
sptr, sizeof(OBJECT_IDENTIFIER_t), opt_mname,
|
||||
buf_ptr, size, OBJECT_IDENTIFIER__xer_body_decode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OBJECT_IDENTIFIER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
OBJECT_IDENTIFIER_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
|
@ -253,9 +255,10 @@ OBJECT_IDENTIFIER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
}
|
||||
|
||||
int
|
||||
OBJECT_IDENTIFIER_print(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
OBJECT_IDENTIFIER_print(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const OBJECT_IDENTIFIER_t *st = (const OBJECT_IDENTIFIER_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _OBJECT_IDENTIFIER_H_
|
||||
|
|
|
@ -178,9 +178,9 @@ _new_stack(void) {
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
OCTET_STRING_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void **sptr, const void *buf_ptr, size_t size, int tag_mode) {
|
||||
const asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const void *buf_ptr, size_t size, int tag_mode) {
|
||||
const asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
? (const asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_SPC_OCTET_STRING_specs;
|
||||
BIT_STRING_t *st = (BIT_STRING_t *)*sptr;
|
||||
|
@ -532,14 +532,14 @@ OCTET_STRING_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode OCTET STRING type using DER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
OCTET_STRING_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
const asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
? (const asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_SPC_OCTET_STRING_specs;
|
||||
BIT_STRING_t *st = (BIT_STRING_t *)sptr;
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
enum asn_OS_Subvariant type_variant = specs->subvariant;
|
||||
int fix_last_byte = 0;
|
||||
|
||||
|
@ -594,10 +594,10 @@ cb_failed:
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
OCTET_STRING_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
char scratch[16 * 3 + 4];
|
||||
|
@ -746,10 +746,10 @@ OCTET_STRING__handle_control_chars(void *struct_ptr, const void *chunk_buf, size
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
OCTET_STRING_encode_xer_utf8(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
uint8_t *buf, *end;
|
||||
uint8_t *ss; /* Sequence start */
|
||||
|
@ -974,8 +974,10 @@ OS__strtoent(int base, const char *buf, const char *end, int32_t *ret_value) {
|
|||
/*
|
||||
* Convert from the plain UTF-8 format, expanding entity references: "2 < 3"
|
||||
*/
|
||||
static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf, size_t chunk_size, int have_more) {
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
|
||||
static ssize_t
|
||||
OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
|
||||
size_t chunk_size, int have_more) {
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
|
||||
const char *p = (const char *)chunk_buf;
|
||||
const char *pend = p + chunk_size;
|
||||
uint8_t *buf;
|
||||
|
@ -1115,16 +1117,14 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
|
|||
* Decode OCTET STRING from the XML element's body.
|
||||
*/
|
||||
static asn_dec_rval_t
|
||||
OCTET_STRING__decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size,
|
||||
int (*opt_unexpected_tag_decoder)
|
||||
(void *struct_ptr, const void *chunk_buf, size_t chunk_size),
|
||||
ssize_t (*body_receiver)
|
||||
(void *struct_ptr, const void *chunk_buf, size_t chunk_size,
|
||||
int have_more)
|
||||
) {
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)*sptr;
|
||||
OCTET_STRING__decode_xer(
|
||||
const asn_codec_ctx_t *opt_codec_ctx, const asn_TYPE_descriptor_t *td,
|
||||
void **sptr, const char *opt_mname, const void *buf_ptr, size_t size,
|
||||
int (*opt_unexpected_tag_decoder)(void *struct_ptr, const void *chunk_buf,
|
||||
size_t chunk_size),
|
||||
ssize_t (*body_receiver)(void *struct_ptr, const void *chunk_buf,
|
||||
size_t chunk_size, int have_more)) {
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)*sptr;
|
||||
const asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
? (const asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_SPC_OCTET_STRING_specs;
|
||||
|
@ -1176,9 +1176,10 @@ sta_failed:
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
OCTET_STRING_decode_xer_hex(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr,
|
||||
size_t size) {
|
||||
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
|
||||
buf_ptr, size, 0, OCTET_STRING__convert_hexadecimal);
|
||||
}
|
||||
|
||||
|
@ -1187,9 +1188,10 @@ OCTET_STRING_decode_xer_hex(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
OCTET_STRING_decode_xer_binary(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr,
|
||||
size_t size) {
|
||||
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
|
||||
buf_ptr, size, 0, OCTET_STRING__convert_binary);
|
||||
}
|
||||
|
||||
|
@ -1198,9 +1200,10 @@ OCTET_STRING_decode_xer_binary(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
OCTET_STRING_decode_xer_utf8(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr,
|
||||
size_t size) {
|
||||
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
|
||||
buf_ptr, size,
|
||||
OCTET_STRING__handle_control_chars,
|
||||
OCTET_STRING__convert_entrefs);
|
||||
|
@ -1349,7 +1352,7 @@ static asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = {
|
|||
|
||||
asn_dec_rval_t
|
||||
OCTET_STRING_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void **sptr,
|
||||
asn_per_data_t *pd) {
|
||||
const asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
|
@ -1498,9 +1501,9 @@ OCTET_STRING_decode_uper(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
OCTET_STRING_encode_uper(const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints,
|
||||
const void *sptr, asn_per_outp_t *po) {
|
||||
const asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
? (const asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_SPC_OCTET_STRING_specs;
|
||||
|
@ -1643,9 +1646,9 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
#endif /* ASN_DISABLE_PER_SUPPORT */
|
||||
|
||||
int
|
||||
OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
OCTET_STRING_print(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
char scratch[16 * 3 + 4];
|
||||
char *p = scratch;
|
||||
|
@ -1685,9 +1688,10 @@ OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
}
|
||||
|
||||
int
|
||||
OCTET_STRING_print_utf8(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
OCTET_STRING_print_utf8(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _OCTET_STRING_H_
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
asn_dec_rval_t
|
||||
OCTET_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
const asn_OCTET_STRING_specifics_t *specs =
|
||||
|
@ -100,13 +100,14 @@ OCTET_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
OCTET_STRING_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
OCTET_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
const void *sptr, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const asn_OCTET_STRING_specifics_t *specs =
|
||||
td->specifics ? (const asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_SPC_OCTET_STRING_specs;
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
const asn_oer_constraints_t *cts =
|
||||
constraints ? constraints : td->encoding_constraints.oer_constraints;
|
||||
ssize_t ct_size = cts ? cts->size : -1;
|
||||
|
|
|
@ -37,9 +37,9 @@ asn_TYPE_operation_t asn_OP_OPEN_TYPE = {
|
|||
} while(0)
|
||||
|
||||
asn_dec_rval_t
|
||||
OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void *sptr, asn_TYPE_member_t *elm, const void *ptr,
|
||||
size_t size) {
|
||||
OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const asn_TYPE_member_t *elm, const void *ptr, size_t size) {
|
||||
size_t consumed_myself = 0;
|
||||
asn_type_selector_result_t selected;
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
|
@ -122,9 +122,9 @@ OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *t
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void *sptr, asn_TYPE_member_t *elm, const void *ptr,
|
||||
size_t size) {
|
||||
OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const asn_TYPE_member_t *elm, const void *ptr, size_t size) {
|
||||
size_t consumed_myself = 0;
|
||||
asn_type_selector_result_t selected;
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
|
@ -287,8 +287,8 @@ OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *t
|
|||
|
||||
asn_dec_rval_t
|
||||
OPEN_TYPE_uper_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void *sptr,
|
||||
asn_TYPE_member_t *elm, asn_per_data_t *pd) {
|
||||
const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const asn_TYPE_member_t *elm, asn_per_data_t *pd) {
|
||||
asn_type_selector_result_t selected;
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
|
@ -361,10 +361,10 @@ OPEN_TYPE_uper_get(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
OPEN_TYPE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
OPEN_TYPE_encode_uper(const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints,
|
||||
const void *sptr, asn_per_outp_t *po) {
|
||||
const void *memb_ptr; /* Pointer to the member */
|
||||
asn_TYPE_member_t *elm; /* CHOICE's element */
|
||||
asn_enc_rval_t er;
|
||||
unsigned present;
|
||||
|
@ -383,10 +383,11 @@ OPEN_TYPE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
elm = &td->elements[present];
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
/* Member is a pointer to another structure */
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr =
|
||||
*(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
memb_ptr = (char *)sptr + elm->memb_offset;
|
||||
memb_ptr = (const char *)sptr + elm->memb_offset;
|
||||
}
|
||||
|
||||
if(uper_open_type_put(elm->type, NULL, memb_ptr, po) < 0) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2017-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_OPEN_TYPE_H
|
||||
|
@ -28,33 +28,33 @@ extern asn_TYPE_operation_t asn_OP_OPEN_TYPE;
|
|||
* by the other members of the parent structure.
|
||||
*/
|
||||
asn_dec_rval_t OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *parent_type,
|
||||
const asn_TYPE_descriptor_t *parent_type,
|
||||
void *parent_structure,
|
||||
asn_TYPE_member_t *element, const void *ptr,
|
||||
size_t size);
|
||||
const asn_TYPE_member_t *element,
|
||||
const void *ptr, size_t size);
|
||||
|
||||
asn_dec_rval_t OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *parent_type,
|
||||
const asn_TYPE_descriptor_t *parent_type,
|
||||
void *parent_structure,
|
||||
const asn_TYPE_member_t *element,
|
||||
const void *ptr, size_t size);
|
||||
|
||||
asn_dec_rval_t OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *parent_type,
|
||||
void *parent_structure,
|
||||
asn_TYPE_member_t *element, const void *ptr,
|
||||
size_t size);
|
||||
|
||||
asn_dec_rval_t OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *parent_type,
|
||||
void *parent_structure,
|
||||
asn_TYPE_member_t *element,
|
||||
const void *ptr, size_t size);
|
||||
|
||||
asn_dec_rval_t OPEN_TYPE_uper_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *parent_type,
|
||||
const asn_TYPE_descriptor_t *parent_type,
|
||||
void *parent_structure,
|
||||
asn_TYPE_member_t *element,
|
||||
const asn_TYPE_member_t *element,
|
||||
asn_per_data_t *pd);
|
||||
|
||||
asn_enc_rval_t OPEN_TYPE_encode_uper(asn_TYPE_descriptor_t *type_descriptor,
|
||||
const asn_per_constraints_t *constraints,
|
||||
void *struct_ptr,
|
||||
asn_per_outp_t *per_output);
|
||||
asn_enc_rval_t OPEN_TYPE_encode_uper(
|
||||
const asn_TYPE_descriptor_t *type_descriptor,
|
||||
const asn_per_constraints_t *constraints, const void *struct_ptr,
|
||||
asn_per_outp_t *per_output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include <errno.h>
|
||||
|
||||
asn_dec_rval_t
|
||||
OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void *sptr, asn_TYPE_member_t *elm, const void *ptr,
|
||||
size_t size) {
|
||||
OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
asn_TYPE_member_t *elm, const void *ptr, size_t size) {
|
||||
asn_type_selector_result_t selected;
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _ObjectDescriptor_H_
|
||||
|
|
|
@ -89,9 +89,10 @@ asn_TYPE_descriptor_t asn_DEF_PrintableString = {
|
|||
|
||||
|
||||
int
|
||||
PrintableString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const PrintableString_t *st = (const PrintableString_t *)sptr;
|
||||
PrintableString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb,
|
||||
void *app_key) {
|
||||
const PrintableString_t *st = (const PrintableString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _PrintableString_H_
|
||||
|
|
|
@ -306,9 +306,9 @@ REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key)
|
|||
}
|
||||
|
||||
int
|
||||
REAL_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const REAL_t *st = (const REAL_t *)sptr;
|
||||
REAL_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const REAL_t *st = (const REAL_t *)sptr;
|
||||
ssize_t ret;
|
||||
double d;
|
||||
|
||||
|
@ -369,10 +369,10 @@ REAL_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
REAL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
REAL_t *st = (REAL_t *)sptr;
|
||||
REAL_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const REAL_t *st = (const REAL_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
double d;
|
||||
|
||||
|
@ -392,8 +392,9 @@ REAL_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
* Decode the chunk of XML text encoding REAL.
|
||||
*/
|
||||
static enum xer_pbd_rval
|
||||
REAL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
|
||||
REAL_t *st = (REAL_t *)sptr;
|
||||
REAL__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const void *chunk_buf, size_t chunk_size) {
|
||||
REAL_t *st = (REAL_t *)sptr;
|
||||
double value;
|
||||
const char *xerdata = (const char *)chunk_buf;
|
||||
char *endptr = 0;
|
||||
|
@ -458,10 +459,9 @@ REAL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_b
|
|||
|
||||
asn_dec_rval_t
|
||||
REAL_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
sptr, sizeof(REAL_t), opt_mname,
|
||||
buf_ptr, size, REAL__xer_body_decode);
|
||||
}
|
||||
|
@ -846,8 +846,8 @@ asn_double2float(double d, float *outcome) {
|
|||
* Encode as Canonical OER
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
REAL_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
REAL_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const REAL_t *st = sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
@ -874,7 +874,8 @@ REAL_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
REAL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
REAL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
asn_dec_rval_t ok = {RC_OK, 0};
|
||||
|
@ -929,7 +930,8 @@ REAL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
#ifndef ASN_DISABLE_PER_SUPPORT
|
||||
|
||||
asn_dec_rval_t
|
||||
REAL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
REAL_decode_uper(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 */
|
||||
|
@ -937,8 +939,8 @@ REAL_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
REAL_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
REAL_encode_uper(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_uper(td, 0, sptr, po);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_TYPE_REAL_H
|
||||
|
|
|
@ -93,9 +93,9 @@ RELATIVE_OID__dump_body(const RELATIVE_OID_t *st, asn_app_consume_bytes_f *cb, v
|
|||
}
|
||||
|
||||
int
|
||||
RELATIVE_OID_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
|
||||
RELATIVE_OID_print(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
@ -114,8 +114,9 @@ RELATIVE_OID_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
}
|
||||
|
||||
static enum xer_pbd_rval
|
||||
RELATIVE_OID__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_buf, size_t chunk_size) {
|
||||
RELATIVE_OID_t *st = (RELATIVE_OID_t *)sptr;
|
||||
RELATIVE_OID__xer_body_decode(const asn_TYPE_descriptor_t *td, void *sptr,
|
||||
const void *chunk_buf, size_t chunk_size) {
|
||||
RELATIVE_OID_t *st = (RELATIVE_OID_t *)sptr;
|
||||
const char *chunk_end = (const char *)chunk_buf + chunk_size;
|
||||
const char *endptr;
|
||||
asn_oid_arc_t s_arcs[6];
|
||||
|
@ -157,19 +158,19 @@ RELATIVE_OID__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void
|
|||
|
||||
asn_dec_rval_t
|
||||
RELATIVE_OID_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr,
|
||||
size_t size) {
|
||||
return xer_decode_primitive(opt_codec_ctx, td,
|
||||
sptr, sizeof(RELATIVE_OID_t), opt_mname,
|
||||
buf_ptr, size, RELATIVE_OID__xer_body_decode);
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
RELATIVE_OID_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
RELATIVE_OID_t *st = (RELATIVE_OID_t *)sptr;
|
||||
RELATIVE_OID_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const RELATIVE_OID_t *st = (const RELATIVE_OID_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _RELATIVE_OID_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _T61String_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _TeletexString_H_
|
||||
|
|
|
@ -74,18 +74,17 @@ asn_TYPE_descriptor_t asn_DEF_UTCTime = {
|
|||
* Check that the time looks like the time.
|
||||
*/
|
||||
int
|
||||
UTCTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const UTCTime_t *st = (const UTCTime_t *)sptr;
|
||||
UTCTime_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const UTCTime_t *st = (const UTCTime_t *)sptr;
|
||||
time_t tloc;
|
||||
|
||||
errno = EPERM; /* Just an unlikely error code */
|
||||
tloc = asn_UT2time(st, 0, 0);
|
||||
if(tloc == -1 && errno != EPERM) {
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: Invalid time format: %s (%s:%d)",
|
||||
td->name, strerror(errno), __FILE__, __LINE__);
|
||||
return -1;
|
||||
ASN__CTFAIL(app_key, td, sptr, "%s: Invalid time format: %s (%s:%d)",
|
||||
td->name, strerror(errno), __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -94,17 +93,16 @@ UTCTime_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
#ifndef ASN___INTERNAL_TEST_MODE
|
||||
|
||||
asn_enc_rval_t
|
||||
UTCTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
UTCTime_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
if(flags & XER_F_CANONICAL) {
|
||||
asn_enc_rval_t rv;
|
||||
UTCTime_t *ut;
|
||||
struct tm tm;
|
||||
|
||||
errno = EPERM;
|
||||
if(asn_UT2time((UTCTime_t *)sptr, &tm, 1) == -1
|
||||
if(asn_UT2time((const UTCTime_t *)sptr, &tm, 1) == -1
|
||||
&& errno != EPERM)
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
|
@ -125,9 +123,9 @@ UTCTime_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
#endif /* ASN___INTERNAL_TEST_MODE */
|
||||
|
||||
int
|
||||
UTCTime_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UTCTime_t *st = (const UTCTime_t *)sptr;
|
||||
UTCTime_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UTCTime_t *st = (const UTCTime_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _UTCTime_H_
|
||||
|
|
|
@ -84,9 +84,9 @@ static const int32_t UTF8String_mv[7] = { 0, 0,
|
|||
#define U8E_EINVAL -5 /* Invalid arguments */
|
||||
|
||||
int
|
||||
UTF8String_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
ssize_t len = UTF8String_length((const UTF8String_t *)sptr);
|
||||
UTF8String_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
ssize_t len = UTF8String_length((const UTF8String_t *)sptr);
|
||||
switch(len) {
|
||||
case U8E_EINVAL:
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
|
@ -185,9 +185,9 @@ UTF8String_to_wcs(const UTF8String_t *st, uint32_t *dst, size_t dstlen) {
|
|||
}
|
||||
|
||||
int
|
||||
UTF8String_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UTF8String_t *st = (const UTF8String_t *)sptr;
|
||||
UTF8String_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UTF8String_t *st = (const UTF8String_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _UTF8String_H_
|
||||
|
|
|
@ -64,13 +64,13 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = {
|
|||
};
|
||||
|
||||
int
|
||||
UniversalString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
UniversalString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb,
|
||||
void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
if(st->size & 3) {
|
||||
if(st->size % 4) {
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: invalid size %zu not divisible by 4 (%s:%d)",
|
||||
td->name, st->size, __FILE__, __LINE__);
|
||||
|
@ -146,9 +146,10 @@ UniversalString__dump(const UniversalString_t *st,
|
|||
|
||||
asn_dec_rval_t
|
||||
UniversalString_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
asn_dec_rval_t rc;
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const char *opt_mname, const void *buf_ptr,
|
||||
size_t size) {
|
||||
asn_dec_rval_t rc;
|
||||
|
||||
rc = OCTET_STRING_decode_xer_utf8(opt_codec_ctx, td, sptr, opt_mname,
|
||||
buf_ptr, size);
|
||||
|
@ -202,10 +203,10 @@ UniversalString_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
UniversalString_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
UniversalString_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
(void)ilevel;
|
||||
|
@ -221,9 +222,9 @@ UniversalString_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
}
|
||||
|
||||
int
|
||||
UniversalString_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
UniversalString_print(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const UniversalString_t *st = (const UniversalString_t *)sptr;
|
||||
|
||||
(void)td; /* Unused argument */
|
||||
(void)ilevel; /* Unused argument */
|
||||
|
@ -236,36 +237,3 @@ UniversalString_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Biased function for randomizing UCS-4 sequences.
|
||||
*/
|
||||
static size_t
|
||||
UniversalString__random_char(uint8_t *b) {
|
||||
uint32_t code;
|
||||
|
||||
switch(asn_random_between(0, 4)) {
|
||||
case 0:
|
||||
code = 0;
|
||||
break;
|
||||
case 1:
|
||||
code = 1;
|
||||
break;
|
||||
case 2:
|
||||
code = 0xd7ff; /* End of pre-surrogate block */
|
||||
break;
|
||||
case 3:
|
||||
code = 0xe000; /* Beginning of post-surrogate block */
|
||||
break;
|
||||
case 4:
|
||||
code = 0x10ffff;
|
||||
break;
|
||||
}
|
||||
|
||||
b[0] = code >> 24;
|
||||
b[1] = code >> 16;
|
||||
b[2] = code >> 8;
|
||||
b[3] = code;
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _UniversalString_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _VideotexString_H_
|
||||
|
|
|
@ -58,9 +58,9 @@ asn_TYPE_descriptor_t asn_DEF_VisibleString = {
|
|||
};
|
||||
|
||||
int
|
||||
VisibleString_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const VisibleString_t *st = (const VisibleString_t *)sptr;
|
||||
VisibleString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const VisibleString_t *st = (const VisibleString_t *)sptr;
|
||||
|
||||
if(st && st->buf) {
|
||||
uint8_t *buf = st->buf;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _VisibleString_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_SEQUENCE_OF_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_SET_OF_H
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
#include <asn_application.h>
|
||||
#include <errno.h>
|
||||
|
||||
static asn_enc_rval_t asn_encode_internal(
|
||||
const asn_codec_ctx_t *opt_codec_ctx,
|
||||
enum asn_transfer_syntax syntax, asn_TYPE_descriptor_t *td,
|
||||
void *sptr, asn_app_consume_bytes_f *callback, void *callback_key);
|
||||
static asn_enc_rval_t asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
enum asn_transfer_syntax syntax,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const void *sptr,
|
||||
asn_app_consume_bytes_f *callback,
|
||||
void *callback_key);
|
||||
|
||||
|
||||
struct callback_count_bytes_key {
|
||||
|
@ -113,8 +115,9 @@ asn_encode(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
|
||||
asn_enc_rval_t
|
||||
asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
enum asn_transfer_syntax syntax, asn_TYPE_descriptor_t *td,
|
||||
void *sptr, void *buffer, size_t buffer_size) {
|
||||
enum asn_transfer_syntax syntax,
|
||||
const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
void *buffer, size_t buffer_size) {
|
||||
struct overrun_encoder_key buf_key;
|
||||
asn_enc_rval_t er;
|
||||
|
||||
|
@ -141,9 +144,9 @@ asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
|
||||
static asn_enc_rval_t
|
||||
asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
enum asn_transfer_syntax syntax, asn_TYPE_descriptor_t *td,
|
||||
void *sptr, asn_app_consume_bytes_f *callback,
|
||||
void *callback_key) {
|
||||
enum asn_transfer_syntax syntax,
|
||||
const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_consume_bytes_f *callback, void *callback_key) {
|
||||
asn_enc_rval_t er;
|
||||
enum xer_encoder_flags_e xer_flags = XER_F_CANONICAL;
|
||||
|
||||
|
@ -303,9 +306,8 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
|
||||
asn_dec_rval_t
|
||||
asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
enum asn_transfer_syntax syntax, struct asn_TYPE_descriptor_s *td,
|
||||
enum asn_transfer_syntax syntax, const asn_TYPE_descriptor_t *td,
|
||||
void **sptr, const void *buffer, size_t size) {
|
||||
|
||||
if(!td || !td->op || !sptr || (size && !buffer)) {
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
|
|
@ -78,9 +78,8 @@ enum asn_transfer_syntax {
|
|||
asn_enc_rval_t asn_encode_to_buffer(
|
||||
const asn_codec_ctx_t *opt_codec_parameters, /* See asn_codecs.h */
|
||||
enum asn_transfer_syntax,
|
||||
struct asn_TYPE_descriptor_s *type_to_encode,
|
||||
void *structure_to_encode,
|
||||
void *buffer, size_t buffer_size);
|
||||
const struct asn_TYPE_descriptor_s *type_to_encode,
|
||||
const void *structure_to_encode, void *buffer, size_t buffer_size);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -118,11 +117,11 @@ asn_enc_rval_t asn_encode(
|
|||
*/
|
||||
asn_dec_rval_t asn_decode(
|
||||
const asn_codec_ctx_t *opt_codec_parameters, enum asn_transfer_syntax,
|
||||
struct asn_TYPE_descriptor_s *type_to_decode,
|
||||
const struct asn_TYPE_descriptor_s *type_to_decode,
|
||||
void **structure_ptr, /* Pointer to a target structure's pointer */
|
||||
const void *buffer, /* Data to be decoded */
|
||||
size_t size /* Size of that buffer */
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -134,7 +133,7 @@ asn_dec_rval_t asn_decode(
|
|||
* particular constraint has failed.
|
||||
*/
|
||||
typedef void (asn_app_constraint_failed_f)(void *application_specific_key,
|
||||
struct asn_TYPE_descriptor_s *type_descriptor_which_failed,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor_which_failed,
|
||||
const void *structure_which_failed_ptr,
|
||||
const char *error_message_format, ...) CC_PRINTFLIKE(4, 5);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_BIT_DATA
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_CODECS_H
|
||||
|
@ -52,10 +51,10 @@ typedef struct asn_enc_rval_s {
|
|||
*/
|
||||
|
||||
/* Type which cannot be encoded */
|
||||
struct asn_TYPE_descriptor_s *failed_type;
|
||||
const struct asn_TYPE_descriptor_s *failed_type;
|
||||
|
||||
/* Pointer to the structure of that type */
|
||||
void *structure_ptr;
|
||||
const void *structure_ptr;
|
||||
} asn_enc_rval_t;
|
||||
#define ASN__ENCODE_FAILED do { \
|
||||
asn_enc_rval_t tmp_error; \
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
ber_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void **sptr, const void *buf_ptr, size_t size, int tag_mode) {
|
||||
ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)*sptr;
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const void *buf_ptr, size_t size, int tag_mode) {
|
||||
ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)*sptr;
|
||||
asn_dec_rval_t rval;
|
||||
ber_tlv_len_t length = 0; /* =0 to avoid [incorrect] warning. */
|
||||
|
||||
|
@ -81,11 +81,11 @@ ber_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
* Encode an always-primitive type using DER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
der_encode_primitive(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr;
|
||||
der_encode_primitive(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t erval;
|
||||
const ASN__PRIMITIVE_TYPE_t *st = (const ASN__PRIMITIVE_TYPE_t *)sptr;
|
||||
|
||||
ASN_DEBUG("%s %s as a primitive type (tm=%d)",
|
||||
cb?"Encoding":"Estimating", td->name, tag_mode);
|
||||
|
@ -144,8 +144,8 @@ ASN__PRIMITIVE_TYPE_free(const asn_TYPE_descriptor_t *td, void *sptr,
|
|||
* Local internal type passed around as an argument.
|
||||
*/
|
||||
struct xdp_arg_s {
|
||||
asn_TYPE_descriptor_t *type_descriptor;
|
||||
void *struct_key;
|
||||
const asn_TYPE_descriptor_t *type_descriptor;
|
||||
void *struct_key;
|
||||
xer_primitive_body_decoder_f *prim_body_decoder;
|
||||
int decoded_something;
|
||||
int want_more;
|
||||
|
@ -249,14 +249,11 @@ xer_decode__primitive_body(void *key, const void *chunk_buf, size_t chunk_size,
|
|||
|
||||
asn_dec_rval_t
|
||||
xer_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
void **sptr,
|
||||
size_t struct_size,
|
||||
const char *opt_mname,
|
||||
const void *buf_ptr, size_t size,
|
||||
xer_primitive_body_decoder_f *prim_body_decoder
|
||||
) {
|
||||
const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
size_t struct_size, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size,
|
||||
xer_primitive_body_decoder_f *prim_body_decoder) {
|
||||
const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
|
||||
asn_struct_ctx_t s_ctx;
|
||||
struct xdp_arg_s s_arg;
|
||||
asn_dec_rval_t rc;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_CODECS_PRIM_H
|
||||
|
@ -30,21 +30,19 @@ enum xer_pbd_rval {
|
|||
XPBD_NOT_BODY_IGNORE, /* Not a body format, but safe to ignore */
|
||||
XPBD_BODY_CONSUMED /* Body is recognized and consumed */
|
||||
};
|
||||
typedef enum xer_pbd_rval (xer_primitive_body_decoder_f)
|
||||
(asn_TYPE_descriptor_t *td, void *struct_ptr,
|
||||
const void *chunk_buf, size_t chunk_size);
|
||||
typedef enum xer_pbd_rval(xer_primitive_body_decoder_f)(
|
||||
const asn_TYPE_descriptor_t *td, void *struct_ptr,
|
||||
const void *chunk_buf, size_t chunk_size);
|
||||
|
||||
/*
|
||||
* Specific function to decode simple primitive types.
|
||||
* Also see xer_decode_general() in xer_decoder.h
|
||||
*/
|
||||
asn_dec_rval_t xer_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *type_descriptor,
|
||||
void **struct_ptr, size_t struct_size,
|
||||
const char *opt_mname,
|
||||
const void *buf_ptr, size_t size,
|
||||
xer_primitive_body_decoder_f *prim_body_decoder
|
||||
);
|
||||
asn_dec_rval_t xer_decode_primitive(
|
||||
const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
|
||||
size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size,
|
||||
xer_primitive_body_decoder_f *prim_body_decoder);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005, 2007 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
/*
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN_RANDOM_FILL
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
/*
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
ber_decode(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *type_descriptor,
|
||||
void **struct_ptr, const void *ptr, size_t size) {
|
||||
asn_codec_ctx_t s_codec_ctx;
|
||||
const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
asn_codec_ctx_t s_codec_ctx;
|
||||
|
||||
/*
|
||||
* Stack checker requires that the codec context
|
||||
|
@ -63,10 +63,10 @@ ber_decode(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
ber_check_tags(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx,
|
||||
const void *ptr, size_t size, int tag_mode, int last_tag_form,
|
||||
ber_tlv_len_t *last_length, int *opt_tlv_form) {
|
||||
ssize_t consumed_myself = 0;
|
||||
const asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx,
|
||||
const void *ptr, size_t size, int tag_mode, int last_tag_form,
|
||||
ber_tlv_len_t *last_length, int *opt_tlv_form) {
|
||||
ssize_t consumed_myself = 0;
|
||||
ssize_t tag_len;
|
||||
ssize_t len_len;
|
||||
ber_tlv_tag_t tlv_tag;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _BER_DECODER_H_
|
||||
|
@ -22,21 +22,21 @@ struct asn_codec_ctx_s; /* Forward declaration */
|
|||
* NOTE: Use the der_encode() function (der_encoder.h) to produce encoding
|
||||
* which is compliant with ber_decode().
|
||||
*/
|
||||
asn_dec_rval_t ber_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void **struct_ptr, /* Pointer to a target structure's pointer */
|
||||
const void *buffer, /* Data to be decoded */
|
||||
size_t size /* Size of that buffer */
|
||||
);
|
||||
asn_dec_rval_t ber_decode(
|
||||
const struct asn_codec_ctx_s *opt_codec_ctx,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void **struct_ptr, /* Pointer to a target structure's pointer */
|
||||
const void *buffer, /* Data to be decoded */
|
||||
size_t size /* Size of that buffer */
|
||||
);
|
||||
|
||||
/*
|
||||
* Type of generic function which decodes the byte stream into the structure.
|
||||
*/
|
||||
typedef asn_dec_rval_t (ber_type_decoder_f)(
|
||||
const struct asn_codec_ctx_s *opt_codec_ctx,
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void **struct_ptr, const void *buf_ptr, size_t size,
|
||||
int tag_mode);
|
||||
typedef asn_dec_rval_t(ber_type_decoder_f)(
|
||||
const struct asn_codec_ctx_s *opt_codec_ctx,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr,
|
||||
const void *buf_ptr, size_t size, int tag_mode);
|
||||
|
||||
/*******************************
|
||||
* INTERNALLY USEFUL FUNCTIONS *
|
||||
|
@ -50,15 +50,14 @@ typedef asn_dec_rval_t (ber_type_decoder_f)(
|
|||
* head->last_tag_form is non-zero.
|
||||
*/
|
||||
asn_dec_rval_t ber_check_tags(
|
||||
const struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
asn_struct_ctx_t *opt_ctx, /* saved decoding context */
|
||||
const void *ptr, size_t size,
|
||||
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
|
||||
int last_tag_form, /* {-1,0:1}: any, primitive, constr */
|
||||
ber_tlv_len_t *last_length,
|
||||
int *opt_tlv_form /* optional tag form */
|
||||
);
|
||||
const struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
asn_struct_ctx_t *opt_ctx, /* saved decoding context */
|
||||
const void *ptr, size_t size,
|
||||
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
|
||||
int last_tag_form, /* {-1,0:1}: any, primitive, constr */
|
||||
ber_tlv_len_t *last_length, int *opt_tlv_form /* optional tag form */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _BER_TLV_LENGTH_H_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _BER_TLV_TAG_H_
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#include <asn_internal.h>
|
||||
|
@ -103,9 +102,10 @@ _search4tag(const void *ap, const void *bp) {
|
|||
* The decoder of the CHOICE type.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_CHOICE_specifics_t *specs =
|
||||
|
@ -360,13 +360,13 @@ CHOICE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *t
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
|
||||
CHOICE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elm; /* CHOICE element */
|
||||
asn_enc_rval_t erval;
|
||||
void *memb_ptr;
|
||||
const void *memb_ptr;
|
||||
size_t computed_size = 0;
|
||||
unsigned present;
|
||||
|
||||
|
@ -396,8 +396,9 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
*/
|
||||
elm = &td->elements[present-1];
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(memb_ptr == 0) {
|
||||
memb_ptr =
|
||||
*(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(memb_ptr == 0) {
|
||||
if(elm->optional) {
|
||||
erval.encoded = 0;
|
||||
ASN__ENCODED_OK(erval);
|
||||
|
@ -406,8 +407,8 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the CHOICE itself is tagged EXPLICIT:
|
||||
|
@ -483,10 +484,11 @@ CHOICE_outmost_tag(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mod
|
|||
}
|
||||
|
||||
int
|
||||
CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
|
||||
unsigned present;
|
||||
CHOICE_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs =
|
||||
(const asn_CHOICE_specifics_t *)td->specifics;
|
||||
unsigned present;
|
||||
|
||||
if(!sptr) {
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
|
@ -544,10 +546,10 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
* Decode the XER (XML) data.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
CHOICE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
/*
|
||||
CHOICE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
|
||||
|
@ -774,11 +776,12 @@ CHOICE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *t
|
|||
|
||||
|
||||
asn_enc_rval_t
|
||||
CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs=(const asn_CHOICE_specifics_t *)td->specifics;
|
||||
asn_enc_rval_t er;
|
||||
CHOICE_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs =
|
||||
(const asn_CHOICE_specifics_t *)td->specifics;
|
||||
asn_enc_rval_t er;
|
||||
unsigned present;
|
||||
|
||||
if(!sptr)
|
||||
|
@ -794,18 +797,19 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
} else {
|
||||
asn_enc_rval_t tmper;
|
||||
asn_TYPE_member_t *elm = &td->elements[present-1];
|
||||
void *memb_ptr;
|
||||
const void *memb_ptr;
|
||||
const char *mname = elm->name;
|
||||
unsigned int mlen = strlen(mname);
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
memb_ptr =
|
||||
*(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
er.encoded = 0;
|
||||
er.encoded = 0;
|
||||
|
||||
if(!(flags & XER_F_CANONICAL)) ASN__TEXT_INDENT(1, ilevel);
|
||||
ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
@ -826,7 +830,8 @@ cb_failed:
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
CHOICE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
CHOICE_decode_uper(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 =
|
||||
|
@ -878,8 +883,11 @@ CHOICE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *
|
|||
}
|
||||
|
||||
/* Adjust if canonical order is different from natural order */
|
||||
if(specs->canonical_order)
|
||||
value = specs->canonical_order[value];
|
||||
if(specs->from_canonical_order) {
|
||||
ASN_DEBUG("CHOICE presence from wire %d", value);
|
||||
value = specs->from_canonical_order[value];
|
||||
ASN_DEBUG("CHOICE presence index effective %d", value);
|
||||
}
|
||||
|
||||
/* Set presence to be able to free it later */
|
||||
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
|
||||
|
@ -909,13 +917,13 @@ CHOICE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
CHOICE_encode_uper(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_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elm; /* CHOICE's element */
|
||||
const asn_per_constraint_t *ct;
|
||||
void *memb_ptr;
|
||||
const void *memb_ptr;
|
||||
unsigned present;
|
||||
int present_enc;
|
||||
|
||||
|
@ -941,17 +949,20 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
|
||||
ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present);
|
||||
|
||||
/* Adjust if canonical order is different from natural order */
|
||||
if(specs->canonical_order)
|
||||
present_enc = specs->canonical_order[present];
|
||||
else
|
||||
present_enc = present;
|
||||
/* Adjust if canonical order is different from natural order */
|
||||
if(specs->to_canonical_order)
|
||||
present_enc = specs->to_canonical_order[present];
|
||||
else
|
||||
present_enc = present;
|
||||
|
||||
if(ct && ct->range_bits >= 0) {
|
||||
if(ct && ct->range_bits >= 0) {
|
||||
if(present_enc < ct->lower_bound
|
||||
|| present_enc > ct->upper_bound) {
|
||||
if(ct->flags & APC_EXTENSIBLE) {
|
||||
if(per_put_few_bits(po, 1, 1))
|
||||
ASN_DEBUG(
|
||||
"CHOICE member %d (enc %d) is an extension (%ld..%ld)",
|
||||
present, present_enc, ct->lower_bound, ct->upper_bound);
|
||||
if(per_put_few_bits(po, 1, 1))
|
||||
ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
ASN__ENCODE_FAILED;
|
||||
|
@ -959,44 +970,51 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
ct = 0;
|
||||
}
|
||||
}
|
||||
if(ct && ct->flags & APC_EXTENSIBLE)
|
||||
if(per_put_few_bits(po, 0, 1))
|
||||
if(ct && ct->flags & APC_EXTENSIBLE) {
|
||||
ASN_DEBUG("CHOICE member %d (enc %d) is not an extension (%ld..%ld)",
|
||||
present, present_enc, ct->lower_bound, ct->upper_bound);
|
||||
if(per_put_few_bits(po, 0, 1))
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
|
||||
elm = &td->elements[present];
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
ASN_DEBUG("CHOICE member \"%s\" %d (as %d)", elm->name, present,
|
||||
present_enc);
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
/* Member is a pointer to another structure */
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
memb_ptr =
|
||||
*(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
memb_ptr = (char *)sptr + elm->memb_offset;
|
||||
}
|
||||
memb_ptr = (const char *)sptr + elm->memb_offset;
|
||||
}
|
||||
|
||||
if(ct && ct->range_bits >= 0) {
|
||||
if(per_put_few_bits(po, present_enc, ct->range_bits))
|
||||
ASN__ENCODE_FAILED;
|
||||
if(ct && ct->range_bits >= 0) {
|
||||
if(per_put_few_bits(po, present_enc, ct->range_bits))
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
return elm->type->op->uper_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(uper_put_nsnnwn(po, present_enc - specs->ext_start))
|
||||
ASN__ENCODE_FAILED;
|
||||
if(uper_open_type_put(elm->type, elm->encoding_constraints.per_constraints,
|
||||
memb_ptr, po))
|
||||
ASN__ENCODE_FAILED;
|
||||
rval.encoded = 0;
|
||||
ASN__ENCODED_OK(rval);
|
||||
}
|
||||
return elm->type->op->uper_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(uper_put_nsnnwn(po, present_enc - specs->ext_start))
|
||||
ASN__ENCODE_FAILED;
|
||||
if(uper_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(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
|
||||
CHOICE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
|
||||
unsigned present;
|
||||
|
||||
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _CONSTR_CHOICE_H_
|
||||
|
@ -28,7 +27,8 @@ typedef struct asn_CHOICE_specifics_s {
|
|||
unsigned tag2el_count;
|
||||
|
||||
/* Canonical ordering of CHOICE elements, for PER */
|
||||
const unsigned *canonical_order;
|
||||
const unsigned *to_canonical_order;
|
||||
const unsigned *from_canonical_order;
|
||||
|
||||
/*
|
||||
* Extensions-related stuff.
|
||||
|
|
|
@ -125,7 +125,8 @@ oer_fetch_tag(const void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
CHOICE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
CHOICE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
/*
|
||||
|
@ -314,14 +315,14 @@ oer_put_tag(ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
CHOICE_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
CHOICE_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_CHOICE_specifics_t *specs =
|
||||
(const asn_CHOICE_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elm; /* CHOICE element */
|
||||
unsigned present;
|
||||
void *memb_ptr;
|
||||
const void *memb_ptr;
|
||||
ber_tlv_tag_t tag;
|
||||
ssize_t tag_len;
|
||||
asn_enc_rval_t er = {0, 0, 0};
|
||||
|
@ -340,13 +341,14 @@ CHOICE_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
|
||||
elm = &td->elements[present-1];
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr =
|
||||
*(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(memb_ptr == 0) {
|
||||
/* Mandatory element absent */
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
tag = asn_TYPE_outmost_tag(elm->type, memb_ptr, elm->tag_mode, elm->tag);
|
||||
|
@ -359,7 +361,7 @@ CHOICE_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
if(specs->ext_start >= 0 && specs->ext_start <= (present-1)) {
|
||||
if(specs->ext_start >= 0 && (unsigned)specs->ext_start <= (present-1)) {
|
||||
ssize_t encoded = oer_open_type_put(elm->type,
|
||||
elm->encoding_constraints.oer_constraints,
|
||||
memb_ptr, cb, app_key);
|
||||
|
|
|
@ -110,15 +110,16 @@ _t2e_cmp(const void *ap, const void *bp) {
|
|||
* The decoder of the SEQUENCE type.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elements = td->elements;
|
||||
const asn_TYPE_member_t *elements = td->elements;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Parts of the structure being constructed.
|
||||
*/
|
||||
void *st = *struct_ptr; /* Target structure. */
|
||||
|
@ -515,10 +516,10 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
* The DER encoder of the SEQUENCE type.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
||||
void *sptr, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t computed_size = 0;
|
||||
SEQUENCE_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t computed_size = 0;
|
||||
asn_enc_rval_t erval;
|
||||
ssize_t ret;
|
||||
size_t edx;
|
||||
|
@ -532,12 +533,13 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
|||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
const void *memb_ptr; /* Pointer to the member */
|
||||
const void *const *memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
ASN_DEBUG("Element %s %zu not present",
|
||||
elm->name, edx);
|
||||
if(elm->optional)
|
||||
|
@ -546,12 +548,12 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
|||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
}
|
||||
|
||||
/* Eliminate default values */
|
||||
if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
|
||||
if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
|
||||
continue;
|
||||
|
||||
erval = elm->type->op->der_encoder(elm->type, *memb_ptr2,
|
||||
|
@ -581,20 +583,21 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
|||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
asn_enc_rval_t tmperval;
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
const void *memb_ptr; /* Pointer to the member */
|
||||
const void *const *memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) continue;
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) continue;
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
}
|
||||
|
||||
/* Eliminate default values */
|
||||
if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
|
||||
continue;
|
||||
if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
|
||||
continue;
|
||||
|
||||
tmperval = elm->type->op->der_encoder(elm->type, *memb_ptr2,
|
||||
elm->tag_mode, elm->tag, cb, app_key);
|
||||
|
@ -628,10 +631,10 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
|||
* Decode the XER (XML) data.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const char *opt_mname,
|
||||
const void *ptr, size_t size) {
|
||||
/*
|
||||
SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const char *opt_mname, const void *ptr, size_t size) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_SEQUENCE_specifics_t *specs
|
||||
|
@ -876,9 +879,9 @@ SEQUENCE_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
SEQUENCE_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
asn_TYPE_descriptor_t *tmp_def_val_td = 0;
|
||||
|
@ -892,16 +895,17 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
|
|||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn_enc_rval_t tmper;
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr;
|
||||
const void *memb_ptr;
|
||||
const char *mname = elm->name;
|
||||
unsigned int mlen = strlen(mname);
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr =
|
||||
*(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) {
|
||||
assert(tmp_def_val == 0);
|
||||
if(elm->default_value) {
|
||||
if(elm->default_value(1, &tmp_def_val)) {
|
||||
if(elm->default_value_set) {
|
||||
if(elm->default_value_set(&tmp_def_val)) {
|
||||
ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
memb_ptr = tmp_def_val;
|
||||
|
@ -915,7 +919,7 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel);
|
||||
|
@ -943,9 +947,9 @@ cb_failed:
|
|||
}
|
||||
|
||||
int
|
||||
SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t edx;
|
||||
SEQUENCE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t edx;
|
||||
int ret;
|
||||
|
||||
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||
|
@ -1035,9 +1039,9 @@ SEQUENCE_free(const asn_TYPE_descriptor_t *td, void *sptr,
|
|||
}
|
||||
|
||||
int
|
||||
SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
size_t edx;
|
||||
SEQUENCE_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
size_t edx;
|
||||
|
||||
if(!sptr) {
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
|
@ -1083,10 +1087,11 @@ SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
#ifndef ASN_DISABLE_PER_SUPPORT
|
||||
|
||||
asn_dec_rval_t
|
||||
SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
SEQUENCE_decode_uper(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_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
|
||||
const asn_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
|
||||
void *st = *sptr; /* Target structure. */
|
||||
int extpresent; /* Extension additions are present */
|
||||
uint8_t *opres; /* Presence of optional root members */
|
||||
|
@ -1159,9 +1164,9 @@ SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
(int)opmd.nboff, (int)opmd.nbits);
|
||||
if(present == 0) {
|
||||
/* This element is not present */
|
||||
if(elm->default_value) {
|
||||
if(elm->default_value_set) {
|
||||
/* Fill-in DEFAULT */
|
||||
if(elm->default_value(1, memb_ptr2)) {
|
||||
if(elm->default_value_set(memb_ptr2)) {
|
||||
FREEMEM(opres);
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
@ -1281,7 +1286,7 @@ SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void **memb_ptr2; /* Pointer to member pointer */
|
||||
|
||||
if(!elm->default_value) continue;
|
||||
if(!elm->default_value_set) continue;
|
||||
|
||||
/* Fetch the pointer to this member */
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
|
@ -1293,8 +1298,8 @@ SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
}
|
||||
|
||||
/* Set default value */
|
||||
if(elm->default_value(1, memb_ptr2)) {
|
||||
ASN__DECODE_FAILED;
|
||||
if(elm->default_value_set(memb_ptr2)) {
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1304,9 +1309,9 @@ SEQUENCE_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
}
|
||||
|
||||
static int
|
||||
SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
asn_per_outp_t *po1, asn_per_outp_t *po2) {
|
||||
const asn_SEQUENCE_specifics_t *specs
|
||||
SEQUENCE__handle_extensions(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_per_outp_t *po1, asn_per_outp_t *po2) {
|
||||
const asn_SEQUENCE_specifics_t *specs
|
||||
= (const asn_SEQUENCE_specifics_t *)td->specifics;
|
||||
int exts_present = 0;
|
||||
int exts_count = 0;
|
||||
|
@ -1318,9 +1323,9 @@ SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
/* Find out which extensions are present */
|
||||
for(edx = specs->ext_after + 1; edx < td->elements_count; edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
int present;
|
||||
const void *memb_ptr; /* Pointer to the member */
|
||||
const void *const *memb_ptr2; /* Pointer to that pointer */
|
||||
int present;
|
||||
|
||||
if(!IN_EXTENSION_GROUP(specs, edx)) {
|
||||
ASN_DEBUG("%s (@%zu) is not extension", elm->type->name, edx);
|
||||
|
@ -1329,11 +1334,12 @@ SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
|
||||
/* Fetch the pointer to this member */
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
present = (*memb_ptr2 != 0);
|
||||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
present = (*memb_ptr2 != 0);
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
present = 1;
|
||||
}
|
||||
|
||||
|
@ -1356,10 +1362,10 @@ SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
SEQUENCE_encode_uper(const asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, const void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
const asn_SEQUENCE_specifics_t *specs
|
||||
const asn_SEQUENCE_specifics_t *specs
|
||||
= (const asn_SEQUENCE_specifics_t *)td->specifics;
|
||||
asn_enc_rval_t er;
|
||||
int n_extensions;
|
||||
|
@ -1381,7 +1387,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
* and whether to encode extensions
|
||||
*/
|
||||
if(specs->ext_before >= 0) {
|
||||
n_extensions = SEQUENCE_handle_extensions(td, sptr, 0, 0);
|
||||
n_extensions = SEQUENCE__handle_extensions(td, sptr, 0, 0);
|
||||
if(n_extensions < 0)
|
||||
ASN__ENCODE_FAILED;
|
||||
if(per_put_few_bits(po, n_extensions ? 1 : 0, 1))
|
||||
|
@ -1393,31 +1399,32 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
/* Encode a presence bitmap */
|
||||
for(i = 0; i < specs->roms_count; i++) {
|
||||
asn_TYPE_member_t *elm;
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
int present;
|
||||
const void *memb_ptr; /* Pointer to the member */
|
||||
const void *const *memb_ptr2; /* Pointer to that pointer */
|
||||
int present;
|
||||
|
||||
edx = specs->oms[i];
|
||||
elm = &td->elements[edx];
|
||||
|
||||
/* Fetch the pointer to this member */
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
present = (*memb_ptr2 != 0);
|
||||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
present = (*memb_ptr2 != 0);
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
present = 1;
|
||||
}
|
||||
|
||||
/* Eliminate default values */
|
||||
if(present && elm->default_value
|
||||
&& elm->default_value(0, memb_ptr2) == 1)
|
||||
present = 0;
|
||||
if(present && elm->default_value_cmp
|
||||
&& elm->default_value_cmp(*memb_ptr2) == 0)
|
||||
present = 0;
|
||||
|
||||
ASN_DEBUG("Element %s %s %s->%s is %s",
|
||||
elm->flags & ATF_POINTER ? "ptr" : "inline",
|
||||
elm->default_value ? "def" : "wtv",
|
||||
elm->default_value_cmp ? "def" : "wtv",
|
||||
td->name, elm->name, present ? "present" : "absent");
|
||||
if(per_put_few_bits(po, present, 1))
|
||||
ASN__ENCODE_FAILED;
|
||||
|
@ -1431,18 +1438,19 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
? td->elements_count : specs->ext_before - 1); edx++) {
|
||||
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
const void *memb_ptr; /* Pointer to the member */
|
||||
const void *const *memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
if(IN_EXTENSION_GROUP(specs, edx))
|
||||
if(IN_EXTENSION_GROUP(specs, edx))
|
||||
continue;
|
||||
|
||||
ASN_DEBUG("About to encode %s", elm->type->name);
|
||||
|
||||
/* Fetch the pointer to this member */
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
ASN_DEBUG("Element %s %zu not present",
|
||||
elm->name, edx);
|
||||
if(elm->optional)
|
||||
|
@ -1451,12 +1459,12 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr;
|
||||
}
|
||||
|
||||
/* Eliminate default values */
|
||||
if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
|
||||
if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
|
||||
continue;
|
||||
|
||||
ASN_DEBUG("Encoding %s->%s", td->name, elm->name);
|
||||
|
@ -1477,12 +1485,12 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||
ASN_DEBUG("Bit-map of %d elements", n_extensions);
|
||||
/* #18.7. Encoding the extensions presence bit-map. */
|
||||
/* TODO: act upon NOTE in #18.7 for canonical PER */
|
||||
if(SEQUENCE_handle_extensions(td, sptr, po, 0) != n_extensions)
|
||||
if(SEQUENCE__handle_extensions(td, sptr, po, 0) != n_extensions)
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("Writing %d extensions", n_extensions);
|
||||
/* #18.9. Encode extensions as open type fields. */
|
||||
if(SEQUENCE_handle_extensions(td, sptr, 0, po) != n_extensions)
|
||||
if(SEQUENCE__handle_extensions(td, sptr, 0, po) != n_extensions)
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
ASN__ENCODED_OK(er);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _CONSTR_SEQUENCE_H_
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
* The DER encoder of the SEQUENCE OF type.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(ptr);
|
||||
SEQUENCE_OF_encode_der(const asn_TYPE_descriptor_t *td, const void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
const asn_anonymous_sequence_ *list = _A_CSEQUENCE_FROM_VOID(ptr);
|
||||
size_t computed_size = 0;
|
||||
ssize_t encoding_size = 0;
|
||||
asn_enc_rval_t erval;
|
||||
|
@ -88,17 +88,17 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags,
|
||||
SEQUENCE_OF_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(sptr);
|
||||
const asn_TYPE_member_t *elm = td->elements;
|
||||
const asn_anonymous_sequence_ *list = _A_CSEQUENCE_FROM_VOID(sptr);
|
||||
const char *mname = specs->as_XMLValueList
|
||||
? 0
|
||||
: ((*elm->name) ? elm->name : elm->type->xml_tag);
|
||||
unsigned int mlen = mname ? strlen(mname) : 0;
|
||||
size_t mlen = mname ? strlen(mname) : 0;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
int i;
|
||||
|
||||
|
@ -140,19 +140,19 @@ cb_failed:
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const asn_per_constraints_t *constraints, void *sptr,
|
||||
asn_per_outp_t *po) {
|
||||
asn_anonymous_sequence_ *list;
|
||||
SEQUENCE_OF_encode_uper(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;
|
||||
const asn_TYPE_member_t *elm = td->elements;
|
||||
int seq;
|
||||
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
list = _A_SEQUENCE_FROM_VOID(sptr);
|
||||
list = _A_CSEQUENCE_FROM_VOID(sptr);
|
||||
|
||||
er.encoded = 0;
|
||||
er.encoded = 0;
|
||||
|
||||
ASN_DEBUG("Encoding %s as SEQUENCE OF (%d)", td->name, list->count);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _CONSTR_SEQUENCE_OF_H_
|
||||
|
|
|
@ -66,17 +66,20 @@ element_ptrptr(void *struct_ptr, asn_TYPE_member_t *elm, void **tmp_save_ptr) {
|
|||
}
|
||||
}
|
||||
|
||||
static void *element_ptr(void *struct_ptr, asn_TYPE_member_t *elm) {
|
||||
static const void *
|
||||
element_ptr(const void *struct_ptr, const asn_TYPE_member_t *elm) {
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
/* Member is a pointer to another structure */
|
||||
return *(void **)((char *)struct_ptr + elm->memb_offset);
|
||||
return *(const void *const *)((const char *)struct_ptr
|
||||
+ elm->memb_offset);
|
||||
} else {
|
||||
return (void *)((char *)struct_ptr + elm->memb_offset);
|
||||
return (const void *)((const char *)struct_ptr + elm->memb_offset);
|
||||
}
|
||||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
const asn_SEQUENCE_specifics_t *specs =
|
||||
|
@ -177,11 +180,11 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
ASN_DEBUG("Presence map ended prematurely: %d", present);
|
||||
RETURN(RC_FAIL);
|
||||
} else if(present == 0) {
|
||||
if(elm->default_value) {
|
||||
if(elm->default_value_set) {
|
||||
/* Fill-in DEFAULT */
|
||||
void *tmp;
|
||||
if(elm->default_value(1,
|
||||
element_ptrptr(st, elm, &tmp))) {
|
||||
if(elm->default_value_set(
|
||||
element_ptrptr(st, elm, &tmp))) {
|
||||
RETURN(RC_FAIL);
|
||||
}
|
||||
}
|
||||
|
@ -322,7 +325,8 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
/* Fall through */
|
||||
case 0:
|
||||
/* Fill-in DEFAULT */
|
||||
if(elm->default_value && elm->default_value(1, memb_ptr2)) {
|
||||
if(elm->default_value_set
|
||||
&& elm->default_value_set(memb_ptr2)) {
|
||||
RETURN(RC_FAIL);
|
||||
}
|
||||
continue;
|
||||
|
@ -388,8 +392,8 @@ SEQUENCE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
SEQUENCE_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_SEQUENCE_specifics_t *specs = (const asn_SEQUENCE_specifics_t *)td->specifics;
|
||||
size_t computed_size = 0;
|
||||
|
@ -412,10 +416,10 @@ SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
for(edx = specs->ext_after + 1;
|
||||
(ssize_t)edx < specs->ext_before - 1; edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr = element_ptr(sptr, elm);
|
||||
const void *memb_ptr = element_ptr(sptr, elm);
|
||||
if(memb_ptr) {
|
||||
if(elm->default_value
|
||||
&& elm->default_value(0, &memb_ptr) == 1) {
|
||||
if(elm->default_value_cmp
|
||||
&& elm->default_value_cmp(memb_ptr) == 0) {
|
||||
/* Do not encode default values in extensions */
|
||||
} else {
|
||||
has_extensions = 1;
|
||||
|
@ -440,10 +444,10 @@ SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
if(IN_EXTENSION_GROUP(specs, edx)) break;
|
||||
|
||||
if(elm->optional) {
|
||||
void *memb_ptr = element_ptr(sptr, elm);
|
||||
const void *memb_ptr = element_ptr(sptr, elm);
|
||||
uint32_t has_component = memb_ptr != NULL;
|
||||
if(has_component && elm->default_value
|
||||
&& elm->default_value(0, &memb_ptr) == 1) {
|
||||
if(has_component && elm->default_value_cmp
|
||||
&& elm->default_value_cmp(&memb_ptr) == 0) {
|
||||
has_component = 0;
|
||||
}
|
||||
ret = asn_put_few_bits(&preamble, has_component, 1);
|
||||
|
@ -464,13 +468,14 @@ SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
asn_enc_rval_t er;
|
||||
void *memb_ptr;
|
||||
const void *memb_ptr;
|
||||
|
||||
if(IN_EXTENSION_GROUP(specs, edx)) break;
|
||||
|
||||
memb_ptr = element_ptr(sptr, elm);
|
||||
if(memb_ptr) {
|
||||
if(elm->default_value && elm->default_value(0, &memb_ptr) == 1) {
|
||||
if(elm->default_value_cmp
|
||||
&& elm->default_value_cmp(memb_ptr) == 0) {
|
||||
/* Skip default values in encoding */
|
||||
continue;
|
||||
}
|
||||
|
@ -524,9 +529,9 @@ SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
for(edx = specs->ext_after + 1; (ssize_t)edx < specs->ext_before - 1;
|
||||
edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr = element_ptr(sptr, elm);
|
||||
if(memb_ptr && elm->default_value
|
||||
&& elm->default_value(0, &memb_ptr) == 1) {
|
||||
const void *memb_ptr = element_ptr(sptr, elm);
|
||||
if(memb_ptr && elm->default_value_cmp
|
||||
&& elm->default_value_cmp(memb_ptr) == 0) {
|
||||
memb_ptr = 0; /* Do not encode default value. */
|
||||
}
|
||||
ret |= asn_put_few_bits(&extadds, memb_ptr ? 1 : 0, 1);
|
||||
|
@ -540,11 +545,11 @@ SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
for(edx = specs->ext_after + 1; (ssize_t)edx < specs->ext_before - 1;
|
||||
edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
void *memb_ptr = element_ptr(sptr, elm);
|
||||
const void *memb_ptr = element_ptr(sptr, elm);
|
||||
|
||||
if(memb_ptr) {
|
||||
if(elm->default_value
|
||||
&& elm->default_value(0, &memb_ptr) == 1) {
|
||||
if(elm->default_value_cmp
|
||||
&& elm->default_value_cmp(memb_ptr) == 0) {
|
||||
/* Do not encode default value. */
|
||||
} else {
|
||||
asn_enc_rval_t er = elm->type->op->oer_encoder(
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <constr_SET.h>
|
||||
|
||||
/* Check that all the mandatory members are present */
|
||||
static int _SET_is_populated(asn_TYPE_descriptor_t *td, void *st);
|
||||
static int _SET_is_populated(const asn_TYPE_descriptor_t *td, const void *st);
|
||||
|
||||
/*
|
||||
* Number of bytes left for this structure.
|
||||
|
@ -94,13 +94,14 @@ _t2e_cmp(const void *ap, const void *bp) {
|
|||
* The decoder of the SET type.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elements = td->elements;
|
||||
const asn_TYPE_member_t *elements = td->elements;
|
||||
|
||||
/*
|
||||
* Parts of the structure being constructed.
|
||||
|
@ -392,8 +393,8 @@ SET_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
static int
|
||||
_SET_is_populated(asn_TYPE_descriptor_t *td, void *st) {
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
_SET_is_populated(const asn_TYPE_descriptor_t *td, const void *st) {
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
size_t edx;
|
||||
|
||||
/*
|
||||
|
@ -404,8 +405,9 @@ _SET_is_populated(asn_TYPE_descriptor_t *td, void *st) {
|
|||
unsigned int midx, pres, must;
|
||||
|
||||
midx = edx/(8 * sizeof(specs->_mandatory_elements[0]));
|
||||
pres = ((unsigned int *)((char *)st + specs->pres_offset))[midx];
|
||||
must = sys_ntohl(specs->_mandatory_elements[midx]);
|
||||
pres = ((const unsigned int *)((const char *)st
|
||||
+ specs->pres_offset))[midx];
|
||||
must = sys_ntohl(specs->_mandatory_elements[midx]);
|
||||
|
||||
if((pres & must) == must) {
|
||||
/*
|
||||
|
@ -432,10 +434,9 @@ _SET_is_populated(asn_TYPE_descriptor_t *td, void *st) {
|
|||
* The DER encoder of the SET type.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
SET_encode_der(asn_TYPE_descriptor_t *td,
|
||||
void *sptr, int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
SET_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr, int tag_mode,
|
||||
ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
size_t computed_size = 0;
|
||||
asn_enc_rval_t er;
|
||||
int t2m_build_own = (specs->tag2el_count != td->elements_count);
|
||||
|
@ -467,15 +468,16 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
|
|||
for(edx = 0; edx < td->elements_count; edx++) {
|
||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||
asn_enc_rval_t tmper;
|
||||
void *memb_ptr_dontuse; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
const void *memb_ptr_dontuse; /* Pointer to the member */
|
||||
const void *const *memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Compute the length of the encoding of this member.
|
||||
*/
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) {
|
||||
if(!elm->optional) {
|
||||
/* Mandatory elements missing */
|
||||
FREEMEM(t2m_build);
|
||||
|
@ -489,13 +491,14 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
|
|||
continue;
|
||||
}
|
||||
} else {
|
||||
memb_ptr_dontuse = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
|
||||
memb_ptr_dontuse =
|
||||
(const void *)((const char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
|
||||
}
|
||||
|
||||
/* Eliminate default values */
|
||||
if(elm->default_value && elm->default_value(0, memb_ptr2) == 1) {
|
||||
if(t2m_build) {
|
||||
if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0) {
|
||||
if(t2m_build) {
|
||||
t2m_build[t2m_count].el_no = edx;
|
||||
t2m_build[t2m_count].el_tag = 0;
|
||||
t2m_count++;
|
||||
|
@ -566,23 +569,25 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
|
|||
asn_TYPE_member_t *elm;
|
||||
asn_enc_rval_t tmper;
|
||||
|
||||
void *memb_ptr_dontuse; /* Pointer to the member */
|
||||
void **memb_ptr2; /* Pointer to that pointer */
|
||||
const void *memb_ptr_dontuse; /* Pointer to the member */
|
||||
const void *const *memb_ptr2; /* Pointer to that pointer */
|
||||
|
||||
/* Encode according to the tag order */
|
||||
/* Encode according to the tag order */
|
||||
elm = &td->elements[t2m[edx].el_no];
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr2 = (void **)((char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) continue;
|
||||
memb_ptr2 =
|
||||
(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!*memb_ptr2) continue;
|
||||
} else {
|
||||
memb_ptr_dontuse = (void *)((char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
|
||||
memb_ptr_dontuse =
|
||||
(const void *)((const char *)sptr + elm->memb_offset);
|
||||
memb_ptr2 = &memb_ptr_dontuse; /* Only use of memb_ptr_dontuse */
|
||||
}
|
||||
|
||||
/* Eliminate default values */
|
||||
if(elm->default_value && elm->default_value(0, memb_ptr2) == 1)
|
||||
continue;
|
||||
if(elm->default_value_cmp && elm->default_value_cmp(*memb_ptr2) == 0)
|
||||
continue;
|
||||
|
||||
tmper = elm->type->op->der_encoder(elm->type, *memb_ptr2,
|
||||
elm->tag_mode, elm->tag, cb, app_key);
|
||||
|
@ -615,14 +620,14 @@ SET_encode_der(asn_TYPE_descriptor_t *td,
|
|||
* Decode the XER (XML) data.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
SET_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
/*
|
||||
SET_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elements = td->elements;
|
||||
const asn_TYPE_member_t *elements = td->elements;
|
||||
const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
|
||||
|
||||
/*
|
||||
|
@ -660,7 +665,7 @@ SET_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
pxer_chunk_type_e ch_type; /* XER chunk type */
|
||||
ssize_t ch_size; /* Chunk size */
|
||||
xer_check_tag_e tcv; /* Tag check value */
|
||||
asn_TYPE_member_t *elm;
|
||||
const asn_TYPE_member_t *elm;
|
||||
|
||||
/*
|
||||
* Go inside the inner member of a set.
|
||||
|
@ -831,10 +836,10 @@ SET_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
SET_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const asn_SET_specifics_t *specs = (const asn_SET_specifics_t *)td->specifics;
|
||||
asn_enc_rval_t er;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
const asn_TYPE_tag2member_t *t2m = specs->tag2el_cxer;
|
||||
|
@ -851,25 +856,26 @@ SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||
for(edx = 0; edx < t2m_count; edx++) {
|
||||
asn_enc_rval_t tmper;
|
||||
asn_TYPE_member_t *elm;
|
||||
void *memb_ptr;
|
||||
const char *mname;
|
||||
unsigned int mlen;
|
||||
const void *memb_ptr;
|
||||
const char *mname;
|
||||
size_t mlen;
|
||||
|
||||
elm = &td->elements[t2m[edx].el_no];
|
||||
mname = elm->name;
|
||||
mlen = strlen(elm->name);
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) {
|
||||
memb_ptr =
|
||||
*(const void *const *)((const char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) {
|
||||
if(elm->optional)
|
||||
continue;
|
||||
/* Mandatory element missing */
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
if(!xcan)
|
||||
ASN__TEXT_INDENT(1, ilevel);
|
||||
|
@ -892,9 +898,9 @@ cb_failed:
|
|||
}
|
||||
|
||||
int
|
||||
SET_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t edx;
|
||||
SET_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t edx;
|
||||
int ret;
|
||||
|
||||
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||
|
@ -975,9 +981,9 @@ SET_free(const asn_TYPE_descriptor_t *td, void *ptr,
|
|||
}
|
||||
|
||||
int
|
||||
SET_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
size_t edx;
|
||||
SET_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
size_t edx;
|
||||
|
||||
if(!sptr) {
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _CONSTR_SET_H_
|
||||
|
|
|
@ -66,15 +66,16 @@
|
|||
* The decoder of the SET OF type.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
SET_OF_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
SET_OF_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const void *ptr, size_t size, int tag_mode) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elm = td->elements; /* Single one */
|
||||
const asn_TYPE_member_t *elm = td->elements; /* Single one */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Parts of the structure being constructed.
|
||||
*/
|
||||
void *st = *struct_ptr; /* Target structure. */
|
||||
|
@ -310,14 +311,14 @@ static int _el_buf_cmp(const void *ap, const void *bp) {
|
|||
* The DER encoder of the SET OF type.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
||||
int tag_mode, ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_TYPE_descriptor_t *elm_type = elm->type;
|
||||
SET_OF_encode_der(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
const asn_TYPE_member_t *elm = td->elements;
|
||||
const asn_TYPE_descriptor_t *elm_type = elm->type;
|
||||
der_type_encoder_f *der_encoder = elm_type->op->der_encoder;
|
||||
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
|
||||
size_t computed_size = 0;
|
||||
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
|
||||
size_t computed_size = 0;
|
||||
ssize_t encoding_size = 0;
|
||||
struct _el_buffer *encoded_els;
|
||||
ssize_t eels_count = 0;
|
||||
|
@ -334,8 +335,8 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
if(!memb_ptr) continue;
|
||||
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
|
||||
if(erval.encoded == -1)
|
||||
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
|
||||
if(erval.encoded == -1)
|
||||
return erval;
|
||||
computed_size += erval.encoded;
|
||||
|
||||
|
@ -352,7 +353,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
if(encoding_size == -1) {
|
||||
erval.encoded = -1;
|
||||
erval.failed_type = td;
|
||||
erval.structure_ptr = ptr;
|
||||
erval.structure_ptr = sptr;
|
||||
return erval;
|
||||
}
|
||||
computed_size += encoding_size;
|
||||
|
@ -367,22 +368,19 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
* according to their encodings. Build an array of the
|
||||
* encoded elements.
|
||||
*/
|
||||
encoded_els = (struct _el_buffer *)MALLOC(
|
||||
list->count * sizeof(encoded_els[0]));
|
||||
if(encoded_els == NULL) {
|
||||
erval.encoded = -1;
|
||||
erval.failed_type = td;
|
||||
erval.structure_ptr = ptr;
|
||||
return erval;
|
||||
}
|
||||
encoded_els =
|
||||
(struct _el_buffer *)MALLOC(list->count * sizeof(encoded_els[0]));
|
||||
if(encoded_els == NULL) {
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
ASN_DEBUG("Encoding members of %s SET OF", td->name);
|
||||
ASN_DEBUG("Encoding members of %s SET OF", td->name);
|
||||
|
||||
/*
|
||||
* Encode all members.
|
||||
*/
|
||||
for(edx = 0; edx < list->count; edx++) {
|
||||
void *memb_ptr = list->array[edx];
|
||||
const void *memb_ptr = list->array[edx];
|
||||
struct _el_buffer *encoded_el = &encoded_els[eels_count];
|
||||
|
||||
if(!memb_ptr) continue;
|
||||
|
@ -398,10 +396,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
for(edx--; edx >= 0; edx--)
|
||||
FREEMEM(encoded_els[edx].buf);
|
||||
FREEMEM(encoded_els);
|
||||
erval.encoded = -1;
|
||||
erval.failed_type = td;
|
||||
erval.structure_ptr = ptr;
|
||||
return erval;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -444,14 +439,11 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
* Standard callback failed, or
|
||||
* encoded size is not equal to the computed size.
|
||||
*/
|
||||
erval.encoded = -1;
|
||||
erval.failed_type = td;
|
||||
erval.structure_ptr = ptr;
|
||||
ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
erval.encoded = computed_size;
|
||||
}
|
||||
|
||||
ASN__ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
}
|
||||
|
||||
#undef XER_ADVANCE
|
||||
|
@ -466,14 +458,14 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||
* Decode the XER (XML) data.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
SET_OF_decode_xer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void **struct_ptr, const char *opt_mname,
|
||||
const void *buf_ptr, size_t size) {
|
||||
/*
|
||||
SET_OF_decode_xer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **struct_ptr,
|
||||
const char *opt_mname, const void *buf_ptr, size_t size) {
|
||||
/*
|
||||
* Bring closer parts of structure description.
|
||||
*/
|
||||
const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *element = td->elements;
|
||||
const asn_TYPE_member_t *element = td->elements;
|
||||
const char *elm_tag;
|
||||
const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
|
||||
|
||||
|
@ -651,14 +643,14 @@ SET_OF_xer_order(const void *aptr, const void *bptr) {
|
|||
|
||||
|
||||
asn_enc_rval_t
|
||||
SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int ilevel, enum xer_encoder_flags_e flags,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
SET_OF_encode_xer(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
asn_enc_rval_t er;
|
||||
const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr);
|
||||
const char *mname = specs->as_XMLValueList
|
||||
const asn_TYPE_member_t *elm = td->elements;
|
||||
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
|
||||
const char *mname = specs->as_XMLValueList
|
||||
? 0 : ((*elm->name) ? elm->name : elm->type->xml_tag);
|
||||
size_t mlen = mname ? strlen(mname) : 0;
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
|
@ -750,9 +742,9 @@ cleanup:
|
|||
}
|
||||
|
||||
int
|
||||
SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
SET_OF_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
|
||||
int ret;
|
||||
int i;
|
||||
|
@ -825,9 +817,9 @@ SET_OF_free(const asn_TYPE_descriptor_t *td, void *ptr,
|
|||
}
|
||||
|
||||
int
|
||||
SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
SET_OF_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
|
||||
const asn_TYPE_member_t *elm = td->elements;
|
||||
asn_constr_check_f *constr;
|
||||
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
|
||||
int i;
|
||||
|
@ -860,13 +852,14 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
SET_OF_decode_uper(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
SET_OF_decode_uper(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;
|
||||
asn_dec_rval_t rv;
|
||||
const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_TYPE_member_t *elm = td->elements; /* Single one */
|
||||
void *st = *sptr;
|
||||
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;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef CONSTR_SET_OF_H
|
||||
|
|
|
@ -107,9 +107,10 @@ oer_fetch_quantity(const void *ptr, size_t size, size_t *qty_r) {
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
SET_OF_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
SET_OF_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
const asn_SET_OF_specifics_t *specs = (const asn_SET_OF_specifics_t *)td->specifics;
|
||||
asn_dec_rval_t rval = {RC_OK, 0};
|
||||
void *st = *struct_ptr; /* Target structure */
|
||||
|
@ -227,13 +228,13 @@ oer_put_quantity(size_t qty, asn_app_consume_bytes_f *cb, void *app_key) {
|
|||
* Encode as Canonical OER.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
SET_OF_encode_oer(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
SET_OF_encode_oer(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const asn_TYPE_member_t *elm;
|
||||
const asn_anonymous_set_ *list;
|
||||
size_t computed_size = 0;
|
||||
ssize_t qty_len;
|
||||
asn_TYPE_member_t *elm;
|
||||
asn_anonymous_set_ *list;
|
||||
int n;
|
||||
|
||||
(void)constraints;
|
||||
|
@ -241,7 +242,7 @@ SET_OF_encode_oer(asn_TYPE_descriptor_t *td,
|
|||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
|
||||
elm = td->elements;
|
||||
list = _A_SET_FROM_VOID(sptr);
|
||||
list = _A_CSET_FROM_VOID(sptr);
|
||||
|
||||
qty_len = oer_put_quantity(list->count, cb, app_key);
|
||||
if(qty_len < 0) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
/*
|
||||
|
@ -97,11 +96,11 @@ typedef void (asn_struct_free_f)(
|
|||
/*
|
||||
* Print the structure according to its specification.
|
||||
*/
|
||||
typedef int (asn_struct_print_f)(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const void *struct_ptr,
|
||||
int level, /* Indentation level */
|
||||
asn_app_consume_bytes_f *callback, void *app_key);
|
||||
typedef int(asn_struct_print_f)(
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const void *struct_ptr,
|
||||
int level, /* Indentation level */
|
||||
asn_app_consume_bytes_f *callback, void *app_key);
|
||||
|
||||
/*
|
||||
* Compare two structs between each other.
|
||||
|
@ -131,7 +130,7 @@ asn_outmost_tag_f asn_TYPE_outmost_tag;
|
|||
* Information Object Set driven constraints.
|
||||
*/
|
||||
typedef struct asn_type_selector_result_s {
|
||||
struct asn_TYPE_descriptor_s *type_descriptor; /* Type encoded. */
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor; /* Type encoded. */
|
||||
unsigned presence_index; /* Associated choice variant. */
|
||||
} asn_type_selector_result_t;
|
||||
typedef asn_type_selector_result_t(asn_type_selector_f)(
|
||||
|
@ -227,7 +226,8 @@ typedef struct asn_TYPE_member_s {
|
|||
asn_TYPE_descriptor_t *type; /* Member type descriptor */
|
||||
asn_type_selector_f *type_selector; /* IoS runtime type selector */
|
||||
asn_encoding_constraints_t encoding_constraints;
|
||||
int (*default_value)(int setval, void **sptr); /* DEFAULT <value> */
|
||||
int (*default_value_set)(void **sptr); /* Set DEFAULT <value> */
|
||||
int (*default_value_cmp)(const void *sptr); /* Compare DEFAULT <value> */
|
||||
const char *name; /* ASN.1 identifier of the element */
|
||||
} asn_TYPE_member_t;
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
#include <constraints.h>
|
||||
|
||||
int
|
||||
asn_generic_no_constraint(asn_TYPE_descriptor_t *type_descriptor,
|
||||
const void *struct_ptr, asn_app_constraint_failed_f *cb, void *key) {
|
||||
|
||||
(void)type_descriptor; /* Unused argument */
|
||||
asn_generic_no_constraint(const asn_TYPE_descriptor_t *type_descriptor,
|
||||
const void *struct_ptr,
|
||||
asn_app_constraint_failed_f *cb, void *key) {
|
||||
(void)type_descriptor; /* Unused argument */
|
||||
(void)struct_ptr; /* Unused argument */
|
||||
(void)cb; /* Unused argument */
|
||||
(void)key; /* Unused argument */
|
||||
|
@ -15,10 +15,10 @@ asn_generic_no_constraint(asn_TYPE_descriptor_t *type_descriptor,
|
|||
}
|
||||
|
||||
int
|
||||
asn_generic_unknown_constraint(asn_TYPE_descriptor_t *type_descriptor,
|
||||
const void *struct_ptr, asn_app_constraint_failed_f *cb, void *key) {
|
||||
|
||||
(void)type_descriptor; /* Unused argument */
|
||||
asn_generic_unknown_constraint(const asn_TYPE_descriptor_t *type_descriptor,
|
||||
const void *struct_ptr,
|
||||
asn_app_constraint_failed_f *cb, void *key) {
|
||||
(void)type_descriptor; /* Unused argument */
|
||||
(void)struct_ptr; /* Unused argument */
|
||||
(void)cb; /* Unused argument */
|
||||
(void)key; /* Unused argument */
|
||||
|
@ -28,15 +28,16 @@ asn_generic_unknown_constraint(asn_TYPE_descriptor_t *type_descriptor,
|
|||
}
|
||||
|
||||
struct errbufDesc {
|
||||
asn_TYPE_descriptor_t *failed_type;
|
||||
const void *failed_struct_ptr;
|
||||
const asn_TYPE_descriptor_t *failed_type;
|
||||
const void *failed_struct_ptr;
|
||||
char *errbuf;
|
||||
size_t errlen;
|
||||
};
|
||||
|
||||
static void
|
||||
_asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, const void *sptr, const char *fmt, ...) {
|
||||
struct errbufDesc *arg = key;
|
||||
_asn_i_ctfailcb(void *key, const asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
const char *fmt, ...) {
|
||||
struct errbufDesc *arg = key;
|
||||
va_list ap;
|
||||
ssize_t vlen;
|
||||
ssize_t maxlen;
|
||||
|
@ -73,7 +74,7 @@ _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td, const void *sptr, const ch
|
|||
}
|
||||
|
||||
int
|
||||
asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor,
|
||||
asn_check_constraints(const asn_TYPE_descriptor_t *type_descriptor,
|
||||
const void *struct_ptr, char *errbuf, size_t *errlen) {
|
||||
struct errbufDesc arg;
|
||||
int ret;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2004, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef ASN1_CONSTRAINTS_VALIDATOR_H
|
||||
|
@ -25,24 +25,23 @@ struct asn_TYPE_descriptor_s; /* Forward declaration */
|
|||
* This function returns 0 in case all ASN.1 constraints are met
|
||||
* and -1 if one or more constraints were failed.
|
||||
*/
|
||||
int
|
||||
asn_check_constraints(struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const void *struct_ptr, /* Target language's structure */
|
||||
char *errbuf, /* Returned error description */
|
||||
size_t *errlen /* Length of the error description */
|
||||
);
|
||||
int asn_check_constraints(
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const void *struct_ptr, /* Target language's structure */
|
||||
char *errbuf, /* Returned error description */
|
||||
size_t *errlen /* Length of the error description */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Generic type for constraint checking callback,
|
||||
* associated with every type descriptor.
|
||||
*/
|
||||
typedef int (asn_constr_check_f)(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const void *struct_ptr,
|
||||
asn_app_constraint_failed_f *optional_callback, /* Log the error */
|
||||
void *optional_app_key /* Opaque key passed to a callback */
|
||||
);
|
||||
typedef int(asn_constr_check_f)(
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr,
|
||||
asn_app_constraint_failed_f *optional_callback, /* Log the error */
|
||||
void *optional_app_key /* Opaque key passed to a callback */
|
||||
);
|
||||
|
||||
/*******************************
|
||||
* INTERNALLY USEFUL FUNCTIONS *
|
||||
|
|
|
@ -12,19 +12,17 @@ static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len,
|
|||
* The DER encoder of any type.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
der_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
|
||||
asn_app_consume_bytes_f *consume_bytes, void *app_key) {
|
||||
|
||||
ASN_DEBUG("DER encoder invoked for %s",
|
||||
der_encode(const asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr,
|
||||
asn_app_consume_bytes_f *consume_bytes, void *app_key) {
|
||||
ASN_DEBUG("DER encoder invoked for %s",
|
||||
type_descriptor->name);
|
||||
|
||||
/*
|
||||
* Invoke type-specific encoder.
|
||||
*/
|
||||
return type_descriptor->op->der_encoder(type_descriptor,
|
||||
struct_ptr, /* Pointer to the destination structure */
|
||||
0, 0,
|
||||
consume_bytes, app_key);
|
||||
return type_descriptor->op->der_encoder(
|
||||
type_descriptor, struct_ptr, /* Pointer to the destination structure */
|
||||
0, 0, consume_bytes, app_key);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -51,9 +49,9 @@ static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) {
|
|||
* A variant of the der_encode() which encodes the data into the provided buffer
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
der_encode_to_buffer(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
|
||||
void *buffer, size_t buffer_size) {
|
||||
enc_to_buf_arg arg;
|
||||
der_encode_to_buffer(const asn_TYPE_descriptor_t *type_descriptor,
|
||||
const void *struct_ptr, void *buffer, size_t buffer_size) {
|
||||
enc_to_buf_arg arg;
|
||||
asn_enc_rval_t ec;
|
||||
|
||||
arg.buffer = buffer;
|
||||
|
@ -74,8 +72,8 @@ der_encode_to_buffer(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
|
|||
* Write out leading TL[v] sequence according to the type definition.
|
||||
*/
|
||||
ssize_t
|
||||
der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length, int tag_mode,
|
||||
int last_tag_form,
|
||||
der_write_tags(const asn_TYPE_descriptor_t *sd, size_t struct_length,
|
||||
int tag_mode, int last_tag_form,
|
||||
ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
#define ASN1_DER_MAX_TAGS_COUNT 4
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*-
|
||||
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _DER_ENCODER_H_
|
||||
|
@ -20,31 +20,30 @@ struct asn_TYPE_descriptor_s; /* Forward declaration */
|
|||
* NOTE: Use the ber_decode() function (ber_decoder.h) to decode data
|
||||
* produced by der_encode().
|
||||
*/
|
||||
asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
asn_app_consume_bytes_f *consume_bytes_cb,
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
asn_enc_rval_t der_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,
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
|
||||
/* A variant of der_encode() which encodes data into the pre-allocated buffer */
|
||||
asn_enc_rval_t der_encode_to_buffer(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
void *buffer, /* Pre-allocated buffer */
|
||||
size_t buffer_size /* Initial buffer size (maximum) */
|
||||
);
|
||||
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 (maximum) */
|
||||
);
|
||||
|
||||
/*
|
||||
* Type of the generic DER encoder.
|
||||
*/
|
||||
typedef asn_enc_rval_t (der_type_encoder_f)(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
|
||||
ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
typedef asn_enc_rval_t(der_type_encoder_f)(
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const void *struct_ptr, /* Structure to be encoded */
|
||||
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
|
||||
ber_tlv_tag_t tag, asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
|
||||
|
||||
/*******************************
|
||||
|
@ -54,15 +53,13 @@ typedef asn_enc_rval_t (der_type_encoder_f)(
|
|||
/*
|
||||
* Write out leading TL[v] sequence according to the type definition.
|
||||
*/
|
||||
ssize_t der_write_tags(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
size_t struct_length,
|
||||
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
|
||||
int last_tag_form, /* {0,!0}: prim, constructed */
|
||||
ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *consume_bytes_cb,
|
||||
void *app_key
|
||||
);
|
||||
ssize_t der_write_tags(const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
size_t struct_length,
|
||||
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
|
||||
int last_tag_form, /* {0,!0}: prim, constructed */
|
||||
ber_tlv_tag_t tag,
|
||||
asn_app_consume_bytes_f *consume_bytes_cb,
|
||||
void *app_key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
*/
|
||||
asn_dec_rval_t
|
||||
oer_decode(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *type_descriptor,
|
||||
void **struct_ptr, const void *ptr, size_t size) {
|
||||
asn_codec_ctx_t s_codec_ctx;
|
||||
const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
|
||||
const void *ptr, size_t size) {
|
||||
asn_codec_ctx_t s_codec_ctx;
|
||||
|
||||
/*
|
||||
* Stack checker requires that the codec context
|
||||
|
@ -58,7 +58,7 @@ oer_open_type_skip(const void *bufptr, size_t size) {
|
|||
*/
|
||||
ssize_t
|
||||
oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
struct asn_TYPE_descriptor_s *td,
|
||||
const struct asn_TYPE_descriptor_s *td,
|
||||
const asn_oer_constraints_t *constraints, void **struct_ptr,
|
||||
const void *bufptr, size_t size) {
|
||||
asn_dec_rval_t dr;
|
||||
|
@ -96,7 +96,7 @@ oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
|
|||
|
||||
asn_dec_rval_t
|
||||
oer_decode_primitive(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
asn_TYPE_descriptor_t *td,
|
||||
const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void **sptr,
|
||||
const void *ptr, size_t size) {
|
||||
ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)*sptr;
|
||||
|
|
|
@ -21,7 +21,7 @@ struct asn_codec_ctx_s; /* Forward declaration */
|
|||
* Parses CANONICAL-OER and BASIC-OER.
|
||||
*/
|
||||
asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void **struct_ptr, /* Pointer to a target structure's pointer */
|
||||
const void *buffer, /* Data to be decoded */
|
||||
size_t size /* Size of that buffer */
|
||||
|
@ -32,7 +32,7 @@ asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
|
|||
*/
|
||||
typedef asn_dec_rval_t(oer_type_decoder_f)(
|
||||
const struct asn_codec_ctx_s *opt_codec_ctx,
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void **struct_ptr,
|
||||
const void *buf_ptr,
|
||||
|
@ -55,7 +55,7 @@ ssize_t oer_open_type_skip(const void *bufptr, size_t size);
|
|||
* >0: Number of bytes used from bufptr.
|
||||
*/
|
||||
ssize_t oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
struct asn_TYPE_descriptor_s *td,
|
||||
const struct asn_TYPE_descriptor_s *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void **struct_ptr, const void *bufptr, size_t size);
|
||||
|
||||
|
|
|
@ -9,18 +9,17 @@
|
|||
* The OER encoder of any type.
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
oer_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
|
||||
asn_app_consume_bytes_f *consume_bytes, void *app_key) {
|
||||
oer_encode(const asn_TYPE_descriptor_t *type_descriptor, const void *struct_ptr,
|
||||
asn_app_consume_bytes_f *consume_bytes, void *app_key) {
|
||||
ASN_DEBUG("OER encoder invoked for %s", type_descriptor->name);
|
||||
|
||||
ASN_DEBUG("OER encoder invoked for %s",
|
||||
type_descriptor->name);
|
||||
|
||||
/*
|
||||
* Invoke type-specific encoder.
|
||||
*/
|
||||
return type_descriptor->op->oer_encoder(type_descriptor, 0,
|
||||
struct_ptr, /* Pointer to the destination structure */
|
||||
consume_bytes, app_key);
|
||||
/*
|
||||
* Invoke type-specific encoder.
|
||||
*/
|
||||
return type_descriptor->op->oer_encoder(
|
||||
type_descriptor, 0,
|
||||
struct_ptr, /* Pointer to the destination structure */
|
||||
consume_bytes, app_key);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -30,29 +29,29 @@ typedef struct enc_to_buf_arg {
|
|||
void *buffer;
|
||||
size_t left;
|
||||
} enc_to_buf_arg;
|
||||
static int encode_to_buffer_cb(const void *buffer, size_t size, void *key) {
|
||||
enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
|
||||
static int
|
||||
encode_to_buffer_cb(const void *buffer, size_t size, void *key) {
|
||||
enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
|
||||
|
||||
if(arg->left < size)
|
||||
return -1; /* Data exceeds the available buffer size */
|
||||
if(arg->left < size) return -1; /* Data exceeds the available buffer size */
|
||||
|
||||
memcpy(arg->buffer, buffer, size);
|
||||
arg->buffer = ((char *)arg->buffer) + size;
|
||||
arg->left -= size;
|
||||
memcpy(arg->buffer, buffer, size);
|
||||
arg->buffer = ((char *)arg->buffer) + size;
|
||||
arg->left -= size;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* A variant of the oer_encode() which encodes the data into the provided buffer
|
||||
*/
|
||||
asn_enc_rval_t
|
||||
oer_encode_to_buffer(struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
oer_encode_to_buffer(const asn_TYPE_descriptor_t *type_descriptor,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
void *buffer, /* Pre-allocated buffer */
|
||||
size_t buffer_size /* Initial buffer size (maximum) */
|
||||
) {
|
||||
const void *struct_ptr, /* Structure to be encoded */
|
||||
void *buffer, /* Pre-allocated buffer */
|
||||
size_t buffer_size /* Initial buffer size (maximum) */
|
||||
) {
|
||||
enc_to_buf_arg arg;
|
||||
asn_enc_rval_t ec;
|
||||
|
||||
|
@ -79,8 +78,8 @@ oer_encode_to_buffer(struct asn_TYPE_descriptor_s *type_descriptor,
|
|||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
oer_encode_primitive(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, void *sptr,
|
||||
oer_encode_primitive(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
const ASN__PRIMITIVE_TYPE_t *st = (const ASN__PRIMITIVE_TYPE_t *)sptr;
|
||||
asn_enc_rval_t er = {0, 0, 0};
|
||||
|
@ -112,30 +111,30 @@ oer_encode_primitive(asn_TYPE_descriptor_t *td,
|
|||
static int
|
||||
oer__count_bytes(const void *buffer, size_t size, void *bytes_ptr) {
|
||||
size_t *bytes = bytes_ptr;
|
||||
(void)buffer;
|
||||
*bytes += size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
oer_open_type_put(asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void *sptr, asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
oer_open_type_put(const asn_TYPE_descriptor_t *td,
|
||||
const asn_oer_constraints_t *constraints, const void *sptr,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
size_t serialized_byte_count = 0;
|
||||
asn_enc_rval_t er;
|
||||
ssize_t len_len;
|
||||
|
||||
er = td->op->oer_encoder(td, constraints, sptr, oer__count_bytes,
|
||||
&serialized_byte_count);
|
||||
if(er.encoded == -1) return -1;
|
||||
assert(serialized_byte_count == er.encoded);
|
||||
if(er.encoded < 0) return -1;
|
||||
assert(serialized_byte_count == (size_t)er.encoded);
|
||||
|
||||
len_len = oer_serialize_length(serialized_byte_count, cb, app_key);
|
||||
if(len_len == -1) return -1;
|
||||
|
||||
er = td->op->oer_encoder(td, constraints, sptr, cb, app_key);
|
||||
if(er.encoded == -1) return -1;
|
||||
assert(serialized_byte_count == er.encoded);
|
||||
if(er.encoded < 0) return -1;
|
||||
assert(serialized_byte_count == (size_t)er.encoded);
|
||||
|
||||
return er.encoded + len_len;
|
||||
}
|
||||
|
|
|
@ -19,31 +19,31 @@ struct asn_TYPE_descriptor_s; /* Forward declaration */
|
|||
* Produces CANONICAL-OER output compatible with CANONICAL-OER
|
||||
* and BASIC-OER decoders.
|
||||
*/
|
||||
asn_enc_rval_t oer_encode(struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
asn_enc_rval_t oer_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,
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
);
|
||||
|
||||
/* A variant of oer_encode() which encodes data into the pre-allocated buffer */
|
||||
asn_enc_rval_t oer_encode_to_buffer(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
void *buffer, /* Pre-allocated buffer */
|
||||
size_t buffer_size /* Initial buffer size (maximum) */
|
||||
);
|
||||
const void *struct_ptr, /* Structure to be encoded */
|
||||
void *buffer, /* Pre-allocated buffer */
|
||||
size_t buffer_size /* Initial buffer size (maximum) */
|
||||
);
|
||||
|
||||
/*
|
||||
* Type of the generic OER encoder.
|
||||
*/
|
||||
typedef asn_enc_rval_t(oer_type_encoder_f)(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void *struct_ptr, /* Structure to be encoded */
|
||||
const void *struct_ptr, /* Structure to be encoded */
|
||||
asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
|
||||
void *app_key /* Arbitrary callback argument */
|
||||
);
|
||||
);
|
||||
|
||||
/*
|
||||
* Write out the Open Type (X.696 (08/2015), #30).
|
||||
|
@ -51,9 +51,9 @@ typedef asn_enc_rval_t(oer_type_encoder_f)(
|
|||
* -1: Fatal error encoding the type.
|
||||
* >=0: Number of bytes serialized.
|
||||
*/
|
||||
ssize_t oer_open_type_put(struct asn_TYPE_descriptor_s *td,
|
||||
ssize_t oer_open_type_put(const struct asn_TYPE_descriptor_s *td,
|
||||
const asn_oer_constraints_t *constraints,
|
||||
void *struct_ptr,
|
||||
const void *struct_ptr,
|
||||
asn_app_consume_bytes_f *consume_bytes_cb,
|
||||
void *app_key);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef OER_SUPPORT_H
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
* multiple of 8 bytes.
|
||||
*/
|
||||
asn_dec_rval_t
|
||||
uper_decode_complete(const 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;
|
||||
uper_decode_complete(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const asn_TYPE_descriptor_t *td, void **sptr,
|
||||
const void *buffer, size_t size) {
|
||||
asn_dec_rval_t rval;
|
||||
|
||||
rval = uper_decode(opt_codec_ctx, td, sptr, buffer, size, 0, 0);
|
||||
if(rval.consumed) {
|
||||
|
@ -37,8 +39,10 @@ uper_decode_complete(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
|
|||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
uper_decode(const 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;
|
||||
uper_decode(const asn_codec_ctx_t *opt_codec_ctx,
|
||||
const 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;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue