OBER_OID_CMP(3)

NAME
ober_oid_cmp, ober_oid2ber, ober_string2oid - OID helper functions for the BER library

SYNOPSIS
libutil
#include <sys/types.h>
#include <ber.h>
int
ober_oid_cmp(struct ber_oid *a, struct ber_oid *b);
size_t
ober_oid2ber(struct ber_oid *oid, u_int8_t *buf, size_t size);
int
ober_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		64
    struct ber_oid {
    	u_int32_t	bo_id[BER_MAX_OID_LEN + 1];
    	size_t		bo_n;
    };

The ober_oid2ber() and ober_string2oid() functions may be used to convert from and to struct ber_oid.

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

RETURN VALUES
ober_oid2ber() returns the number of bytes written or 0 on failure.

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

ober_oid_cmp() returns an integer greater than, equal to, or less than 0, according to whether the oid a is greater than, equal to, or less than the oid b. If the shortest length from a and b matches the weight of the integer is 2, else it is 1.

SEE ALSO
ober_add_string(3), ober_get_string(3), ober_read_elements(3), ober_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>.