Commit 8c3b8540 authored by Lev Walkin's avatar Lev Walkin
Browse files

added const qualifier

parent fb617704
......@@ -79,7 +79,7 @@ BMPString__dump(const BMPString_t *st,
asn_dec_rval_t
BMPString_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, void *buf_ptr, size_t size) {
const char *opt_mname, const void *buf_ptr, size_t size) {
asn_dec_rval_t rc;
rc = OCTET_STRING_decode_xer_utf8(opt_codec_ctx, td, sptr, opt_mname,
......
......@@ -37,7 +37,7 @@ asn_TYPE_descriptor_t asn_DEF_BOOLEAN = {
asn_dec_rval_t
BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td,
void **bool_value, void *buf_ptr, size_t size,
void **bool_value, const void *buf_ptr, size_t size,
int tag_mode) {
BOOLEAN_t *st = (BOOLEAN_t *)*bool_value;
asn_dec_rval_t rval;
......@@ -66,7 +66,7 @@ BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
ASN_DEBUG("Boolean length is %d bytes", (int)length);
buf_ptr = ((char *)buf_ptr) + rval.consumed;
buf_ptr = ((const char *)buf_ptr) + rval.consumed;
size -= rval.consumed;
if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
......@@ -84,7 +84,7 @@ BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
* value is already TRUE.
* BOOLEAN is not supposed to contain meaningful data anyway.
*/
*st |= ((uint8_t *)buf_ptr)[lidx];
*st |= ((const uint8_t *)buf_ptr)[lidx];
}
rval.code = RC_OK;
......@@ -169,7 +169,7 @@ BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun
asn_dec_rval_t
BOOLEAN_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
return xer_decode_primitive(opt_codec_ctx, td,
sptr, sizeof(BOOLEAN_t), opt_mname, buf_ptr, size,
......
......@@ -409,7 +409,7 @@ INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chun
asn_dec_rval_t
INTEGER_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
return xer_decode_primitive(opt_codec_ctx, td,
sptr, sizeof(INTEGER_t), opt_mname,
......
......@@ -81,7 +81,7 @@ NULL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_b
asn_dec_rval_t
NULL_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
return xer_decode_primitive(opt_codec_ctx, td,
sptr, sizeof(NULL_t), opt_mname, buf_ptr, size,
......
......@@ -44,7 +44,7 @@ asn_TYPE_descriptor_t asn_DEF_NativeInteger = {
asn_dec_rval_t
NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td,
void **nint_ptr, void *buf_ptr, size_t size, int tag_mode) {
void **nint_ptr, const void *buf_ptr, size_t size, int tag_mode) {
long *native = (long *)*nint_ptr;
asn_dec_rval_t rval;
ber_tlv_len_t length;
......@@ -77,7 +77,7 @@ NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
/*
* Make sure we have this length.
*/
buf_ptr = ((char *)buf_ptr) + rval.consumed;
buf_ptr = ((const char *)buf_ptr) + rval.consumed;
size -= rval.consumed;
if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
......@@ -93,7 +93,7 @@ NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
{
INTEGER_t tmp;
long l;
tmp.buf = (uint8_t *)buf_ptr;
(const uint8_t *)tmp.buf = (const uint8_t *)buf_ptr;
tmp.size = length;
if(asn_INTEGER2long(&tmp, &l)) {
......@@ -169,7 +169,7 @@ NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr,
asn_dec_rval_t
NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
asn_dec_rval_t rval;
INTEGER_t *st = 0;
void *st_ptr = (void *)&st;
......
......@@ -45,7 +45,7 @@ asn_TYPE_descriptor_t asn_DEF_NativeReal = {
asn_dec_rval_t
NativeReal_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td,
void **dbl_ptr, void *buf_ptr, size_t size, int tag_mode) {
void **dbl_ptr, const void *buf_ptr, size_t size, int tag_mode) {
double *Dbl = (double *)*dbl_ptr;
asn_dec_rval_t rval;
ber_tlv_len_t length;
......@@ -79,7 +79,7 @@ NativeReal_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
/*
* Make sure we have this length.
*/
buf_ptr = ((char *)buf_ptr) + rval.consumed;
buf_ptr = ((const char *)buf_ptr) + rval.consumed;
size -= rval.consumed;
if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
......@@ -95,7 +95,7 @@ NativeReal_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
{
REAL_t tmp;
double d;
tmp.buf = (uint8_t *)buf_ptr;
(const uint8_t *)tmp.buf = (const uint8_t *)buf_ptr;
tmp.size = length;
if(asn_REAL2double(&tmp, &d)) {
......@@ -158,7 +158,7 @@ NativeReal_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
asn_dec_rval_t
NativeReal_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
asn_dec_rval_t rval;
REAL_t *st = 0;
double *Dbl = (double *)*sptr;
......
......@@ -310,7 +310,7 @@ OBJECT_IDENTIFIER__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const
asn_dec_rval_t
OBJECT_IDENTIFIER_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
return xer_decode_primitive(opt_codec_ctx, td,
sptr, sizeof(OBJECT_IDENTIFIER_t), opt_mname,
......
......@@ -54,7 +54,7 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = {
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = (num_bytes); \
buf_ptr = ((char *)buf_ptr) + num; \
buf_ptr = ((const char *)buf_ptr) + num;\
size -= num; \
consumed_myself += num; \
} while(0)
......@@ -164,7 +164,7 @@ _new_stack() {
asn_dec_rval_t
OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td,
void **os_structure, void *buf_ptr, size_t size, int tag_mode) {
void **os_structure, const void *buf_ptr, size_t size, int tag_mode) {
asn_OCTET_STRING_specifics_t *specs = td->specifics
? (asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_DEF_OCTET_STRING_specs;
......@@ -285,7 +285,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
tlv_constr = BER_TLV_CONSTRUCTED(buf_ptr);
ll = ber_fetch_length(tlv_constr,
(char *)buf_ptr + tl, Left - tl, &tlv_len);
(const char *)buf_ptr + tl,Left - tl,&tlv_len);
ASN_DEBUG("Got tag=%s, tc=%d, left=%ld, tl=%ld, len=%ld, ll=%ld",
ber_tlv_tag_string(tlv_tag), tlv_constr,
(long)Left, (long)tl, (long)tlv_len, (long)ll);
......@@ -295,8 +295,8 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
}
if(sel && sel->want_nulls
&& ((uint8_t *)buf_ptr)[0] == 0
&& ((uint8_t *)buf_ptr)[1] == 0)
&& ((const uint8_t *)buf_ptr)[0] == 0
&& ((const uint8_t *)buf_ptr)[1] == 0)
{
ASN_DEBUG("Eat EOC; wn=%d--", sel->want_nulls);
......@@ -426,8 +426,8 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
if(type_variant == _TT_BIT_STRING
&& sel->bits_chopped == 0) {
/* Put the unused-bits-octet away */
st->bits_unused = *(uint8_t *)buf_ptr;
APPEND(((char *)buf_ptr+1), (len - 1));
st->bits_unused = *(const uint8_t *)buf_ptr;
APPEND(((const char *)buf_ptr+1), (len - 1));
sel->bits_chopped = 1;
} else {
APPEND(buf_ptr, len);
......@@ -457,7 +457,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
if(size < (size_t)ctx->left) {
if(!size) RETURN(RC_WMORE);
if(type_variant == _TT_BIT_STRING && ctx->step == 0) {
st->bits_unused = *(uint8_t *)buf_ptr;
st->bits_unused = *(const uint8_t *)buf_ptr;
ctx->left--;
ADVANCE(1);
}
......@@ -469,7 +469,7 @@ OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
} else {
if(type_variant == _TT_BIT_STRING
&& ctx->step == 0 && ctx->left) {
st->bits_unused = *(uint8_t *)buf_ptr;
st->bits_unused = *(const uint8_t *)buf_ptr;
ctx->left--;
ADVANCE(1);
}
......@@ -1096,7 +1096,7 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
static asn_dec_rval_t
OCTET_STRING__decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, void *buf_ptr, size_t size,
const char *opt_mname, const void *buf_ptr, size_t size,
int (*opt_unexpected_tag_decoder)
(void *struct_ptr, const void *chunk_buf, size_t chunk_size),
ssize_t (*body_receiver)
......@@ -1156,7 +1156,7 @@ sta_failed:
asn_dec_rval_t
OCTET_STRING_decode_xer_hex(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, void *buf_ptr, size_t size) {
const char *opt_mname, const void *buf_ptr, size_t size) {
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
buf_ptr, size, 0, OCTET_STRING__convert_hexadecimal);
}
......@@ -1167,7 +1167,7 @@ OCTET_STRING_decode_xer_hex(asn_codec_ctx_t *opt_codec_ctx,
asn_dec_rval_t
OCTET_STRING_decode_xer_binary(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, void *buf_ptr, size_t size) {
const char *opt_mname, const void *buf_ptr, size_t size) {
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
buf_ptr, size, 0, OCTET_STRING__convert_binary);
}
......@@ -1178,7 +1178,7 @@ OCTET_STRING_decode_xer_binary(asn_codec_ctx_t *opt_codec_ctx,
asn_dec_rval_t
OCTET_STRING_decode_xer_utf8(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, void *buf_ptr, size_t size) {
const char *opt_mname, const void *buf_ptr, size_t size) {
return OCTET_STRING__decode_xer(opt_codec_ctx, td, sptr, opt_mname,
buf_ptr, size,
OCTET_STRING__handle_control_chars,
......
......@@ -325,7 +325,7 @@ REAL__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void *chunk_b
asn_dec_rval_t
REAL_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
return xer_decode_primitive(opt_codec_ctx, td,
sptr, sizeof(REAL_t), opt_mname,
......
......@@ -134,7 +134,7 @@ RELATIVE_OID__xer_body_decode(asn_TYPE_descriptor_t *td, void *sptr, const void
asn_dec_rval_t
RELATIVE_OID_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
return xer_decode_primitive(opt_codec_ctx, td,
sptr, sizeof(RELATIVE_OID_t), opt_mname,
......
......@@ -98,7 +98,7 @@ UniversalString__dump(const UniversalString_t *st,
asn_dec_rval_t
UniversalString_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, void **sptr,
const char *opt_mname, void *buf_ptr, size_t size) {
const char *opt_mname, const void *buf_ptr, size_t size) {
asn_dec_rval_t rc;
rc = OCTET_STRING_decode_xer_utf8(opt_codec_ctx, td, sptr, opt_mname,
......
......@@ -13,7 +13,7 @@
asn_dec_rval_t
ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td,
void **sptr, void *buf_ptr, size_t size, int tag_mode) {
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;
......@@ -47,7 +47,7 @@ ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
/*
* Make sure we have this length.
*/
buf_ptr = ((char *)buf_ptr) + rval.consumed;
buf_ptr = ((const char *)buf_ptr) + rval.consumed;
size -= rval.consumed;
if(length > (ber_tlv_len_t)size) {
rval.code = RC_WMORE;
......@@ -238,7 +238,7 @@ xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
void **sptr,
size_t struct_size,
const char *opt_mname,
void *buf_ptr, size_t size,
const void *buf_ptr, size_t size,
xer_primitive_body_decoder_f *prim_body_decoder
) {
const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
......
......@@ -38,7 +38,7 @@ asn_dec_rval_t xer_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *type_descriptor,
void **struct_ptr, size_t struct_size,
const char *opt_mname,
void *buf_ptr, size_t size,
const void *buf_ptr, size_t size,
xer_primitive_body_decoder_f *prim_body_decoder
);
......
......@@ -8,7 +8,7 @@
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
ptr = ((char *)ptr) + num; \
ptr = ((const char *)ptr) + num; \
size -= num; \
consumed_myself += num; \
} while(0)
......@@ -30,7 +30,7 @@
asn_dec_rval_t
ber_decode(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *type_descriptor,
void **struct_ptr, void *ptr, size_t size) {
void **struct_ptr, const void *ptr, size_t size) {
asn_codec_ctx_t s_codec_ctx;
/*
......@@ -58,7 +58,7 @@ ber_decode(asn_codec_ctx_t *opt_codec_ctx,
asn_dec_rval_t
ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *td, asn_struct_ctx_t *opt_ctx,
void *ptr, size_t size, int tag_mode, int last_tag_form,
const void *ptr, size_t size, int tag_mode, int last_tag_form,
ber_tlv_len_t *last_length, int *opt_tlv_form) {
ssize_t consumed_myself = 0;
ssize_t tag_len;
......@@ -128,7 +128,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
}
tlv_constr = BER_TLV_CONSTRUCTED(ptr);
len_len = ber_fetch_length(tlv_constr,
(char *)ptr + tag_len, size - tag_len, &tlv_len);
(const char *)ptr + tag_len, size - tag_len, &tlv_len);
switch(len_len) {
case -1: RETURN(RC_FAIL);
case 0: RETURN(RC_WMORE);
......@@ -208,7 +208,7 @@ ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
* Fetch and process L from TLV.
*/
len_len = ber_fetch_length(tlv_constr,
(char *)ptr + tag_len, size - tag_len, &tlv_len);
(const char *)ptr + tag_len, size - tag_len, &tlv_len);
ASN_DEBUG("Fetchinig len = %ld", (long)len_len);
switch(len_len) {
case -1: RETURN(RC_FAIL);
......
......@@ -17,7 +17,7 @@ struct asn_codec_ctx_s; /* Forward declaration */
asn_dec_rval_t ber_decode(struct asn_codec_ctx_s *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor,
void **struct_ptr, /* Pointer to a target structure's pointer */
void *buffer, /* Data to be decoded */
const void *buffer, /* Data to be decoded */
size_t size /* Size of that buffer */
);
......@@ -27,7 +27,7 @@ asn_dec_rval_t ber_decode(struct asn_codec_ctx_s *opt_codec_ctx,
typedef asn_dec_rval_t (ber_type_decoder_f)(
struct asn_codec_ctx_s *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor,
void **struct_ptr, void *buf_ptr, size_t size,
void **struct_ptr, const void *buf_ptr, size_t size,
int tag_mode);
/*******************************
......@@ -45,7 +45,7 @@ asn_dec_rval_t ber_check_tags(
struct asn_codec_ctx_s *opt_codec_ctx, /* optional context */
struct asn_TYPE_descriptor_s *type_dsc,
asn_struct_ctx_t *opt_ctx, /* saved decoding context */
void *ptr, size_t size,
const void *ptr, size_t size,
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
int last_tag_form, /* {-1,0:1}: any, primitive, constr */
ber_tlv_len_t *last_length,
......
......@@ -7,15 +7,15 @@
#include <ber_tlv_tag.h>
ssize_t
ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
ber_tlv_len_t *len_r) {
uint8_t *buf = (uint8_t *)bufptr;
const uint8_t *buf = (const uint8_t *)bufptr;
unsigned oct;
if(size == 0)
return 0; /* Want more */
oct = *(uint8_t *)buf;
oct = *(const uint8_t *)buf;
if((oct & 0x80) == 0) {
/*
* Short definite length.
......@@ -75,7 +75,7 @@ ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
ssize_t
ber_skip_length(asn_codec_ctx_t *opt_codec_ctx,
int _is_constructed, void *ptr, size_t size) {
int _is_constructed, const void *ptr, size_t size) {
ber_tlv_len_t vlen; /* Length of V in TLV */
ssize_t tl; /* Length of L in TLV */
ssize_t ll; /* Length of L in TLV */
......@@ -116,7 +116,7 @@ ber_skip_length(asn_codec_ctx_t *opt_codec_ctx,
* Indefinite length!
*/
ASN_DEBUG("Skipping indefinite length");
for(skip = ll, ptr = ((char *)ptr) + ll, size -= ll;;) {
for(skip = ll, ptr = ((const char *)ptr) + ll, size -= ll;;) {
ber_tlv_tag_t tag;
/* Fetch the tag */
......@@ -125,7 +125,7 @@ ber_skip_length(asn_codec_ctx_t *opt_codec_ctx,
ll = ber_skip_length(opt_codec_ctx,
BER_TLV_CONSTRUCTED(ptr),
((char *)ptr) + tl, size - tl);
((const char *)ptr) + tl, size - tl);
if(ll <= 0) return ll;
skip += tl + ll;
......@@ -135,11 +135,11 @@ ber_skip_length(asn_codec_ctx_t *opt_codec_ctx,
* two consecutive 0 octets.
* Check if it is true.
*/
if(((uint8_t *)ptr)[0] == 0
&& ((uint8_t *)ptr)[1] == 0)
if(((const uint8_t *)ptr)[0] == 0
&& ((const uint8_t *)ptr)[1] == 0)
return skip;
ptr = ((char *)ptr) + tl + ll;
ptr = ((const char *)ptr) + tl + ll;
size -= tl + ll;
}
......
......@@ -17,7 +17,7 @@ typedef ssize_t ber_tlv_len_t;
* On return with >0, len_r is constrained as -1..MAX, where -1 mean
* that the value is of indefinite length.
*/
ssize_t ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
ber_tlv_len_t *len_r);
/*
......@@ -30,7 +30,7 @@ ssize_t ber_fetch_length(int _is_constructed, void *bufptr, size_t size,
struct asn_codec_ctx_s; /* Forward declaration */
ssize_t ber_skip_length(
struct asn_codec_ctx_s *opt_codec_ctx, /* optional context */
int _is_constructed, void *bufptr, size_t size);
int _is_constructed, const void *bufptr, size_t size);
/*
* This function serializes the length (L from TLV) in DER format.
......
......@@ -7,7 +7,7 @@
#include <errno.h>
ssize_t
ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
ber_fetch_tag(const void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
ber_tlv_tag_t val;
ber_tlv_tag_t tclass;
size_t skipped;
......@@ -15,7 +15,7 @@ ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
if(size == 0)
return 0;
val = *(uint8_t *)ptr;
val = *(const uint8_t *)ptr;
tclass = (val >> 6);
if((val &= 0x1F) != 0x1F) {
/*
......@@ -30,9 +30,10 @@ ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
* Each octet contains 7 bits of useful information.
* The MSB is 0 if it is the last octet of the tag.
*/
for(val = 0, ptr = ((char *)ptr) + 1, skipped = 2;
skipped <= size; ptr = ((char *)ptr) + 1, skipped++) {
unsigned int oct = *(uint8_t *)ptr;
for(val = 0, ptr = ((const char *)ptr) + 1, skipped = 2;
skipped <= size;
ptr = ((const char *)ptr) + 1, skipped++) {
unsigned int oct = *(const uint8_t *)ptr;
if(oct & 0x80) {
val = (val << 7) | (oct & 0x7F);
/*
......
......@@ -18,7 +18,7 @@ typedef unsigned ber_tlv_tag_t; /* BER TAG from Tag-Length-Value */
*/
#define BER_TAG_CLASS(tag) ((tag) & 0x3)
#define BER_TAG_VALUE(tag) ((tag) >> 2)
#define BER_TLV_CONSTRUCTED(tagptr) (((*(uint8_t *)tagptr) & 0x20)?1:0)
#define BER_TLV_CONSTRUCTED(tagptr) (((*(const uint8_t *)tagptr)&0x20)?1:0)
#define BER_TAGS_EQUAL(tag1, tag2) ((tag1) == (tag2))
......@@ -39,7 +39,7 @@ char *ber_tlv_tag_string(ber_tlv_tag_t tag);
* -1: Fatal error deciphering tag.
* >0: Number of bytes used from bufptr. tag_r will contain the tag.
*/
ssize_t ber_fetch_tag(void *bufptr, size_t size, ber_tlv_tag_t *tag_r);
ssize_t ber_fetch_tag(const void *bufptr, size_t size, ber_tlv_tag_t *tag_r);
/*
* This function serializes the tag (T from TLV) in BER format.
......
......@@ -34,7 +34,7 @@
#undef ADVANCE
#define ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
ptr = ((char *)ptr) + num; \
ptr = ((const char *)ptr) + num;\
size -= num; \
if(ctx->left >= 0) \
ctx->left -= num; \
......@@ -99,7 +99,7 @@ _search4tag(const void *ap, const void *bp) {
*/
asn_dec_rval_t
CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **struct_ptr, void *ptr, size_t size, int tag_mode) {
void **struct_ptr, const void *ptr, size_t size, int tag_mode) {
/*
* Bring closer parts of structure description.
*/
......@@ -211,7 +211,8 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
skip = ber_skip_length(opt_codec_ctx,
BER_TLV_CONSTRUCTED(ptr),
(char *)ptr + tag_len, LEFT - tag_len);
(const char *)ptr + tag_len,
LEFT - tag_len);
switch(skip) {
case 0: if(!SIZE_VIOLATION) RETURN(RC_WMORE);
......@@ -320,13 +321,13 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
/*
* Expected <0><0>...
*/
if(((uint8_t *)ptr)[0] == 0) {
if(((const uint8_t *)ptr)[0] == 0) {
if(LEFT < 2) {
if(SIZE_VIOLATION)
RETURN(RC_FAIL);
else
RETURN(RC_WMORE);
} else if(((uint8_t *)ptr)[1] == 0) {
} else if(((const uint8_t *)ptr)[1] == 0) {
/*
* Correctly finished with <0><0>.
*/
......@@ -543,7 +544,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
#undef XER_ADVANCE
#define XER_ADVANCE(num_bytes) do { \
size_t num = num_bytes; \
buf_ptr = ((char *)buf_ptr) + num; \
buf_ptr = ((const char *)buf_ptr) + num;\
size -= num; \
consumed_myself += num; \
} while(0)
......@@ -554,7 +555,7 @@ CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_dec_rval_t
CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
void **struct_ptr, const char *opt_mname,
void *buf_ptr, size_t size) {
const void *buf_ptr, size_t size) {
/*
* Bring closer parts of structure description.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment