RE: tablesnmpwalk on table not working via subagent - need help please

"Joan Landry" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <A9FCB77F97940A418A61FD9BB71E4170A1C680@dexbe012-6.exch012.intermedia.net>
I am using net-snmp-5-4-1.
I looked at the generic helper code. In the file 
net-snmp-5.4.1/agent/helpers/table_generic.c

All the functions are empty. I attached the file. So I am not sure how
this helper will work.

My goal is very simple.
I want to code a subagent to register for a mib table and be able to
handle the get, getnext, set for the rows and columns in the table
because the data is in the subagent not the master agent. I was able to
use the following for the get and the set but not for the getnext.
Meaning I can do a get on all the rows and the columns in the table,
which would possibly indicate that I created the table ok and added the
rows correctly. For some reason though the getnext does not work
correctly:
netsnmp_create_table_data_set
netsnmp_table_set_add_indexes
netsnmp_table_set_multi_add_default_row
netsnmp_create_table_data_row
netsnmp_table_row_add_index
netsnmp_set_row_column
netsnmp_table_dataset_add_row

One of the errors I get is that instead of getting the next row of the
current column - I get the next column. Also, a walk never exits the
loop of getnext. 

So I am now using:
REGISTER_MIB(...)
To handle get,get next, and set. This works ok.
Is this the recommended approach instead of using the helpers?

Thanks,
Joan

Thanks,
Joan 
 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Dave Shield
Sent: Wednesday, April 23, 2008 5:33 PM
To: Joan Landry; Mike Ayers
Cc: [email protected]
Subject: Re: tablesnmpwalk on table not working via subagent - need help
please

2008/4/23 Mike Ayers <[email protected]>:
>  > I have found no information about table_dataset2 helper. Does  > 
> this exist?

No.

>         I suspect that it is this:
>
>  http://www.net-snmp.org/dev/agent/group__tdata.html

Not quite.
The 'table_tdata' helper is a reworked version of the 'table_data'
helper.

Both of these represent the table as a collection of individual row data
structures.   The helper takes care of selecting the appropriate row
from
within this collection.   The user-provided handler should then select
the requested column value from within this data structure.

The 'table_dataset' helper takes this a stage further.
As well as taking care of the table as a collection of rows, it also
handles each row as a collection of column values.
The standard helper can therefore process an SNMP request without
needing *any* user-provided handler code.

The original intention of the table_dataset2' helper was to apply the
same 'table_data' -> 'table_tdata' reworking to the dataset framework.
But this never actually happened.


>  > Can anyone clarify for me which code in net-snmp works for  > the 
> purpose of implementing a table.

All of the table helpers have been used for implementing assorted tables
with the Net-SNMP agent, so they should all work successfully.
I still hope to look properly at the problems you have been having.


>   The table_dataset/group_tdata functions are for "datamatted" [sic] 
> tables those for which you store the data and forget.

That's true for 'table_dataset', but not for 'table_tdata'.


>  I don't see any functions to build the rows, either.

The code for building a row in a 'tdata'-based table is specific to the
individual MIB table, so isn't part of the tdata helper itself.
Instead it will be generated as part of the mib2c.tdata.conf template.


>  I suggest taking a look here:
>
>  http://www.net-snmp.org/dev/agent/group__table__generic.html
>
>         ...for what appears to be a more generic and complete set of
functions.


That's not actually a user-level table helper.
It's more intended as a design framework of the API that a particular
table helper should look at providing.

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
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
table_generic.c (application/octet-stream, 8.8 KB)
/*
 * table_generic.c
 *
 *    Generic table API framework
 */

/** @defgroup table_generic generic_table_API
 *  General requirements for a table helper.
 *  @ingroup table
 *
 * A given table helper need not implement the whole of this API,
 *   and may need to adjust the prototype of certain routines.
 * But this description provides a suitable standard design framework.
 *   
 * @{
 */

/* =======================================================
 * 
 *  Table Maintenance:
 *      create/delete table
 *      create/copy/clone/delete row
 *      add/replace/remove row
 *
 * ======================================================= */

