+/*-\r
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
+ * Redistribution and modifications are permitted subject to BSD license.\r
+ */\r
+#ifndef _OCTET_STRING_H_\r
+#define _OCTET_STRING_H_\r
+\r
+#include <asn_application.h>\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+typedef struct OCTET_STRING {\r
+ uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */\r
+ size_t size; /* Size of the buffer */\r
+\r
+ asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */\r
+} OCTET_STRING_t;\r
+\r
+extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING;\r
+extern asn_TYPE_operation_t asn_OP_OCTET_STRING;\r
+\r
+asn_struct_free_f OCTET_STRING_free;\r
+asn_struct_print_f OCTET_STRING_print;\r
+asn_struct_print_f OCTET_STRING_print_utf8;\r
+asn_struct_compare_f OCTET_STRING_compare;\r
+ber_type_decoder_f OCTET_STRING_decode_ber;\r
+der_type_encoder_f OCTET_STRING_encode_der;\r
+xer_type_decoder_f OCTET_STRING_decode_xer_hex; /* Hexadecimal */\r
+xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */\r
+xer_type_decoder_f OCTET_STRING_decode_xer_utf8; /* ASCII/UTF-8 */\r
+xer_type_encoder_f OCTET_STRING_encode_xer;\r
+xer_type_encoder_f OCTET_STRING_encode_xer_utf8;\r
+oer_type_decoder_f OCTET_STRING_decode_oer;\r
+oer_type_encoder_f OCTET_STRING_encode_oer;\r
+per_type_decoder_f OCTET_STRING_decode_uper;\r
+per_type_encoder_f OCTET_STRING_encode_uper;\r
+per_type_decoder_f OCTET_STRING_decode_aper;\r
+per_type_encoder_f OCTET_STRING_encode_aper;\r
+asn_random_fill_f OCTET_STRING_random_fill;\r
+\r
+#define OCTET_STRING_constraint asn_generic_no_constraint\r
+#define OCTET_STRING_decode_xer OCTET_STRING_decode_xer_hex\r
+\r
+/******************************\r
+ * Handy conversion routines. *\r
+ ******************************/\r
+\r
+/*\r
+ * This function clears the previous value of the OCTET STRING (if any)\r
+ * and then allocates a new memory with the specified content (str/size).\r
+ * If size = -1, the size of the original string will be determined\r
+ * using strlen(str).\r
+ * If str equals to NULL, the function will silently clear the\r
+ * current contents of the OCTET STRING.\r
+ * Returns 0 if it was possible to perform operation, -1 otherwise.\r
+ */\r
+int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);\r
+\r
+/* Handy conversion from the C string into the OCTET STRING. */\r
+#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1)\r
+\r
+/*\r
+ * Allocate and fill the new OCTET STRING and return a pointer to the newly\r
+ * allocated object. NULL is permitted in str: the function will just allocate\r
+ * empty OCTET STRING.\r
+ */\r
+OCTET_STRING_t *OCTET_STRING_new_fromBuf(const asn_TYPE_descriptor_t *td,\r
+ const char *str, int size);\r
+\r
+/****************************\r
+ * Internally useful stuff. *\r
+ ****************************/\r
+\r
+typedef struct asn_OCTET_STRING_specifics_s {\r
+ /*\r
+ * Target structure description.\r
+ */\r
+ unsigned struct_size; /* Size of the structure */\r
+ unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */\r
+\r
+ enum asn_OS_Subvariant {\r
+ ASN_OSUBV_ANY, /* The open type (ANY) */\r
+ ASN_OSUBV_BIT, /* BIT STRING */\r
+ ASN_OSUBV_STR, /* String types, not {BMP,Universal}String */\r
+ ASN_OSUBV_U16, /* 16-bit character (BMPString) */\r
+ ASN_OSUBV_U32 /* 32-bit character (UniversalString) */\r
+ } subvariant;\r
+} asn_OCTET_STRING_specifics_t;\r
+\r
+extern asn_OCTET_STRING_specifics_t asn_SPC_OCTET_STRING_specs;\r
+\r
+size_t OCTET_STRING_random_length_constrained(\r
+ const asn_TYPE_descriptor_t *, const asn_encoding_constraints_t *,\r
+ size_t max_length);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* _OCTET_STRING_H_ */\r