Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.6 KiB

  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
  35. Object Identifiers are commonly used in ASN.1-based protocols.
  36. These functions provide an interface to parse OIDs.
  37. For internal representation of OIDs, the following structure
  38. .Vt struct ber_oid
  39. is being used:
  40. .Bd -literal
  41. #define BER_MIN_OID_LEN 2
  42. #define BER_MAX_OID_LEN 64
  43. struct ber_oid {
  44. u_int32_t bo_id[BER_MAX_OID_LEN + 1];
  45. size_t bo_n;
  46. };
  47. .Ed
  48. .Pp
  49. The
  50. .Fn ober_oid2ber
  51. and
  52. .Fn ober_string2oid
  53. functions may be used to convert from and to
  54. .Vt struct ber_oid .
  55. .Pp
  56. .Fn ober_oid_cmp
  57. may be used to compare two
  58. .Vt ber_oid
  59. structures.
  60. .Sh RETURN VALUES
  61. .Fn ober_oid2ber
  62. returns the number of bytes written or 0 on faliure.
  63. .Pp
  64. .Fn ober_string2oid
  65. returns 0 on success or -1 on failure.
  66. .Pp
  67. .Fn ober_oid_cmp
  68. returns 0 when oids
  69. .Fa a
  70. and
  71. .Fa b
  72. are identical.
  73. If
  74. .Fa b
  75. is a successor of
  76. .Fa a ,
  77. 1 is returned.
  78. If
  79. .Fa b
  80. is a predecessor of
  81. .Fa a ,
  82. -1 is returned.
  83. If
  84. .Fa b
  85. is larger, but a child of
  86. .Fa a ,
  87. 2 is returned.
  88. .Sh SEE ALSO
  89. .Xr ober_add_string 3 ,
  90. .Xr ober_get_string 3 ,
  91. .Xr ober_read_elements 3 ,
  92. .Xr ober_set_header 3
  93. .Sh HISTORY
  94. These functions first appeared as internal functions in
  95. .Xr snmpd 8
  96. in
  97. .Ox 4.2
  98. and were moved to libutil in
  99. .Ox 6.6 .
  100. .Sh AUTHORS
  101. .An -nosplit
  102. The BER library was written by
  103. .An Claudio Jeker Aq Mt claudio@openbsd.org ,
  104. .An Marc Balmer Aq Mt marc@openbsd.org
  105. and
  106. .An Reyk Floeter Aq Mt reyk@openbsd.org .