vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1 | |
| 2 | /*** <<< INCLUDES [Int1] >>> ***/ |
| 3 | |
| 4 | #include <INTEGER.h> |
| 5 | |
| 6 | /*** <<< TYPE-DECLS [Int1] >>> ***/ |
| 7 | |
| 8 | |
| 9 | typedef INTEGER_t Int1_t; |
| 10 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 11 | /*** <<< FUNC-DECLS [Int1] >>> ***/ |
| 12 | |
| 13 | extern asn1_TYPE_descriptor_t asn1_DEF_Int1; |
| 14 | asn_constr_check_f Int1_constraint; |
| 15 | ber_type_decoder_f Int1_decode_ber; |
| 16 | der_type_encoder_f Int1_encode_der; |
| 17 | asn_struct_print_f Int1_print; |
| 18 | asn_struct_free_f Int1_free; |
| 19 | |
| 20 | /*** <<< CODE [Int1] >>> ***/ |
| 21 | |
| 22 | int |
| 23 | Int1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 24 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 25 | |
| 26 | /* Make the underlying type checker permanent */ |
| 27 | td->check_constraints = asn1_DEF_INTEGER.check_constraints; |
| 28 | return td->check_constraints |
| 29 | (td, sptr, app_errlog, app_key); |
| 30 | } |
| 31 | |
| 32 | /* |
| 33 | * This type is implemented using INTEGER, |
| 34 | * so adjust the DEF appropriately. |
| 35 | */ |
| 36 | static void |
| 37 | Int1_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 38 | td->ber_decoder = asn1_DEF_INTEGER.ber_decoder; |
| 39 | td->der_encoder = asn1_DEF_INTEGER.der_encoder; |
| 40 | td->free_struct = asn1_DEF_INTEGER.free_struct; |
| 41 | td->print_struct = asn1_DEF_INTEGER.print_struct; |
| 42 | td->last_tag_form = asn1_DEF_INTEGER.last_tag_form; |
| 43 | td->elements = asn1_DEF_INTEGER.elements; |
| 44 | td->elements_count = asn1_DEF_INTEGER.elements_count; |
| 45 | td->specifics = asn1_DEF_INTEGER.specifics; |
| 46 | } |
| 47 | |
| 48 | ber_dec_rval_t |
| 49 | Int1_decode_ber(asn1_TYPE_descriptor_t *td, |
| 50 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 51 | Int1_inherit_TYPE_descriptor(td); |
| 52 | return td->ber_decoder(td, structure, |
| 53 | bufptr, size, tag_mode); |
| 54 | } |
| 55 | |
| 56 | der_enc_rval_t |
| 57 | Int1_encode_der(asn1_TYPE_descriptor_t *td, |
| 58 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 59 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 60 | Int1_inherit_TYPE_descriptor(td); |
| 61 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 62 | } |
| 63 | |
| 64 | int |
| 65 | Int1_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 66 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 67 | Int1_inherit_TYPE_descriptor(td); |
| 68 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 69 | } |
| 70 | |
| 71 | void |
| 72 | Int1_free(asn1_TYPE_descriptor_t *td, |
| 73 | void *struct_ptr, int contents_only) { |
| 74 | Int1_inherit_TYPE_descriptor(td); |
| 75 | td->free_struct(td, struct_ptr, contents_only); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /*** <<< STAT-DEFS [Int1] >>> ***/ |
| 80 | |
| 81 | static ber_tlv_tag_t asn1_DEF_Int1_tags[] = { |
| 82 | (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) |
| 83 | }; |
| 84 | asn1_TYPE_descriptor_t asn1_DEF_Int1 = { |
| 85 | "Int1", |
| 86 | Int1_constraint, |
| 87 | Int1_decode_ber, |
| 88 | Int1_encode_der, |
| 89 | Int1_print, |
| 90 | Int1_free, |
| 91 | 0, /* Use generic outmost tag fetcher */ |
| 92 | asn1_DEF_Int1_tags, |
| 93 | sizeof(asn1_DEF_Int1_tags) |
| 94 | /sizeof(asn1_DEF_Int1_tags[0]), /* 1 */ |
| 95 | 1, /* Tags to skip */ |
| 96 | -0, /* Unknown yet */ |
| 97 | 0, 0, /* No members */ |
| 98 | 0 /* No specifics */ |
| 99 | }; |
| 100 | |
| 101 | |
| 102 | /*** <<< INCLUDES [Int2] >>> ***/ |
| 103 | |
| 104 | #include <Int1.h> |
| 105 | |
| 106 | /*** <<< TYPE-DECLS [Int2] >>> ***/ |
| 107 | |
| 108 | |
| 109 | typedef Int1_t Int2_t; |
| 110 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 111 | /*** <<< FUNC-DECLS [Int2] >>> ***/ |
| 112 | |
| 113 | extern asn1_TYPE_descriptor_t asn1_DEF_Int2; |
| 114 | asn_constr_check_f Int2_constraint; |
| 115 | ber_type_decoder_f Int2_decode_ber; |
| 116 | der_type_encoder_f Int2_encode_der; |
| 117 | asn_struct_print_f Int2_print; |
| 118 | asn_struct_free_f Int2_free; |
| 119 | |
| 120 | /*** <<< CODE [Int2] >>> ***/ |
| 121 | |
| 122 | int |
| 123 | Int2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 124 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 125 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 126 | const Int1_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 127 | long value; |
| 128 | |
| 129 | if(!sptr) { |
| 130 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 131 | "%s: value not given (%s:%d)", |
| 132 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 133 | return -1; |
| 134 | } |
| 135 | |
| 136 | if(asn1_INTEGER2long(st, &value)) { |
| 137 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 138 | "%s: value too large (%s:%d)", |
| 139 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 140 | return -1; |
| 141 | } |
| 142 | |
| 143 | if((value >= 0)) { |
| 144 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 145 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 146 | } else { |
| 147 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 148 | "%s: constraint failed (%s:%d)", |
| 149 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 150 | return -1; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | /* |
| 155 | * This type is implemented using Int1, |
| 156 | * so adjust the DEF appropriately. |
| 157 | */ |
| 158 | static void |
| 159 | Int2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 160 | td->ber_decoder = asn1_DEF_Int1.ber_decoder; |
| 161 | td->der_encoder = asn1_DEF_Int1.der_encoder; |
| 162 | td->free_struct = asn1_DEF_Int1.free_struct; |
| 163 | td->print_struct = asn1_DEF_Int1.print_struct; |
| 164 | td->last_tag_form = asn1_DEF_Int1.last_tag_form; |
| 165 | td->elements = asn1_DEF_Int1.elements; |
| 166 | td->elements_count = asn1_DEF_Int1.elements_count; |
| 167 | td->specifics = asn1_DEF_Int1.specifics; |
| 168 | } |
| 169 | |
| 170 | ber_dec_rval_t |
| 171 | Int2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 172 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 173 | Int2_inherit_TYPE_descriptor(td); |
| 174 | return td->ber_decoder(td, structure, |
| 175 | bufptr, size, tag_mode); |
| 176 | } |
| 177 | |
| 178 | der_enc_rval_t |
| 179 | Int2_encode_der(asn1_TYPE_descriptor_t *td, |
| 180 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 181 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 182 | Int2_inherit_TYPE_descriptor(td); |
| 183 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 184 | } |
| 185 | |
| 186 | int |
| 187 | Int2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 188 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 189 | Int2_inherit_TYPE_descriptor(td); |
| 190 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 191 | } |
| 192 | |
| 193 | void |
| 194 | Int2_free(asn1_TYPE_descriptor_t *td, |
| 195 | void *struct_ptr, int contents_only) { |
| 196 | Int2_inherit_TYPE_descriptor(td); |
| 197 | td->free_struct(td, struct_ptr, contents_only); |
| 198 | } |
| 199 | |
| 200 | |
| 201 | /*** <<< STAT-DEFS [Int2] >>> ***/ |
| 202 | |
| 203 | static ber_tlv_tag_t asn1_DEF_Int2_tags[] = { |
| 204 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 205 | }; |
| 206 | asn1_TYPE_descriptor_t asn1_DEF_Int2 = { |
| 207 | "Int2", |
| 208 | Int2_constraint, |
| 209 | Int2_decode_ber, |
| 210 | Int2_encode_der, |
| 211 | Int2_print, |
| 212 | Int2_free, |
| 213 | 0, /* Use generic outmost tag fetcher */ |
| 214 | asn1_DEF_Int2_tags, |
| 215 | sizeof(asn1_DEF_Int2_tags) |
| 216 | /sizeof(asn1_DEF_Int2_tags[0]), /* 1 */ |
| 217 | 1, /* Tags to skip */ |
| 218 | -0, /* Unknown yet */ |
| 219 | 0, 0, /* No members */ |
| 220 | 0 /* No specifics */ |
| 221 | }; |
| 222 | |
| 223 | |
| 224 | /*** <<< INCLUDES [Int3] >>> ***/ |
| 225 | |
| 226 | #include <Int2.h> |
| 227 | |
| 228 | /*** <<< TYPE-DECLS [Int3] >>> ***/ |
| 229 | |
| 230 | |
| 231 | typedef Int2_t Int3_t; |
| 232 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 233 | /*** <<< FUNC-DECLS [Int3] >>> ***/ |
| 234 | |
| 235 | extern asn1_TYPE_descriptor_t asn1_DEF_Int3; |
| 236 | asn_constr_check_f Int3_constraint; |
| 237 | ber_type_decoder_f Int3_decode_ber; |
| 238 | der_type_encoder_f Int3_encode_der; |
| 239 | asn_struct_print_f Int3_print; |
| 240 | asn_struct_free_f Int3_free; |
| 241 | |
| 242 | /*** <<< CODE [Int3] >>> ***/ |
| 243 | |
| 244 | int |
| 245 | Int3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 246 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 247 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 248 | const Int2_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 249 | long value; |
| 250 | |
| 251 | if(!sptr) { |
| 252 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 253 | "%s: value not given (%s:%d)", |
| 254 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 255 | return -1; |
| 256 | } |
| 257 | |
| 258 | if(asn1_INTEGER2long(st, &value)) { |
| 259 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 260 | "%s: value too large (%s:%d)", |
| 261 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 262 | return -1; |
| 263 | } |
| 264 | |
| 265 | if((value >= 0 && value <= 10)) { |
| 266 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 267 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 268 | } else { |
| 269 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 270 | "%s: constraint failed (%s:%d)", |
| 271 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 272 | return -1; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | /* |
| 277 | * This type is implemented using Int2, |
| 278 | * so adjust the DEF appropriately. |
| 279 | */ |
| 280 | static void |
| 281 | Int3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 282 | td->ber_decoder = asn1_DEF_Int2.ber_decoder; |
| 283 | td->der_encoder = asn1_DEF_Int2.der_encoder; |
| 284 | td->free_struct = asn1_DEF_Int2.free_struct; |
| 285 | td->print_struct = asn1_DEF_Int2.print_struct; |
| 286 | td->last_tag_form = asn1_DEF_Int2.last_tag_form; |
| 287 | td->elements = asn1_DEF_Int2.elements; |
| 288 | td->elements_count = asn1_DEF_Int2.elements_count; |
| 289 | td->specifics = asn1_DEF_Int2.specifics; |
| 290 | } |
| 291 | |
| 292 | ber_dec_rval_t |
| 293 | Int3_decode_ber(asn1_TYPE_descriptor_t *td, |
| 294 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 295 | Int3_inherit_TYPE_descriptor(td); |
| 296 | return td->ber_decoder(td, structure, |
| 297 | bufptr, size, tag_mode); |
| 298 | } |
| 299 | |
| 300 | der_enc_rval_t |
| 301 | Int3_encode_der(asn1_TYPE_descriptor_t *td, |
| 302 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 303 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 304 | Int3_inherit_TYPE_descriptor(td); |
| 305 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 306 | } |
| 307 | |
| 308 | int |
| 309 | Int3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 310 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 311 | Int3_inherit_TYPE_descriptor(td); |
| 312 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 313 | } |
| 314 | |
| 315 | void |
| 316 | Int3_free(asn1_TYPE_descriptor_t *td, |
| 317 | void *struct_ptr, int contents_only) { |
| 318 | Int3_inherit_TYPE_descriptor(td); |
| 319 | td->free_struct(td, struct_ptr, contents_only); |
| 320 | } |
| 321 | |
| 322 | |
| 323 | /*** <<< STAT-DEFS [Int3] >>> ***/ |
| 324 | |
| 325 | static ber_tlv_tag_t asn1_DEF_Int3_tags[] = { |
| 326 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 327 | }; |
| 328 | asn1_TYPE_descriptor_t asn1_DEF_Int3 = { |
| 329 | "Int3", |
| 330 | Int3_constraint, |
| 331 | Int3_decode_ber, |
| 332 | Int3_encode_der, |
| 333 | Int3_print, |
| 334 | Int3_free, |
| 335 | 0, /* Use generic outmost tag fetcher */ |
| 336 | asn1_DEF_Int3_tags, |
| 337 | sizeof(asn1_DEF_Int3_tags) |
| 338 | /sizeof(asn1_DEF_Int3_tags[0]), /* 1 */ |
| 339 | 1, /* Tags to skip */ |
| 340 | -0, /* Unknown yet */ |
| 341 | 0, 0, /* No members */ |
| 342 | 0 /* No specifics */ |
| 343 | }; |
| 344 | |
| 345 | |
| 346 | /*** <<< INCLUDES [Int4] >>> ***/ |
| 347 | |
| 348 | #include <Int3.h> |
| 349 | |
| 350 | /*** <<< TYPE-DECLS [Int4] >>> ***/ |
| 351 | |
| 352 | |
| 353 | typedef Int3_t Int4_t; |
| 354 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 355 | /*** <<< FUNC-DECLS [Int4] >>> ***/ |
| 356 | |
| 357 | extern asn1_TYPE_descriptor_t asn1_DEF_Int4; |
| 358 | asn_constr_check_f Int4_constraint; |
| 359 | ber_type_decoder_f Int4_decode_ber; |
| 360 | der_type_encoder_f Int4_encode_der; |
| 361 | asn_struct_print_f Int4_print; |
| 362 | asn_struct_free_f Int4_free; |
| 363 | |
| 364 | /*** <<< CODE [Int4] >>> ***/ |
| 365 | |
| 366 | int |
| 367 | Int4_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 368 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 369 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 370 | const Int3_t *st = sptr; |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 371 | long value; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 372 | |
| 373 | if(!sptr) { |
| 374 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 375 | "%s: value not given (%s:%d)", |
| 376 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 377 | return -1; |
| 378 | } |
| 379 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 380 | if(asn1_INTEGER2long(st, &value)) { |
| 381 | _ASN_ERRLOG(app_errlog, app_key, |
| 382 | "%s: value too large (%s:%d)", |
| 383 | td->name, __FILE__, __LINE__); |
| 384 | return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 385 | } |
| 386 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 387 | if((value >= 1 && value <= 10)) { |
| 388 | /* Constraint check succeeded */ |
| 389 | return 0; |
| 390 | } else { |
| 391 | _ASN_ERRLOG(app_errlog, app_key, |
| 392 | "%s: constraint failed (%s:%d)", |
| 393 | td->name, __FILE__, __LINE__); |
| 394 | return -1; |
| 395 | } |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | /* |
| 399 | * This type is implemented using Int3, |
| 400 | * so adjust the DEF appropriately. |
| 401 | */ |
| 402 | static void |
| 403 | Int4_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 404 | td->ber_decoder = asn1_DEF_Int3.ber_decoder; |
| 405 | td->der_encoder = asn1_DEF_Int3.der_encoder; |
| 406 | td->free_struct = asn1_DEF_Int3.free_struct; |
| 407 | td->print_struct = asn1_DEF_Int3.print_struct; |
| 408 | td->last_tag_form = asn1_DEF_Int3.last_tag_form; |
| 409 | td->elements = asn1_DEF_Int3.elements; |
| 410 | td->elements_count = asn1_DEF_Int3.elements_count; |
| 411 | td->specifics = asn1_DEF_Int3.specifics; |
| 412 | } |
| 413 | |
| 414 | ber_dec_rval_t |
| 415 | Int4_decode_ber(asn1_TYPE_descriptor_t *td, |
| 416 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 417 | Int4_inherit_TYPE_descriptor(td); |
| 418 | return td->ber_decoder(td, structure, |
| 419 | bufptr, size, tag_mode); |
| 420 | } |
| 421 | |
| 422 | der_enc_rval_t |
| 423 | Int4_encode_der(asn1_TYPE_descriptor_t *td, |
| 424 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 425 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 426 | Int4_inherit_TYPE_descriptor(td); |
| 427 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 428 | } |
| 429 | |
| 430 | int |
| 431 | Int4_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 432 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 433 | Int4_inherit_TYPE_descriptor(td); |
| 434 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 435 | } |
| 436 | |
| 437 | void |
| 438 | Int4_free(asn1_TYPE_descriptor_t *td, |
| 439 | void *struct_ptr, int contents_only) { |
| 440 | Int4_inherit_TYPE_descriptor(td); |
| 441 | td->free_struct(td, struct_ptr, contents_only); |
| 442 | } |
| 443 | |
| 444 | |
| 445 | /*** <<< STAT-DEFS [Int4] >>> ***/ |
| 446 | |
| 447 | static ber_tlv_tag_t asn1_DEF_Int4_tags[] = { |
| 448 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 449 | }; |
| 450 | asn1_TYPE_descriptor_t asn1_DEF_Int4 = { |
| 451 | "Int4", |
| 452 | Int4_constraint, |
| 453 | Int4_decode_ber, |
| 454 | Int4_encode_der, |
| 455 | Int4_print, |
| 456 | Int4_free, |
| 457 | 0, /* Use generic outmost tag fetcher */ |
| 458 | asn1_DEF_Int4_tags, |
| 459 | sizeof(asn1_DEF_Int4_tags) |
| 460 | /sizeof(asn1_DEF_Int4_tags[0]), /* 1 */ |
| 461 | 1, /* Tags to skip */ |
| 462 | -0, /* Unknown yet */ |
| 463 | 0, 0, /* No members */ |
| 464 | 0 /* No specifics */ |
| 465 | }; |
| 466 | |
| 467 | |
| 468 | /*** <<< INCLUDES [Int5] >>> ***/ |
| 469 | |
| 470 | #include <Int4.h> |
| 471 | |
| 472 | /*** <<< TYPE-DECLS [Int5] >>> ***/ |
| 473 | |
| 474 | |
| 475 | typedef Int4_t Int5_t; |
| 476 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 477 | /*** <<< FUNC-DECLS [Int5] >>> ***/ |
| 478 | |
| 479 | extern asn1_TYPE_descriptor_t asn1_DEF_Int5; |
| 480 | asn_constr_check_f Int5_constraint; |
| 481 | ber_type_decoder_f Int5_decode_ber; |
| 482 | der_type_encoder_f Int5_encode_der; |
| 483 | asn_struct_print_f Int5_print; |
| 484 | asn_struct_free_f Int5_free; |
| 485 | |
| 486 | /*** <<< CODE [Int5] >>> ***/ |
| 487 | |
| 488 | int |
| 489 | Int5_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 490 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 491 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 492 | const Int4_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 493 | long value; |
| 494 | |
| 495 | if(!sptr) { |
| 496 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 497 | "%s: value not given (%s:%d)", |
| 498 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 499 | return -1; |
| 500 | } |
| 501 | |
| 502 | if(asn1_INTEGER2long(st, &value)) { |
| 503 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 504 | "%s: value too large (%s:%d)", |
| 505 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 506 | return -1; |
| 507 | } |
| 508 | |
| 509 | if((value == 5)) { |
| 510 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 511 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 512 | } else { |
| 513 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 514 | "%s: constraint failed (%s:%d)", |
| 515 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 516 | return -1; |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | /* |
| 521 | * This type is implemented using Int4, |
| 522 | * so adjust the DEF appropriately. |
| 523 | */ |
| 524 | static void |
| 525 | Int5_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 526 | td->ber_decoder = asn1_DEF_Int4.ber_decoder; |
| 527 | td->der_encoder = asn1_DEF_Int4.der_encoder; |
| 528 | td->free_struct = asn1_DEF_Int4.free_struct; |
| 529 | td->print_struct = asn1_DEF_Int4.print_struct; |
| 530 | td->last_tag_form = asn1_DEF_Int4.last_tag_form; |
| 531 | td->elements = asn1_DEF_Int4.elements; |
| 532 | td->elements_count = asn1_DEF_Int4.elements_count; |
| 533 | td->specifics = asn1_DEF_Int4.specifics; |
| 534 | } |
| 535 | |
| 536 | ber_dec_rval_t |
| 537 | Int5_decode_ber(asn1_TYPE_descriptor_t *td, |
| 538 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 539 | Int5_inherit_TYPE_descriptor(td); |
| 540 | return td->ber_decoder(td, structure, |
| 541 | bufptr, size, tag_mode); |
| 542 | } |
| 543 | |
| 544 | der_enc_rval_t |
| 545 | Int5_encode_der(asn1_TYPE_descriptor_t *td, |
| 546 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 547 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 548 | Int5_inherit_TYPE_descriptor(td); |
| 549 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 550 | } |
| 551 | |
| 552 | int |
| 553 | Int5_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 554 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 555 | Int5_inherit_TYPE_descriptor(td); |
| 556 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 557 | } |
| 558 | |
| 559 | void |
| 560 | Int5_free(asn1_TYPE_descriptor_t *td, |
| 561 | void *struct_ptr, int contents_only) { |
| 562 | Int5_inherit_TYPE_descriptor(td); |
| 563 | td->free_struct(td, struct_ptr, contents_only); |
| 564 | } |
| 565 | |
| 566 | |
| 567 | /*** <<< STAT-DEFS [Int5] >>> ***/ |
| 568 | |
| 569 | static ber_tlv_tag_t asn1_DEF_Int5_tags[] = { |
| 570 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 571 | }; |
| 572 | asn1_TYPE_descriptor_t asn1_DEF_Int5 = { |
| 573 | "Int5", |
| 574 | Int5_constraint, |
| 575 | Int5_decode_ber, |
| 576 | Int5_encode_der, |
| 577 | Int5_print, |
| 578 | Int5_free, |
| 579 | 0, /* Use generic outmost tag fetcher */ |
| 580 | asn1_DEF_Int5_tags, |
| 581 | sizeof(asn1_DEF_Int5_tags) |
| 582 | /sizeof(asn1_DEF_Int5_tags[0]), /* 1 */ |
| 583 | 1, /* Tags to skip */ |
| 584 | -0, /* Unknown yet */ |
| 585 | 0, 0, /* No members */ |
| 586 | 0 /* No specifics */ |
| 587 | }; |
| 588 | |
| 589 | |
| 590 | /*** <<< INCLUDES [ExtensibleExtensions] >>> ***/ |
| 591 | |
| 592 | #include <INTEGER.h> |
| 593 | |
| 594 | /*** <<< TYPE-DECLS [ExtensibleExtensions] >>> ***/ |
| 595 | |
| 596 | |
| 597 | typedef INTEGER_t ExtensibleExtensions_t; |
| 598 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 599 | /*** <<< FUNC-DECLS [ExtensibleExtensions] >>> ***/ |
| 600 | |
| 601 | extern asn1_TYPE_descriptor_t asn1_DEF_ExtensibleExtensions; |
| 602 | asn_constr_check_f ExtensibleExtensions_constraint; |
| 603 | ber_type_decoder_f ExtensibleExtensions_decode_ber; |
| 604 | der_type_encoder_f ExtensibleExtensions_encode_der; |
| 605 | asn_struct_print_f ExtensibleExtensions_print; |
| 606 | asn_struct_free_f ExtensibleExtensions_free; |
| 607 | |
| 608 | /*** <<< CODE [ExtensibleExtensions] >>> ***/ |
| 609 | |
| 610 | int |
| 611 | ExtensibleExtensions_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 612 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 613 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 614 | const INTEGER_t *st = sptr; |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 615 | long value; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 616 | |
| 617 | if(!sptr) { |
| 618 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 619 | "%s: value not given (%s:%d)", |
| 620 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 621 | return -1; |
| 622 | } |
| 623 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 624 | if(asn1_INTEGER2long(st, &value)) { |
| 625 | _ASN_ERRLOG(app_errlog, app_key, |
| 626 | "%s: value too large (%s:%d)", |
| 627 | td->name, __FILE__, __LINE__); |
| 628 | return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 629 | } |
| 630 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 631 | if((value >= 1 && value <= 256)) { |
| 632 | /* Constraint check succeeded */ |
| 633 | return 0; |
| 634 | } else { |
| 635 | _ASN_ERRLOG(app_errlog, app_key, |
| 636 | "%s: constraint failed (%s:%d)", |
| 637 | td->name, __FILE__, __LINE__); |
| 638 | return -1; |
| 639 | } |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | /* |
| 643 | * This type is implemented using INTEGER, |
| 644 | * so adjust the DEF appropriately. |
| 645 | */ |
| 646 | static void |
| 647 | ExtensibleExtensions_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 648 | td->ber_decoder = asn1_DEF_INTEGER.ber_decoder; |
| 649 | td->der_encoder = asn1_DEF_INTEGER.der_encoder; |
| 650 | td->free_struct = asn1_DEF_INTEGER.free_struct; |
| 651 | td->print_struct = asn1_DEF_INTEGER.print_struct; |
| 652 | td->last_tag_form = asn1_DEF_INTEGER.last_tag_form; |
| 653 | td->elements = asn1_DEF_INTEGER.elements; |
| 654 | td->elements_count = asn1_DEF_INTEGER.elements_count; |
| 655 | td->specifics = asn1_DEF_INTEGER.specifics; |
| 656 | } |
| 657 | |
| 658 | ber_dec_rval_t |
| 659 | ExtensibleExtensions_decode_ber(asn1_TYPE_descriptor_t *td, |
| 660 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 661 | ExtensibleExtensions_inherit_TYPE_descriptor(td); |
| 662 | return td->ber_decoder(td, structure, |
| 663 | bufptr, size, tag_mode); |
| 664 | } |
| 665 | |
| 666 | der_enc_rval_t |
| 667 | ExtensibleExtensions_encode_der(asn1_TYPE_descriptor_t *td, |
| 668 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 669 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 670 | ExtensibleExtensions_inherit_TYPE_descriptor(td); |
| 671 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 672 | } |
| 673 | |
| 674 | int |
| 675 | ExtensibleExtensions_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 676 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 677 | ExtensibleExtensions_inherit_TYPE_descriptor(td); |
| 678 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 679 | } |
| 680 | |
| 681 | void |
| 682 | ExtensibleExtensions_free(asn1_TYPE_descriptor_t *td, |
| 683 | void *struct_ptr, int contents_only) { |
| 684 | ExtensibleExtensions_inherit_TYPE_descriptor(td); |
| 685 | td->free_struct(td, struct_ptr, contents_only); |
| 686 | } |
| 687 | |
| 688 | |
| 689 | /*** <<< STAT-DEFS [ExtensibleExtensions] >>> ***/ |
| 690 | |
| 691 | static ber_tlv_tag_t asn1_DEF_ExtensibleExtensions_tags[] = { |
| 692 | (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) |
| 693 | }; |
| 694 | asn1_TYPE_descriptor_t asn1_DEF_ExtensibleExtensions = { |
| 695 | "ExtensibleExtensions", |
| 696 | ExtensibleExtensions_constraint, |
| 697 | ExtensibleExtensions_decode_ber, |
| 698 | ExtensibleExtensions_encode_der, |
| 699 | ExtensibleExtensions_print, |
| 700 | ExtensibleExtensions_free, |
| 701 | 0, /* Use generic outmost tag fetcher */ |
| 702 | asn1_DEF_ExtensibleExtensions_tags, |
| 703 | sizeof(asn1_DEF_ExtensibleExtensions_tags) |
| 704 | /sizeof(asn1_DEF_ExtensibleExtensions_tags[0]), /* 1 */ |
| 705 | 1, /* Tags to skip */ |
| 706 | -0, /* Unknown yet */ |
| 707 | 0, 0, /* No members */ |
| 708 | 0 /* No specifics */ |
| 709 | }; |
| 710 | |
| 711 | |
| 712 | /*** <<< INCLUDES [Str1] >>> ***/ |
| 713 | |
| 714 | #include <IA5String.h> |
| 715 | |
| 716 | /*** <<< TYPE-DECLS [Str1] >>> ***/ |
| 717 | |
| 718 | |
| 719 | typedef IA5String_t Str1_t; |
| 720 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 721 | /*** <<< FUNC-DECLS [Str1] >>> ***/ |
| 722 | |
| 723 | extern asn1_TYPE_descriptor_t asn1_DEF_Str1; |
| 724 | asn_constr_check_f Str1_constraint; |
| 725 | ber_type_decoder_f Str1_decode_ber; |
| 726 | der_type_encoder_f Str1_encode_der; |
| 727 | asn_struct_print_f Str1_print; |
| 728 | asn_struct_free_f Str1_free; |
| 729 | |
| 730 | /*** <<< CODE [Str1] >>> ***/ |
| 731 | |
| 732 | int |
| 733 | Str1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 734 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 735 | |
| 736 | /* Make the underlying type checker permanent */ |
| 737 | td->check_constraints = asn1_DEF_IA5String.check_constraints; |
| 738 | return td->check_constraints |
| 739 | (td, sptr, app_errlog, app_key); |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | * This type is implemented using IA5String, |
| 744 | * so adjust the DEF appropriately. |
| 745 | */ |
| 746 | static void |
| 747 | Str1_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 748 | td->ber_decoder = asn1_DEF_IA5String.ber_decoder; |
| 749 | td->der_encoder = asn1_DEF_IA5String.der_encoder; |
| 750 | td->free_struct = asn1_DEF_IA5String.free_struct; |
| 751 | td->print_struct = asn1_DEF_IA5String.print_struct; |
| 752 | td->last_tag_form = asn1_DEF_IA5String.last_tag_form; |
| 753 | td->elements = asn1_DEF_IA5String.elements; |
| 754 | td->elements_count = asn1_DEF_IA5String.elements_count; |
| 755 | td->specifics = asn1_DEF_IA5String.specifics; |
| 756 | } |
| 757 | |
| 758 | ber_dec_rval_t |
| 759 | Str1_decode_ber(asn1_TYPE_descriptor_t *td, |
| 760 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 761 | Str1_inherit_TYPE_descriptor(td); |
| 762 | return td->ber_decoder(td, structure, |
| 763 | bufptr, size, tag_mode); |
| 764 | } |
| 765 | |
| 766 | der_enc_rval_t |
| 767 | Str1_encode_der(asn1_TYPE_descriptor_t *td, |
| 768 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 769 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 770 | Str1_inherit_TYPE_descriptor(td); |
| 771 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 772 | } |
| 773 | |
| 774 | int |
| 775 | Str1_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 776 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 777 | Str1_inherit_TYPE_descriptor(td); |
| 778 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 779 | } |
| 780 | |
| 781 | void |
| 782 | Str1_free(asn1_TYPE_descriptor_t *td, |
| 783 | void *struct_ptr, int contents_only) { |
| 784 | Str1_inherit_TYPE_descriptor(td); |
| 785 | td->free_struct(td, struct_ptr, contents_only); |
| 786 | } |
| 787 | |
| 788 | |
| 789 | /*** <<< STAT-DEFS [Str1] >>> ***/ |
| 790 | |
| 791 | static ber_tlv_tag_t asn1_DEF_Str1_tags[] = { |
| 792 | (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)) |
| 793 | }; |
| 794 | asn1_TYPE_descriptor_t asn1_DEF_Str1 = { |
| 795 | "Str1", |
| 796 | Str1_constraint, |
| 797 | Str1_decode_ber, |
| 798 | Str1_encode_der, |
| 799 | Str1_print, |
| 800 | Str1_free, |
| 801 | 0, /* Use generic outmost tag fetcher */ |
| 802 | asn1_DEF_Str1_tags, |
| 803 | sizeof(asn1_DEF_Str1_tags) |
| 804 | /sizeof(asn1_DEF_Str1_tags[0]), /* 1 */ |
| 805 | 1, /* Tags to skip */ |
| 806 | -0, /* Unknown yet */ |
| 807 | 0, 0, /* No members */ |
| 808 | 0 /* No specifics */ |
| 809 | }; |
| 810 | |
| 811 | |
| 812 | /*** <<< INCLUDES [Str2] >>> ***/ |
| 813 | |
| 814 | #include <Str1.h> |
| 815 | |
| 816 | /*** <<< TYPE-DECLS [Str2] >>> ***/ |
| 817 | |
| 818 | |
| 819 | typedef Str1_t Str2_t; |
| 820 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 821 | /*** <<< FUNC-DECLS [Str2] >>> ***/ |
| 822 | |
| 823 | extern asn1_TYPE_descriptor_t asn1_DEF_Str2; |
| 824 | asn_constr_check_f Str2_constraint; |
| 825 | ber_type_decoder_f Str2_decode_ber; |
| 826 | der_type_encoder_f Str2_encode_der; |
| 827 | asn_struct_print_f Str2_print; |
| 828 | asn_struct_free_f Str2_free; |
| 829 | |
| 830 | /*** <<< CTABLES [Str2] >>> ***/ |
| 831 | |
| 832 | static int check_permitted_alphabet_1(const void *sptr) { |
| 833 | /* The underlying type is IA5String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 834 | const IA5String_t *st = sptr; |
| 835 | const uint8_t *ch = st->buf; |
| 836 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 837 | |
| 838 | for(; ch < end; ch++) { |
| 839 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 840 | if(!(cv <= 127)) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 841 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 842 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | |
| 846 | /*** <<< CODE [Str2] >>> ***/ |
| 847 | |
| 848 | int |
| 849 | Str2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 850 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 851 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 852 | const Str1_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 853 | size_t size; |
| 854 | |
| 855 | if(!sptr) { |
| 856 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 857 | "%s: value not given (%s:%d)", |
| 858 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 859 | return -1; |
| 860 | } |
| 861 | |
| 862 | size = st->size; |
| 863 | |
| 864 | if(((size <= 20) || (size >= 25 && size <= 30)) |
vlm | 7e20dfc | 2004-08-22 13:11:40 +0000 | [diff] [blame] | 865 | && !check_permitted_alphabet_1(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 866 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 867 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 868 | } else { |
| 869 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 870 | "%s: constraint failed (%s:%d)", |
| 871 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 872 | return -1; |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | /* |
| 877 | * This type is implemented using Str1, |
| 878 | * so adjust the DEF appropriately. |
| 879 | */ |
| 880 | static void |
| 881 | Str2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 882 | td->ber_decoder = asn1_DEF_Str1.ber_decoder; |
| 883 | td->der_encoder = asn1_DEF_Str1.der_encoder; |
| 884 | td->free_struct = asn1_DEF_Str1.free_struct; |
| 885 | td->print_struct = asn1_DEF_Str1.print_struct; |
| 886 | td->last_tag_form = asn1_DEF_Str1.last_tag_form; |
| 887 | td->elements = asn1_DEF_Str1.elements; |
| 888 | td->elements_count = asn1_DEF_Str1.elements_count; |
| 889 | td->specifics = asn1_DEF_Str1.specifics; |
| 890 | } |
| 891 | |
| 892 | ber_dec_rval_t |
| 893 | Str2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 894 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 895 | Str2_inherit_TYPE_descriptor(td); |
| 896 | return td->ber_decoder(td, structure, |
| 897 | bufptr, size, tag_mode); |
| 898 | } |
| 899 | |
| 900 | der_enc_rval_t |
| 901 | Str2_encode_der(asn1_TYPE_descriptor_t *td, |
| 902 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 903 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 904 | Str2_inherit_TYPE_descriptor(td); |
| 905 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 906 | } |
| 907 | |
| 908 | int |
| 909 | Str2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 910 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 911 | Str2_inherit_TYPE_descriptor(td); |
| 912 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 913 | } |
| 914 | |
| 915 | void |
| 916 | Str2_free(asn1_TYPE_descriptor_t *td, |
| 917 | void *struct_ptr, int contents_only) { |
| 918 | Str2_inherit_TYPE_descriptor(td); |
| 919 | td->free_struct(td, struct_ptr, contents_only); |
| 920 | } |
| 921 | |
| 922 | |
| 923 | /*** <<< STAT-DEFS [Str2] >>> ***/ |
| 924 | |
| 925 | static ber_tlv_tag_t asn1_DEF_Str2_tags[] = { |
| 926 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 927 | }; |
| 928 | asn1_TYPE_descriptor_t asn1_DEF_Str2 = { |
| 929 | "Str2", |
| 930 | Str2_constraint, |
| 931 | Str2_decode_ber, |
| 932 | Str2_encode_der, |
| 933 | Str2_print, |
| 934 | Str2_free, |
| 935 | 0, /* Use generic outmost tag fetcher */ |
| 936 | asn1_DEF_Str2_tags, |
| 937 | sizeof(asn1_DEF_Str2_tags) |
| 938 | /sizeof(asn1_DEF_Str2_tags[0]), /* 1 */ |
| 939 | 1, /* Tags to skip */ |
| 940 | -0, /* Unknown yet */ |
| 941 | 0, 0, /* No members */ |
| 942 | 0 /* No specifics */ |
| 943 | }; |
| 944 | |
| 945 | |
| 946 | /*** <<< INCLUDES [Str3] >>> ***/ |
| 947 | |
| 948 | #include <Str2.h> |
| 949 | |
| 950 | /*** <<< TYPE-DECLS [Str3] >>> ***/ |
| 951 | |
| 952 | |
| 953 | typedef Str2_t Str3_t; |
| 954 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 955 | /*** <<< FUNC-DECLS [Str3] >>> ***/ |
| 956 | |
| 957 | extern asn1_TYPE_descriptor_t asn1_DEF_Str3; |
| 958 | asn_constr_check_f Str3_constraint; |
| 959 | ber_type_decoder_f Str3_decode_ber; |
| 960 | der_type_encoder_f Str3_encode_der; |
| 961 | asn_struct_print_f Str3_print; |
| 962 | asn_struct_free_f Str3_free; |
| 963 | |
| 964 | /*** <<< CTABLES [Str3] >>> ***/ |
| 965 | |
| 966 | static int permitted_alphabet_table_2[256] = { |
| 967 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 968 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 969 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 970 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 971 | 0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, /* ABC */ |
| 972 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 973 | 0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0, /* def */ |
| 974 | }; |
| 975 | |
| 976 | static int check_permitted_alphabet_2(const void *sptr) { |
| 977 | int *table = permitted_alphabet_table_2; |
| 978 | /* The underlying type is IA5String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 979 | const IA5String_t *st = sptr; |
| 980 | const uint8_t *ch = st->buf; |
| 981 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 982 | |
| 983 | for(; ch < end; ch++) { |
| 984 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 985 | if(!table[cv]) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 986 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 987 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 988 | } |
| 989 | |
| 990 | |
| 991 | /*** <<< CODE [Str3] >>> ***/ |
| 992 | |
| 993 | int |
| 994 | Str3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 995 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 996 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 997 | const Str2_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 998 | size_t size; |
| 999 | |
| 1000 | if(!sptr) { |
| 1001 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1002 | "%s: value not given (%s:%d)", |
| 1003 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1004 | return -1; |
| 1005 | } |
| 1006 | |
| 1007 | size = st->size; |
| 1008 | |
| 1009 | if(((size >= 10 && size <= 20) || (size >= 25 && size <= 27)) |
vlm | 7e20dfc | 2004-08-22 13:11:40 +0000 | [diff] [blame] | 1010 | && !check_permitted_alphabet_2(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1011 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1012 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1013 | } else { |
| 1014 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1015 | "%s: constraint failed (%s:%d)", |
| 1016 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1017 | return -1; |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | /* |
| 1022 | * This type is implemented using Str2, |
| 1023 | * so adjust the DEF appropriately. |
| 1024 | */ |
| 1025 | static void |
| 1026 | Str3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1027 | td->ber_decoder = asn1_DEF_Str2.ber_decoder; |
| 1028 | td->der_encoder = asn1_DEF_Str2.der_encoder; |
| 1029 | td->free_struct = asn1_DEF_Str2.free_struct; |
| 1030 | td->print_struct = asn1_DEF_Str2.print_struct; |
| 1031 | td->last_tag_form = asn1_DEF_Str2.last_tag_form; |
| 1032 | td->elements = asn1_DEF_Str2.elements; |
| 1033 | td->elements_count = asn1_DEF_Str2.elements_count; |
| 1034 | td->specifics = asn1_DEF_Str2.specifics; |
| 1035 | } |
| 1036 | |
| 1037 | ber_dec_rval_t |
| 1038 | Str3_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1039 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1040 | Str3_inherit_TYPE_descriptor(td); |
| 1041 | return td->ber_decoder(td, structure, |
| 1042 | bufptr, size, tag_mode); |
| 1043 | } |
| 1044 | |
| 1045 | der_enc_rval_t |
| 1046 | Str3_encode_der(asn1_TYPE_descriptor_t *td, |
| 1047 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1048 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1049 | Str3_inherit_TYPE_descriptor(td); |
| 1050 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1051 | } |
| 1052 | |
| 1053 | int |
| 1054 | Str3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1055 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1056 | Str3_inherit_TYPE_descriptor(td); |
| 1057 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1058 | } |
| 1059 | |
| 1060 | void |
| 1061 | Str3_free(asn1_TYPE_descriptor_t *td, |
| 1062 | void *struct_ptr, int contents_only) { |
| 1063 | Str3_inherit_TYPE_descriptor(td); |
| 1064 | td->free_struct(td, struct_ptr, contents_only); |
| 1065 | } |
| 1066 | |
| 1067 | |
| 1068 | /*** <<< STAT-DEFS [Str3] >>> ***/ |
| 1069 | |
| 1070 | static ber_tlv_tag_t asn1_DEF_Str3_tags[] = { |
| 1071 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1072 | }; |
| 1073 | asn1_TYPE_descriptor_t asn1_DEF_Str3 = { |
| 1074 | "Str3", |
| 1075 | Str3_constraint, |
| 1076 | Str3_decode_ber, |
| 1077 | Str3_encode_der, |
| 1078 | Str3_print, |
| 1079 | Str3_free, |
| 1080 | 0, /* Use generic outmost tag fetcher */ |
| 1081 | asn1_DEF_Str3_tags, |
| 1082 | sizeof(asn1_DEF_Str3_tags) |
| 1083 | /sizeof(asn1_DEF_Str3_tags[0]), /* 1 */ |
| 1084 | 1, /* Tags to skip */ |
| 1085 | -0, /* Unknown yet */ |
| 1086 | 0, 0, /* No members */ |
| 1087 | 0 /* No specifics */ |
| 1088 | }; |
| 1089 | |
| 1090 | |
| 1091 | /*** <<< INCLUDES [PER-Visible] >>> ***/ |
| 1092 | |
| 1093 | #include <IA5String.h> |
| 1094 | |
| 1095 | /*** <<< TYPE-DECLS [PER-Visible] >>> ***/ |
| 1096 | |
| 1097 | |
| 1098 | typedef IA5String_t PER_Visible_t; |
| 1099 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1100 | /*** <<< FUNC-DECLS [PER-Visible] >>> ***/ |
| 1101 | |
| 1102 | extern asn1_TYPE_descriptor_t asn1_DEF_PER_Visible; |
| 1103 | asn_constr_check_f PER_Visible_constraint; |
| 1104 | ber_type_decoder_f PER_Visible_decode_ber; |
| 1105 | der_type_encoder_f PER_Visible_encode_der; |
| 1106 | asn_struct_print_f PER_Visible_print; |
| 1107 | asn_struct_free_f PER_Visible_free; |
| 1108 | |
| 1109 | /*** <<< CTABLES [PER-Visible] >>> ***/ |
| 1110 | |
| 1111 | static int check_permitted_alphabet_3(const void *sptr) { |
| 1112 | /* The underlying type is IA5String */ |
vlm | 4fdaead | 2004-08-21 07:34:17 +0000 | [diff] [blame] | 1113 | const IA5String_t *st = sptr; |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1114 | const uint8_t *ch = st->buf; |
| 1115 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1116 | |
| 1117 | for(; ch < end; ch++) { |
| 1118 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1119 | if(!(cv >= 65 && cv <= 70)) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1120 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1121 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1122 | } |
| 1123 | |
| 1124 | |
| 1125 | /*** <<< CODE [PER-Visible] >>> ***/ |
| 1126 | |
| 1127 | int |
| 1128 | PER_Visible_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1129 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1130 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1131 | const IA5String_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1132 | |
| 1133 | if(!sptr) { |
| 1134 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1135 | "%s: value not given (%s:%d)", |
| 1136 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1137 | return -1; |
| 1138 | } |
| 1139 | |
| 1140 | |
vlm | 7e20dfc | 2004-08-22 13:11:40 +0000 | [diff] [blame] | 1141 | if(!check_permitted_alphabet_3(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1142 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1143 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1144 | } else { |
| 1145 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1146 | "%s: constraint failed (%s:%d)", |
| 1147 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1148 | return -1; |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | /* |
| 1153 | * This type is implemented using IA5String, |
| 1154 | * so adjust the DEF appropriately. |
| 1155 | */ |
| 1156 | static void |
| 1157 | PER_Visible_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1158 | td->ber_decoder = asn1_DEF_IA5String.ber_decoder; |
| 1159 | td->der_encoder = asn1_DEF_IA5String.der_encoder; |
| 1160 | td->free_struct = asn1_DEF_IA5String.free_struct; |
| 1161 | td->print_struct = asn1_DEF_IA5String.print_struct; |
| 1162 | td->last_tag_form = asn1_DEF_IA5String.last_tag_form; |
| 1163 | td->elements = asn1_DEF_IA5String.elements; |
| 1164 | td->elements_count = asn1_DEF_IA5String.elements_count; |
| 1165 | td->specifics = asn1_DEF_IA5String.specifics; |
| 1166 | } |
| 1167 | |
| 1168 | ber_dec_rval_t |
| 1169 | PER_Visible_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1170 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1171 | PER_Visible_inherit_TYPE_descriptor(td); |
| 1172 | return td->ber_decoder(td, structure, |
| 1173 | bufptr, size, tag_mode); |
| 1174 | } |
| 1175 | |
| 1176 | der_enc_rval_t |
| 1177 | PER_Visible_encode_der(asn1_TYPE_descriptor_t *td, |
| 1178 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1179 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1180 | PER_Visible_inherit_TYPE_descriptor(td); |
| 1181 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1182 | } |
| 1183 | |
| 1184 | int |
| 1185 | PER_Visible_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1186 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1187 | PER_Visible_inherit_TYPE_descriptor(td); |
| 1188 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1189 | } |
| 1190 | |
| 1191 | void |
| 1192 | PER_Visible_free(asn1_TYPE_descriptor_t *td, |
| 1193 | void *struct_ptr, int contents_only) { |
| 1194 | PER_Visible_inherit_TYPE_descriptor(td); |
| 1195 | td->free_struct(td, struct_ptr, contents_only); |
| 1196 | } |
| 1197 | |
| 1198 | |
| 1199 | /*** <<< STAT-DEFS [PER-Visible] >>> ***/ |
| 1200 | |
| 1201 | static ber_tlv_tag_t asn1_DEF_PER_Visible_tags[] = { |
| 1202 | (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)) |
| 1203 | }; |
| 1204 | asn1_TYPE_descriptor_t asn1_DEF_PER_Visible = { |
| 1205 | "PER-Visible", |
| 1206 | PER_Visible_constraint, |
| 1207 | PER_Visible_decode_ber, |
| 1208 | PER_Visible_encode_der, |
| 1209 | PER_Visible_print, |
| 1210 | PER_Visible_free, |
| 1211 | 0, /* Use generic outmost tag fetcher */ |
| 1212 | asn1_DEF_PER_Visible_tags, |
| 1213 | sizeof(asn1_DEF_PER_Visible_tags) |
| 1214 | /sizeof(asn1_DEF_PER_Visible_tags[0]), /* 1 */ |
| 1215 | 1, /* Tags to skip */ |
| 1216 | -0, /* Unknown yet */ |
| 1217 | 0, 0, /* No members */ |
| 1218 | 0 /* No specifics */ |
| 1219 | }; |
| 1220 | |
| 1221 | |
| 1222 | /*** <<< INCLUDES [PER-Visible-2] >>> ***/ |
| 1223 | |
| 1224 | #include <PER-Visible.h> |
| 1225 | |
| 1226 | /*** <<< TYPE-DECLS [PER-Visible-2] >>> ***/ |
| 1227 | |
| 1228 | |
| 1229 | typedef PER_Visible_t PER_Visible_2_t; |
| 1230 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1231 | /*** <<< FUNC-DECLS [PER-Visible-2] >>> ***/ |
| 1232 | |
| 1233 | extern asn1_TYPE_descriptor_t asn1_DEF_PER_Visible_2; |
| 1234 | asn_constr_check_f PER_Visible_2_constraint; |
| 1235 | ber_type_decoder_f PER_Visible_2_decode_ber; |
| 1236 | der_type_encoder_f PER_Visible_2_encode_der; |
| 1237 | asn_struct_print_f PER_Visible_2_print; |
| 1238 | asn_struct_free_f PER_Visible_2_free; |
| 1239 | |
| 1240 | /*** <<< CTABLES [PER-Visible-2] >>> ***/ |
| 1241 | |
| 1242 | static int check_permitted_alphabet_4(const void *sptr) { |
| 1243 | /* The underlying type is IA5String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1244 | const IA5String_t *st = sptr; |
| 1245 | const uint8_t *ch = st->buf; |
| 1246 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1247 | |
| 1248 | for(; ch < end; ch++) { |
| 1249 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1250 | if(!(cv >= 69 && cv <= 70)) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1251 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1252 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | |
| 1256 | /*** <<< CODE [PER-Visible-2] >>> ***/ |
| 1257 | |
| 1258 | int |
| 1259 | PER_Visible_2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1260 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1261 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1262 | const PER_Visible_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1263 | |
| 1264 | if(!sptr) { |
| 1265 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1266 | "%s: value not given (%s:%d)", |
| 1267 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1268 | return -1; |
| 1269 | } |
| 1270 | |
| 1271 | |
vlm | 7e20dfc | 2004-08-22 13:11:40 +0000 | [diff] [blame] | 1272 | if(!check_permitted_alphabet_4(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1273 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1274 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1275 | } else { |
| 1276 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1277 | "%s: constraint failed (%s:%d)", |
| 1278 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1279 | return -1; |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | /* |
| 1284 | * This type is implemented using PER_Visible, |
| 1285 | * so adjust the DEF appropriately. |
| 1286 | */ |
| 1287 | static void |
| 1288 | PER_Visible_2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1289 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1290 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1291 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1292 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1293 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1294 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1295 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1296 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1297 | } |
| 1298 | |
| 1299 | ber_dec_rval_t |
| 1300 | PER_Visible_2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1301 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1302 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1303 | return td->ber_decoder(td, structure, |
| 1304 | bufptr, size, tag_mode); |
| 1305 | } |
| 1306 | |
| 1307 | der_enc_rval_t |
| 1308 | PER_Visible_2_encode_der(asn1_TYPE_descriptor_t *td, |
| 1309 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1310 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1311 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1312 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1313 | } |
| 1314 | |
| 1315 | int |
| 1316 | PER_Visible_2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1317 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1318 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1319 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1320 | } |
| 1321 | |
| 1322 | void |
| 1323 | PER_Visible_2_free(asn1_TYPE_descriptor_t *td, |
| 1324 | void *struct_ptr, int contents_only) { |
| 1325 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1326 | td->free_struct(td, struct_ptr, contents_only); |
| 1327 | } |
| 1328 | |
| 1329 | |
| 1330 | /*** <<< STAT-DEFS [PER-Visible-2] >>> ***/ |
| 1331 | |
| 1332 | static ber_tlv_tag_t asn1_DEF_PER_Visible_2_tags[] = { |
| 1333 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1334 | }; |
| 1335 | asn1_TYPE_descriptor_t asn1_DEF_PER_Visible_2 = { |
| 1336 | "PER-Visible-2", |
| 1337 | PER_Visible_2_constraint, |
| 1338 | PER_Visible_2_decode_ber, |
| 1339 | PER_Visible_2_encode_der, |
| 1340 | PER_Visible_2_print, |
| 1341 | PER_Visible_2_free, |
| 1342 | 0, /* Use generic outmost tag fetcher */ |
| 1343 | asn1_DEF_PER_Visible_2_tags, |
| 1344 | sizeof(asn1_DEF_PER_Visible_2_tags) |
| 1345 | /sizeof(asn1_DEF_PER_Visible_2_tags[0]), /* 1 */ |
| 1346 | 1, /* Tags to skip */ |
| 1347 | -0, /* Unknown yet */ |
| 1348 | 0, 0, /* No members */ |
| 1349 | 0 /* No specifics */ |
| 1350 | }; |
| 1351 | |
| 1352 | |
| 1353 | /*** <<< INCLUDES [Not-PER-Visible-1] >>> ***/ |
| 1354 | |
| 1355 | #include <PER-Visible.h> |
| 1356 | |
| 1357 | /*** <<< TYPE-DECLS [Not-PER-Visible-1] >>> ***/ |
| 1358 | |
| 1359 | |
| 1360 | typedef PER_Visible_t Not_PER_Visible_1_t; |
| 1361 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1362 | /*** <<< FUNC-DECLS [Not-PER-Visible-1] >>> ***/ |
| 1363 | |
| 1364 | extern asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_1; |
| 1365 | asn_constr_check_f Not_PER_Visible_1_constraint; |
| 1366 | ber_type_decoder_f Not_PER_Visible_1_decode_ber; |
| 1367 | der_type_encoder_f Not_PER_Visible_1_encode_der; |
| 1368 | asn_struct_print_f Not_PER_Visible_1_print; |
| 1369 | asn_struct_free_f Not_PER_Visible_1_free; |
| 1370 | |
| 1371 | /*** <<< CTABLES [Not-PER-Visible-1] >>> ***/ |
| 1372 | |
| 1373 | static int check_permitted_alphabet_5(const void *sptr) { |
| 1374 | /* The underlying type is IA5String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1375 | const IA5String_t *st = sptr; |
| 1376 | const uint8_t *ch = st->buf; |
| 1377 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1378 | |
| 1379 | for(; ch < end; ch++) { |
| 1380 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1381 | if(!(cv >= 65 && cv <= 70)) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1382 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1383 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1384 | } |
| 1385 | |
| 1386 | |
| 1387 | /*** <<< CODE [Not-PER-Visible-1] >>> ***/ |
| 1388 | |
| 1389 | int |
| 1390 | Not_PER_Visible_1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1391 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1392 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1393 | const PER_Visible_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1394 | |
| 1395 | if(!sptr) { |
| 1396 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1397 | "%s: value not given (%s:%d)", |
| 1398 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1399 | return -1; |
| 1400 | } |
| 1401 | |
| 1402 | |
vlm | 7e20dfc | 2004-08-22 13:11:40 +0000 | [diff] [blame] | 1403 | if(!check_permitted_alphabet_5(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1404 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1405 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1406 | } else { |
| 1407 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1408 | "%s: constraint failed (%s:%d)", |
| 1409 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1410 | return -1; |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | /* |
| 1415 | * This type is implemented using PER_Visible, |
| 1416 | * so adjust the DEF appropriately. |
| 1417 | */ |
| 1418 | static void |
| 1419 | Not_PER_Visible_1_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1420 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1421 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1422 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1423 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1424 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1425 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1426 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1427 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1428 | } |
| 1429 | |
| 1430 | ber_dec_rval_t |
| 1431 | Not_PER_Visible_1_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1432 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1433 | Not_PER_Visible_1_inherit_TYPE_descriptor(td); |
| 1434 | return td->ber_decoder(td, structure, |
| 1435 | bufptr, size, tag_mode); |
| 1436 | } |
| 1437 | |
| 1438 | der_enc_rval_t |
| 1439 | Not_PER_Visible_1_encode_der(asn1_TYPE_descriptor_t *td, |
| 1440 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1441 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1442 | Not_PER_Visible_1_inherit_TYPE_descriptor(td); |
| 1443 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1444 | } |
| 1445 | |
| 1446 | int |
| 1447 | Not_PER_Visible_1_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1448 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1449 | Not_PER_Visible_1_inherit_TYPE_descriptor(td); |
| 1450 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1451 | } |
| 1452 | |
| 1453 | void |
| 1454 | Not_PER_Visible_1_free(asn1_TYPE_descriptor_t *td, |
| 1455 | void *struct_ptr, int contents_only) { |
| 1456 | Not_PER_Visible_1_inherit_TYPE_descriptor(td); |
| 1457 | td->free_struct(td, struct_ptr, contents_only); |
| 1458 | } |
| 1459 | |
| 1460 | |
| 1461 | /*** <<< STAT-DEFS [Not-PER-Visible-1] >>> ***/ |
| 1462 | |
| 1463 | static ber_tlv_tag_t asn1_DEF_Not_PER_Visible_1_tags[] = { |
| 1464 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1465 | }; |
| 1466 | asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_1 = { |
| 1467 | "Not-PER-Visible-1", |
| 1468 | Not_PER_Visible_1_constraint, |
| 1469 | Not_PER_Visible_1_decode_ber, |
| 1470 | Not_PER_Visible_1_encode_der, |
| 1471 | Not_PER_Visible_1_print, |
| 1472 | Not_PER_Visible_1_free, |
| 1473 | 0, /* Use generic outmost tag fetcher */ |
| 1474 | asn1_DEF_Not_PER_Visible_1_tags, |
| 1475 | sizeof(asn1_DEF_Not_PER_Visible_1_tags) |
| 1476 | /sizeof(asn1_DEF_Not_PER_Visible_1_tags[0]), /* 1 */ |
| 1477 | 1, /* Tags to skip */ |
| 1478 | -0, /* Unknown yet */ |
| 1479 | 0, 0, /* No members */ |
| 1480 | 0 /* No specifics */ |
| 1481 | }; |
| 1482 | |
| 1483 | |
| 1484 | /*** <<< INCLUDES [Not-PER-Visible-2] >>> ***/ |
| 1485 | |
| 1486 | #include <PER-Visible.h> |
| 1487 | |
| 1488 | /*** <<< TYPE-DECLS [Not-PER-Visible-2] >>> ***/ |
| 1489 | |
| 1490 | |
| 1491 | typedef PER_Visible_t Not_PER_Visible_2_t; |
| 1492 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1493 | /*** <<< FUNC-DECLS [Not-PER-Visible-2] >>> ***/ |
| 1494 | |
| 1495 | extern asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_2; |
| 1496 | asn_constr_check_f Not_PER_Visible_2_constraint; |
| 1497 | ber_type_decoder_f Not_PER_Visible_2_decode_ber; |
| 1498 | der_type_encoder_f Not_PER_Visible_2_encode_der; |
| 1499 | asn_struct_print_f Not_PER_Visible_2_print; |
| 1500 | asn_struct_free_f Not_PER_Visible_2_free; |
| 1501 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1502 | /*** <<< CTABLES [Not-PER-Visible-2] >>> ***/ |
| 1503 | |
| 1504 | static int check_permitted_alphabet_6(const void *sptr) { |
| 1505 | /* The underlying type is IA5String */ |
| 1506 | const IA5String_t *st = sptr; |
| 1507 | const uint8_t *ch = st->buf; |
| 1508 | const uint8_t *end = ch + st->size; |
| 1509 | |
| 1510 | for(; ch < end; ch++) { |
| 1511 | uint8_t cv = *ch; |
| 1512 | if(!(cv >= 65 && cv <= 66)) return -1; |
| 1513 | } |
| 1514 | return 0; |
| 1515 | } |
| 1516 | |
| 1517 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1518 | /*** <<< CODE [Not-PER-Visible-2] >>> ***/ |
| 1519 | |
| 1520 | int |
| 1521 | Not_PER_Visible_2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1522 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1523 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1524 | const PER_Visible_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1525 | |
| 1526 | if(!sptr) { |
| 1527 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1528 | "%s: value not given (%s:%d)", |
| 1529 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1530 | return -1; |
| 1531 | } |
| 1532 | |
| 1533 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1534 | if(!check_permitted_alphabet_6(sptr)) { |
| 1535 | /* Constraint check succeeded */ |
| 1536 | return 0; |
| 1537 | } else { |
| 1538 | _ASN_ERRLOG(app_errlog, app_key, |
| 1539 | "%s: constraint failed (%s:%d)", |
| 1540 | td->name, __FILE__, __LINE__); |
| 1541 | return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1542 | } |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1543 | } |
| 1544 | |
| 1545 | /* |
| 1546 | * This type is implemented using PER_Visible, |
| 1547 | * so adjust the DEF appropriately. |
| 1548 | */ |
| 1549 | static void |
| 1550 | Not_PER_Visible_2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1551 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1552 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1553 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1554 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1555 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1556 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1557 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1558 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1559 | } |
| 1560 | |
| 1561 | ber_dec_rval_t |
| 1562 | Not_PER_Visible_2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1563 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1564 | Not_PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1565 | return td->ber_decoder(td, structure, |
| 1566 | bufptr, size, tag_mode); |
| 1567 | } |
| 1568 | |
| 1569 | der_enc_rval_t |
| 1570 | Not_PER_Visible_2_encode_der(asn1_TYPE_descriptor_t *td, |
| 1571 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1572 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1573 | Not_PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1574 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1575 | } |
| 1576 | |
| 1577 | int |
| 1578 | Not_PER_Visible_2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1579 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1580 | Not_PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1581 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1582 | } |
| 1583 | |
| 1584 | void |
| 1585 | Not_PER_Visible_2_free(asn1_TYPE_descriptor_t *td, |
| 1586 | void *struct_ptr, int contents_only) { |
| 1587 | Not_PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1588 | td->free_struct(td, struct_ptr, contents_only); |
| 1589 | } |
| 1590 | |
| 1591 | |
| 1592 | /*** <<< STAT-DEFS [Not-PER-Visible-2] >>> ***/ |
| 1593 | |
| 1594 | static ber_tlv_tag_t asn1_DEF_Not_PER_Visible_2_tags[] = { |
| 1595 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1596 | }; |
| 1597 | asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_2 = { |
| 1598 | "Not-PER-Visible-2", |
| 1599 | Not_PER_Visible_2_constraint, |
| 1600 | Not_PER_Visible_2_decode_ber, |
| 1601 | Not_PER_Visible_2_encode_der, |
| 1602 | Not_PER_Visible_2_print, |
| 1603 | Not_PER_Visible_2_free, |
| 1604 | 0, /* Use generic outmost tag fetcher */ |
| 1605 | asn1_DEF_Not_PER_Visible_2_tags, |
| 1606 | sizeof(asn1_DEF_Not_PER_Visible_2_tags) |
| 1607 | /sizeof(asn1_DEF_Not_PER_Visible_2_tags[0]), /* 1 */ |
| 1608 | 1, /* Tags to skip */ |
| 1609 | -0, /* Unknown yet */ |
| 1610 | 0, 0, /* No members */ |
| 1611 | 0 /* No specifics */ |
| 1612 | }; |
| 1613 | |
| 1614 | |
| 1615 | /*** <<< INCLUDES [Not-PER-Visible-3] >>> ***/ |
| 1616 | |
| 1617 | #include <PER-Visible.h> |
| 1618 | |
| 1619 | /*** <<< TYPE-DECLS [Not-PER-Visible-3] >>> ***/ |
| 1620 | |
| 1621 | |
| 1622 | typedef PER_Visible_t Not_PER_Visible_3_t; |
| 1623 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1624 | /*** <<< FUNC-DECLS [Not-PER-Visible-3] >>> ***/ |
| 1625 | |
| 1626 | extern asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_3; |
| 1627 | asn_constr_check_f Not_PER_Visible_3_constraint; |
| 1628 | ber_type_decoder_f Not_PER_Visible_3_decode_ber; |
| 1629 | der_type_encoder_f Not_PER_Visible_3_encode_der; |
| 1630 | asn_struct_print_f Not_PER_Visible_3_print; |
| 1631 | asn_struct_free_f Not_PER_Visible_3_free; |
| 1632 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1633 | /*** <<< CTABLES [Not-PER-Visible-3] >>> ***/ |
| 1634 | |
| 1635 | static int check_permitted_alphabet_7(const void *sptr) { |
| 1636 | /* The underlying type is IA5String */ |
| 1637 | const IA5String_t *st = sptr; |
| 1638 | const uint8_t *ch = st->buf; |
| 1639 | const uint8_t *end = ch + st->size; |
| 1640 | |
| 1641 | for(; ch < end; ch++) { |
| 1642 | uint8_t cv = *ch; |
| 1643 | if(!(cv >= 65 && cv <= 66)) return -1; |
| 1644 | } |
| 1645 | return 0; |
| 1646 | } |
| 1647 | |
| 1648 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1649 | /*** <<< CODE [Not-PER-Visible-3] >>> ***/ |
| 1650 | |
| 1651 | int |
| 1652 | Not_PER_Visible_3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1653 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1654 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1655 | const PER_Visible_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1656 | |
| 1657 | if(!sptr) { |
| 1658 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1659 | "%s: value not given (%s:%d)", |
| 1660 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1661 | return -1; |
| 1662 | } |
| 1663 | |
| 1664 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1665 | if(!check_permitted_alphabet_7(sptr)) { |
| 1666 | /* Constraint check succeeded */ |
| 1667 | return 0; |
| 1668 | } else { |
| 1669 | _ASN_ERRLOG(app_errlog, app_key, |
| 1670 | "%s: constraint failed (%s:%d)", |
| 1671 | td->name, __FILE__, __LINE__); |
| 1672 | return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1673 | } |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | /* |
| 1677 | * This type is implemented using PER_Visible, |
| 1678 | * so adjust the DEF appropriately. |
| 1679 | */ |
| 1680 | static void |
| 1681 | Not_PER_Visible_3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1682 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1683 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1684 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1685 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1686 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1687 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1688 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1689 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1690 | } |
| 1691 | |
| 1692 | ber_dec_rval_t |
| 1693 | Not_PER_Visible_3_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1694 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1695 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1696 | return td->ber_decoder(td, structure, |
| 1697 | bufptr, size, tag_mode); |
| 1698 | } |
| 1699 | |
| 1700 | der_enc_rval_t |
| 1701 | Not_PER_Visible_3_encode_der(asn1_TYPE_descriptor_t *td, |
| 1702 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1703 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1704 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1705 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1706 | } |
| 1707 | |
| 1708 | int |
| 1709 | Not_PER_Visible_3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1710 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1711 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1712 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1713 | } |
| 1714 | |
| 1715 | void |
| 1716 | Not_PER_Visible_3_free(asn1_TYPE_descriptor_t *td, |
| 1717 | void *struct_ptr, int contents_only) { |
| 1718 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1719 | td->free_struct(td, struct_ptr, contents_only); |
| 1720 | } |
| 1721 | |
| 1722 | |
| 1723 | /*** <<< STAT-DEFS [Not-PER-Visible-3] >>> ***/ |
| 1724 | |
| 1725 | static ber_tlv_tag_t asn1_DEF_Not_PER_Visible_3_tags[] = { |
| 1726 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1727 | }; |
| 1728 | asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_3 = { |
| 1729 | "Not-PER-Visible-3", |
| 1730 | Not_PER_Visible_3_constraint, |
| 1731 | Not_PER_Visible_3_decode_ber, |
| 1732 | Not_PER_Visible_3_encode_der, |
| 1733 | Not_PER_Visible_3_print, |
| 1734 | Not_PER_Visible_3_free, |
| 1735 | 0, /* Use generic outmost tag fetcher */ |
| 1736 | asn1_DEF_Not_PER_Visible_3_tags, |
| 1737 | sizeof(asn1_DEF_Not_PER_Visible_3_tags) |
| 1738 | /sizeof(asn1_DEF_Not_PER_Visible_3_tags[0]), /* 1 */ |
| 1739 | 1, /* Tags to skip */ |
| 1740 | -0, /* Unknown yet */ |
| 1741 | 0, 0, /* No members */ |
| 1742 | 0 /* No specifics */ |
| 1743 | }; |
| 1744 | |
| 1745 | |
| 1746 | /*** <<< INCLUDES [SIZE-but-not-FROM] >>> ***/ |
| 1747 | |
| 1748 | #include <PER-Visible.h> |
| 1749 | |
| 1750 | /*** <<< TYPE-DECLS [SIZE-but-not-FROM] >>> ***/ |
| 1751 | |
| 1752 | |
| 1753 | typedef PER_Visible_t SIZE_but_not_FROM_t; |
| 1754 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1755 | /*** <<< FUNC-DECLS [SIZE-but-not-FROM] >>> ***/ |
| 1756 | |
| 1757 | extern asn1_TYPE_descriptor_t asn1_DEF_SIZE_but_not_FROM; |
| 1758 | asn_constr_check_f SIZE_but_not_FROM_constraint; |
| 1759 | ber_type_decoder_f SIZE_but_not_FROM_decode_ber; |
| 1760 | der_type_encoder_f SIZE_but_not_FROM_encode_der; |
| 1761 | asn_struct_print_f SIZE_but_not_FROM_print; |
| 1762 | asn_struct_free_f SIZE_but_not_FROM_free; |
| 1763 | |
| 1764 | /*** <<< CTABLES [SIZE-but-not-FROM] >>> ***/ |
| 1765 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1766 | static int check_permitted_alphabet_8(const void *sptr) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1767 | /* The underlying type is IA5String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1768 | const IA5String_t *st = sptr; |
| 1769 | const uint8_t *ch = st->buf; |
| 1770 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1771 | |
| 1772 | for(; ch < end; ch++) { |
| 1773 | uint8_t cv = *ch; |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1774 | if(!(cv >= 65 && cv <= 68)) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1775 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1776 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1777 | } |
| 1778 | |
| 1779 | |
| 1780 | /*** <<< CODE [SIZE-but-not-FROM] >>> ***/ |
| 1781 | |
| 1782 | int |
| 1783 | SIZE_but_not_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1784 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1785 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1786 | const PER_Visible_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1787 | size_t size; |
| 1788 | |
| 1789 | if(!sptr) { |
| 1790 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1791 | "%s: value not given (%s:%d)", |
| 1792 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1793 | return -1; |
| 1794 | } |
| 1795 | |
| 1796 | size = st->size; |
| 1797 | |
| 1798 | if((size >= 1 && size <= 4) |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1799 | && !check_permitted_alphabet_8(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1800 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1801 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1802 | } else { |
| 1803 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1804 | "%s: constraint failed (%s:%d)", |
| 1805 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1806 | return -1; |
| 1807 | } |
| 1808 | } |
| 1809 | |
| 1810 | /* |
| 1811 | * This type is implemented using PER_Visible, |
| 1812 | * so adjust the DEF appropriately. |
| 1813 | */ |
| 1814 | static void |
| 1815 | SIZE_but_not_FROM_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1816 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1817 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1818 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1819 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1820 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1821 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1822 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1823 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1824 | } |
| 1825 | |
| 1826 | ber_dec_rval_t |
| 1827 | SIZE_but_not_FROM_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1828 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1829 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1830 | return td->ber_decoder(td, structure, |
| 1831 | bufptr, size, tag_mode); |
| 1832 | } |
| 1833 | |
| 1834 | der_enc_rval_t |
| 1835 | SIZE_but_not_FROM_encode_der(asn1_TYPE_descriptor_t *td, |
| 1836 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1837 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1838 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1839 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1840 | } |
| 1841 | |
| 1842 | int |
| 1843 | SIZE_but_not_FROM_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1844 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1845 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1846 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1847 | } |
| 1848 | |
| 1849 | void |
| 1850 | SIZE_but_not_FROM_free(asn1_TYPE_descriptor_t *td, |
| 1851 | void *struct_ptr, int contents_only) { |
| 1852 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1853 | td->free_struct(td, struct_ptr, contents_only); |
| 1854 | } |
| 1855 | |
| 1856 | |
| 1857 | /*** <<< STAT-DEFS [SIZE-but-not-FROM] >>> ***/ |
| 1858 | |
| 1859 | static ber_tlv_tag_t asn1_DEF_SIZE_but_not_FROM_tags[] = { |
| 1860 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1861 | }; |
| 1862 | asn1_TYPE_descriptor_t asn1_DEF_SIZE_but_not_FROM = { |
| 1863 | "SIZE-but-not-FROM", |
| 1864 | SIZE_but_not_FROM_constraint, |
| 1865 | SIZE_but_not_FROM_decode_ber, |
| 1866 | SIZE_but_not_FROM_encode_der, |
| 1867 | SIZE_but_not_FROM_print, |
| 1868 | SIZE_but_not_FROM_free, |
| 1869 | 0, /* Use generic outmost tag fetcher */ |
| 1870 | asn1_DEF_SIZE_but_not_FROM_tags, |
| 1871 | sizeof(asn1_DEF_SIZE_but_not_FROM_tags) |
| 1872 | /sizeof(asn1_DEF_SIZE_but_not_FROM_tags[0]), /* 1 */ |
| 1873 | 1, /* Tags to skip */ |
| 1874 | -0, /* Unknown yet */ |
| 1875 | 0, 0, /* No members */ |
| 1876 | 0 /* No specifics */ |
| 1877 | }; |
| 1878 | |
| 1879 | |
| 1880 | /*** <<< INCLUDES [SIZE-and-FROM] >>> ***/ |
| 1881 | |
| 1882 | #include <PER-Visible.h> |
| 1883 | |
| 1884 | /*** <<< TYPE-DECLS [SIZE-and-FROM] >>> ***/ |
| 1885 | |
| 1886 | |
| 1887 | typedef PER_Visible_t SIZE_and_FROM_t; |
| 1888 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1889 | /*** <<< FUNC-DECLS [SIZE-and-FROM] >>> ***/ |
| 1890 | |
| 1891 | extern asn1_TYPE_descriptor_t asn1_DEF_SIZE_and_FROM; |
| 1892 | asn_constr_check_f SIZE_and_FROM_constraint; |
| 1893 | ber_type_decoder_f SIZE_and_FROM_decode_ber; |
| 1894 | der_type_encoder_f SIZE_and_FROM_encode_der; |
| 1895 | asn_struct_print_f SIZE_and_FROM_print; |
| 1896 | asn_struct_free_f SIZE_and_FROM_free; |
| 1897 | |
| 1898 | /*** <<< CTABLES [SIZE-and-FROM] >>> ***/ |
| 1899 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1900 | static int check_permitted_alphabet_9(const void *sptr) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1901 | /* The underlying type is IA5String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1902 | const IA5String_t *st = sptr; |
| 1903 | const uint8_t *ch = st->buf; |
| 1904 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1905 | |
| 1906 | for(; ch < end; ch++) { |
| 1907 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1908 | if(!(cv >= 65 && cv <= 68)) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1909 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1910 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1911 | } |
| 1912 | |
| 1913 | |
| 1914 | /*** <<< CODE [SIZE-and-FROM] >>> ***/ |
| 1915 | |
| 1916 | int |
| 1917 | SIZE_and_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1918 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1919 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1920 | const PER_Visible_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1921 | size_t size; |
| 1922 | |
| 1923 | if(!sptr) { |
| 1924 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1925 | "%s: value not given (%s:%d)", |
| 1926 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1927 | return -1; |
| 1928 | } |
| 1929 | |
| 1930 | size = st->size; |
| 1931 | |
| 1932 | if((size >= 1 && size <= 4) |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1933 | && !check_permitted_alphabet_9(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1934 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1935 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1936 | } else { |
| 1937 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1938 | "%s: constraint failed (%s:%d)", |
| 1939 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1940 | return -1; |
| 1941 | } |
| 1942 | } |
| 1943 | |
| 1944 | /* |
| 1945 | * This type is implemented using PER_Visible, |
| 1946 | * so adjust the DEF appropriately. |
| 1947 | */ |
| 1948 | static void |
| 1949 | SIZE_and_FROM_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1950 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1951 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1952 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1953 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1954 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1955 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1956 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1957 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1958 | } |
| 1959 | |
| 1960 | ber_dec_rval_t |
| 1961 | SIZE_and_FROM_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1962 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1963 | SIZE_and_FROM_inherit_TYPE_descriptor(td); |
| 1964 | return td->ber_decoder(td, structure, |
| 1965 | bufptr, size, tag_mode); |
| 1966 | } |
| 1967 | |
| 1968 | der_enc_rval_t |
| 1969 | SIZE_and_FROM_encode_der(asn1_TYPE_descriptor_t *td, |
| 1970 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1971 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1972 | SIZE_and_FROM_inherit_TYPE_descriptor(td); |
| 1973 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1974 | } |
| 1975 | |
| 1976 | int |
| 1977 | SIZE_and_FROM_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1978 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1979 | SIZE_and_FROM_inherit_TYPE_descriptor(td); |
| 1980 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1981 | } |
| 1982 | |
| 1983 | void |
| 1984 | SIZE_and_FROM_free(asn1_TYPE_descriptor_t *td, |
| 1985 | void *struct_ptr, int contents_only) { |
| 1986 | SIZE_and_FROM_inherit_TYPE_descriptor(td); |
| 1987 | td->free_struct(td, struct_ptr, contents_only); |
| 1988 | } |
| 1989 | |
| 1990 | |
| 1991 | /*** <<< STAT-DEFS [SIZE-and-FROM] >>> ***/ |
| 1992 | |
| 1993 | static ber_tlv_tag_t asn1_DEF_SIZE_and_FROM_tags[] = { |
| 1994 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1995 | }; |
| 1996 | asn1_TYPE_descriptor_t asn1_DEF_SIZE_and_FROM = { |
| 1997 | "SIZE-and-FROM", |
| 1998 | SIZE_and_FROM_constraint, |
| 1999 | SIZE_and_FROM_decode_ber, |
| 2000 | SIZE_and_FROM_encode_der, |
| 2001 | SIZE_and_FROM_print, |
| 2002 | SIZE_and_FROM_free, |
| 2003 | 0, /* Use generic outmost tag fetcher */ |
| 2004 | asn1_DEF_SIZE_and_FROM_tags, |
| 2005 | sizeof(asn1_DEF_SIZE_and_FROM_tags) |
| 2006 | /sizeof(asn1_DEF_SIZE_and_FROM_tags[0]), /* 1 */ |
| 2007 | 1, /* Tags to skip */ |
| 2008 | -0, /* Unknown yet */ |
| 2009 | 0, 0, /* No members */ |
| 2010 | 0 /* No specifics */ |
| 2011 | }; |
| 2012 | |
| 2013 | |
| 2014 | /*** <<< INCLUDES [Neither-SIZE-nor-FROM] >>> ***/ |
| 2015 | |
| 2016 | #include <PER-Visible.h> |
| 2017 | |
| 2018 | /*** <<< TYPE-DECLS [Neither-SIZE-nor-FROM] >>> ***/ |
| 2019 | |
| 2020 | |
| 2021 | typedef PER_Visible_t Neither_SIZE_nor_FROM_t; |
| 2022 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2023 | /*** <<< FUNC-DECLS [Neither-SIZE-nor-FROM] >>> ***/ |
| 2024 | |
| 2025 | extern asn1_TYPE_descriptor_t asn1_DEF_Neither_SIZE_nor_FROM; |
| 2026 | asn_constr_check_f Neither_SIZE_nor_FROM_constraint; |
| 2027 | ber_type_decoder_f Neither_SIZE_nor_FROM_decode_ber; |
| 2028 | der_type_encoder_f Neither_SIZE_nor_FROM_encode_der; |
| 2029 | asn_struct_print_f Neither_SIZE_nor_FROM_print; |
| 2030 | asn_struct_free_f Neither_SIZE_nor_FROM_free; |
| 2031 | |
| 2032 | /*** <<< CTABLES [Neither-SIZE-nor-FROM] >>> ***/ |
| 2033 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 2034 | static int check_permitted_alphabet_10(const void *sptr) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2035 | /* The underlying type is IA5String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2036 | const IA5String_t *st = sptr; |
| 2037 | const uint8_t *ch = st->buf; |
| 2038 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2039 | |
| 2040 | for(; ch < end; ch++) { |
| 2041 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2042 | if(!(cv >= 65 && cv <= 70)) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2043 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2044 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2045 | } |
| 2046 | |
| 2047 | |
| 2048 | /*** <<< CODE [Neither-SIZE-nor-FROM] >>> ***/ |
| 2049 | |
| 2050 | int |
| 2051 | Neither_SIZE_nor_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2052 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2053 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2054 | const PER_Visible_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2055 | |
| 2056 | if(!sptr) { |
| 2057 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2058 | "%s: value not given (%s:%d)", |
| 2059 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2060 | return -1; |
| 2061 | } |
| 2062 | |
| 2063 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 2064 | if(!check_permitted_alphabet_10(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2065 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2066 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2067 | } else { |
| 2068 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2069 | "%s: constraint failed (%s:%d)", |
| 2070 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2071 | return -1; |
| 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | /* |
| 2076 | * This type is implemented using PER_Visible, |
| 2077 | * so adjust the DEF appropriately. |
| 2078 | */ |
| 2079 | static void |
| 2080 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2081 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 2082 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 2083 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 2084 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 2085 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 2086 | td->elements = asn1_DEF_PER_Visible.elements; |
| 2087 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 2088 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 2089 | } |
| 2090 | |
| 2091 | ber_dec_rval_t |
| 2092 | Neither_SIZE_nor_FROM_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2093 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2094 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2095 | return td->ber_decoder(td, structure, |
| 2096 | bufptr, size, tag_mode); |
| 2097 | } |
| 2098 | |
| 2099 | der_enc_rval_t |
| 2100 | Neither_SIZE_nor_FROM_encode_der(asn1_TYPE_descriptor_t *td, |
| 2101 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2102 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2103 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2104 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2105 | } |
| 2106 | |
| 2107 | int |
| 2108 | Neither_SIZE_nor_FROM_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2109 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2110 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2111 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2112 | } |
| 2113 | |
| 2114 | void |
| 2115 | Neither_SIZE_nor_FROM_free(asn1_TYPE_descriptor_t *td, |
| 2116 | void *struct_ptr, int contents_only) { |
| 2117 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2118 | td->free_struct(td, struct_ptr, contents_only); |
| 2119 | } |
| 2120 | |
| 2121 | |
| 2122 | /*** <<< STAT-DEFS [Neither-SIZE-nor-FROM] >>> ***/ |
| 2123 | |
| 2124 | static ber_tlv_tag_t asn1_DEF_Neither_SIZE_nor_FROM_tags[] = { |
| 2125 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 2126 | }; |
| 2127 | asn1_TYPE_descriptor_t asn1_DEF_Neither_SIZE_nor_FROM = { |
| 2128 | "Neither-SIZE-nor-FROM", |
| 2129 | Neither_SIZE_nor_FROM_constraint, |
| 2130 | Neither_SIZE_nor_FROM_decode_ber, |
| 2131 | Neither_SIZE_nor_FROM_encode_der, |
| 2132 | Neither_SIZE_nor_FROM_print, |
| 2133 | Neither_SIZE_nor_FROM_free, |
| 2134 | 0, /* Use generic outmost tag fetcher */ |
| 2135 | asn1_DEF_Neither_SIZE_nor_FROM_tags, |
| 2136 | sizeof(asn1_DEF_Neither_SIZE_nor_FROM_tags) |
| 2137 | /sizeof(asn1_DEF_Neither_SIZE_nor_FROM_tags[0]), /* 1 */ |
| 2138 | 1, /* Tags to skip */ |
| 2139 | -0, /* Unknown yet */ |
| 2140 | 0, 0, /* No members */ |
| 2141 | 0 /* No specifics */ |
| 2142 | }; |
| 2143 | |
| 2144 | |
| 2145 | /*** <<< INCLUDES [Utf8-3] >>> ***/ |
| 2146 | |
| 2147 | #include <Utf8-2.h> |
| 2148 | |
| 2149 | /*** <<< TYPE-DECLS [Utf8-3] >>> ***/ |
| 2150 | |
| 2151 | |
| 2152 | typedef Utf8_2_t Utf8_3_t; |
| 2153 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2154 | /*** <<< FUNC-DECLS [Utf8-3] >>> ***/ |
| 2155 | |
| 2156 | extern asn1_TYPE_descriptor_t asn1_DEF_Utf8_3; |
| 2157 | asn_constr_check_f Utf8_3_constraint; |
| 2158 | ber_type_decoder_f Utf8_3_decode_ber; |
| 2159 | der_type_encoder_f Utf8_3_encode_der; |
| 2160 | asn_struct_print_f Utf8_3_print; |
| 2161 | asn_struct_free_f Utf8_3_free; |
| 2162 | |
| 2163 | /*** <<< CTABLES [Utf8-3] >>> ***/ |
| 2164 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 2165 | static int permitted_alphabet_table_11[128] = { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2166 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2167 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2168 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2169 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2170 | 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ABCDEFGHIJKLMNO */ |
| 2171 | 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* PQRSTUVWXYZ */ |
| 2172 | 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* abcdefghijklmno */ |
| 2173 | 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* pqrstuvwxyz */ |
| 2174 | }; |
| 2175 | |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 2176 | static int check_permitted_alphabet_11(const void *sptr) { |
| 2177 | int *table = permitted_alphabet_table_11; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2178 | /* The underlying type is UTF8String */ |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2179 | const UTF8String_t *st = sptr; |
| 2180 | const uint8_t *ch = st->buf; |
| 2181 | const uint8_t *end = ch + st->size; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2182 | |
| 2183 | for(; ch < end; ch++) { |
| 2184 | uint8_t cv = *ch; |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2185 | if(cv >= 0x80) return -1; |
| 2186 | if(!table[cv]) return -1; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2187 | } |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2188 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2189 | } |
| 2190 | |
| 2191 | |
| 2192 | /*** <<< CODE [Utf8-3] >>> ***/ |
| 2193 | |
| 2194 | int |
| 2195 | Utf8_3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2196 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2197 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2198 | const Utf8_2_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2199 | size_t size; |
| 2200 | |
| 2201 | if(!sptr) { |
| 2202 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2203 | "%s: value not given (%s:%d)", |
| 2204 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2205 | return -1; |
| 2206 | } |
| 2207 | |
| 2208 | size = UTF8String_length(st, td->name, app_errlog, app_key); |
| 2209 | if(size == (size_t)-1) return -1; |
| 2210 | |
| 2211 | if((size >= 1 && size <= 2) |
vlm | 26afd20 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 2212 | && !check_permitted_alphabet_11(sptr)) { |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2213 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2214 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2215 | } else { |
| 2216 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2217 | "%s: constraint failed (%s:%d)", |
| 2218 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2219 | return -1; |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | /* |
| 2224 | * This type is implemented using Utf8_2, |
| 2225 | * so adjust the DEF appropriately. |
| 2226 | */ |
| 2227 | static void |
| 2228 | Utf8_3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2229 | td->ber_decoder = asn1_DEF_Utf8_2.ber_decoder; |
| 2230 | td->der_encoder = asn1_DEF_Utf8_2.der_encoder; |
| 2231 | td->free_struct = asn1_DEF_Utf8_2.free_struct; |
| 2232 | td->print_struct = asn1_DEF_Utf8_2.print_struct; |
| 2233 | td->last_tag_form = asn1_DEF_Utf8_2.last_tag_form; |
| 2234 | td->elements = asn1_DEF_Utf8_2.elements; |
| 2235 | td->elements_count = asn1_DEF_Utf8_2.elements_count; |
| 2236 | td->specifics = asn1_DEF_Utf8_2.specifics; |
| 2237 | } |
| 2238 | |
| 2239 | ber_dec_rval_t |
| 2240 | Utf8_3_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2241 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2242 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2243 | return td->ber_decoder(td, structure, |
| 2244 | bufptr, size, tag_mode); |
| 2245 | } |
| 2246 | |
| 2247 | der_enc_rval_t |
| 2248 | Utf8_3_encode_der(asn1_TYPE_descriptor_t *td, |
| 2249 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2250 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2251 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2252 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2253 | } |
| 2254 | |
| 2255 | int |
| 2256 | Utf8_3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2257 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2258 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2259 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2260 | } |
| 2261 | |
| 2262 | void |
| 2263 | Utf8_3_free(asn1_TYPE_descriptor_t *td, |
| 2264 | void *struct_ptr, int contents_only) { |
| 2265 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2266 | td->free_struct(td, struct_ptr, contents_only); |
| 2267 | } |
| 2268 | |
| 2269 | |
| 2270 | /*** <<< STAT-DEFS [Utf8-3] >>> ***/ |
| 2271 | |
| 2272 | static ber_tlv_tag_t asn1_DEF_Utf8_3_tags[] = { |
| 2273 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 2274 | }; |
| 2275 | asn1_TYPE_descriptor_t asn1_DEF_Utf8_3 = { |
| 2276 | "Utf8-3", |
| 2277 | Utf8_3_constraint, |
| 2278 | Utf8_3_decode_ber, |
| 2279 | Utf8_3_encode_der, |
| 2280 | Utf8_3_print, |
| 2281 | Utf8_3_free, |
| 2282 | 0, /* Use generic outmost tag fetcher */ |
| 2283 | asn1_DEF_Utf8_3_tags, |
| 2284 | sizeof(asn1_DEF_Utf8_3_tags) |
| 2285 | /sizeof(asn1_DEF_Utf8_3_tags[0]), /* 1 */ |
| 2286 | 1, /* Tags to skip */ |
| 2287 | -0, /* Unknown yet */ |
| 2288 | 0, 0, /* No members */ |
| 2289 | 0 /* No specifics */ |
| 2290 | }; |
| 2291 | |
| 2292 | |
| 2293 | /*** <<< INCLUDES [Utf8-2] >>> ***/ |
| 2294 | |
| 2295 | #include <Utf8-1.h> |
| 2296 | |
| 2297 | /*** <<< TYPE-DECLS [Utf8-2] >>> ***/ |
| 2298 | |
| 2299 | |
| 2300 | typedef Utf8_1_t Utf8_2_t; |
| 2301 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2302 | /*** <<< FUNC-DECLS [Utf8-2] >>> ***/ |
| 2303 | |
| 2304 | extern asn1_TYPE_descriptor_t asn1_DEF_Utf8_2; |
| 2305 | asn_constr_check_f Utf8_2_constraint; |
| 2306 | ber_type_decoder_f Utf8_2_decode_ber; |
| 2307 | der_type_encoder_f Utf8_2_encode_der; |
| 2308 | asn_struct_print_f Utf8_2_print; |
| 2309 | asn_struct_free_f Utf8_2_free; |
| 2310 | |
| 2311 | /*** <<< CODE [Utf8-2] >>> ***/ |
| 2312 | |
| 2313 | int |
| 2314 | Utf8_2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2315 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2316 | |
vlm | b08de15 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2317 | const Utf8_1_t *st = sptr; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2318 | size_t size; |
| 2319 | |
| 2320 | if(!sptr) { |
| 2321 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2322 | "%s: value not given (%s:%d)", |
| 2323 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2324 | return -1; |
| 2325 | } |
| 2326 | |
| 2327 | size = UTF8String_length(st, td->name, app_errlog, app_key); |
| 2328 | if(size == (size_t)-1) return -1; |
| 2329 | |
| 2330 | if((size >= 1 && size <= 2)) { |
| 2331 | /* Constraint check succeeded */ |
vlm | cdf661b | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2332 | return 0; |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2333 | } else { |
| 2334 | _ASN_ERRLOG(app_errlog, app_key, |
vlm | 758530a | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2335 | "%s: constraint failed (%s:%d)", |
| 2336 | td->name, __FILE__, __LINE__); |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2337 | return -1; |
| 2338 | } |
| 2339 | } |
| 2340 | |
| 2341 | /* |
| 2342 | * This type is implemented using Utf8_1, |
| 2343 | * so adjust the DEF appropriately. |
| 2344 | */ |
| 2345 | static void |
| 2346 | Utf8_2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2347 | td->ber_decoder = asn1_DEF_Utf8_1.ber_decoder; |
| 2348 | td->der_encoder = asn1_DEF_Utf8_1.der_encoder; |
| 2349 | td->free_struct = asn1_DEF_Utf8_1.free_struct; |
| 2350 | td->print_struct = asn1_DEF_Utf8_1.print_struct; |
| 2351 | td->last_tag_form = asn1_DEF_Utf8_1.last_tag_form; |
| 2352 | td->elements = asn1_DEF_Utf8_1.elements; |
| 2353 | td->elements_count = asn1_DEF_Utf8_1.elements_count; |
| 2354 | td->specifics = asn1_DEF_Utf8_1.specifics; |
| 2355 | } |
| 2356 | |
| 2357 | ber_dec_rval_t |
| 2358 | Utf8_2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2359 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2360 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2361 | return td->ber_decoder(td, structure, |
| 2362 | bufptr, size, tag_mode); |
| 2363 | } |
| 2364 | |
| 2365 | der_enc_rval_t |
| 2366 | Utf8_2_encode_der(asn1_TYPE_descriptor_t *td, |
| 2367 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2368 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2369 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2370 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2371 | } |
| 2372 | |
| 2373 | int |
| 2374 | Utf8_2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2375 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2376 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2377 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2378 | } |
| 2379 | |
| 2380 | void |
| 2381 | Utf8_2_free(asn1_TYPE_descriptor_t *td, |
| 2382 | void *struct_ptr, int contents_only) { |
| 2383 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2384 | td->free_struct(td, struct_ptr, contents_only); |
| 2385 | } |
| 2386 | |
| 2387 | |
| 2388 | /*** <<< STAT-DEFS [Utf8-2] >>> ***/ |
| 2389 | |
| 2390 | static ber_tlv_tag_t asn1_DEF_Utf8_2_tags[] = { |
| 2391 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 2392 | }; |
| 2393 | asn1_TYPE_descriptor_t asn1_DEF_Utf8_2 = { |
| 2394 | "Utf8-2", |
| 2395 | Utf8_2_constraint, |
| 2396 | Utf8_2_decode_ber, |
| 2397 | Utf8_2_encode_der, |
| 2398 | Utf8_2_print, |
| 2399 | Utf8_2_free, |
| 2400 | 0, /* Use generic outmost tag fetcher */ |
| 2401 | asn1_DEF_Utf8_2_tags, |
| 2402 | sizeof(asn1_DEF_Utf8_2_tags) |
| 2403 | /sizeof(asn1_DEF_Utf8_2_tags[0]), /* 1 */ |
| 2404 | 1, /* Tags to skip */ |
| 2405 | -0, /* Unknown yet */ |
| 2406 | 0, 0, /* No members */ |
| 2407 | 0 /* No specifics */ |
| 2408 | }; |
| 2409 | |
| 2410 | |
| 2411 | /*** <<< INCLUDES [Utf8-1] >>> ***/ |
| 2412 | |
| 2413 | #include <UTF8String.h> |
| 2414 | |
| 2415 | /*** <<< TYPE-DECLS [Utf8-1] >>> ***/ |
| 2416 | |
| 2417 | |
| 2418 | typedef UTF8String_t Utf8_1_t; |
| 2419 | |
vlm | 7d576b3 | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2420 | /*** <<< FUNC-DECLS [Utf8-1] >>> ***/ |
| 2421 | |
| 2422 | extern asn1_TYPE_descriptor_t asn1_DEF_Utf8_1; |
| 2423 | asn_constr_check_f Utf8_1_constraint; |
| 2424 | ber_type_decoder_f Utf8_1_decode_ber; |
| 2425 | der_type_encoder_f Utf8_1_encode_der; |
| 2426 | asn_struct_print_f Utf8_1_print; |
| 2427 | asn_struct_free_f Utf8_1_free; |
| 2428 | |
| 2429 | /*** <<< CODE [Utf8-1] >>> ***/ |
| 2430 | |
| 2431 | int |
| 2432 | Utf8_1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2433 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2434 | |
| 2435 | /* Make the underlying type checker permanent */ |
| 2436 | td->check_constraints = asn1_DEF_UTF8String.check_constraints; |
| 2437 | return td->check_constraints |
| 2438 | (td, sptr, app_errlog, app_key); |
| 2439 | } |
| 2440 | |
| 2441 | /* |
| 2442 | * This type is implemented using UTF8String, |
| 2443 | * so adjust the DEF appropriately. |
| 2444 | */ |
| 2445 | static void |
| 2446 | Utf8_1_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2447 | td->ber_decoder = asn1_DEF_UTF8String.ber_decoder; |
| 2448 | td->der_encoder = asn1_DEF_UTF8String.der_encoder; |
| 2449 | td->free_struct = asn1_DEF_UTF8String.free_struct; |
| 2450 | td->print_struct = asn1_DEF_UTF8String.print_struct; |
| 2451 | td->last_tag_form = asn1_DEF_UTF8String.last_tag_form; |
| 2452 | td->elements = asn1_DEF_UTF8String.elements; |
| 2453 | td->elements_count = asn1_DEF_UTF8String.elements_count; |
| 2454 | td->specifics = asn1_DEF_UTF8String.specifics; |
| 2455 | } |
| 2456 | |
| 2457 | ber_dec_rval_t |
| 2458 | Utf8_1_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2459 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2460 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2461 | return td->ber_decoder(td, structure, |
| 2462 | bufptr, size, tag_mode); |
| 2463 | } |
| 2464 | |
| 2465 | der_enc_rval_t |
| 2466 | Utf8_1_encode_der(asn1_TYPE_descriptor_t *td, |
| 2467 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2468 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2469 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2470 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2471 | } |
| 2472 | |
| 2473 | int |
| 2474 | Utf8_1_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2475 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2476 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2477 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2478 | } |
| 2479 | |
| 2480 | void |
| 2481 | Utf8_1_free(asn1_TYPE_descriptor_t *td, |
| 2482 | void *struct_ptr, int contents_only) { |
| 2483 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2484 | td->free_struct(td, struct_ptr, contents_only); |
| 2485 | } |
| 2486 | |
| 2487 | |
| 2488 | /*** <<< STAT-DEFS [Utf8-1] >>> ***/ |
| 2489 | |
| 2490 | static ber_tlv_tag_t asn1_DEF_Utf8_1_tags[] = { |
| 2491 | (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)) |
| 2492 | }; |
| 2493 | asn1_TYPE_descriptor_t asn1_DEF_Utf8_1 = { |
| 2494 | "Utf8-1", |
| 2495 | Utf8_1_constraint, |
| 2496 | Utf8_1_decode_ber, |
| 2497 | Utf8_1_encode_der, |
| 2498 | Utf8_1_print, |
| 2499 | Utf8_1_free, |
| 2500 | 0, /* Use generic outmost tag fetcher */ |
| 2501 | asn1_DEF_Utf8_1_tags, |
| 2502 | sizeof(asn1_DEF_Utf8_1_tags) |
| 2503 | /sizeof(asn1_DEF_Utf8_1_tags[0]), /* 1 */ |
| 2504 | 1, /* Tags to skip */ |
| 2505 | -0, /* Unknown yet */ |
| 2506 | 0, 0, /* No members */ |
| 2507 | 0 /* No specifics */ |
| 2508 | }; |
| 2509 | |