Commit 2eb11954 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Address build/clang-format warning

parent ff6ce4a4

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -29,6 +29,8 @@
#ifndef FILE_3GPP_24_501_H_SEEN
#define FILE_3GPP_24_501_H_SEEN
#include <netinet/in.h>
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -220,7 +220,7 @@ void xgpp_conv::sm_context_create_from_openapi(
"PDU Session ID %d", context_data.getPduSessionId());
pcr.set_pdu_session_id(context_data.getPduSessionId());
} else {
Logger::smf_app().warn("No PDU Session ID available");
Logger::smf_app().warn("No PDU Session ID available");
}
// AMF ID (ServingNFId/NfInstanceId)
......
......@@ -48,7 +48,7 @@ int decode_bstring(
*bstr = blk2bstr(buffer, pdulen);
return pdulen;
} else {
*bstr = NULL;
if (bstr) *bstr = NULL;
return TLV_BUFFER_TOO_SHORT;
}
}
......
......@@ -2475,6 +2475,7 @@ bstring bjoinblk(const struct bstrList* bl, const void* blk, int len) {
* NULL is returned, otherwise a bstring with the correct result is returned.
*/
bstring bjoin(const struct bstrList* bl, const_bstring sep) {
if (sep == NULL) return NULL;
if (sep != NULL && (sep->slen < 0 || sep->data == NULL)) return NULL;
return bjoinblk(bl, sep->data, sep->slen);
}
......
......@@ -269,7 +269,6 @@
pLMN.mnc_digit2 * 10 + pLMN.mnc_digit1; \
} while (0)
/*
* TS 36.413 v10.9.0 section 9.2.1.37:
* Macro eNB ID:
......
......@@ -55,7 +55,8 @@ class conv {
static void hexa_to_ascii(uint8_t* from, char* to, size_t length);
static int ascii_to_hex(uint8_t* dst, const char* h);
static struct in_addr fromString(const std::string addr4);
static bool plmnFromString(plmn_t& p, const std::string mcc, const std::string mnc);
static bool plmnFromString(
plmn_t& p, const std::string mcc, const std::string mnc);
static std::string toString(const struct in_addr& inaddr);
static std::string toString(const struct in6_addr& in6addr);
static std::string mccToString(
......
......@@ -83,9 +83,7 @@ unsigned char* mime_parser::format_string_as_hex(const std::string& str) {
unsigned char* data_hex = (uint8_t*) malloc(str_len / 2 + 1);
conv::ascii_to_hex(data_hex, (const char*) data);
Logger::smf_app().debug(
"Input string (%d bytes): %s ", str_len,
str.c_str());
Logger::smf_app().debug("Input string (%d bytes): %s ", str_len, str.c_str());
Logger::smf_app().debug("Data (formatted):");
#if DEBUG_IS_ON
for (int i = 0; i < str_len / 2; i++) printf(" %02x ", data_hex[i]);
......
......@@ -37,7 +37,7 @@ typedef struct {
uint8_t spare : 5;
uint8_t pdu_session_type_value : 3;
bstring pdu_address_information;
} __attribute__((__packed__)) PDUAddress;
} PDUAddress;
int encode_pdu_address(
PDUAddress pduaddress, uint8_t iei, uint8_t* buffer, uint32_t len);
......
......@@ -214,8 +214,7 @@ int decode_qos_rules(
qosrulesie->packetfilterlist.create_modifyandadd_modifyandreplace[j]
.packetfilteridentifier = bitstream & 0x0f;
uint8_t lenghtofpacketfiltercontents =
*(buffer + decoded) - 1;
uint8_t lenghtofpacketfiltercontents = *(buffer + decoded) - 1;
decoded++;
DECODE_U8(buffer + decoded, bitstream, decoded);
......@@ -306,8 +305,7 @@ int decode_qos_rules(
.packetfilterlist.create_modifyandadd_modifyandreplace[j]
.packetfilteridentifier = bitstream & 0x0f;
uint8_t lenghtofpacketfiltercontents =
*(buffer + decoded) - 1;
uint8_t lenghtofpacketfiltercontents = *(buffer + decoded) - 1;
decoded++;
DECODE_U8(buffer + decoded, bitstream, decoded);
......
......@@ -75,7 +75,7 @@
typedef struct {
uint8_t spare : 4;
uint8_t packetfilteridentifier : 4;
} __attribute__((__packed__)) ModifyAndDelete;
} ModifyAndDelete;
typedef struct {
uint8_t component_type;
......@@ -89,7 +89,7 @@ typedef struct {
uint8_t lenghtofpacketfiltercontents;
PacketFilterContents packetfiltercontents;
} __attribute__((__packed__)) Create_ModifyAndAdd_ModifyAndReplace;
} Create_ModifyAndAdd_ModifyAndReplace;
typedef struct {
uint8_t qosruleidentifer;
......@@ -106,7 +106,7 @@ typedef struct {
uint8_t spare : 1;
uint8_t segregation : 1;
uint8_t qosflowidentifer : 6;
} __attribute__((__packed__)) QOSRulesIE;
} QOSRulesIE;
typedef struct {
uint16_t lengthofqosrulesie;
......
......@@ -31,30 +31,17 @@ int encode_security_header_type(
SecurityHeaderType securityheadertype, uint8_t iei, uint8_t* buffer,
uint32_t len) {
uint32_t encoded = 0;
int encode_result;
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, SECURITY_HEADER_TYPE_MINIMUM_LENGTH, len);
if ((encode_result = encode_bstring(
securityheadertype, buffer + encoded, len - encoded)) < 0)
return encode_result;
else
encoded += encode_result;
ENCODE_U8(buffer + encoded, securityheadertype, encoded);
return encoded;
}
int decode_security_header_type(
SecurityHeaderType* securityheadertype, uint8_t iei, uint8_t* buffer,
uint32_t len) {
int decoded = 0;
uint8_t ielen = 0;
int decode_result;
if ((decode_result = decode_bstring(
securityheadertype, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
int decoded = 0;
DECODE_U8(buffer + decoded, *securityheadertype, decoded);
return decoded;
}
......@@ -64,7 +64,6 @@ int decode__5gs_mobile_identity(
uint32_t len) {
int decoded = 0;
uint8_t ielen = 0;
int decode_result;
if (iei > 0) {
CHECK_IEI_DECODER(iei, *buffer);
......@@ -76,11 +75,15 @@ int decode__5gs_mobile_identity(
ielen = (ielen << 8) + *(buffer + decoded);
decoded++;
CHECK_LENGTH_DECODER(len - decoded, ielen);
/*
int decode_result;
//TODO: to be updated
if ((decode_result = decode_bstring(
_5gsmobileidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
if ((decode_result = decode_bstring(
_5gsmobileidentity, ielen, buffer + decoded, len - decoded)) < 0)
return decode_result;
else
decoded += decode_result;
*/
return decoded;
}
......@@ -36,7 +36,7 @@ int encode__pdu_session_type(
buffer, _PDU_SESSION_TYPE_MINIMUM_LENGTH, len);
if (iei > 0) {
bitStream |= (iei & 0xf0) ;
bitStream |= (iei & 0xf0);
}
bitStream |= ((_pdusessiontype.pdu_session_type_value & 0x07) | 0x10);
......
This diff is collapsed.
......@@ -215,7 +215,6 @@ int encode_pdu_session_establishment_accept(
CHECK_PDU_POINTER_AND_LENGTH_ENCODER(
buffer, PDU_SESSION_ESTABLISHMENT_ACCEPT_MINIMUM_LENGTH, len);
if ((encoded_result = encode__pdu_session_type(
pdu_session_establishment_accept->_pdusessiontype, 0,
buffer + encoded, len - encoded)) < 0)
......
This diff is collapsed.
......@@ -5,17 +5,17 @@
#ifndef ASN_TYPE_ANY_H
#define ASN_TYPE_ANY_H
#include <OCTET_STRING.h> /* Implemented via OCTET STRING type */
#include <OCTET_STRING.h> /* Implemented via OCTET STRING type */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ANY {
uint8_t *buf; /* BER-encoded ANY contents */
int size; /* Size of the above buffer */
uint8_t* buf; /* BER-encoded ANY contents */
int size; /* Size of the above buffer */
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
} ANY_t;
extern asn_TYPE_descriptor_t asn_DEF_ANY;
......@@ -32,34 +32,34 @@ per_type_encoder_f ANY_encode_uper;
per_type_decoder_f ANY_decode_aper;
per_type_encoder_f ANY_encode_aper;
#define ANY_free OCTET_STRING_free
#define ANY_print OCTET_STRING_print
#define ANY_compare OCTET_STRING_compare
#define ANY_constraint asn_generic_no_constraint
#define ANY_decode_ber OCTET_STRING_decode_ber
#define ANY_encode_der OCTET_STRING_encode_der
#define ANY_decode_xer OCTET_STRING_decode_xer_hex
#define ANY_free OCTET_STRING_free
#define ANY_print OCTET_STRING_print
#define ANY_compare OCTET_STRING_compare
#define ANY_constraint asn_generic_no_constraint
#define ANY_decode_ber OCTET_STRING_decode_ber
#define ANY_encode_der OCTET_STRING_encode_der
#define ANY_decode_xer OCTET_STRING_decode_xer_hex
/******************************
* Handy conversion routines. *
******************************/
/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
int ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr);
ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
ANY_t *ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr);
int ANY_fromType(ANY_t*, asn_TYPE_descriptor_t* td, void* struct_ptr);
int ANY_fromType_aper(ANY_t* st, asn_TYPE_descriptor_t* td, void* sptr);
ANY_t* ANY_new_fromType(asn_TYPE_descriptor_t* td, void* struct_ptr);
ANY_t* ANY_new_fromType_aper(asn_TYPE_descriptor_t* td, void* sptr);
/* Convert the contents of the ANY type into the specified type. */
int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
int ANY_to_type_aper(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
int ANY_to_type(ANY_t*, asn_TYPE_descriptor_t* td, void** struct_ptr);
int ANY_to_type_aper(ANY_t*, asn_TYPE_descriptor_t* td, void** struct_ptr);
#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \
&asn_DEF_ANY, (buf), (size))
#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
#define ANY_new_fromBuf(buf, size) \
OCTET_STRING_new_fromBuf(&asn_DEF_ANY, (buf), (size))
#ifdef __cplusplus
}
#endif
#endif /* ASN_TYPE_ANY_H */
#endif /* ASN_TYPE_ANY_H */
This diff is collapsed.
......@@ -2,29 +2,29 @@
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _BIT_STRING_H_
#define _BIT_STRING_H_
#ifndef _BIT_STRING_H_
#define _BIT_STRING_H_
#include <OCTET_STRING.h> /* Some help from OCTET STRING */
#include <OCTET_STRING.h> /* Some help from OCTET STRING */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct BIT_STRING_s {
uint8_t *buf; /* BIT STRING body */
size_t size; /* Size of the above buffer */
uint8_t* buf; /* BIT STRING body */
size_t size; /* Size of the above buffer */
int bits_unused;/* Unused trailing bits in the last octet (0..7) */
int bits_unused; /* Unused trailing bits in the last octet (0..7) */
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
} BIT_STRING_t;
extern asn_TYPE_descriptor_t asn_DEF_BIT_STRING;
extern asn_TYPE_operation_t asn_OP_BIT_STRING;
extern asn_OCTET_STRING_specifics_t asn_SPC_BIT_STRING_specs;
asn_struct_print_f BIT_STRING_print; /* Human-readable output */
asn_struct_print_f BIT_STRING_print; /* Human-readable output */
asn_struct_compare_f BIT_STRING_compare;
asn_constr_check_f BIT_STRING_constraint;
xer_type_encoder_f BIT_STRING_encode_xer;
......@@ -32,17 +32,17 @@ oer_type_decoder_f BIT_STRING_decode_oer;
oer_type_encoder_f BIT_STRING_encode_oer;
per_type_decoder_f BIT_STRING_decode_uper;
per_type_encoder_f BIT_STRING_encode_uper;
asn_random_fill_f BIT_STRING_random_fill;
asn_random_fill_f BIT_STRING_random_fill;
#define BIT_STRING_free OCTET_STRING_free
#define BIT_STRING_decode_ber OCTET_STRING_decode_ber
#define BIT_STRING_encode_der OCTET_STRING_encode_der
#define BIT_STRING_decode_xer OCTET_STRING_decode_xer_binary
#define BIT_STRING_decode_aper OCTET_STRING_decode_aper
#define BIT_STRING_encode_aper OCTET_STRING_encode_aper
#define BIT_STRING_free OCTET_STRING_free
#define BIT_STRING_decode_ber OCTET_STRING_decode_ber
#define BIT_STRING_encode_der OCTET_STRING_encode_der
#define BIT_STRING_decode_xer OCTET_STRING_decode_xer_binary
#define BIT_STRING_decode_aper OCTET_STRING_decode_aper
#define BIT_STRING_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
#endif
#endif /* _BIT_STRING_H_ */
#endif /* _BIT_STRING_H_ */
......@@ -9,166 +9,164 @@
#include <BIT_STRING.h>
#include <errno.h>
asn_dec_rval_t
BIT_STRING_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints, void **sptr,
const void *ptr, size_t size) {
BIT_STRING_t *st = (BIT_STRING_t *)*sptr;
const asn_oer_constraints_t *cts =
constraints ? constraints : td->encoding_constraints.oer_constraints;
ssize_t ct_size = cts ? cts->size : -1;
asn_dec_rval_t rval = {RC_OK, 0};
size_t expected_length = 0;
(void)opt_codec_ctx;
if(!st) {
st = (BIT_STRING_t *)(*sptr = CALLOC(1, sizeof(*st)));
if(!st) ASN__DECODE_FAILED;
asn_dec_rval_t BIT_STRING_decode_oer(
const asn_codec_ctx_t* opt_codec_ctx, const asn_TYPE_descriptor_t* td,
const asn_oer_constraints_t* constraints, void** sptr, const void* ptr,
size_t size) {
BIT_STRING_t* st = (BIT_STRING_t*) *sptr;
const asn_oer_constraints_t* cts =
constraints ? constraints : td->encoding_constraints.oer_constraints;
ssize_t ct_size = cts ? cts->size : -1;
asn_dec_rval_t rval = {RC_OK, 0};
size_t expected_length = 0;
(void) opt_codec_ctx;
if (!st) {
st = (BIT_STRING_t*) (*sptr = CALLOC(1, sizeof(*st)));
if (!st) ASN__DECODE_FAILED;
}
if (ct_size >= 0) {
expected_length = (ct_size + 7) >> 3;
st->bits_unused = (8 - (ct_size & 7)) & 7;
} else {
/*
* X.696 (08/2015) #13.3.1
* Encode length determinant as _number of octets_, but only
* if upper bound is not equal to lower bound.
*/
ssize_t len_len = oer_fetch_length(ptr, size, &expected_length);
if (len_len > 0) {
ptr = (const char*) ptr + len_len;
size -= len_len;
} else if (len_len == 0) {
ASN__DECODE_STARVED;
} else if (len_len < 0) {
ASN__DECODE_FAILED;
}
if(ct_size >= 0) {
expected_length = (ct_size + 7) >> 3;
st->bits_unused = (8 - (ct_size & 7)) & 7;
} else {
/*
* X.696 (08/2015) #13.3.1
* Encode length determinant as _number of octets_, but only
* if upper bound is not equal to lower bound.
*/
ssize_t len_len = oer_fetch_length(ptr, size, &expected_length);
if(len_len > 0) {
ptr = (const char *)ptr + len_len;
size -= len_len;
} else if(len_len == 0) {
ASN__DECODE_STARVED;
} else if(len_len < 0) {
ASN__DECODE_FAILED;
}
if(expected_length < 1) {
ASN__DECODE_FAILED;
} else if(expected_length > size) {
ASN__DECODE_STARVED;
}
st->bits_unused = ((const uint8_t *)ptr)[0];
if(st->bits_unused & ~7) {
ASN_DEBUG("%s: unused bits outside of 0..7 range", td->name);
ASN__DECODE_FAILED;
}
ptr = (const char *)ptr + 1;
size--;
expected_length--;
rval.consumed = len_len + 1;
if (expected_length < 1) {
ASN__DECODE_FAILED;
} else if (expected_length > size) {
ASN__DECODE_STARVED;
}
if(size < expected_length) {
ASN__DECODE_STARVED;
st->bits_unused = ((const uint8_t*) ptr)[0];
if (st->bits_unused & ~7) {
ASN_DEBUG("%s: unused bits outside of 0..7 range", td->name);
ASN__DECODE_FAILED;
}
ptr = (const char*) ptr + 1;
size--;
expected_length--;
rval.consumed = len_len + 1;
}
if (size < expected_length) {
ASN__DECODE_STARVED;
} else {
uint8_t* buf = MALLOC(expected_length + 1);
if (buf == NULL) {
ASN__DECODE_FAILED;
} else {
uint8_t *buf = MALLOC(expected_length + 1);
if(buf == NULL) {
ASN__DECODE_FAILED;
} else {
memcpy(buf, ptr, expected_length);
buf[expected_length] = '\0';
}
FREEMEM(st->buf);
st->buf = buf;
st->size = expected_length;
if(expected_length > 0) {
buf[expected_length - 1] &= (0xff << st->bits_unused);
}
rval.consumed += expected_length;
return rval;
memcpy(buf, ptr, expected_length);
buf[expected_length] = '\0';
}
FREEMEM(st->buf);
st->buf = buf;
st->size = expected_length;
if (expected_length > 0) {
buf[expected_length - 1] &= (0xff << st->bits_unused);
}
rval.consumed += expected_length;
return rval;
}
}
/*
* Encode as Canonical OER.
*/
asn_enc_rval_t
BIT_STRING_encode_oer(const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints,
const void *sptr, asn_app_consume_bytes_f *cb,
void *app_key) {
const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
asn_enc_rval_t erval = {0, 0, 0};
const asn_oer_constraints_t *cts =
constraints ? constraints : td->encoding_constraints.oer_constraints;
ssize_t ct_size = cts ? cts->size : -1;
size_t trailing_zeros = 0;
int fix_last_byte = 0;
if(!st) ASN__ENCODE_FAILED;
if(st->bits_unused & ~7) {
ASN_DEBUG("BIT STRING unused bits %d out of 0..7 range",
st->bits_unused);
ASN__ENCODE_FAILED;
}
if(st->bits_unused && !(st->size && st->buf)) {
ASN_DEBUG("BIT STRING %s size 0 can't support unused bits %d", td->name,
st->bits_unused);
ASN__ENCODE_FAILED;
asn_enc_rval_t BIT_STRING_encode_oer(
const asn_TYPE_descriptor_t* td, const asn_oer_constraints_t* constraints,
const void* sptr, asn_app_consume_bytes_f* cb, void* app_key) {
const BIT_STRING_t* st = (const BIT_STRING_t*) sptr;
asn_enc_rval_t erval = {0, 0, 0};
const asn_oer_constraints_t* cts =
constraints ? constraints : td->encoding_constraints.oer_constraints;
ssize_t ct_size = cts ? cts->size : -1;
size_t trailing_zeros = 0;
int fix_last_byte = 0;
if (!st) ASN__ENCODE_FAILED;
if (st->bits_unused & ~7) {
ASN_DEBUG("BIT STRING unused bits %d out of 0..7 range", st->bits_unused);
ASN__ENCODE_FAILED;
}
if (st->bits_unused && !(st->size && st->buf)) {
ASN_DEBUG(
"BIT STRING %s size 0 can't support unused bits %d", td->name,
st->bits_unused);
ASN__ENCODE_FAILED;
}
if (ct_size >= 0) {
size_t ct_bytes = (ct_size + 7) >> 3;
if (st->size > ct_bytes) {
ASN_DEBUG(
"More bits in BIT STRING %s (%" ASN_PRI_SSIZE
") than constrained %" ASN_PRI_SSIZE "",
td->name, 8 * st->size - st->bits_unused, ct_size);
ASN__ENCODE_FAILED;
}
if(ct_size >= 0) {
size_t ct_bytes = (ct_size + 7) >> 3;
if(st->size > ct_bytes) {
ASN_DEBUG("More bits in BIT STRING %s (%" ASN_PRI_SSIZE ") than constrained %" ASN_PRI_SSIZE "",
td->name, 8 * st->size - st->bits_unused, ct_size);
ASN__ENCODE_FAILED;
}
trailing_zeros = ct_bytes - st->size; /* Allow larger constraint */
} else {
uint8_t ub = st->bits_unused & 7;
ssize_t len_len = oer_serialize_length(1 + st->size, cb, app_key);
if(len_len < 0) ASN__ENCODE_FAILED;
if(cb(&ub, 1, app_key) < 0) {
ASN__ENCODE_FAILED;
}
erval.encoded += len_len + 1;
trailing_zeros = ct_bytes - st->size; /* Allow larger constraint */
} else {
uint8_t ub = st->bits_unused & 7;
ssize_t len_len = oer_serialize_length(1 + st->size, cb, app_key);
if (len_len < 0) ASN__ENCODE_FAILED;
if (cb(&ub, 1, app_key) < 0) {
ASN__ENCODE_FAILED;
}
erval.encoded += len_len + 1;
}
if(st->bits_unused) {
if(st->buf[st->size - 1] & (0xff << st->bits_unused)) {
fix_last_byte = 1;
}
if (st->bits_unused) {
if (st->buf[st->size - 1] & (0xff << st->bits_unused)) {
fix_last_byte = 1;
}
}
if(cb(st->buf, st->size - fix_last_byte, app_key) < 0) {
ASN__ENCODE_FAILED;
}
if (cb(st->buf, st->size - fix_last_byte, app_key) < 0) {
ASN__ENCODE_FAILED;
}
if(fix_last_byte) {
uint8_t b = st->buf[st->size - 1] & (0xff << st->bits_unused);
if(cb(&b, 1, app_key) < 0) {
ASN__ENCODE_FAILED;
}
if (fix_last_byte) {
uint8_t b = st->buf[st->size - 1] & (0xff << st->bits_unused);
if (cb(&b, 1, app_key) < 0) {
ASN__ENCODE_FAILED;
}
erval.encoded += st->size;
if(trailing_zeros) {
static uint8_t zeros[16];
while(trailing_zeros > 0) {
int ret;
if(trailing_zeros < sizeof(zeros)) {
ret = cb(zeros, trailing_zeros, app_key);
erval.encoded += trailing_zeros;
} else {
ret = cb(zeros, sizeof(zeros), app_key);
erval.encoded += sizeof(zeros);
}
if(ret < 0) ASN__ENCODE_FAILED;
}
}
erval.encoded += st->size;
if (trailing_zeros) {
static uint8_t zeros[16];
while (trailing_zeros > 0) {
int ret;
if (trailing_zeros < sizeof(zeros)) {
ret = cb(zeros, trailing_zeros, app_key);
erval.encoded += trailing_zeros;
} else {
ret = cb(zeros, sizeof(zeros), app_key);
erval.encoded += sizeof(zeros);
}
if (ret < 0) ASN__ENCODE_FAILED;
}
}
return erval;
return erval;
}
#endif /* ASN_DISABLE_OER_SUPPORT */
#endif /* ASN_DISABLE_OER_SUPPORT */
This diff is collapsed.
......@@ -2,8 +2,8 @@
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _INTEGER_H_
#define _INTEGER_H_
#ifndef _INTEGER_H_
#define _INTEGER_H_
#include <asn_application.h>
#include <asn_codecs_prim.h>
......@@ -19,25 +19,25 @@ extern asn_TYPE_operation_t asn_OP_INTEGER;
/* Map with <tag> to integer value association */
typedef struct asn_INTEGER_enum_map_s {
long nat_value; /* associated native integer value */
size_t enum_len; /* strlen("tag") */
const char *enum_name; /* "tag" */
long nat_value; /* associated native integer value */
size_t enum_len; /* strlen("tag") */
const char* enum_name; /* "tag" */
} asn_INTEGER_enum_map_t;
/* This type describes an enumeration for INTEGER and ENUMERATED types */
typedef 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 */
int field_width; /* Size of native integer */
int field_unsigned; /* Signed=0, unsigned=1 */
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 */
int field_width; /* Size of native integer */
int field_unsigned; /* Signed=0, unsigned=1 */
} asn_INTEGER_specifics_t;
#define INTEGER_free ASN__PRIMITIVE_TYPE_free
#define INTEGER_decode_ber ber_decode_primitive
#define INTEGER_constraint asn_generic_no_constraint
#define INTEGER_free ASN__PRIMITIVE_TYPE_free
#define INTEGER_decode_ber ber_decode_primitive
#define INTEGER_constraint asn_generic_no_constraint
asn_struct_print_f INTEGER_print;
asn_struct_compare_f INTEGER_compare;
der_type_encoder_f INTEGER_encode_der;
......@@ -49,7 +49,7 @@ per_type_decoder_f INTEGER_decode_uper;
per_type_encoder_f INTEGER_encode_uper;
per_type_decoder_f INTEGER_decode_aper;
per_type_encoder_f INTEGER_encode_aper;
asn_random_fill_f INTEGER_random_fill;
asn_random_fill_f INTEGER_random_fill;
/***********************************
* Some handy conversion routines. *
......@@ -63,46 +63,47 @@ asn_random_fill_f INTEGER_random_fill;
* -1/ERANGE: Value encoded is out of range for long representation
* -1/ENOMEM: Memory allocation failed (in asn_*2INTEGER()).
*/
int asn_INTEGER2imax(const INTEGER_t *i, intmax_t *l);
int asn_INTEGER2umax(const INTEGER_t *i, uintmax_t *l);
int asn_imax2INTEGER(INTEGER_t *i, intmax_t l);
int asn_umax2INTEGER(INTEGER_t *i, uintmax_t l);
int asn_INTEGER2imax(const INTEGER_t* i, intmax_t* l);
int asn_INTEGER2umax(const INTEGER_t* i, uintmax_t* l);
int asn_imax2INTEGER(INTEGER_t* i, intmax_t l);
int asn_umax2INTEGER(INTEGER_t* i, uintmax_t l);
/*
* Size-specific conversion helpers.
*/
int asn_INTEGER2long(const INTEGER_t *i, long *l);
int asn_INTEGER2ulong(const INTEGER_t *i, unsigned long *l);
int asn_long2INTEGER(INTEGER_t *i, long l);
int asn_ulong2INTEGER(INTEGER_t *i, unsigned long l);
int asn_int642INTEGER(INTEGER_t *i, int64_t l);
int asn_uint642INTEGER(INTEGER_t *i, uint64_t l);
int asn_INTEGER2long(const INTEGER_t* i, long* l);
int asn_INTEGER2ulong(const INTEGER_t* i, unsigned long* l);
int asn_long2INTEGER(INTEGER_t* i, long l);
int asn_ulong2INTEGER(INTEGER_t* i, unsigned long l);
int asn_int642INTEGER(INTEGER_t* i, int64_t l);
int asn_uint642INTEGER(INTEGER_t* i, uint64_t l);
/* A version of strtol/strtoimax(3) with nicer error reporting. */
enum asn_strtox_result_e {
ASN_STRTOX_ERROR_RANGE = -3, /* Input outside of supported numeric range */
ASN_STRTOX_ERROR_INVAL = -2, /* Invalid data encountered (e.g., "+-") */
ASN_STRTOX_EXPECT_MORE = -1, /* More data expected (e.g. "+") */
ASN_STRTOX_OK = 0, /* Conversion succeded, number ends at (*end) */
ASN_STRTOX_EXTRA_DATA = 1 /* Conversion succeded, but the string has extra stuff */
ASN_STRTOX_ERROR_RANGE = -3, /* Input outside of supported numeric range */
ASN_STRTOX_ERROR_INVAL = -2, /* Invalid data encountered (e.g., "+-") */
ASN_STRTOX_EXPECT_MORE = -1, /* More data expected (e.g. "+") */
ASN_STRTOX_OK = 0, /* Conversion succeded, number ends at (*end) */
ASN_STRTOX_EXTRA_DATA =
1 /* Conversion succeded, but the string has extra stuff */
};
enum asn_strtox_result_e asn_strtol_lim(const char *str, const char **end,
long *l);
enum asn_strtox_result_e asn_strtoul_lim(const char *str, const char **end,
unsigned long *l);
enum asn_strtox_result_e asn_strtoimax_lim(const char *str, const char **end,
intmax_t *l);
enum asn_strtox_result_e asn_strtoumax_lim(const char *str, const char **end,
uintmax_t *l);
enum asn_strtox_result_e asn_strtol_lim(
const char* str, const char** end, long* l);
enum asn_strtox_result_e asn_strtoul_lim(
const char* str, const char** end, unsigned long* l);
enum asn_strtox_result_e asn_strtoimax_lim(
const char* str, const char** end, intmax_t* l);
enum asn_strtox_result_e asn_strtoumax_lim(
const char* str, const char** end, uintmax_t* l);
/*
* Convert the integer value into the corresponding enumeration map entry.
*/
const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(
const asn_INTEGER_specifics_t *specs, long value);
const asn_INTEGER_enum_map_t* INTEGER_map_value2enum(
const asn_INTEGER_specifics_t* specs, long value);
#ifdef __cplusplus
}
#endif
#endif /* _INTEGER_H_ */
#endif /* _INTEGER_H_ */
......@@ -9,171 +9,169 @@
#include <INTEGER.h>
#include <errno.h>
asn_dec_rval_t
INTEGER_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints, void **sptr,
const void *ptr, size_t size) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;
asn_dec_rval_t rval = {RC_OK, 0};
INTEGER_t *st = (INTEGER_t *)*sptr;
struct asn_oer_constraint_number_s ct = {0, 0};
size_t req_bytes;
(void)opt_codec_ctx;
(void)specs;
if(!st) {
st = (INTEGER_t *)(*sptr = CALLOC(1, sizeof(*st)));
if(!st) ASN__DECODE_FAILED;
asn_dec_rval_t INTEGER_decode_oer(
const asn_codec_ctx_t* opt_codec_ctx, const asn_TYPE_descriptor_t* td,
const asn_oer_constraints_t* constraints, void** sptr, const void* ptr,
size_t size) {
const asn_INTEGER_specifics_t* specs =
(const asn_INTEGER_specifics_t*) td->specifics;
asn_dec_rval_t rval = {RC_OK, 0};
INTEGER_t* st = (INTEGER_t*) *sptr;
struct asn_oer_constraint_number_s ct = {0, 0};
size_t req_bytes;
(void) opt_codec_ctx;
(void) specs;
if (!st) {
st = (INTEGER_t*) (*sptr = CALLOC(1, sizeof(*st)));
if (!st) ASN__DECODE_FAILED;
}
FREEMEM(st->buf);
st->buf = 0;
st->size = 0;
if (!constraints) constraints = td->encoding_constraints.oer_constraints;
if (constraints) ct = constraints->value;
if (ct.width) {
req_bytes = ct.width;
} else {
/* No lower bound and no upper bound, effectively */
ssize_t consumed = oer_fetch_length(ptr, size, &req_bytes);
if (consumed == 0) {
ASN__DECODE_STARVED;
} else if (consumed == -1) {
ASN__DECODE_FAILED;
}
FREEMEM(st->buf);
st->buf = 0;
st->size = 0;
if(!constraints) constraints = td->encoding_constraints.oer_constraints;
if(constraints) ct = constraints->value;
if(ct.width) {
req_bytes = ct.width;
} else {
/* No lower bound and no upper bound, effectively */
ssize_t consumed = oer_fetch_length(ptr, size, &req_bytes);
if(consumed == 0) {
ASN__DECODE_STARVED;
} else if(consumed == -1) {
ASN__DECODE_FAILED;
}
rval.consumed += consumed;
ptr = (const char *)ptr + consumed;
size -= consumed;
rval.consumed += consumed;
ptr = (const char*) ptr + consumed;
size -= consumed;
}
if (req_bytes > size) {
ASN__DECODE_STARVED;
}
if (ct.positive) {
/* X.969 08/2015 10.2(a) */
unsigned msb; /* Most significant bit */
size_t useful_size;
/* Check most significant bit */
msb = *(const uint8_t*) ptr >> 7; /* yields 0 or 1 */
useful_size = msb + req_bytes;
st->buf = (uint8_t*) MALLOC(useful_size + 1);
if (!st->buf) {
ASN__DECODE_FAILED;
}
if(req_bytes > size) {
ASN__DECODE_STARVED;
/*
* Record a large unsigned in a way not to confuse it
* with signed value.
*/
st->buf[0] = '\0';
memcpy(st->buf + msb, ptr, req_bytes);
st->buf[useful_size] = '\0'; /* Just in case, 0-terminate */
st->size = useful_size;
rval.consumed += req_bytes;
return rval;
} else {
/* X.969 08/2015 10.2(b) */
st->buf = (uint8_t*) MALLOC(req_bytes + 1);
if (!st->buf) {
ASN__DECODE_FAILED;
}
if(ct.positive) {
/* X.969 08/2015 10.2(a) */
unsigned msb; /* Most significant bit */
size_t useful_size;
/* Check most significant bit */
msb = *(const uint8_t *)ptr >> 7; /* yields 0 or 1 */
useful_size = msb + req_bytes;
st->buf = (uint8_t *)MALLOC(useful_size + 1);
if(!st->buf) {
ASN__DECODE_FAILED;
}
/*
* Record a large unsigned in a way not to confuse it
* with signed value.
*/
st->buf[0] = '\0';
memcpy(st->buf + msb, ptr, req_bytes);
st->buf[useful_size] = '\0'; /* Just in case, 0-terminate */
st->size = useful_size;
rval.consumed += req_bytes;
return rval;
} else {
/* X.969 08/2015 10.2(b) */
st->buf = (uint8_t *)MALLOC(req_bytes + 1);
if(!st->buf) {
ASN__DECODE_FAILED;
}
memcpy(st->buf, ptr, req_bytes);
st->buf[req_bytes] = '\0'; /* Just in case, 0-terminate */
st->size = req_bytes;
rval.consumed += req_bytes;
return rval;
}
memcpy(st->buf, ptr, req_bytes);
st->buf[req_bytes] = '\0'; /* Just in case, 0-terminate */
st->size = req_bytes;
rval.consumed += req_bytes;
return rval;
}
}
/*
* Encode as Canonical OER.
*/
asn_enc_rval_t
INTEGER_encode_oer(const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints, const void *sptr,
asn_app_consume_bytes_f *cb, void *app_key) {
const INTEGER_t *st = sptr;
asn_enc_rval_t er;
struct asn_oer_constraint_number_s ct = {0, 0};
const uint8_t *buf;
const uint8_t *end;
size_t useful_bytes;
size_t req_bytes = 0;
int sign = 0;
if(!st || st->size == 0) ASN__ENCODE_FAILED;
if(!constraints) constraints = td->encoding_constraints.oer_constraints;
if(constraints) ct = constraints->value;
er.encoded = 0;
buf = st->buf;
end = buf + st->size;
sign = (buf && buf < end) ? buf[0] & 0x80 : 0;
/* Ignore 9 leading zeroes or ones */
if(ct.positive) {
if(sign) {
/* The value given is a signed value. Can't proceed. */
ASN__ENCODE_FAILED;
}
/* Remove leading zeros. */
for(; buf + 1 < end; buf++) {
if(buf[0] != 0x0) break;
}
} else {
for(; buf + 1 < end; buf++) {
if(buf[0] == 0x0 && (buf[1] & 0x80) == 0) {
continue;
} else if(buf[0] == 0xff && (buf[1] & 0x80) != 0) {
continue;
}
break;
}
asn_enc_rval_t INTEGER_encode_oer(
const asn_TYPE_descriptor_t* td, const asn_oer_constraints_t* constraints,
const void* sptr, asn_app_consume_bytes_f* cb, void* app_key) {
const INTEGER_t* st = sptr;
asn_enc_rval_t er;
struct asn_oer_constraint_number_s ct = {0, 0};
const uint8_t* buf;
const uint8_t* end;
size_t useful_bytes;
size_t req_bytes = 0;
int sign = 0;
if (!st || st->size == 0) ASN__ENCODE_FAILED;
if (!constraints) constraints = td->encoding_constraints.oer_constraints;
if (constraints) ct = constraints->value;
er.encoded = 0;
buf = st->buf;
end = buf + st->size;
sign = (buf && buf < end) ? buf[0] & 0x80 : 0;
/* Ignore 9 leading zeroes or ones */
if (ct.positive) {
if (sign) {
/* The value given is a signed value. Can't proceed. */
ASN__ENCODE_FAILED;
}
useful_bytes = end - buf;
if(ct.width) {
req_bytes = ct.width;
} else {
ssize_t r = oer_serialize_length(useful_bytes, cb, app_key);
if(r < 0) {
ASN__ENCODE_FAILED;
}
er.encoded += r;
req_bytes = useful_bytes;
/* Remove leading zeros. */
for (; buf + 1 < end; buf++) {
if (buf[0] != 0x0) break;
}
if(req_bytes < useful_bytes) {
ASN__ENCODE_FAILED;
} else {
for (; buf + 1 < end; buf++) {
if (buf[0] == 0x0 && (buf[1] & 0x80) == 0) {
continue;
} else if (buf[0] == 0xff && (buf[1] & 0x80) != 0) {
continue;
}
break;
}
}
useful_bytes = end - buf;
if (ct.width) {
req_bytes = ct.width;
} else {
ssize_t r = oer_serialize_length(useful_bytes, cb, app_key);
if (r < 0) {
ASN__ENCODE_FAILED;
}
er.encoded += r;
req_bytes = useful_bytes;
}
er.encoded += req_bytes;
if (req_bytes < useful_bytes) {
ASN__ENCODE_FAILED;
}
for(; req_bytes > useful_bytes; req_bytes--) {
if(cb(sign?"\xff":"\0", 1, app_key) < 0) {
ASN__ENCODE_FAILED;
}
}
er.encoded += req_bytes;
if(cb(buf, useful_bytes, app_key) < 0) {
ASN__ENCODE_FAILED;
for (; req_bytes > useful_bytes; req_bytes--) {
if (cb(sign ? "\xff" : "\0", 1, app_key) < 0) {
ASN__ENCODE_FAILED;
}
}
if (cb(buf, useful_bytes, app_key) < 0) {
ASN__ENCODE_FAILED;
}
ASN__ENCODED_OK(er);
ASN__ENCODED_OK(er);
}
#endif /* ASN_DISABLE_OER_SUPPORT */
#endif /* ASN_DISABLE_OER_SUPPORT */
This diff is collapsed.
......@@ -9,8 +9,8 @@
* will do).
* This type may be used when integer range is limited by subtype constraints.
*/
#ifndef _NativeEnumerated_H_
#define _NativeEnumerated_H_
#ifndef _NativeEnumerated_H_
#define _NativeEnumerated_H_
#include <NativeInteger.h>
......@@ -29,9 +29,9 @@ per_type_encoder_f NativeEnumerated_encode_uper;
per_type_decoder_f NativeEnumerated_decode_aper;
per_type_encoder_f NativeEnumerated_encode_aper;
#define NativeEnumerated_free NativeInteger_free
#define NativeEnumerated_print NativeInteger_print
#define NativeEnumerated_compare NativeInteger_compare
#define NativeEnumerated_free NativeInteger_free
#define NativeEnumerated_print NativeInteger_print
#define NativeEnumerated_compare NativeInteger_compare
#define NativeEnumerated_random_fill NativeInteger_random_fill
#define NativeEnumerated_constraint asn_generic_no_constraint
#define NativeEnumerated_decode_ber NativeInteger_decode_ber
......@@ -42,4 +42,4 @@ per_type_encoder_f NativeEnumerated_encode_aper;
}
#endif
#endif /* _NativeEnumerated_H_ */
#endif /* _NativeEnumerated_H_ */
......@@ -9,141 +9,138 @@
#include <NativeEnumerated.h>
#include <errno.h>
static long
asn__nativeenumerated_convert(const uint8_t *b, const uint8_t *end) {
unsigned long value;
/* Perform the sign initialization */
/* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
if((*b >> 7)) {
value = (unsigned long)(-1);
} else {
value = 0;
}
/* Conversion engine */
for(; b < end; b++) {
value = (value << 8) | *b;
}
return value;
static long asn__nativeenumerated_convert(
const uint8_t* b, const uint8_t* end) {
unsigned long value;
/* Perform the sign initialization */
/* Actually value = -(*b >> 7); gains nothing, yet unreadable! */
if ((*b >> 7)) {
value = (unsigned long) (-1);
} else {
value = 0;
}
/* Conversion engine */
for (; b < end; b++) {
value = (value << 8) | *b;
}
return value;
}
asn_dec_rval_t
NativeEnumerated_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints,
void **nint_ptr, const void *ptr, size_t size) {
asn_dec_rval_t rval = {RC_OK, 0};
long *native = (long *)*nint_ptr;
const uint8_t *b = ptr;
(void)opt_codec_ctx;
(void)constraints;
if(size < 1) {
ASN__DECODE_STARVED;
asn_dec_rval_t NativeEnumerated_decode_oer(
const asn_codec_ctx_t* opt_codec_ctx, const asn_TYPE_descriptor_t* td,
const asn_oer_constraints_t* constraints, void** nint_ptr, const void* ptr,
size_t size) {
asn_dec_rval_t rval = {RC_OK, 0};
long* native = (long*) *nint_ptr;
const uint8_t* b = ptr;
(void) opt_codec_ctx;
(void) constraints;
if (size < 1) {
ASN__DECODE_STARVED;
}
if ((*b & 0x80) == 0) {
/*
* X.696 (08/2015) #11.2 Short form for Enumerated.
*/
if (!native) {
native = (long*) (*nint_ptr = CALLOC(1, sizeof(*native)));
if (!native) ASN__DECODE_FAILED;
}
if((*b & 0x80) == 0) {
/*
* X.696 (08/2015) #11.2 Short form for Enumerated.
*/
if(!native) {
native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native)));
if(!native) ASN__DECODE_FAILED;
}
*native = *b;
rval.consumed = 1;
} else {
/*
* X.696 (08/2015) #11.4 Long form for Enumerated.
*/
size_t length = *b & 0x7f;
const uint8_t *bend;
long value;
if(length < 1 || length > sizeof(*native)) {
ASN__DECODE_FAILED;
}
if((1 + length) > size) {
ASN__DECODE_STARVED;
}
b++;
bend = b + length;
value = asn__nativeenumerated_convert(b, bend);
if(value < 0) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;
if(specs && specs->field_unsigned) {
ASN__DECODE_FAILED;
}
}
*native = *b;
rval.consumed = 1;
} else {
/*
* X.696 (08/2015) #11.4 Long form for Enumerated.
*/
size_t length = *b & 0x7f;
const uint8_t* bend;
long value;
if (length < 1 || length > sizeof(*native)) {
ASN__DECODE_FAILED;
}
if ((1 + length) > size) {
ASN__DECODE_STARVED;
}
b++;
bend = b + length;
value = asn__nativeenumerated_convert(b, bend);
if (value < 0) {
const asn_INTEGER_specifics_t* specs =
(const asn_INTEGER_specifics_t*) td->specifics;
if (specs && specs->field_unsigned) {
ASN__DECODE_FAILED;
}
}
if(!native) {
native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native)));
if(!native) ASN__DECODE_FAILED;
}
if (!native) {
native = (long*) (*nint_ptr = CALLOC(1, sizeof(*native)));
if (!native) ASN__DECODE_FAILED;
}
*native = value;
*native = value;
rval.consumed = (1 + length);
}
rval.consumed = (1 + length);
}
return rval;
return rval;
}
/*
* Encode as Canonical OER.
*/
asn_enc_rval_t
NativeEnumerated_encode_oer(const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints,
const void *sptr, asn_app_consume_bytes_f *cb,
void *app_key) {
asn_enc_rval_t er;
long native;
(void)constraints;
if(!sptr) ASN__ENCODE_FAILED;
native = *(const long *)sptr;
if(native >= 0 && native <= 127) {
/* #11.2 Short form */
uint8_t b = native;
er.encoded = 1;
if(cb(&b, er.encoded, app_key) < 0) {
ASN__ENCODE_FAILED;
}
ASN__ENCODED_OK(er);
} else {
/* #11.2 Long form */
uint8_t buf[1 + sizeof(native)];
uint8_t *b = &buf[sizeof(native)]; /* Last addressable */
long final_pattern = -1 * (native < 0);
for(;;) {
*b-- = native;
native >>= 8;
if(native == final_pattern) {
if(final_pattern) {
if((b[1] & 0x80)) break;
} else {
if(!(b[1] & 0x80)) break;
}
}
}
*b = 0x80 | (&buf[sizeof(native)] - b);
er.encoded = 1 + (&buf[sizeof(native)] - b);
if(cb(b, er.encoded, app_key) < 0) {
ASN__ENCODE_FAILED;
asn_enc_rval_t NativeEnumerated_encode_oer(
const asn_TYPE_descriptor_t* td, const asn_oer_constraints_t* constraints,
const void* sptr, asn_app_consume_bytes_f* cb, void* app_key) {
asn_enc_rval_t er;
long native;
(void) constraints;
if (!sptr) ASN__ENCODE_FAILED;
native = *(const long*) sptr;
if (native >= 0 && native <= 127) {
/* #11.2 Short form */
uint8_t b = native;
er.encoded = 1;
if (cb(&b, er.encoded, app_key) < 0) {
ASN__ENCODE_FAILED;
}
ASN__ENCODED_OK(er);
} else {
/* #11.2 Long form */
uint8_t buf[1 + sizeof(native)];
uint8_t* b = &buf[sizeof(native)]; /* Last addressable */
long final_pattern = -1 * (native < 0);
for (;;) {
*b-- = native;
native >>= 8;
if (native == final_pattern) {
if (final_pattern) {
if ((b[1] & 0x80)) break;
} else {
if (!(b[1] & 0x80)) break;
}
ASN__ENCODED_OK(er);
}
}
*b = 0x80 | (&buf[sizeof(native)] - b);
er.encoded = 1 + (&buf[sizeof(native)] - b);
if (cb(b, er.encoded, app_key) < 0) {
ASN__ENCODE_FAILED;
}
ASN__ENCODED_OK(er);
}
}
#endif /* ASN_DISABLE_OER_SUPPORT */
#endif /* ASN_DISABLE_OER_SUPPORT */
This diff is collapsed.
......@@ -9,8 +9,8 @@
* will do).
* This type may be used when integer range is limited by subtype constraints.
*/
#ifndef _NativeInteger_H_
#define _NativeInteger_H_
#ifndef _NativeInteger_H_
#define _NativeInteger_H_
#include <asn_application.h>
#include <INTEGER.h>
......@@ -22,7 +22,7 @@ extern "C" {
extern asn_TYPE_descriptor_t asn_DEF_NativeInteger;
extern asn_TYPE_operation_t asn_OP_NativeInteger;
asn_struct_free_f NativeInteger_free;
asn_struct_free_f NativeInteger_free;
asn_struct_print_f NativeInteger_print;
asn_struct_compare_f NativeInteger_compare;
ber_type_decoder_f NativeInteger_decode_ber;
......@@ -35,12 +35,12 @@ per_type_decoder_f NativeInteger_decode_uper;
per_type_encoder_f NativeInteger_encode_uper;
per_type_decoder_f NativeInteger_decode_aper;
per_type_encoder_f NativeInteger_encode_aper;
asn_random_fill_f NativeInteger_random_fill;
asn_random_fill_f NativeInteger_random_fill;
#define NativeInteger_constraint asn_generic_no_constraint
#define NativeInteger_constraint asn_generic_no_constraint
#ifdef __cplusplus
}
#endif
#endif /* _NativeInteger_H_ */
#endif /* _NativeInteger_H_ */
......@@ -9,91 +9,88 @@
#include <NativeInteger.h>
#include <errno.h>
asn_dec_rval_t
NativeInteger_decode_oer(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints,
void **nint_ptr, const void *ptr, size_t size) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;
asn_dec_rval_t rval = {RC_OK, 0};
long *native = (long *)*nint_ptr;
INTEGER_t tmpint;
INTEGER_t *tmpintptr = &tmpint;
asn_dec_rval_t NativeInteger_decode_oer(
const asn_codec_ctx_t* opt_codec_ctx, const asn_TYPE_descriptor_t* td,
const asn_oer_constraints_t* constraints, void** nint_ptr, const void* ptr,
size_t size) {
const asn_INTEGER_specifics_t* specs =
(const asn_INTEGER_specifics_t*) td->specifics;
asn_dec_rval_t rval = {RC_OK, 0};
long* native = (long*) *nint_ptr;
INTEGER_t tmpint;
INTEGER_t* tmpintptr = &tmpint;
memset(&tmpint, 0, sizeof(tmpint));
memset(&tmpint, 0, sizeof(tmpint));
if(!native) {
native = (long *)(*nint_ptr = CALLOC(1, sizeof(*native)));
if(!native) ASN__DECODE_FAILED;
}
if (!native) {
native = (long*) (*nint_ptr = CALLOC(1, sizeof(*native)));
if (!native) ASN__DECODE_FAILED;
}
/*
* OPTIMIZATION: Encode directly rather than passing through INTEGER.
* Saves a memory allocation.
*/
rval = INTEGER_decode_oer(opt_codec_ctx, td, constraints,
(void **)&tmpintptr, ptr, size);
if(rval.code != RC_OK) {
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return rval;
}
/*
* OPTIMIZATION: Encode directly rather than passing through INTEGER.
* Saves a memory allocation.
*/
rval = INTEGER_decode_oer(
opt_codec_ctx, td, constraints, (void**) &tmpintptr, ptr, size);
if (rval.code != RC_OK) {
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return rval;
}
if(specs && specs->field_unsigned) {
unsigned long ul;
int ok = asn_INTEGER2ulong(&tmpint, &ul) == 0;
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
if(ok) {
*native = ul;
} else {
rval.code = RC_FAIL;
return rval;
}
if (specs && specs->field_unsigned) {
unsigned long ul;
int ok = asn_INTEGER2ulong(&tmpint, &ul) == 0;
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
if (ok) {
*native = ul;
} else {
rval.code = RC_FAIL;
return rval;
}
} else {
long l;
int ok = asn_INTEGER2long(&tmpint, &l) == 0;
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
if (ok) {
*native = l;
} else {
long l;
int ok = asn_INTEGER2long(&tmpint, &l) == 0;
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
if(ok) {
*native = l;
} else {
rval.code = RC_FAIL;
return rval;
}
rval.code = RC_FAIL;
return rval;
}
}
return rval;
return rval;
}
/*
* Encode as Canonical OER.
*/
asn_enc_rval_t
NativeInteger_encode_oer(const asn_TYPE_descriptor_t *td,
const asn_oer_constraints_t *constraints,
const void *sptr, asn_app_consume_bytes_f *cb,
void *app_key) {
const asn_INTEGER_specifics_t *specs =
(const asn_INTEGER_specifics_t *)td->specifics;
INTEGER_t tmpint;
long native;
asn_enc_rval_t NativeInteger_encode_oer(
const asn_TYPE_descriptor_t* td, const asn_oer_constraints_t* constraints,
const void* sptr, asn_app_consume_bytes_f* cb, void* app_key) {
const asn_INTEGER_specifics_t* specs =
(const asn_INTEGER_specifics_t*) td->specifics;
INTEGER_t tmpint;
long native;
if(!sptr) ASN__ENCODE_FAILED;
if (!sptr) ASN__ENCODE_FAILED;
native = *(const long *)sptr;
memset(&tmpint, 0, sizeof(tmpint));
native = *(const long*) sptr;
memset(&tmpint, 0, sizeof(tmpint));
ASN_DEBUG("Encoding %s %ld as NativeInteger", td ? td->name : "", native);
ASN_DEBUG("Encoding %s %ld as NativeInteger", td ? td->name : "", native);
if((specs && specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native)
: asn_long2INTEGER(&tmpint, native)) {
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
ASN__ENCODE_FAILED;
} else {
asn_enc_rval_t er =
INTEGER_encode_oer(td, constraints, &tmpint, cb, app_key);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return er;
}
if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native) :
asn_long2INTEGER(&tmpint, native)) {
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
ASN__ENCODE_FAILED;
} else {
asn_enc_rval_t er =
INTEGER_encode_oer(td, constraints, &tmpint, cb, app_key);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
return er;
}
}
#endif /* ASN_DISABLE_OER_SUPPORT */
#endif /* ASN_DISABLE_OER_SUPPORT */
This diff is collapsed.
......@@ -2,8 +2,8 @@
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _OBJECT_IDENTIFIER_H_
#define _OBJECT_IDENTIFIER_H_
#ifndef _OBJECT_IDENTIFIER_H_
#define _OBJECT_IDENTIFIER_H_
#include <asn_application.h>
#include <asn_codecs_prim.h>
......@@ -14,7 +14,7 @@ extern "C" {
#endif
typedef uint32_t asn_oid_arc_t;
#define ASN_OID_ARC_MAX (~((asn_oid_arc_t)0))
#define ASN_OID_ARC_MAX (~((asn_oid_arc_t) 0))
typedef ASN__PRIMITIVE_TYPE_t OBJECT_IDENTIFIER_t;
......@@ -26,18 +26,18 @@ asn_constr_check_f OBJECT_IDENTIFIER_constraint;
der_type_encoder_f OBJECT_IDENTIFIER_encode_der;
xer_type_decoder_f OBJECT_IDENTIFIER_decode_xer;
xer_type_encoder_f OBJECT_IDENTIFIER_encode_xer;
asn_random_fill_f OBJECT_IDENTIFIER_random_fill;
#define OBJECT_IDENTIFIER_free ASN__PRIMITIVE_TYPE_free
#define OBJECT_IDENTIFIER_compare OCTET_STRING_compare
#define OBJECT_IDENTIFIER_decode_ber ber_decode_primitive
#define OBJECT_IDENTIFIER_encode_der der_encode_primitive
#define OBJECT_IDENTIFIER_decode_oer oer_decode_primitive
#define OBJECT_IDENTIFIER_encode_oer oer_encode_primitive
#define OBJECT_IDENTIFIER_decode_uper OCTET_STRING_decode_uper
#define OBJECT_IDENTIFIER_encode_uper OCTET_STRING_encode_uper
#define OBJECT_IDENTIFIER_decode_aper OCTET_STRING_decode_aper
#define OBJECT_IDENTIFIER_encode_aper OCTET_STRING_encode_aper
asn_random_fill_f OBJECT_IDENTIFIER_random_fill;
#define OBJECT_IDENTIFIER_free ASN__PRIMITIVE_TYPE_free
#define OBJECT_IDENTIFIER_compare OCTET_STRING_compare
#define OBJECT_IDENTIFIER_decode_ber ber_decode_primitive
#define OBJECT_IDENTIFIER_encode_der der_encode_primitive
#define OBJECT_IDENTIFIER_decode_oer oer_decode_primitive
#define OBJECT_IDENTIFIER_encode_oer oer_encode_primitive
#define OBJECT_IDENTIFIER_decode_uper OCTET_STRING_decode_uper
#define OBJECT_IDENTIFIER_encode_uper OCTET_STRING_encode_uper
#define OBJECT_IDENTIFIER_decode_aper OCTET_STRING_decode_aper
#define OBJECT_IDENTIFIER_encode_aper OCTET_STRING_encode_aper
/**********************************
* Some handy conversion routines *
......@@ -51,9 +51,8 @@ asn_random_fill_f OBJECT_IDENTIFIER_random_fill;
* void print_arcs(OBJECT_IDENTIFIER_t *oid) {
* asn_oid_arc_t fixed_arcs[10]; // Try with fixed space first
* asn_oid_arc_t *arcs = fixed_arcs;
* size_t arc_slots = sizeof(fixed_arcs)/sizeof(fixed_arcs[0]); // 10
* ssize_t count; // Real number of arcs.
* int i;
* size_t arc_slots = sizeof(fixed_arcs)/sizeof(fixed_arcs[0]); //
* 10 ssize_t count; // Real number of arcs. int i;
*
* count = OBJECT_IDENTIFIER_get_arcs(oid, arcs, arc_slots);
* // If necessary, reallocate arcs array and try again.
......@@ -61,8 +60,8 @@ asn_random_fill_f OBJECT_IDENTIFIER_random_fill;
* arc_slots = count;
* arcs = malloc(sizeof(asn_oid_arc_t) * arc_slots);
* if(!arcs) return;
* count = OBJECT_IDENTIFIER_get_arcs(oid, arcs, arc_slots);
* assert(count == arc_slots);
* count = OBJECT_IDENTIFIER_get_arcs(oid, arcs,
* arc_slots); assert(count == arc_slots);
* }
*
* // Print the contents of the arcs array.
......@@ -81,8 +80,8 @@ asn_random_fill_f OBJECT_IDENTIFIER_random_fill;
* WARNING: The function always returns the actual number of arcs,
* even if there is no sufficient (arc_slots) provided.
*/
ssize_t OBJECT_IDENTIFIER_get_arcs(const OBJECT_IDENTIFIER_t *oid,
asn_oid_arc_t *arcs, size_t arc_slots);
ssize_t OBJECT_IDENTIFIER_get_arcs(
const OBJECT_IDENTIFIER_t* oid, asn_oid_arc_t* arcs, size_t arc_slots);
/*
* This functions initializes the OBJECT IDENTIFIER object with
......@@ -94,9 +93,8 @@ ssize_t OBJECT_IDENTIFIER_get_arcs(const OBJECT_IDENTIFIER_t *oid,
* -1/ENOMEM: Memory allocation failed
* 0: The object was initialized with new arcs.
*/
int OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *oid,
const asn_oid_arc_t *arcs, size_t arcs_count);
int OBJECT_IDENTIFIER_set_arcs(
OBJECT_IDENTIFIER_t* oid, const asn_oid_arc_t* arcs, size_t arcs_count);
/*
* Parse the OBJECT IDENTIFIER textual representation ("1.3.6.1.4.1.9363").
......@@ -107,22 +105,21 @@ int OBJECT_IDENTIFIER_set_arcs(OBJECT_IDENTIFIER_t *oid,
*
* If (oid_txt_length == -1), the strlen() will be invoked to determine the
* size of the (oid_text) string.
*
*
* After return, the optional (opt_oid_text_end) is set to the character after
* the last parsed one. (opt_oid_text_end) is never less than (oid_text).
*
*
* RETURN VALUES:
* -1: Parse error.
* >= 0: Number of arcs contained in the OBJECT IDENTIFIER.
*
*
* WARNING: The function always returns the real number of arcs,
* even if there is no sufficient (arc_slots) provided.
* This is useful for (arc_slots) value estimation.
*/
ssize_t OBJECT_IDENTIFIER_parse_arcs(const char *oid_text,
ssize_t oid_txt_length,
asn_oid_arc_t *arcs, size_t arcs_count,
const char **opt_oid_text_end);
ssize_t OBJECT_IDENTIFIER_parse_arcs(
const char* oid_text, ssize_t oid_txt_length, asn_oid_arc_t* arcs,
size_t arcs_count, const char** opt_oid_text_end);
/*
* Internal functions.
......@@ -135,9 +132,8 @@ ssize_t OBJECT_IDENTIFIER_parse_arcs(const char *oid_text,
* -1: Failed to retrieve the value from the (arcbuf).
* >0: Number of bytes consumed from the (arcbuf), <= (arcbuf_len).
*/
ssize_t OBJECT_IDENTIFIER_get_single_arc(const uint8_t *arcbuf,
size_t arcbuf_len,
asn_oid_arc_t *ret_value);
ssize_t OBJECT_IDENTIFIER_get_single_arc(
const uint8_t* arcbuf, size_t arcbuf_len, asn_oid_arc_t* ret_value);
/*
* Write the unterminated arc value into the (arcbuf) which has the size at
......@@ -146,11 +142,11 @@ ssize_t OBJECT_IDENTIFIER_get_single_arc(const uint8_t *arcbuf,
* -1: (arcbuf_len) size is not sufficient to write the value.
* <n>: Number of bytes appended to the arcbuf (<= arcbuf_len).
*/
ssize_t OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf, size_t arcbuf_len,
asn_oid_arc_t arc_value);
ssize_t OBJECT_IDENTIFIER_set_single_arc(
uint8_t* arcbuf, size_t arcbuf_len, asn_oid_arc_t arc_value);
#ifdef __cplusplus
}
#endif
#endif /* _OBJECT_IDENTIFIER_H_ */
#endif /* _OBJECT_IDENTIFIER_H_ */
This diff is collapsed.
......@@ -2,8 +2,8 @@
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _OCTET_STRING_H_
#define _OCTET_STRING_H_
#ifndef _OCTET_STRING_H_
#define _OCTET_STRING_H_
#include <asn_application.h>
......@@ -12,10 +12,10 @@ extern "C" {
#endif
typedef struct OCTET_STRING {
uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */
size_t size; /* Size of the buffer */
uint8_t* buf; /* Buffer with consecutive OCTET_STRING bits */
size_t size; /* Size of the buffer */
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
} OCTET_STRING_t;
extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING;
......@@ -27,9 +27,9 @@ asn_struct_print_f OCTET_STRING_print_utf8;
asn_struct_compare_f OCTET_STRING_compare;
ber_type_decoder_f OCTET_STRING_decode_ber;
der_type_encoder_f OCTET_STRING_encode_der;
xer_type_decoder_f OCTET_STRING_decode_xer_hex; /* Hexadecimal */
xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */
xer_type_decoder_f OCTET_STRING_decode_xer_utf8; /* ASCII/UTF-8 */
xer_type_decoder_f OCTET_STRING_decode_xer_hex; /* Hexadecimal */
xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */
xer_type_decoder_f OCTET_STRING_decode_xer_utf8; /* ASCII/UTF-8 */
xer_type_encoder_f OCTET_STRING_encode_xer;
xer_type_encoder_f OCTET_STRING_encode_xer_utf8;
oer_type_decoder_f OCTET_STRING_decode_oer;
......@@ -38,10 +38,10 @@ per_type_decoder_f OCTET_STRING_decode_uper;
per_type_encoder_f OCTET_STRING_encode_uper;
per_type_decoder_f OCTET_STRING_decode_aper;
per_type_encoder_f OCTET_STRING_encode_aper;
asn_random_fill_f OCTET_STRING_random_fill;
asn_random_fill_f OCTET_STRING_random_fill;
#define OCTET_STRING_constraint asn_generic_no_constraint
#define OCTET_STRING_decode_xer OCTET_STRING_decode_xer_hex
#define OCTET_STRING_constraint asn_generic_no_constraint
#define OCTET_STRING_decode_xer OCTET_STRING_decode_xer_hex
/******************************
* Handy conversion routines. *
......@@ -56,47 +56,47 @@ asn_random_fill_f OCTET_STRING_random_fill;
* current contents of the OCTET STRING.
* Returns 0 if it was possible to perform operation, -1 otherwise.
*/
int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);
int OCTET_STRING_fromBuf(OCTET_STRING_t* s, const char* str, int size);
/* Handy conversion from the C string into the OCTET STRING. */
#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1)
#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1)
/*
* Allocate and fill the new OCTET STRING and return a pointer to the newly
* allocated object. NULL is permitted in str: the function will just allocate
* empty OCTET STRING.
*/
OCTET_STRING_t *OCTET_STRING_new_fromBuf(const asn_TYPE_descriptor_t *td,
const char *str, int size);
OCTET_STRING_t* OCTET_STRING_new_fromBuf(
const asn_TYPE_descriptor_t* td, const char* str, int size);
/****************************
* Internally useful stuff. *
****************************/
typedef struct asn_OCTET_STRING_specifics_s {
/*
* Target structure description.
*/
unsigned struct_size; /* Size of the structure */
unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */
enum asn_OS_Subvariant {
ASN_OSUBV_ANY, /* The open type (ANY) */
ASN_OSUBV_BIT, /* BIT STRING */
ASN_OSUBV_STR, /* String types, not {BMP,Universal}String */
ASN_OSUBV_U16, /* 16-bit character (BMPString) */
ASN_OSUBV_U32 /* 32-bit character (UniversalString) */
} subvariant;
/*
* Target structure description.
*/
unsigned struct_size; /* Size of the structure */
unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */
enum asn_OS_Subvariant {
ASN_OSUBV_ANY, /* The open type (ANY) */
ASN_OSUBV_BIT, /* BIT STRING */
ASN_OSUBV_STR, /* String types, not {BMP,Universal}String */
ASN_OSUBV_U16, /* 16-bit character (BMPString) */
ASN_OSUBV_U32 /* 32-bit character (UniversalString) */
} subvariant;
} asn_OCTET_STRING_specifics_t;
extern asn_OCTET_STRING_specifics_t asn_SPC_OCTET_STRING_specs;
size_t OCTET_STRING_random_length_constrained(
const asn_TYPE_descriptor_t *, const asn_encoding_constraints_t *,
const asn_TYPE_descriptor_t*, const asn_encoding_constraints_t*,
size_t max_length);
#ifdef __cplusplus
}
#endif
#endif /* _OCTET_STRING_H_ */
#endif /* _OCTET_STRING_H_ */
This diff is collapsed.
This diff is collapsed.
......@@ -30,48 +30,43 @@ extern asn_TYPE_operation_t asn_OP_OPEN_TYPE;
* Decode an Open Type which is potentially constraiend
* by the other members of the parent structure.
*/
asn_dec_rval_t OPEN_TYPE_ber_get(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *parent_type,
void *parent_structure,
const asn_TYPE_member_t *element,
const void *ptr, size_t size);
asn_dec_rval_t OPEN_TYPE_ber_get(
const asn_codec_ctx_t* opt_codec_ctx,
const asn_TYPE_descriptor_t* parent_type, void* parent_structure,
const asn_TYPE_member_t* element, const void* ptr, size_t size);
asn_dec_rval_t OPEN_TYPE_xer_get(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *parent_type,
void *parent_structure,
const asn_TYPE_member_t *element,
const void *ptr, size_t size);
asn_dec_rval_t OPEN_TYPE_xer_get(
const asn_codec_ctx_t* opt_codec_ctx,
const asn_TYPE_descriptor_t* parent_type, void* parent_structure,
const asn_TYPE_member_t* element, const void* ptr, size_t size);
asn_dec_rval_t OPEN_TYPE_oer_get(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *parent_type,
void *parent_structure,
asn_TYPE_member_t *element, const void *ptr,
size_t size);
asn_dec_rval_t OPEN_TYPE_oer_get(
const asn_codec_ctx_t* opt_codec_ctx,
const asn_TYPE_descriptor_t* parent_type, void* parent_structure,
asn_TYPE_member_t* element, const void* ptr, size_t size);
asn_dec_rval_t OPEN_TYPE_uper_get(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *parent_type,
void *parent_structure,
const asn_TYPE_member_t *element,
asn_per_data_t *pd);
asn_dec_rval_t OPEN_TYPE_uper_get(
const asn_codec_ctx_t* opt_codec_ctx,
const asn_TYPE_descriptor_t* parent_type, void* parent_structure,
const asn_TYPE_member_t* element, asn_per_data_t* pd);
asn_dec_rval_t OPEN_TYPE_aper_get(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *parent_type,
void *parent_structure,
const asn_TYPE_member_t *element,
asn_per_data_t *pd);
asn_dec_rval_t OPEN_TYPE_aper_get(
const asn_codec_ctx_t* opt_codec_ctx,
const asn_TYPE_descriptor_t* parent_type, void* parent_structure,
const asn_TYPE_member_t* element, asn_per_data_t* pd);
asn_enc_rval_t OPEN_TYPE_encode_uper(
const asn_TYPE_descriptor_t *type_descriptor,
const asn_per_constraints_t *constraints, const void *struct_ptr,
asn_per_outp_t *per_output);
const asn_TYPE_descriptor_t* type_descriptor,
const asn_per_constraints_t* constraints, const void* struct_ptr,
asn_per_outp_t* per_output);
asn_enc_rval_t OPEN_TYPE_encode_aper(
const asn_TYPE_descriptor_t *type_descriptor,
const asn_per_constraints_t *constraints, const void *struct_ptr,
asn_per_outp_t *per_output);
const asn_TYPE_descriptor_t* type_descriptor,
const asn_per_constraints_t* constraints, const void* struct_ptr,
asn_per_outp_t* per_output);
#ifdef __cplusplus
}
#endif
#endif /* ASN_OPEN_TYPE_H */
#endif /* ASN_OPEN_TYPE_H */
This diff is collapsed.
This diff is collapsed.
......@@ -2,8 +2,8 @@
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _PrintableString_H_
#define _PrintableString_H_
#ifndef _PrintableString_H_
#define _PrintableString_H_
#include <OCTET_STRING.h>
......@@ -11,27 +11,27 @@
extern "C" {
#endif
typedef OCTET_STRING_t PrintableString_t; /* Implemented via OCTET STRING */
typedef OCTET_STRING_t PrintableString_t; /* Implemented via OCTET STRING */
extern asn_TYPE_descriptor_t asn_DEF_PrintableString;
extern asn_TYPE_operation_t asn_OP_PrintableString;
asn_constr_check_f PrintableString_constraint;
#define PrintableString_free OCTET_STRING_free
#define PrintableString_print OCTET_STRING_print_utf8
#define PrintableString_compare OCTET_STRING_compare
#define PrintableString_decode_ber OCTET_STRING_decode_ber
#define PrintableString_encode_der OCTET_STRING_encode_der
#define PrintableString_decode_xer OCTET_STRING_decode_xer_utf8
#define PrintableString_encode_xer OCTET_STRING_encode_xer_utf8
#define PrintableString_decode_uper OCTET_STRING_decode_uper
#define PrintableString_encode_uper OCTET_STRING_encode_uper
#define PrintableString_decode_aper OCTET_STRING_decode_aper
#define PrintableString_encode_aper OCTET_STRING_encode_aper
#define PrintableString_free OCTET_STRING_free
#define PrintableString_print OCTET_STRING_print_utf8
#define PrintableString_compare OCTET_STRING_compare
#define PrintableString_decode_ber OCTET_STRING_decode_ber
#define PrintableString_encode_der OCTET_STRING_encode_der
#define PrintableString_decode_xer OCTET_STRING_decode_xer_utf8
#define PrintableString_encode_xer OCTET_STRING_encode_xer_utf8
#define PrintableString_decode_uper OCTET_STRING_decode_uper
#define PrintableString_encode_uper OCTET_STRING_encode_uper
#define PrintableString_decode_aper OCTET_STRING_decode_aper
#define PrintableString_encode_aper OCTET_STRING_encode_aper
#ifdef __cplusplus
}
#endif
#endif /* _PrintableString_H_ */
#endif /* _PrintableString_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2,8 +2,8 @@
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _BER_TLV_LENGTH_H_
#define _BER_TLV_LENGTH_H_
#ifndef _BER_TLV_LENGTH_H_
#define _BER_TLV_LENGTH_H_
#ifdef __cplusplus
extern "C" {
......@@ -21,8 +21,8 @@ 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, const void *bufptr, size_t size,
ber_tlv_len_t *len_r);
ssize_t ber_fetch_length(
int _is_constructed, const void* bufptr, size_t size, ber_tlv_len_t* len_r);
/*
* This function expects bufptr to be positioned over L in TLV.
......@@ -32,8 +32,8 @@ ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
* Standard {-1,0,>0} convention.
*/
ssize_t ber_skip_length(
const struct asn_codec_ctx_s *opt_codec_ctx, /* optional context */
int _is_constructed, const void *bufptr, size_t size);
const struct asn_codec_ctx_s* opt_codec_ctx, /* optional context */
int _is_constructed, const void* bufptr, size_t size);
/*
* This function serializes the length (L from TLV) in DER format.
......@@ -41,10 +41,10 @@ ssize_t ber_skip_length(
* it is a caller's responsibility to check the return value
* against the supplied buffer's size.
*/
size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size);
size_t der_tlv_length_serialize(ber_tlv_len_t len, void* bufptr, size_t size);
#ifdef __cplusplus
}
#endif
#endif /* _BER_TLV_LENGTH_H_ */
#endif /* _BER_TLV_LENGTH_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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