I have a net-snmp-5.4.2.1, want to make mib-module with own OIDs. So, I made
MIB file, then used mib2c utility, and got 11 files:
>
> myMibTable.c
myMibTable.h
myMibTable_data_access.c
myMibTable_data_access.h
myMibTable_data_set.c
myMibTable_data_set.h
myMibTable_data_get.c
myMibTable_data_get.h
myMibTable_enums.h
myMibTable_interface.c
myMibTable_interface.h
myMibTable_oids.h
So, everything is right, i guess.
When i try to compile, there is error:
MY-MIB/myMibTable/myMibTable_interface.c: In function
'myMibTable_index_to_oid':
MY-MIB/myMibTable/myMibTable_interface.c:359: error: 'var_' undeclared
(first use in this function)
MY-MIB/myMibTable/myMibTable_interface.c:359: error: (Each undeclared
identifier is reported only once
MY-MIB/myMibTable/myMibTable_interface.c:359: error: for each function it
appears in.)
MY-MIB/myMibTable/myMibTable_interface.c: In function
'myMibTable_index_from_oid':
MY-MIB/myMibTable/myMibTable_interface.c:403: error: 'var_' undeclared
(first use in this function)
make[6]: *** [MY-MIB/myMibTable/myMibTable_interface.lo] Error 1
I found this function in file myMibTable_interface.c:
> /**
* @internal
* convert the index component stored in the context to an oid
*/
int
myMibTable_index_to_oid(netsnmp_index *oid_idx,
myMibTable_mib_index *mib_idx)
{
int err = SNMP_ERR_NOERROR;
/*
* temp storage for parsing indexes
*/
> /*
* set up varbinds
*/
> /*
* chain temp index varbinds together
*/
NULL;
>
> DEBUGMSGTL(("verbose:myMibTable:myMibTable_index_to_oid","called\n"));
>
> err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len,
NULL, 0, &var_);
if(err)
snmp_log(LOG_ERR,"error %d converting index to oid\n", err);
> /*
* parsing may have allocated memory. free it.
*/
snmp_reset_var_buffers( &var_ );
> return err;
} /* myMibTable_index_to_oid */
and it's really true. but I haven't to modify this file, because it's
generated automatically by mib2c.
In myMibTable.h I found strange record:
> typedef struct myMibTable_mib_index_s {
>
> } myMibTable_mib_index;
and that's all.
In the end, want to show MIB file:
> MY-MIB DEFINITIONS ::= BEGIN
> IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, enterprises, Integer32
FROM SNMPv2-SMI;
>
> myMibTable MODULE-IDENTITY
LAST-UPDATED "201112010000Z" -- 12 January 2011
ORGANIZATION
CONTACT-INFO
> DESCRIPTION
"This MIB is just joke"
::= { enterprises 7 }
> myMibInfo OBJECT IDENTIFIER::={ myMibTable 1 }
> InfoInteger OBJECT-TYPE
SYNTAX Integer32 (0..2147483647)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Interger decription of info information"
::= { myMibInfo 1 }
> InfoString OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(0..1024))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"A publicly settable string that can be set for testing
snmpsets. This value has no real usage other than
testing purposes."
::= { myMibInfo 2 }
> END
So, what is the problem in automatically generated file with uninitialized
variable?
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders