1.\" 2.\" Copyright (c) 2001-2003 3.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4.\" All rights reserved. 5.\" 6.\" Redistribution of this software and documentation and use in source and 7.\" binary forms, with or without modification, are permitted provided that 8.\" the following conditions are met: 9.\" 10.\" 1. Redistributions of source code or documentation must retain the above 11.\" copyright notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the Institute nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY FRAUNHOFER FOKUS 20.\" AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 21.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22.\" FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23.\" FRAUNHOFER FOKUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 26.\" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27.\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30.\" 31.\" $Begemot: bsnmp/gensnmptree/gensnmptree.1,v 1.2 2003/12/03 09:56:57 hbb Exp $ 32.\" 33.\" Author: Harti Brandt <harti@freebsd.org> 34.\" 35.Dd October 7, 2003 36.Dt gensnmptree 1 37.Os 38.Sh NAME 39.Nm gensnmptree 40.Nd "generate C and header files from a MIB description file" 41.Sh SYNOPSIS 42.Nm 43.Op Fl hel 44.Op Fl p Ar prefix 45.Op Ar name Ar ... 46.Sh DESCRIPTION 47The 48.Nm 49utility is used to either generate C language tables and header files from 50a MIB description or to numeric OIDs from MIB descriptions. The first form 51is used only for maintaining the 52.Xr snmpd 1 53daemon or for module writers. 54The second form may be used by SNMP client program writers. 55.Pp 56If the 57.Fl e 58option is not used 59.Nm 60reads a MIB description from its standard input and creates two files: a 61C-file 62.Ar prefix Ns tree.c 63containing a table used by 64.Xr snmpd 1 65during PDU processing 66and a header file 67.Ar prefix Ns tree.h 68containing appropriate declarations of the callback functions used in this table 69and the table itself. 70.Pp 71If the 72.Fl e 73option is specified 74.Nm 75expects MIB variable names (only the last component) on its command line. 76It reads a MIB specification from standard input and for each MIB variable 77name emits two C preprocessor defines on its standard output. One define 78.Va OID_ Ns Ar name 79can be used as an array initialized to initialize a 80.Va struct asn_oid . 81The other define 82.Va OIDLEN_ Ns Ar name 83contains the length of the OID. 84.Pp 85The options are as follows: 86.Bl -tag -width ".Fl d Ar argument" 87.It Fl h 88Print a short help page. 89.It Fl e 90Enter extract mode. 91.It Fl l 92Generate local preprocessor includes. This is used for bootstrapping 93.Xr snmpd 1 . 94.It Fl p Ar prefix 95Prefix the file names and the table name with 96.Ar prefix . 97.El 98.Sh MIBS 99The syntax of the MIB description file can formally be specified as follows: 100.Bd -unfilled -offset indent 101tree := head elements ')' 102 103entry := head ':' index STRING elements ')' 104 105leaf := head TYPE STRING ACCESS ')' 106 107column := head TYPE ACCESS ')' 108 109head := '(' INT STRING 110 111elements := EMPTY | elements element 112 113element := tree | leaf 114 115index := TYPE | index TYPE 116.Ed 117.Pp 118.Ar TYPE 119specifies a SNMP data type and may be one of 120.Bl -bullet -offset indent -compact 121.It 122NULL 123.It 124INTEGER 125.It 126INTEGER32 (same as INTEGER) 127.It 128UNSIGNED32 (same as GAUGE) 129.It 130OCTETSTRING 131.It 132IPADDRESS 133.It 134OID 135.It 136TIMETICKS 137.It 138COUNTER 139.It 140GAUGE 141.It 142COUNTER64 143.El 144.Pp 145.Ar ACCESS 146specifies the accessibility of the MIB variable (which operation can be 147performed) and is one of 148.Bl -bullet -offset indent -compact 149.It 150GET 151.It 152SET 153.El 154.Pp 155.Ar INT 156is a decimal integer and 157.Ar STRING 158is any string starting with a letter or underscore and consisting of 159letters, digits and underscores, that is not one of the keywords. 160.Sh EXAMPLES 161The following MIB description describes the system group: 162.Bd -literal -offset indent 163(1 internet 164 (2 mgmt 165 (1 mibII 166 (1 system 167 (1 sysDescr OCTETSTRING op_system_group GET) 168 (2 sysObjectId OID op_system_group GET) 169 (3 sysUpTime TIMETICKS op_system_group GET) 170 (4 sysContact OCTETSTRING op_system_group GET SET) 171 (5 sysName OCTETSTRING op_system_group GET SET) 172 (6 sysLocation OCTETSTRING op_system_group GET SET) 173 (7 sysServices INTEGER op_system_group GET) 174 (8 sysORLastChange TIMETICKS op_system_group GET) 175 (9 sysORTable 176 (1 sysOREntry : INTEGER op_or_table 177 (1 sysORIndex INTEGER) 178 (2 sysORID OID GET) 179 (3 sysORDescr OCTETSTRING GET) 180 (4 sysORUpTime TIMETICKS GET) 181 )) 182 ) 183 ) 184 ) 185) 186.Ed 187.Sh SEE ALSO 188.Xr snmpd 1 189.Sh AUTHORS 190.An Hartmut Brandt Aq harti@freebsd.org 191