SIM-115: update simulator to use latest E2SM KPM version 3
[sim/e2-interface.git] / e2sim / asn1c / OCTET_STRING.h
1 /*-
2  * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef _OCTET_STRING_H_
6 #define _OCTET_STRING_H_
7
8 #include <asn_application.h>
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 typedef struct OCTET_STRING {
15         uint8_t *buf;   /* Buffer with consecutive OCTET_STRING bits */
16         size_t size;    /* Size of the buffer */
17
18         asn_struct_ctx_t _asn_ctx;      /* Parsing across buffer boundaries */
19 } OCTET_STRING_t;
20
21 extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING;
22 extern asn_TYPE_operation_t asn_OP_OCTET_STRING;
23
24 asn_struct_free_f OCTET_STRING_free;
25
26 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
27 asn_struct_print_f OCTET_STRING_print;
28 asn_struct_print_f OCTET_STRING_print_utf8;
29 #endif  /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
30
31 asn_struct_compare_f OCTET_STRING_compare;
32
33 #define OCTET_STRING_constraint asn_generic_no_constraint
34
35 #if !defined(ASN_DISABLE_BER_SUPPORT)
36 ber_type_decoder_f OCTET_STRING_decode_ber;
37 der_type_encoder_f OCTET_STRING_encode_der;
38 #endif  /* !defined(ASN_DISABLE_BER_SUPPORT) */
39
40 #if !defined(ASN_DISABLE_XER_SUPPORT)
41 xer_type_decoder_f OCTET_STRING_decode_xer_hex;     /* Hexadecimal */
42 xer_type_decoder_f OCTET_STRING_decode_xer_binary;  /* 01010111010 */
43 xer_type_decoder_f OCTET_STRING_decode_xer_utf8;    /* ASCII/UTF-8 */
44 xer_type_encoder_f OCTET_STRING_encode_xer;
45 xer_type_encoder_f OCTET_STRING_encode_xer_utf8;
46 #endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
47
48 #if !defined(ASN_DISABLE_JER_SUPPORT)
49 jer_type_encoder_f OCTET_STRING_encode_jer;
50 jer_type_encoder_f OCTET_STRING_encode_jer_utf8;
51 #endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
52
53 #if !defined(ASN_DISABLE_OER_SUPPORT)
54 oer_type_decoder_f OCTET_STRING_decode_oer;
55 oer_type_encoder_f OCTET_STRING_encode_oer;
56 #endif  /* !defined(ASN_DISABLE_OER_SUPPORT) */
57
58 #if !defined(ASN_DISABLE_UPER_SUPPORT)
59 per_type_decoder_f OCTET_STRING_decode_uper;
60 per_type_encoder_f OCTET_STRING_encode_uper;
61 #endif  /* !defined(ASN_DISABLE_UPER_SUPPORT) */
62 #if !defined(ASN_DISABLE_APER_SUPPORT)
63 per_type_decoder_f OCTET_STRING_decode_aper;
64 per_type_encoder_f OCTET_STRING_encode_aper;
65 #endif  /* !defined(ASN_DISABLE_APER_SUPPORT) */
66
67 #if !defined(ASN_DISABLE_RFILL_SUPPORT)
68 asn_random_fill_f  OCTET_STRING_random_fill;
69 #endif  /* !defined(ASN_DISABLE_RFILL_SUPPORT) */
70
71 #if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT)
72 int OCTET_STRING_per_get_characters(
73         asn_per_data_t *po,
74         uint8_t *buf,
75         size_t units,
76         unsigned int bpc,
77         unsigned int unit_bits,
78         long lb,
79         long ub,
80         const asn_per_constraints_t *pc);
81
82 int OCTET_STRING_per_put_characters(
83         asn_per_outp_t *po,
84         const uint8_t *buf,
85         size_t units,
86         unsigned int bpc,
87         unsigned int unit_bits,
88         long lb,
89         long ub,
90         const asn_per_constraints_t *pc);
91 #endif  /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */
92 /******************************
93  * Handy conversion routines. *
94  ******************************/
95
96 /*
97  * This function clears the previous value of the OCTET STRING (if any)
98  * and then allocates a new memory with the specified content (str/size).
99  * If size = -1, the size of the original string will be determined
100  * using strlen(str).
101  * If str equals to NULL, the function will silently clear the
102  * current contents of the OCTET STRING.
103  * Returns 0 if it was possible to perform operation, -1 otherwise.
104  */
105 int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);
106
107 /* Handy conversion from the C string into the OCTET STRING. */
108 #define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1)
109
110 /*
111  * Allocate and fill the new OCTET STRING and return a pointer to the newly
112  * allocated object. NULL is permitted in str: the function will just allocate
113  * empty OCTET STRING.
114  */
115 OCTET_STRING_t *OCTET_STRING_new_fromBuf(const asn_TYPE_descriptor_t *td,
116                                          const char *str, int size);
117
118 /****************************
119  * Internally useful stuff. *
120  ****************************/
121
122 typedef struct asn_OCTET_STRING_specifics_s {
123     /*
124      * Target structure description.
125      */
126     unsigned struct_size;   /* Size of the structure */
127     unsigned ctx_offset;    /* Offset of the asn_struct_ctx_t member */
128
129     enum asn_OS_Subvariant {
130         ASN_OSUBV_ANY, /* The open type (ANY) */
131         ASN_OSUBV_BIT, /* BIT STRING */
132         ASN_OSUBV_STR, /* String types, not {BMP,Universal}String  */
133         ASN_OSUBV_U16, /* 16-bit character (BMPString) */
134         ASN_OSUBV_U32  /* 32-bit character (UniversalString) */
135     } subvariant;
136 } asn_OCTET_STRING_specifics_t;
137
138 extern asn_OCTET_STRING_specifics_t asn_SPC_OCTET_STRING_specs;
139
140 size_t OCTET_STRING_random_length_constrained(
141     const asn_TYPE_descriptor_t *, const asn_encoding_constraints_t *,
142     size_t max_length);
143
144 #if !defined(ASN_DISABLE_BER_SUPPORT)
145 struct _stack_el {
146     ber_tlv_len_t left;   /* What's left to read (or -1) */
147     ber_tlv_len_t got;    /* What was actually processed */
148     unsigned cont_level;  /* Depth of subcontainment */
149     int want_nulls;       /* Want null "end of content" octets? */
150     int bits_chopped;     /* Flag in BIT STRING mode */
151     ber_tlv_tag_t tag;    /* For debugging purposes */
152     struct _stack_el *prev;
153     struct _stack_el *next;
154 };
155 struct _stack {
156     struct _stack_el *tail;
157     struct _stack_el *cur_ptr;
158 };
159 #endif  /* !defined(ASN_DISABLE_BER_SUPPORT) */
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif  /* _OCTET_STRING_H_ */