/*
 * Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
 * From ASN.1 module "E2SM-RC-IEs"
 * 	found in "e2sm-rc-nov2021.asn"
 * 	`asn1c -fcompound-names -fno-include-deps -findirect-choice -pdu=auto -gen-PER -gen-OER -no-gen-example -D .`
 */

#include "E2SM-RC-ActionDefinition.h"

#include "E2SM-RC-ActionDefinition-Format1.h"
#include "E2SM-RC-ActionDefinition-Format2.h"
#include "E2SM-RC-ActionDefinition-Format3.h"
static asn_oer_constraints_t asn_OER_type_ric_actionDefinition_formats_constr_3 CC_NOTUSED = {
	{ 0, 0 },
	-1};
static asn_per_constraints_t asn_PER_type_ric_actionDefinition_formats_constr_3 CC_NOTUSED = {
	{ APC_CONSTRAINED | APC_EXTENSIBLE,  2,  2,  0,  2 }	/* (0..2,...) */,
	{ APC_UNCONSTRAINED,	-1, -1,  0,  0 },
	0, 0	/* No PER value map */
};
static asn_TYPE_member_t asn_MBR_ric_actionDefinition_formats_3[] = {
	{ ATF_POINTER, 0, offsetof(struct E2SM_RC_ActionDefinition__ric_actionDefinition_formats, choice.actionDefinition_Format1),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_E2SM_RC_ActionDefinition_Format1,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"actionDefinition-Format1"
		},
	{ ATF_POINTER, 0, offsetof(struct E2SM_RC_ActionDefinition__ric_actionDefinition_formats, choice.actionDefinition_Format2),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_E2SM_RC_ActionDefinition_Format2,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"actionDefinition-Format2"
		},
	{ ATF_POINTER, 0, offsetof(struct E2SM_RC_ActionDefinition__ric_actionDefinition_formats, choice.actionDefinition_Format3),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_E2SM_RC_ActionDefinition_Format3,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"actionDefinition-Format3"
		},
};
static const asn_TYPE_tag2member_t asn_MAP_ric_actionDefinition_formats_tag2el_3[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* actionDefinition-Format1 */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* actionDefinition-Format2 */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* actionDefinition-Format3 */
};
static asn_CHOICE_specifics_t asn_SPC_ric_actionDefinition_formats_specs_3 = {
	sizeof(struct E2SM_RC_ActionDefinition__ric_actionDefinition_formats),
	offsetof(struct E2SM_RC_ActionDefinition__ric_actionDefinition_formats, _asn_ctx),
	offsetof(struct E2SM_RC_ActionDefinition__ric_actionDefinition_formats, present),
	sizeof(((struct E2SM_RC_ActionDefinition__ric_actionDefinition_formats *)0)->present),
	asn_MAP_ric_actionDefinition_formats_tag2el_3,
	3,	/* Count of tags in the map */
	0, 0,
	3	/* Extensions start */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_ric_actionDefinition_formats_3 = {
	"ric-actionDefinition-formats",
	"ric-actionDefinition-formats",
	&asn_OP_CHOICE,
	0,	/* No effective tags (pointer) */
	0,	/* No effective tags (count) */
	0,	/* No tags (pointer) */
	0,	/* No tags (count) */
	{ &asn_OER_type_ric_actionDefinition_formats_constr_3, &asn_PER_type_ric_actionDefinition_formats_constr_3, CHOICE_constraint },
	asn_MBR_ric_actionDefinition_formats_3,
	3,	/* Elements count */
	&asn_SPC_ric_actionDefinition_formats_specs_3	/* Additional specs */
};

static asn_TYPE_member_t asn_MBR_E2SM_RC_ActionDefinition_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct E2SM_RC_ActionDefinition, ric_Style_Type),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_RIC_Style_Type,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"ric-Style-Type"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct E2SM_RC_ActionDefinition, ric_actionDefinition_formats),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		+1,	/* EXPLICIT tag at current level */
		&asn_DEF_ric_actionDefinition_formats_3,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"ric-actionDefinition-formats"
		},
};
static const ber_tlv_tag_t asn_DEF_E2SM_RC_ActionDefinition_tags_1[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_E2SM_RC_ActionDefinition_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* ric-Style-Type */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* ric-actionDefinition-formats */
};
static asn_SEQUENCE_specifics_t asn_SPC_E2SM_RC_ActionDefinition_specs_1 = {
	sizeof(struct E2SM_RC_ActionDefinition),
	offsetof(struct E2SM_RC_ActionDefinition, _asn_ctx),
	asn_MAP_E2SM_RC_ActionDefinition_tag2el_1,
	2,	/* Count of tags in the map */
	0, 0, 0,	/* Optional elements (not needed) */
	2,	/* First extension addition */
};
asn_TYPE_descriptor_t asn_DEF_E2SM_RC_ActionDefinition = {
	"E2SM-RC-ActionDefinition",
	"E2SM-RC-ActionDefinition",
	&asn_OP_SEQUENCE,
	asn_DEF_E2SM_RC_ActionDefinition_tags_1,
	sizeof(asn_DEF_E2SM_RC_ActionDefinition_tags_1)
		/sizeof(asn_DEF_E2SM_RC_ActionDefinition_tags_1[0]), /* 1 */
	asn_DEF_E2SM_RC_ActionDefinition_tags_1,	/* Same as above */
	sizeof(asn_DEF_E2SM_RC_ActionDefinition_tags_1)
		/sizeof(asn_DEF_E2SM_RC_ActionDefinition_tags_1[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_E2SM_RC_ActionDefinition_1,
	2,	/* Elements count */
	&asn_SPC_E2SM_RC_ActionDefinition_specs_1	/* Additional specs */
};

