Hi all,
Can someone please put some light on this:
I'm trying to generate template code using mib2c.mfd.conf on a mib
i'm developing (work in progress). I've been following tutorial 5
(ifTable generation code).
The problem I've found when trying to generate template code from the
mib is that mib2c get all my variables as scalars instead of a table
with some rows.
Specification of the mib is as follows:
IPTABLES2-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, enterprises, Integer32,
Counter32, Gauge32, TimeTicks FROM SNMPv2-SMI
InetAddressType, InetAddress FROM INET-ADDRESS-MIB
TEXTUAL-CONVENTION, DisplayString FROM SNMPv2-TC
MODULE-COMPLIANCE, OBJECT-GROUP FROM SNMPv2-CONF
InterfaceIndexOrZero FROM IF-MIB;
iptablesMib MODULE-IDENTITY
LAST-UPDATED "200703110000Z" -- 11 March 2007
ORGANIZATION "none"
CONTACT-INFO
"Sergi"
DESCRIPTION
"This MIB is for use in managing iptables on a UNIX based system"
::= { enterprises 2828 }
iptablesInfo OBJECT IDENTIFIER::={ iptablesMib 1 }
iptablesVersion OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"iptables current version installed"
::= { iptablesInfo 2 }
iptablesForwardDefaultValue OBJECT-TYPE
SYNTAX INTEGER {
disabled(0),
enabled(1) }
MAX-ACCESS read-write
STATUS current
DESCRIPTION
" Enables or disables forwarding of packets at kernel level"
::= {iptablesInfo 3}
iptables OBJECT IDENTIFIER ::={ iptablesMib 2 }
chainNumber OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The number of chains already present on the system"
::= { iptables 1 }
iptablesChains OBJECT-TYPE
SYNTAX SEQUENCE OF chainEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"filter table from kernel"
DEFVAL {8}
::= { iptables 2 }
chainEntry OBJECT-TYPE
SYNTAX ChainEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"An entry containing management information applicable
to an
iptables rule."
INDEX { chainIndex }
::= { iptablesChains 1 }
ChainEntry ::=
SEQUENCE {
chainIndex Integer32,
chainName OCTET STRING,
ruleToApply INTEGER {
INPUT(0),
OUTPUT(1),
FORWARD(2) }
Integer32,
ruleTarget OCTET STRING
}
chainIndex OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
" A unique value, starting at 1, to address any row from Filter
Table"
::={ chainEntry 1 }
chainName OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"The name of the table, usually nat, mangle or filter, but maybe
user defined"
::={ chainEntry 2}
ruleToApply OBJECT-TYPE
SYNTAX INTEGER {
INPUT(0),
OUTPUT(1),
FORWARD(2) }
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Chain that applies, INPUT,OUTPUT or FORWARD"
::={ chainEntry 3 }
ruleTarget OBJECT-TYPE
SYNTAX INTEGER{
ADD(0)
DROP(1)
NEW(2)
REJECT(3) }
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Targe to apply a rule from a chain in the Filter Table"
::={ chainEntry 4}
END
snmptranslate tree is as follows:
gentoo-box ~ # snmptranslate -m +IPTABLES2-MIB -Tp -IR iptablesMib
+--iptablesMib(2828)
|
+--iptablesInfo(1)
| |
| +-- -R-- String iptablesVersion(2)
| +-- -RW- EnumVal iptablesForwardDefaultValue(3)
| Values: disabled(0), enabled(1)
|
+--iptables(2)
|
+-- -R-- Integer32 chainNumber(1)
|
+--iptablesChains(2)
|
+--chainEntry(1)
| Index: chainIndex
|
+-- -R-- Gauge chainIndex(1)
+-- -RW- String chainName(2)
+-- -RW- EnumVal ruleToApply(3)
| Values: INPUT(0), OUTPUT(1), FORWARD(2)
+-- -RW- EnumVal ruleTarget(4)
Values: ADD(0), DROP(1), NEW(2), REJECT(3)
The output that mib2c shows when I try to generate code of
iptablesChains table is:
gentoo-box mfd_agent_info # env MIBS="+IPTABLES2-MIB" mib2c
iptablesChains
writing to -
mib2c has multiple configuration files depending on the type of
code you need to write. You must pick one depending on your need.
You requested mib2c to be run on the following part of the MIB tree:
OID: iptablesChains
numeric translation: .1.3.6.1.4.1.2828.2.2
number of scalars within: 4
number of tables within: 0
number of notifications within: 0
First, do you want to generate code that is compatible with the
ucd-snmp 4.X line of code, or code for the newer Net-SNMP 5.X code
base (which provides a much greater choice of APIs to pick from):
[...]
if I try generating code using mib2c.mfc.conf I get:
gentoo-box mfd_agent_info # env MIBS="+IPTABLES2-MIB" mib2c -c
mib2c.mfd.conf iptablesChains
This module can only be used with tables, not branches or entire MIBs.
Please specify and OID that is a table. (OID: iptablesChains)
/usr/share/snmp//mib2c.mfd.conf:25 contained a line that started with
a @ but did not match any mib2c configuration tokens.
(maybe missing the trailing @?)
/usr/share/snmp//mib2c.mfd.conf:25 [@ [EMAIL PROTECTED]
Starting MFD code generation...
writing to iptablesChains.h
writing to iptablesChains.c
writing to iptablesChains_data_get.h
writing to iptablesChains_data_get.c
writing to iptablesChains_data_set.h
writing to iptablesChains_data_set.c
writing to iptablesChains_interface.h
writing to iptablesChains_interface.c
writing to iptablesChains_data_access.h
writing to iptablesChains_data_access.c
writing to iptablesChains-README-FIRST.txt
running indent on iptablesChains_data_set.c
running indent on iptablesChains_data_set.h
running indent on iptablesChains.h
running indent on iptablesChains_data_access.c
running indent on iptablesChains_interface.h
running indent on iptablesChains_data_get.h
running indent on iptablesChains_interface.c
running indent on iptablesChains_data_access.h
running indent on iptablesChains.c
running indent on iptablesChains_data_get.c
My question is: Shouldn't be mib2c getting iptablesChains as a table?
If I do the same with ifTable as in the tutorial, it works fine:
gentoo-box mfd_agent_info # mib2c ifTable
writing to -
mib2c has multiple configuration files depending on the type of
code you need to write. You must pick one depending on your need.
You requested mib2c to be run on the following part of the MIB tree:
OID: ifTable
numeric translation: .1.3.6.1.2.1.2.2
number of scalars within: 0
number of tables within: 1
number of notifications within: 0
Mib2c detect that there is a table. I can't figure out what's
happening because I've been using the same structure that ifTable uses.
Anyway, I'm pretty sure that the error is on the specification of the
mib...but where?
Any help would be apreciated. Thanks in advance.
Sergi.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders