blob: 22bd6272bdf8cf63c08e654780093af86ff30e90 [file] [log] [blame]
vlmfa67ddc2004-06-03 03:38:44 +00001/*-
2 * Copyright (c) 2003 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
vlmd1579582004-09-24 21:00:50 +00008#include <asn_application.h>
vlmfa67ddc2004-06-03 03:38:44 +00009
vlm3a417582005-07-24 09:03:44 +000010#ifdef __cplusplus
11extern "C" {
12#endif
13
vlmfa67ddc2004-06-03 03:38:44 +000014typedef struct OCTET_STRING {
15 uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */
16 int size; /* Size of the buffer */
17
vlmef6355b2004-09-29 13:26:15 +000018 asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
vlmfa67ddc2004-06-03 03:38:44 +000019} OCTET_STRING_t;
20
vlmef6355b2004-09-29 13:26:15 +000021extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING;
vlmfa67ddc2004-06-03 03:38:44 +000022
vlm39ba4c42004-09-22 16:06:28 +000023asn_struct_free_f OCTET_STRING_free;
vlmfa67ddc2004-06-03 03:38:44 +000024asn_struct_print_f OCTET_STRING_print;
vlm9de248e2004-10-20 15:50:55 +000025asn_struct_print_f OCTET_STRING_print_utf8;
vlm39ba4c42004-09-22 16:06:28 +000026ber_type_decoder_f OCTET_STRING_decode_ber;
27der_type_encoder_f OCTET_STRING_encode_der;
vlm9de248e2004-10-20 15:50:55 +000028xer_type_decoder_f OCTET_STRING_decode_xer_hex; /* Hexadecimal */
29xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */
30xer_type_decoder_f OCTET_STRING_decode_xer_utf8; /* ASCII/UTF-8 */
vlm39ba4c42004-09-22 16:06:28 +000031xer_type_encoder_f OCTET_STRING_encode_xer;
vlm9de248e2004-10-20 15:50:55 +000032xer_type_encoder_f OCTET_STRING_encode_xer_utf8;
vlm337167e2005-11-26 11:25:14 +000033per_type_decoder_f OCTET_STRING_decode_uper;
vlmfa67ddc2004-06-03 03:38:44 +000034
vlm0f1ab762004-10-12 05:57:23 +000035/******************************
36 * Handy conversion routines. *
37 ******************************/
vlmfa67ddc2004-06-03 03:38:44 +000038
39/*
40 * This function clears the previous value of the OCTET STRING (if any)
vlm7e66aa82004-09-02 12:11:47 +000041 * and then allocates a new memory and returns a pointer to it.
42 * If size = -1, the size of the original string will be determined
vlmfa67ddc2004-06-03 03:38:44 +000043 * using strlen(str).
44 * If str equals to NULL, the function will silently clear the
45 * current contents of the OCTET STRING.
46 * Returns 0 if it was possible to perform operation, -1 otherwise.
47 */
48int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);
49
vlm0f1ab762004-10-12 05:57:23 +000050/* Handy conversion from the C string into the OCTET STRING. */
vlmfa8b7942005-04-18 05:41:08 +000051#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1)
vlm0f1ab762004-10-12 05:57:23 +000052
vlmfa67ddc2004-06-03 03:38:44 +000053/*
54 * Allocate and fill the new OCTET STRING and return a pointer to the newly
55 * allocated object. NULL is permitted in str: the function will just allocate
56 * empty OCTET STRING.
57 */
vlm0f1ab762004-10-12 05:57:23 +000058OCTET_STRING_t *OCTET_STRING_new_fromBuf(asn_TYPE_descriptor_t *td,
59 const char *str, int size);
vlmfa67ddc2004-06-03 03:38:44 +000060
vlm0f1ab762004-10-12 05:57:23 +000061/****************************
62 * Internally useful stuff. *
63 ****************************/
64
65typedef struct asn_OCTET_STRING_specifics_s {
66 /*
67 * Target structure description.
68 */
69 int struct_size; /* Size of the structure */
70 int ctx_offset; /* Offset of the asn_struct_ctx_t member */
71
72 int subvariant; /* {0,1,2} for O-S, BIT STRING or ANY */
73} asn_OCTET_STRING_specifics_t;
vlmfa67ddc2004-06-03 03:38:44 +000074
vlm3a417582005-07-24 09:03:44 +000075#ifdef __cplusplus
76}
77#endif
78
vlmfa67ddc2004-06-03 03:38:44 +000079#endif /* _OCTET_STRING_H_ */