mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Regenerate ASN.1 code with asn1c 0.9.28
Closes: https://pagure.io/freeipa/issue/6818 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Simo Sorce <ssorce@redhat.com>
This commit is contained in:
committed by
Martin Basti
parent
434d9e539d
commit
ad08430477
@@ -9,7 +9,7 @@
|
||||
/*
|
||||
* BIT STRING basic type description.
|
||||
*/
|
||||
static ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_BIT_STRING_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
|
||||
};
|
||||
static asn_OCTET_STRING_specifics_t asn_DEF_BIT_STRING_specs = {
|
||||
@@ -52,13 +52,13 @@ BIT_STRING_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
if(st && st->buf) {
|
||||
if((st->size == 0 && st->bits_unused)
|
||||
|| st->bits_unused < 0 || st->bits_unused > 7) {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: invalid padding byte (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: value not given (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -86,7 +86,7 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
uint8_t *end;
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
@@ -101,9 +101,9 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int nline = xcan?0:(((buf - st->buf) % 8) == 0);
|
||||
if(p >= scend || nline) {
|
||||
er.encoded += p - scratch;
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
ASN__CALLBACK(scratch, p - scratch);
|
||||
p = scratch;
|
||||
if(nline) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
if(nline) ASN__TEXT_INDENT(1, ilevel);
|
||||
}
|
||||
memcpy(p + 0, _bit_pattern[v >> 4], 4);
|
||||
memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
|
||||
@@ -111,9 +111,9 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
}
|
||||
|
||||
if(!xcan && ((buf - st->buf) % 8) == 0)
|
||||
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||
ASN__TEXT_INDENT(1, ilevel);
|
||||
er.encoded += p - scratch;
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
ASN__CALLBACK(scratch, p - scratch);
|
||||
p = scratch;
|
||||
|
||||
if(buf == end) {
|
||||
@@ -123,14 +123,14 @@ BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
for(i = 7; i >= ubits; i--)
|
||||
*p++ = (v & (1 << i)) ? 0x31 : 0x30;
|
||||
er.encoded += p - scratch;
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
ASN__CALLBACK(scratch, p - scratch);
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
cb_failed:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ cb_failed:
|
||||
int
|
||||
BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
static const char *h2c = "0123456789ABCDEF";
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
char scratch[64];
|
||||
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
|
||||
uint8_t *buf;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#include "GKCurrentKeys.h"
|
||||
@@ -18,10 +18,10 @@ static asn_TYPE_member_t asn_MBR_GKCurrentKeys_1[] = {
|
||||
"serviceIdentity"
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn_DEF_GKCurrentKeys_tags_1[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_GKCurrentKeys_tags_1[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_GKCurrentKeys_tag2el_1[] = {
|
||||
static const asn_TYPE_tag2member_t asn_MAP_GKCurrentKeys_tag2el_1[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* serviceIdentity */
|
||||
};
|
||||
static asn_SEQUENCE_specifics_t asn_SPC_GKCurrentKeys_specs_1 = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#ifndef _GKCurrentKeys_H_
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#include "GKNewKeys.h"
|
||||
@@ -18,7 +18,7 @@ static asn_TYPE_member_t asn_MBR_enctypes_3[] = {
|
||||
""
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn_DEF_enctypes_tags_3[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_enctypes_tags_3[] = {
|
||||
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
@@ -81,10 +81,10 @@ static asn_TYPE_member_t asn_MBR_GKNewKeys_1[] = {
|
||||
"password"
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn_DEF_GKNewKeys_tags_1[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_GKNewKeys_tags_1[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_GKNewKeys_tag2el_1[] = {
|
||||
static const asn_TYPE_tag2member_t asn_MAP_GKNewKeys_tag2el_1[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* serviceIdentity */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* enctypes */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* password */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#ifndef _GKNewKeys_H_
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#include "GKReply.h"
|
||||
@@ -18,7 +18,7 @@ static asn_TYPE_member_t asn_MBR_keys_3[] = {
|
||||
""
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn_DEF_keys_tags_3[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_keys_tags_3[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn_SET_OF_specifics_t asn_SPC_keys_specs_3 = {
|
||||
@@ -71,10 +71,10 @@ static asn_TYPE_member_t asn_MBR_GKReply_1[] = {
|
||||
"keys"
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn_DEF_GKReply_tags_1[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_GKReply_tags_1[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_GKReply_tag2el_1[] = {
|
||||
static const asn_TYPE_tag2member_t asn_MAP_GKReply_tag2el_1[] = {
|
||||
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* newkvno */
|
||||
{ (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, 0, 0 } /* keys */
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#ifndef _GKReply_H_
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#include "GetKeytabControl.h"
|
||||
@@ -36,7 +36,7 @@ static asn_TYPE_member_t asn_MBR_GetKeytabControl_1[] = {
|
||||
"reply"
|
||||
},
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_GetKeytabControl_tag2el_1[] = {
|
||||
static const asn_TYPE_tag2member_t asn_MAP_GetKeytabControl_tag2el_1[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* newkeys */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* curkeys */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* reply */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#ifndef _GetKeytabControl_H_
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/*
|
||||
* INTEGER basic type description.
|
||||
*/
|
||||
static ber_tlv_tag_t asn_DEF_INTEGER_tags[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_INTEGER_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
|
||||
};
|
||||
asn_TYPE_descriptor_t asn_DEF_INTEGER = {
|
||||
@@ -106,7 +106,7 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value(asn_INTEGER_specific
|
||||
* INTEGER specific human-readable output.
|
||||
*/
|
||||
static ssize_t
|
||||
INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key, int plainOrXER) {
|
||||
INTEGER__dump(const asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_bytes_f *cb, void *app_key, int plainOrXER) {
|
||||
asn_INTEGER_specifics_t *specs=(asn_INTEGER_specifics_t *)td->specifics;
|
||||
char scratch[32]; /* Enough for 64-bit integer */
|
||||
uint8_t *buf = st->buf;
|
||||
@@ -166,7 +166,7 @@ INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st, asn_app_consume_by
|
||||
/* Output in the long xx:yy:zz... format */
|
||||
/* TODO: replace with generic algorithm (Knuth TAOCP Vol 2, 4.3.1) */
|
||||
for(p = scratch; buf < buf_end; buf++) {
|
||||
static const char *h2c = "0123456789ABCDEF";
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
if((p - scratch) >= (ssize_t)(sizeof(scratch) - 4)) {
|
||||
/* Flush buffer */
|
||||
if(cb(scratch, p - scratch, app_key) < 0)
|
||||
@@ -208,8 +208,8 @@ INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
struct e2v_key {
|
||||
const char *start;
|
||||
const char *stop;
|
||||
asn_INTEGER_enum_map_t *vemap;
|
||||
unsigned int *evmap;
|
||||
const asn_INTEGER_enum_map_t *vemap;
|
||||
const unsigned int *evmap;
|
||||
};
|
||||
static int
|
||||
INTEGER__compar_enum2value(const void *kp, const void *am) {
|
||||
@@ -232,7 +232,7 @@ INTEGER__compar_enum2value(const void *kp, const void *am) {
|
||||
|
||||
static const asn_INTEGER_enum_map_t *
|
||||
INTEGER_map_enum2value(asn_INTEGER_specifics_t *specs, const char *lstart, const char *lstop) {
|
||||
asn_INTEGER_enum_map_t *el_found;
|
||||
const asn_INTEGER_enum_map_t *el_found;
|
||||
int count = specs ? specs->map_count : 0;
|
||||
struct e2v_key key;
|
||||
const char *lp;
|
||||
@@ -544,12 +544,12 @@ INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
(void)flags;
|
||||
|
||||
if(!st || !st->buf)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = INTEGER__dump(td, st, cb, app_key, 1);
|
||||
if(er.encoded < 0) _ASN_ENCODE_FAILED;
|
||||
if(er.encoded < 0) ASN__ENCODE_FAILED;
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
#ifndef ASN_DISABLE_PER_SUPPORT
|
||||
@@ -567,7 +567,7 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
|
||||
if(!st) {
|
||||
st = (INTEGER_t *)(*sptr = CALLOC(1, sizeof(*st)));
|
||||
if(!st) _ASN_DECODE_FAILED;
|
||||
if(!st) ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
if(!constraints) constraints = td->per_constraints;
|
||||
@@ -575,7 +575,7 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
|
||||
if(ct && ct->flags & APC_EXTENSIBLE) {
|
||||
int inext = per_get_few_bits(pd, 1);
|
||||
if(inext < 0) _ASN_DECODE_STARVED;
|
||||
if(inext < 0) ASN__DECODE_STARVED;
|
||||
if(inext) ct = 0;
|
||||
}
|
||||
|
||||
@@ -585,12 +585,12 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
if(ct) {
|
||||
if(ct->flags & APC_SEMI_CONSTRAINED) {
|
||||
st->buf = (uint8_t *)CALLOC(1, 2);
|
||||
if(!st->buf) _ASN_DECODE_FAILED;
|
||||
if(!st->buf) ASN__DECODE_FAILED;
|
||||
st->size = 1;
|
||||
} else if(ct->flags & APC_CONSTRAINED && ct->range_bits >= 0) {
|
||||
size_t size = (ct->range_bits + 7) >> 3;
|
||||
st->buf = (uint8_t *)MALLOC(1 + size + 1);
|
||||
if(!st->buf) _ASN_DECODE_FAILED;
|
||||
if(!st->buf) ASN__DECODE_FAILED;
|
||||
st->size = size;
|
||||
}
|
||||
}
|
||||
@@ -601,28 +601,28 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
ASN_DEBUG("Integer with range %d bits", ct->range_bits);
|
||||
if(ct->range_bits >= 0) {
|
||||
if((size_t)ct->range_bits > 8 * sizeof(unsigned long))
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
|
||||
if(specs && specs->field_unsigned) {
|
||||
unsigned long uvalue;
|
||||
if(uper_get_constrained_whole_number(pd,
|
||||
&uvalue, ct->range_bits))
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
ASN_DEBUG("Got value %lu + low %ld",
|
||||
uvalue, ct->lower_bound);
|
||||
uvalue += ct->lower_bound;
|
||||
if(asn_ulong2INTEGER(st, uvalue))
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
} else {
|
||||
unsigned long svalue;
|
||||
if(uper_get_constrained_whole_number(pd,
|
||||
&svalue, ct->range_bits))
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
ASN_DEBUG("Got value %ld + low %ld",
|
||||
svalue, ct->lower_bound);
|
||||
svalue += ct->lower_bound;
|
||||
if(asn_long2INTEGER(st, svalue))
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
@@ -638,14 +638,14 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
|
||||
/* Get the PER length */
|
||||
len = uper_get_length(pd, -1, &repeat);
|
||||
if(len < 0) _ASN_DECODE_STARVED;
|
||||
if(len < 0) ASN__DECODE_STARVED;
|
||||
|
||||
p = REALLOC(st->buf, st->size + len + 1);
|
||||
if(!p) _ASN_DECODE_FAILED;
|
||||
if(!p) ASN__DECODE_FAILED;
|
||||
st->buf = (uint8_t *)p;
|
||||
|
||||
ret = per_get_many_bits(pd, &st->buf[st->size], 0, 8 * len);
|
||||
if(ret < 0) _ASN_DECODE_STARVED;
|
||||
if(ret < 0) ASN__DECODE_STARVED;
|
||||
st->size += len;
|
||||
} while(repeat);
|
||||
st->buf[st->size] = 0; /* JIC */
|
||||
@@ -657,9 +657,9 @@ INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
*/
|
||||
long value;
|
||||
if(asn_INTEGER2long(st, &value))
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
if(asn_long2INTEGER(st, value + ct->lower_bound))
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
return rval;
|
||||
@@ -675,8 +675,9 @@ INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
const uint8_t *end;
|
||||
asn_per_constraint_t *ct;
|
||||
long value = 0;
|
||||
unsigned long v = 0;
|
||||
|
||||
if(!st || st->size == 0) _ASN_ENCODE_FAILED;
|
||||
if(!st || st->size == 0) ASN__ENCODE_FAILED;
|
||||
|
||||
if(!constraints) constraints = td->per_constraints;
|
||||
ct = constraints ? &constraints->value : 0;
|
||||
@@ -688,7 +689,7 @@ INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
if(specs && specs->field_unsigned) {
|
||||
unsigned long uval;
|
||||
if(asn_INTEGER2ulong(st, &uval))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
/* Check proper range */
|
||||
if(ct->flags & APC_SEMI_CONSTRAINED) {
|
||||
if(uval < (unsigned long)ct->lower_bound)
|
||||
@@ -705,7 +706,7 @@ INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
value = uval;
|
||||
} else {
|
||||
if(asn_INTEGER2long(st, &value))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
/* Check proper range */
|
||||
if(ct->flags & APC_SEMI_CONSTRAINED) {
|
||||
if(value < ct->lower_bound)
|
||||
@@ -722,10 +723,10 @@ INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
}
|
||||
if(ct->flags & APC_EXTENSIBLE) {
|
||||
if(per_put_few_bits(po, inext, 1))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
if(inext) ct = 0;
|
||||
} else if(inext) {
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,28 +736,28 @@ INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
/* #11.5.6 -> #11.3 */
|
||||
ASN_DEBUG("Encoding integer %ld (%lu) with range %d bits",
|
||||
value, value - ct->lower_bound, ct->range_bits);
|
||||
unsigned long v = value - ct->lower_bound;
|
||||
v = value - ct->lower_bound;
|
||||
if(uper_put_constrained_whole_number_u(po, v, ct->range_bits))
|
||||
_ASN_ENCODE_FAILED;
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODE_FAILED;
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
if(ct && ct->lower_bound) {
|
||||
ASN_DEBUG("Adjust lower bound to %ld", ct->lower_bound);
|
||||
/* TODO: adjust lower bound */
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
for(buf = st->buf, end = st->buf + st->size; buf < end;) {
|
||||
ssize_t mayEncode = uper_put_length(po, end - buf);
|
||||
if(mayEncode < 0)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
if(per_put_many_bits(po, buf, 8 * mayEncode))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
buf += mayEncode;
|
||||
}
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
#endif /* ASN_DISABLE_PER_SUPPORT */
|
||||
@@ -976,6 +977,7 @@ asn_strtol_lim(const char *str, const char **end, long *lp) {
|
||||
case '-':
|
||||
last_digit_max++;
|
||||
sign = -1;
|
||||
/* FALL THROUGH */
|
||||
case '+':
|
||||
str++;
|
||||
if(str >= *end) {
|
||||
|
||||
@@ -24,9 +24,9 @@ typedef struct asn_INTEGER_enum_map_s {
|
||||
} asn_INTEGER_enum_map_t;
|
||||
|
||||
/* This type describes an enumeration for INTEGER and ENUMERATED types */
|
||||
typedef struct asn_INTEGER_specifics_s {
|
||||
asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
|
||||
unsigned int *enum2value; /* "tag" => N; sorted by tag */
|
||||
typedef const struct asn_INTEGER_specifics_s {
|
||||
const asn_INTEGER_enum_map_t *value2enum; /* N -> "tag"; sorted by N */
|
||||
const unsigned int *enum2value; /* "tag" => N; sorted by tag */
|
||||
int map_count; /* Elements in either map */
|
||||
int extension; /* This map is extensible */
|
||||
int strict_enumeration; /* Enumeration set is fixed */
|
||||
@@ -63,7 +63,7 @@ enum asn_strtol_result_e {
|
||||
ASN_STRTOL_ERROR_INVAL = -2, /* Invalid data encountered (e.g., "+-") */
|
||||
ASN_STRTOL_EXPECT_MORE = -1, /* More data expected (e.g. "+") */
|
||||
ASN_STRTOL_OK = 0, /* Conversion succeded, number ends at (*end) */
|
||||
ASN_STRTOL_EXTRA_DATA = 1, /* Conversion succeded, but the string has extra stuff */
|
||||
ASN_STRTOL_EXTRA_DATA = 1 /* Conversion succeded, but the string has extra stuff */
|
||||
};
|
||||
enum asn_strtol_result_e asn_strtol_lim(const char *str, const char **end, long *l);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#include "Int32.h"
|
||||
@@ -13,7 +13,7 @@ Int32_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
long value;
|
||||
|
||||
if(!sptr) {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: value not given (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -25,7 +25,7 @@ Int32_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
/* Constraint check succeeded */
|
||||
return 0;
|
||||
} else {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: constraint failed (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -98,7 +98,7 @@ Int32_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
|
||||
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
|
||||
}
|
||||
|
||||
static ber_tlv_tag_t asn_DEF_Int32_tags_1[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_Int32_tags_1[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
|
||||
};
|
||||
asn_TYPE_descriptor_t asn_DEF_Int32 = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#ifndef _Int32_H_
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#include "KrbKey.h"
|
||||
@@ -36,10 +36,10 @@ static asn_TYPE_member_t asn_MBR_KrbKey_1[] = {
|
||||
"s2kparams"
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn_DEF_KrbKey_tags_1[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_KrbKey_tags_1[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_KrbKey_tag2el_1[] = {
|
||||
static const asn_TYPE_tag2member_t asn_MAP_KrbKey_tag2el_1[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* key */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* salt */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* s2kparams */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#ifndef _KrbKey_H_
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/*
|
||||
* NativeEnumerated basic type description.
|
||||
*/
|
||||
static ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
|
||||
};
|
||||
asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = {
|
||||
@@ -52,7 +52,7 @@ NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!native) _ASN_ENCODE_FAILED;
|
||||
if(!native) ASN__ENCODE_FAILED;
|
||||
|
||||
el = INTEGER_map_value2enum(specs, *native);
|
||||
if(el) {
|
||||
@@ -61,12 +61,12 @@ NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
|
||||
er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name);
|
||||
assert(er.encoded > 0 && (size_t)er.encoded < srcsize);
|
||||
if(cb(src, er.encoded, app_key) < 0) _ASN_ENCODE_FAILED;
|
||||
_ASN_ENCODED_OK(er);
|
||||
if(cb(src, er.encoded, app_key) < 0) ASN__ENCODE_FAILED;
|
||||
ASN__ENCODED_OK(er);
|
||||
} else {
|
||||
ASN_DEBUG("ASN.1 forbids dealing with "
|
||||
"unknown value of ENUMERATED type");
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,39 +84,39 @@ NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
||||
|
||||
if(constraints) ct = &constraints->value;
|
||||
else if(td->per_constraints) ct = &td->per_constraints->value;
|
||||
else _ASN_DECODE_FAILED; /* Mandatory! */
|
||||
if(!specs) _ASN_DECODE_FAILED;
|
||||
else ASN__DECODE_FAILED; /* Mandatory! */
|
||||
if(!specs) ASN__DECODE_FAILED;
|
||||
|
||||
if(!native) {
|
||||
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
|
||||
if(!native) _ASN_DECODE_FAILED;
|
||||
if(!native) ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
|
||||
|
||||
if(ct->flags & APC_EXTENSIBLE) {
|
||||
int inext = per_get_few_bits(pd, 1);
|
||||
if(inext < 0) _ASN_DECODE_STARVED;
|
||||
if(inext < 0) ASN__DECODE_STARVED;
|
||||
if(inext) ct = 0;
|
||||
}
|
||||
|
||||
if(ct && ct->range_bits >= 0) {
|
||||
value = per_get_few_bits(pd, ct->range_bits);
|
||||
if(value < 0) _ASN_DECODE_STARVED;
|
||||
if(value < 0) ASN__DECODE_STARVED;
|
||||
if(value >= (specs->extension
|
||||
? specs->extension - 1 : specs->map_count))
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
} else {
|
||||
if(!specs->extension)
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
/*
|
||||
* X.691, #10.6: normally small non-negative whole number;
|
||||
*/
|
||||
value = uper_get_nsnnwn(pd);
|
||||
if(value < 0) _ASN_DECODE_STARVED;
|
||||
if(value < 0) ASN__DECODE_STARVED;
|
||||
value += specs->extension - 1;
|
||||
if(value >= specs->map_count)
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
*native = specs->value2enum[value].nat_value;
|
||||
@@ -145,28 +145,28 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
asn_per_constraint_t *ct;
|
||||
int inext = 0;
|
||||
asn_INTEGER_enum_map_t key;
|
||||
asn_INTEGER_enum_map_t *kf;
|
||||
const asn_INTEGER_enum_map_t *kf;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
if(!specs) _ASN_ENCODE_FAILED;
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
if(!specs) ASN__ENCODE_FAILED;
|
||||
|
||||
if(constraints) ct = &constraints->value;
|
||||
else if(td->per_constraints) ct = &td->per_constraints->value;
|
||||
else _ASN_ENCODE_FAILED; /* Mandatory! */
|
||||
else ASN__ENCODE_FAILED; /* Mandatory! */
|
||||
|
||||
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
native = *(long *)sptr;
|
||||
if(native < 0) _ASN_ENCODE_FAILED;
|
||||
if(native < 0) ASN__ENCODE_FAILED;
|
||||
|
||||
key.nat_value = native;
|
||||
kf = bsearch(&key, specs->value2enum, specs->map_count,
|
||||
sizeof(key), NativeEnumerated__compar_value2enum);
|
||||
if(!kf) {
|
||||
ASN_DEBUG("No element corresponds to %ld", native);
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
value = kf - specs->value2enum;
|
||||
|
||||
@@ -178,20 +178,20 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
}
|
||||
if(ct->flags & APC_EXTENSIBLE) {
|
||||
if(per_put_few_bits(po, inext, 1))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
if(inext) ct = 0;
|
||||
} else if(inext) {
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
if(ct && ct->range_bits >= 0) {
|
||||
if(per_put_few_bits(po, value, ct->range_bits))
|
||||
_ASN_ENCODE_FAILED;
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODE_FAILED;
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
if(!specs->extension)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
/*
|
||||
* X.691, #10.6: normally small non-negative whole number;
|
||||
@@ -200,8 +200,8 @@ NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
value, specs->extension, inext,
|
||||
value - (inext ? (specs->extension - 1) : 0));
|
||||
if(uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0)))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
/*
|
||||
* NativeInteger basic type description.
|
||||
*/
|
||||
static ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
|
||||
};
|
||||
asn_TYPE_descriptor_t asn_DEF_NativeInteger = {
|
||||
@@ -178,7 +178,7 @@ NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
||||
|
||||
if(!native) {
|
||||
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
|
||||
if(!native) _ASN_DECODE_FAILED;
|
||||
if(!native) ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
memset(&st, 0, sizeof(st));
|
||||
@@ -219,16 +219,16 @@ NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
(void)ilevel;
|
||||
(void)flags;
|
||||
|
||||
if(!native) _ASN_ENCODE_FAILED;
|
||||
if(!native) ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = snprintf(scratch, sizeof(scratch),
|
||||
(specs && specs->field_unsigned)
|
||||
? "%lu" : "%ld", *native);
|
||||
if(er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch)
|
||||
|| cb(scratch, er.encoded, app_key) < 0)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
@@ -247,7 +247,7 @@ NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
||||
|
||||
if(!native) {
|
||||
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
|
||||
if(!native) _ASN_DECODE_FAILED;
|
||||
if(!native) ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
memset(&tmpint, 0, sizeof tmpint);
|
||||
@@ -275,7 +275,7 @@ NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
long native;
|
||||
INTEGER_t tmpint;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
|
||||
native = *(long *)sptr;
|
||||
|
||||
@@ -285,7 +285,7 @@ NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
if((specs&&specs->field_unsigned)
|
||||
? asn_ulong2INTEGER(&tmpint, native)
|
||||
: asn_long2INTEGER(&tmpint, native))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
er = INTEGER_encode_uper(td, constraints, &tmpint, po);
|
||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
|
||||
return er;
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
/*
|
||||
* OCTET STRING basic type description.
|
||||
*/
|
||||
static ber_tlv_tag_t asn_DEF_OCTET_STRING_tags[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_OCTET_STRING_tags[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
|
||||
};
|
||||
static asn_OCTET_STRING_specifics_t asn_DEF_OCTET_STRING_specs = {
|
||||
static const asn_OCTET_STRING_specifics_t asn_DEF_OCTET_STRING_specs = {
|
||||
sizeof(OCTET_STRING_t),
|
||||
offsetof(OCTET_STRING_t, _asn_ctx),
|
||||
ASN_OSUBV_STR
|
||||
};
|
||||
static asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = {
|
||||
static const asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = {
|
||||
{ APC_CONSTRAINED, 8, 8, 0, 255 },
|
||||
{ APC_SEMI_CONSTRAINED, -1, -1, 0, 0 },
|
||||
0, 0
|
||||
@@ -244,8 +244,8 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
||||
ber_tlv_tag_t expected_tag;
|
||||
ssize_t tl, ll, tlvl;
|
||||
/* This one works even if (sel->left == -1) */
|
||||
size_t Left = ((!sel||(size_t)sel->left >= size)
|
||||
?size:(size_t)sel->left);
|
||||
ssize_t Left = ((!sel||(size_t)sel->left >= size)
|
||||
?(ssize_t)size:sel->left);
|
||||
|
||||
|
||||
ASN_DEBUG("%p, s->l=%ld, s->wn=%ld, s->g=%ld\n", sel,
|
||||
@@ -483,6 +483,15 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
||||
break;
|
||||
}
|
||||
|
||||
if(sel) {
|
||||
ASN_DEBUG("3sel p=%p, wn=%d, l=%ld, g=%ld, size=%ld",
|
||||
sel->prev, sel->want_nulls,
|
||||
(long)sel->left, (long)sel->got, (long)size);
|
||||
if(sel->prev || sel->want_nulls > 1 || sel->left > 0) {
|
||||
RETURN(RC_WMORE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* BIT STRING-specific processing.
|
||||
*/
|
||||
@@ -539,7 +548,7 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
|
||||
if(!cb) {
|
||||
er.encoded += (type_variant == ASN_OSUBV_BIT) + st->size;
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -548,30 +557,30 @@ OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(type_variant == ASN_OSUBV_BIT) {
|
||||
uint8_t b = st->bits_unused & 0x07;
|
||||
if(b && st->size) fix_last_byte = 1;
|
||||
_ASN_CALLBACK(&b, 1);
|
||||
ASN__CALLBACK(&b, 1);
|
||||
er.encoded++;
|
||||
}
|
||||
|
||||
/* Invoke callback for the main part of the buffer */
|
||||
_ASN_CALLBACK(st->buf, st->size - fix_last_byte);
|
||||
ASN__CALLBACK(st->buf, st->size - fix_last_byte);
|
||||
|
||||
/* The last octet should be stripped off the unused bits */
|
||||
if(fix_last_byte) {
|
||||
uint8_t b = st->buf[st->size-1] & (0xff << st->bits_unused);
|
||||
_ASN_CALLBACK(&b, 1);
|
||||
ASN__CALLBACK(&b, 1);
|
||||
}
|
||||
|
||||
er.encoded += st->size;
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
cb_failed:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_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) {
|
||||
static const char *h2c = "0123456789ABCDEF";
|
||||
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];
|
||||
@@ -581,7 +590,7 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
size_t i;
|
||||
|
||||
if(!st || (!st->buf && st->size))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
@@ -594,7 +603,7 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
char *scend = scratch + (sizeof(scratch) - 2);
|
||||
for(; buf < end; buf++) {
|
||||
if(p >= scend) {
|
||||
_ASN_CALLBACK(scratch, p - scratch);
|
||||
ASN__CALLBACK(scratch, p - scratch);
|
||||
er.encoded += p - scratch;
|
||||
p = scratch;
|
||||
}
|
||||
@@ -602,15 +611,15 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
*p++ = h2c[*buf & 0x0F];
|
||||
}
|
||||
|
||||
_ASN_CALLBACK(scratch, p-scratch); /* Dump the rest */
|
||||
ASN__CALLBACK(scratch, p-scratch); /* Dump the rest */
|
||||
er.encoded += p - scratch;
|
||||
} else {
|
||||
for(i = 0; buf < end; buf++, i++) {
|
||||
if(!(i % 16) && (i || st->size > 16)) {
|
||||
_ASN_CALLBACK(scratch, p-scratch);
|
||||
ASN__CALLBACK(scratch, p-scratch);
|
||||
er.encoded += (p-scratch);
|
||||
p = scratch;
|
||||
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||
ASN__TEXT_INDENT(1, ilevel);
|
||||
}
|
||||
*p++ = h2c[(*buf >> 4) & 0x0F];
|
||||
*p++ = h2c[*buf & 0x0F];
|
||||
@@ -618,20 +627,20 @@ OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
}
|
||||
if(p - scratch) {
|
||||
p--; /* Remove the tail space */
|
||||
_ASN_CALLBACK(scratch, p-scratch); /* Dump the rest */
|
||||
ASN__CALLBACK(scratch, p-scratch); /* Dump the rest */
|
||||
er.encoded += p - scratch;
|
||||
if(st->size > 16)
|
||||
_i_ASN_TEXT_INDENT(1, ilevel-1);
|
||||
ASN__TEXT_INDENT(1, ilevel-1);
|
||||
}
|
||||
}
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
cb_failed:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
static struct OCTET_STRING__xer_escape_table_s {
|
||||
char *string;
|
||||
static const struct OCTET_STRING__xer_escape_table_s {
|
||||
const char *string;
|
||||
int size;
|
||||
} OCTET_STRING__xer_escape_table[] = {
|
||||
#define OSXET(s) { s, sizeof(s) - 1 }
|
||||
@@ -693,7 +702,7 @@ OS__check_escaped_control_char(const void *buf, int size) {
|
||||
* nested table lookups).
|
||||
*/
|
||||
for(i = 0; i < 32 /* Don't spend time on the bottom half */; i++) {
|
||||
struct OCTET_STRING__xer_escape_table_s *el;
|
||||
const struct OCTET_STRING__xer_escape_table_s *el;
|
||||
el = &OCTET_STRING__xer_escape_table[i];
|
||||
if(el->size == size && memcmp(buf, el->string, size) == 0)
|
||||
return i;
|
||||
@@ -737,7 +746,7 @@ OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
(void)flags; /* Unused argument */
|
||||
|
||||
if(!st || (!st->buf && st->size))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
buf = st->buf;
|
||||
end = buf + st->size;
|
||||
@@ -754,7 +763,7 @@ OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(((buf - ss) && cb(ss, buf - ss, app_key) < 0)
|
||||
|| cb(OCTET_STRING__xer_escape_table[ch].string, s_len,
|
||||
app_key) < 0)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
encoded_len += (buf - ss) + s_len;
|
||||
ss = buf + 1;
|
||||
}
|
||||
@@ -762,10 +771,10 @@ OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
|
||||
encoded_len += (buf - ss);
|
||||
if((buf - ss) && cb(ss, buf - ss, app_key) < 0)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = encoded_len;
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1511,7 +1520,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
int ct_extensible;
|
||||
|
||||
if(!st || (!st->buf && st->size))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
if(pc) {
|
||||
cval = &pc->value;
|
||||
@@ -1525,7 +1534,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
switch(specs->subvariant) {
|
||||
default:
|
||||
case ASN_OSUBV_ANY:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
case ASN_OSUBV_BIT:
|
||||
canonical_unit_bits = unit_bits = 1;
|
||||
bpc = OS__BPC_BIT;
|
||||
@@ -1573,7 +1582,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
unit_bits = canonical_unit_bits;
|
||||
inext = 1;
|
||||
} else
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
inext = 0;
|
||||
@@ -1582,7 +1591,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
if(ct_extensible) {
|
||||
/* Declare whether length is [not] within extension root */
|
||||
if(per_put_few_bits(po, inext, 1))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
/* X.691, #16.5: zero-length encoding */
|
||||
@@ -1594,7 +1603,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
csiz->effective_bits);
|
||||
ret = per_put_few_bits(po, sizeinunits - csiz->lower_bound,
|
||||
csiz->effective_bits);
|
||||
if(ret) _ASN_ENCODE_FAILED;
|
||||
if(ret) ASN__ENCODE_FAILED;
|
||||
if(bpc) {
|
||||
ret = OCTET_STRING_per_put_characters(po, st->buf,
|
||||
sizeinunits, bpc, unit_bits,
|
||||
@@ -1603,22 +1612,22 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
ret = per_put_many_bits(po, st->buf,
|
||||
sizeinunits * unit_bits);
|
||||
}
|
||||
if(ret) _ASN_ENCODE_FAILED;
|
||||
_ASN_ENCODED_OK(er);
|
||||
if(ret) ASN__ENCODE_FAILED;
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
ASN_DEBUG("Encoding %d bytes", st->size);
|
||||
|
||||
if(sizeinunits == 0) {
|
||||
if(uper_put_length(po, 0))
|
||||
_ASN_ENCODE_FAILED;
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODE_FAILED;
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
buf = st->buf;
|
||||
while(sizeinunits) {
|
||||
ssize_t maySave = uper_put_length(po, sizeinunits);
|
||||
if(maySave < 0) _ASN_ENCODE_FAILED;
|
||||
if(maySave < 0) ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("Encoding %ld of %ld",
|
||||
(long)maySave, (long)sizeinunits);
|
||||
@@ -1630,7 +1639,7 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
} else {
|
||||
ret = per_put_many_bits(po, buf, maySave * unit_bits);
|
||||
}
|
||||
if(ret) _ASN_ENCODE_FAILED;
|
||||
if(ret) ASN__ENCODE_FAILED;
|
||||
|
||||
if(bpc)
|
||||
buf += maySave * bpc;
|
||||
@@ -1640,13 +1649,13 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
assert(!(maySave & 0x07) || !sizeinunits);
|
||||
}
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
int
|
||||
OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
||||
asn_app_consume_bytes_f *cb, void *app_key) {
|
||||
static const char *h2c = "0123456789ABCDEF";
|
||||
const char * const h2c = "0123456789ABCDEF";
|
||||
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
|
||||
char scratch[16 * 3 + 4];
|
||||
char *p = scratch;
|
||||
@@ -1703,16 +1712,18 @@ OCTET_STRING_print_utf8(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
void
|
||||
OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
|
||||
OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
|
||||
asn_OCTET_STRING_specifics_t *specs = td->specifics
|
||||
? (asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_DEF_OCTET_STRING_specs;
|
||||
asn_struct_ctx_t *ctx = (asn_struct_ctx_t *)
|
||||
((char *)st + specs->ctx_offset);
|
||||
asn_OCTET_STRING_specifics_t *specs;
|
||||
asn_struct_ctx_t *ctx;
|
||||
struct _stack *stck;
|
||||
|
||||
if(!td || !st)
|
||||
return;
|
||||
|
||||
specs = td->specifics
|
||||
? (asn_OCTET_STRING_specifics_t *)td->specifics
|
||||
: &asn_DEF_OCTET_STRING_specs;
|
||||
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
||||
|
||||
ASN_DEBUG("Freeing %s as OCTET STRING", td->name);
|
||||
|
||||
if(st->buf) {
|
||||
|
||||
@@ -63,7 +63,7 @@ OCTET_STRING_t *OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td,
|
||||
* Internally useful stuff. *
|
||||
****************************/
|
||||
|
||||
typedef struct asn_OCTET_STRING_specifics_s {
|
||||
typedef const struct asn_OCTET_STRING_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#include "TypeValuePair.h"
|
||||
@@ -27,10 +27,10 @@ static asn_TYPE_member_t asn_MBR_TypeValuePair_1[] = {
|
||||
"value"
|
||||
},
|
||||
};
|
||||
static ber_tlv_tag_t asn_DEF_TypeValuePair_tags_1[] = {
|
||||
static const ber_tlv_tag_t asn_DEF_TypeValuePair_tags_1[] = {
|
||||
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
|
||||
};
|
||||
static asn_TYPE_tag2member_t asn_MAP_TypeValuePair_tag2el_1[] = {
|
||||
static const asn_TYPE_tag2member_t asn_MAP_TypeValuePair_tag2el_1[] = {
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type */
|
||||
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* value */
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Generated by asn1c-0.9.27 (http://lionet.info/asn1c)
|
||||
* Generated by asn1c-0.9.28 (http://lionet.info/asn1c)
|
||||
* From ASN.1 module "KeytabModule"
|
||||
* found in "ipa.asn1"
|
||||
* `asn1c -fskeletons-copy`
|
||||
* `asn1c -fskeletons-copy -fnative-types`
|
||||
*/
|
||||
|
||||
#ifndef _TypeValuePair_H_
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
/*
|
||||
* Application-level ASN.1 callbacks.
|
||||
*/
|
||||
#ifndef _ASN_APPLICATION_H_
|
||||
#define _ASN_APPLICATION_H_
|
||||
#ifndef ASN_APPLICATION_H
|
||||
#define ASN_APPLICATION_H
|
||||
|
||||
#include "asn_system.h" /* for platform-dependent types */
|
||||
#include "asn_codecs.h" /* for ASN.1 codecs specifics */
|
||||
@@ -44,4 +44,4 @@ typedef void (asn_app_constraint_failed_f)(void *application_specific_key,
|
||||
|
||||
#include "constr_TYPE.h" /* for asn_TYPE_descriptor_t */
|
||||
|
||||
#endif /* _ASN_APPLICATION_H_ */
|
||||
#endif /* ASN_APPLICATION_H */
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _ASN_CODECS_H_
|
||||
#define _ASN_CODECS_H_
|
||||
#ifndef ASN_CODECS_H
|
||||
#define ASN_CODECS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -57,7 +57,7 @@ typedef struct asn_enc_rval_s {
|
||||
/* Pointer to the structure of that type */
|
||||
void *structure_ptr;
|
||||
} asn_enc_rval_t;
|
||||
#define _ASN_ENCODE_FAILED do { \
|
||||
#define ASN__ENCODE_FAILED do { \
|
||||
asn_enc_rval_t tmp_error; \
|
||||
tmp_error.encoded = -1; \
|
||||
tmp_error.failed_type = td; \
|
||||
@@ -65,7 +65,7 @@ typedef struct asn_enc_rval_s {
|
||||
ASN_DEBUG("Failed to encode element %s", td ? td->name : ""); \
|
||||
return tmp_error; \
|
||||
} while(0)
|
||||
#define _ASN_ENCODED_OK(rval) do { \
|
||||
#define ASN__ENCODED_OK(rval) do { \
|
||||
rval.structure_ptr = 0; \
|
||||
rval.failed_type = 0; \
|
||||
return rval; \
|
||||
@@ -88,14 +88,14 @@ typedef struct asn_dec_rval_s {
|
||||
enum asn_dec_rval_code_e code; /* Result code */
|
||||
size_t consumed; /* Number of bytes consumed */
|
||||
} asn_dec_rval_t;
|
||||
#define _ASN_DECODE_FAILED do { \
|
||||
#define ASN__DECODE_FAILED do { \
|
||||
asn_dec_rval_t tmp_error; \
|
||||
tmp_error.code = RC_FAIL; \
|
||||
tmp_error.consumed = 0; \
|
||||
ASN_DEBUG("Failed to decode element %s", td ? td->name : ""); \
|
||||
return tmp_error; \
|
||||
} while(0)
|
||||
#define _ASN_DECODE_STARVED do { \
|
||||
#define ASN__DECODE_STARVED do { \
|
||||
asn_dec_rval_t tmp_error; \
|
||||
tmp_error.code = RC_WMORE; \
|
||||
tmp_error.consumed = 0; \
|
||||
@@ -106,4 +106,4 @@ typedef struct asn_dec_rval_s {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ASN_CODECS_H_ */
|
||||
#endif /* ASN_CODECS_H */
|
||||
|
||||
@@ -15,14 +15,14 @@ ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
|
||||
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.
|
||||
ber_tlv_len_t length = 0; /* =0 to avoid [incorrect] warning. */
|
||||
|
||||
/*
|
||||
* If the structure is not there, allocate it.
|
||||
*/
|
||||
if(st == NULL) {
|
||||
st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st));
|
||||
if(st == NULL) _ASN_DECODE_FAILED;
|
||||
if(st == NULL) ASN__DECODE_FAILED;
|
||||
*sptr = (void *)st;
|
||||
}
|
||||
|
||||
@@ -55,13 +55,13 @@ ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
|
||||
if(sizeof(st->size) != sizeof(length)
|
||||
&& (ber_tlv_len_t)st->size != length) {
|
||||
st->size = 0;
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
st->buf = (uint8_t *)MALLOC(length + 1);
|
||||
if(!st->buf) {
|
||||
st->size = 0;
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
memcpy(st->buf, buf_ptr, length);
|
||||
@@ -111,7 +111,7 @@ der_encode_primitive(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
}
|
||||
|
||||
erval.encoded += st->size;
|
||||
_ASN_ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -258,7 +258,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
|
||||
*/
|
||||
if(!*sptr) {
|
||||
*sptr = CALLOC(1, struct_size);
|
||||
if(!*sptr) _ASN_DECODE_FAILED;
|
||||
if(!*sptr) ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
memset(&s_ctx, 0, sizeof(s_ctx));
|
||||
@@ -288,7 +288,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
|
||||
/*
|
||||
* This decoder does not like empty stuff.
|
||||
*/
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -304,7 +304,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
|
||||
if(s_arg.want_more)
|
||||
rc.code = RC_WMORE;
|
||||
else
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
/*
|
||||
* Declarations internally useful for the ASN.1 support code.
|
||||
*/
|
||||
#ifndef _ASN_INTERNAL_H_
|
||||
#define _ASN_INTERNAL_H_
|
||||
#ifndef ASN_INTERNAL_H
|
||||
#define ASN_INTERNAL_H
|
||||
|
||||
#include "asn_application.h" /* Application-visible API */
|
||||
|
||||
@@ -59,50 +59,52 @@ void ASN_DEBUG_f(const char *fmt, ...);
|
||||
#define ASN_DEBUG ASN_DEBUG_f
|
||||
#endif /* __GNUC__ */
|
||||
#else /* EMIT_ASN_DEBUG != 1 */
|
||||
static inline void ASN_DEBUG(const char *fmt, ...) { (void)fmt; }
|
||||
static void ASN_DEBUG(const char *fmt, ...) { (void)fmt; }
|
||||
#endif /* EMIT_ASN_DEBUG */
|
||||
#endif /* ASN_DEBUG */
|
||||
|
||||
/*
|
||||
* Invoke the application-supplied callback and fail, if something is wrong.
|
||||
*/
|
||||
#define __ASN_E_cbc(buf, size) (cb((buf), (size), app_key) < 0)
|
||||
#define _ASN_E_CALLBACK(foo) do { \
|
||||
#define ASN__E_cbc(buf, size) (cb((buf), (size), app_key) < 0)
|
||||
#define ASN__E_CALLBACK(foo) do { \
|
||||
if(foo) goto cb_failed; \
|
||||
} while(0)
|
||||
#define _ASN_CALLBACK(buf, size) \
|
||||
_ASN_E_CALLBACK(__ASN_E_cbc(buf, size))
|
||||
#define _ASN_CALLBACK2(buf1, size1, buf2, size2) \
|
||||
_ASN_E_CALLBACK(__ASN_E_cbc(buf1, size1) || __ASN_E_cbc(buf2, size2))
|
||||
#define _ASN_CALLBACK3(buf1, size1, buf2, size2, buf3, size3) \
|
||||
_ASN_E_CALLBACK(__ASN_E_cbc(buf1, size1) \
|
||||
|| __ASN_E_cbc(buf2, size2) \
|
||||
|| __ASN_E_cbc(buf3, size3))
|
||||
#define ASN__CALLBACK(buf, size) \
|
||||
ASN__E_CALLBACK(ASN__E_cbc(buf, size))
|
||||
#define ASN__CALLBACK2(buf1, size1, buf2, size2) \
|
||||
ASN__E_CALLBACK(ASN__E_cbc(buf1, size1) || ASN__E_cbc(buf2, size2))
|
||||
#define ASN__CALLBACK3(buf1, size1, buf2, size2, buf3, size3) \
|
||||
ASN__E_CALLBACK(ASN__E_cbc(buf1, size1) \
|
||||
|| ASN__E_cbc(buf2, size2) \
|
||||
|| ASN__E_cbc(buf3, size3))
|
||||
|
||||
#define _i_ASN_TEXT_INDENT(nl, level) do { \
|
||||
int __level = (level); \
|
||||
int __nl = ((nl) != 0); \
|
||||
int __i; \
|
||||
if(__nl) _ASN_CALLBACK("\n", 1); \
|
||||
if(__level < 0) __level = 0; \
|
||||
for(__i = 0; __i < __level; __i++) \
|
||||
_ASN_CALLBACK(" ", 4); \
|
||||
er.encoded += __nl + 4 * __level; \
|
||||
} while(0)
|
||||
#define ASN__TEXT_INDENT(nl, level) do { \
|
||||
int tmp_level = (level); \
|
||||
int tmp_nl = ((nl) != 0); \
|
||||
int tmp_i; \
|
||||
if(tmp_nl) ASN__CALLBACK("\n", 1); \
|
||||
if(tmp_level < 0) tmp_level = 0; \
|
||||
for(tmp_i = 0; tmp_i < tmp_level; tmp_i++) \
|
||||
ASN__CALLBACK(" ", 4); \
|
||||
er.encoded += tmp_nl + 4 * tmp_level; \
|
||||
} while(0)
|
||||
|
||||
#define _i_INDENT(nl) do { \
|
||||
int __i; \
|
||||
if((nl) && cb("\n", 1, app_key) < 0) return -1; \
|
||||
for(__i = 0; __i < ilevel; __i++) \
|
||||
if(cb(" ", 4, app_key) < 0) return -1; \
|
||||
} while(0)
|
||||
#define _i_INDENT(nl) do { \
|
||||
int tmp_i; \
|
||||
if((nl) && cb("\n", 1, app_key) < 0) \
|
||||
return -1; \
|
||||
for(tmp_i = 0; tmp_i < ilevel; tmp_i++) \
|
||||
if(cb(" ", 4, app_key) < 0) \
|
||||
return -1; \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Check stack against overflow, if limit is set.
|
||||
*/
|
||||
#define _ASN_DEFAULT_STACK_MAX (30000)
|
||||
static inline int
|
||||
_ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) {
|
||||
#define ASN__DEFAULT_STACK_MAX (30000)
|
||||
static int __attribute__((unused))
|
||||
ASN__STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) {
|
||||
if(ctx && ctx->max_stack_size) {
|
||||
|
||||
/* ctx MUST be allocated on the stack */
|
||||
@@ -123,4 +125,4 @@ _ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ASN_INTERNAL_H_ */
|
||||
#endif /* ASN_INTERNAL_H */
|
||||
|
||||
@@ -6,13 +6,17 @@
|
||||
/*
|
||||
* Miscellaneous system-dependent types.
|
||||
*/
|
||||
#ifndef _ASN_SYSTEM_H_
|
||||
#define _ASN_SYSTEM_H_
|
||||
#ifndef ASN_SYSTEM_H
|
||||
#define ASN_SYSTEM_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef _BSD_SOURCE
|
||||
#define _BSD_SOURCE /* for snprintf() on some linux systems */
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* For snprintf(3) */
|
||||
#include <stdlib.h> /* For *alloc(3) */
|
||||
#include <string.h> /* For memcpy(3) */
|
||||
@@ -21,6 +25,10 @@
|
||||
#include <stdarg.h> /* For va_start */
|
||||
#include <stddef.h> /* for offsetof and ptrdiff_t */
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h> /* For alloca(3) */
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <malloc.h>
|
||||
@@ -126,4 +134,4 @@ typedef unsigned int uint32_t;
|
||||
#endif /* __GNUC__ */
|
||||
#endif /* MIN */
|
||||
|
||||
#endif /* _ASN_SYSTEM_H_ */
|
||||
#endif /* ASN_SYSTEM_H */
|
||||
|
||||
@@ -44,7 +44,7 @@ ber_decode(asn_codec_ctx_t *opt_codec_ctx,
|
||||
} else {
|
||||
/* If context is not given, be security-conscious anyway */
|
||||
memset(&s_codec_ctx, 0, sizeof(s_codec_ctx));
|
||||
s_codec_ctx.max_stack_size = _ASN_DEFAULT_STACK_MAX;
|
||||
s_codec_ctx.max_stack_size = ASN__DEFAULT_STACK_MAX;
|
||||
opt_codec_ctx = &s_codec_ctx;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
|
||||
/*
|
||||
* Make sure we didn't exceed the maximum stack size.
|
||||
*/
|
||||
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
RETURN(RC_FAIL);
|
||||
|
||||
/*
|
||||
|
||||
@@ -85,7 +85,7 @@ ber_skip_length(asn_codec_ctx_t *opt_codec_ctx,
|
||||
/*
|
||||
* Make sure we didn't exceed the maximum stack size.
|
||||
*/
|
||||
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
return -1;
|
||||
|
||||
/*
|
||||
|
||||
@@ -183,11 +183,11 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
}
|
||||
|
||||
do {
|
||||
asn_TYPE_tag2member_t *t2m;
|
||||
const asn_TYPE_tag2member_t *t2m;
|
||||
asn_TYPE_tag2member_t key;
|
||||
|
||||
key.el_tag = tlv_tag;
|
||||
t2m = (asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
specs->tag2el, specs->tag2el_count,
|
||||
sizeof(specs->tag2el[0]), _search4tag);
|
||||
if(t2m) {
|
||||
@@ -364,7 +364,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
size_t computed_size = 0;
|
||||
int present;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("%s %s as CHOICE",
|
||||
cb?"Encoding":"Estimating", td->name);
|
||||
@@ -380,9 +380,9 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(present == 0 && td->elements_count == 0) {
|
||||
/* The CHOICE is empty?! */
|
||||
erval.encoded = 0;
|
||||
_ASN_ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -394,10 +394,10 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(memb_ptr == 0) {
|
||||
if(elm->optional) {
|
||||
erval.encoded = 0;
|
||||
_ASN_ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
/* Mandatory element absent */
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
@@ -424,7 +424,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
ret = der_write_tags(td, erval.encoded, tag_mode, 1, tag,
|
||||
cb, app_key);
|
||||
if(ret == -1)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
computed_size += ret;
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
}
|
||||
|
||||
ber_tlv_tag_t
|
||||
CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
|
||||
CHOICE_outmost_tag(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber_tlv_tag_t tag) {
|
||||
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||
int present;
|
||||
|
||||
@@ -458,7 +458,7 @@ CHOICE_outmost_tag(asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode, ber
|
||||
present = _fetch_present_idx(ptr, specs->pres_offset, specs->pres_size);
|
||||
|
||||
if(present > 0 || present <= td->elements_count) {
|
||||
asn_TYPE_member_t *elm = &td->elements[present-1];
|
||||
const asn_TYPE_member_t *elm = &td->elements[present-1];
|
||||
const void *memb_ptr;
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
@@ -483,7 +483,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int present;
|
||||
|
||||
if(!sptr) {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: value not given (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -502,7 +502,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
if(!memb_ptr) {
|
||||
if(elm->optional)
|
||||
return 0;
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: mandatory CHOICE element %s absent (%s:%d)",
|
||||
td->name, elm->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -525,7 +525,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: no CHOICE element given (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -640,11 +640,12 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
* Get the next part of the XML stream.
|
||||
*/
|
||||
ch_size = xer_next_token(&ctx->context, buf_ptr, size, &ch_type);
|
||||
switch(ch_size) {
|
||||
case -1: RETURN(RC_FAIL);
|
||||
case 0: RETURN(RC_WMORE);
|
||||
default:
|
||||
if(ch_size == -1) {
|
||||
RETURN(RC_FAIL);
|
||||
} else {
|
||||
switch(ch_type) {
|
||||
case PXER_WMORE:
|
||||
RETURN(RC_WMORE);
|
||||
case PXER_COMMENT: /* Got XML comment */
|
||||
case PXER_TEXT: /* Ignore free-standing text */
|
||||
XER_ADVANCE(ch_size); /* Skip silently */
|
||||
@@ -670,6 +671,7 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
case -1:
|
||||
ctx->phase = 5;
|
||||
RETURN(RC_FAIL);
|
||||
continue;
|
||||
case 1:
|
||||
ctx->phase = 3;
|
||||
/* Fall through */
|
||||
@@ -779,7 +781,7 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int present;
|
||||
|
||||
if(!sptr)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
/*
|
||||
* Figure out which CHOICE element is encoded.
|
||||
@@ -787,7 +789,7 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
|
||||
|
||||
if(present <= 0 || present > td->elements_count) {
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
asn_enc_rval_t tmper;
|
||||
asn_TYPE_member_t *elm = &td->elements[present-1];
|
||||
@@ -797,30 +799,30 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
|
||||
if(elm->flags & ATF_POINTER) {
|
||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||
if(!memb_ptr) _ASN_ENCODE_FAILED;
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
if(!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
if(!(flags & XER_F_CANONICAL)) ASN__TEXT_INDENT(1, ilevel);
|
||||
ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
ASN__CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
|
||||
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
if(!(flags & XER_F_CANONICAL)) ASN__TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
cb_failed:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
asn_dec_rval_t
|
||||
@@ -835,15 +837,15 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
void *st = *sptr;
|
||||
int value;
|
||||
|
||||
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
_ASN_DECODE_FAILED;
|
||||
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
ASN__DECODE_FAILED;
|
||||
|
||||
/*
|
||||
* Create the target structure if it is not present already.
|
||||
*/
|
||||
if(!st) {
|
||||
st = *sptr = CALLOC(1, specs->struct_size);
|
||||
if(!st) _ASN_DECODE_FAILED;
|
||||
if(!st) ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
if(constraints) ct = &constraints->value;
|
||||
@@ -852,25 +854,25 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
|
||||
if(ct && ct->flags & APC_EXTENSIBLE) {
|
||||
value = per_get_few_bits(pd, 1);
|
||||
if(value < 0) _ASN_DECODE_STARVED;
|
||||
if(value < 0) ASN__DECODE_STARVED;
|
||||
if(value) ct = 0; /* Not restricted */
|
||||
}
|
||||
|
||||
if(ct && ct->range_bits >= 0) {
|
||||
value = per_get_few_bits(pd, ct->range_bits);
|
||||
if(value < 0) _ASN_DECODE_STARVED;
|
||||
if(value < 0) ASN__DECODE_STARVED;
|
||||
ASN_DEBUG("CHOICE %s got index %d in range %d",
|
||||
td->name, value, ct->range_bits);
|
||||
if(value > ct->upper_bound)
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
} else {
|
||||
if(specs->ext_start == -1)
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
value = uper_get_nsnnwn(pd);
|
||||
if(value < 0) _ASN_DECODE_STARVED;
|
||||
if(value < 0) ASN__DECODE_STARVED;
|
||||
value += specs->ext_start;
|
||||
if(value >= td->elements_count)
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
/* Adjust if canonical order is different from natural order */
|
||||
@@ -914,7 +916,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
int present;
|
||||
int present_enc;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
|
||||
ASN_DEBUG("Encoding %s as CHOICE", td->name);
|
||||
|
||||
@@ -930,7 +932,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
* can't deduce what to encode in the choice type.
|
||||
*/
|
||||
if(present <= 0 || present > td->elements_count)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
else
|
||||
present--;
|
||||
|
||||
@@ -947,43 +949,43 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
|| present_enc > ct->upper_bound) {
|
||||
if(ct->flags & APC_EXTENSIBLE) {
|
||||
if(per_put_few_bits(po, 1, 1))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
ct = 0;
|
||||
}
|
||||
}
|
||||
if(ct && ct->flags & APC_EXTENSIBLE)
|
||||
if(per_put_few_bits(po, 0, 1))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
elm = &td->elements[present];
|
||||
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;
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
} else {
|
||||
memb_ptr = (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;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
return elm->type->uper_encoder(elm->type, elm->per_constraints,
|
||||
memb_ptr, po);
|
||||
} else {
|
||||
asn_enc_rval_t rval;
|
||||
if(specs->ext_start == -1)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
if(uper_put_nsnnwn(po, present_enc - specs->ext_start))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
if(uper_open_type_put(elm->type, elm->per_constraints,
|
||||
memb_ptr, po))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
rval.encoded = 0;
|
||||
_ASN_ENCODED_OK(rval);
|
||||
ASN__ENCODED_OK(rval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_CHOICE_specifics_s {
|
||||
typedef const struct asn_CHOICE_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
@@ -24,7 +24,7 @@ typedef struct asn_CHOICE_specifics_s {
|
||||
/*
|
||||
* Tags to members mapping table.
|
||||
*/
|
||||
asn_TYPE_tag2member_t *tag2el;
|
||||
const asn_TYPE_tag2member_t *tag2el;
|
||||
int tag2el_count;
|
||||
|
||||
/* Canonical ordering of CHOICE elements, for PER */
|
||||
|
||||
@@ -310,16 +310,16 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
* Resort to a binary search over
|
||||
* sorted array of tags.
|
||||
*/
|
||||
asn_TYPE_tag2member_t *t2m;
|
||||
const asn_TYPE_tag2member_t *t2m;
|
||||
asn_TYPE_tag2member_t key;
|
||||
key.el_tag = tlv_tag;
|
||||
key.el_no = edx;
|
||||
t2m = (asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
t2m = (const asn_TYPE_tag2member_t *)bsearch(&key,
|
||||
specs->tag2el, specs->tag2el_count,
|
||||
sizeof(specs->tag2el[0]), _t2e_cmp);
|
||||
if(t2m) {
|
||||
asn_TYPE_tag2member_t *best = 0;
|
||||
asn_TYPE_tag2member_t *t2m_f, *t2m_l;
|
||||
const asn_TYPE_tag2member_t *best = 0;
|
||||
const asn_TYPE_tag2member_t *t2m_f, *t2m_l;
|
||||
int edx_max = edx + elements[edx].optional;
|
||||
/*
|
||||
* Rewind to the first element with that tag,
|
||||
@@ -532,7 +532,7 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
||||
if(!memb_ptr) {
|
||||
if(elm->optional) continue;
|
||||
/* Mandatory element is missing */
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
@@ -553,10 +553,10 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
||||
ret = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key);
|
||||
ASN_DEBUG("Wrote tags: %ld (+%ld)", (long)ret, (long)computed_size);
|
||||
if(ret == -1)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
erval.encoded = computed_size + ret;
|
||||
|
||||
if(!cb) _ASN_ENCODED_OK(erval);
|
||||
if(!cb) ASN__ENCODED_OK(erval);
|
||||
|
||||
/*
|
||||
* Encode all members.
|
||||
@@ -586,9 +586,9 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td,
|
||||
/*
|
||||
* Encoded size is not equal to the computed size.
|
||||
*/
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
_ASN_ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
|
||||
|
||||
@@ -692,11 +692,12 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
*/
|
||||
ch_size = xer_next_token(&ctx->context, buf_ptr, size,
|
||||
&ch_type);
|
||||
switch(ch_size) {
|
||||
case -1: RETURN(RC_FAIL);
|
||||
case 0: RETURN(RC_WMORE);
|
||||
default:
|
||||
if(ch_size == -1) {
|
||||
RETURN(RC_FAIL);
|
||||
} else {
|
||||
switch(ch_type) {
|
||||
case PXER_WMORE:
|
||||
RETURN(RC_WMORE);
|
||||
case PXER_COMMENT: /* Got XML comment */
|
||||
case PXER_TEXT: /* Ignore free-standing text */
|
||||
XER_ADVANCE(ch_size); /* Skip silently */
|
||||
@@ -857,7 +858,7 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int edx;
|
||||
|
||||
if(!sptr)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
@@ -874,29 +875,29 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(elm->optional)
|
||||
continue;
|
||||
/* Mandatory element is missing */
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel);
|
||||
ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
||||
/* Print the member itself */
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + 1, flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
ASN__CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
cb_failed:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -980,7 +981,7 @@ SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int edx;
|
||||
|
||||
if(!sptr) {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: value not given (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -998,7 +999,7 @@ SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
if(!memb_ptr) {
|
||||
if(elm->optional)
|
||||
continue;
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: mandatory element %s absent (%s:%d)",
|
||||
td->name, elm->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -1039,12 +1040,12 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
|
||||
(void)constraints;
|
||||
|
||||
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
_ASN_DECODE_FAILED;
|
||||
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
ASN__DECODE_FAILED;
|
||||
|
||||
if(!st) {
|
||||
st = *sptr = CALLOC(1, specs->struct_size);
|
||||
if(!st) _ASN_DECODE_FAILED;
|
||||
if(!st) ASN__DECODE_FAILED;
|
||||
}
|
||||
|
||||
ASN_DEBUG("Decoding %s as SEQUENCE (UPER)", td->name);
|
||||
@@ -1052,7 +1053,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
/* Handle extensions */
|
||||
if(specs->ext_before >= 0) {
|
||||
extpresent = per_get_few_bits(pd, 1);
|
||||
if(extpresent < 0) _ASN_DECODE_STARVED;
|
||||
if(extpresent < 0) ASN__DECODE_STARVED;
|
||||
} else {
|
||||
extpresent = 0;
|
||||
}
|
||||
@@ -1061,11 +1062,11 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
memset(&opmd, 0, sizeof(opmd));
|
||||
if(specs->roms_count) {
|
||||
opres = (uint8_t *)MALLOC(((specs->roms_count + 7) >> 3) + 1);
|
||||
if(!opres) _ASN_DECODE_FAILED;
|
||||
if(!opres) ASN__DECODE_FAILED;
|
||||
/* Get the presence map */
|
||||
if(per_get_many_bits(pd, opres, 0, specs->roms_count)) {
|
||||
FREEMEM(opres);
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
}
|
||||
opmd.buffer = opres;
|
||||
opmd.nbits = specs->roms_count;
|
||||
@@ -1106,7 +1107,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
/* Fill-in DEFAULT */
|
||||
if(elm->default_value(1, memb_ptr2)) {
|
||||
FREEMEM(opres);
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
ASN_DEBUG("Filled-in default");
|
||||
}
|
||||
@@ -1140,16 +1141,18 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
asn_per_data_t epmd;
|
||||
|
||||
bmlength = uper_get_nslength(pd);
|
||||
if(bmlength < 0) _ASN_DECODE_STARVED;
|
||||
if(bmlength < 0) ASN__DECODE_STARVED;
|
||||
|
||||
ASN_DEBUG("Extensions %ld present in %s", (long)bmlength, td->name);
|
||||
|
||||
epres = (uint8_t *)MALLOC((bmlength + 15) >> 3);
|
||||
if(!epres) _ASN_DECODE_STARVED;
|
||||
if(!epres) ASN__DECODE_STARVED;
|
||||
|
||||
/* Get the extensions map */
|
||||
if(per_get_many_bits(pd, epres, 0, bmlength))
|
||||
_ASN_DECODE_STARVED;
|
||||
if(per_get_many_bits(pd, epres, 0, bmlength)) {
|
||||
FREEMEM(epres);
|
||||
ASN__DECODE_STARVED;
|
||||
}
|
||||
|
||||
memset(&epmd, 0, sizeof(epmd));
|
||||
epmd.buffer = epres;
|
||||
@@ -1202,7 +1205,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
default:
|
||||
if(uper_open_type_skip(opt_codec_ctx, pd)) {
|
||||
FREEMEM(epres);
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1230,7 +1233,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
|
||||
/* Set default value */
|
||||
if(elm->default_value(1, memb_ptr2)) {
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1304,7 +1307,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
(void)constraints;
|
||||
|
||||
if(!sptr)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
@@ -1352,7 +1355,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
elm->default_value ? "def" : "wtv",
|
||||
td->name, elm->name, present ? "present" : "absent");
|
||||
if(per_put_few_bits(po, present, 1))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1380,7 +1383,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
if(elm->optional)
|
||||
continue;
|
||||
/* Mandatory element is missing */
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||
@@ -1399,24 +1402,24 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
}
|
||||
|
||||
/* No extensions to encode */
|
||||
if(!n_extensions) _ASN_ENCODED_OK(er);
|
||||
if(!n_extensions) ASN__ENCODED_OK(er);
|
||||
|
||||
ASN_DEBUG("Length of %d bit-map", n_extensions);
|
||||
/* #18.8. Write down the presence bit-map length. */
|
||||
if(uper_put_nslength(po, n_extensions))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
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)
|
||||
_ASN_ENCODE_FAILED;
|
||||
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)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_SEQUENCE_specifics_s {
|
||||
typedef const struct asn_SEQUENCE_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
@@ -21,14 +21,14 @@ typedef struct asn_SEQUENCE_specifics_s {
|
||||
/*
|
||||
* Tags to members mapping table (sorted).
|
||||
*/
|
||||
asn_TYPE_tag2member_t *tag2el;
|
||||
const asn_TYPE_tag2member_t *tag2el;
|
||||
int tag2el_count;
|
||||
|
||||
/*
|
||||
* Optional members of the extensions root (roms) or additions (aoms).
|
||||
* Meaningful for PER.
|
||||
*/
|
||||
int *oms; /* Optional MemberS */
|
||||
const int *oms; /* Optional MemberS */
|
||||
int roms_count; /* Root optional members count */
|
||||
int aoms_count; /* Additions optional members count */
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
||||
computed_size += encoding_size;
|
||||
if(!cb) {
|
||||
erval.encoded = computed_size;
|
||||
_ASN_ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
|
||||
ASN_DEBUG("Encoding members of SEQUENCE OF %s", td->name);
|
||||
@@ -101,7 +101,7 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
int xcan = (flags & XER_F_CANONICAL);
|
||||
int i;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
|
||||
er.encoded = 0;
|
||||
|
||||
@@ -111,8 +111,8 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(!memb_ptr) continue;
|
||||
|
||||
if(mname) {
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel);
|
||||
ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
}
|
||||
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
@@ -121,23 +121,23 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(tmper.encoded == 0 && specs->as_XMLValueList) {
|
||||
const char *name = elm->type->xml_tag;
|
||||
size_t len = strlen(name);
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel + 1);
|
||||
_ASN_CALLBACK3("<", 1, name, len, "/>", 2);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel + 1);
|
||||
ASN__CALLBACK3("<", 1, name, len, "/>", 2);
|
||||
}
|
||||
|
||||
if(mname) {
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
ASN__CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
er.encoded += 5;
|
||||
}
|
||||
|
||||
er.encoded += (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
cb_failed:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
asn_enc_rval_t
|
||||
@@ -149,7 +149,7 @@ SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
asn_TYPE_member_t *elm = td->elements;
|
||||
int seq;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
list = _A_SEQUENCE_FROM_VOID(sptr);
|
||||
|
||||
er.encoded = 0;
|
||||
@@ -170,17 +170,17 @@ SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
if(ct->flags & APC_EXTENSIBLE) {
|
||||
/* Declare whether size is in extension root */
|
||||
if(per_put_few_bits(po, not_in_root, 1))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
if(not_in_root) ct = 0;
|
||||
} else if(not_in_root && ct->effective_bits >= 0)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
if(ct && ct->effective_bits >= 0) {
|
||||
/* X.691, #19.5: No length determinant */
|
||||
if(per_put_few_bits(po, list->count - ct->lower_bound,
|
||||
ct->effective_bits))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
for(seq = -1; seq < list->count;) {
|
||||
@@ -190,19 +190,19 @@ SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
||||
mayEncode = list->count;
|
||||
} else {
|
||||
mayEncode = uper_put_length(po, list->count - seq);
|
||||
if(mayEncode < 0) _ASN_ENCODE_FAILED;
|
||||
if(mayEncode < 0) ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
while(mayEncode--) {
|
||||
void *memb_ptr = list->array[seq++];
|
||||
if(!memb_ptr) _ASN_ENCODE_FAILED;
|
||||
if(!memb_ptr) ASN__ENCODE_FAILED;
|
||||
er = elm->type->uper_encoder(elm->type,
|
||||
elm->per_constraints, memb_ptr, po);
|
||||
if(er.encoded == -1)
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
||||
|
||||
if(!cb || list->count == 0) {
|
||||
erval.encoded = computed_size;
|
||||
_ASN_ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -451,7 +451,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
||||
erval.encoded = computed_size;
|
||||
}
|
||||
|
||||
_ASN_ENCODED_OK(erval);
|
||||
ASN__ENCODED_OK(erval);
|
||||
}
|
||||
|
||||
#undef XER_ADVANCE
|
||||
@@ -549,11 +549,12 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
*/
|
||||
ch_size = xer_next_token(&ctx->context,
|
||||
buf_ptr, size, &ch_type);
|
||||
switch(ch_size) {
|
||||
case -1: RETURN(RC_FAIL);
|
||||
case 0: RETURN(RC_WMORE);
|
||||
default:
|
||||
if(ch_size == -1) {
|
||||
RETURN(RC_FAIL);
|
||||
} else {
|
||||
switch(ch_type) {
|
||||
case PXER_WMORE:
|
||||
RETURN(RC_WMORE);
|
||||
case PXER_COMMENT: /* Got XML comment */
|
||||
case PXER_TEXT: /* Ignore free-standing text */
|
||||
XER_ADVANCE(ch_size); /* Skip silently */
|
||||
@@ -667,11 +668,11 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
asn_app_consume_bytes_f *original_cb = cb;
|
||||
int i;
|
||||
|
||||
if(!sptr) _ASN_ENCODE_FAILED;
|
||||
if(!sptr) ASN__ENCODE_FAILED;
|
||||
|
||||
if(xcan) {
|
||||
encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0]));
|
||||
if(!encs) _ASN_ENCODE_FAILED;
|
||||
if(!encs) ASN__ENCODE_FAILED;
|
||||
cb = SET_OF_encode_xer_callback;
|
||||
}
|
||||
|
||||
@@ -690,12 +691,12 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
}
|
||||
|
||||
if(mname) {
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel);
|
||||
ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
}
|
||||
|
||||
if(!xcan && specs->as_XMLValueList == 1)
|
||||
_i_ASN_TEXT_INDENT(1, ilevel + 1);
|
||||
ASN__TEXT_INDENT(1, ilevel + 1);
|
||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr,
|
||||
ilevel + (specs->as_XMLValueList != 2),
|
||||
flags, cb, app_key);
|
||||
@@ -707,18 +708,18 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
if(tmper.encoded == 0 && specs->as_XMLValueList) {
|
||||
const char *name = elm->type->xml_tag;
|
||||
size_t len = strlen(name);
|
||||
_ASN_CALLBACK3("<", 1, name, len, "/>", 2);
|
||||
ASN__CALLBACK3("<", 1, name, len, "/>", 2);
|
||||
}
|
||||
|
||||
if(mname) {
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
ASN__CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||
er.encoded += 5;
|
||||
}
|
||||
|
||||
er.encoded += (2 * mlen) + tmper.encoded;
|
||||
}
|
||||
|
||||
if(!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||
if(!xcan) ASN__TEXT_INDENT(1, ilevel - 1);
|
||||
|
||||
if(encs) {
|
||||
xer_tmp_enc_t *enc = encs;
|
||||
@@ -730,7 +731,7 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
qsort(encs, encs_count, sizeof(encs[0]), SET_OF_xer_order);
|
||||
|
||||
for(; enc < end; enc++) {
|
||||
_ASN_CALLBACK(enc->buffer, enc->offset);
|
||||
ASN__CALLBACK(enc->buffer, enc->offset);
|
||||
FREEMEM(enc->buffer);
|
||||
enc->buffer = 0;
|
||||
control_size += enc->offset;
|
||||
@@ -751,7 +752,7 @@ cleanup:
|
||||
}
|
||||
FREEMEM(encs);
|
||||
}
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -830,7 +831,7 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
||||
int i;
|
||||
|
||||
if(!sptr) {
|
||||
_ASN_CTFAIL(app_key, td, sptr,
|
||||
ASN__CTFAIL(app_key, td, sptr,
|
||||
"%s: value not given (%s:%d)",
|
||||
td->name, __FILE__, __LINE__);
|
||||
return -1;
|
||||
@@ -875,15 +876,15 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
int repeat = 0;
|
||||
ssize_t nelems;
|
||||
|
||||
if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
_ASN_DECODE_FAILED;
|
||||
if(ASN__STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||
ASN__DECODE_FAILED;
|
||||
|
||||
/*
|
||||
* Create the target structure if it is not present already.
|
||||
*/
|
||||
if(!st) {
|
||||
st = *sptr = CALLOC(1, specs->struct_size);
|
||||
if(!st) _ASN_DECODE_FAILED;
|
||||
if(!st) ASN__DECODE_FAILED;
|
||||
}
|
||||
list = _A_SET_FROM_VOID(st);
|
||||
|
||||
@@ -894,7 +895,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
|
||||
if(ct && ct->flags & APC_EXTENSIBLE) {
|
||||
int value = per_get_few_bits(pd, 1);
|
||||
if(value < 0) _ASN_DECODE_STARVED;
|
||||
if(value < 0) ASN__DECODE_STARVED;
|
||||
if(value) ct = 0; /* Not restricted! */
|
||||
}
|
||||
|
||||
@@ -903,7 +904,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
nelems = per_get_few_bits(pd, ct->effective_bits);
|
||||
ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s",
|
||||
(long)nelems, ct->lower_bound, td->name);
|
||||
if(nelems < 0) _ASN_DECODE_STARVED;
|
||||
if(nelems < 0) ASN__DECODE_STARVED;
|
||||
nelems += ct->lower_bound;
|
||||
} else {
|
||||
nelems = -1;
|
||||
@@ -916,7 +917,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
ct ? ct->effective_bits : -1, &repeat);
|
||||
ASN_DEBUG("Got to decode %d elements (eff %d)",
|
||||
(int)nelems, (int)(ct ? ct->effective_bits : -1));
|
||||
if(nelems < 0) _ASN_DECODE_STARVED;
|
||||
if(nelems < 0) ASN__DECODE_STARVED;
|
||||
}
|
||||
|
||||
for(i = 0; i < nelems; i++) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct asn_SET_OF_specifics_s {
|
||||
typedef const struct asn_SET_OF_specifics_s {
|
||||
/*
|
||||
* Target structure description.
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,7 @@ static asn_app_consume_bytes_f _print2fp;
|
||||
* Return the outmost tag of the type.
|
||||
*/
|
||||
ber_tlv_tag_t
|
||||
asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor,
|
||||
asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor,
|
||||
const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) {
|
||||
|
||||
if(tag_mode)
|
||||
|
||||
@@ -73,7 +73,7 @@ typedef int (asn_struct_print_f)(
|
||||
* Do not use it in your application.
|
||||
*/
|
||||
typedef ber_tlv_tag_t (asn_outmost_tag_f)(
|
||||
struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const struct asn_TYPE_descriptor_s *type_descriptor,
|
||||
const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag);
|
||||
/* The instance of the above function type; used internally. */
|
||||
asn_outmost_tag_f asn_TYPE_outmost_tag;
|
||||
@@ -83,8 +83,8 @@ asn_outmost_tag_f asn_TYPE_outmost_tag;
|
||||
* The definitive description of the destination language's structure.
|
||||
*/
|
||||
typedef struct asn_TYPE_descriptor_s {
|
||||
char *name; /* A name of the ASN.1 type. "" in some cases. */
|
||||
char *xml_tag; /* Name used in XML tag */
|
||||
const char *name; /* A name of the ASN.1 type. "" in some cases. */
|
||||
const char *xml_tag; /* Name used in XML tag */
|
||||
|
||||
/*
|
||||
* Generalized functions for dealing with the specific type.
|
||||
@@ -108,10 +108,10 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
* Tags that are expected to occur.
|
||||
*/
|
||||
asn_outmost_tag_f *outmost_tag; /* <optional, internal> */
|
||||
ber_tlv_tag_t *tags; /* Effective tags sequence for this type */
|
||||
int tags_count; /* Number of tags which are expected */
|
||||
ber_tlv_tag_t *all_tags;/* Every tag for BER/containment */
|
||||
int all_tags_count; /* Number of tags */
|
||||
const ber_tlv_tag_t *tags; /* Effective tags sequence for this type */
|
||||
int tags_count; /* Number of tags which are expected */
|
||||
const ber_tlv_tag_t *all_tags; /* Every tag for BER/containment */
|
||||
int all_tags_count; /* Number of tags */
|
||||
|
||||
asn_per_constraints_t *per_constraints; /* PER compiled constraints */
|
||||
|
||||
@@ -125,7 +125,7 @@ typedef struct asn_TYPE_descriptor_s {
|
||||
* Additional information describing the type, used by appropriate
|
||||
* functions above.
|
||||
*/
|
||||
void *specifics;
|
||||
const void *specifics;
|
||||
} asn_TYPE_descriptor_t;
|
||||
|
||||
/*
|
||||
@@ -147,7 +147,7 @@ typedef struct asn_TYPE_member_s {
|
||||
asn_constr_check_f *memb_constraints; /* Constraints validator */
|
||||
asn_per_constraints_t *per_constraints; /* PER compiled constraints */
|
||||
int (*default_value)(int setval, void **sptr); /* DEFAULT <value> */
|
||||
char *name; /* ASN.1 identifier of the element */
|
||||
const char *name; /* ASN.1 identifier of the element */
|
||||
} asn_TYPE_member_t;
|
||||
|
||||
/*
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* Copyright (c) 2004, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
||||
* Redistribution and modifications are permitted subject to BSD license.
|
||||
*/
|
||||
#ifndef _ASN1_CONSTRAINTS_VALIDATOR_H_
|
||||
#define _ASN1_CONSTRAINTS_VALIDATOR_H_
|
||||
#ifndef ASN1_CONSTRAINTS_VALIDATOR_H
|
||||
#define ASN1_CONSTRAINTS_VALIDATOR_H
|
||||
|
||||
#include <asn_system.h> /* Platform-dependent types */
|
||||
|
||||
@@ -54,10 +54,10 @@ asn_constr_check_f asn_generic_unknown_constraint; /* Not fully supported */
|
||||
/*
|
||||
* Invoke the callback with a complete error message.
|
||||
*/
|
||||
#define _ASN_CTFAIL if(ctfailcb) ctfailcb
|
||||
#define ASN__CTFAIL if(ctfailcb) ctfailcb
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ASN1_CONSTRAINTS_VALIDATOR_H_ */
|
||||
#endif /* ASN1_CONSTRAINTS_VALIDATOR_H */
|
||||
|
||||
@@ -80,8 +80,8 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
|
||||
ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */
|
||||
asn_app_consume_bytes_f *cb,
|
||||
void *app_key) {
|
||||
ber_tlv_tag_t *tags; /* Copy of tags stream */
|
||||
int tags_count; /* Number of tags */
|
||||
const ber_tlv_tag_t *tags; /* Copy of tags stream */
|
||||
int tags_count; /* Number of tags */
|
||||
size_t overall_length;
|
||||
ssize_t *lens;
|
||||
int i;
|
||||
@@ -102,8 +102,9 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
|
||||
* and initialize it appropriately.
|
||||
*/
|
||||
int stag_offset;
|
||||
tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
|
||||
if(!tags) { /* Can fail on !x86 */
|
||||
ber_tlv_tag_t *tags_buf;
|
||||
tags_buf = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t));
|
||||
if(!tags_buf) { /* Can fail on !x86 */
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
@@ -111,10 +112,11 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
|
||||
+ 1 /* EXPLICIT or IMPLICIT tag is given */
|
||||
- ((tag_mode == -1) && sd->tags_count);
|
||||
/* Copy tags over */
|
||||
tags[0] = tag;
|
||||
tags_buf[0] = tag;
|
||||
stag_offset = -1 + ((tag_mode == -1) && sd->tags_count);
|
||||
for(i = 1; i < tags_count; i++)
|
||||
tags[i] = sd->tags[i + stag_offset];
|
||||
tags_buf[i] = sd->tags[i + stag_offset];
|
||||
tags = tags_buf;
|
||||
} else {
|
||||
tags = sd->tags;
|
||||
tags_count = sd->tags_count;
|
||||
@@ -144,8 +146,8 @@ der_write_tags(asn_TYPE_descriptor_t *sd,
|
||||
|
||||
if(!cb) return overall_length - struct_length;
|
||||
|
||||
ASN_DEBUG("Encoding %s TL sequence (%d elements)", sd->name,
|
||||
tags_count);
|
||||
ASN_DEBUG("%s %s TL sequence (%d elements)",
|
||||
cb?"Encoding":"Estimating", sd->name, tags_count);
|
||||
|
||||
/*
|
||||
* Encode the TL sequence for real.
|
||||
|
||||
@@ -45,7 +45,7 @@ uper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sp
|
||||
if(skip_bits < 0 || skip_bits > 7
|
||||
|| unused_bits < 0 || unused_bits > 7
|
||||
|| (unused_bits > 0 && !size))
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
|
||||
/*
|
||||
* Stack checker requires that the codec context
|
||||
@@ -59,7 +59,7 @@ uper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sp
|
||||
} else {
|
||||
/* If context is not given, be security-conscious anyway */
|
||||
memset(&s_codec_ctx, 0, sizeof(s_codec_ctx));
|
||||
s_codec_ctx.max_stack_size = _ASN_DEFAULT_STACK_MAX;
|
||||
s_codec_ctx.max_stack_size = ASN__DEFAULT_STACK_MAX;
|
||||
opt_codec_ctx = &s_codec_ctx;
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ uper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sp
|
||||
pd.nboff = skip_bits;
|
||||
pd.nbits = 8 * size - unused_bits; /* 8 is CHAR_BIT from <limits.h> */
|
||||
if(pd.nboff > pd.nbits)
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
|
||||
/*
|
||||
* Invoke type-specific decoder.
|
||||
*/
|
||||
if(!td->uper_decoder)
|
||||
_ASN_DECODE_FAILED; /* PER is not compiled in */
|
||||
ASN__DECODE_FAILED; /* PER is not compiled in */
|
||||
rval = td->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd);
|
||||
if(rval.code == RC_OK) {
|
||||
/* Return the number of consumed bits */
|
||||
|
||||
@@ -124,7 +124,7 @@ uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constrain
|
||||
* Invoke type-specific encoder.
|
||||
*/
|
||||
if(!td || !td->uper_encoder)
|
||||
_ASN_ENCODE_FAILED; /* PER is not compiled in */
|
||||
ASN__ENCODE_FAILED; /* PER is not compiled in */
|
||||
|
||||
po.buffer = po.tmpspace;
|
||||
po.nboff = 0;
|
||||
@@ -143,7 +143,7 @@ uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *constrain
|
||||
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
|
||||
|
||||
if(_uper_encode_flush_outp(&po))
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
return er;
|
||||
|
||||
@@ -65,7 +65,7 @@ uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
asn_per_data_t spd;
|
||||
size_t padding;
|
||||
|
||||
_ASN_STACK_OVERFLOW_CHECK(ctx);
|
||||
ASN__STACK_OVERFLOW_CHECK(ctx);
|
||||
|
||||
ASN_DEBUG("Getting open type %s...", td->name);
|
||||
|
||||
@@ -73,7 +73,7 @@ uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
chunk_bytes = uper_get_length(pd, -1, &repeat);
|
||||
if(chunk_bytes < 0) {
|
||||
FREEMEM(buf);
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
}
|
||||
if(bufLen + chunk_bytes > bufSize) {
|
||||
void *ptr;
|
||||
@@ -81,13 +81,13 @@ uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
ptr = REALLOC(buf, bufSize);
|
||||
if(!ptr) {
|
||||
FREEMEM(buf);
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
buf = ptr;
|
||||
}
|
||||
if(per_get_many_bits(pd, buf + bufLen, 0, chunk_bytes << 3)) {
|
||||
FREEMEM(buf);
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
}
|
||||
bufLen += chunk_bytes;
|
||||
} while(repeat);
|
||||
@@ -117,10 +117,10 @@ uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
FREEMEM(buf);
|
||||
if(padding >= 8) {
|
||||
ASN_DEBUG("Too large padding %d in open type", (int)padding);
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
} else {
|
||||
ASN_DEBUG("Non-zero padding");
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
} else {
|
||||
FREEMEM(buf);
|
||||
@@ -138,7 +138,7 @@ uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
asn_dec_rval_t rv;
|
||||
ssize_t padding;
|
||||
|
||||
_ASN_STACK_OVERFLOW_CHECK(ctx);
|
||||
ASN__STACK_OVERFLOW_CHECK(ctx);
|
||||
|
||||
ASN_DEBUG("Getting open type %s from %s", td->name,
|
||||
per_data_string(pd));
|
||||
@@ -190,13 +190,13 @@ uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
case -1:
|
||||
ASN_DEBUG("Padding skip failed");
|
||||
UPDRESTOREPD;
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
case 0: break;
|
||||
default:
|
||||
ASN_DEBUG("Non-blank padding (%d bits 0x%02x)",
|
||||
(int)padding, (int)pvalue);
|
||||
UPDRESTOREPD;
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
}
|
||||
if(pd->nboff != pd->nbits) {
|
||||
@@ -204,7 +204,7 @@ uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
per_data_string(pd), per_data_string(&arg.oldpd));
|
||||
if(1) {
|
||||
UPDRESTOREPD;
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
} else {
|
||||
arg.unclaimed += pd->nbits - pd->nboff;
|
||||
}
|
||||
@@ -219,14 +219,14 @@ uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td,
|
||||
switch(per_skip_bits(pd, arg.unclaimed)) {
|
||||
case -1:
|
||||
ASN_DEBUG("Claim of %d failed", (int)arg.unclaimed);
|
||||
_ASN_DECODE_STARVED;
|
||||
ASN__DECODE_STARVED;
|
||||
case 0:
|
||||
ASN_DEBUG("Got claim of %d", (int)arg.unclaimed);
|
||||
break;
|
||||
default:
|
||||
/* Padding must be blank */
|
||||
ASN_DEBUG("Non-blank unconsumed padding");
|
||||
_ASN_DECODE_FAILED;
|
||||
ASN__DECODE_FAILED;
|
||||
}
|
||||
arg.unclaimed = 0;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ per_data_string(asn_per_data_t *pd) {
|
||||
static char buf[2][32];
|
||||
static int n;
|
||||
n = (n+1) % 2;
|
||||
snprintf(buf[n], sizeof(buf),
|
||||
snprintf(buf[n], sizeof(buf[n]),
|
||||
"{m=%ld span %+ld[%d..%d] (%d)}",
|
||||
(long)pd->moved,
|
||||
(((long)pd->buffer) & 0xf),
|
||||
@@ -109,7 +109,7 @@ per_get_few_bits(asn_per_data_t *pd, int nbits) {
|
||||
(int)pd->moved,
|
||||
(((long)pd->buffer) & 0xf),
|
||||
(int)pd->nboff, (int)pd->nbits,
|
||||
pd->buffer[0],
|
||||
((pd->buffer != NULL)?pd->buffer[0]:0),
|
||||
(int)(pd->nbits - pd->nboff),
|
||||
(int)accum);
|
||||
|
||||
@@ -394,8 +394,8 @@ per_put_few_bits(asn_per_outp_t *po, uint32_t bits, int obits) {
|
||||
buf[2] = bits >> 8,
|
||||
buf[3] = bits;
|
||||
else {
|
||||
if(per_put_few_bits(po, bits >> (obits - 24), 24)) return -1;
|
||||
if(per_put_few_bits(po, bits, obits - 24)) return -1;
|
||||
per_put_few_bits(po, bits >> (obits - 24), 24);
|
||||
per_put_few_bits(po, bits, obits - 24);
|
||||
}
|
||||
|
||||
ASN_DEBUG("[PER out %u/%x => %02x buf+%ld]",
|
||||
|
||||
@@ -15,7 +15,7 @@ extern "C" {
|
||||
/*
|
||||
* Pre-computed PER constraints.
|
||||
*/
|
||||
typedef struct asn_per_constraint_s {
|
||||
typedef const struct asn_per_constraint_s {
|
||||
enum asn_per_constraint_flags {
|
||||
APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
|
||||
APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
|
||||
@@ -27,9 +27,9 @@ typedef struct asn_per_constraint_s {
|
||||
long lower_bound; /* "lb" value */
|
||||
long upper_bound; /* "ub" value */
|
||||
} asn_per_constraint_t;
|
||||
typedef struct asn_per_constraints_s {
|
||||
asn_per_constraint_t value;
|
||||
asn_per_constraint_t size;
|
||||
typedef const struct asn_per_constraints_s {
|
||||
struct asn_per_constraint_s value;
|
||||
struct asn_per_constraint_s size;
|
||||
int (*value2code)(unsigned int value);
|
||||
int (*code2value)(unsigned int code);
|
||||
} asn_per_constraints_t;
|
||||
|
||||
@@ -27,7 +27,7 @@ xer_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
||||
} else {
|
||||
/* If context is not given, be security-conscious anyway */
|
||||
memset(&s_codec_ctx, 0, sizeof(s_codec_ctx));
|
||||
s_codec_ctx.max_stack_size = _ASN_DEFAULT_STACK_MAX;
|
||||
s_codec_ctx.max_stack_size = ASN__DEFAULT_STACK_MAX;
|
||||
opt_codec_ctx = &s_codec_ctx;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ xer_next_token(int *stateContext, const void *buffer, size_t size, pxer_chunk_ty
|
||||
if(ret < 0) return -1;
|
||||
if(arg.callback_not_invoked) {
|
||||
assert(ret == 0); /* No data was consumed */
|
||||
*ch_type = PXER_WMORE;
|
||||
return 0; /* Try again with more data */
|
||||
} else {
|
||||
assert(arg.chunk_size);
|
||||
@@ -83,7 +84,9 @@ xer_next_token(int *stateContext, const void *buffer, size_t size, pxer_chunk_ty
|
||||
case PXML_TEXT:
|
||||
*ch_type = PXER_TEXT;
|
||||
break;
|
||||
case PXML_TAG: return 0; /* Want more */
|
||||
case PXML_TAG:
|
||||
*ch_type = PXER_WMORE;
|
||||
return 0; /* Want more */
|
||||
case PXML_TAG_END:
|
||||
*ch_type = PXER_TAG;
|
||||
break;
|
||||
@@ -231,12 +234,12 @@ xer_decode_general(asn_codec_ctx_t *opt_codec_ctx,
|
||||
*/
|
||||
ch_size = xer_next_token(&ctx->context, buf_ptr, size,
|
||||
&ch_type);
|
||||
switch(ch_size) {
|
||||
case -1: RETURN(RC_FAIL);
|
||||
case 0:
|
||||
RETURN(RC_WMORE);
|
||||
default:
|
||||
if(ch_size == -1) {
|
||||
RETURN(RC_FAIL);
|
||||
} else {
|
||||
switch(ch_type) {
|
||||
case PXER_WMORE:
|
||||
RETURN(RC_WMORE);
|
||||
case PXER_COMMENT: /* Got XML comment */
|
||||
ADVANCE(ch_size); /* Skip silently */
|
||||
continue;
|
||||
|
||||
@@ -60,11 +60,12 @@ asn_dec_rval_t xer_decode_general(asn_codec_ctx_t *opt_codec_ctx,
|
||||
* Fetch the next XER (XML) token from the stream.
|
||||
* The function returns the number of bytes occupied by the chunk type,
|
||||
* returned in the _ch_type. The _ch_type is only set (and valid) when
|
||||
* the return value is greater than 0.
|
||||
* the return value is >= 0.
|
||||
*/
|
||||
typedef enum pxer_chunk_type {
|
||||
PXER_TAG, /* Complete XER tag */
|
||||
PXER_TEXT, /* Plain text between XER tags */
|
||||
PXER_WMORE, /* Chunk type is not clear, more data expected. */
|
||||
PXER_TAG, /* Complete XER tag */
|
||||
PXER_TEXT, /* Plain text between XER tags */
|
||||
PXER_COMMENT /* A comment, may be part of */
|
||||
} pxer_chunk_type_e;
|
||||
ssize_t xer_next_token(int *stateContext,
|
||||
|
||||
@@ -23,18 +23,18 @@ xer_encode(asn_TYPE_descriptor_t *td, void *sptr,
|
||||
mname = td->xml_tag;
|
||||
mlen = strlen(mname);
|
||||
|
||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
ASN__CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||
|
||||
tmper = td->xer_encoder(td, sptr, 1, xer_flags, cb, app_key);
|
||||
if(tmper.encoded == -1) return tmper;
|
||||
|
||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">\n", xcan);
|
||||
ASN__CALLBACK3("</", 2, mname, mlen, ">\n", xcan);
|
||||
|
||||
er.encoded = 4 + xcan + (2 * mlen) + tmper.encoded;
|
||||
|
||||
_ASN_ENCODED_OK(er);
|
||||
ASN__ENCODED_OK(er);
|
||||
cb_failed:
|
||||
_ASN_ENCODE_FAILED;
|
||||
ASN__ENCODE_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,16 +22,7 @@ typedef enum {
|
||||
ST_COMMENT_CLO_RT /* "-->"[1] */
|
||||
} pstate_e;
|
||||
|
||||
static pxml_chunk_type_e final_chunk_type[] = {
|
||||
PXML_TEXT,
|
||||
PXML_TAG_END,
|
||||
PXML_COMMENT_END,
|
||||
PXML_TAG_END,
|
||||
PXML_COMMENT_END,
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
static const int
|
||||
_charclass[256] = {
|
||||
0,0,0,0,0,0,0,0, 0,1,1,0,1,1,0,0,
|
||||
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
|
||||
@@ -79,8 +70,11 @@ _charclass[256] = {
|
||||
#define TOKEN_CB(_type, _ns, _current_too) \
|
||||
TOKEN_CB_CALL(_type, _ns, _current_too, 0)
|
||||
|
||||
#define PXML_TAG_FINAL_CHUNK_TYPE PXML_TAG_END
|
||||
#define PXML_COMMENT_FINAL_CHUNK_TYPE PXML_COMMENT_END
|
||||
|
||||
#define TOKEN_CB_FINAL(_type, _ns, _current_too) \
|
||||
TOKEN_CB_CALL(final_chunk_type[_type], _ns, _current_too, 1)
|
||||
TOKEN_CB_CALL( _type ## _FINAL_CHUNK_TYPE , _ns, _current_too, 1)
|
||||
|
||||
/*
|
||||
* Parser itself
|
||||
|
||||
Reference in New Issue
Block a user