Greetings to all.

I have written my won sub-agent for my MIB. Below follows the relevant code
for the same:


void *VAR;
oid systemInfo_variables_oid[] = { *1,3,6,1,4,1,6305,1,10,1,2,1* };

struct variable4 systemInfo_variables[] = {
/*  magic number        , variable type , ro/rw , callback fn  , L,
oidsuffix */

#define INDEX           1
{INDEX,  ASN_UNSIGNED,  RONLY,   var_callTypeStatsNotfyAttrTable, 4,  { 2,2,
1, 1 }},
#define TOTALCALLHOLDTIME               2
{TOTALCALLHOLDTIME,  ASN_UNSIGNED,  RONLY,
var_callTypeStatsNotfyAttrTable, 4,  { 2,2, 1, 2 }},
};


void
init_systemInfo(void)
{

   DEBUGMSGTL(("systemInfo", "Initializing\n"));

   REGISTER_MIB("systemInfo", systemInfo_variables, variable4,
              systemInfo_variables_oid);

}

unsigned char *
var_callTypeStatsNotfyAttrTable(struct variable *vp,
           oid     *name,
           size_t  *length,
           int     exact,
           size_t  *var_len,
           WriteMethod **write_method)
{
       int i,in_id, value1;

  if (header_simple_table(vp,name,length,exact,var_len,write_method, 2)
                                               == MATCH_FAILED )
       return NULL;

       printf("\nOID received=");
   for(i=0;i<*length;i++)
       printf("%d.",name[i]);

   in_id = name[(*length)-1];
       printf("\nin_id fetched = %d", in_id);
       printf("\nvp->magic = %d",vp->magic);
   switch (vp->magic)
   {
   case INDEX:
               value1 = junk1[in_id-1].index;
               printf("\n%d",value1);
               VAR = (int *) &value1;
               return (u_char *) VAR;
   case TOTALCALLHOLDTIME:
               value1 = junk1[in_id-1].CallHoldTime;
               printf("\n%d", value1);
               VAR = (int *) &value1;
               return (u_char *) VAR;
   default:
               printf("\nDefault case");
               ERROR_MSG("");
   }
   return NULL;
}

When I do a snmpget on any OID pertaining to any object in my MIB, I observe
that OID passed by the master agent is always
1.3.6.1.4.1.6305.1.10.1.2.1.2.2.1.1.1.

The master agent always calls the var_callTypeStatsNotfyAttrTable() with OID
of the very first element in my table. I found out that in the code
generated by mib2c, the array of OID was defined using variable4 and while
calling REGISTER_MIB, datatype passed was variable7. I tried passing the
same datatype also at both the places, yet I am not getting the right values
using snmpgetnext.

Can someone provide me with any pointers to solve this.. Thanks.

Shivani
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to