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