Fwd: how to Access Table data

Francois Bouchard <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <CAAZiaZf1SbUtoy4krLn8=i5W-qETf4uA5-aX8LBJ6_=utKuDBA@mail.gmail.com>
sorry, forgot to add mailing list

---------- Forwarded message ----------
From: Francois Bouchard <[email protected]>
Date: 2012/3/15
Subject: Re: how to Access Table data
To: Dave Shield <[email protected]>


oups wrong button,


> the index
> Could you help us to find table_data structure, would you

> table_data  =     netsnmp_tdata_extract_table(request);
To get the table_data, would you use

table_data  =     netsnmp_tdata_extract_table(request); ?



see example below:



2012/3/15 Francois Bouchard <[email protected]>

> Hi
> thanks
>
> the index
> Could you help us to find table_data structure, would you
>
>
> table_data  =     netsnmp_tdata_extract_table(request);
>
>
> In the following code
> /** handles requests for the mpbcRMHNotifiedNMSipAddressTable table */
>
> int mpbcRMHNotifiedNMSipAddressTable_handler(
>     netsnmp_mib_handler               *handler,
>     netsnmp_handler_registration      *reginfo,
>     netsnmp_agent_request_info        *reqinfo,
>     netsnmp_request_info              *requests)
>
>
> {
>
>     netsnmp_request_info       *request;
>     netsnmp_table_request_info *table_info;
>     netsnmp_tdata              *table_data;
>     netsnmp_tdata_row          *table_row;
>     struct mpbcRMHNotifiedNMSipAddressTable_entry *table_entry;
>
>
>     int                         ret;
>
>     switch (reqinfo->mode)
>     {
>         /*
>          * Read-support (also covers GetNext requests)
>          */
>                 case MODE_GET: // When Get/ Get(walk)/ Get Table) from Browser
>
>
>
>                         // Read Config file
>                         read_config_file(); // <-----------------------
>
>                         // Process Request
>                         for (request=requests; request; request=request->next) {
>
>
>                                 // ... etc etc etc
>
>
>                         }// for (request=request...
>                         break;
>
>         // ... etc etc etc
>
> }
>
>
> in the following function, would you recommend to pass the resquest as parameter, then extract the table_data using
>
>
> table_data = netsnmp_tdata_extract_table(request) ?
>
> void read_config_file(void ... or netsnmp_request_info *request)
> {
>         int i;
>         netsnmp_tdata_row *row;
>
>         // extract table_data ...
>
>
>
>
>         // Enter values
>         for (        i = 0,  row = netsnmp_tdata_get_first(  table_data );
>                 i < RMH_NOTIFIED_NMS_IP_MAX_ENTRIES ;
>                 ++i, row = netsnmp_tdata_get_next( table_data, row ))
>
>
>         {
>
>                 if (!row) {
>                 snmp_log(LOG_ERR, "xxxx i=%d\n", i);
>                 break;
>
>             // RMH Notified NMS Address Table index
>
>
>             row->data->mpbcRMHNotifiedNMSipAddress_Index = i;
>             row->data->mpbcRMHNotifiedNMSipAddress_IP = Tabl[i].Ip;// My table
>             // ....
>         }
> }
>
>
> Thanks,
>
>
> Francois
>
> ps Cache is not used for that table
>
>
>
>
>
> 2012/3/15 Dave Shield <[email protected]>
>
>> On 15 March 2012 13:42, Francois Bouchard <[email protected]>
>> wrote:
>> >> netsnmp_request_info  (and netsnmp_table_request_info) explicitly
>> >> refer to a particular incoming request.
>> > Yes, not with the request-related structures, more from another function
>> > like in the exampel below:
>>
>>     [ snip ]
>>
>> OK - try using the API calls
>>
>>    row = netsnmp_tdata_get_first(  table_data );
>>    row = netsnmp_tdata_get_next( table_data, row );
>>
>> to walk through the table, or one of
>>
>>    row = netsnmp_tdata_get_byidx(  table_data, indexes );
>>    row = netsnmp_tdata_get_byoid(  table_data, oids, len );
>>
>> to retrieve a particular entry
>>
>>
>> See the section 'TData API: Row operations' in the header
>> file <net-snmp/agent/table_tdata.h> for the precise declarations.
>>
>> Dave
>>
>
>

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.