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