/*
 * 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 "RANParameter-Value.h"

static asn_oer_constraints_t asn_OER_type_RANParameter_Value_constr_1 CC_NOTUSED = {
	{ 0, 0 },
	-1};
asn_per_constraints_t asn_PER_type_RANParameter_Value_constr_1 CC_NOTUSED = {
	{ APC_CONSTRAINED | APC_EXTENSIBLE,  3,  3,  0,  5 }	/* (0..5,...) */,
	{ APC_UNCONSTRAINED,	-1, -1,  0,  0 },
	0, 0	/* No PER value map */
};
asn_TYPE_member_t asn_MBR_RANParameter_Value_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct RANParameter_Value, choice.valueBoolean),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_BOOLEAN,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"valueBoolean"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct RANParameter_Value, choice.valueInt),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_NativeInteger,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"valueInt"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct RANParameter_Value, choice.valueReal),
		(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_NativeReal,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"valueReal"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct RANParameter_Value, choice.valueBitS),
		(ASN_TAG_CLASS_CONTEXT | (3 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_BIT_STRING,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"valueBitS"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct RANParameter_Value, choice.valueOctS),
		(ASN_TAG_CLASS_CONTEXT | (4 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_OCTET_STRING,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"valueOctS"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct RANParameter_Value, choice.valuePrintableString),
		(ASN_TAG_CLASS_CONTEXT | (5 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_PrintableString,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"valuePrintableString"
		},
};
static const asn_TYPE_tag2member_t asn_MAP_RANParameter_Value_tag2el_1[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* valueBoolean */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* valueInt */
    { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* valueReal */
    { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* valueBitS */
    { (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* valueOctS */
    { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 } /* valuePrintableString */
};
asn_CHOICE_specifics_t asn_SPC_RANParameter_Value_specs_1 = {
	sizeof(struct RANParameter_Value),
	offsetof(struct RANParameter_Value, _asn_ctx),
	offsetof(struct RANParameter_Value, present),
	sizeof(((struct RANParameter_Value *)0)->present),
	asn_MAP_RANParameter_Value_tag2el_1,
	6,	/* Count of tags in the map */
	0, 0,
	6	/* Extensions start */
};
asn_TYPE_descriptor_t asn_DEF_RANParameter_Value = {
	"RANParameter-Value",
	"RANParameter-Value",
	&asn_OP_CHOICE,
	0,	/* No effective tags (pointer) */
	0,	/* No effective tags (count) */
	0,	/* No tags (pointer) */
	0,	/* No tags (count) */
	{ &asn_OER_type_RANParameter_Value_constr_1, &asn_PER_type_RANParameter_Value_constr_1, CHOICE_constraint },
	asn_MBR_RANParameter_Value_1,
	6,	/* Elements count */
	&asn_SPC_RANParameter_Value_specs_1	/* Additional specs */
};

