Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Generated by asn1c-0.9.28 (http://lionet.info/asn1c) |
| 3 | * From ASN.1 module "RSPRO" |
| 4 | * found in "../../asn1/RSPRO.asn" |
| 5 | */ |
| 6 | |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 7 | #include <osmocom/rspro/ErrorString.h> |
Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 8 | |
| 9 | static int check_permitted_alphabet_1(const void *sptr) { |
| 10 | /* The underlying type is IA5String */ |
| 11 | const IA5String_t *st = (const IA5String_t *)sptr; |
| 12 | const uint8_t *ch = st->buf; |
| 13 | const uint8_t *end = ch + st->size; |
| 14 | |
| 15 | for(; ch < end; ch++) { |
| 16 | uint8_t cv = *ch; |
| 17 | if(!(cv <= 127l)) return -1; |
| 18 | } |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | int |
| 23 | ErrorString_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
| 24 | asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
| 25 | const IA5String_t *st = (const IA5String_t *)sptr; |
| 26 | size_t size; |
| 27 | |
| 28 | if(!sptr) { |
| 29 | _ASN_CTFAIL(app_key, td, sptr, |
| 30 | "%s: value not given (%s:%d)", |
| 31 | td->name, __FILE__, __LINE__); |
| 32 | return -1; |
| 33 | } |
| 34 | |
| 35 | size = st->size; |
| 36 | |
| 37 | if((size >= 1l && size <= 255l) |
| 38 | && !check_permitted_alphabet_1(st)) { |
| 39 | /* Constraint check succeeded */ |
| 40 | return 0; |
| 41 | } else { |
| 42 | _ASN_CTFAIL(app_key, td, sptr, |
| 43 | "%s: constraint failed (%s:%d)", |
| 44 | td->name, __FILE__, __LINE__); |
| 45 | return -1; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | * This type is implemented using IA5String, |
| 51 | * so here we adjust the DEF accordingly. |
| 52 | */ |
| 53 | static void |
| 54 | ErrorString_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
| 55 | td->free_struct = asn_DEF_IA5String.free_struct; |
| 56 | td->print_struct = asn_DEF_IA5String.print_struct; |
| 57 | td->check_constraints = asn_DEF_IA5String.check_constraints; |
| 58 | td->ber_decoder = asn_DEF_IA5String.ber_decoder; |
| 59 | td->der_encoder = asn_DEF_IA5String.der_encoder; |
| 60 | td->xer_decoder = asn_DEF_IA5String.xer_decoder; |
| 61 | td->xer_encoder = asn_DEF_IA5String.xer_encoder; |
| 62 | td->uper_decoder = asn_DEF_IA5String.uper_decoder; |
| 63 | td->uper_encoder = asn_DEF_IA5String.uper_encoder; |
| 64 | td->aper_decoder = asn_DEF_IA5String.aper_decoder; |
| 65 | td->aper_encoder = asn_DEF_IA5String.aper_encoder; |
| 66 | if(!td->per_constraints) |
| 67 | td->per_constraints = asn_DEF_IA5String.per_constraints; |
| 68 | td->elements = asn_DEF_IA5String.elements; |
| 69 | td->elements_count = asn_DEF_IA5String.elements_count; |
| 70 | td->specifics = asn_DEF_IA5String.specifics; |
| 71 | } |
| 72 | |
| 73 | void |
| 74 | ErrorString_free(asn_TYPE_descriptor_t *td, |
| 75 | void *struct_ptr, int contents_only) { |
| 76 | ErrorString_1_inherit_TYPE_descriptor(td); |
| 77 | td->free_struct(td, struct_ptr, contents_only); |
| 78 | } |
| 79 | |
| 80 | int |
| 81 | ErrorString_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
| 82 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 83 | ErrorString_1_inherit_TYPE_descriptor(td); |
| 84 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 85 | } |
| 86 | |
| 87 | asn_dec_rval_t |
| 88 | ErrorString_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 89 | void **structure, const void *bufptr, size_t size, int tag_mode) { |
| 90 | ErrorString_1_inherit_TYPE_descriptor(td); |
| 91 | return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
| 92 | } |
| 93 | |
| 94 | asn_enc_rval_t |
| 95 | ErrorString_encode_der(asn_TYPE_descriptor_t *td, |
| 96 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 97 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 98 | ErrorString_1_inherit_TYPE_descriptor(td); |
| 99 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 100 | } |
| 101 | |
| 102 | asn_dec_rval_t |
| 103 | ErrorString_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 104 | void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
| 105 | ErrorString_1_inherit_TYPE_descriptor(td); |
| 106 | return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
| 107 | } |
| 108 | |
| 109 | asn_enc_rval_t |
| 110 | ErrorString_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
| 111 | int ilevel, enum xer_encoder_flags_e flags, |
| 112 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 113 | ErrorString_1_inherit_TYPE_descriptor(td); |
| 114 | return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
| 115 | } |
| 116 | |
| 117 | static const ber_tlv_tag_t asn_DEF_ErrorString_tags_1[] = { |
| 118 | (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)) |
| 119 | }; |
| 120 | asn_TYPE_descriptor_t asn_DEF_ErrorString = { |
| 121 | "ErrorString", |
| 122 | "ErrorString", |
| 123 | ErrorString_free, |
| 124 | ErrorString_print, |
| 125 | ErrorString_constraint, |
| 126 | ErrorString_decode_ber, |
| 127 | ErrorString_encode_der, |
| 128 | ErrorString_decode_xer, |
| 129 | ErrorString_encode_xer, |
| 130 | 0, 0, /* No UPER support, use "-gen-PER" to enable */ |
| 131 | 0, 0, /* No APER support, use "-gen-PER" to enable */ |
| 132 | 0, /* Use generic outmost tag fetcher */ |
| 133 | asn_DEF_ErrorString_tags_1, |
| 134 | sizeof(asn_DEF_ErrorString_tags_1) |
| 135 | /sizeof(asn_DEF_ErrorString_tags_1[0]), /* 1 */ |
| 136 | asn_DEF_ErrorString_tags_1, /* Same as above */ |
| 137 | sizeof(asn_DEF_ErrorString_tags_1) |
| 138 | /sizeof(asn_DEF_ErrorString_tags_1[0]), /* 1 */ |
| 139 | 0, /* No PER visible constraints */ |
| 140 | 0, 0, /* No members */ |
| 141 | 0 /* No specifics */ |
| 142 | }; |
| 143 | |