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 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1087 | /*** <<< INCLUDES [Str4] >>> ***/ |
| 1088 | |
| 1089 | #include <IA5String.h> |
| 1090 | |
| 1091 | /*** <<< TYPE-DECLS [Str4] >>> ***/ |
| 1092 | |
| 1093 | |
| 1094 | typedef IA5String_t Str4_t; |
| 1095 | |
| 1096 | /*** <<< FUNC-DECLS [Str4] >>> ***/ |
| 1097 | |
| 1098 | extern asn1_TYPE_descriptor_t asn1_DEF_Str4; |
| 1099 | asn_constr_check_f Str4_constraint; |
| 1100 | ber_type_decoder_f Str4_decode_ber; |
| 1101 | der_type_encoder_f Str4_encode_der; |
| 1102 | asn_struct_print_f Str4_print; |
| 1103 | asn_struct_free_f Str4_free; |
| 1104 | |
| 1105 | /*** <<< CTABLES [Str4] >>> ***/ |
| 1106 | |
| 1107 | static int check_permitted_alphabet_3(const void *sptr) { |
| 1108 | /* The underlying type is IA5String */ |
| 1109 | const IA5String_t *st = sptr; |
| 1110 | const uint8_t *ch = st->buf; |
| 1111 | const uint8_t *end = ch + st->size; |
| 1112 | |
| 1113 | for(; ch < end; ch++) { |
| 1114 | uint8_t cv = *ch; |
| 1115 | if(!(cv <= 127)) return -1; |
| 1116 | } |
| 1117 | return 0; |
| 1118 | } |
| 1119 | |
| 1120 | |
| 1121 | /*** <<< CODE [Str4] >>> ***/ |
| 1122 | |
| 1123 | int |
| 1124 | Str4_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1125 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1126 | |
| 1127 | const IA5String_t *st = sptr; |
| 1128 | |
| 1129 | if(!sptr) { |
| 1130 | _ASN_ERRLOG(app_errlog, app_key, |
| 1131 | "%s: value not given (%s:%d)", |
| 1132 | td->name, __FILE__, __LINE__); |
| 1133 | return -1; |
| 1134 | } |
| 1135 | |
| 1136 | |
| 1137 | if(!check_permitted_alphabet_3(sptr)) { |
| 1138 | /* Constraint check succeeded */ |
| 1139 | return 0; |
| 1140 | } else { |
| 1141 | _ASN_ERRLOG(app_errlog, app_key, |
| 1142 | "%s: constraint failed (%s:%d)", |
| 1143 | td->name, __FILE__, __LINE__); |
| 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 | Str4_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 | Str4_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1166 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1167 | Str4_inherit_TYPE_descriptor(td); |
| 1168 | return td->ber_decoder(td, structure, |
| 1169 | bufptr, size, tag_mode); |
| 1170 | } |
| 1171 | |
| 1172 | der_enc_rval_t |
| 1173 | Str4_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 | Str4_inherit_TYPE_descriptor(td); |
| 1177 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1178 | } |
| 1179 | |
| 1180 | int |
| 1181 | Str4_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1182 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1183 | Str4_inherit_TYPE_descriptor(td); |
| 1184 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1185 | } |
| 1186 | |
| 1187 | void |
| 1188 | Str4_free(asn1_TYPE_descriptor_t *td, |
| 1189 | void *struct_ptr, int contents_only) { |
| 1190 | Str4_inherit_TYPE_descriptor(td); |
| 1191 | td->free_struct(td, struct_ptr, contents_only); |
| 1192 | } |
| 1193 | |
| 1194 | |
| 1195 | /*** <<< STAT-DEFS [Str4] >>> ***/ |
| 1196 | |
| 1197 | static ber_tlv_tag_t asn1_DEF_Str4_tags[] = { |
| 1198 | (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)) |
| 1199 | }; |
| 1200 | asn1_TYPE_descriptor_t asn1_DEF_Str4 = { |
| 1201 | "Str4", |
| 1202 | Str4_constraint, |
| 1203 | Str4_decode_ber, |
| 1204 | Str4_encode_der, |
| 1205 | Str4_print, |
| 1206 | Str4_free, |
| 1207 | 0, /* Use generic outmost tag fetcher */ |
| 1208 | asn1_DEF_Str4_tags, |
| 1209 | sizeof(asn1_DEF_Str4_tags) |
| 1210 | /sizeof(asn1_DEF_Str4_tags[0]), /* 1 */ |
| 1211 | 1, /* Tags to skip */ |
| 1212 | -0, /* Unknown yet */ |
| 1213 | 0, 0, /* No members */ |
| 1214 | 0 /* No specifics */ |
| 1215 | }; |
| 1216 | |
| 1217 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1218 | /*** <<< INCLUDES [PER-Visible] >>> ***/ |
| 1219 | |
| 1220 | #include <IA5String.h> |
| 1221 | |
| 1222 | /*** <<< TYPE-DECLS [PER-Visible] >>> ***/ |
| 1223 | |
| 1224 | |
| 1225 | typedef IA5String_t PER_Visible_t; |
| 1226 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1227 | /*** <<< FUNC-DECLS [PER-Visible] >>> ***/ |
| 1228 | |
| 1229 | extern asn1_TYPE_descriptor_t asn1_DEF_PER_Visible; |
| 1230 | asn_constr_check_f PER_Visible_constraint; |
| 1231 | ber_type_decoder_f PER_Visible_decode_ber; |
| 1232 | der_type_encoder_f PER_Visible_encode_der; |
| 1233 | asn_struct_print_f PER_Visible_print; |
| 1234 | asn_struct_free_f PER_Visible_free; |
| 1235 | |
| 1236 | /*** <<< CTABLES [PER-Visible] >>> ***/ |
| 1237 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1238 | static int check_permitted_alphabet_4(const void *sptr) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1239 | /* The underlying type is IA5String */ |
Lev Walkin | d1e5494 | 2004-08-21 07:34:17 +0000 | [diff] [blame] | 1240 | const IA5String_t *st = sptr; |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 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 >= 65 && 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] >>> ***/ |
| 1253 | |
| 1254 | int |
| 1255 | PER_Visible_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 IA5String_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 | 8a99bf7 | 2004-09-10 06:07:39 +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 IA5String, |
| 1281 | * so adjust the DEF appropriately. |
| 1282 | */ |
| 1283 | static void |
| 1284 | PER_Visible_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1285 | td->ber_decoder = asn1_DEF_IA5String.ber_decoder; |
| 1286 | td->der_encoder = asn1_DEF_IA5String.der_encoder; |
| 1287 | td->free_struct = asn1_DEF_IA5String.free_struct; |
| 1288 | td->print_struct = asn1_DEF_IA5String.print_struct; |
| 1289 | td->last_tag_form = asn1_DEF_IA5String.last_tag_form; |
| 1290 | td->elements = asn1_DEF_IA5String.elements; |
| 1291 | td->elements_count = asn1_DEF_IA5String.elements_count; |
| 1292 | td->specifics = asn1_DEF_IA5String.specifics; |
| 1293 | } |
| 1294 | |
| 1295 | ber_dec_rval_t |
| 1296 | PER_Visible_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1297 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1298 | PER_Visible_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_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_inherit_TYPE_descriptor(td); |
| 1308 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1309 | } |
| 1310 | |
| 1311 | int |
| 1312 | PER_Visible_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_inherit_TYPE_descriptor(td); |
| 1315 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1316 | } |
| 1317 | |
| 1318 | void |
| 1319 | PER_Visible_free(asn1_TYPE_descriptor_t *td, |
| 1320 | void *struct_ptr, int contents_only) { |
| 1321 | PER_Visible_inherit_TYPE_descriptor(td); |
| 1322 | td->free_struct(td, struct_ptr, contents_only); |
| 1323 | } |
| 1324 | |
| 1325 | |
| 1326 | /*** <<< STAT-DEFS [PER-Visible] >>> ***/ |
| 1327 | |
| 1328 | static ber_tlv_tag_t asn1_DEF_PER_Visible_tags[] = { |
| 1329 | (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)) |
| 1330 | }; |
| 1331 | asn1_TYPE_descriptor_t asn1_DEF_PER_Visible = { |
| 1332 | "PER-Visible", |
| 1333 | PER_Visible_constraint, |
| 1334 | PER_Visible_decode_ber, |
| 1335 | PER_Visible_encode_der, |
| 1336 | PER_Visible_print, |
| 1337 | PER_Visible_free, |
| 1338 | 0, /* Use generic outmost tag fetcher */ |
| 1339 | asn1_DEF_PER_Visible_tags, |
| 1340 | sizeof(asn1_DEF_PER_Visible_tags) |
| 1341 | /sizeof(asn1_DEF_PER_Visible_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 [PER-Visible-2] >>> ***/ |
| 1350 | |
| 1351 | #include <PER-Visible.h> |
| 1352 | |
| 1353 | /*** <<< TYPE-DECLS [PER-Visible-2] >>> ***/ |
| 1354 | |
| 1355 | |
| 1356 | typedef PER_Visible_t PER_Visible_2_t; |
| 1357 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1358 | /*** <<< FUNC-DECLS [PER-Visible-2] >>> ***/ |
| 1359 | |
| 1360 | extern asn1_TYPE_descriptor_t asn1_DEF_PER_Visible_2; |
| 1361 | asn_constr_check_f PER_Visible_2_constraint; |
| 1362 | ber_type_decoder_f PER_Visible_2_decode_ber; |
| 1363 | der_type_encoder_f PER_Visible_2_encode_der; |
| 1364 | asn_struct_print_f PER_Visible_2_print; |
| 1365 | asn_struct_free_f PER_Visible_2_free; |
| 1366 | |
| 1367 | /*** <<< CTABLES [PER-Visible-2] >>> ***/ |
| 1368 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1369 | static int check_permitted_alphabet_5(const void *sptr) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 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 >= 69 && 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 [PER-Visible-2] >>> ***/ |
| 1384 | |
| 1385 | int |
| 1386 | PER_Visible_2_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 | 8a99bf7 | 2004-09-10 06:07:39 +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 | PER_Visible_2_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 | PER_Visible_2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1428 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1429 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1430 | return td->ber_decoder(td, structure, |
| 1431 | bufptr, size, tag_mode); |
| 1432 | } |
| 1433 | |
| 1434 | der_enc_rval_t |
| 1435 | PER_Visible_2_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 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1439 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1440 | } |
| 1441 | |
| 1442 | int |
| 1443 | PER_Visible_2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1444 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1445 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1446 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1447 | } |
| 1448 | |
| 1449 | void |
| 1450 | PER_Visible_2_free(asn1_TYPE_descriptor_t *td, |
| 1451 | void *struct_ptr, int contents_only) { |
| 1452 | PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1453 | td->free_struct(td, struct_ptr, contents_only); |
| 1454 | } |
| 1455 | |
| 1456 | |
| 1457 | /*** <<< STAT-DEFS [PER-Visible-2] >>> ***/ |
| 1458 | |
| 1459 | static ber_tlv_tag_t asn1_DEF_PER_Visible_2_tags[] = { |
| 1460 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1461 | }; |
| 1462 | asn1_TYPE_descriptor_t asn1_DEF_PER_Visible_2 = { |
| 1463 | "PER-Visible-2", |
| 1464 | PER_Visible_2_constraint, |
| 1465 | PER_Visible_2_decode_ber, |
| 1466 | PER_Visible_2_encode_der, |
| 1467 | PER_Visible_2_print, |
| 1468 | PER_Visible_2_free, |
| 1469 | 0, /* Use generic outmost tag fetcher */ |
| 1470 | asn1_DEF_PER_Visible_2_tags, |
| 1471 | sizeof(asn1_DEF_PER_Visible_2_tags) |
| 1472 | /sizeof(asn1_DEF_PER_Visible_2_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-1] >>> ***/ |
| 1481 | |
| 1482 | #include <PER-Visible.h> |
| 1483 | |
| 1484 | /*** <<< TYPE-DECLS [Not-PER-Visible-1] >>> ***/ |
| 1485 | |
| 1486 | |
| 1487 | typedef PER_Visible_t Not_PER_Visible_1_t; |
| 1488 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1489 | /*** <<< FUNC-DECLS [Not-PER-Visible-1] >>> ***/ |
| 1490 | |
| 1491 | extern asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_1; |
| 1492 | asn_constr_check_f Not_PER_Visible_1_constraint; |
| 1493 | ber_type_decoder_f Not_PER_Visible_1_decode_ber; |
| 1494 | der_type_encoder_f Not_PER_Visible_1_encode_der; |
| 1495 | asn_struct_print_f Not_PER_Visible_1_print; |
| 1496 | asn_struct_free_f Not_PER_Visible_1_free; |
| 1497 | |
| 1498 | /*** <<< CTABLES [Not-PER-Visible-1] >>> ***/ |
| 1499 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1500 | static int check_permitted_alphabet_6(const void *sptr) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1501 | /* The underlying type is IA5String */ |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1502 | const IA5String_t *st = sptr; |
| 1503 | const uint8_t *ch = st->buf; |
| 1504 | const uint8_t *end = ch + st->size; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1505 | |
| 1506 | for(; ch < end; ch++) { |
| 1507 | uint8_t cv = *ch; |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1508 | if(!(cv >= 65 && cv <= 70)) return -1; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1509 | } |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1510 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1511 | } |
| 1512 | |
| 1513 | |
| 1514 | /*** <<< CODE [Not-PER-Visible-1] >>> ***/ |
| 1515 | |
| 1516 | int |
| 1517 | Not_PER_Visible_1_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 | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1530 | if(!check_permitted_alphabet_6(sptr)) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1531 | /* Constraint check succeeded */ |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1532 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1533 | } else { |
| 1534 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1535 | "%s: constraint failed (%s:%d)", |
| 1536 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1537 | return -1; |
| 1538 | } |
| 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_1_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_1_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1559 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1560 | Not_PER_Visible_1_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_1_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_1_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_1_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_1_inherit_TYPE_descriptor(td); |
| 1577 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1578 | } |
| 1579 | |
| 1580 | void |
| 1581 | Not_PER_Visible_1_free(asn1_TYPE_descriptor_t *td, |
| 1582 | void *struct_ptr, int contents_only) { |
| 1583 | Not_PER_Visible_1_inherit_TYPE_descriptor(td); |
| 1584 | td->free_struct(td, struct_ptr, contents_only); |
| 1585 | } |
| 1586 | |
| 1587 | |
| 1588 | /*** <<< STAT-DEFS [Not-PER-Visible-1] >>> ***/ |
| 1589 | |
| 1590 | static ber_tlv_tag_t asn1_DEF_Not_PER_Visible_1_tags[] = { |
| 1591 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1592 | }; |
| 1593 | asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_1 = { |
| 1594 | "Not-PER-Visible-1", |
| 1595 | Not_PER_Visible_1_constraint, |
| 1596 | Not_PER_Visible_1_decode_ber, |
| 1597 | Not_PER_Visible_1_encode_der, |
| 1598 | Not_PER_Visible_1_print, |
| 1599 | Not_PER_Visible_1_free, |
| 1600 | 0, /* Use generic outmost tag fetcher */ |
| 1601 | asn1_DEF_Not_PER_Visible_1_tags, |
| 1602 | sizeof(asn1_DEF_Not_PER_Visible_1_tags) |
| 1603 | /sizeof(asn1_DEF_Not_PER_Visible_1_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-2] >>> ***/ |
| 1612 | |
| 1613 | #include <PER-Visible.h> |
| 1614 | |
| 1615 | /*** <<< TYPE-DECLS [Not-PER-Visible-2] >>> ***/ |
| 1616 | |
| 1617 | |
| 1618 | typedef PER_Visible_t Not_PER_Visible_2_t; |
| 1619 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1620 | /*** <<< FUNC-DECLS [Not-PER-Visible-2] >>> ***/ |
| 1621 | |
| 1622 | extern asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_2; |
| 1623 | asn_constr_check_f Not_PER_Visible_2_constraint; |
| 1624 | ber_type_decoder_f Not_PER_Visible_2_decode_ber; |
| 1625 | der_type_encoder_f Not_PER_Visible_2_encode_der; |
| 1626 | asn_struct_print_f Not_PER_Visible_2_print; |
| 1627 | asn_struct_free_f Not_PER_Visible_2_free; |
| 1628 | |
Lev Walkin | d35c8b5 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1629 | /*** <<< CTABLES [Not-PER-Visible-2] >>> ***/ |
| 1630 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1631 | static int check_permitted_alphabet_7(const void *sptr) { |
Lev Walkin | d35c8b5 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 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-2] >>> ***/ |
| 1646 | |
| 1647 | int |
| 1648 | Not_PER_Visible_2_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 | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1661 | if(!check_permitted_alphabet_7(sptr)) { |
Lev Walkin | d35c8b5 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 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_2_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_2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1690 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1691 | Not_PER_Visible_2_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_2_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_2_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_2_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_2_inherit_TYPE_descriptor(td); |
| 1708 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1709 | } |
| 1710 | |
| 1711 | void |
| 1712 | Not_PER_Visible_2_free(asn1_TYPE_descriptor_t *td, |
| 1713 | void *struct_ptr, int contents_only) { |
| 1714 | Not_PER_Visible_2_inherit_TYPE_descriptor(td); |
| 1715 | td->free_struct(td, struct_ptr, contents_only); |
| 1716 | } |
| 1717 | |
| 1718 | |
| 1719 | /*** <<< STAT-DEFS [Not-PER-Visible-2] >>> ***/ |
| 1720 | |
| 1721 | static ber_tlv_tag_t asn1_DEF_Not_PER_Visible_2_tags[] = { |
| 1722 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1723 | }; |
| 1724 | asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_2 = { |
| 1725 | "Not-PER-Visible-2", |
| 1726 | Not_PER_Visible_2_constraint, |
| 1727 | Not_PER_Visible_2_decode_ber, |
| 1728 | Not_PER_Visible_2_encode_der, |
| 1729 | Not_PER_Visible_2_print, |
| 1730 | Not_PER_Visible_2_free, |
| 1731 | 0, /* Use generic outmost tag fetcher */ |
| 1732 | asn1_DEF_Not_PER_Visible_2_tags, |
| 1733 | sizeof(asn1_DEF_Not_PER_Visible_2_tags) |
| 1734 | /sizeof(asn1_DEF_Not_PER_Visible_2_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 [Not-PER-Visible-3] >>> ***/ |
| 1743 | |
| 1744 | #include <PER-Visible.h> |
| 1745 | |
| 1746 | /*** <<< TYPE-DECLS [Not-PER-Visible-3] >>> ***/ |
| 1747 | |
| 1748 | |
| 1749 | typedef PER_Visible_t Not_PER_Visible_3_t; |
| 1750 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1751 | /*** <<< FUNC-DECLS [Not-PER-Visible-3] >>> ***/ |
| 1752 | |
| 1753 | extern asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_3; |
| 1754 | asn_constr_check_f Not_PER_Visible_3_constraint; |
| 1755 | ber_type_decoder_f Not_PER_Visible_3_decode_ber; |
| 1756 | der_type_encoder_f Not_PER_Visible_3_encode_der; |
| 1757 | asn_struct_print_f Not_PER_Visible_3_print; |
| 1758 | asn_struct_free_f Not_PER_Visible_3_free; |
| 1759 | |
Lev Walkin | d35c8b5 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1760 | /*** <<< CTABLES [Not-PER-Visible-3] >>> ***/ |
| 1761 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1762 | static int check_permitted_alphabet_8(const void *sptr) { |
Lev Walkin | d35c8b5 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1763 | /* The underlying type is IA5String */ |
| 1764 | const IA5String_t *st = sptr; |
| 1765 | const uint8_t *ch = st->buf; |
| 1766 | const uint8_t *end = ch + st->size; |
| 1767 | |
| 1768 | for(; ch < end; ch++) { |
| 1769 | uint8_t cv = *ch; |
| 1770 | if(!(cv >= 65 && cv <= 66)) return -1; |
| 1771 | } |
| 1772 | return 0; |
| 1773 | } |
| 1774 | |
| 1775 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1776 | /*** <<< CODE [Not-PER-Visible-3] >>> ***/ |
| 1777 | |
| 1778 | int |
| 1779 | Not_PER_Visible_3_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 | |
| 1784 | if(!sptr) { |
| 1785 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1786 | "%s: value not given (%s:%d)", |
| 1787 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1788 | return -1; |
| 1789 | } |
| 1790 | |
| 1791 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1792 | if(!check_permitted_alphabet_8(sptr)) { |
Lev Walkin | d35c8b5 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1793 | /* Constraint check succeeded */ |
| 1794 | return 0; |
| 1795 | } else { |
| 1796 | _ASN_ERRLOG(app_errlog, app_key, |
| 1797 | "%s: constraint failed (%s:%d)", |
| 1798 | td->name, __FILE__, __LINE__); |
| 1799 | return -1; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1800 | } |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1801 | } |
| 1802 | |
| 1803 | /* |
| 1804 | * This type is implemented using PER_Visible, |
| 1805 | * so adjust the DEF appropriately. |
| 1806 | */ |
| 1807 | static void |
| 1808 | Not_PER_Visible_3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1809 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1810 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1811 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1812 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1813 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1814 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1815 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1816 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1817 | } |
| 1818 | |
| 1819 | ber_dec_rval_t |
| 1820 | Not_PER_Visible_3_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1821 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1822 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1823 | return td->ber_decoder(td, structure, |
| 1824 | bufptr, size, tag_mode); |
| 1825 | } |
| 1826 | |
| 1827 | der_enc_rval_t |
| 1828 | Not_PER_Visible_3_encode_der(asn1_TYPE_descriptor_t *td, |
| 1829 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1830 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1831 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1832 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1833 | } |
| 1834 | |
| 1835 | int |
| 1836 | Not_PER_Visible_3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1837 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1838 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1839 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1840 | } |
| 1841 | |
| 1842 | void |
| 1843 | Not_PER_Visible_3_free(asn1_TYPE_descriptor_t *td, |
| 1844 | void *struct_ptr, int contents_only) { |
| 1845 | Not_PER_Visible_3_inherit_TYPE_descriptor(td); |
| 1846 | td->free_struct(td, struct_ptr, contents_only); |
| 1847 | } |
| 1848 | |
| 1849 | |
| 1850 | /*** <<< STAT-DEFS [Not-PER-Visible-3] >>> ***/ |
| 1851 | |
| 1852 | static ber_tlv_tag_t asn1_DEF_Not_PER_Visible_3_tags[] = { |
| 1853 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1854 | }; |
| 1855 | asn1_TYPE_descriptor_t asn1_DEF_Not_PER_Visible_3 = { |
| 1856 | "Not-PER-Visible-3", |
| 1857 | Not_PER_Visible_3_constraint, |
| 1858 | Not_PER_Visible_3_decode_ber, |
| 1859 | Not_PER_Visible_3_encode_der, |
| 1860 | Not_PER_Visible_3_print, |
| 1861 | Not_PER_Visible_3_free, |
| 1862 | 0, /* Use generic outmost tag fetcher */ |
| 1863 | asn1_DEF_Not_PER_Visible_3_tags, |
| 1864 | sizeof(asn1_DEF_Not_PER_Visible_3_tags) |
| 1865 | /sizeof(asn1_DEF_Not_PER_Visible_3_tags[0]), /* 1 */ |
| 1866 | 1, /* Tags to skip */ |
| 1867 | -0, /* Unknown yet */ |
| 1868 | 0, 0, /* No members */ |
| 1869 | 0 /* No specifics */ |
| 1870 | }; |
| 1871 | |
| 1872 | |
| 1873 | /*** <<< INCLUDES [SIZE-but-not-FROM] >>> ***/ |
| 1874 | |
| 1875 | #include <PER-Visible.h> |
| 1876 | |
| 1877 | /*** <<< TYPE-DECLS [SIZE-but-not-FROM] >>> ***/ |
| 1878 | |
| 1879 | |
| 1880 | typedef PER_Visible_t SIZE_but_not_FROM_t; |
| 1881 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1882 | /*** <<< FUNC-DECLS [SIZE-but-not-FROM] >>> ***/ |
| 1883 | |
| 1884 | extern asn1_TYPE_descriptor_t asn1_DEF_SIZE_but_not_FROM; |
| 1885 | asn_constr_check_f SIZE_but_not_FROM_constraint; |
| 1886 | ber_type_decoder_f SIZE_but_not_FROM_decode_ber; |
| 1887 | der_type_encoder_f SIZE_but_not_FROM_encode_der; |
| 1888 | asn_struct_print_f SIZE_but_not_FROM_print; |
| 1889 | asn_struct_free_f SIZE_but_not_FROM_free; |
| 1890 | |
| 1891 | /*** <<< CTABLES [SIZE-but-not-FROM] >>> ***/ |
| 1892 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1893 | static int check_permitted_alphabet_9(const void *sptr) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1894 | /* The underlying type is IA5String */ |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1895 | const IA5String_t *st = sptr; |
| 1896 | const uint8_t *ch = st->buf; |
| 1897 | const uint8_t *end = ch + st->size; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1898 | |
| 1899 | for(; ch < end; ch++) { |
| 1900 | uint8_t cv = *ch; |
Lev Walkin | d35c8b5 | 2004-08-25 02:08:08 +0000 | [diff] [blame] | 1901 | if(!(cv >= 65 && cv <= 68)) return -1; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1902 | } |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1903 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1904 | } |
| 1905 | |
| 1906 | |
| 1907 | /*** <<< CODE [SIZE-but-not-FROM] >>> ***/ |
| 1908 | |
| 1909 | int |
| 1910 | SIZE_but_not_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 1911 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 1912 | |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 1913 | const PER_Visible_t *st = sptr; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1914 | size_t size; |
| 1915 | |
| 1916 | if(!sptr) { |
| 1917 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1918 | "%s: value not given (%s:%d)", |
| 1919 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1920 | return -1; |
| 1921 | } |
| 1922 | |
| 1923 | size = st->size; |
| 1924 | |
| 1925 | if((size >= 1 && size <= 4) |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 1926 | && !check_permitted_alphabet_9(sptr)) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1927 | /* Constraint check succeeded */ |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 1928 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1929 | } else { |
| 1930 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 1931 | "%s: constraint failed (%s:%d)", |
| 1932 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 1933 | return -1; |
| 1934 | } |
| 1935 | } |
| 1936 | |
| 1937 | /* |
| 1938 | * This type is implemented using PER_Visible, |
| 1939 | * so adjust the DEF appropriately. |
| 1940 | */ |
| 1941 | static void |
| 1942 | SIZE_but_not_FROM_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 1943 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 1944 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 1945 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 1946 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 1947 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 1948 | td->elements = asn1_DEF_PER_Visible.elements; |
| 1949 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 1950 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 1951 | } |
| 1952 | |
| 1953 | ber_dec_rval_t |
| 1954 | SIZE_but_not_FROM_decode_ber(asn1_TYPE_descriptor_t *td, |
| 1955 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 1956 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1957 | return td->ber_decoder(td, structure, |
| 1958 | bufptr, size, tag_mode); |
| 1959 | } |
| 1960 | |
| 1961 | der_enc_rval_t |
| 1962 | SIZE_but_not_FROM_encode_der(asn1_TYPE_descriptor_t *td, |
| 1963 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 1964 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 1965 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1966 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 1967 | } |
| 1968 | |
| 1969 | int |
| 1970 | SIZE_but_not_FROM_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 1971 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 1972 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1973 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 1974 | } |
| 1975 | |
| 1976 | void |
| 1977 | SIZE_but_not_FROM_free(asn1_TYPE_descriptor_t *td, |
| 1978 | void *struct_ptr, int contents_only) { |
| 1979 | SIZE_but_not_FROM_inherit_TYPE_descriptor(td); |
| 1980 | td->free_struct(td, struct_ptr, contents_only); |
| 1981 | } |
| 1982 | |
| 1983 | |
| 1984 | /*** <<< STAT-DEFS [SIZE-but-not-FROM] >>> ***/ |
| 1985 | |
| 1986 | static ber_tlv_tag_t asn1_DEF_SIZE_but_not_FROM_tags[] = { |
| 1987 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 1988 | }; |
| 1989 | asn1_TYPE_descriptor_t asn1_DEF_SIZE_but_not_FROM = { |
| 1990 | "SIZE-but-not-FROM", |
| 1991 | SIZE_but_not_FROM_constraint, |
| 1992 | SIZE_but_not_FROM_decode_ber, |
| 1993 | SIZE_but_not_FROM_encode_der, |
| 1994 | SIZE_but_not_FROM_print, |
| 1995 | SIZE_but_not_FROM_free, |
| 1996 | 0, /* Use generic outmost tag fetcher */ |
| 1997 | asn1_DEF_SIZE_but_not_FROM_tags, |
| 1998 | sizeof(asn1_DEF_SIZE_but_not_FROM_tags) |
| 1999 | /sizeof(asn1_DEF_SIZE_but_not_FROM_tags[0]), /* 1 */ |
| 2000 | 1, /* Tags to skip */ |
| 2001 | -0, /* Unknown yet */ |
| 2002 | 0, 0, /* No members */ |
| 2003 | 0 /* No specifics */ |
| 2004 | }; |
| 2005 | |
| 2006 | |
| 2007 | /*** <<< INCLUDES [SIZE-and-FROM] >>> ***/ |
| 2008 | |
| 2009 | #include <PER-Visible.h> |
| 2010 | |
| 2011 | /*** <<< TYPE-DECLS [SIZE-and-FROM] >>> ***/ |
| 2012 | |
| 2013 | |
| 2014 | typedef PER_Visible_t SIZE_and_FROM_t; |
| 2015 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2016 | /*** <<< FUNC-DECLS [SIZE-and-FROM] >>> ***/ |
| 2017 | |
| 2018 | extern asn1_TYPE_descriptor_t asn1_DEF_SIZE_and_FROM; |
| 2019 | asn_constr_check_f SIZE_and_FROM_constraint; |
| 2020 | ber_type_decoder_f SIZE_and_FROM_decode_ber; |
| 2021 | der_type_encoder_f SIZE_and_FROM_encode_der; |
| 2022 | asn_struct_print_f SIZE_and_FROM_print; |
| 2023 | asn_struct_free_f SIZE_and_FROM_free; |
| 2024 | |
| 2025 | /*** <<< CTABLES [SIZE-and-FROM] >>> ***/ |
| 2026 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 2027 | static int check_permitted_alphabet_10(const void *sptr) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2028 | /* The underlying type is IA5String */ |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2029 | const IA5String_t *st = sptr; |
| 2030 | const uint8_t *ch = st->buf; |
| 2031 | const uint8_t *end = ch + st->size; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2032 | |
| 2033 | for(; ch < end; ch++) { |
| 2034 | uint8_t cv = *ch; |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2035 | if(!(cv >= 65 && cv <= 68)) return -1; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2036 | } |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2037 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2038 | } |
| 2039 | |
| 2040 | |
| 2041 | /*** <<< CODE [SIZE-and-FROM] >>> ***/ |
| 2042 | |
| 2043 | int |
| 2044 | SIZE_and_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2045 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2046 | |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2047 | const PER_Visible_t *st = sptr; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2048 | size_t size; |
| 2049 | |
| 2050 | if(!sptr) { |
| 2051 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2052 | "%s: value not given (%s:%d)", |
| 2053 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2054 | return -1; |
| 2055 | } |
| 2056 | |
| 2057 | size = st->size; |
| 2058 | |
| 2059 | if((size >= 1 && size <= 4) |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 2060 | && !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 | SIZE_and_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 | SIZE_and_FROM_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2089 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2090 | SIZE_and_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 | SIZE_and_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 | SIZE_and_FROM_inherit_TYPE_descriptor(td); |
| 2100 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2101 | } |
| 2102 | |
| 2103 | int |
| 2104 | SIZE_and_FROM_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2105 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2106 | SIZE_and_FROM_inherit_TYPE_descriptor(td); |
| 2107 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2108 | } |
| 2109 | |
| 2110 | void |
| 2111 | SIZE_and_FROM_free(asn1_TYPE_descriptor_t *td, |
| 2112 | void *struct_ptr, int contents_only) { |
| 2113 | SIZE_and_FROM_inherit_TYPE_descriptor(td); |
| 2114 | td->free_struct(td, struct_ptr, contents_only); |
| 2115 | } |
| 2116 | |
| 2117 | |
| 2118 | /*** <<< STAT-DEFS [SIZE-and-FROM] >>> ***/ |
| 2119 | |
| 2120 | static ber_tlv_tag_t asn1_DEF_SIZE_and_FROM_tags[] = { |
| 2121 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 2122 | }; |
| 2123 | asn1_TYPE_descriptor_t asn1_DEF_SIZE_and_FROM = { |
| 2124 | "SIZE-and-FROM", |
| 2125 | SIZE_and_FROM_constraint, |
| 2126 | SIZE_and_FROM_decode_ber, |
| 2127 | SIZE_and_FROM_encode_der, |
| 2128 | SIZE_and_FROM_print, |
| 2129 | SIZE_and_FROM_free, |
| 2130 | 0, /* Use generic outmost tag fetcher */ |
| 2131 | asn1_DEF_SIZE_and_FROM_tags, |
| 2132 | sizeof(asn1_DEF_SIZE_and_FROM_tags) |
| 2133 | /sizeof(asn1_DEF_SIZE_and_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 [Neither-SIZE-nor-FROM] >>> ***/ |
| 2142 | |
| 2143 | #include <PER-Visible.h> |
| 2144 | |
| 2145 | /*** <<< TYPE-DECLS [Neither-SIZE-nor-FROM] >>> ***/ |
| 2146 | |
| 2147 | |
| 2148 | typedef PER_Visible_t Neither_SIZE_nor_FROM_t; |
| 2149 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2150 | /*** <<< FUNC-DECLS [Neither-SIZE-nor-FROM] >>> ***/ |
| 2151 | |
| 2152 | extern asn1_TYPE_descriptor_t asn1_DEF_Neither_SIZE_nor_FROM; |
| 2153 | asn_constr_check_f Neither_SIZE_nor_FROM_constraint; |
| 2154 | ber_type_decoder_f Neither_SIZE_nor_FROM_decode_ber; |
| 2155 | der_type_encoder_f Neither_SIZE_nor_FROM_encode_der; |
| 2156 | asn_struct_print_f Neither_SIZE_nor_FROM_print; |
| 2157 | asn_struct_free_f Neither_SIZE_nor_FROM_free; |
| 2158 | |
| 2159 | /*** <<< CTABLES [Neither-SIZE-nor-FROM] >>> ***/ |
| 2160 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 2161 | static int check_permitted_alphabet_11(const void *sptr) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2162 | /* The underlying type is IA5String */ |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2163 | const IA5String_t *st = sptr; |
| 2164 | const uint8_t *ch = st->buf; |
| 2165 | const uint8_t *end = ch + st->size; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2166 | |
| 2167 | for(; ch < end; ch++) { |
| 2168 | uint8_t cv = *ch; |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2169 | if(!(cv >= 65 && cv <= 70)) return -1; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2170 | } |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2171 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2172 | } |
| 2173 | |
| 2174 | |
| 2175 | /*** <<< CODE [Neither-SIZE-nor-FROM] >>> ***/ |
| 2176 | |
| 2177 | int |
| 2178 | Neither_SIZE_nor_FROM_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2179 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2180 | |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2181 | const PER_Visible_t *st = sptr; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2182 | |
| 2183 | if(!sptr) { |
| 2184 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2185 | "%s: value not given (%s:%d)", |
| 2186 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2187 | return -1; |
| 2188 | } |
| 2189 | |
| 2190 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 2191 | if(!check_permitted_alphabet_11(sptr)) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2192 | /* Constraint check succeeded */ |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2193 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2194 | } else { |
| 2195 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2196 | "%s: constraint failed (%s:%d)", |
| 2197 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2198 | return -1; |
| 2199 | } |
| 2200 | } |
| 2201 | |
| 2202 | /* |
| 2203 | * This type is implemented using PER_Visible, |
| 2204 | * so adjust the DEF appropriately. |
| 2205 | */ |
| 2206 | static void |
| 2207 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2208 | td->ber_decoder = asn1_DEF_PER_Visible.ber_decoder; |
| 2209 | td->der_encoder = asn1_DEF_PER_Visible.der_encoder; |
| 2210 | td->free_struct = asn1_DEF_PER_Visible.free_struct; |
| 2211 | td->print_struct = asn1_DEF_PER_Visible.print_struct; |
| 2212 | td->last_tag_form = asn1_DEF_PER_Visible.last_tag_form; |
| 2213 | td->elements = asn1_DEF_PER_Visible.elements; |
| 2214 | td->elements_count = asn1_DEF_PER_Visible.elements_count; |
| 2215 | td->specifics = asn1_DEF_PER_Visible.specifics; |
| 2216 | } |
| 2217 | |
| 2218 | ber_dec_rval_t |
| 2219 | Neither_SIZE_nor_FROM_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2220 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2221 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2222 | return td->ber_decoder(td, structure, |
| 2223 | bufptr, size, tag_mode); |
| 2224 | } |
| 2225 | |
| 2226 | der_enc_rval_t |
| 2227 | Neither_SIZE_nor_FROM_encode_der(asn1_TYPE_descriptor_t *td, |
| 2228 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2229 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2230 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2231 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2232 | } |
| 2233 | |
| 2234 | int |
| 2235 | Neither_SIZE_nor_FROM_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2236 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2237 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2238 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2239 | } |
| 2240 | |
| 2241 | void |
| 2242 | Neither_SIZE_nor_FROM_free(asn1_TYPE_descriptor_t *td, |
| 2243 | void *struct_ptr, int contents_only) { |
| 2244 | Neither_SIZE_nor_FROM_inherit_TYPE_descriptor(td); |
| 2245 | td->free_struct(td, struct_ptr, contents_only); |
| 2246 | } |
| 2247 | |
| 2248 | |
| 2249 | /*** <<< STAT-DEFS [Neither-SIZE-nor-FROM] >>> ***/ |
| 2250 | |
| 2251 | static ber_tlv_tag_t asn1_DEF_Neither_SIZE_nor_FROM_tags[] = { |
| 2252 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 2253 | }; |
| 2254 | asn1_TYPE_descriptor_t asn1_DEF_Neither_SIZE_nor_FROM = { |
| 2255 | "Neither-SIZE-nor-FROM", |
| 2256 | Neither_SIZE_nor_FROM_constraint, |
| 2257 | Neither_SIZE_nor_FROM_decode_ber, |
| 2258 | Neither_SIZE_nor_FROM_encode_der, |
| 2259 | Neither_SIZE_nor_FROM_print, |
| 2260 | Neither_SIZE_nor_FROM_free, |
| 2261 | 0, /* Use generic outmost tag fetcher */ |
| 2262 | asn1_DEF_Neither_SIZE_nor_FROM_tags, |
| 2263 | sizeof(asn1_DEF_Neither_SIZE_nor_FROM_tags) |
| 2264 | /sizeof(asn1_DEF_Neither_SIZE_nor_FROM_tags[0]), /* 1 */ |
| 2265 | 1, /* Tags to skip */ |
| 2266 | -0, /* Unknown yet */ |
| 2267 | 0, 0, /* No members */ |
| 2268 | 0 /* No specifics */ |
| 2269 | }; |
| 2270 | |
| 2271 | |
| 2272 | /*** <<< INCLUDES [Utf8-3] >>> ***/ |
| 2273 | |
| 2274 | #include <Utf8-2.h> |
| 2275 | |
| 2276 | /*** <<< TYPE-DECLS [Utf8-3] >>> ***/ |
| 2277 | |
| 2278 | |
| 2279 | typedef Utf8_2_t Utf8_3_t; |
| 2280 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2281 | /*** <<< FUNC-DECLS [Utf8-3] >>> ***/ |
| 2282 | |
| 2283 | extern asn1_TYPE_descriptor_t asn1_DEF_Utf8_3; |
| 2284 | asn_constr_check_f Utf8_3_constraint; |
| 2285 | ber_type_decoder_f Utf8_3_decode_ber; |
| 2286 | der_type_encoder_f Utf8_3_encode_der; |
| 2287 | asn_struct_print_f Utf8_3_print; |
| 2288 | asn_struct_free_f Utf8_3_free; |
| 2289 | |
| 2290 | /*** <<< CTABLES [Utf8-3] >>> ***/ |
| 2291 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 2292 | static int permitted_alphabet_table_12[128] = { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2293 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2294 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2295 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2296 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* */ |
| 2297 | 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ABCDEFGHIJKLMNO */ |
| 2298 | 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* PQRSTUVWXYZ */ |
| 2299 | 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* abcdefghijklmno */ |
| 2300 | 1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0, /* pqrstuvwxyz */ |
| 2301 | }; |
| 2302 | |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 2303 | static int check_permitted_alphabet_12(const void *sptr) { |
| 2304 | int *table = permitted_alphabet_table_12; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2305 | /* The underlying type is UTF8String */ |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2306 | const UTF8String_t *st = sptr; |
| 2307 | const uint8_t *ch = st->buf; |
| 2308 | const uint8_t *end = ch + st->size; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2309 | |
| 2310 | for(; ch < end; ch++) { |
| 2311 | uint8_t cv = *ch; |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2312 | if(cv >= 0x80) return -1; |
| 2313 | if(!table[cv]) return -1; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2314 | } |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2315 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2316 | } |
| 2317 | |
| 2318 | |
| 2319 | /*** <<< CODE [Utf8-3] >>> ***/ |
| 2320 | |
| 2321 | int |
| 2322 | Utf8_3_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2323 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2324 | |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2325 | const Utf8_2_t *st = sptr; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2326 | size_t size; |
| 2327 | |
| 2328 | if(!sptr) { |
| 2329 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2330 | "%s: value not given (%s:%d)", |
| 2331 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2332 | return -1; |
| 2333 | } |
| 2334 | |
| 2335 | size = UTF8String_length(st, td->name, app_errlog, app_key); |
| 2336 | if(size == (size_t)-1) return -1; |
| 2337 | |
| 2338 | if((size >= 1 && size <= 2) |
Lev Walkin | 8a99bf7 | 2004-09-10 06:07:39 +0000 | [diff] [blame] | 2339 | && !check_permitted_alphabet_12(sptr)) { |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2340 | /* Constraint check succeeded */ |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2341 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2342 | } else { |
| 2343 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2344 | "%s: constraint failed (%s:%d)", |
| 2345 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2346 | return -1; |
| 2347 | } |
| 2348 | } |
| 2349 | |
| 2350 | /* |
| 2351 | * This type is implemented using Utf8_2, |
| 2352 | * so adjust the DEF appropriately. |
| 2353 | */ |
| 2354 | static void |
| 2355 | Utf8_3_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2356 | td->ber_decoder = asn1_DEF_Utf8_2.ber_decoder; |
| 2357 | td->der_encoder = asn1_DEF_Utf8_2.der_encoder; |
| 2358 | td->free_struct = asn1_DEF_Utf8_2.free_struct; |
| 2359 | td->print_struct = asn1_DEF_Utf8_2.print_struct; |
| 2360 | td->last_tag_form = asn1_DEF_Utf8_2.last_tag_form; |
| 2361 | td->elements = asn1_DEF_Utf8_2.elements; |
| 2362 | td->elements_count = asn1_DEF_Utf8_2.elements_count; |
| 2363 | td->specifics = asn1_DEF_Utf8_2.specifics; |
| 2364 | } |
| 2365 | |
| 2366 | ber_dec_rval_t |
| 2367 | Utf8_3_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2368 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2369 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2370 | return td->ber_decoder(td, structure, |
| 2371 | bufptr, size, tag_mode); |
| 2372 | } |
| 2373 | |
| 2374 | der_enc_rval_t |
| 2375 | Utf8_3_encode_der(asn1_TYPE_descriptor_t *td, |
| 2376 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2377 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2378 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2379 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2380 | } |
| 2381 | |
| 2382 | int |
| 2383 | Utf8_3_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2384 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2385 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2386 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2387 | } |
| 2388 | |
| 2389 | void |
| 2390 | Utf8_3_free(asn1_TYPE_descriptor_t *td, |
| 2391 | void *struct_ptr, int contents_only) { |
| 2392 | Utf8_3_inherit_TYPE_descriptor(td); |
| 2393 | td->free_struct(td, struct_ptr, contents_only); |
| 2394 | } |
| 2395 | |
| 2396 | |
| 2397 | /*** <<< STAT-DEFS [Utf8-3] >>> ***/ |
| 2398 | |
| 2399 | static ber_tlv_tag_t asn1_DEF_Utf8_3_tags[] = { |
| 2400 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 2401 | }; |
| 2402 | asn1_TYPE_descriptor_t asn1_DEF_Utf8_3 = { |
| 2403 | "Utf8-3", |
| 2404 | Utf8_3_constraint, |
| 2405 | Utf8_3_decode_ber, |
| 2406 | Utf8_3_encode_der, |
| 2407 | Utf8_3_print, |
| 2408 | Utf8_3_free, |
| 2409 | 0, /* Use generic outmost tag fetcher */ |
| 2410 | asn1_DEF_Utf8_3_tags, |
| 2411 | sizeof(asn1_DEF_Utf8_3_tags) |
| 2412 | /sizeof(asn1_DEF_Utf8_3_tags[0]), /* 1 */ |
| 2413 | 1, /* Tags to skip */ |
| 2414 | -0, /* Unknown yet */ |
| 2415 | 0, 0, /* No members */ |
| 2416 | 0 /* No specifics */ |
| 2417 | }; |
| 2418 | |
| 2419 | |
| 2420 | /*** <<< INCLUDES [Utf8-2] >>> ***/ |
| 2421 | |
| 2422 | #include <Utf8-1.h> |
| 2423 | |
| 2424 | /*** <<< TYPE-DECLS [Utf8-2] >>> ***/ |
| 2425 | |
| 2426 | |
| 2427 | typedef Utf8_1_t Utf8_2_t; |
| 2428 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2429 | /*** <<< FUNC-DECLS [Utf8-2] >>> ***/ |
| 2430 | |
| 2431 | extern asn1_TYPE_descriptor_t asn1_DEF_Utf8_2; |
| 2432 | asn_constr_check_f Utf8_2_constraint; |
| 2433 | ber_type_decoder_f Utf8_2_decode_ber; |
| 2434 | der_type_encoder_f Utf8_2_encode_der; |
| 2435 | asn_struct_print_f Utf8_2_print; |
| 2436 | asn_struct_free_f Utf8_2_free; |
| 2437 | |
| 2438 | /*** <<< CODE [Utf8-2] >>> ***/ |
| 2439 | |
| 2440 | int |
| 2441 | Utf8_2_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2442 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2443 | |
Lev Walkin | 634a3b8 | 2004-08-22 03:30:05 +0000 | [diff] [blame] | 2444 | const Utf8_1_t *st = sptr; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2445 | size_t size; |
| 2446 | |
| 2447 | if(!sptr) { |
| 2448 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2449 | "%s: value not given (%s:%d)", |
| 2450 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2451 | return -1; |
| 2452 | } |
| 2453 | |
| 2454 | size = UTF8String_length(st, td->name, app_errlog, app_key); |
| 2455 | if(size == (size_t)-1) return -1; |
| 2456 | |
| 2457 | if((size >= 1 && size <= 2)) { |
| 2458 | /* Constraint check succeeded */ |
Lev Walkin | 775885e | 2004-08-22 12:47:03 +0000 | [diff] [blame] | 2459 | return 0; |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2460 | } else { |
| 2461 | _ASN_ERRLOG(app_errlog, app_key, |
Lev Walkin | 16835b6 | 2004-08-22 13:47:59 +0000 | [diff] [blame] | 2462 | "%s: constraint failed (%s:%d)", |
| 2463 | td->name, __FILE__, __LINE__); |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2464 | return -1; |
| 2465 | } |
| 2466 | } |
| 2467 | |
| 2468 | /* |
| 2469 | * This type is implemented using Utf8_1, |
| 2470 | * so adjust the DEF appropriately. |
| 2471 | */ |
| 2472 | static void |
| 2473 | Utf8_2_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2474 | td->ber_decoder = asn1_DEF_Utf8_1.ber_decoder; |
| 2475 | td->der_encoder = asn1_DEF_Utf8_1.der_encoder; |
| 2476 | td->free_struct = asn1_DEF_Utf8_1.free_struct; |
| 2477 | td->print_struct = asn1_DEF_Utf8_1.print_struct; |
| 2478 | td->last_tag_form = asn1_DEF_Utf8_1.last_tag_form; |
| 2479 | td->elements = asn1_DEF_Utf8_1.elements; |
| 2480 | td->elements_count = asn1_DEF_Utf8_1.elements_count; |
| 2481 | td->specifics = asn1_DEF_Utf8_1.specifics; |
| 2482 | } |
| 2483 | |
| 2484 | ber_dec_rval_t |
| 2485 | Utf8_2_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2486 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2487 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2488 | return td->ber_decoder(td, structure, |
| 2489 | bufptr, size, tag_mode); |
| 2490 | } |
| 2491 | |
| 2492 | der_enc_rval_t |
| 2493 | Utf8_2_encode_der(asn1_TYPE_descriptor_t *td, |
| 2494 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2495 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2496 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2497 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2498 | } |
| 2499 | |
| 2500 | int |
| 2501 | Utf8_2_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2502 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2503 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2504 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2505 | } |
| 2506 | |
| 2507 | void |
| 2508 | Utf8_2_free(asn1_TYPE_descriptor_t *td, |
| 2509 | void *struct_ptr, int contents_only) { |
| 2510 | Utf8_2_inherit_TYPE_descriptor(td); |
| 2511 | td->free_struct(td, struct_ptr, contents_only); |
| 2512 | } |
| 2513 | |
| 2514 | |
| 2515 | /*** <<< STAT-DEFS [Utf8-2] >>> ***/ |
| 2516 | |
| 2517 | static ber_tlv_tag_t asn1_DEF_Utf8_2_tags[] = { |
| 2518 | (ASN_TAG_CLASS_UNIVERSAL | (0 << 2)) |
| 2519 | }; |
| 2520 | asn1_TYPE_descriptor_t asn1_DEF_Utf8_2 = { |
| 2521 | "Utf8-2", |
| 2522 | Utf8_2_constraint, |
| 2523 | Utf8_2_decode_ber, |
| 2524 | Utf8_2_encode_der, |
| 2525 | Utf8_2_print, |
| 2526 | Utf8_2_free, |
| 2527 | 0, /* Use generic outmost tag fetcher */ |
| 2528 | asn1_DEF_Utf8_2_tags, |
| 2529 | sizeof(asn1_DEF_Utf8_2_tags) |
| 2530 | /sizeof(asn1_DEF_Utf8_2_tags[0]), /* 1 */ |
| 2531 | 1, /* Tags to skip */ |
| 2532 | -0, /* Unknown yet */ |
| 2533 | 0, 0, /* No members */ |
| 2534 | 0 /* No specifics */ |
| 2535 | }; |
| 2536 | |
| 2537 | |
| 2538 | /*** <<< INCLUDES [Utf8-1] >>> ***/ |
| 2539 | |
| 2540 | #include <UTF8String.h> |
| 2541 | |
| 2542 | /*** <<< TYPE-DECLS [Utf8-1] >>> ***/ |
| 2543 | |
| 2544 | |
| 2545 | typedef UTF8String_t Utf8_1_t; |
| 2546 | |
Lev Walkin | 006de1c | 2004-08-20 13:37:45 +0000 | [diff] [blame] | 2547 | /*** <<< FUNC-DECLS [Utf8-1] >>> ***/ |
| 2548 | |
| 2549 | extern asn1_TYPE_descriptor_t asn1_DEF_Utf8_1; |
| 2550 | asn_constr_check_f Utf8_1_constraint; |
| 2551 | ber_type_decoder_f Utf8_1_decode_ber; |
| 2552 | der_type_encoder_f Utf8_1_encode_der; |
| 2553 | asn_struct_print_f Utf8_1_print; |
| 2554 | asn_struct_free_f Utf8_1_free; |
| 2555 | |
| 2556 | /*** <<< CODE [Utf8-1] >>> ***/ |
| 2557 | |
| 2558 | int |
| 2559 | Utf8_1_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 2560 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 2561 | |
| 2562 | /* Make the underlying type checker permanent */ |
| 2563 | td->check_constraints = asn1_DEF_UTF8String.check_constraints; |
| 2564 | return td->check_constraints |
| 2565 | (td, sptr, app_errlog, app_key); |
| 2566 | } |
| 2567 | |
| 2568 | /* |
| 2569 | * This type is implemented using UTF8String, |
| 2570 | * so adjust the DEF appropriately. |
| 2571 | */ |
| 2572 | static void |
| 2573 | Utf8_1_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 2574 | td->ber_decoder = asn1_DEF_UTF8String.ber_decoder; |
| 2575 | td->der_encoder = asn1_DEF_UTF8String.der_encoder; |
| 2576 | td->free_struct = asn1_DEF_UTF8String.free_struct; |
| 2577 | td->print_struct = asn1_DEF_UTF8String.print_struct; |
| 2578 | td->last_tag_form = asn1_DEF_UTF8String.last_tag_form; |
| 2579 | td->elements = asn1_DEF_UTF8String.elements; |
| 2580 | td->elements_count = asn1_DEF_UTF8String.elements_count; |
| 2581 | td->specifics = asn1_DEF_UTF8String.specifics; |
| 2582 | } |
| 2583 | |
| 2584 | ber_dec_rval_t |
| 2585 | Utf8_1_decode_ber(asn1_TYPE_descriptor_t *td, |
| 2586 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 2587 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2588 | return td->ber_decoder(td, structure, |
| 2589 | bufptr, size, tag_mode); |
| 2590 | } |
| 2591 | |
| 2592 | der_enc_rval_t |
| 2593 | Utf8_1_encode_der(asn1_TYPE_descriptor_t *td, |
| 2594 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 2595 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 2596 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2597 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 2598 | } |
| 2599 | |
| 2600 | int |
| 2601 | Utf8_1_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 2602 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 2603 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2604 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 2605 | } |
| 2606 | |
| 2607 | void |
| 2608 | Utf8_1_free(asn1_TYPE_descriptor_t *td, |
| 2609 | void *struct_ptr, int contents_only) { |
| 2610 | Utf8_1_inherit_TYPE_descriptor(td); |
| 2611 | td->free_struct(td, struct_ptr, contents_only); |
| 2612 | } |
| 2613 | |
| 2614 | |
| 2615 | /*** <<< STAT-DEFS [Utf8-1] >>> ***/ |
| 2616 | |
| 2617 | static ber_tlv_tag_t asn1_DEF_Utf8_1_tags[] = { |
| 2618 | (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)) |
| 2619 | }; |
| 2620 | asn1_TYPE_descriptor_t asn1_DEF_Utf8_1 = { |
| 2621 | "Utf8-1", |
| 2622 | Utf8_1_constraint, |
| 2623 | Utf8_1_decode_ber, |
| 2624 | Utf8_1_encode_der, |
| 2625 | Utf8_1_print, |
| 2626 | Utf8_1_free, |
| 2627 | 0, /* Use generic outmost tag fetcher */ |
| 2628 | asn1_DEF_Utf8_1_tags, |
| 2629 | sizeof(asn1_DEF_Utf8_1_tags) |
| 2630 | /sizeof(asn1_DEF_Utf8_1_tags[0]), /* 1 */ |
| 2631 | 1, /* Tags to skip */ |
| 2632 | -0, /* Unknown yet */ |
| 2633 | 0, 0, /* No members */ |
| 2634 | 0 /* No specifics */ |
| 2635 | }; |
| 2636 | |