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

#include "ExpectedUEBehaviour.h"

#include "ExpectedUEActivityBehaviour.h"
#include "ProtocolExtensionContainer.h"
static asn_TYPE_member_t asn_MBR_ExpectedUEBehaviour_1[] = {
	{ ATF_POINTER, 3, offsetof(struct ExpectedUEBehaviour, expectedActivity),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ExpectedUEActivityBehaviour,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"expectedActivity"
		},
	{ ATF_POINTER, 2, offsetof(struct ExpectedUEBehaviour, expectedHOInterval),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ExpectedHOInterval,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"expectedHOInterval"
		},
	{ ATF_POINTER, 1, offsetof(struct ExpectedUEBehaviour, iE_Extensions),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_ProtocolExtensionContainer_9566P142,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"iE-Extensions"
		},
};
static const int asn_MAP_ExpectedUEBehaviour_oms_1[] = { 0, 1, 2 };
static const ber_tlv_tag_t asn_DEF_ExpectedUEBehaviour_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_ExpectedUEBehaviour_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* expectedActivity */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* expectedHOInterval */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* iE-Extensions */
};
static asn_SEQUENCE_specifics_t asn_SPC_ExpectedUEBehaviour_specs_1 = {
	sizeof(struct ExpectedUEBehaviour),
	offsetof(struct ExpectedUEBehaviour, _asn_ctx),
	asn_MAP_ExpectedUEBehaviour_tag2el_1,
	3,	/* Count of tags in the map */
	asn_MAP_ExpectedUEBehaviour_oms_1,	/* Optional members */
	3, 0,	/* Root/Additions */
	3,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_ExpectedUEBehaviour = {
	"ExpectedUEBehaviour",
	"ExpectedUEBehaviour",
	&asn_OP_SEQUENCE,
	asn_DEF_ExpectedUEBehaviour_tags_1,
	sizeof(asn_DEF_ExpectedUEBehaviour_tags_1)
		/sizeof(asn_DEF_ExpectedUEBehaviour_tags_1[0]), /* 1 */
	asn_DEF_ExpectedUEBehaviour_tags_1,	/* Same as above */
	sizeof(asn_DEF_ExpectedUEBehaviour_tags_1)
		/sizeof(asn_DEF_ExpectedUEBehaviour_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_ExpectedUEBehaviour_1,
	3,	/* Elements count */
	&asn_SPC_ExpectedUEBehaviour_specs_1	/* Additional specs */
};

