BER_SET_HEADER(3)

NAME
ber_set_header, ber_calc_len, ber_set_writecallback, ber_link_elements, ber_replace_elements, ber_unlink_elements, ber_free_element, ber_free_elements - change and destroy ASN.1 objects for BER encoding

SYNOPSIS
#include <sys/types.h>
#include <ber.h>
void
ber_set_header(struct ber_element *elm, int class, unsigned int type);
size_t
ber_calc_len(struct ber_element *root);
void
ber_set_writecallback(void (*cb)(void *arg, sizeof_t offs));
void
ber_link_elements(struct ber_element *prev, struct ber_element *elm);
void
ber_replace_elements(struct ber_element *prev, struct ber_element *elm);
struct ber_element *
ber_unlink_elements(struct ber_element *prev);
void
ber_free_element(struct ber_element *root);
void
ber_free_elements(struct ber_element *root);

#define BER_TYPE_BOOLEAN 1
#define BER_TYPE_INTEGER 2
#define BER_TYPE_BITSTRING 3
#define BER_TYPE_OCTETSTRING 4
#define BER_TYPE_NULL 5
#define BER_TYPE_OBJECT 6
#define BER_TYPE_ENUMERATED 10
#define BER_TYPE_SEQUENCE 16
#define BER_TYPE_SET 17

#define BER_TYPE_CONSTRUCTED 0x20

#define BER_CLASS_UNIVERSAL 0x0
#define BER_CLASS_UNIV BER_CLASS_UNIVERSAL
#define BER_CLASS_APPLICATION 0x1
#define BER_CLASS_APP BER_CLASS_APPLICATION
#define BER_CLASS_CONTEXT 0x2
#define BER_CLASS_PRIVATE 0x3

DESCRIPTION
ber_set_header() sets the class and type of elm.

ber_calc_len() determines the total length of root.

ber_set_writecallback() registers the br_cb callback function.

ber_link_elements() links prev and elm.

ber_replace_elements() replaces prev with new and frees any dynamically allocated storage assocated with prev.

ber_unlink_elements() unlinks prev.

ber_free_element() and ber_free_elements() free any dynamically allocated storage associated with root.

RETURN VALUES
ber_calc_len() returns the total length of a fully populated root containing one or more ber_element.

ber_unlink_elements() returns a pointer to ber_element.

SEE ALSO
ber_add_string(3), ber_get_string(3), ber_oid_cmp(3), ber_read_elements(3)

STANDARDS
ITU-T Recommendation X.690, also known as ISO/IEC 8825-1: Information technology - ASN.1 encoding rules.

HISTORY
These functions first appeared as internal functions in snmpd(8) in OpenBSD 4.2 and were moved to libutil in OpenBSD 6.6.

AUTHORS
-nosplit The ber library was written by Claudio Jeker <claudio@openbsd.org>, Marc Balmer <marc@openbsd.org> and Reyk Floeter <reyk@openbsd.org>.