/*
 * 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 "HFN.h"

int
HFN_constraint(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 <= 1048575)) {
		/* 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 NativeInteger,
 * so here we adjust the DEF accordingly.
 */
static asn_oer_constraints_t asn_OER_type_HFN_constr_1 CC_NOTUSED = {
	{ 4, 1 }	/* (0..1048575) */,
	-1};
asn_per_constraints_t asn_PER_type_HFN_constr_1 CC_NOTUSED = {
	{ APC_CONSTRAINED,	 20, -1,  0,  1048575 }	/* (0..1048575) */,
	{ APC_UNCONSTRAINED,	-1, -1,  0,  0 },
	0, 0	/* No PER value map */
};
static const ber_tlv_tag_t asn_DEF_HFN_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
};
asn_TYPE_descriptor_t asn_DEF_HFN = {
	"HFN",
	"HFN",
	&asn_OP_NativeInteger,
	asn_DEF_HFN_tags_1,
	sizeof(asn_DEF_HFN_tags_1)
		/sizeof(asn_DEF_HFN_tags_1[0]), /* 1 */
	asn_DEF_HFN_tags_1,	/* Same as above */
	sizeof(asn_DEF_HFN_tags_1)
		/sizeof(asn_DEF_HFN_tags_1[0]), /* 1 */
	{ &asn_OER_type_HFN_constr_1, &asn_PER_type_HFN_constr_1, HFN_constraint },
	0, 0,	/* No members */
	0	/* No specifics */
};

