---
name: "netsnmp_table_dataset"
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_dataset"
---

# netsnmp\_table\_dataset(3snmp)

Helps you implement a table with automatted storage.

## NAME

table\_dataset -

Helps you implement a table with automatted storage.

### Functions

void **netsnmp\_init\_table\_dataset** (void)\
 **netsnmp\_table\_data\_set** \* **netsnmp\_create\_table\_data\_set** (const char \*table\_name)\
 *Create a netsnmp\_table\_data\_set structure given a table\_data definition.*  **netsnmp\_table\_row** \* **netsnmp\_table\_data\_set\_clone\_row** (**netsnmp\_table\_row** \*row)\
 *clones a dataset row, including all data.*  NETSNMP\_INLINE **netsnmp\_table\_data\_set\_storage** \* **netsnmp\_table\_dataset\_delete\_data** (**netsnmp\_table\_data\_set\_storage** \*data)\
 *deletes a single dataset table data.*  NETSNMP\_INLINE void **netsnmp\_table\_dataset\_delete\_all\_data** (**netsnmp\_table\_data\_set\_storage** \*data)\
 *deletes all the data from this* **node** *and beyond in the linked list*  NETSNMP\_INLINE void **netsnmp\_table\_dataset\_delete\_row** (**netsnmp\_table\_row** \*row)\
 *deletes all the data from this* **node** *and beyond in the linked list*  NETSNMP\_INLINE void **netsnmp\_table\_dataset\_add\_row** (**netsnmp\_table\_data\_set** \*table, **netsnmp\_table\_row** \*row)\
 *adds a new row to a dataset table*  NETSNMP\_INLINE void **netsnmp\_table\_dataset\_replace\_row** (**netsnmp\_table\_data\_set** \*table, **netsnmp\_table\_row** \*origrow, **netsnmp\_table\_row** \*newrow)\
 *adds a new row to a dataset table*  NETSNMP\_INLINE void **netsnmp\_table\_dataset\_remove\_row** (**netsnmp\_table\_data\_set** \*table, **netsnmp\_table\_row** \*row)\
 *removes a row from the table, but doesn't delete/free the column values*  NETSNMP\_INLINE void **netsnmp\_table\_dataset\_remove\_and\_delete\_row** (**netsnmp\_table\_data\_set** \*table, **netsnmp\_table\_row** \*row)\
 *removes a row from the table and then deletes it (and all its data)*  **netsnmp\_table\_row** \* **netsnmp\_table\_data\_set\_create\_row\_from\_defaults** (**netsnmp\_table\_data\_set\_storage** \*defrow)\
 *creates a new row from an existing defined default set*  int **netsnmp\_table\_set\_add\_default\_row** (**netsnmp\_table\_data\_set** \*table\_set, unsigned int column, int type, int writable, void \*default\_value, size\_t default\_value\_len)\
 *adds a new default row to a table\_set.*  void **netsnmp\_table\_set\_multi\_add\_default\_row** (**netsnmp\_table\_data\_set** \*tset,...)\
 *adds multiple data column definitions to each row.*  **netsnmp\_mib\_handler** \* **netsnmp\_get\_table\_data\_set\_handler** (**netsnmp\_table\_data\_set** \*data\_set)\
 *Given a netsnmp\_table\_data\_set definition, create a handler for it.*  int **netsnmp\_register\_table\_data\_set** (**netsnmp\_handler\_registration** \*reginfo, **netsnmp\_table\_data\_set** \*data\_set, **netsnmp\_table\_registration\_info** \*table\_info)\
 *register a given data\_set at a given oid (specified in the netsnmp\_handler\_registration pointer).*  **newrow\_stash** \* **netsnmp\_table\_data\_set\_create\_newrowstash** (**netsnmp\_table\_data\_set** \*datatable, **netsnmp\_table\_request\_info** \*table\_info)\
 int **netsnmp\_table\_data\_set\_helper\_handler** (**netsnmp\_mib\_handler** \*handler, **netsnmp\_handler\_registration** \*reginfo, **netsnmp\_agent\_request\_info** \*reqinfo, **netsnmp\_request\_info** \*requests)\
 NETSNMP\_INLINE **netsnmp\_table\_data\_set** \* **netsnmp\_extract\_table\_data\_set** (**netsnmp\_request\_info** \*request)\
 *extracts a netsnmp\_table\_data\_set pointer from a given request*  **netsnmp\_table\_data\_set\_storage** \* **netsnmp\_extract\_table\_data\_set\_column** (**netsnmp\_request\_info** \*request, unsigned int column)\
 *extracts a netsnmp\_table\_data\_set pointer from a given request*  void **netsnmp\_register\_auto\_data\_table** (**netsnmp\_table\_data\_set** \*table\_set, char \*registration\_name)\
 *registers a table\_dataset so that the 'add\_row' snmpd.conf token can be used to add data to this table.*  void **netsnmp\_config\_parse\_table\_set** (const char \*token, char \*line)\
 void **netsnmp\_config\_parse\_add\_row** (const char \*token, char \*line)\
 **netsnmp\_table\_row** \* **netsnmp\_table\_data\_set\_get\_first\_row** (**netsnmp\_table\_data\_set** \*table)\
 *returns the first row in the table*  **netsnmp\_table\_row** \* **netsnmp\_table\_data\_set\_get\_next\_row** (**netsnmp\_table\_data\_set** \*table, **netsnmp\_table\_row** \*row)\
 *returns the next row in the table*  int **netsnmp\_table\_set\_num\_rows** (**netsnmp\_table\_data\_set** \*table)\
 **netsnmp\_table\_data\_set\_storage** \* **netsnmp\_table\_data\_set\_find\_column** (**netsnmp\_table\_data\_set\_storage** \*start, unsigned int column)\
 *Finds a column within a given storage set, given the pointer to the start of the storage set list.*  int **netsnmp\_mark\_row\_column\_writable** (**netsnmp\_table\_row** \*row, int column, int writable)\
 *marks a given column in a row as writable or not.*  int **netsnmp\_set\_row\_column** (**netsnmp\_table\_row** \*row, unsigned int column, int type, const char \*value, size\_t value\_len)\
 *sets a given column in a row with data given a type, value, and length.*  void **netsnmp\_table\_dataset\_add\_index** (**netsnmp\_table\_data\_set** \*table, u\_char type)\
 *adds an index to the table.*  void **netsnmp\_table\_set\_add\_indexes** (**netsnmp\_table\_data\_set** \*tset,...)\
 *adds multiple indexes to a table\_dataset helper object.*

