/*
 * Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
 * From ASN.1 module "X2AP-PDU-Contents"
 * 	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 "MeasurementInitiationResult-Item.h"

#include "MeasurementFailureCause-List.h"
#include "ProtocolExtensionContainer.h"
static asn_TYPE_member_t asn_MBR_MeasurementInitiationResult_Item_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct MeasurementInitiationResult_Item, cell_ID),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ECGI,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"cell-ID"
		},
	{ ATF_POINTER, 2, offsetof(struct MeasurementInitiationResult_Item, measurementFailureCause_List),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_MeasurementFailureCause_List,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"measurementFailureCause-List"
		},
	{ ATF_POINTER, 1, offsetof(struct MeasurementInitiationResult_Item, iE_Extensions),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ProtocolExtensionContainer_8858P3,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"iE-Extensions"
		},
};
static const int asn_MAP_MeasurementInitiationResult_Item_oms_1[] = { 1, 2 };
static const ber_tlv_tag_t asn_DEF_MeasurementInitiationResult_Item_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_MeasurementInitiationResult_Item_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* cell-ID */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* measurementFailureCause-List */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* iE-Extensions */
};
static asn_SEQUENCE_specifics_t asn_SPC_MeasurementInitiationResult_Item_specs_1 = {
	sizeof(struct MeasurementInitiationResult_Item),
	offsetof(struct MeasurementInitiationResult_Item, _asn_ctx),
	asn_MAP_MeasurementInitiationResult_Item_tag2el_1,
	3,	/* Count of tags in the map */
	asn_MAP_MeasurementInitiationResult_Item_oms_1,	/* Optional members */
	2, 0,	/* Root/Additions */
	3,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_MeasurementInitiationResult_Item = {
	"MeasurementInitiationResult-Item",
	"MeasurementInitiationResult-Item",
	&asn_OP_SEQUENCE,
	asn_DEF_MeasurementInitiationResult_Item_tags_1,
	sizeof(asn_DEF_MeasurementInitiationResult_Item_tags_1)
		/sizeof(asn_DEF_MeasurementInitiationResult_Item_tags_1[0]), /* 1 */
	asn_DEF_MeasurementInitiationResult_Item_tags_1,	/* Same as above */
	sizeof(asn_DEF_MeasurementInitiationResult_Item_tags_1)
		/sizeof(asn_DEF_MeasurementInitiationResult_Item_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_MeasurementInitiationResult_Item_1,
	3,	/* Elements count */
	&asn_SPC_MeasurementInitiationResult_Item_specs_1	/* Additional specs */
};

