Fix licensing issues
[ric-plt/resource-status-manager.git] / RSM / 3rdparty / asn1codec / e2ap_engine / OCTET_STRING.h
1
2 /*-
3  * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
4  * Redistribution and modifications are permitted subject to BSD license.
5  */
6 #ifndef _OCTET_STRING_H_
7 #define _OCTET_STRING_H_
8
9 #include <asn_application.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 typedef struct OCTET_STRING {
16         uint8_t *buf;   /* Buffer with consecutive OCTET_STRING bits */
17         size_t size;    /* Size of the buffer */
18
19         asn_struct_ctx_t _asn_ctx;      /* Parsing across buffer boundaries */
20 } OCTET_STRING_t;
21
22 extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING;
23 extern asn_TYPE_operation_t asn_OP_OCTET_STRING;
24
25 asn_struct_free_f OCTET_STRING_free;
26 asn_struct_print_f OCTET_STRING_print;
27 asn_struct_print_f OCTET_STRING_print_utf8;
28 asn_struct_compare_f OCTET_STRING_compare;
29 ber_type_decoder_f OCTET_STRING_decode_ber;
30 der_type_encoder_f OCTET_STRING_encode_der;
31 xer_type_decoder_f OCTET_STRING_decode_xer_hex;         /* Hexadecimal */
32 xer_type_decoder_f OCTET_STRING_decode_xer_binary;      /* 01010111010 */
33 xer_type_decoder_f OCTET_STRING_decode_xer_utf8;        /* ASCII/UTF-8 */
34 xer_type_encoder_f OCTET_STRING_encode_xer;
35 xer_type_encoder_f OCTET_STRING_encode_xer_utf8;
36 oer_type_decoder_f OCTET_STRING_decode_oer;
37 oer_type_encoder_f OCTET_STRING_encode_oer;
38 per_type_decoder_f OCTET_STRING_decode_uper;
39 per_type_encoder_f OCTET_STRING_encode_uper;
40 per_type_decoder_f OCTET_STRING_decode_aper;
41 per_type_encoder_f OCTET_STRING_encode_aper;
42 asn_random_fill_f  OCTET_STRING_random_fill;
43
44 #define OCTET_STRING_constraint  asn_generic_no_constraint
45 #define OCTET_STRING_decode_xer  OCTET_STRING_decode_xer_hex
46
47 /******************************
48  * Handy conversion routines. *
49  ******************************/
50
51 /*
52  * This function clears the previous value of the OCTET STRING (if any)
53  * and then allocates a new memory with the specified content (str/size).
54  * If size = -1, the size of the original string will be determined
55  * using strlen(str).
56  * If str equals to NULL, the function will silently clear the
57  * current contents of the OCTET STRING.
58  * Returns 0 if it was possible to perform operation, -1 otherwise.
59  */
60 int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);
61
62 /* Handy conversion from the C string into the OCTET STRING. */
63 #define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1)
64
65 /*
66  * Allocate and fill the new OCTET STRING and return a pointer to the newly
67  * allocated object. NULL is permitted in str: the function will just allocate
68  * empty OCTET STRING.
69  */
70 OCTET_STRING_t *OCTET_STRING_new_fromBuf(const asn_TYPE_descriptor_t *td,
71                                          const char *str, int size);
72
73 /****************************
74  * Internally useful stuff. *
75  ****************************/
76
77 typedef struct asn_OCTET_STRING_specifics_s {
78     /*
79      * Target structure description.
80      */
81     unsigned struct_size;   /* Size of the structure */
82     unsigned ctx_offset;    /* Offset of the asn_struct_ctx_t member */
83
84     enum asn_OS_Subvariant {
85         ASN_OSUBV_ANY, /* The open type (ANY) */
86         ASN_OSUBV_BIT, /* BIT STRING */
87         ASN_OSUBV_STR, /* String types, not {BMP,Universal}String  */
88         ASN_OSUBV_U16, /* 16-bit character (BMPString) */
89         ASN_OSUBV_U32  /* 32-bit character (UniversalString) */
90     } subvariant;
91 } asn_OCTET_STRING_specifics_t;
92
93 extern asn_OCTET_STRING_specifics_t asn_SPC_OCTET_STRING_specs;
94
95 size_t OCTET_STRING_random_length_constrained(
96     const asn_TYPE_descriptor_t *, const asn_encoding_constraints_t *,
97     size_t max_length);
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif  /* _OCTET_STRING_H_ */