NumericString.c
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2003, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
7 
8 /*
9  * NumericString basic type description.
10  */
12  (ASN_TAG_CLASS_UNIVERSAL | (18 << 2)), /* [UNIVERSAL 18] IMPLICIT ...*/
13  (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */
14 };
15 #if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
16 static int asn_DEF_NumericString_v2c(unsigned int value) {
17  switch(value) {
18  case 0x20: return 0;
19  case 0x30: case 0x31: case 0x32: case 0x33: case 0x34:
20  case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
21  return value - (0x30 - 1);
22  }
23  return -1;
24 }
25 static int asn_DEF_NumericString_c2v(unsigned int code) {
26  if(code > 0) {
27  if(code <= 10)
28  return code + (0x30 - 1);
29  else
30  return -1;
31  } else {
32  return 0x20;
33  }
34 }
36  { APC_CONSTRAINED, 4, 4, 0x20, 0x39 }, /* Value */
37  { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */
40 };
41 #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
44 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
45  OCTET_STRING_print_utf8, /* ASCII subset */
46 #else
47  0,
48 #endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
51 #if !defined(ASN_DISABLE_BER_SUPPORT)
52  OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */
54 #else
55  0,
56  0,
57 #endif /* !defined(ASN_DISABLE_BER_SUPPORT) */
58 #if !defined(ASN_DISABLE_XER_SUPPORT)
61 #else
62  0,
63  0,
64 #endif /* !defined(ASN_DISABLE_XER_SUPPORT) */
65 #if !defined(ASN_DISABLE_JER_SUPPORT)
68 #else
69  0,
70  0,
71 #endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
72 #if !defined(ASN_DISABLE_OER_SUPPORT)
75 #else
76  0,
77  0,
78 #endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
79 #if !defined(ASN_DISABLE_UPER_SUPPORT)
82 #else
83  0,
84  0,
85 #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) */
86 #if !defined(ASN_DISABLE_APER_SUPPORT)
89 #else
90  0,
91  0,
92 #endif /* !defined(ASN_DISABLE_APER_SUPPORT) */
93 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
95 #else
96  0,
97 #endif /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
98  0 /* Use generic outmost tag fetcher */
99 };
101  "NumericString",
102  "NumericString",
106  / sizeof(asn_DEF_NumericString_tags[0]) - 1,
109  / sizeof(asn_DEF_NumericString_tags[0]),
110  {
111 #if !defined(ASN_DISABLE_OER_SUPPORT)
112  0,
113 #endif /* !defined(ASN_DISABLE_OER_SUPPORT) */
114 #if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
116 #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
117 #if !defined(ASN_DISABLE_JER_SUPPORT)
118  0,
119 #endif /* !defined(ASN_DISABLE_JER_SUPPORT) */
121  },
122  0, 0, /* No members */
123  0 /* No specifics */
124 };
125 
126 int
128  asn_app_constraint_failed_f *ctfailcb, void *app_key) {
129  const NumericString_t *st = (const NumericString_t *)sptr;
130 
131  if(st && st->buf) {
132  uint8_t *buf = st->buf;
133  uint8_t *end = buf + st->size;
134 
135  /*
136  * Check the alphabet of the NumericString.
137  * ASN.1:1984 (X.409)
138  */
139  for(; buf < end; buf++) {
140  switch(*buf) {
141  case 0x20:
142  case 0x30: case 0x31: case 0x32: case 0x33: case 0x34:
143  case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
144  continue;
145  }
146  ASN__CTFAIL(app_key, td, sptr,
147  "%s: value byte %ld (%d) "
148  "not in NumericString alphabet (%s:%d)",
149  td->name,
150  (long)((buf - st->buf) + 1),
151  *buf,
152  __FILE__, __LINE__);
153  return -1;
154  }
155  } else {
156  ASN__CTFAIL(app_key, td, sptr,
157  "%s: value not given (%s:%d)",
158  td->name, __FILE__, __LINE__);
159  return -1;
160  }
161 
162  return 0;
163 }
NumericString.h
asn_TYPE_operation_s
Definition: constr_TYPE.h:184
OCTET_STRING_free
asn_struct_free_f OCTET_STRING_free
Definition: OCTET_STRING.h:24
asn_app_constraint_failed_f
void() asn_app_constraint_failed_f(void *application_specific_key, const struct asn_TYPE_descriptor_s *type_descriptor_which_failed, const void *structure_which_failed_ptr, const char *error_message_format,...) CC_PRINTFLIKE(4
Definition: asn_application.h:167
ber_tlv_tag_t
unsigned ber_tlv_tag_t
Definition: ber_tlv_tag.h:18
asn_DEF_NumericString_per_constraints
static asn_per_constraints_t asn_DEF_NumericString_per_constraints
Definition: NumericString.c:35
OCTET_STRING_encode_der
der_type_encoder_f OCTET_STRING_encode_der
Definition: OCTET_STRING.h:38
ASN_TAG_CLASS_UNIVERSAL
@ ASN_TAG_CLASS_UNIVERSAL
Definition: ber_tlv_tag.h:13
asn_TYPE_descriptor_s::name
const char * name
Definition: constr_TYPE.h:225
OCTET_STRING_decode_oer
oer_type_decoder_f OCTET_STRING_decode_oer
Definition: OCTET_STRING.h:57
OCTET_STRING::buf
uint8_t * buf
Definition: OCTET_STRING.h:15
OCTET_STRING_encode_aper
per_type_encoder_f OCTET_STRING_encode_aper
Definition: OCTET_STRING.h:67
asn_DEF_NumericString_c2v
static int asn_DEF_NumericString_c2v(unsigned int code)
Definition: NumericString.c:25
asn_TYPE_descriptor_s
Definition: constr_TYPE.h:224
OCTET_STRING_decode_aper
per_type_decoder_f OCTET_STRING_decode_aper
Definition: OCTET_STRING.h:66
NumericString_constraint
int NumericString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key)
Definition: NumericString.c:127
OCTET_STRING_encode_xer_utf8
xer_type_encoder_f OCTET_STRING_encode_xer_utf8
Definition: OCTET_STRING.h:46
asn_OP_NumericString
asn_TYPE_operation_t asn_OP_NumericString
Definition: NumericString.c:42
OCTET_STRING_print_utf8
asn_struct_print_f OCTET_STRING_print_utf8
Definition: OCTET_STRING.h:28
OCTET_STRING_random_fill
asn_random_fill_f OCTET_STRING_random_fill
Definition: OCTET_STRING.h:71
OCTET_STRING
Definition: OCTET_STRING.h:14
OCTET_STRING_encode_oer
oer_type_encoder_f OCTET_STRING_encode_oer
Definition: OCTET_STRING.h:58
asn_internal.h
ASN__CTFAIL
#define ASN__CTFAIL
Definition: constraints.h:57
OCTET_STRING_decode_ber
ber_type_decoder_f OCTET_STRING_decode_ber
Definition: OCTET_STRING.h:37
asn_DEF_NumericString
asn_TYPE_descriptor_t asn_DEF_NumericString
Definition: NumericString.c:100
OCTET_STRING_decode_uper
per_type_decoder_f OCTET_STRING_decode_uper
Definition: OCTET_STRING.h:62
asn_DEF_NumericString_v2c
static int asn_DEF_NumericString_v2c(unsigned int value)
Definition: NumericString.c:16
OCTET_STRING_copy
asn_struct_copy_f OCTET_STRING_copy
Definition: OCTET_STRING.h:32
OCTET_STRING_decode_xer_utf8
xer_type_decoder_f OCTET_STRING_decode_xer_utf8
Definition: OCTET_STRING.h:44
OCTET_STRING_decode_jer_utf8
jer_type_decoder_f OCTET_STRING_decode_jer_utf8
Definition: OCTET_STRING.h:51
asn_per_constraints_s
Definition: per_support.h:30
asn_DEF_NumericString_tags
static const ber_tlv_tag_t asn_DEF_NumericString_tags[]
Definition: NumericString.c:11
OCTET_STRING_encode_uper
per_type_encoder_f OCTET_STRING_encode_uper
Definition: OCTET_STRING.h:63
OCTET_STRING_encode_jer_utf8
jer_type_encoder_f OCTET_STRING_encode_jer_utf8
Definition: OCTET_STRING.h:53
OCTET_STRING_compare
asn_struct_compare_f OCTET_STRING_compare
Definition: OCTET_STRING.h:31
OCTET_STRING::size
size_t size
Definition: OCTET_STRING.h:16


etsi_its_vam_ts_coding
Author(s): Jean-Pierre Busch , Guido Küppers , Lennart Reiher
autogenerated on Sun May 18 2025 02:30:55