---
name: "netsnmp_table"
section: "3snmp"
platform: "linux"
package: "libsnmp-dev"
version: "5.4.3~dfsg-2.8+deb7u1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/netsnmp_table"
---

# netsnmp\_table(3snmp)

Helps you implement a table.

## NAME

table -

Helps you implement a table.

### Modules

**table\_array**\

*Helps you implement a table when data can be stored locally.*  **table\_container**\

*Helps you implement a table when data can be found via a netsnmp\_container.*  **table\_data**\

*Helps you implement a table with datamatted storage.*  **generic\_table\_API**\

*General requirements for a table helper.*  **table\_iterator**\

*The table iterator helper is designed to simplify the task of writing a table handler for the net-snmp agent when the data being accessed is not in an oid sorted form and must be accessed externally.*  **table\_row**\

*Helps you implement a table shared across two or more subagents, or otherwise split into individual row slices.*  **tdata**\

*Implement a table with datamatted storage.*

### Defines

\#define **SPARSE\_TABLE\_HANDLER\_NAME**   'sparse\_table'\

### Functions

**netsnmp\_mib\_handler** \* **netsnmp\_get\_table\_handler** (**netsnmp\_table\_registration\_info** \*tabreq)\
 *Given a netsnmp\_table\_registration\_info object, creates a table handler.*  int **netsnmp\_register\_table** (**netsnmp\_handler\_registration** \*reginfo, **netsnmp\_table\_registration\_info** \*tabreq)\
 *creates a table handler given the netsnmp\_table\_registration\_info object, inserts it into the request chain and then calls* **netsnmp\_register\_handler()** *to register the table into the agent.*  NETSNMP\_INLINE **netsnmp\_table\_request\_info** \* **netsnmp\_extract\_table\_info** (**netsnmp\_request\_info** \*request)\
 *Extracts the processed table information from a given request.*  **netsnmp\_table\_registration\_info** \* **netsnmp\_find\_table\_registration\_info** (**netsnmp\_handler\_registration** \*reginfo)\
 *extracts the registered netsnmp\_table\_registration\_info object from a netsnmp\_handler\_registration object*  int **table\_helper\_handler** (**netsnmp\_mib\_handler** \*handler, **netsnmp\_handler\_registration** \*reginfo, **netsnmp\_agent\_request\_info** \*reqinfo, **netsnmp\_request\_info** \*requests)\
 *implements the table helper handler*  **netsnmp\_mib\_handler** \* **netsnmp\_sparse\_table\_handler\_get** (void)\
 *create sparse table handler*  int **netsnmp\_sparse\_table\_register** (**netsnmp\_handler\_registration** \*reginfo, **netsnmp\_table\_registration\_info** \*tabreq)\
 *creates a table handler given the netsnmp\_table\_registration\_info object, inserts it into the request chain and then calls* **netsnmp\_register\_handler()** *to register the table into the agent.*  int **netsnmp\_table\_build\_result** (**netsnmp\_handler\_registration** \*reginfo, **netsnmp\_request\_info** \*reqinfo, **netsnmp\_table\_request\_info** \*table\_info, u\_char type, u\_char \*result, size\_t result\_len)\
 *Builds the result to be returned to the agent given the table information.*  int **netsnmp\_table\_build\_oid** (**netsnmp\_handler\_registration** \*reginfo, **netsnmp\_request\_info** \*reqinfo, **netsnmp\_table\_request\_info** \*table\_info)\
 *given a registration info object, a request object and the table info object it builds the request-\>requestvb-\>name oid from the index values and column information found in the table\_info object.*  int **netsnmp\_table\_build\_oid\_from\_index** (**netsnmp\_handler\_registration** \*reginfo, **netsnmp\_request\_info** \*reqinfo, **netsnmp\_table\_request\_info** \*table\_info)\
 *given a registration info object, a request object and the table info object it builds the request-\>requestvb-\>name oid from the index values and column information found in the table\_info object.*  int **netsnmp\_update\_variable\_list\_from\_index** (**netsnmp\_table\_request\_info** \*tri)\
 *parses an OID into table indexses*  int **netsnmp\_update\_indexes\_from\_variable\_list** (**netsnmp\_table\_request\_info** \*tri)\
 *builds an oid given a set of indexes.*  int **netsnmp\_check\_getnext\_reply** (**netsnmp\_request\_info** \*request, oid \*prefix, size\_t prefix\_len, **netsnmp\_variable\_list** \*newvar, **netsnmp\_variable\_list** \*\*outvar)\
 *checks the original request against the current data being passed in if its greater than the request oid but less than the current valid return, set the current valid return to the new value.*

## Detailed Description

Helps you implement a table.

This handler helps you implement a table by doing some of the processing for you.

This handler truly shows the power of the new handler mechanism. By creating a table handler and injecting it into your calling chain, or by using the **netsnmp\_register\_table()** function to register your table, you get access to some pre-parsed information. Specifically, the table handler pulls out the column number and indexes from the request oid so that you don't have to do the complex work to do that parsing within your own code.

To do this, the table handler needs to know up front how your table is structured. To inform it about this, you fill in a table\_registeration\_info structure that is passed to the table handler. It contains the asn index types for the table as well as the minimum and maximum column that should be used.