/** @defgroup table_maintenance table_maintenance
 *
 * Routines for maintaining the contents of a table.
 * This would typically be part of implementing an SNMP MIB,
 *   but could potentially also be used for a standalone table.
 *
 * This section of the generic API is primarily relevant to
 *   table helpers where the representation of the table is 
 *   constructed and maintained within the helper itself.
 * "External" tables will typically look after such aspects
 *   directly, although this section of the abstract API 
 *   framework could also help direct the design of such
 *   table-specific implementations.
 *
 * @{
 */

/** Create a structure to represent the table.
  *
  * This could be as simple as the head of a linked
  *   list, or a more complex container structure.
  * The 'name' field would typically be used to
  *  distinguish between several tables implemented
  *  using the same table helper.  The 'flags' field
  *  would be used to control various (helper-specific)
  *  aspects of table behaviour.
  *
  * The table structure returned should typically be
  *  regarded as an opaque, private structure. All
  *  operations on the content of the table should
  *  ideally use the appropriate routines from this API.
  */
void *
netsnmp_generic_create_table( const char *name, int flags ) {
}

/** Release the structure representing a table.
  * Any rows still contained within the table
  *   should also be removed and deleted.
  */
void
netsnmp_generic_delete_table( void *table ) {
}

/** Create a new row structure suitable for this style of table.
  * Note that this would typically be a 'standalone' row, and
  *   would not automatically be inserted into an actual table.
  */
void *
netsnmp_generic_create_row( void ) {
}

/** Create a new copy of the specified row.
  */
void *
netsnmp_generic_clone_row( void *row ) {
}

/** Copy the contents of one row into another.
  * The destination row structure should be
  *   created before this routine is called.
  */
int
netsnmp_generic_copy_row( void *dst_row, void *src_row ) {
}

/** Delete a row data structure.
  * The row should be removed from any relevant
  *   table(s) before this routine is called.
  */
void
netsnmp_generic_delete_row( void *row ) {
}

/** Add a row to the table.
  */
int
netsnmp_generic_add_row( void *table, void *row ) {
}

/** Replace one row with another in the table.
  * This will typically (but not necessarily) involve
  *   two rows sharing the same index information (e.g.
  *   to implement update/restore-style SET behaviour).
  */
int
netsnmp_generic_replace_row( void *table, void *old_row, void *new_row ) {
}

/** Remove a row from the table.
  * The data structure for the row should not be released,
  *   and would be the return value of this routine.
  */
void *
netsnmp_generic_remove_row( void *table, void *row ) {
}

/** Remove and delete a row from the table.
  */
void
netsnmp_generic_remove_delete_row( void *table, void *row ) {
}

/** @} end of table_maintenance */

/* =======================================================
 * 
 *  MIB Maintenance:
 *      create a handler registration
 *      register/unregister table
 *      extract table from request
 *      extract/insert row
 *
 * ======================================================= */

/** @defgroup mib_maintenance mib_maintenance
 *
 * Routines for maintaining a MIB table.
 *
 * @{
 */

/** Create a MIB handler structure.
  * This will typically be invoked within the corresponding
  *   'netsnmp_generic_register' routine (or the registration
  *   code of a sub-helper based on this helper).
  *
  * Alternatively, it might be called from the initialisation
  *   code of a particular MIB table implementation.
  */
netsnmp_mib_handler *
netsnmp_generic_get_handler(void /* table specific */ ) {

}

/** Free a MIB handler structure, releasing any related resources.
  * Possibly called automatically by 'netsnmp_unregister_handler' ?
  */
netsnmp_generic_free_handler( netsnmp_mib_handler *handler ) {

}

/** Register a MIB table with the SNMP agent.
  */
int
netsnmp_generic_register(netsnmp_handler_registration    *reginfo,
                         void                            *table,
                         netsnmp_table_registration_info *table_info) {
}