## Detailed Description

Helps you implement a table with automatted storage.

This handler helps you implement a table where all the data is expected to be stored within the agent itself and not in some external storage location. It handles all MIB requests including GETs, GETNEXTs and SETs. It's possible to simply create a table without actually ever defining a handler to be called when SNMP requests come in. To use the data, you can either attach a sub-handler that merely uses/manipulates the data further when requests come in, or you can loop through it externally when it's actually needed. This handler is most useful in cases where a table is holding configuration data for something which gets triggered via another event.

NOTE NOTE NOTE: This helper isn't complete and is likely to change somewhat over time. Specifically, the way it stores data internally may change drastically.

## Function Documentation

### netsnmp\_table\_data\_set\* netsnmp\_create\_table\_data\_set (const char \* table\_name)

Create a netsnmp\_table\_data\_set structure given a table\_data definition.

**Examples:**  **data\_set.c**.

Definition at line 77 of file table\_dataset.c.

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

extracts a netsnmp\_table\_data\_set pointer from a given request

Definition at line 813 of file table\_dataset.c.

### netsnmp\_table\_data\_set\_storage\* netsnmp\_extract\_table\_data\_set\_column (netsnmp\_request\_info \* request, unsigned int column)

extracts a netsnmp\_table\_data\_set pointer from a given request

Definition at line 823 of file table\_dataset.c.

### netsnmp\_mib\_handler\* netsnmp\_get\_table\_data\_set\_handler (netsnmp\_table\_data\_set \* data\_set)

Given a netsnmp\_table\_data\_set definition, create a handler for it.

Definition at line 353 of file table\_dataset.c.

### int netsnmp\_mark\_row\_column\_writable (netsnmp\_table\_row \* row, int column, int writable)

marks a given column in a row as writable or not.

**Examples:**  **data\_set.c**.

Definition at line 1189 of file table\_dataset.c.

### void netsnmp\_register\_auto\_data\_table (netsnmp\_table\_data\_set \* table\_set, char \* registration\_name)

registers a table\_dataset so that the 'add\_row' snmpd.conf token can be used to add data to this table. If registration\_name is NULL then the name used when the table was created will be used instead.

**Todo**

create a properly free'ing registeration pointer for the datalist, and get the datalist freed at shutdown.

**Examples:**  **data\_set.c**.

Definition at line 850 of file table\_dataset.c.

### int netsnmp\_register\_table\_data\_set (netsnmp\_handler\_registration \* reginfo, netsnmp\_table\_data\_set \* data\_set, netsnmp\_table\_registration\_info \* table\_info)

register a given data\_set at a given oid (specified in the netsnmp\_handler\_registration pointer). The reginfo-\>handler-\>access\_method \*may\* be null if the call doesn't ever want to be called for SNMP operations.

**Examples:**  **data\_set.c**.

Definition at line 379 of file table\_dataset.c.

### int netsnmp\_set\_row\_column (netsnmp\_table\_row \* row, unsigned int column, int type, const char \* value, size\_t value\_len)

sets a given column in a row with data given a type, value, and length. Data is memdup'ed by the function.

