| 1 |
|
| 2 |
/*** <<< INCLUDES [Narrow] >>> ***/ |
| 3 |
|
| 4 |
#include <NativeInteger.h> |
| 5 |
#include <constr_SEQUENCE.h> |
| 6 |
|
| 7 |
/*** <<< TYPE-DECLS [Narrow] >>> ***/ |
| 8 |
|
| 9 |
typedef struct Narrow_15P0 { |
| 10 |
long *narrow1 /* DEFAULT 3 */; |
| 11 |
long narrow2; |
| 12 |
long *narrow3 /* OPTIONAL */; |
| 13 |
|
| 14 |
/* Context for parsing across buffer boundaries */ |
| 15 |
asn_struct_ctx_t _asn_ctx; |
| 16 |
} Narrow_15P0_t; |
| 17 |
|
| 18 |
/*** <<< FUNC-DECLS [Narrow] >>> ***/ |
| 19 |
|
| 20 |
extern asn_TYPE_descriptor_t asn_DEF_Narrow_15P0; |
| 21 |
|
| 22 |
/*** <<< CODE [Narrow] >>> ***/ |
| 23 |
|
| 24 |
static int |
| 25 |
memb_narrow1_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, |
| 26 |
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
| 27 |
long value; |
| 28 |
|
| 29 |
if(!sptr) { |
| 30 |
ASN__CTFAIL(app_key, td, sptr, |
| 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__CTFAIL(app_key, td, sptr, |
| 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, |
| 51 |
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
| 52 |
long value; |
| 53 |
|
| 54 |
if(!sptr) { |
| 55 |
ASN__CTFAIL(app_key, td, sptr, |
| 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__CTFAIL(app_key, td, sptr, |
| 68 |
"%s: constraint failed (%s:%d)", |
| 69 |
td->name, __FILE__, __LINE__); |
| 70 |
return -1; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
static int |
| 75 |
memb_narrow3_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, |
| 76 |
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
| 77 |
long value; |
| 78 |
|
| 79 |
if(!sptr) { |
| 80 |
ASN__CTFAIL(app_key, td, sptr, |
| 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__CTFAIL(app_key, td, sptr, |
| 93 |
"%s: constraint failed (%s:%d)", |
| 94 |
td->name, __FILE__, __LINE__); |
| 95 |
return -1; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
/*** <<< STAT-DEFS [Narrow] >>> ***/ |
| 101 |
|
| 102 |
static int asn_DFL_2_set_3(int set_value, void **sptr) { |
| 103 |
long *st = *sptr; |
| 104 |
|
| 105 |
if(!st) { |
| 106 |
if(!set_value) return -1; /* Not a default value */ |
| 107 |
st = (*sptr = CALLOC(1, sizeof(*st))); |
| 108 |
if(!st) return -1; |
| 109 |
} |
| 110 |
|
| 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 |
} |
| 119 |
} |
| 120 |
static asn_TYPE_member_t asn_MBR_Narrow_15P0_1[] = { |
| 121 |
{ ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow1), |
| 122 |
.tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), |
| 123 |
.tag_mode = 0, |
| 124 |
.type = &asn_DEF_NativeInteger, |
| 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, |
| 135 |
.per_constraints = 0, /* PER is not compiled, use -gen-PER */ |
| 136 |
.default_value = 0, |
| 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" |
| 147 |
}, |
| 148 |
}; |
| 149 |
static const ber_tlv_tag_t asn_DEF_Narrow_15P0_tags_1[] = { |
| 150 |
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 151 |
}; |
| 152 |
static const asn_TYPE_tag2member_t asn_MAP_Narrow_15P0_tag2el_1[] = { |
| 153 |
{ (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* narrow1 */ |
| 154 |
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 }, /* narrow2 */ |
| 155 |
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 2, 0, 0 } /* narrow3 */ |
| 156 |
}; |
| 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 */ |
| 162 |
0, 0, 0, /* Optional elements (not needed) */ |
| 163 |
-1, /* Start extensions */ |
| 164 |
-1 /* Stop extensions */ |
| 165 |
}; |
| 166 |
asn_TYPE_descriptor_t asn_DEF_Narrow_15P0 = { |
| 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, |
| 176 |
0, 0, /* No PER support, use "-gen-PER" to enable */ |
| 177 |
0, /* Use generic outmost tag fetcher */ |
| 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 */ |
| 184 |
0, /* No PER visible constraints */ |
| 185 |
asn_MBR_Narrow_15P0_1, |
| 186 |
3, /* Elements count */ |
| 187 |
&asn_SPC_Narrow_15P0_specs_1 /* Additional specs */ |
| 188 |
}; |
| 189 |
|
| 190 |
|
| 191 |
/*** <<< INCLUDES [NarrowInteger] >>> ***/ |
| 192 |
|
| 193 |
#include "Narrow.h" |
| 194 |
|
| 195 |
/*** <<< TYPE-DECLS [NarrowInteger] >>> ***/ |
| 196 |
|
| 197 |
typedef Narrow_15P0_t NarrowInteger_t; |
| 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, |
| 214 |
asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
| 215 |
/* Replace with underlying type checker */ |
| 216 |
td->check_constraints = asn_DEF_Narrow_15P0.check_constraints; |
| 217 |
return td->check_constraints(td, sptr, ctfailcb, app_key); |
| 218 |
} |
| 219 |
|
| 220 |
/* |
| 221 |
* This type is implemented using Narrow_15P0, |
| 222 |
* so here we adjust the DEF accordingly. |
| 223 |
*/ |
| 224 |
static void |
| 225 |
NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
| 226 |
td->free_struct = asn_DEF_Narrow_15P0.free_struct; |
| 227 |
td->print_struct = asn_DEF_Narrow_15P0.print_struct; |
| 228 |
td->check_constraints = asn_DEF_Narrow_15P0.check_constraints; |
| 229 |
td->ber_decoder = asn_DEF_Narrow_15P0.ber_decoder; |
| 230 |
td->der_encoder = asn_DEF_Narrow_15P0.der_encoder; |
| 231 |
td->xer_decoder = asn_DEF_Narrow_15P0.xer_decoder; |
| 232 |
td->xer_encoder = asn_DEF_Narrow_15P0.xer_encoder; |
| 233 |
td->uper_decoder = asn_DEF_Narrow_15P0.uper_decoder; |
| 234 |
td->uper_encoder = asn_DEF_Narrow_15P0.uper_encoder; |
| 235 |
if(!td->per_constraints) |
| 236 |
td->per_constraints = asn_DEF_Narrow_15P0.per_constraints; |
| 237 |
td->elements = asn_DEF_Narrow_15P0.elements; |
| 238 |
td->elements_count = asn_DEF_Narrow_15P0.elements_count; |
| 239 |
td->specifics = asn_DEF_Narrow_15P0.specifics; |
| 240 |
} |
| 241 |
|
| 242 |
void |
| 243 |
NarrowInteger_free(asn_TYPE_descriptor_t *td, |
| 244 |
void *struct_ptr, int contents_only) { |
| 245 |
NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 246 |
td->free_struct(td, struct_ptr, contents_only); |
| 247 |
} |
| 248 |
|
| 249 |
int |
| 250 |
NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
| 251 |
int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 252 |
NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 253 |
return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 254 |
} |
| 255 |
|
| 256 |
asn_dec_rval_t |
| 257 |
NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 258 |
void **structure, const void *bufptr, size_t size, int tag_mode) { |
| 259 |
NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 260 |
return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
| 261 |
} |
| 262 |
|
| 263 |
asn_enc_rval_t |
| 264 |
NarrowInteger_encode_der(asn_TYPE_descriptor_t *td, |
| 265 |
void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 266 |
asn_app_consume_bytes_f *cb, void *app_key) { |
| 267 |
NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 268 |
return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 269 |
} |
| 270 |
|
| 271 |
asn_dec_rval_t |
| 272 |
NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
| 273 |
void **structure, const char *opt_mname, const void *bufptr, size_t size) { |
| 274 |
NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 275 |
return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); |
| 276 |
} |
| 277 |
|
| 278 |
asn_enc_rval_t |
| 279 |
NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
| 280 |
int ilevel, enum xer_encoder_flags_e flags, |
| 281 |
asn_app_consume_bytes_f *cb, void *app_key) { |
| 282 |
NarrowInteger_1_inherit_TYPE_descriptor(td); |
| 283 |
return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
| 284 |
} |
| 285 |
|
| 286 |
|
| 287 |
/*** <<< STAT-DEFS [NarrowInteger] >>> ***/ |
| 288 |
|
| 289 |
static const ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = { |
| 290 |
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 291 |
}; |
| 292 |
asn_TYPE_descriptor_t asn_DEF_NarrowInteger = { |
| 293 |
"NarrowInteger", |
| 294 |
"NarrowInteger", |
| 295 |
NarrowInteger_free, |
| 296 |
NarrowInteger_print, |
| 297 |
NarrowInteger_constraint, |
| 298 |
NarrowInteger_decode_ber, |
| 299 |
NarrowInteger_encode_der, |
| 300 |
NarrowInteger_decode_xer, |
| 301 |
NarrowInteger_encode_xer, |
| 302 |
0, 0, /* No PER support, use "-gen-PER" to enable */ |
| 303 |
0, /* Use generic outmost tag fetcher */ |
| 304 |
asn_DEF_NarrowInteger_tags_1, |
| 305 |
sizeof(asn_DEF_NarrowInteger_tags_1) |
| 306 |
/sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ |
| 307 |
asn_DEF_NarrowInteger_tags_1, /* Same as above */ |
| 308 |
sizeof(asn_DEF_NarrowInteger_tags_1) |
| 309 |
/sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ |
| 310 |
0, /* No PER visible constraints */ |
| 311 |
0, 0, /* Defined elsewhere */ |
| 312 |
0 /* No specifics */ |
| 313 |
}; |
| 314 |
|