/contrib/bsnmp/gensnmptree/gensnmptree.1

https://bitbucket.org/freebsd/freebsd-head/ · Unknown · 246 lines · 227 code · 19 blank · 0 comment · 0 complexity · e99f3a6ff2a772e3cf8787b422232f51 MD5 · raw file

  1. .\"
  2. .\" Copyright (c) 2001-2005
  3. .\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
  4. .\" All rights reserved.
  5. .\" Copyright (c) 2006
  6. .\" Hartmut Brandt
  7. .\" All rights reserved.
  8. .\"
  9. .\" Author: Harti Brandt <harti@FreeBSD.org>
  10. .\"
  11. .\" Redistribution and use in source and binary forms, with or without
  12. .\" modification, are permitted provided that the following conditions
  13. .\" are met:
  14. .\" 1. Redistributions of source code must retain the above copyright
  15. .\" notice, this list of conditions and the following disclaimer.
  16. .\" 2. Redistributions in binary form must reproduce the above copyright
  17. .\" notice, this list of conditions and the following disclaimer in the
  18. .\" documentation and/or other materials provided with the distribution.
  19. .\"
  20. .\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  21. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23. .\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
  24. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  26. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  28. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  29. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. .\" SUCH DAMAGE.
  31. .\"
  32. .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $
  33. .\"
  34. .Dd May 26, 2006
  35. .Dt GENSNMPTREE 1
  36. .Os
  37. .Sh NAME
  38. .Nm gensnmptree
  39. .Nd "generate C and header files from a MIB description file"
  40. .Sh SYNOPSIS
  41. .Nm
  42. .Op Fl dEehlt
  43. .Op Fl I Ar directory
  44. .Op Fl i Ar infile
  45. .Op Fl p Ar prefix
  46. .Op Ar name Ar ...
  47. .Sh DESCRIPTION
  48. The
  49. .Nm
  50. utility is used to either generate C language tables and header files from
  51. a MIB description or to numeric OIDs from MIB descriptions.
  52. The first form is used only for maintaining the
  53. .Xr bsnmpd 1
  54. daemon or for module writers.
  55. The second form may be used by SNMP client program writers.
  56. .Pp
  57. If none of the options
  58. .Fl e ,
  59. .Fl E
  60. or
  61. .Fl t
  62. are used
  63. .Nm
  64. reads a MIB description from its standard input and creates two files: a
  65. C-file
  66. .Ar prefix Ns tree.c
  67. containing a table used by
  68. .Xr bsnmpd 1
  69. during PDU processing
  70. and a header file
  71. .Ar prefix Ns tree.h
  72. containing appropriate declarations of the callback functions used in this
  73. table, the table itself and definitions for all enums.
  74. .Pp
  75. The following options are available:
  76. .Bl -tag -width ".Fl E"
  77. .It Fl d
  78. Switch on debugging.
  79. .It Fl E
  80. Extract enumerations and bit constructs.
  81. In this mode the tool emits
  82. a header file that contains for each type given on the command line a
  83. C-enum definition and a preprocessor define that may be used to map
  84. values to strings.
  85. .It Fl e
  86. .Nm
  87. expects MIB variable names (only the last component) on its command line.
  88. It reads a MIB specification from standard input and for each MIB variable
  89. name emits three C preprocessor defines on its standard output:
  90. .Bl -tag -width ".Va OIDLEN_ Ns Ar Name"
  91. .It Va OIDX_ Ns Ar name
  92. This define can be used to initialize a
  93. .Va struct asn_oid
  94. in the following way:
  95. .Pp
  96. .Dl const struct asn_oid oid_sysDescr = OIDX_sysDescr;
  97. .It Va OIDLEN_ Ns Ar name
  98. is the length of the OID.
  99. .It Va OID_ Ns Ar name
  100. is the last component of the OID.
  101. .El
  102. .It Fl h
  103. Print a short help page.
  104. .It Fl I Ar directory
  105. Add the named directory to the include path just before the standard include
  106. directories.
  107. .It Fl i Ar infile
  108. Read from the named file instead of standard input.
  109. .It Fl l
  110. Generate local preprocessor includes.
  111. This is used for bootstrapping
  112. .Xr bsnmpd 1 .
  113. .It Fl t
  114. Instead of normal output print the resulting tree.
  115. .It Fl p Ar prefix
  116. Prefix the file names and the table name with
  117. .Ar prefix .
  118. .El
  119. .Sh MIBS
  120. The syntax of the MIB description file can formally be specified as follows:
  121. .Bd -unfilled -offset indent
  122. file := top | top file
  123. top := tree | typedef | include
  124. tree := head elements ')'
  125. entry := head ':' index STRING elements ')'
  126. leaf := head type STRING ACCESS ')'
  127. column := head type ACCESS ')'
  128. type := BASETYPE | BASETYPE '|' subtype | enum | bits
  129. subtype := STRING
  130. enum := ENUM '(' value ')'
  131. bits := BITS '(' value ')'
  132. value := INT STRING | INT STRING value
  133. head := '(' INT STRING
  134. elements := EMPTY | elements element
  135. element := tree | leaf | column
  136. index := type | index type
  137. typedef := 'typedef' STRING type
  138. include := 'include' filespec
  139. filespec := '"' STRING '"' | '<' STRING '>'
  140. .Ed
  141. .Pp
  142. .Ar BASETYPE
  143. specifies a SNMP data type and may be one of
  144. .Bl -bullet -offset indent -compact
  145. .It
  146. NULL
  147. .It
  148. INTEGER
  149. .It
  150. INTEGER32 (same as INTEGER)
  151. .It
  152. UNSIGNED32 (same as GAUGE)
  153. .It
  154. OCTETSTRING
  155. .It
  156. IPADDRESS
  157. .It
  158. OID
  159. .It
  160. TIMETICKS
  161. .It
  162. COUNTER
  163. .It
  164. GAUGE
  165. .It
  166. COUNTER64
  167. .El
  168. .Pp
  169. .Ar ACCESS
  170. specifies the accessibility of the MIB variable (which operation can be
  171. performed) and is one of
  172. .Bl -bullet -offset indent -compact
  173. .It
  174. GET
  175. .It
  176. SET
  177. .El
  178. .Pp
  179. .Ar INT
  180. is a decimal integer and
  181. .Ar STRING
  182. is any string starting with a letter or underscore and consisting of
  183. letters, digits, underscores and minuses, that is not one of the keywords.
  184. .Pp
  185. The
  186. .Ar typedef
  187. directive associates a type with a single name.
  188. .Pp
  189. The
  190. .Ar include
  191. directive is replaced by the contents of the named file.
  192. .Sh EXAMPLES
  193. The following MIB description describes the system group:
  194. .Bd -literal -offset indent
  195. include "tc.def"
  196. typedef AdminStatus ENUM (
  197. 1 up
  198. 2 down
  199. )
  200. (1 internet
  201. (2 mgmt
  202. (1 mibII
  203. (1 system
  204. (1 sysDescr OCTETSTRING op_system_group GET)
  205. (2 sysObjectId OID op_system_group GET)
  206. (3 sysUpTime TIMETICKS op_system_group GET)
  207. (4 sysContact OCTETSTRING op_system_group GET SET)
  208. (5 sysName OCTETSTRING op_system_group GET SET)
  209. (6 sysLocation OCTETSTRING op_system_group GET SET)
  210. (7 sysServices INTEGER op_system_group GET)
  211. (8 sysORLastChange TIMETICKS op_system_group GET)
  212. (9 sysORTable
  213. (1 sysOREntry : INTEGER op_or_table
  214. (1 sysORIndex INTEGER)
  215. (2 sysORID OID GET)
  216. (3 sysORDescr OCTETSTRING GET)
  217. (4 sysORUpTime TIMETICKS GET)
  218. ))
  219. )
  220. )
  221. )
  222. )
  223. .Ed
  224. .Sh SEE ALSO
  225. .Xr bsnmpd 1
  226. .Sh AUTHORS
  227. .An Hartmut Brandt Aq harti@FreeBSD.org