Re: how to Access Table data

Francois Bouchard <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <CAAZiaZf-Cx8tO5HWWMDK-zfyA==qqjB61BAgy+BYaNWgmQ-Eqw@mail.gmail.com>
> 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:



In the init function, we create a table:

// Initialize the contents of the table here
for (i = 0; i < RMH_NOTIFIED_NMS_IP_MAX_ENTRIES ; ++i)
{

// Allocate memory
entry = SNMP_MALLOC_TYPEDEF(struct mpbcRMHNotifiedNMSipAddressTable_entry);

// Return if Failed
if (!entry) return ;

// Create Row
row = netsnmp_tdata_create_row();
if (!row) {SNMP_FREE(entry);return ;}

row->data = entry;

entry->mpbcRMHNotifiedNMSipAddress_Index = i;

entry->mpbcRMHNotifiedNMSipAddress_IP = RMH_NOTIFIED_NMS_IP_DFT_IP_ADDR;

memset(entry->mpbcRMHNotifiedNMSipAddress_Description, 0,
sizeof(entry->mpbcRMHNotifiedNMSipAddress_Description));

entry->mpbcRMHNotifiedNMSipAddress_Description_len = 0;

entry->mpbcRMHNotifiedNMSipAddress_Enabled = 1;

// index the row

netsnmp_tdata_row_add_index( row, ASN_INTEGER, &i, sizeof(i));

// add the row

if (table_data) netsnmp_tdata_add_row( table_data, row );
}


Now in another function, we want to retrieve the values from the table :


void dump(void)
{

  for (i = 0; i < RMH_NOTIFIED_NMS_IP_MAX_ENTRIES ; ++i)
  {

// entry = ….(i) ????

index = entry->mpbcRMHNotifiedNMSipAddress_Index ;
ip_add= entry->mpbcRMHNotifiedNMSipAddress_IP ;
len = entry->mpbcRMHNotifiedNMSipAddress_Description_len ;
enable= entry->mpbcRMHNotifiedNMSipAddress_Enabled ;
  }
}


thanks,

Francois

2012/3/14 Dave Shield <[email protected]>

> On 14 March 2012 22:14, Francois Bouchard <[email protected]>
> wrote:
> >  what is the way to access any time a table - or a row - data  through
> >  netsnmp_request_info       *request;
> >  or
> >  netsnmp_table_request_info *table_info or another structure, and not
> > necessarily inside the handler routine ?
>
> netsnmp_request_info  (and netsnmp_table_request_info) explicitly
> refer to a particular incoming request.  Hence they are only valid
> while processing that request - which effectively means within the
> request handling routine (i.e. the handler).
>
> Outside of this routine, it doesn't really make sense to refer to a
> request-related structure.
>
> 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.