Hi,

As Dave says, you have to use the cache helper :
mib2c -c mib2c.table_data.conf  -S cache=1   myDataTable
The code produced don't compile, it's a little buggy. See my code below.
the cache->flags is set to call each time the load function.
http://www.net-snmp.org/dev/agent/group__cache__handler.html
The last problem is if the table is empty the load function is never call !

----------
in .h:
NetsnmpCacheLoad myDataTable_load;
//NetsnmpCacheFree myDataTable_free;

in.c :
initialize_table_mydataTable(void) {
....
    netsnmp_tdata_register(reg, table_data, table_info);

    cache = netsnmp_cache_create(-1, myDataTable_load, (NetsnmpCacheFree *)myDataTable_free,
        myDataTable_oid, myDataTable_oid_len);
  cache->magic =  (void *) table_data;
  cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET | NETSNMP_CACHE_DONT_FREE_BEFORE_LOAD | NETSNMP_CACHE_DONT_FREE_EXPIRED | NETSNMP_CACHE_DONT_AUTO_RELEASE;

  netsnmp_inject_handler_before(reg, netsnmp_cache_handler_get(cache),"mydataTable");
    // Init table
    mydataTable_load(cache, table_data);

}


int myDataTable_load(netsnmp_cache * cache, void *vmagic)
{
  netsnmp_tdata * table_data = (netsnmp_tdata *) vmagic;
  netsnmp_tdata_row *row;
  struct myDataTable_entry *row_entry; 
 
    row = NULL;
  row = netsnmp_tdata_row_next(table_data, row);
  row_entry = (struct myDataTable_entry *)row->data;
  row_entry->myDataVal1++;
    ....
}
-------

Stephane.

kumar undurthi a écrit :
Hi All,

      I have requirement in which i have to fill the table data when ever a request will come, For example check the below  example.... it was generated by using mib2c.table_data.conf.
          : in which "ocStbHostAVInterfaceTable_handler"  is taking care of the requests, So my requirement is
when the a request come  at " i.e   "(check in code )  case MODE_GET:"  then i want to update the table instated of initialize the  table first (filling the table)  at (check in code " initialize_table_ocStbHostAVInterfaceTable(void) " )

Please give the Solution as early as possible..... (adv Thank's)
...   

On Wed, Mar 12, 2008 at 6:39 AM, Dave Shield <[EMAIL PROTECTED]> wrote:
On 11/03/2008, kumar undurthi <[EMAIL PROTECTED]> wrote:
>        I have a problem in creating a table and Fill the table. i.e
> Normally table can create in initialization() part and can be fill with the
> static data.
> But in My case.... I want to Create and Fill the table with the dynamic
> data(values) when ever a request comes to the Agent.

Probably the best approach would be to use the cache helper.

You haven't said how you are generating the code,
or which table helper you are using.   But if you run
something like
   mib2c -c mib2c.table_data.conf  -S cache=1   myTable

this should generate a suitable framework for your MIB module,
including the code to load the table data when a request
comes in.   This cached data will then be used for the next
few requests, until it's judged "too old".  Whereupon the
next request will trigger a fresh reload.

 The same approach can be used with the iterator helper
(same command, but specifying 'mib2c.iterator.conf'),
and probably also with the MfD framework.
 (though I don't know much about that one).

Dave


------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users





-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to