2003-11-10 08:53:38 +00:00
|
|
|
.\"
|
2005-10-04 14:41:06 +00:00
|
|
|
.\" Copyright (c) 2001-2005
|
2003-11-10 08:53:38 +00:00
|
|
|
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
|
|
|
|
.\" All rights reserved.
|
2006-05-30 07:46:52 +00:00
|
|
|
.\" Copyright (c) 2006
|
|
|
|
.\" Hartmut Brandt
|
|
|
|
.\" All rights reserved.
|
2003-11-10 08:53:38 +00:00
|
|
|
.\"
|
2010-05-24 06:26:38 +00:00
|
|
|
.\" Author: Harti Brandt <harti@FreeBSD.org>
|
2016-12-27 23:32:54 +00:00
|
|
|
.\"
|
2004-08-06 13:38:30 +00:00
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
2003-11-10 08:53:38 +00:00
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2016-12-27 23:32:54 +00:00
|
|
|
.\"
|
2004-08-06 13:38:30 +00:00
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
2003-11-10 08:53:38 +00:00
|
|
|
.\"
|
2006-05-30 07:46:52 +00:00
|
|
|
.\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $
|
2003-11-10 08:53:38 +00:00
|
|
|
.\"
|
2006-05-30 07:46:52 +00:00
|
|
|
.Dd May 26, 2006
|
2005-02-28 17:27:11 +00:00
|
|
|
.Dt GENSNMPTREE 1
|
2003-11-10 08:53:38 +00:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm gensnmptree
|
|
|
|
.Nd "generate C and header files from a MIB description file"
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
2006-05-30 07:46:52 +00:00
|
|
|
.Op Fl dEehlt
|
|
|
|
.Op Fl I Ar directory
|
|
|
|
.Op Fl i Ar infile
|
2003-11-10 08:53:38 +00:00
|
|
|
.Op Fl p Ar prefix
|
|
|
|
.Op Ar name Ar ...
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility is used to either generate C language tables and header files from
|
2005-10-04 14:41:06 +00:00
|
|
|
a MIB description or to numeric OIDs from MIB descriptions.
|
|
|
|
The first form is used only for maintaining the
|
2006-02-27 16:16:18 +00:00
|
|
|
.Xr bsnmpd 1
|
2003-11-10 08:53:38 +00:00
|
|
|
daemon or for module writers.
|
|
|
|
The second form may be used by SNMP client program writers.
|
|
|
|
.Pp
|
2006-05-30 07:46:52 +00:00
|
|
|
If none of the options
|
|
|
|
.Fl e ,
|
|
|
|
.Fl E
|
|
|
|
or
|
2010-03-12 11:05:37 +00:00
|
|
|
.Fl t
|
2006-05-30 07:46:52 +00:00
|
|
|
are used
|
2003-11-10 08:53:38 +00:00
|
|
|
.Nm
|
|
|
|
reads a MIB description from its standard input and creates two files: a
|
|
|
|
C-file
|
|
|
|
.Ar prefix Ns tree.c
|
|
|
|
containing a table used by
|
2006-02-27 16:16:18 +00:00
|
|
|
.Xr bsnmpd 1
|
2003-11-10 08:53:38 +00:00
|
|
|
during PDU processing
|
|
|
|
and a header file
|
|
|
|
.Ar prefix Ns tree.h
|
2006-05-30 07:46:52 +00:00
|
|
|
containing appropriate declarations of the callback functions used in this
|
|
|
|
table, the table itself and definitions for all enums.
|
2003-11-10 08:53:38 +00:00
|
|
|
.Pp
|
2006-05-30 07:46:52 +00:00
|
|
|
The following options are available:
|
|
|
|
.Bl -tag -width ".Fl E"
|
|
|
|
.It Fl d
|
|
|
|
Switch on debugging.
|
|
|
|
.It Fl E
|
|
|
|
Extract enumerations and bit constructs.
|
|
|
|
In this mode the tool emits
|
|
|
|
a header file that contains for each type given on the command line a
|
|
|
|
C-enum definition and a preprocessor define that may be used to map
|
|
|
|
values to strings.
|
|
|
|
.It Fl e
|
2003-11-10 08:53:38 +00:00
|
|
|
.Nm
|
|
|
|
expects MIB variable names (only the last component) on its command line.
|
|
|
|
It reads a MIB specification from standard input and for each MIB variable
|
2006-02-27 16:16:18 +00:00
|
|
|
name emits three C preprocessor defines on its standard output:
|
|
|
|
.Bl -tag -width ".Va OIDLEN_ Ns Ar Name"
|
|
|
|
.It Va OIDX_ Ns Ar name
|
|
|
|
This define can be used to initialize a
|
|
|
|
.Va struct asn_oid
|
|
|
|
in the following way:
|
|
|
|
.Pp
|
|
|
|
.Dl const struct asn_oid oid_sysDescr = OIDX_sysDescr;
|
|
|
|
.It Va OIDLEN_ Ns Ar name
|
|
|
|
is the length of the OID.
|
|
|
|
.It Va OID_ Ns Ar name
|
|
|
|
is the last component of the OID.
|
|
|
|
.El
|
2003-11-10 08:53:38 +00:00
|
|
|
.It Fl h
|
|
|
|
Print a short help page.
|
2006-05-30 07:46:52 +00:00
|
|
|
.It Fl I Ar directory
|
|
|
|
Add the named directory to the include path just before the standard include
|
|
|
|
directories.
|
|
|
|
.It Fl i Ar infile
|
|
|
|
Read from the named file instead of standard input.
|
2003-11-10 08:53:38 +00:00
|
|
|
.It Fl l
|
2005-10-04 14:41:06 +00:00
|
|
|
Generate local preprocessor includes.
|
|
|
|
This is used for bootstrapping
|
2006-02-27 16:16:18 +00:00
|
|
|
.Xr bsnmpd 1 .
|
2004-08-06 13:38:30 +00:00
|
|
|
.It Fl t
|
|
|
|
Instead of normal output print the resulting tree.
|
2003-11-10 08:53:38 +00:00
|
|
|
.It Fl p Ar prefix
|
|
|
|
Prefix the file names and the table name with
|
|
|
|
.Ar prefix .
|
|
|
|
.El
|
|
|
|
.Sh MIBS
|
|
|
|
The syntax of the MIB description file can formally be specified as follows:
|
|
|
|
.Bd -unfilled -offset indent
|
2006-05-30 07:46:52 +00:00
|
|
|
file := top | top file
|
|
|
|
|
|
|
|
top := tree | typedef | include
|
|
|
|
|
|
|
|
tree := head elements ')'
|
|
|
|
|
|
|
|
entry := head ':' index STRING elements ')'
|
|
|
|
|
|
|
|
leaf := head type STRING ACCESS ')'
|
|
|
|
|
|
|
|
column := head type ACCESS ')'
|
|
|
|
|
|
|
|
type := BASETYPE | BASETYPE '|' subtype | enum | bits
|
2004-08-06 13:38:30 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
subtype := STRING
|
2003-11-10 08:53:38 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
enum := ENUM '(' value ')'
|
2003-11-10 08:53:38 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
bits := BITS '(' value ')'
|
2003-11-10 08:53:38 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
value := INT STRING | INT STRING value
|
2003-11-10 08:53:38 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
head := '(' INT STRING
|
2003-11-10 08:53:38 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
elements := EMPTY | elements element
|
2003-11-10 08:53:38 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
element := tree | leaf | column
|
2003-11-10 08:53:38 +00:00
|
|
|
|
2006-05-30 07:46:52 +00:00
|
|
|
index := type | index type
|
|
|
|
|
|
|
|
typedef := 'typedef' STRING type
|
|
|
|
|
|
|
|
include := 'include' filespec
|
|
|
|
|
|
|
|
filespec := '"' STRING '"' | '<' STRING '>'
|
2003-11-10 08:53:38 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
2006-05-30 07:46:52 +00:00
|
|
|
.Ar BASETYPE
|
2003-11-10 08:53:38 +00:00
|
|
|
specifies a SNMP data type and may be one of
|
|
|
|
.Bl -bullet -offset indent -compact
|
|
|
|
.It
|
|
|
|
NULL
|
|
|
|
.It
|
|
|
|
INTEGER
|
|
|
|
.It
|
|
|
|
INTEGER32 (same as INTEGER)
|
|
|
|
.It
|
|
|
|
UNSIGNED32 (same as GAUGE)
|
|
|
|
.It
|
|
|
|
OCTETSTRING
|
|
|
|
.It
|
|
|
|
IPADDRESS
|
|
|
|
.It
|
|
|
|
OID
|
|
|
|
.It
|
|
|
|
TIMETICKS
|
|
|
|
.It
|
|
|
|
COUNTER
|
|
|
|
.It
|
|
|
|
GAUGE
|
|
|
|
.It
|
|
|
|
COUNTER64
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Ar ACCESS
|
|
|
|
specifies the accessibility of the MIB variable (which operation can be
|
|
|
|
performed) and is one of
|
|
|
|
.Bl -bullet -offset indent -compact
|
|
|
|
.It
|
|
|
|
GET
|
|
|
|
.It
|
|
|
|
SET
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
.Ar INT
|
|
|
|
is a decimal integer and
|
|
|
|
.Ar STRING
|
|
|
|
is any string starting with a letter or underscore and consisting of
|
2006-05-30 07:46:52 +00:00
|
|
|
letters, digits, underscores and minuses, that is not one of the keywords.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Ar typedef
|
|
|
|
directive associates a type with a single name.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Ar include
|
|
|
|
directive is replaced by the contents of the named file.
|
2003-11-10 08:53:38 +00:00
|
|
|
.Sh EXAMPLES
|
|
|
|
The following MIB description describes the system group:
|
|
|
|
.Bd -literal -offset indent
|
2006-05-30 07:46:52 +00:00
|
|
|
include "tc.def"
|
|
|
|
|
|
|
|
typedef AdminStatus ENUM (
|
|
|
|
1 up
|
|
|
|
2 down
|
|
|
|
)
|
|
|
|
|
2003-11-10 08:53:38 +00:00
|
|
|
(1 internet
|
|
|
|
(2 mgmt
|
|
|
|
(1 mibII
|
|
|
|
(1 system
|
|
|
|
(1 sysDescr OCTETSTRING op_system_group GET)
|
|
|
|
(2 sysObjectId OID op_system_group GET)
|
|
|
|
(3 sysUpTime TIMETICKS op_system_group GET)
|
|
|
|
(4 sysContact OCTETSTRING op_system_group GET SET)
|
|
|
|
(5 sysName OCTETSTRING op_system_group GET SET)
|
|
|
|
(6 sysLocation OCTETSTRING op_system_group GET SET)
|
|
|
|
(7 sysServices INTEGER op_system_group GET)
|
|
|
|
(8 sysORLastChange TIMETICKS op_system_group GET)
|
|
|
|
(9 sysORTable
|
|
|
|
(1 sysOREntry : INTEGER op_or_table
|
|
|
|
(1 sysORIndex INTEGER)
|
|
|
|
(2 sysORID OID GET)
|
|
|
|
(3 sysORDescr OCTETSTRING GET)
|
|
|
|
(4 sysORUpTime TIMETICKS GET)
|
|
|
|
))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
2006-02-27 16:16:18 +00:00
|
|
|
.Xr bsnmpd 1
|
2003-11-10 08:53:38 +00:00
|
|
|
.Sh AUTHORS
|
2010-05-24 06:26:38 +00:00
|
|
|
.An Hartmut Brandt Aq harti@FreeBSD.org
|