/*
 * Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
 * From ASN.1 module "PKIX1Explicit88"
 * 	found in "../../../asn1/PKIX1Explicit88.asn"
 * 	`asn1c -fcompound-names -no-gen-example`
 */

#include "ExtendedNetworkAddress.h"

static const int permitted_alphabet_table_3[256] = {
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/*                  */
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/*                  */
 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* .                */
 2, 3, 4, 5, 6, 7, 8, 9,10,11, 0, 0, 0, 0, 0, 0,	/* 0123456789       */
};
static const int permitted_alphabet_code2value_3[11] = {
32,48,49,50,51,52,53,54,55,56,57,};


static int check_permitted_alphabet_3(const void *sptr) {
	const int *table = permitted_alphabet_table_3;
	/* The underlying type is NumericString */
	const NumericString_t *st = (const NumericString_t *)sptr;
	const uint8_t *ch = st->buf;
	const uint8_t *end = ch + st->size;
	
	for(; ch < end; ch++) {
		uint8_t cv = *ch;
		if(!table[cv]) return -1;
	}
	return 0;
}

static const int permitted_alphabet_table_4[256] = {
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/*                  */
 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/*                  */
 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,	/* .                */
 2, 3, 4, 5, 6, 7, 8, 9,10,11, 0, 0, 0, 0, 0, 0,	/* 0123456789       */
};
static const int permitted_alphabet_code2value_4[11] = {
32,48,49,50,51,52,53,54,55,56,57,};


static int check_permitted_alphabet_4(const void *sptr) {
	const int *table = permitted_alphabet_table_4;
	/* The underlying type is NumericString */
	const NumericString_t *st = (const NumericString_t *)sptr;
	const uint8_t *ch = st->buf;
	const uint8_t *end = ch + st->size;
	
	for(; ch < end; ch++) {
		uint8_t cv = *ch;
		if(!table[cv]) return -1;
	}
	return 0;
}

