GENSNMPTREE(1)
π NAME π
okay bestie, welcome to the gensnmptree(1) page from the General Commands Manual β yes, that one. This is gensnmptree β generate C and header files from a MIB description file. π
β¨ SYNOPSIS β¨
gensnmptree [-dEeFfhlt] [-I directory] [-i infile] [-p prefix]
[name ...]
π¦ DESCRIPTION π¦
okay so gensnmptree is used either to generate C language tables and header files from a MIB description, or for numeric OIDs from MIB descriptions. The first form is used only for maintaining the bsnmpd(1) daemon or for module writers. The second form may be used by SNMP client program writers. iykyk π
π¨ important vibe check: if none of the options-e,-Eor-tare used,gensnmptreereads a MIB description from its standard input and creates two files: a C-fileprefixtree.ccontaining a table used bybsnmpd(1)during PDU processing, and a header fileprefixtree.hcontaining appropriate declarations of the callback functions used in this table, the table itself and definitions for all enums. not me forgetting the two files π
The following options are available:
-dβ switch on debugging. literally debug mode, bestie.-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. enum girlies rise β¨-eβgensnmptreeexpects MIB variable names (only the last component) on its command line. It reads a MIB specification from standard input and for each MIB variable name emits three C preprocessor defines on its standard output:OIDX_nameβ this define can be used to initialize astruct asn_oidin the following way:
const struct asn_oid oid_sysDescr =
OIDX_sysDescr;
OIDLEN_nameβ is the length of the OID.OID_nameβ is the last component of the OID.
-Fβ emit definitions for C-functions includeable in a C-file that do some basic stuff on enums like value checking and conversion between value and strings. functional, fr fr π«Ά-fβ emit definitions for inline C-functions that do some basic stuff on enums like value checking and conversion between value and strings. inline icon behavior β-hβ print a short help page. when in doubt, ask for help π-Idirectory β add the named directory to the include path just before the standard include directories. path magic πͺ-iinfile β read from the named file instead of standard input. file era π-lβ generate local preprocessor includes. This is used for bootstrappingbsnmpd(1). bootstrap bestie π§-tβ instead of normal output print the resulting tree. tree reveal π³-pprefix β prefix the file names and the table name with prefix. name it and claim it π
πΈ MIBS πΈ
The syntax of the MIB description file can formally be specified as follows:
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
subtype := STRING
enum := ENUM '(' value ')'
bits := BITS '(' value ')'
value := INT STRING | INT STRING value
head := '(' INT STRING
elements := EMPTY | elements element
element := tree | leaf | column
index := type | index type
typedef := 'typedef' STRING type
include := 'include' filespec
filespec := '"' STRING '"' | '<' STRING '>'
BASETYPE specifies a SNMP data type and may be one of:
NULLINTEGERINTEGER32(same asINTEGER)UNSIGNED32(same asGAUGE)OCTETSTRINGIPADDRESSOIDTIMETICKSCOUNTERGAUGECOUNTER64
ACCESS specifies the accessibility of the MIB variable (which operation can be performed) and is one of:
GETSET
INT is a decimal integer and STRING is any string starting with a letter or underscore and consisting of letters, digits, underscores and minuses, that is not one of the keywords.
The typedef directive associates a type with a single name.
The include directive is replaced by the contents of the named file. copy-paste but make it official π¦
π EXAMPLES π
The following MIB description describes the system group:
include "tc.def"
typedef AdminStatus ENUM (
1 up
2 down
)
(1 internet
(2 mgmt
(1 mib-2
(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)
))
)
)
)
)
π₯ SEE ALSO π₯
bsnmpd(1) β that's the one, bestie. go read it, iykYK π
π AUTHORS π
Hartmut Brandt <harti@FreeBSD.org> β iconic contributor behavior. periodt π
mwah π β this page comes from Debian, dated April 2, 2019. that's the whole footer, bestie π«Ά
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2001-2005 Fraunhofer Institute for Open Communication Systems (FhG Fokus)
- Copyright (c) 2006,2018 Hartmut Brandt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms