2004-06-03 03:38:44 +00:00
|
|
|
/*-
|
2005-11-26 11:25:14 +00:00
|
|
|
* Copyright (c) 2003, 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
2004-06-03 03:38:44 +00:00
|
|
|
* Redistribution and modifications are permitted subject to BSD license.
|
|
|
|
*/
|
2004-09-22 16:06:28 +00:00
|
|
|
#include <asn_internal.h>
|
2004-06-03 03:38:44 +00:00
|
|
|
#include <ENUMERATED.h>
|
2005-11-26 11:25:14 +00:00
|
|
|
#include <NativeEnumerated.h>
|
2004-10-21 11:22:12 +00:00
|
|
|
#include <asn_codecs_prim.h> /* Encoder and decoder of a primitive type */
|
2004-06-03 03:38:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ENUMERATED basic type description.
|
|
|
|
*/
|
2004-09-29 13:26:15 +00:00
|
|
|
static ber_tlv_tag_t asn_DEF_ENUMERATED_tags[] = {
|
2004-06-03 03:38:44 +00:00
|
|
|
(ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
|
|
|
|
};
|
2004-09-29 13:26:15 +00:00
|
|
|
asn_TYPE_descriptor_t asn_DEF_ENUMERATED = {
|
2004-10-20 15:50:55 +00:00
|
|
|
"ENUMERATED",
|
2004-06-03 03:38:44 +00:00
|
|
|
"ENUMERATED",
|
2004-09-26 13:10:40 +00:00
|
|
|
ASN__PRIMITIVE_TYPE_free,
|
2004-09-22 16:06:28 +00:00
|
|
|
INTEGER_print, /* Implemented in terms of INTEGER */
|
2004-06-03 03:38:44 +00:00
|
|
|
asn_generic_no_constraint,
|
2004-09-26 13:10:40 +00:00
|
|
|
ber_decode_primitive,
|
2004-06-03 03:38:44 +00:00
|
|
|
INTEGER_encode_der, /* Implemented in terms of INTEGER */
|
2004-10-21 11:23:12 +00:00
|
|
|
INTEGER_decode_xer, /* This is temporary! */
|
|
|
|
INTEGER_encode_xer,
|
2005-11-26 11:25:14 +00:00
|
|
|
ENUMERATED_decode_uper, /* Unaligned PER decoder */
|
2004-06-03 03:38:44 +00:00
|
|
|
0, /* Use generic outmost tag fetcher */
|
2004-09-29 13:26:15 +00:00
|
|
|
asn_DEF_ENUMERATED_tags,
|
|
|
|
sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]),
|
|
|
|
asn_DEF_ENUMERATED_tags, /* Same as above */
|
|
|
|
sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]),
|
2005-11-26 11:25:14 +00:00
|
|
|
0, /* No PER visible constraints */
|
2004-08-20 13:23:42 +00:00
|
|
|
0, 0, /* No members */
|
2004-06-05 08:17:50 +00:00
|
|
|
0 /* No specifics */
|
2004-06-03 03:38:44 +00:00
|
|
|
};
|
|
|
|
|
2005-11-26 11:25:14 +00:00
|
|
|
asn_dec_rval_t
|
|
|
|
ENUMERATED_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
|
|
|
|
asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
|
|
|
|
asn_dec_rval_t rval;
|
|
|
|
ENUMERATED_t *st = (ENUMERATED_t *)*sptr;
|
|
|
|
long value, *vptr = &value;
|
|
|
|
|
|
|
|
if(!st) {
|
|
|
|
st = (ENUMERATED_t *)(*sptr = CALLOC(1, sizeof(*st)));
|
|
|
|
if(!st) _ASN_DECODE_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
rval = NativeEnumerated_decode_uper(opt_codec_ctx, td, constraints,
|
|
|
|
(void **)&vptr, pd);
|
|
|
|
if(rval.code == RC_OK)
|
|
|
|
if(asn_long2INTEGER(st, value))
|
|
|
|
rval.code = RC_FAIL;
|
|
|
|
return rval;
|
|
|
|
}
|