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