OpenBSD manual page server

Manual Page Search Parameters

OBER_OID_CMP(3) Library Functions Manual OBER_OID_CMP(3)

ober_oid_cmp, ober_oid2ber, ober_string2oidOID helper functions for the BER library

#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);

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 () and () functions may be used to convert from and to struct ber_oid.

() may be used to compare two ber_oid structures.

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.

ober_add_string(3), ober_get_string(3), ober_read_elements(3), ober_set_header(3)

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

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

October 21, 2021 OpenBSD-current