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

#include "ProtocolExtensionContainer.h"
asn_TYPE_member_t asn_MBR_BandInfo_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct BandInfo, freqBandIndicator),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_FreqBandIndicator,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"freqBandIndicator"
		},
	{ ATF_POINTER, 1, offsetof(struct BandInfo, iE_Extensions),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ProtocolExtensionContainer_8858P50,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"iE-Extensions"
		},
};
static const int asn_MAP_BandInfo_oms_1[] = { 1 };
static const ber_tlv_tag_t asn_DEF_BandInfo_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_BandInfo_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* freqBandIndicator */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* iE-Extensions */
};
asn_SEQUENCE_specifics_t asn_SPC_BandInfo_specs_1 = {
	sizeof(struct BandInfo),
	offsetof(struct BandInfo, _asn_ctx),
	asn_MAP_BandInfo_tag2el_1,
	2,	/* Count of tags in the map */
	asn_MAP_BandInfo_oms_1,	/* Optional members */
	1, 0,	/* Root/Additions */
	2,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_BandInfo = {
	"BandInfo",
	"BandInfo",
	&asn_OP_SEQUENCE,
	asn_DEF_BandInfo_tags_1,
	sizeof(asn_DEF_BandInfo_tags_1)
		/sizeof(asn_DEF_BandInfo_tags_1[0]), /* 1 */
	asn_DEF_BandInfo_tags_1,	/* Same as above */
	sizeof(asn_DEF_BandInfo_tags_1)
		/sizeof(asn_DEF_BandInfo_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_BandInfo_1,
	2,	/* Elements count */
	&asn_SPC_BandInfo_specs_1	/* Additional specs */
};

