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