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

#include "Neighbour-Information.h"
#include "ProtocolExtensionContainer.h"
asn_TYPE_member_t asn_MBR_ServedCellsToModify_Item_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct ServedCellsToModify_Item, old_ecgi),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ECGI,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"old-ecgi"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct ServedCellsToModify_Item, servedCellInfo),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ServedCell_Information,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"servedCellInfo"
		},
	{ ATF_POINTER, 2, offsetof(struct ServedCellsToModify_Item, neighbour_Info),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_Neighbour_Information,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"neighbour-Info"
		},
	{ ATF_POINTER, 1, offsetof(struct ServedCellsToModify_Item, iE_Extensions),
		(ASN_TAG_CLASS_CONTEXT | (3 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ProtocolExtensionContainer_8858P1,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"iE-Extensions"
		},
};
static const int asn_MAP_ServedCellsToModify_Item_oms_1[] = { 2, 3 };
static const ber_tlv_tag_t asn_DEF_ServedCellsToModify_Item_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_ServedCellsToModify_Item_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* old-ecgi */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* servedCellInfo */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* neighbour-Info */
    { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 } /* iE-Extensions */
};
asn_SEQUENCE_specifics_t asn_SPC_ServedCellsToModify_Item_specs_1 = {
	sizeof(struct ServedCellsToModify_Item),
	offsetof(struct ServedCellsToModify_Item, _asn_ctx),
	asn_MAP_ServedCellsToModify_Item_tag2el_1,
	4,	/* Count of tags in the map */
	asn_MAP_ServedCellsToModify_Item_oms_1,	/* Optional members */
	2, 0,	/* Root/Additions */
	4,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_ServedCellsToModify_Item = {
	"ServedCellsToModify-Item",
	"ServedCellsToModify-Item",
	&asn_OP_SEQUENCE,
	asn_DEF_ServedCellsToModify_Item_tags_1,
	sizeof(asn_DEF_ServedCellsToModify_Item_tags_1)
		/sizeof(asn_DEF_ServedCellsToModify_Item_tags_1[0]), /* 1 */
	asn_DEF_ServedCellsToModify_Item_tags_1,	/* Same as above */
	sizeof(asn_DEF_ServedCellsToModify_Item_tags_1)
		/sizeof(asn_DEF_ServedCellsToModify_Item_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_ServedCellsToModify_Item_1,
	4,	/* Elements count */
	&asn_SPC_ServedCellsToModify_Item_specs_1	/* Additional specs */
};

