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

#include "HWLoadIndicator.h"
#include "S1TNLLoadIndicator.h"
#include "RadioResourceStatus.h"
#include "ProtocolExtensionContainer.h"
static asn_TYPE_member_t asn_MBR_CellMeasurementResult_Item_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct CellMeasurementResult_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, 4, offsetof(struct CellMeasurementResult_Item, hWLoadIndicator),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_HWLoadIndicator,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"hWLoadIndicator"
		},
	{ ATF_POINTER, 3, offsetof(struct CellMeasurementResult_Item, s1TNLLoadIndicator),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_S1TNLLoadIndicator,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"s1TNLLoadIndicator"
		},
	{ ATF_POINTER, 2, offsetof(struct CellMeasurementResult_Item, radioResourceStatus),
		(ASN_TAG_CLASS_CONTEXT | (3 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_RadioResourceStatus,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"radioResourceStatus"
		},
	{ ATF_POINTER, 1, offsetof(struct CellMeasurementResult_Item, iE_Extensions),
		(ASN_TAG_CLASS_CONTEXT | (4 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ProtocolExtensionContainer_8858P6,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"iE-Extensions"
		},
};
static const int asn_MAP_CellMeasurementResult_Item_oms_1[] = { 1, 2, 3, 4 };
static const ber_tlv_tag_t asn_DEF_CellMeasurementResult_Item_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_CellMeasurementResult_Item_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* cell-ID */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* hWLoadIndicator */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* s1TNLLoadIndicator */
    { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* radioResourceStatus */
    { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 } /* iE-Extensions */
};
static asn_SEQUENCE_specifics_t asn_SPC_CellMeasurementResult_Item_specs_1 = {
	sizeof(struct CellMeasurementResult_Item),
	offsetof(struct CellMeasurementResult_Item, _asn_ctx),
	asn_MAP_CellMeasurementResult_Item_tag2el_1,
	5,	/* Count of tags in the map */
	asn_MAP_CellMeasurementResult_Item_oms_1,	/* Optional members */
	4, 0,	/* Root/Additions */
	5,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_CellMeasurementResult_Item = {
	"CellMeasurementResult-Item",
	"CellMeasurementResult-Item",
	&asn_OP_SEQUENCE,
	asn_DEF_CellMeasurementResult_Item_tags_1,
	sizeof(asn_DEF_CellMeasurementResult_Item_tags_1)
		/sizeof(asn_DEF_CellMeasurementResult_Item_tags_1[0]), /* 1 */
	asn_DEF_CellMeasurementResult_Item_tags_1,	/* Same as above */
	sizeof(asn_DEF_CellMeasurementResult_Item_tags_1)
		/sizeof(asn_DEF_CellMeasurementResult_Item_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_CellMeasurementResult_Item_1,
	5,	/* Elements count */
	&asn_SPC_CellMeasurementResult_Item_specs_1	/* Additional specs */
};

