/*
 * Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
 * From ASN.1 module "X2AP-PDU-Contents"
 * 	found in "Spec/e2ap-v031ex.asn"
 * 	`asn1c -fcompound-names -fno-include-deps -findirect-choice -gen-PER`
 */

#include "E-RABs-Admitted-ToBeAdded-SgNBModAck-Item-SgNBPDCPnotpresent.h"

#include "GTPtunnelEndpoint.h"
#include "ProtocolExtensionContainer.h"
asn_TYPE_member_t asn_MBR_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent, sgNB_DL_GTP_TEIDatSCG),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_GTPtunnelEndpoint,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"sgNB-DL-GTP-TEIDatSCG"
		},
	{ ATF_POINTER, 2, offsetof(struct E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent, secondary_sgNB_DL_GTP_TEIDatSCG),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_GTPtunnelEndpoint,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"secondary-sgNB-DL-GTP-TEIDatSCG"
		},
	{ ATF_POINTER, 1, offsetof(struct E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent, iE_Extensions),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ProtocolExtensionContainer_9566P64,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"iE-Extensions"
		},
};
static const int asn_MAP_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_oms_1[] = { 1, 2 };
static const ber_tlv_tag_t asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* sgNB-DL-GTP-TEIDatSCG */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* secondary-sgNB-DL-GTP-TEIDatSCG */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* iE-Extensions */
};
asn_SEQUENCE_specifics_t asn_SPC_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_specs_1 = {
	sizeof(struct E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent),
	offsetof(struct E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent, _asn_ctx),
	asn_MAP_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tag2el_1,
	3,	/* Count of tags in the map */
	asn_MAP_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_oms_1,	/* Optional members */
	2, 0,	/* Root/Additions */
	3,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent = {
	"E-RABs-Admitted-ToBeAdded-SgNBModAck-Item-SgNBPDCPnotpresent",
	"E-RABs-Admitted-ToBeAdded-SgNBModAck-Item-SgNBPDCPnotpresent",
	&asn_OP_SEQUENCE,
	asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tags_1,
	sizeof(asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tags_1)
		/sizeof(asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tags_1[0]), /* 1 */
	asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tags_1,	/* Same as above */
	sizeof(asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tags_1)
		/sizeof(asn_DEF_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_1,
	3,	/* Elements count */
	&asn_SPC_E_RABs_Admitted_ToBeAdded_SgNBModAck_Item_SgNBPDCPnotpresent_specs_1	/* Additional specs */
};

