vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame^] | 1 | |
| 2 | /*** <<< INCLUDES [Narrow] >>> ***/ |
| 3 | |
| 4 | #include <NativeInteger.h> |
| 5 | #include <constr_SEQUENCE.h> |
| 6 | |
| 7 | /*** <<< TYPE-DECLS [Narrow] >>> ***/ |
| 8 | |
| 9 | typedef struct Narrow_16P0 { |
| 10 | long narrower; |
| 11 | |
| 12 | /* Context for parsing across buffer boundaries */ |
| 13 | asn_struct_ctx_t _asn_ctx; |
| 14 | } Narrow_16P0_t; |
| 15 | |
| 16 | /*** <<< FUNC-DECLS [Narrow] >>> ***/ |
| 17 | |
| 18 | extern asn_TYPE_descriptor_t asn_DEF_Narrow_16P0; |
| 19 | |
| 20 | /*** <<< CODE [Narrow] >>> ***/ |
| 21 | |
| 22 | static int |
| 23 | memb_narrower_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, |
| 24 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 25 | long value; |
| 26 | |
| 27 | if(!sptr) { |
| 28 | _ASN_ERRLOG(app_errlog, app_key, |
| 29 | "%s: value not given (%s:%d)", |
| 30 | td->name, __FILE__, __LINE__); |
| 31 | return -1; |
| 32 | } |
| 33 | |
| 34 | value = *(const long *)sptr; |
| 35 | |
| 36 | if((value >= 2 && value <= 5)) { |
| 37 | /* Constraint check succeeded */ |
| 38 | return 0; |
| 39 | } else { |
| 40 | _ASN_ERRLOG(app_errlog, app_key, |
| 41 | "%s: constraint failed (%s:%d)", |
| 42 | td->name, __FILE__, __LINE__); |
| 43 | return -1; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | |
| 48 | /*** <<< STAT-DEFS [Narrow] >>> ***/ |
| 49 | |
| 50 | static asn_TYPE_member_t asn_MBR_Narrow_16P0_1[] = { |
| 51 | { ATF_NOFLAGS, 0, offsetof(struct Narrow_16P0, narrower), |
| 52 | .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), |
| 53 | .tag_mode = 0, |
| 54 | .type = &asn_DEF_NativeInteger, |
| 55 | .memb_constraints = memb_narrower_constraint_1, |
| 56 | .per_constraints = 0, /* PER is not compiled, use -gen-PER */ |
| 57 | .default_value = 0, |
| 58 | .name = "narrower" |
| 59 | }, |
| 60 | }; |
| 61 | static ber_tlv_tag_t asn_DEF_Narrow_16P0_tags_1[] = { |
| 62 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 63 | }; |
| 64 | static asn_TYPE_tag2member_t asn_MAP_Narrow_16P0_tag2el_1[] = { |
| 65 | { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* narrower at 18 */ |
| 66 | }; |
| 67 | static asn_SEQUENCE_specifics_t asn_SPC_Narrow_16P0_specs_1 = { |
| 68 | sizeof(struct Narrow_16P0), |
| 69 | offsetof(struct Narrow_16P0, _asn_ctx), |
| 70 | asn_MAP_Narrow_16P0_tag2el_1, |
| 71 | 1, /* Count of tags in the map */ |
| 72 | 0, 0, 0, /* Optional elements (not needed) */ |
| 73 | -1, /* Start extensions */ |
| 74 | -1 /* Stop extensions */ |
| 75 | }; |
| 76 | asn_TYPE_descriptor_t asn_DEF_Narrow_16P0 = { |
| 77 | "Narrow", |
| 78 | "Narrow", |
| 79 | SEQUENCE_free, |
| 80 | SEQUENCE_print, |
| 81 | SEQUENCE_constraint, |
| 82 | SEQUENCE_decode_ber, |
| 83 | SEQUENCE_encode_der, |
| 84 | SEQUENCE_decode_xer, |
| 85 | SEQUENCE_encode_xer, |
| 86 | 0, /* No PER decoder, -gen-PER to enable */ |
| 87 | 0, /* Use generic outmost tag fetcher */ |
| 88 | asn_DEF_Narrow_16P0_tags_1, |
| 89 | sizeof(asn_DEF_Narrow_16P0_tags_1) |
| 90 | /sizeof(asn_DEF_Narrow_16P0_tags_1[0]), /* 1 */ |
| 91 | asn_DEF_Narrow_16P0_tags_1, /* Same as above */ |
| 92 | sizeof(asn_DEF_Narrow_16P0_tags_1) |
| 93 | /sizeof(asn_DEF_Narrow_16P0_tags_1[0]), /* 1 */ |
| 94 | 0, /* No PER visible constraints */ |
| 95 | asn_MBR_Narrow_16P0_1, |
| 96 | 1, /* Elements count */ |
| 97 | &asn_SPC_Narrow_16P0_specs_1 /* Additional specs */ |
| 98 | }; |
| 99 | |
| 100 | |
| 101 | /*** <<< INCLUDES [NarrowInteger] >>> ***/ |
| 102 | |
| 103 | #include <Narrow.h> |
| 104 | |
| 105 | /*** <<< TYPE-DECLS [NarrowInteger] >>> ***/ |
| 106 | |
| 107 | typedef Narrow_16P0_t NarrowInteger_t; |
| 108 | |
| 109 | /*** <<< FUNC-DECLS [NarrowInteger] >>> ***/ |
| 110 | |
| 111 | extern asn_TYPE_descriptor_t asn_DEF_NarrowInteger; |
| 112 | asn_struct_free_f NarrowInteger_free; |
| 113 | asn_struct_print_f NarrowInteger_print; |
| 114 | asn_constr_check_f NarrowInteger_constraint; |
| 115 | ber_type_decoder_f NarrowInteger_decode_ber; |
| 116 | der_type_encoder_f NarrowInteger_encode_der; |
| 117 | xer_type_decoder_f NarrowInteger_decode_xer; |
| 118 | xer_type_encoder_f NarrowInteger_encode_xer; |
| 119 | |
| 120 | /*** <<< CODE [NarrowInteger] >>> ***/ |
| 121 | |
| 122 | int |
| 123 | NarrowInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
| 124 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 125 | /* Replace with underlying type checker */ |
| 126 | td->check_constraints = asn_DEF_Narrow_16P0.check_constraints; |
| 127 | return td->check_constraints(td, sptr, app_errlog, app_key); |
| 128 | } |
| 129 | |
| 130 | /* |
| 131 | * This type is implemented using Narrow_16P0, |
| 132 | * so here we adjust the DEF accordingly. |
| 133 | */ |
| 134 | static void |
| 135 | NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
| 136 | td->free_struct = asn_DEF_Narrow_16P0.free_struct; |
| 137 | td->print_struct = asn_DEF_Narrow_16P0.print_struct; |
| 138 | td->ber_decoder = asn_DEF_Narrow_16P0.ber_decoder; |
| 139 | td->der_encoder = asn_DEF_Narrow_16P0.der_encoder; |
| 140 | td->xer_decoder = asn_DEF_Narrow_16P0.xer_decoder; |
| 141 | td->xer_encoder = asn_DEF_Narrow_16P0.xer_encoder; |
| 142 | td->uper_decoder = asn_DEF_Narrow_16P0.uper_decoder; |
| 143 | if(!td->per_constraints) |
| 144 | td->per_constraints = asn_DEF_Narrow_16P0.per_constraints; |
| 145 | td->elements = asn_DEF_Narrow_16P0.elements; |
| 146 | td->elements_count = asn_DEF_Narrow_16P0.elements_count; |
| 147 | td->specifics = asn_DEF_Narrow_16P0.specifics; |
| 148 | } |
| 149 | |
| 150 | void |
| 151 | NarrowInteger_free(asn_TYPE_descriptor_t *td, |
| 152 | void *struct_ptr, int contents_only) { |
| 153 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 154 | td->free_struct(td, struct_ptr, contents_only); |
| 155 | } |
| 156 | |
| 157 | int |
| 158 | NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
| 159 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 160 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 161 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 162 | } |
| 163 | |
| 164 | asn_dec_rval_t |
| 165 | NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 166 | void **structure, const void *bufptr, size_t size, int tag_mode) { |
| 167 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 168 | return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
| 169 | } |
| 170 | |
| 171 | asn_enc_rval_t |
| 172 | NarrowInteger_encode_der(asn_TYPE_descriptor_t *td, |
| 173 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 174 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 175 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 176 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 177 | } |
| 178 | |
| 179 | asn_dec_rval_t |
| 180 | NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 181 | void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
| 182 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 183 | return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
| 184 | } |
| 185 | |
| 186 | asn_enc_rval_t |
| 187 | NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
| 188 | int ilevel, enum xer_encoder_flags_e flags, |
| 189 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 190 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 191 | return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
| 192 | } |
| 193 | |
| 194 | |
| 195 | /*** <<< STAT-DEFS [NarrowInteger] >>> ***/ |
| 196 | |
| 197 | static ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = { |
| 198 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 199 | }; |
| 200 | asn_TYPE_descriptor_t asn_DEF_NarrowInteger = { |
| 201 | "NarrowInteger", |
| 202 | "NarrowInteger", |
| 203 | NarrowInteger_free, |
| 204 | NarrowInteger_print, |
| 205 | NarrowInteger_constraint, |
| 206 | NarrowInteger_decode_ber, |
| 207 | NarrowInteger_encode_der, |
| 208 | NarrowInteger_decode_xer, |
| 209 | NarrowInteger_encode_xer, |
| 210 | 0, /* No PER decoder, -gen-PER to enable */ |
| 211 | 0, /* Use generic outmost tag fetcher */ |
| 212 | asn_DEF_NarrowInteger_tags_1, |
| 213 | sizeof(asn_DEF_NarrowInteger_tags_1) |
| 214 | /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ |
| 215 | asn_DEF_NarrowInteger_tags_1, /* Same as above */ |
| 216 | sizeof(asn_DEF_NarrowInteger_tags_1) |
| 217 | /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ |
| 218 | 0, /* No PER visible constraints */ |
| 219 | 0, 0, /* Defined elsewhere */ |
| 220 | 0 /* No specifics */ |
| 221 | }; |
| 222 | |