xref: /openbsd-src/lib/libutil/ober_oid_cmp.3 (revision 46035553bfdd96e63c94e32da0210227ec2e3cf1)
1.\" $OpenBSD: ober_oid_cmp.3,v 1.2 2019/12/31 10:34:14 martijn Exp $
2.\"
3.\" Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: December 31 2019 $
18.Dt OBER_OID_CMP 3
19.Os
20.Sh NAME
21.Nm ober_oid_cmp ,
22.Nm ober_oid2ber ,
23.Nm ober_string2oid
24.Nd OID helper functions for the BER library
25.Sh SYNOPSIS
26.In sys/types.h
27.In ber.h
28.Ft "int"
29.Fn "ober_oid_cmp" "struct ber_oid *a" "struct ber_oid *b"
30.Ft "size_t"
31.Fn "ober_oid2ber" "struct ber_oid *oid" "u_int8_t *buf" "size_t size"
32.Ft "int"
33.Fn "ober_string2oid" "const char *string" "struct ber_oid *oid"
34.Sh DESCRIPTION
35Object Identifiers are commonly used in ASN.1-based protocols.
36These functions provide an interface to parse OIDs.
37For internal representation of OIDs, the following structure
38.Vt struct ber_oid
39is being used:
40.Bd -literal
41#define BER_MIN_OID_LEN		2
42#define BER_MAX_OID_LEN		64
43
44struct ber_oid {
45	u_int32_t	bo_id[BER_MAX_OID_LEN + 1];
46	size_t		bo_n;
47};
48.Ed
49.Pp
50The
51.Fn ober_oid2ber
52and
53.Fn ober_string2oid
54functions may be used to convert from and to
55.Vt struct ber_oid .
56.Pp
57.Fn ober_oid_cmp
58may be used to compare two
59.Vt ber_oid
60structures.
61.Sh RETURN VALUES
62.Fn ober_oid2ber
63returns the number of bytes written or 0 on faliure.
64.Pp
65.Fn ober_string2oid
66returns 0 on success or -1 on failure.
67.Pp
68.Fn ober_oid_cmp
69returns 0 when oids
70.Fa a
71and
72.Fa b
73are identical.
74If
75.Fa b
76is a successor of
77.Fa a ,
781 is returned.
79If
80.Fa b
81is a predecessor of
82.Fa a ,
83-1 is returned.
84If
85.Fa b
86is larger, but a child of
87.Fa a ,
882 is returned.
89.Sh SEE ALSO
90.Xr ober_add_string 3 ,
91.Xr ober_get_string 3 ,
92.Xr ober_read_elements 3 ,
93.Xr ober_set_header 3
94.Sh HISTORY
95These functions first appeared as internal functions in
96.Xr snmpd 8
97in
98.Ox 4.2
99and were moved to libutil in
100.Ox 6.6 .
101.Sh AUTHORS
102.An -nosplit
103The BER library was written by
104.An Claudio Jeker Aq Mt claudio@openbsd.org ,
105.An Marc Balmer Aq Mt marc@openbsd.org
106and
107.An Reyk Floeter Aq Mt reyk@openbsd.org .
108