BER_OID_CMP(3)

NAME
ber_oid_cmp, ber_oid2ber, ber_string2oid - OID helper functions for the BER library

SYNOPSIS
#include <sys/types.h>
#include <ber.h>
int
ber_oid_cmp(struct ber_oid *a, struct ber_oid *b);
size_t
ber_oid2ber(struct ber_oid *oid, u_int8_t *buf, size_t size);
int
ber_string2oid(const char *string, struct ber_oid *oid);

DESCRIPTION
Object Identifiers are commonly used in ASN.1-based protocols. These functions provide an interface to parse OIDs. For internal representation of OIDs, the following structure struct ber_oid is being used:

    #define BER_MIN_OID_LEN		2
    #define BER_MAX_OID_LEN		32
    struct ber_oid {
    	u_int32_t	bo_id[BER_MAX_OID_LEN + 1];
    	size_t		bo_n;
    };

The ber_oid2ber() and ber_string2oid() functions may be used to convert from and to struct ber_oid.

ber_oid_cmp() may be used to compare two ber_oid structures.

RETURN VALUES
ber_oid2ber() returns the number of bytes written or 0 on faliure.

ber_string2oid() returns 0 on success or -1 on failure.

ber_oid_cmp() returns 0 when oids a and b are identical. If b is a successor of a, 1 is returned. If b is a predecessor of a, -1 is returned. If b is larger, but a child of a, 2 is returned.

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

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>.