Commit 8ac149d3 authored by Mouse's avatar Mouse

Merge remote-tracking branch 'upstream/master' into vlm_master

parents dbd0ed09 00fa516f
Full list of copyright holders:
Rob Stradling <rob@sectigo.com>
Bartosz Marcinkiewicz <bma@megawatt.com.pl>
Bent Nicolaisen <BN@JAI.com>
Bi-Ruei, Chiu <biruei.chiu@gmail.com>
Damir Franusic <damir.franusic@gmail.com>
Daniele Varrazzo <daniele.varrazzo@gmail.com>
Dave Cridland <dave@cridland.net>
Denis Filatov (DanyaFilatov @ github)
......
......@@ -228,9 +228,12 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
INDENT(+1);
switch(etype) {
case ASN_CONSTR_SEQUENCE_OF:
OUT("/* Perform validation of the inner elements */\n");
OUT("return SEQUENCE_OF_constraint(td, sptr, ctfailcb, app_key);\n");
break;
case ASN_CONSTR_SET_OF:
OUT("/* Perform validation of the inner elements */\n");
OUT("return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);\n");
OUT("return SET_OF_constraint(td, sptr, ctfailcb, app_key);\n");
break;
default:
OUT("/* Constraint check succeeded */\n");
......
......@@ -5,7 +5,6 @@
#include <asn_internal.h>
#include <asn_codecs_prim.h>
#include <NULL.h>
#include <BOOLEAN.h> /* Implemented in terms of BOOLEAN type */
/*
* NULL basic type description.
......@@ -14,10 +13,10 @@ static const ber_tlv_tag_t asn_DEF_NULL_tags[] = {
(ASN_TAG_CLASS_UNIVERSAL | (5 << 2))
};
asn_TYPE_operation_t asn_OP_NULL = {
BOOLEAN_free,
NULL_free,
NULL_print,
NULL_compare,
BOOLEAN_decode_ber, /* Implemented in terms of BOOLEAN */
NULL_decode_ber,
NULL_encode_der, /* Special handling of DER encoding */
NULL_decode_xer,
NULL_encode_xer,
......@@ -55,6 +54,65 @@ asn_TYPE_descriptor_t asn_DEF_NULL = {
0 /* No specifics */
};
void
NULL_free(const asn_TYPE_descriptor_t *td, void *ptr,
enum asn_struct_free_method method) {
if(td && ptr) {
switch(method) {
case ASFM_FREE_EVERYTHING:
FREEMEM(ptr);
break;
case ASFM_FREE_UNDERLYING:
break;
case ASFM_FREE_UNDERLYING_AND_RESET:
memset(ptr, 0, sizeof(NULL_t));
break;
}
}
}
/*
* Decode NULL type.
*/
asn_dec_rval_t
NULL_decode_ber(const asn_codec_ctx_t *opt_codec_ctx,
const asn_TYPE_descriptor_t *td, void **bool_value,
const void *buf_ptr, size_t size, int tag_mode) {
NULL_t *st = (NULL_t *)*bool_value;
asn_dec_rval_t rval;
ber_tlv_len_t length;
if(st == NULL) {
st = (NULL_t *)(*bool_value = CALLOC(1, sizeof(*st)));
if(st == NULL) {
rval.code = RC_FAIL;
rval.consumed = 0;
return rval;
}
}
ASN_DEBUG("Decoding %s as NULL (tm=%d)", td->name, tag_mode);
/*
* Check tags.
*/
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
&length, 0);
if(rval.code != RC_OK) {
return rval;
}
// X.690-201508, #8.8.2, length shall be zero.
if(length != 0) {
ASN_DEBUG("Decoding %s as NULL failed: too much data", td->name);
rval.code = RC_FAIL;
rval.consumed = 0;
return rval;
}
return rval;
}
asn_enc_rval_t
NULL_encode_der(const asn_TYPE_descriptor_t *td, const void *ptr, int tag_mode,
ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
......
......@@ -6,23 +6,24 @@
#define ASN_TYPE_NULL_H
#include <asn_application.h>
#include <BOOLEAN.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The value of the NULL type is meaningless: see BOOLEAN if you want to
* carry true/false semantics.
* The value of the NULL type is meaningless.
* Use the BOOLEAN type if you need to carry true/false semantics.
*/
typedef int NULL_t;
extern asn_TYPE_descriptor_t asn_DEF_NULL;
extern asn_TYPE_operation_t asn_OP_NULL;
asn_struct_free_f NULL_free;
asn_struct_print_f NULL_print;
asn_struct_compare_f NULL_compare;
ber_type_decoder_f NULL_decode_ber;
der_type_encoder_f NULL_encode_der;
xer_type_decoder_f NULL_decode_xer;
xer_type_encoder_f NULL_encode_xer;
......@@ -34,8 +35,6 @@ per_type_decoder_f NULL_decode_aper;
per_type_encoder_f NULL_encode_aper;
asn_random_fill_f NULL_random_fill;
#define NULL_free BOOLEAN_free
#define NULL_decode_ber BOOLEAN_decode_ber
#define NULL_constraint asn_generic_no_constraint
#ifdef __cplusplus
......
......@@ -16,7 +16,7 @@ GraphicString.h GraphicString.c OCTET_STRING.h
IA5String.h IA5String.c OCTET_STRING.h
INTEGER.h INTEGER.c
ISO646String.h ISO646String.c OCTET_STRING.h
NULL.h NULL.c BOOLEAN.h
NULL.h NULL.c
NativeEnumerated.h NativeEnumerated.c NativeInteger.h
NativeInteger.h NativeInteger.c INTEGER.h
NativeReal.h NativeReal.c REAL.h
......
......@@ -300,7 +300,7 @@ Packet_List_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
if((size >= 1 && size <= 256)) {
/* Perform validation of the inner elements */
return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
return SEQUENCE_OF_constraint(td, sptr, ctfailcb, app_key);
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
......@@ -387,7 +387,7 @@ UpperLayer_List_41P0_constraint(const asn_TYPE_descriptor_t *td, const void *spt
if((size >= 1 && size <= 256)) {
/* Perform validation of the inner elements */
return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
return SEQUENCE_OF_constraint(td, sptr, ctfailcb, app_key);
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
......
......@@ -56,7 +56,7 @@ memb_varsets_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
if((size >= 1)) {
/* Perform validation of the inner elements */
return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
return SEQUENCE_OF_constraint(td, sptr, ctfailcb, app_key);
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
......@@ -383,7 +383,7 @@ memb_vset_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
if((size >= 1)) {
/* Perform validation of the inner elements */
return td->encoding_constraints.general_constraints(td, sptr, ctfailcb, app_key);
return SET_OF_constraint(td, sptr, ctfailcb, app_key);
} else {
ASN__CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
......
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