/*
 * Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
 * From ASN.1 module "X2AP-IEs"
 * 	found in "Spec/e2_and_x2-combined-and-minimized.asn1"
 * 	`asn1c -pdu=auto -fincludes-quoted -fcompound-names -fno-include-deps -gen-PER -no-gen-OER -no-gen-example`
 */

#include "WidebandCQI.h"

#include "WidebandCQICodeword1.h"
#include "ProtocolExtensionContainer.h"
static int
memb_widebandCQICodeword0_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr,
			asn_app_constraint_failed_f *ctfailcb, void *app_key) {
	long value;
	
	if(!sptr) {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: value not given (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
	
	value = *(const long *)sptr;
	
	if((value >= 0 && value <= 15)) {
		/* Constraint check succeeded */
		return 0;
	} else {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: constraint failed (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
}

static asn_per_constraints_t asn_PER_memb_widebandCQICodeword0_constr_2 CC_NOTUSED = {
	{ APC_CONSTRAINED | APC_EXTENSIBLE,  4,  4,  0,  15 }	/* (0..15,...) */,
	{ APC_UNCONSTRAINED,	-1, -1,  0,  0 },
	0, 0	/* No PER value map */
};
asn_TYPE_member_t asn_MBR_WidebandCQI_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct WidebandCQI, widebandCQICodeword0),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_NativeInteger,
		0,
		{ 0, &asn_PER_memb_widebandCQICodeword0_constr_2,  memb_widebandCQICodeword0_constraint_1 },
		0, 0, /* No default value */
		"widebandCQICodeword0"
		},
	{ ATF_POINTER, 2, offsetof(struct WidebandCQI, widebandCQICodeword1),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		+1,	/* EXPLICIT tag at current level */
		&asn_DEF_WidebandCQICodeword1,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"widebandCQICodeword1"
		},
	{ ATF_POINTER, 1, offsetof(struct WidebandCQI, iE_Extensions),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ProtocolExtensionContainer_8858P75,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"iE-Extensions"
		},
};
static const int asn_MAP_WidebandCQI_oms_1[] = { 1, 2 };
static const ber_tlv_tag_t asn_DEF_WidebandCQI_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_WidebandCQI_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* widebandCQICodeword0 */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* widebandCQICodeword1 */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* iE-Extensions */
};
asn_SEQUENCE_specifics_t asn_SPC_WidebandCQI_specs_1 = {
	sizeof(struct WidebandCQI),
	offsetof(struct WidebandCQI, _asn_ctx),
	asn_MAP_WidebandCQI_tag2el_1,
	3,	/* Count of tags in the map */
	asn_MAP_WidebandCQI_oms_1,	/* Optional members */
	2, 0,	/* Root/Additions */
	3,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_WidebandCQI = {
	"WidebandCQI",
	"WidebandCQI",
	&asn_OP_SEQUENCE,
	asn_DEF_WidebandCQI_tags_1,
	sizeof(asn_DEF_WidebandCQI_tags_1)
		/sizeof(asn_DEF_WidebandCQI_tags_1[0]), /* 1 */
	asn_DEF_WidebandCQI_tags_1,	/* Same as above */
	sizeof(asn_DEF_WidebandCQI_tags_1)
		/sizeof(asn_DEF_WidebandCQI_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_WidebandCQI_1,
	3,	/* Elements count */
	&asn_SPC_WidebandCQI_specs_1	/* Additional specs */
};

