现在的位置: 首页 > 综合 > 正文

mib2c用途和用法

2019年05月29日 ⁄ 综合 ⁄ 共 1923字 ⁄ 字号 评论关闭

1.用途

用于批量注册OID,产生批量的OID注册代码模板。

2.用法

三个文件:

- MIB definition file ---基于该mib文件产生输出文件
- C header file--生成的模板代码头文件
- C implementation file.---生成的模板代码源文件

命令:

mib2c -c mib2c.int_watch.conf nstMIBObjects

***mib2c***

***-c mib2c.int_watch.conf***

(1)指定配置文件

(2)配置文件的位置

  /usr/local/share/snmp/
  /usr/local/share/snmp/mib2c-data
  ./mib2c-conf.d

(3)配置文件的类型

If you're writing code for some scalars, run:

        mib2c -c mib2c.scalar.conf MIBNODE

If you want to magically "tie" integer variables to integerscalars, use:

        mib2c -c mib2c.int_watch.conf MIBNODE

GENERATING CODE FOR TABLES:

The recommended configuration file for tables is the MIBs forDummies, or MFD, configuration file. It hides as much of the SNMPdetails as possible, generating small, easy to understand functions.It is also the most flexible and well documented configuration
file.See the agent/mibgroup/if-mib/ifTable/ifTable*.c files for an example:

        mib2c -c mib2c.mfd.conf MIBNODE

If your table data is kept somewhere else (e.g. it's in thekernel and not in the memory of the agent itself) and you need to"iterate" over it to find the right data for the SNMP row beingaccessed. See the agent/mibgroup/mibII/vacm_context.c file for anexample:

        mib2c -c mib2c.iterate.conf MIBNODE

If your table data is kept in the agent (i.e. it's not located inan external source) and is purely data driven (i.e. you do not needto perform any work when a set occurs). See theagent/mibgroup/examples/data_set.c file for an example of such atable:

        mib2c -c mib2c.create-dataset.conf MIBNODE

If your table data is kept in the agent (i.e. it's not located inan external source), and you can keep your data sorted by the tableindex but you do need to perform work when a set occurs:

        mib2c -c mib2c.array-user.conf MIBNODE

GENERATING HEADER FILE DEFINITIONS

To generate just a header with a define for each column number inyour table:

        mib2c -c mib2c.column_defines.conf MIBNODE

To generate just a header with a define for each enum for anycolumn containing enums:

        mib2c -c mib2c.column_enums.conf MIBNODE

        GENERATING CODE FOR THE 4.X LINE OF CODE (THE OLDER API)

        mib2c -c mib2c.old-api.conf MIBNODE

***nstMIBObjects***

抱歉!评论已关闭.