]> git.stg.codes - stg.git/blob - stglibs/smux.lib/Counter.c
Ticket 37. The TARIFF::CHANGE_POLICY changePolicy object added in the
[stg.git] / stglibs / smux.lib / Counter.c
1 /*
2  * Generated by asn1c-0.9.21 (http://lionet.info/asn1c)
3  * From ASN.1 module "RFC1155-SMI"
4  *      found in "RFC1155-SMI.asn1"
5  *      `asn1c -fskeletons-copy`
6  */
7
8 #include <asn_internal.h>
9
10 #include "Counter.h"
11
12 int
13 Counter_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
14                         asn_app_constraint_failed_f *ctfailcb, void *app_key) {
15         const INTEGER_t *st = (const INTEGER_t *)sptr;
16         long value;
17         
18         if(!sptr) {
19                 _ASN_CTFAIL(app_key, td, sptr,
20                         "%s: value not given (%s:%d)",
21                         td->name, __FILE__, __LINE__);
22                 return -1;
23         }
24         
25         if(asn_INTEGER2long(st, &value)) {
26                 _ASN_CTFAIL(app_key, td, sptr,
27                         "%s: value too large (%s:%d)",
28                         td->name, __FILE__, __LINE__);
29                 return -1;
30         }
31         
32         if((value >= 0 && value <= 4294967295)) {
33                 /* Constraint check succeeded */
34                 return 0;
35         } else {
36                 _ASN_CTFAIL(app_key, td, sptr,
37                         "%s: constraint failed (%s:%d)",
38                         td->name, __FILE__, __LINE__);
39                 return -1;
40         }
41 }
42
43 /*
44  * This type is implemented using INTEGER,
45  * so here we adjust the DEF accordingly.
46  */
47 static void
48 Counter_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
49         td->free_struct    = asn_DEF_INTEGER.free_struct;
50         td->print_struct   = asn_DEF_INTEGER.print_struct;
51         td->ber_decoder    = asn_DEF_INTEGER.ber_decoder;
52         td->der_encoder    = asn_DEF_INTEGER.der_encoder;
53         td->xer_decoder    = asn_DEF_INTEGER.xer_decoder;
54         td->xer_encoder    = asn_DEF_INTEGER.xer_encoder;
55         td->uper_decoder   = asn_DEF_INTEGER.uper_decoder;
56         td->uper_encoder   = asn_DEF_INTEGER.uper_encoder;
57         if(!td->per_constraints)
58                 td->per_constraints = asn_DEF_INTEGER.per_constraints;
59         td->elements       = asn_DEF_INTEGER.elements;
60         td->elements_count = asn_DEF_INTEGER.elements_count;
61         td->specifics      = asn_DEF_INTEGER.specifics;
62 }
63
64 void
65 Counter_free(asn_TYPE_descriptor_t *td,
66                 void *struct_ptr, int contents_only) {
67         Counter_1_inherit_TYPE_descriptor(td);
68         td->free_struct(td, struct_ptr, contents_only);
69 }
70
71 int
72 Counter_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
73                 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
74         Counter_1_inherit_TYPE_descriptor(td);
75         return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
76 }
77
78 asn_dec_rval_t
79 Counter_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
80                 void **structure, const void *bufptr, size_t size, int tag_mode) {
81         Counter_1_inherit_TYPE_descriptor(td);
82         return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
83 }
84
85 asn_enc_rval_t
86 Counter_encode_der(asn_TYPE_descriptor_t *td,
87                 void *structure, int tag_mode, ber_tlv_tag_t tag,
88                 asn_app_consume_bytes_f *cb, void *app_key) {
89         Counter_1_inherit_TYPE_descriptor(td);
90         return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
91 }
92
93 asn_dec_rval_t
94 Counter_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
95                 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
96         Counter_1_inherit_TYPE_descriptor(td);
97         return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
98 }
99
100 asn_enc_rval_t
101 Counter_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
102                 int ilevel, enum xer_encoder_flags_e flags,
103                 asn_app_consume_bytes_f *cb, void *app_key) {
104         Counter_1_inherit_TYPE_descriptor(td);
105         return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
106 }
107
108 static ber_tlv_tag_t asn_DEF_Counter_tags_1[] = {
109         (ASN_TAG_CLASS_APPLICATION | (1 << 2)),
110         (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
111 };
112 asn_TYPE_descriptor_t asn_DEF_Counter = {
113         "Counter",
114         "Counter",
115         Counter_free,
116         Counter_print,
117         Counter_constraint,
118         Counter_decode_ber,
119         Counter_encode_der,
120         Counter_decode_xer,
121         Counter_encode_xer,
122         0, 0,   /* No PER support, use "-gen-PER" to enable */
123         0,      /* Use generic outmost tag fetcher */
124         asn_DEF_Counter_tags_1,
125         sizeof(asn_DEF_Counter_tags_1)
126                 /sizeof(asn_DEF_Counter_tags_1[0]) - 1, /* 1 */
127         asn_DEF_Counter_tags_1, /* Same as above */
128         sizeof(asn_DEF_Counter_tags_1)
129                 /sizeof(asn_DEF_Counter_tags_1[0]), /* 2 */
130         0,      /* No PER visible constraints */
131         0, 0,   /* No members */
132         0       /* No specifics */
133 };
134