Cpp Lesson 1

Tutorial for Visual xAgentBuilder for C++

Lesson 1: MIB Handler

The central point in the management information agent is MIB handler.


MIB handler serves as the registration point for subtree handlers, controls access to management variables through the use of external Access Control subsystem, and finally enables agents to access MIB instrumentation.

MIB Handler maintains the list of subtree handlers. Subtree handler modules could (should) be generated using xAgentBuilder code generator. The code created by code generator is protocol independent, i.e. access to MIB variables is the same no matter which protocol agent dispatched request. This allows for simple extension of MP Agent with yet another protocol agent. The new protocol agent simply has to register with MIB Handler to receive IMIB interface and MIB data could be accessed by that protocol.

The code for the subtree handlers is OS (RTOS) independent. Only the standard ANSI C++ is used, allowing for painless porting of MP Agent to various platforms.

MIB handler functionality is built into the BMibHandler class (in NDMibH library) and BMibHandlerEx class (in NDMibHX library). The difference is that BMibHandlerEx class
allows requests by name along with the requests by oid (the later one being the only one provided by the BMibHandler class).  In this tutorial we’ll be using BMibHandlerEx.

Let’s take a look at the source code for this lesson:

int main(int argc, char*


   BTime tm;

   BMibHandlerEx mh;

   mh.Init(&tm, NULL);


   printf(“Enter ‘q’ for QUIT, ‘d’ to retrieve
sysDescr \n”);

   printf(“ndmp# “);

   int ch = ‘a’;

   while (true)


       ch = getchar();

       if (ch == ‘q’)


       else if (ch == ‘d’)


       else if (ch == ‘\n’)

          printf(“ndmp# “);


   return 0;


Each agent has to keep track of “up time”, i.e. time that elapsed since the agent started. Since we are building multi-protocol agent we need common “up time” handler. This functionality is implemented in BTime class, and it is the first one that we instantiate in each agent. As we’ll see in the following tutorials, address of the BTime object is required parameter for each type of agent.

In this example, we need time object to initialize BMibHandlerEx object.  BMibHandlerEx implements ‘system’ group defined in SNMPv2-MIB. One of the object is system group is “sysUpTime” that reports the time (in hundredths of a second) since the network management portion of the system was last re-initialized.

Finally, a few lines are printed, and user is prompted for input. In this simple menu only two commands are recognized.

When user enters ‘d’, the value of the “sysDescr” object is retrieved and printed on the screen.

To exit application, user should enter ‘q’.

Please build Tutorial1 project, start the agent and execute implemented commands.

Please proceed to Lesson2: CLI topic.