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