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 | |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 9 | typedef struct Narrow_15P0 { |
| 10 | long *narrow1 /* DEFAULT 3 */; |
| 11 | long narrow2; |
| 12 | long *narrow3 /* OPTIONAL */; |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 13 | |
| 14 | /* Context for parsing across buffer boundaries */ |
| 15 | asn_struct_ctx_t _asn_ctx; |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 16 | } Narrow_15P0_t; |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 17 | |
| 18 | /*** <<< FUNC-DECLS [Narrow] >>> ***/ |
| 19 | |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 20 | extern asn_TYPE_descriptor_t asn_DEF_Narrow_15P0; |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 21 | |
| 22 | /*** <<< CODE [Narrow] >>> ***/ |
| 23 | |
| 24 | static int |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 25 | memb_narrow1_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, |
| 26 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 27 | long value; |
| 28 | |
| 29 | if(!sptr) { |
| 30 | _ASN_ERRLOG(app_errlog, app_key, |
| 31 | "%s: value not given (%s:%d)", |
| 32 | td->name, __FILE__, __LINE__); |
| 33 | return -1; |
| 34 | } |
| 35 | |
| 36 | value = *(const long *)sptr; |
| 37 | |
| 38 | if((value >= 1 && value <= 5)) { |
| 39 | /* Constraint check succeeded */ |
| 40 | return 0; |
| 41 | } else { |
| 42 | _ASN_ERRLOG(app_errlog, app_key, |
| 43 | "%s: constraint failed (%s:%d)", |
| 44 | td->name, __FILE__, __LINE__); |
| 45 | return -1; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | static int |
| 50 | memb_narrow2_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 51 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 52 | long value; |
| 53 | |
| 54 | if(!sptr) { |
| 55 | _ASN_ERRLOG(app_errlog, app_key, |
| 56 | "%s: value not given (%s:%d)", |
| 57 | td->name, __FILE__, __LINE__); |
| 58 | return -1; |
| 59 | } |
| 60 | |
| 61 | value = *(const long *)sptr; |
| 62 | |
| 63 | if((value >= 2 && value <= 5)) { |
| 64 | /* Constraint check succeeded */ |
| 65 | return 0; |
| 66 | } else { |
| 67 | _ASN_ERRLOG(app_errlog, app_key, |
| 68 | "%s: constraint failed (%s:%d)", |
| 69 | td->name, __FILE__, __LINE__); |
| 70 | return -1; |
| 71 | } |
| 72 | } |
| 73 | |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 74 | static int |
| 75 | memb_narrow3_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, |
| 76 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 77 | long value; |
| 78 | |
| 79 | if(!sptr) { |
| 80 | _ASN_ERRLOG(app_errlog, app_key, |
| 81 | "%s: value not given (%s:%d)", |
| 82 | td->name, __FILE__, __LINE__); |
| 83 | return -1; |
| 84 | } |
| 85 | |
| 86 | value = *(const long *)sptr; |
| 87 | |
| 88 | if((value >= 3 && value <= 5)) { |
| 89 | /* Constraint check succeeded */ |
| 90 | return 0; |
| 91 | } else { |
| 92 | _ASN_ERRLOG(app_errlog, app_key, |
| 93 | "%s: constraint failed (%s:%d)", |
| 94 | td->name, __FILE__, __LINE__); |
| 95 | return -1; |
| 96 | } |
| 97 | } |
| 98 | |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 99 | |
| 100 | /*** <<< STAT-DEFS [Narrow] >>> ***/ |
| 101 | |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 102 | static int asn_DFL_2_set_3(void **sptr) { |
| 103 | long *st = *sptr; |
| 104 | |
| 105 | if(!st) { |
| 106 | st = (*sptr = CALLOC(1, sizeof(*st))); |
| 107 | if(!st) return -1; |
| 108 | } |
| 109 | |
| 110 | /* Install default value 3 */ |
| 111 | *st = 3; |
| 112 | return 0; |
| 113 | } |
| 114 | static asn_TYPE_member_t asn_MBR_Narrow_15P0_1[] = { |
| 115 | { ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow1), |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 116 | .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), |
| 117 | .tag_mode = 0, |
| 118 | .type = &asn_DEF_NativeInteger, |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 119 | .memb_constraints = memb_narrow1_constraint_1, |
| 120 | .per_constraints = 0, /* PER is not compiled, use -gen-PER */ |
| 121 | .default_value = asn_DFL_2_set_3, /* DEFAULT 3 */ |
| 122 | .name = "narrow1" |
| 123 | }, |
| 124 | { ATF_NOFLAGS, 0, offsetof(struct Narrow_15P0, narrow2), |
| 125 | .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), |
| 126 | .tag_mode = +1, /* EXPLICIT tag at current level */ |
| 127 | .type = &asn_DEF_NativeInteger, |
| 128 | .memb_constraints = memb_narrow2_constraint_1, |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 129 | .per_constraints = 0, /* PER is not compiled, use -gen-PER */ |
| 130 | .default_value = 0, |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 131 | .name = "narrow2" |
| 132 | }, |
| 133 | { ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow3), |
| 134 | .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), |
| 135 | .tag_mode = +1, /* EXPLICIT tag at current level */ |
| 136 | .type = &asn_DEF_NativeInteger, |
| 137 | .memb_constraints = memb_narrow3_constraint_1, |
| 138 | .per_constraints = 0, /* PER is not compiled, use -gen-PER */ |
| 139 | .default_value = 0, |
| 140 | .name = "narrow3" |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 141 | }, |
| 142 | }; |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 143 | static ber_tlv_tag_t asn_DEF_Narrow_15P0_tags_1[] = { |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 144 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 145 | }; |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 146 | static asn_TYPE_tag2member_t asn_MAP_Narrow_15P0_tag2el_1[] = { |
| 147 | { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* narrow1 at 20 */ |
| 148 | { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 }, /* narrow2 at 20 */ |
| 149 | { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 2, 0, 0 } /* narrow3 at 20 */ |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 150 | }; |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 151 | static asn_SEQUENCE_specifics_t asn_SPC_Narrow_15P0_specs_1 = { |
| 152 | sizeof(struct Narrow_15P0), |
| 153 | offsetof(struct Narrow_15P0, _asn_ctx), |
| 154 | asn_MAP_Narrow_15P0_tag2el_1, |
| 155 | 3, /* Count of tags in the map */ |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 156 | 0, 0, 0, /* Optional elements (not needed) */ |
| 157 | -1, /* Start extensions */ |
| 158 | -1 /* Stop extensions */ |
| 159 | }; |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 160 | asn_TYPE_descriptor_t asn_DEF_Narrow_15P0 = { |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 161 | "Narrow", |
| 162 | "Narrow", |
| 163 | SEQUENCE_free, |
| 164 | SEQUENCE_print, |
| 165 | SEQUENCE_constraint, |
| 166 | SEQUENCE_decode_ber, |
| 167 | SEQUENCE_encode_der, |
| 168 | SEQUENCE_decode_xer, |
| 169 | SEQUENCE_encode_xer, |
| 170 | 0, /* No PER decoder, -gen-PER to enable */ |
| 171 | 0, /* Use generic outmost tag fetcher */ |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 172 | asn_DEF_Narrow_15P0_tags_1, |
| 173 | sizeof(asn_DEF_Narrow_15P0_tags_1) |
| 174 | /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */ |
| 175 | asn_DEF_Narrow_15P0_tags_1, /* Same as above */ |
| 176 | sizeof(asn_DEF_Narrow_15P0_tags_1) |
| 177 | /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */ |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 178 | 0, /* No PER visible constraints */ |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 179 | asn_MBR_Narrow_15P0_1, |
| 180 | 3, /* Elements count */ |
| 181 | &asn_SPC_Narrow_15P0_specs_1 /* Additional specs */ |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | |
| 185 | /*** <<< INCLUDES [NarrowInteger] >>> ***/ |
| 186 | |
| 187 | #include <Narrow.h> |
| 188 | |
| 189 | /*** <<< TYPE-DECLS [NarrowInteger] >>> ***/ |
| 190 | |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 191 | typedef Narrow_15P0_t NarrowInteger_t; |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 192 | |
| 193 | /*** <<< FUNC-DECLS [NarrowInteger] >>> ***/ |
| 194 | |
| 195 | extern asn_TYPE_descriptor_t asn_DEF_NarrowInteger; |
| 196 | asn_struct_free_f NarrowInteger_free; |
| 197 | asn_struct_print_f NarrowInteger_print; |
| 198 | asn_constr_check_f NarrowInteger_constraint; |
| 199 | ber_type_decoder_f NarrowInteger_decode_ber; |
| 200 | der_type_encoder_f NarrowInteger_encode_der; |
| 201 | xer_type_decoder_f NarrowInteger_decode_xer; |
| 202 | xer_type_encoder_f NarrowInteger_encode_xer; |
| 203 | |
| 204 | /*** <<< CODE [NarrowInteger] >>> ***/ |
| 205 | |
| 206 | int |
| 207 | NarrowInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
| 208 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 209 | /* Replace with underlying type checker */ |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 210 | td->check_constraints = asn_DEF_Narrow_15P0.check_constraints; |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 211 | return td->check_constraints(td, sptr, app_errlog, app_key); |
| 212 | } |
| 213 | |
| 214 | /* |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 215 | * This type is implemented using Narrow_15P0, |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 216 | * so here we adjust the DEF accordingly. |
| 217 | */ |
| 218 | static void |
| 219 | NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 220 | td->free_struct = asn_DEF_Narrow_15P0.free_struct; |
| 221 | td->print_struct = asn_DEF_Narrow_15P0.print_struct; |
| 222 | td->ber_decoder = asn_DEF_Narrow_15P0.ber_decoder; |
| 223 | td->der_encoder = asn_DEF_Narrow_15P0.der_encoder; |
| 224 | td->xer_decoder = asn_DEF_Narrow_15P0.xer_decoder; |
| 225 | td->xer_encoder = asn_DEF_Narrow_15P0.xer_encoder; |
| 226 | td->uper_decoder = asn_DEF_Narrow_15P0.uper_decoder; |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 227 | if(!td->per_constraints) |
vlm | 17e65d0 | 2006-03-21 04:48:15 +0000 | [diff] [blame] | 228 | td->per_constraints = asn_DEF_Narrow_15P0.per_constraints; |
| 229 | td->elements = asn_DEF_Narrow_15P0.elements; |
| 230 | td->elements_count = asn_DEF_Narrow_15P0.elements_count; |
| 231 | td->specifics = asn_DEF_Narrow_15P0.specifics; |
vlm | 0c6d381 | 2006-03-21 03:40:38 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void |
| 235 | NarrowInteger_free(asn_TYPE_descriptor_t *td, |
| 236 | void *struct_ptr, int contents_only) { |
| 237 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 238 | td->free_struct(td, struct_ptr, contents_only); |
| 239 | } |
| 240 | |
| 241 | int |
| 242 | NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
| 243 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 244 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 245 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 246 | } |
| 247 | |
| 248 | asn_dec_rval_t |
| 249 | NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 250 | void **structure, const void *bufptr, size_t size, int tag_mode) { |
| 251 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 252 | return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
| 253 | } |
| 254 | |
| 255 | asn_enc_rval_t |
| 256 | NarrowInteger_encode_der(asn_TYPE_descriptor_t *td, |
| 257 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 258 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 259 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 260 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 261 | } |
| 262 | |
| 263 | asn_dec_rval_t |
| 264 | NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 265 | void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
| 266 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 267 | return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
| 268 | } |
| 269 | |
| 270 | asn_enc_rval_t |
| 271 | NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
| 272 | int ilevel, enum xer_encoder_flags_e flags, |
| 273 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 274 | NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 275 | return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
| 276 | } |
| 277 | |
| 278 | |
| 279 | /*** <<< STAT-DEFS [NarrowInteger] >>> ***/ |
| 280 | |
| 281 | static ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = { |
| 282 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 283 | }; |
| 284 | asn_TYPE_descriptor_t asn_DEF_NarrowInteger = { |
| 285 | "NarrowInteger", |
| 286 | "NarrowInteger", |
| 287 | NarrowInteger_free, |
| 288 | NarrowInteger_print, |
| 289 | NarrowInteger_constraint, |
| 290 | NarrowInteger_decode_ber, |
| 291 | NarrowInteger_encode_der, |
| 292 | NarrowInteger_decode_xer, |
| 293 | NarrowInteger_encode_xer, |
| 294 | 0, /* No PER decoder, -gen-PER to enable */ |
| 295 | 0, /* Use generic outmost tag fetcher */ |
| 296 | asn_DEF_NarrowInteger_tags_1, |
| 297 | sizeof(asn_DEF_NarrowInteger_tags_1) |
| 298 | /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ |
| 299 | asn_DEF_NarrowInteger_tags_1, /* Same as above */ |
| 300 | sizeof(asn_DEF_NarrowInteger_tags_1) |
| 301 | /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ |
| 302 | 0, /* No PER visible constraints */ |
| 303 | 0, 0, /* Defined elsewhere */ |
| 304 | 0 /* No specifics */ |
| 305 | }; |
| 306 | |