**Examples:**  **data\_set.c**.

Definition at line 1224 of file table\_dataset.c.

### netsnmp\_table\_row\* netsnmp\_table\_data\_set\_clone\_row (netsnmp\_table\_row \* row)

clones a dataset row, including all data.

Definition at line 89 of file table\_dataset.c.

### netsnmp\_table\_row\* netsnmp\_table\_data\_set\_create\_row\_from\_defaults (netsnmp\_table\_data\_set\_storage \* defrow)

creates a new row from an existing defined default set

Definition at line 223 of file table\_dataset.c.

### netsnmp\_table\_data\_set\_storage\* netsnmp\_table\_data\_set\_find\_column (netsnmp\_table\_data\_set\_storage \* start, unsigned int column)

Finds a column within a given storage set, given the pointer to the start of the storage set list.

Definition at line 1177 of file table\_dataset.c.

### netsnmp\_table\_row\* netsnmp\_table\_data\_set\_get\_first\_row (netsnmp\_table\_data\_set \* table)

returns the first row in the table

Definition at line 1146 of file table\_dataset.c.

### netsnmp\_table\_row\* netsnmp\_table\_data\_set\_get\_next\_row (netsnmp\_table\_data\_set \* table, netsnmp\_table\_row \* row)

returns the next row in the table

Definition at line 1153 of file table\_dataset.c.

### void netsnmp\_table\_dataset\_add\_index (netsnmp\_table\_data\_set \* table, u\_char type)

adds an index to the table. Call this repeatly for each index.

**Examples:**  **data\_set.c**.

Definition at line 1278 of file table\_dataset.c.

### NETSNMP\_INLINE void netsnmp\_table\_dataset\_add\_row (netsnmp\_table\_data\_set \* table, netsnmp\_table\_row \* row)

adds a new row to a dataset table

**Examples:**  **data\_set.c**.

Definition at line 168 of file table\_dataset.c.

### NETSNMP\_INLINE void netsnmp\_table\_dataset\_delete\_all\_data (netsnmp\_table\_data\_set\_storage \* data)

deletes all the data from this **node** and beyond in the linked list

Definition at line 145 of file table\_dataset.c.

### NETSNMP\_INLINE netsnmp\_table\_data\_set\_storage\* netsnmp\_table\_dataset\_delete\_data (netsnmp\_table\_data\_set\_storage \* data)

deletes a single dataset table data. returns the (possibly still good) next pointer of the deleted data object.

Definition at line 132 of file table\_dataset.c.

### NETSNMP\_INLINE void netsnmp\_table\_dataset\_delete\_row (netsnmp\_table\_row \* row)

deletes all the data from this **node** and beyond in the linked list

Definition at line 155 of file table\_dataset.c.

### NETSNMP\_INLINE void netsnmp\_table\_dataset\_remove\_and\_delete\_row (netsnmp\_table\_data\_set \* table, netsnmp\_table\_row \* row)

removes a row from the table and then deletes it (and all its data)

Definition at line 200 of file table\_dataset.c.

### NETSNMP\_INLINE void netsnmp\_table\_dataset\_remove\_row (netsnmp\_table\_data\_set \* table, netsnmp\_table\_row \* row)

removes a row from the table, but doesn't delete/free the column values

Definition at line 189 of file table\_dataset.c.

### NETSNMP\_INLINE void netsnmp\_table\_dataset\_replace\_row (netsnmp\_table\_data\_set \* table, netsnmp\_table\_row \* origrow, netsnmp\_table\_row \* newrow)

adds a new row to a dataset table

Definition at line 178 of file table\_dataset.c.

### int netsnmp\_table\_set\_add\_default\_row (netsnmp\_table\_data\_set \* table\_set, unsigned int column, int type, int writable, void \* default\_value, size\_t default\_value\_len)

adds a new default row to a table\_set. Arguments should be the table\_set, column number, **variable** type and finally a 1 if it is allowed to be writable, or a 0 if not. If the default\_value field is not NULL, it will be used to populate new valuse in that column fro newly created rows. It is copied into the storage template (free your calling argument).

returns SNMPERR\_SUCCESS or SNMPERR\_FAILURE

Definition at line 249 of file table\_dataset.c.

### void netsnmp\_table\_set\_add\_indexes (netsnmp\_table\_data\_set \* tset, ...)

adds multiple indexes to a table\_dataset helper object. To end the list, use a 0 after the list of ASN index types.

Definition at line 1289 of file table\_dataset.c.

### void netsnmp\_table\_set\_multi\_add\_default\_row (netsnmp\_table\_data\_set \* tset, ...)

adds multiple data column definitions to each row. Functionally, this is a wrapper around calling netsnmp\_table\_set\_add\_default\_row repeatedly for you.

**Examples:**  **data\_set.c**.

Definition at line 310 of file table\_dataset.c.

## Author

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