/** Unregister a MIB table from the SNMP agent.
  * This should also release the internal representation of the table.
  * ?? Is a table-specific version of this needed, or would
  *    'netsnmp_unregister_handler' + 'netsnmp_generic_free_handler' do?
  */
int
netsnmp_generic_unregister(netsnmp_handler_registration    *reginfo) {
}

/** Extract the table relating to a requested varbind.
  */
void
netsnmp_generic_extract_table( netsnmp_request_info *request ) {
}

/** Extract the row relating to a requested varbind.
  */
void
netsnmp_generic_extract_row( netsnmp_request_info *request ) {
}

/** Associate a (new) row with the requested varbind.
  * The row should also be associated with any other
  *   varbinds that refer to the same index values.
  */
void
netsnmp_generic_insert_row( netsnmp_request_info *request, void *row ) {
}

/** @} end of mib_maintenance */

/* =======================================================
 * 
 *  Row Operations
 *      get first/this/next row
 *      get row/next row by index
 *      get row/next row by OID
 *      number of rows
 *
 * ======================================================= */

/** @defgroup table_rows table_rows
 *
 * Routines for working with the rows of a table.
 *
 * @{
 */

/** Retrieve the first row of the table.
  */
void *
netsnmp_generic_row_first( void *table ) {
}

/** Retrieve the given row from the table.
  * This could either be the same data pointer,
  *   passed in, or a separate row structure
  *   sharing the same index values (or NULL).
  *
  * This routine also provides a means to tell
  *   whether a given row is present in the table.
  */
void *
netsnmp_generic_row_get( void *table, void *row ) {
}

/** Retrieve the following row from the table.
  * If the specified row is not present, this
  *   routine should return the entry next after
  *   the position this row would have occupied.
  */
void *
netsnmp_generic_row_next( void *table, void *row ) {
}

/** Retrieve the row with the specified index values.
  */
void *
netsnmp_generic_row_get_byidx(  void *table,
                                netsnmp_variable_list *indexes ) {
}

/** Retrieve the next row after the specified index values.
  */
void *
netsnmp_generic_row_next_byidx( void *table,
                                netsnmp_variable_list *indexes ) {

}

/** Retrieve the row with the specified instance OIDs.
  */
void *
netsnmp_generic_row_get_byoid(  void *table, oid *instance, size_t len ) {
}

/** Retrieve the next row after the specified instance OIDs.
  */
void *
netsnmp_generic_row_next_byoid( void *table, oid *instance, size_t len ) {
}

/** Report the number of rows in the table.
  */
int
netsnmp_generic_row_count( void *table ) {
}

/** @} end of table_rows */

/* =======================================================
 * 
 *  Index Operations
 *      get table index structure
 *      get row index values/OIDs
 *      compare row with index/OIDs
 *      subtree comparisons (index/OIDs)
 *
 * ======================================================= */

/** @defgroup table_indexes table_indexes
 *
 * Routines for working with row indexes.
 *
 * @{
 */

/** Retrieve the indexing structure of the table.
  */
netsnmp_variable_list *
netsnmp_generic_idx( void *table ) {
}

/** Report the index values for a row.
  */
netsnmp_variable_list *
netsnmp_generic_row_idx( void *row ) {
}

/** Report the instance OIDs for a row.
  */
size_t
netsnmp_generic_row_oid( void *row, oid *instances ) {
}

/** Compare a row against the specified index values.
  */
int
netsnmp_generic_compare_idx( void *row, netsnmp_variable_list *index ) {
}

/** Compare a row against the specified instance OIDs.
  */
int
netsnmp_generic_compare_oid( void *row, oid *instances, size_t len ) {
}

/** Check if a row lies within a subtree of index values.
  */
int
netsnmp_generic_compare_subtree_idx( void *row, netsnmp_variable_list *index ) {
}

/** Check if a row lies within a subtree of instance OIDs.
  */
int
netsnmp_generic_compare_subtree_oid( void *row, oid *instances, size_t len ) {
}

/** @} end of table_indexes */
/** @} end of table_generic */
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.