## Function Documentation

### int netsnmp\_check\_getnext\_reply (netsnmp\_request\_info \* request, oid \* prefix, size\_t prefix\_len, netsnmp\_variable\_list \* newvar, netsnmp\_variable\_list \*\* outvar)

checks the original request against the current data being passed in if its greater than the request oid but less than the current valid return, set the current valid return to the new value. returns 1 if outvar was replaced with the oid from newvar (success). returns 0 if not.

Definition at line 881 of file table.c.

### NETSNMP\_INLINE netsnmp\_table\_request\_info\* netsnmp\_extract\_table\_info (netsnmp\_request\_info \* request)

Extracts the processed table information from a given request. Call this from subhandlers on a request to extract the processed netsnmp\_request\_info information. The resulting information includes the index values and the column number.

**Parameters:**

*request* populated netsnmp request structure

**Returns:**

populated netsnmp\_table\_request\_info structure

Definition at line 125 of file table.c.

### netsnmp\_table\_registration\_info\* netsnmp\_find\_table\_registration\_info (netsnmp\_handler\_registration \* reginfo)

extracts the registered netsnmp\_table\_registration\_info object from a netsnmp\_handler\_registration object

Definition at line 134 of file table.c.

### netsnmp\_mib\_handler\* netsnmp\_get\_table\_handler (netsnmp\_table\_registration\_info \* tabreq)

Given a netsnmp\_table\_registration\_info object, creates a table handler. You can use this table handler by injecting it into a calling chain. When the handler gets called, it'll do processing and store it's information into the request-\>parent\_data structure.

The table helper handler pulls out the column number and indexes from the request oid so that you don't have to do the complex work of parsing within your own code.

**Parameters:**

*tabreq* is a pointer to a netsnmp\_table\_registration\_info struct. The table handler needs to know up front how your table is structured. A netsnmp\_table\_registeration\_info structure that is passed to the table handler should contain the asn index types for the table as well as the minimum and maximum column that should be used.

**Returns:**

Returns a pointer to a netsnmp\_mib\_handler struct which contains the handler's name and the access method

Definition at line 85 of file table.c.

### int netsnmp\_register\_table (netsnmp\_handler\_registration \* reginfo, netsnmp\_table\_registration\_info \* tabreq)

creates a table handler given the netsnmp\_table\_registration\_info object, inserts it into the request chain and then calls **netsnmp\_register\_handler()** to register the table into the agent.

Definition at line 108 of file table.c.

### netsnmp\_mib\_handler\* netsnmp\_sparse\_table\_handler\_get (void)

create sparse table handler

Definition at line 722 of file table.c.

### int netsnmp\_sparse\_table\_register (netsnmp\_handler\_registration \* reginfo, netsnmp\_table\_registration\_info \* tabreq)

creates a table handler given the netsnmp\_table\_registration\_info object, inserts it into the request chain and then calls **netsnmp\_register\_handler()** to register the table into the agent.

Definition at line 733 of file table.c.

### int netsnmp\_table\_build\_oid (netsnmp\_handler\_registration \* reginfo, netsnmp\_request\_info \* reqinfo, netsnmp\_table\_request\_info \* table\_info)

given a registration info object, a request object and the table info object it builds the request-\>requestvb-\>name oid from the index values and column information found in the table\_info object. Index values are extracted from the table\_info varbinds.

Entry

column

Definition at line 784 of file table.c.

### int netsnmp\_table\_build\_oid\_from\_index (netsnmp\_handler\_registration \* reginfo, netsnmp\_request\_info \* reqinfo, netsnmp\_table\_request\_info \* table\_info)

given a registration info object, a request object and the table info object it builds the request-\>requestvb-\>name oid from the index values and column information found in the table\_info object. Index values are extracted from the table\_info index oid.

Definition at line 821 of file table.c.

### int netsnmp\_table\_build\_result (netsnmp\_handler\_registration \* reginfo, netsnmp\_request\_info \* reqinfo, netsnmp\_table\_request\_info \* table\_info, u\_char type, u\_char \* result, size\_t result\_len)

Builds the result to be returned to the agent given the table information. Use this function to return results from lowel level handlers to the agent. It takes care of building the proper resulting oid (containing proper indexing) and inserts the result value into the returning varbind.

Definition at line 751 of file table.c.

### int netsnmp\_update\_indexes\_from\_variable\_list (netsnmp\_table\_request\_info \* tri)

builds an oid given a set of indexes.

Definition at line 863 of file table.c.

### int netsnmp\_update\_variable\_list\_from\_index (netsnmp\_table\_request\_info \* tri)

parses an OID into table indexses

Definition at line 847 of file table.c.

### int table\_helper\_handler (netsnmp\_mib\_handler \* handler, netsnmp\_handler\_registration \* reginfo, netsnmp\_agent\_request\_info \* reqinfo, netsnmp\_request\_info \* requests)

implements the table helper handler

XXX-rks: memory leak. add cleanup handler?

none available

got one ok

for loop

Definition at line 142 of file table.c.

## Author

Generated automatically by Doxygen for net-snmp from the source code.
