/*
 * Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
 * From ASN.1 module "X2AP-IEs"
 * 	found in "X2AP-15-4-0.asn1"
 * 	`asn1c -D ./asn1_n1 -pdu=auto -fno-include-deps -fcompound-names -findirect-choice -gen-PER -gen-OER -no-gen-example`
 */

#include "NRCellIdentifier.h"

int
NRCellIdentifier_constraint(const asn_TYPE_descriptor_t *td, const void *sptr,
			asn_app_constraint_failed_f *ctfailcb, void *app_key) {
	const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
	size_t size;
	
	if(!sptr) {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: value not given (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
	
	if(st->size > 0) {
		/* Size in bits */
		size = 8 * st->size - (st->bits_unused & 0x07);
	} else {
		size = 0;
	}
	
	if((size == 36)) {
		/* Constraint check succeeded */
		return 0;
	} else {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: constraint failed (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
}

/*
 * This type is implemented using BIT_STRING,
 * so here we adjust the DEF accordingly.
 */
static asn_oer_constraints_t asn_OER_type_NRCellIdentifier_constr_1 CC_NOTUSED = {
	{ 0, 0 },
	36	/* (SIZE(36..36)) */};
asn_per_constraints_t asn_PER_type_NRCellIdentifier_constr_1 CC_NOTUSED = {
	{ APC_UNCONSTRAINED,	-1, -1,  0,  0 },
	{ APC_CONSTRAINED,	 0,  0,  36,  36 }	/* (SIZE(36..36)) */,
	0, 0	/* No PER value map */
};
static const ber_tlv_tag_t asn_DEF_NRCellIdentifier_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
};
asn_TYPE_descriptor_t asn_DEF_NRCellIdentifier = {
	"NRCellIdentifier",
	"NRCellIdentifier",
	&asn_OP_BIT_STRING,
	asn_DEF_NRCellIdentifier_tags_1,
	sizeof(asn_DEF_NRCellIdentifier_tags_1)
		/sizeof(asn_DEF_NRCellIdentifier_tags_1[0]), /* 1 */
	asn_DEF_NRCellIdentifier_tags_1,	/* Same as above */
	sizeof(asn_DEF_NRCellIdentifier_tags_1)
		/sizeof(asn_DEF_NRCellIdentifier_tags_1[0]), /* 1 */
	{ &asn_OER_type_NRCellIdentifier_constr_1, &asn_PER_type_NRCellIdentifier_constr_1, NRCellIdentifier_constraint },
	0, 0,	/* No members */
	&asn_SPC_BIT_STRING_specs	/* Additional specs */
};