static int
memb_number_constraint_2(const asn_TYPE_descriptor_t *td, const void *sptr,
			asn_app_constraint_failed_f *ctfailcb, void *app_key) {
	const NumericString_t *st = (const NumericString_t *)sptr;
	size_t size;
	
	if(!sptr) {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: value not given (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
	
	size = st->size;
	
	if((size >= 1 && size <= 15)
		 && !check_permitted_alphabet_3(st)) {
		/* Constraint check succeeded */
		return 0;
	} else {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: constraint failed (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
}

static int asn_PER_MAP_number_3_v2c(unsigned int value) {
	if(value >= sizeof(permitted_alphabet_table_3)/sizeof(permitted_alphabet_table_3[0]))
		return -1;
	return permitted_alphabet_table_3[value] - 1;
}
static int asn_PER_MAP_number_3_c2v(unsigned int code) {
	if(code >= sizeof(permitted_alphabet_code2value_3)/sizeof(permitted_alphabet_code2value_3[0]))
		return -1;
	return permitted_alphabet_code2value_3[code];
}
static int
memb_sub_address_constraint_2(const asn_TYPE_descriptor_t *td, const void *sptr,
			asn_app_constraint_failed_f *ctfailcb, void *app_key) {
	const NumericString_t *st = (const NumericString_t *)sptr;
	size_t size;
	
	if(!sptr) {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: value not given (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
	
	size = st->size;
	
	if((size >= 1 && size <= 40)
		 && !check_permitted_alphabet_4(st)) {
		/* Constraint check succeeded */
		return 0;
	} else {
		ASN__CTFAIL(app_key, td, sptr,
			"%s: constraint failed (%s:%d)",
			td->name, __FILE__, __LINE__);
		return -1;
	}
}

static int asn_PER_MAP_sub_address_4_v2c(unsigned int value) {
	if(value >= sizeof(permitted_alphabet_table_4)/sizeof(permitted_alphabet_table_4[0]))
		return -1;
	return permitted_alphabet_table_4[value] - 1;
}
static int asn_PER_MAP_sub_address_4_c2v(unsigned int code) {
	if(code >= sizeof(permitted_alphabet_code2value_4)/sizeof(permitted_alphabet_code2value_4[0]))
		return -1;
	return permitted_alphabet_code2value_4[code];
}
static asn_oer_constraints_t asn_OER_memb_number_constr_3 CC_NOTUSED = {
	{ 0, 0 },
	-1	/* (SIZE(1..15)) */};
static asn_per_constraints_t asn_PER_memb_number_constr_3 CC_NOTUSED = {
	{ APC_CONSTRAINED,	 4,  4,  32,  57 }	/* (32..57) */,
	{ APC_CONSTRAINED,	 4,  4,  1,  15 }	/* (SIZE(1..15)) */,
	asn_PER_MAP_number_3_v2c,	/* Value to PER code map */
	asn_PER_MAP_number_3_c2v	/* PER code to value map */
};
static asn_oer_constraints_t asn_OER_memb_sub_address_constr_4 CC_NOTUSED = {
	{ 0, 0 },
	-1	/* (SIZE(1..40)) */};
static asn_per_constraints_t asn_PER_memb_sub_address_constr_4 CC_NOTUSED = {
	{ APC_CONSTRAINED,	 4,  4,  32,  57 }	/* (32..57) */,
	{ APC_CONSTRAINED,	 6,  6,  1,  40 }	/* (SIZE(1..40)) */,
	asn_PER_MAP_sub_address_4_v2c,	/* Value to PER code map */
	asn_PER_MAP_sub_address_4_c2v	/* PER code to value map */
};
static asn_oer_constraints_t asn_OER_type_ExtendedNetworkAddress_constr_1 CC_NOTUSED = {
	{ 0, 0 },
	-1};
static asn_per_constraints_t asn_PER_type_ExtendedNetworkAddress_constr_1 CC_NOTUSED = {
	{ APC_CONSTRAINED,	 1,  1,  0,  1 }	/* (0..1) */,
	{ APC_UNCONSTRAINED,	-1, -1,  0,  0 },
	0, 0	/* No PER value map */
};
static asn_TYPE_member_t asn_MBR_e163_4_address_2[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct ExtendedNetworkAddress__e163_4_address, number),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_NumericString,
		0,
		{ &asn_OER_memb_number_constr_3, &asn_PER_memb_number_constr_3,  memb_number_constraint_2 },
		0, 0, /* No default value */
		"number"
		},
	{ ATF_POINTER, 1, offsetof(struct ExtendedNetworkAddress__e163_4_address, sub_address),
		(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_NumericString,
		0,
		{ &asn_OER_memb_sub_address_constr_4, &asn_PER_memb_sub_address_constr_4,  memb_sub_address_constraint_2 },
		0, 0, /* No default value */
		"sub-address"
		},
};
static const int asn_MAP_e163_4_address_oms_2[] = { 1 };
static const ber_tlv_tag_t asn_DEF_e163_4_address_tags_2[] = {
	(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static const asn_TYPE_tag2member_t asn_MAP_e163_4_address_tag2el_2[] = {
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* number */
    { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* sub-address */
};
static asn_SEQUENCE_specifics_t asn_SPC_e163_4_address_specs_2 = {
	sizeof(struct ExtendedNetworkAddress__e163_4_address),
	offsetof(struct ExtendedNetworkAddress__e163_4_address, _asn_ctx),
	asn_MAP_e163_4_address_tag2el_2,
	2,	/* Count of tags in the map */
	asn_MAP_e163_4_address_oms_2,	/* Optional members */
	1, 0,	/* Root/Additions */
	-1,	/* First extension addition */
};
static /* Use -fall-defs-global to expose */
asn_TYPE_descriptor_t asn_DEF_e163_4_address_2 = {
	"e163-4-address",
	"e163-4-address",
	&asn_OP_SEQUENCE,
	asn_DEF_e163_4_address_tags_2,
	sizeof(asn_DEF_e163_4_address_tags_2)
		/sizeof(asn_DEF_e163_4_address_tags_2[0]), /* 1 */
	asn_DEF_e163_4_address_tags_2,	/* Same as above */
	sizeof(asn_DEF_e163_4_address_tags_2)
		/sizeof(asn_DEF_e163_4_address_tags_2[0]), /* 1 */
	{ 0, 0, SEQUENCE_constraint },
	asn_MBR_e163_4_address_2,
	2,	/* Elements count */
	&asn_SPC_e163_4_address_specs_2	/* Additional specs */
};

static asn_TYPE_member_t asn_MBR_ExtendedNetworkAddress_1[] = {
	{ ATF_NOFLAGS, 0, offsetof(struct ExtendedNetworkAddress, choice.e163_4_address),
		(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
		0,
		&asn_DEF_e163_4_address_2,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"e163-4-address"
		},
	{ ATF_NOFLAGS, 0, offsetof(struct ExtendedNetworkAddress, choice.psap_address),
		(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
		-1,	/* IMPLICIT tag at current level */
		&asn_DEF_PresentationAddress,
		0,
		{ 0, 0, 0 },
		0, 0, /* No default value */
		"psap-address"
		},
};
static const asn_TYPE_tag2member_t asn_MAP_ExtendedNetworkAddress_tag2el_1[] = {
    { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* e163-4-address */
    { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* psap-address */
};
static asn_CHOICE_specifics_t asn_SPC_ExtendedNetworkAddress_specs_1 = {
	sizeof(struct ExtendedNetworkAddress),
	offsetof(struct ExtendedNetworkAddress, _asn_ctx),
	offsetof(struct ExtendedNetworkAddress, present),
	sizeof(((struct ExtendedNetworkAddress *)0)->present),
	asn_MAP_ExtendedNetworkAddress_tag2el_1,
	2,	/* Count of tags in the map */
	0, 0,
	-1	/* Extensions start */
};
asn_TYPE_descriptor_t asn_DEF_ExtendedNetworkAddress = {
	"ExtendedNetworkAddress",
	"ExtendedNetworkAddress",
	&asn_OP_CHOICE,
	0,	/* No effective tags (pointer) */
	0,	/* No effective tags (count) */
	0,	/* No tags (pointer) */
	0,	/* No tags (count) */
	{ &asn_OER_type_ExtendedNetworkAddress_constr_1, &asn_PER_type_ExtendedNetworkAddress_constr_1, CHOICE_constraint },
	asn_MBR_ExtendedNetworkAddress_1,
	2,	/* Elements count */
	&asn_SPC_ExtendedNetworkAddress_specs_1	/* Additional specs */
};

