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.

142 lines
3.6 KiB

  1. .\" $OpenBSD: ber_set_header.3,v 1.2 2019/05/21 12:30:07 rob 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: May 21 2019 $
  18. .Dt BER_SET_HEADER 3
  19. .Os
  20. .Sh NAME
  21. .Nm ber_set_header ,
  22. .Nm ber_calc_len ,
  23. .Nm ber_set_writecallback ,
  24. .Nm ber_link_elements ,
  25. .Nm ber_replace_elements ,
  26. .Nm ber_unlink_elements ,
  27. .Nm ber_free_element ,
  28. .Nm ber_free_elements
  29. .Nd change and destroy ASN.1 objects for BER encoding
  30. .Sh SYNOPSIS
  31. .In sys/types.h
  32. .In ber.h
  33. .Ft "void"
  34. .Fn "ber_set_header" "struct ber_element *elm" "int class" "unsigned int type"
  35. .Ft "size_t"
  36. .Fn "ber_calc_len" "struct ber_element *root"
  37. .Ft "void"
  38. .Fo "ber_set_writecallback"
  39. .Fa "void (*cb)(void *arg, sizeof_t offs)"
  40. .Fc
  41. .Ft "void"
  42. .Fn "ber_link_elements" "struct ber_element *prev" "struct ber_element *elm"
  43. .Ft "void"
  44. .Fn "ber_replace_elements" "struct ber_element *prev" "struct ber_element *elm"
  45. .Ft "struct ber_element *"
  46. .Fn "ber_unlink_elements" "struct ber_element *prev"
  47. .Ft "void"
  48. .Fn "ber_free_element" "struct ber_element *root"
  49. .Ft "void"
  50. .Fn "ber_free_elements" "struct ber_element *root"
  51. .Pp
  52. .Fd #define BER_TYPE_BOOLEAN 1
  53. .Fd #define BER_TYPE_INTEGER 2
  54. .Fd #define BER_TYPE_BITSTRING 3
  55. .Fd #define BER_TYPE_OCTETSTRING 4
  56. .Fd #define BER_TYPE_NULL 5
  57. .Fd #define BER_TYPE_OBJECT 6
  58. .Fd #define BER_TYPE_ENUMERATED 10
  59. .Fd #define BER_TYPE_SEQUENCE 16
  60. .Fd #define BER_TYPE_SET 17
  61. .Pp
  62. .Fd #define BER_TYPE_CONSTRUCTED 0x20
  63. .Pp
  64. .Fd #define BER_CLASS_UNIVERSAL 0x0
  65. .Fd #define BER_CLASS_UNIV BER_CLASS_UNIVERSAL
  66. .Fd #define BER_CLASS_APPLICATION 0x1
  67. .Fd #define BER_CLASS_APP BER_CLASS_APPLICATION
  68. .Fd #define BER_CLASS_CONTEXT 0x2
  69. .Fd #define BER_CLASS_PRIVATE 0x3
  70. .Sh DESCRIPTION
  71. .Fn ber_set_header
  72. sets the
  73. .Fa class
  74. and
  75. .Fa type
  76. of
  77. .Fa elm .
  78. .Pp
  79. .Fn ber_calc_len
  80. determines the total length of
  81. .Fa root .
  82. .Pp
  83. .Fn ber_set_writecallback
  84. registers the
  85. .Vt br_cb
  86. callback function.
  87. .Pp
  88. .Fn ber_link_elements
  89. links
  90. .Fa prev
  91. and
  92. .Fa elm .
  93. .Pp
  94. .Fn ber_replace_elements
  95. replaces
  96. .Fa prev
  97. with
  98. .Fa new
  99. and frees any dynamically allocated storage assocated with
  100. .Fa prev .
  101. .Pp
  102. .Fn ber_unlink_elements
  103. unlinks
  104. .Fa prev .
  105. .Pp
  106. .Fn ber_free_element
  107. and
  108. .Fn ber_free_elements
  109. free any dynamically allocated storage associated with
  110. .Fa root .
  111. .Sh RETURN VALUES
  112. .Fn ber_calc_len
  113. returns the total length of a fully populated
  114. .Fa root
  115. containing one or more
  116. .Vt ber_element .
  117. .Pp
  118. .Fn ber_unlink_elements
  119. returns a pointer to
  120. .Vt ber_element .
  121. .Sh SEE ALSO
  122. .Xr ber_add_string 3 ,
  123. .Xr ber_get_string 3 ,
  124. .Xr ber_oid_cmp 3 ,
  125. .Xr ber_read_elements 3
  126. .Sh STANDARDS
  127. ITU-T Recommendation X.690, also known as ISO/IEC 8825-1:
  128. Information technology - ASN.1 encoding rules.
  129. .Sh HISTORY
  130. These functions first appeared as internal functions in
  131. .Xr snmpd 8
  132. in
  133. .Ox 4.2
  134. and were moved to libutil in
  135. .Ox 6.6 .
  136. .Sh AUTHORS
  137. .An -nosplit
  138. The BER library was written by
  139. .An Claudio Jeker Aq Mt claudio@openbsd.org ,
  140. .An Marc Balmer Aq Mt marc@openbsd.org
  141. and
  142. .An Reyk Floeter Aq Mt reyk@openbsd.org .