DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Developing SMUX peers for SNMP agents

Writing get functions

You have written your MIB module, made the #define statements, declared global variables and initialized the values of the MIB objects and the MIB database used by the peer. The next step is to write ``get'' functions for single and multiple instances. This requires additional changes to foomib.c.

When a GetRequest or GetNextRequest PDU is being processed, control is passed through the get function, and it is in the get function that objects are read.

For every single instance leaf object in your MIB module, add a ``case'' to this switch statement. Use the appropriate function (o_string(), o_integer(), and so on) according to the object's syntax.

    switch (ifvar) {
    case PRODUCTNAME:
		return o_string(oi, v, productName, strlen(productName));
		
    case BOARDSTATUS:
        return o_integer(oi, v, boardStatus);

case EXAMPLEIPADDR: { struct sockaddr_in tmp_IpAddr; tmp_IpAddr.sin_addr = exampleIpAddr;

return o_ipaddr(oi, v, (char *) & tmp_IpAddr); }

case EXAMPLEOBJECTID: return o_specific(oi, v, exampleObjectID);

case NUMBERLINES: return o_integer(oi, v, numberLines);

default: return error__status_noSuchName; }

To get multiple instances, get_serialLineTable() is executed to process GetRequest and GetNextRequest PDUs for a VarBind of an Object in the serialLineTable. For each table in your MIB make one of the following functions of name get_tableName():
    static int
    get_serialLineTable(oi, v, offset)
     OI              oi;
   	 register struct type_SNMP_VarBind *v;
   	 int             offset;
	{
When a GetRequest or GetNextRequest PDU is being processed, control is passed through this get function, and it is here that the multiple instance objects are read.

For every object in the table that this function services, add a ``case'' to this ``switch'' statement. Use the appropriate function (o_string(), o_integer(), and so on) according to the object's syntax.

switch (ifvar) {
    case SERIALLINENUMBER:
        return o_integer(oi, v, ifnum);

case SERIALLINEBAUDRATE: return o_integer(oi, v, serialLineTable[ifnum].serialLineBaudRate);

case SERIALLINETERMLOCATION: return o_string(oi, v, serialLineTable[ifnum].serialLineTermLocation, strlen(serialLineTable[ifnum].serialLineTermLocation));

default: return error__status_noSuchName; }


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005