table_dataset(3)

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.
NETSNMP_INLINE 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 helper is obsolete. If you are writing a new module, please consider using the table_dataset2 helper instead.

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 80 of file table_dataset.c.

References netsnmp_create_table_data(), NULL, SNMP_MALLOC_TYPEDEF, and netsnmp_table_data_set_s::table.

Referenced by netsnmp_config_parse_table_set().

  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 816 of file table_dataset.c.

References netsnmp_request_get_list_data().

  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 826 of file table_dataset.c.

References netsnmp_extract_table_row_data(), and netsnmp_table_data_set_find_column().

  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 356 of file table_dataset.c.

References netsnmp_mib_handler_s::flags, MIB_HANDLER_AUTO_NEXT, netsnmp_mib_handler_s::myvoid, netsnmp_create_handler(), netsnmp_table_data_set_helper_handler(), NULL, and snmp_log().

Referenced by netsnmp_register_table_data_set().

  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 1187 of file table_dataset.c.

References netsnmp_table_data_set_storage_s::column, netsnmp_table_row_s::data, netsnmp_table_data_set_find_column(), netsnmp_table_data_set_storage_s::next, snmp_log(), SNMP_MALLOC_TYPEDEF, and netsnmp_table_data_set_storage_s::writable.

Referenced by netsnmp_config_parse_add_row(), and netsnmp_table_data_set_create_row_from_defaults().

  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 853 of file table_dataset.c.

References netsnmp_table_data_s::name, netsnmp_add_list_data(), netsnmp_create_data_list(), NULL, SNMP_MALLOC_TYPEDEF, netsnmp_table_data_set_s::table, and data_set_tables_s::table_set.

Referenced by netsnmp_config_parse_table_set().

  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 382 of file table_dataset.c.

References netsnmp_table_data_set_storage_s::column, netsnmp_table_data_set_s::default_row, netsnmp_table_registration_info_s::indexes, netsnmp_table_data_s::indexes_template, netsnmp_table_registration_info_s::max_column, netsnmp_table_registration_info_s::min_column, netsnmp_get_table_data_set_handler(), netsnmp_inject_handler(), netsnmp_register_table_data(), netsnmp_table_data_set_storage_s::next, NULL, snmp_clone_varbind(), SNMP_MALLOC_TYPEDEF, SNMP_MAX, SNMP_MIN, and netsnmp_table_data_set_s::table.

Referenced by netsnmp_config_parse_table_set().

  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 1222 of file table_dataset.c.

References netsnmp_table_data_set_storage_s::column, netsnmp_table_row_s::data, netsnmp_table_data_set_storage_s::data, netsnmp_table_data_set_storage_s::data_len, memdup(), netsnmp_table_data_set_find_column(), netsnmp_table_data_set_storage_s::next, SNMP_FREE, snmp_log(), SNMP_MALLOC_TYPEDEF, netsnmp_table_data_set_storage_s::string, netsnmp_table_data_set_storage_s::type, and netsnmp_table_data_set_storage_s::voidp.

Referenced by netsnmp_config_parse_add_row(), and netsnmp_table_data_set_create_row_from_defaults().

  netsnmp_table_row* netsnmp_table_data_set_clone_row (netsnmp_table_row * row)

clones a dataset row, including all data.

Definition at line 92 of file table_dataset.c.

References netsnmp_table_row_s::data, memdup(), netsnmp_table_data_clone_row(), netsnmp_table_dataset_delete_row(), netsnmp_table_data_set_storage_s::next, and NULL.

Referenced by netsnmp_table_data_set_helper_handler().

  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 226 of file table_dataset.c.

References netsnmp_table_data_set_storage_s::column, netsnmp_table_data_set_storage_s::data, netsnmp_table_data_set_storage_s::data_len, netsnmp_create_table_data_row(), netsnmp_mark_row_column_writable(), netsnmp_set_row_column(), netsnmp_table_data_set_storage_s::next, NULL, netsnmp_table_data_set_storage_s::type, netsnmp_table_data_set_storage_s::voidp, and netsnmp_table_data_set_storage_s::writable.

Referenced by netsnmp_table_data_set_create_newrowstash().

  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 1175 of file table_dataset.c.

References netsnmp_table_data_set_storage_s::column, and netsnmp_table_data_set_storage_s::next.

Referenced by netsnmp_extract_table_data_set_column(), netsnmp_mark_row_column_writable(), netsnmp_set_row_column(), netsnmp_table_data_set_helper_handler(), and netsnmp_table_set_add_default_row().

  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 1144 of file table_dataset.c.

References netsnmp_table_data_get_first_row(), and netsnmp_table_data_set_s::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

Definition at line 1151 of file table_dataset.c.

References netsnmp_table_data_get_next_row(), and netsnmp_table_data_set_s::table.

  NETSNMP_INLINE 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 1276 of file table_dataset.c.

References netsnmp_table_data_set_s::table.

Referenced by netsnmp_table_set_add_indexes().

  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 171 of file table_dataset.c.

References netsnmp_table_data_add_row(), and netsnmp_table_data_set_s::table.

Referenced by netsnmp_table_data_set_helper_handler().

  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 148 of file table_dataset.c.

References netsnmp_table_dataset_delete_data().

Referenced by netsnmp_table_dataset_delete_row(), and netsnmp_table_dataset_remove_and_delete_row().

  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 135 of file table_dataset.c.

References netsnmp_table_data_set_storage_s::data, netsnmp_table_data_set_storage_s::next, NULL, SNMP_FREE, and netsnmp_table_data_set_storage_s::voidp.

Referenced by netsnmp_table_dataset_delete_all_data().

  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 158 of file table_dataset.c.

References netsnmp_table_data_delete_row(), and netsnmp_table_dataset_delete_all_data().

Referenced by netsnmp_table_data_set_clone_row(), and netsnmp_table_data_set_helper_handler().

  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 203 of file table_dataset.c.

References netsnmp_table_data_remove_and_delete_row(), netsnmp_table_dataset_delete_all_data(), and netsnmp_table_data_set_s::table.

Referenced by netsnmp_table_data_set_helper_handler().

  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 192 of file table_dataset.c.

References netsnmp_table_data_remove_and_delete_row(), and netsnmp_table_data_set_s::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

Definition at line 181 of file table_dataset.c.

References netsnmp_table_data_replace_row(), and netsnmp_table_data_set_s::table.

Referenced by netsnmp_table_data_set_helper_handler().

  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 252 of file table_dataset.c.

References netsnmp_table_data_set_storage_s::column, netsnmp_table_data_set_storage_s::data, netsnmp_table_data_set_storage_s::data_len, netsnmp_table_data_set_s::default_row, memdup(), netsnmp_table_data_set_find_column(), netsnmp_table_data_set_storage_s::next, NULL, snmp_log(), SNMP_MALLOC_TYPEDEF, netsnmp_table_data_set_storage_s::type, netsnmp_table_data_set_storage_s::voidp, and netsnmp_table_data_set_storage_s::writable.

Referenced by netsnmp_config_parse_table_set(), and netsnmp_table_set_multi_add_default_row().

  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 1287 of file table_dataset.c.

References netsnmp_table_dataset_add_index().

  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 313 of file table_dataset.c.

References netsnmp_table_set_add_default_row().