I've been working on my own SNMP agent using the example found here : http://www.net-snmp.org/dev/agent/example_8c_source.html
I am wanting to better organize my tree structure to make more sense which in turn makes using client commands easier.
I am using the traditional old C API to achieve this and is what is used in the example link.
I have a tree I want to implement
My MIB :
MIB-NAME-HERE DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY, OBJECT-TYPE, Integer32, enterprises,
NOTIFICATION-TYPE FROM SNMPv2-SMI
OBJECT-GROUP, NOTIFICATION-GROUP FROM SNMPv2-CONF
;
myProduct MODULE-IDENTITY
LAST-UPDATED "201505200000Z"
ORGANIZATION "www.example.com"
CONTACT-INFO
"email: support@example.com"
DESCRIPTION
"MIB Example."
REVISION "201505200000Z"
DESCRIPTION
"version 1.0"
::= { enterprises 54321 }
--
-- top level structure
--
IPConfig OBJECT IDENTIFIER ::= { myProduct 1 }
Services OBJECT IDENTIFIER ::= { myProduct 3 }
IPConfigValuesGroup OBJECT-GROUP
OBJECTS { ObjectA,
ObjectB,
ObjectC
}
STATUS current
DESCRIPTION
"Group of all blahblah variables."
::= { myProduct 4 } <----**How would this affect a client request?**
--
-- Values
--
ObjectA OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(1..4096))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Test Example"
::= { IPConfig 1 }
ObjectB OBJECT-TYPE
SYNTAX OCTET STRING (SIZE(1..4096))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Test Example"
::= { IPConfig 2 }
--MORE STUFF...
.... END
I want to be able to group relative objects together so the user could do an
snmpset -v 2c -c communityNameHere -m MIB-NAME-HERE.txt 10.20.30.40 1.3.6.1.4.1.54321.x.1.3 s "I am a string"
to access ObjectC under the IPConfig group.
Question : How do I implement subtrees into my 'subagent'?
This is an excerpt from the link shown above.
/*
* This array defines the OID of the top of the mib tree that we're
* registering underneath.
* Note that this needs to be the correct size for the OID being
* registered, so that the length of the OID can be calculated.
* The format given here is the simplest way to achieve this.
*/
oid example_variables_oid[] = { 1, 3, 6, 1, 4, 1, 54321, x};
Do I have to declare another array to include, per say, the Services OID?
oid example_variables_oid[] = { 1, 3, 6, 1, 4, 1, 54321, x, 3};
Or for each subtree do they need to have an example.c*-type* file?
Question : Would this MIB achieve what I want? What would need to be done different? I've read up on OBJECT-GROUPS, SEQUENCE, O'Reily's book as well as the RFCs. I'm still trying to grasp everything.