📄 50-constraint-ok.asn1.-p
字号:
/*** <<< INCLUDES [Int1] >>> ***/#include <INTEGER.h>/*** <<< TYPE-DECLS [Int1] >>> ***/typedef INTEGER_t Int1_t;/*** <<< FUNC-DECLS [Int1] >>> ***/extern asn_TYPE_descriptor_t asn_DEF_Int1;asn_struct_free_f Int1_free;asn_struct_print_f Int1_print;asn_constr_check_f Int1_constraint;ber_type_decoder_f Int1_decode_ber;der_type_encoder_f Int1_encode_der;xer_type_decoder_f Int1_decode_xer;xer_type_encoder_f Int1_encode_xer;/*** <<< CODE [Int1] >>> ***/intInt1_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { /* Replace with underlying type checker */ td->check_constraints = asn_DEF_INTEGER.check_constraints; return td->check_constraints(td, sptr, app_errlog, app_key);}/* * This type is implemented using INTEGER, * so here we adjust the DEF accordingly. */static voidInt1_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_INTEGER.free_struct; td->print_struct = asn_DEF_INTEGER.print_struct; td->ber_decoder = asn_DEF_INTEGER.ber_decoder; td->der_encoder = asn_DEF_INTEGER.der_encoder; td->xer_decoder = asn_DEF_INTEGER.xer_decoder; td->xer_encoder = asn_DEF_INTEGER.xer_encoder; td->elements = asn_DEF_INTEGER.elements; td->elements_count = asn_DEF_INTEGER.elements_count; td->specifics = asn_DEF_INTEGER.specifics;}voidInt1_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { Int1_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only);}intInt1_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { Int1_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key);}asn_dec_rval_tInt1_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, void *bufptr, size_t size, int tag_mode) { Int1_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);}asn_enc_rval_tInt1_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { Int1_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);}asn_dec_rval_tInt1_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, void *bufptr, size_t size) { Int1_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);}asn_enc_rval_tInt1_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { Int1_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);}/*** <<< STAT-DEFS [Int1] >>> ***/static ber_tlv_tag_t asn_DEF_Int1_1_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))};asn_TYPE_descriptor_t asn_DEF_Int1 = { "Int1", "Int1", Int1_free, Int1_print, Int1_constraint, Int1_decode_ber, Int1_encode_der, Int1_decode_xer, Int1_encode_xer, 0, /* Use generic outmost tag fetcher */ asn_DEF_Int1_1_tags, sizeof(asn_DEF_Int1_1_tags) /sizeof(asn_DEF_Int1_1_tags[0]), /* 1 */ asn_DEF_Int1_1_tags, /* Same as above */ sizeof(asn_DEF_Int1_1_tags) /sizeof(asn_DEF_Int1_1_tags[0]), /* 1 */ 0, 0, /* No members */ 0 /* No specifics */};/*** <<< INCLUDES [Int2] >>> ***/#include <Int1.h>/*** <<< TYPE-DECLS [Int2] >>> ***/typedef Int1_t Int2_t;/*** <<< FUNC-DECLS [Int2] >>> ***/extern asn_TYPE_descriptor_t asn_DEF_Int2;asn_struct_free_f Int2_free;asn_struct_print_f Int2_print;asn_constr_check_f Int2_constraint;ber_type_decoder_f Int2_decode_ber;der_type_encoder_f Int2_encode_der;xer_type_decoder_f Int2_decode_xer;xer_type_encoder_f Int2_encode_xer;/*** <<< CODE [Int2] >>> ***/intInt2_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { const Int1_t *st = (const Int1_t *)sptr; long value; if(!sptr) { _ASN_ERRLOG(app_errlog, app_key, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } /* Check if the sign bit is present */ value = st->buf ? ((st->buf[0] & 0x80) ? -1 : 1) : 0; if((value >= 0)) { /* Constraint check succeeded */ return 0; } else { _ASN_ERRLOG(app_errlog, app_key, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; }}/* * This type is implemented using Int1, * so here we adjust the DEF accordingly. */static voidInt2_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_Int1.free_struct; td->print_struct = asn_DEF_Int1.print_struct; td->ber_decoder = asn_DEF_Int1.ber_decoder; td->der_encoder = asn_DEF_Int1.der_encoder; td->xer_decoder = asn_DEF_Int1.xer_decoder; td->xer_encoder = asn_DEF_Int1.xer_encoder; td->elements = asn_DEF_Int1.elements; td->elements_count = asn_DEF_Int1.elements_count; td->specifics = asn_DEF_Int1.specifics;}voidInt2_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { Int2_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only);}intInt2_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { Int2_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key);}asn_dec_rval_tInt2_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, void *bufptr, size_t size, int tag_mode) { Int2_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);}asn_enc_rval_tInt2_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { Int2_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);}asn_dec_rval_tInt2_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, void *bufptr, size_t size) { Int2_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);}asn_enc_rval_tInt2_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { Int2_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);}/*** <<< STAT-DEFS [Int2] >>> ***/static ber_tlv_tag_t asn_DEF_Int2_1_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))};asn_TYPE_descriptor_t asn_DEF_Int2 = { "Int2", "Int2", Int2_free, Int2_print, Int2_constraint, Int2_decode_ber, Int2_encode_der, Int2_decode_xer, Int2_encode_xer, 0, /* Use generic outmost tag fetcher */ asn_DEF_Int2_1_tags, sizeof(asn_DEF_Int2_1_tags) /sizeof(asn_DEF_Int2_1_tags[0]), /* 1 */ asn_DEF_Int2_1_tags, /* Same as above */ sizeof(asn_DEF_Int2_1_tags) /sizeof(asn_DEF_Int2_1_tags[0]), /* 1 */ 0, 0, /* No members */ 0 /* No specifics */};/*** <<< INCLUDES [Int3] >>> ***/#include <Int2.h>/*** <<< TYPE-DECLS [Int3] >>> ***/typedef Int2_t Int3_t;/*** <<< FUNC-DECLS [Int3] >>> ***/extern asn_TYPE_descriptor_t asn_DEF_Int3;asn_struct_free_f Int3_free;asn_struct_print_f Int3_print;asn_constr_check_f Int3_constraint;ber_type_decoder_f Int3_decode_ber;der_type_encoder_f Int3_encode_der;xer_type_decoder_f Int3_decode_xer;xer_type_encoder_f Int3_encode_xer;/*** <<< CODE [Int3] >>> ***/intInt3_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { const Int2_t *st = (const Int2_t *)sptr; long value; if(!sptr) { _ASN_ERRLOG(app_errlog, app_key, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if(asn_INTEGER2long(st, &value)) { _ASN_ERRLOG(app_errlog, app_key, "%s: value too large (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if((value >= 0 && value <= 10)) { /* Constraint check succeeded */ return 0; } else { _ASN_ERRLOG(app_errlog, app_key, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; }}/* * This type is implemented using Int2, * so here we adjust the DEF accordingly. */static voidInt3_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { td->free_struct = asn_DEF_Int2.free_struct; td->print_struct = asn_DEF_Int2.print_struct; td->ber_decoder = asn_DEF_Int2.ber_decoder; td->der_encoder = asn_DEF_Int2.der_encoder; td->xer_decoder = asn_DEF_Int2.xer_decoder; td->xer_encoder = asn_DEF_Int2.xer_encoder; td->elements = asn_DEF_Int2.elements; td->elements_count = asn_DEF_Int2.elements_count; td->specifics = asn_DEF_Int2.specifics;}voidInt3_free(asn_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { Int3_1_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only);}intInt3_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { Int3_1_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key);}asn_dec_rval_tInt3_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, void *bufptr, size_t size, int tag_mode) { Int3_1_inherit_TYPE_descriptor(td); return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);}asn_enc_rval_tInt3_encode_der(asn_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { Int3_1_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);}asn_dec_rval_tInt3_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **structure, const char *opt_mname, void *bufptr, size_t size) { Int3_1_inherit_TYPE_descriptor(td); return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);}asn_enc_rval_tInt3_encode_xer(asn_TYPE_descriptor_t *td, void *structure, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) { Int3_1_inherit_TYPE_descriptor(td); return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);}/*** <<< STAT-DEFS [Int3] >>> ***/static ber_tlv_tag_t asn_DEF_Int3_1_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))};asn_TYPE_descriptor_t asn_DEF_Int3 = { "Int3", "Int3", Int3_free, Int3_print, Int3_constraint, Int3_decode_ber, Int3_encode_der, Int3_decode_xer, Int3_encode_xer, 0, /* Use generic outmost tag fetcher */ asn_DEF_Int3_1_tags, sizeof(asn_DEF_Int3_1_tags) /sizeof(asn_DEF_Int3_1_tags[0]), /* 1 */ asn_DEF_Int3_1_tags, /* Same as above */ sizeof(asn_DEF_Int3_1_tags) /sizeof(asn_DEF_Int3_1_tags[0]), /* 1 */ 0, 0, /* No members */ 0 /* No specifics */};/*** <<< INCLUDES [Int4] >>> ***/#include <Int3.h>/*** <<< TYPE-DECLS [Int4] >>> ***/typedef Int3_t Int4_t;/*** <<< FUNC-DECLS [Int4] >>> ***/extern asn_TYPE_descriptor_t asn_DEF_Int4;asn_struct_free_f Int4_free;asn_struct_print_f Int4_print;asn_constr_check_f Int4_constraint;ber_type_decoder_f Int4_decode_ber;der_type_encoder_f Int4_encode_der;xer_type_decoder_f Int4_decode_xer;xer_type_encoder_f Int4_encode_xer;/*** <<< CODE [Int4] >>> ***/intInt4_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { const Int3_t *st = (const Int3_t *)sptr; long value; if(!sptr) { _ASN_ERRLOG(app_errlog, app_key, "%s: value not given (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if(asn_INTEGER2long(st, &value)) { _ASN_ERRLOG(app_errlog, app_key, "%s: value too large (%s:%d)", td->name, __FILE__, __LINE__); return -1; } if((value >= 1 && value <= 10)) { /* Constraint check succeeded */ return 0; } else { _ASN_ERRLOG(app_errlog, app_key, "%s: constraint failed (%s:%d)", td->name, __FILE__, __LINE__); return -1; }}/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -