netsnmp_table_dataset.3
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:20k
源码类别:
SNMP编程
开发平台:
Unix_Linux
- .TH "table_dataset: Helps you implement a table with automatted storage." 3 "28 Nov 2005" "Version 5.2.1.rc3" "net-snmp" " -*- nroff -*-
- .ad l
- .nh
- .SH NAME
- table_dataset: 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.
- .PP
- .SS "Functions"
- .in +1c
- .ti -1c
- .RI "void fBnetsnmp_init_table_datasetfP (void)"
- .br
- .ti -1c
- .RI "fBnetsnmp_table_data_setfP * fBnetsnmp_create_table_data_setfP (const char *table_name)"
- .br
- .RI "fICreate a netsnmp_table_data_set structure given a table_data definition. fP"
- .ti -1c
- .RI "fBnetsnmp_mib_handlerfP * fBnetsnmp_get_table_data_set_handlerfP (fBnetsnmp_table_data_setfP *data_set)"
- .br
- .RI "fIGiven a netsnmp_table_data_set definition, create a handler for it. fP"
- .ti -1c
- .RI "int fBnetsnmp_register_table_data_setfP (fBnetsnmp_handler_registrationfP *reginfo, fBnetsnmp_table_data_setfP *data_set, fBnetsnmp_table_registration_infofP *table_info)"
- .br
- .RI "fIregister a given data_set at a given oid (specified in the netsnmp_handler_registration pointer). fP"
- .ti -1c
- .RI "fBnetsnmp_table_data_set_storagefP * fBnetsnmp_table_data_set_find_columnfP (fBnetsnmp_table_data_set_storagefP *start, unsigned int column)"
- .br
- .RI "fIFinds a column within a given storage set, given the pointer to the start of the storage set list. fP"
- .ti -1c
- .RI "fBnetsnmp_table_data_set_storagefP * fBnetsnmp_extract_table_data_set_columnfP (fBnetsnmp_request_infofP *request, unsigned int column)"
- .br
- .RI "fIextracts a netsnmp_table_data_set pointer from a given request fP"
- .ti -1c
- .RI "NETSNMP_INLINE fBnetsnmp_table_data_setfP * fBnetsnmp_extract_table_data_setfP (fBnetsnmp_request_infofP *request)"
- .br
- .RI "fIextracts a netsnmp_table_data_set pointer from a given request fP"
- .ti -1c
- .RI "int fBnetsnmp_mark_row_column_writablefP (fBnetsnmp_table_rowfP *row, int column, int writable)"
- .br
- .RI "fImarks a given column in a row as writable or not. fP"
- .ti -1c
- .RI "int fBnetsnmp_set_row_columnfP (fBnetsnmp_table_rowfP *row, unsigned int column, int type, const char *value, size_t value_len)"
- .br
- .RI "fIsets a given column in a row with data given a type, value, and length. fP"
- .ti -1c
- .RI "int fBnetsnmp_table_set_add_default_rowfP (fBnetsnmp_table_data_setfP *table_set, unsigned int column, int type, int writable, void *default_value, size_t default_value_len)"
- .br
- .RI "fIadds a new default row to a table_set. fP"
- .ti -1c
- .RI "fBnetsnmp_table_rowfP * fBnetsnmp_table_data_set_clone_rowfP (fBnetsnmp_table_rowfP *row)"
- .br
- .RI "fIclones a dataset row, including all data. fP"
- .ti -1c
- .RI "fBnetsnmp_table_rowfP * fBnetsnmp_table_data_set_create_row_from_defaultsfP (fBnetsnmp_table_data_set_storagefP *defrow)"
- .br
- .RI "fIcreates a new row from an existing defined default set fP"
- .ti -1c
- .RI "fBnewrow_stashfP * fBnetsnmp_table_data_set_create_newrowstashfP (fBnetsnmp_table_data_setfP *datatable, fBnetsnmp_table_request_infofP *table_info)"
- .br
- .ti -1c
- .RI "int fBnetsnmp_table_data_set_helper_handlerfP (fBnetsnmp_mib_handlerfP *handler, fBnetsnmp_handler_registrationfP *reginfo, fBnetsnmp_agent_request_infofP *reqinfo, fBnetsnmp_request_infofP *requests)"
- .br
- .RI "fIimplements the table data helper. fP"
- .ti -1c
- .RI "void fBnetsnmp_register_auto_data_tablefP (fBnetsnmp_table_data_setfP *table_set, char *registration_name)"
- .br
- .RI "fIregisters a table_dataset so that the 'add_row' snmpd.conf token can be used to add data to this table. fP"
- .ti -1c
- .RI "void fBnetsnmp_config_parse_table_setfP (const char *token, char *line)"
- .br
- .ti -1c
- .RI "void fBnetsnmp_config_parse_add_rowfP (const char *token, char *line)"
- .br
- .ti -1c
- .RI "NETSNMP_INLINE void fBnetsnmp_table_dataset_add_indexfP (fBnetsnmp_table_data_setfP *table, u_char type)"
- .br
- .RI "fIadds an index to the table. fP"
- .ti -1c
- .RI "NETSNMP_INLINE void fBnetsnmp_table_dataset_add_rowfP (fBnetsnmp_table_data_setfP *table, fBnetsnmp_table_rowfP *row)"
- .br
- .RI "fIadds a new row to a dataset table fP"
- .ti -1c
- .RI "NETSNMP_INLINE void fBnetsnmp_table_dataset_replace_rowfP (fBnetsnmp_table_data_setfP *table, fBnetsnmp_table_rowfP *origrow, fBnetsnmp_table_rowfP *newrow)"
- .br
- .RI "fIadds a new row to a dataset table fP"
- .ti -1c
- .RI "NETSNMP_INLINE fBnetsnmp_table_data_set_storagefP * fBnetsnmp_table_dataset_delete_datafP (fBnetsnmp_table_data_set_storagefP *data)"
- .br
- .RI "fIdeletes a single dataset table data. fP"
- .ti -1c
- .RI "NETSNMP_INLINE void fBnetsnmp_table_dataset_delete_all_datafP (fBnetsnmp_table_data_set_storagefP *data)"
- .br
- .RI "fIdeletes all the data from this node and beyond in the linked list fP"
- .ti -1c
- .RI "NETSNMP_INLINE void fBnetsnmp_table_dataset_delete_rowfP (fBnetsnmp_table_rowfP *row)"
- .br
- .RI "fIdeletes all the data from this node and beyond in the linked list fP"
- .ti -1c
- .RI "NETSNMP_INLINE void fBnetsnmp_table_dataset_remove_rowfP (fBnetsnmp_table_data_setfP *table, fBnetsnmp_table_rowfP *row)"
- .br
- .RI "fIremoves a row from the table, but doesn't delete/free anything fP"
- .ti -1c
- .RI "NETSNMP_INLINE void fBnetsnmp_table_dataset_remove_and_delete_rowfP (fBnetsnmp_table_data_setfP *table, fBnetsnmp_table_rowfP *row)"
- .br
- .RI "fIremoves a row from the table and then deletes it (and all it's data) fP"
- .ti -1c
- .RI "void fBnetsnmp_table_set_multi_add_default_rowfP (va_dcl)"
- .br
- .RI "fIadds multiple data column definitions to each row. fP"
- .ti -1c
- .RI "void fBnetsnmp_table_set_add_indexesfP (va_alist)"
- .br
- .RI "fIadds multiple indexes to a table_dataset helper object. fP"
- .ti -1c
- .RI "int fBnetsnmp_table_set_num_rowsfP (fBnetsnmp_table_data_setfP *table)"
- .br
- .in -1c
- .SS "Variables"
- .in +1c
- .ti -1c
- .RI "size_t fBdata_set_cache_s::data_lenfP"
- .br
- .ti -1c
- .RI "int fBnewrow_stash_s::statefP"
- .br
- .ti -1c
- .RI "int fBnewrow_stash_s::createdfP"
- .br
- .ti -1c
- .RI "int fBnewrow_stash_s::deletedfP"
- .br
- .in -1c
- .SH "Detailed Description"
- .PP
- 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.
- .PP
- 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.
- .PP
- 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.
- .SH "Function Documentation"
- .PP
- .SS "fBnetsnmp_table_data_setfP* netsnmp_create_table_data_set (const char * table_name)"
- .PP
- Create a netsnmp_table_data_set structure given a table_data definition.
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 74 of file table_dataset.c.
- .PP
- References netsnmp_create_table_data(), NULL, SNMP_MALLOC_TYPEDEF, and netsnmp_table_data_set_s::table.
- .PP
- Referenced by netsnmp_config_parse_table_set().
- .SS "NETSNMP_INLINE fBnetsnmp_table_data_setfP* netsnmp_extract_table_data_set (fBnetsnmp_request_infofP * request)"
- .PP
- extracts a netsnmp_table_data_set pointer from a given request
- .PP
- Definition at line 187 of file table_dataset.c.
- .PP
- References netsnmp_request_get_list_data().
- .SS "fBnetsnmp_table_data_set_storagefP* netsnmp_extract_table_data_set_column (fBnetsnmp_request_infofP * request, unsigned int column)"
- .PP
- extracts a netsnmp_table_data_set pointer from a given request
- .PP
- Definition at line 173 of file table_dataset.c.
- .PP
- References netsnmp_extract_table_row_data(), and netsnmp_table_data_set_find_column().
- .SS "fBnetsnmp_mib_handlerfP* netsnmp_get_table_data_set_handler (fBnetsnmp_table_data_setfP * data_set)"
- .PP
- Given a netsnmp_table_data_set definition, create a handler for it.
- .PP
- Definition at line 86 of file table_dataset.c.
- .PP
- 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().
- .PP
- Referenced by netsnmp_register_table_data_set().
- .SS "int netsnmp_mark_row_column_writable (fBnetsnmp_table_rowfP * row, int column, int writable)"
- .PP
- marks a given column in a row as writable or not.
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 197 of file table_dataset.c.
- .PP
- 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.
- .PP
- Referenced by netsnmp_config_parse_add_row(), and netsnmp_table_data_set_create_row_from_defaults().
- .SS "void netsnmp_register_auto_data_table (fBnetsnmp_table_data_setfP * table_set, char * registration_name)"
- .PP
- registers a table_dataset so that the 'add_row' snmpd.conf token can be used to add data to this table.
- .PP
- If registration_name is NULL then the name used when the table was created will be used instead.
- .PP
- fBTodofP
- .RS 4
- create a properly free'ing registeration pointer for the datalist, and get the datalist freed at shutdown.
- .RE
- .PP
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 783 of file table_dataset.c.
- .PP
- 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.
- .PP
- Referenced by netsnmp_config_parse_table_set().
- .SS "int netsnmp_register_table_data_set (fBnetsnmp_handler_registrationfP * reginfo, fBnetsnmp_table_data_setfP * data_set, fBnetsnmp_table_registration_infofP * table_info)"
- .PP
- register a given data_set at a given oid (specified in the netsnmp_handler_registration pointer).
- .PP
- The reginfo->handler->access_method *may* be null if the call doesn't ever want to be called for SNMP operations.
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 113 of file table_dataset.c.
- .PP
- 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.
- .PP
- Referenced by netsnmp_config_parse_table_set().
- .SS "int netsnmp_set_row_column (fBnetsnmp_table_rowfP * row, unsigned int column, int type, const char * value, size_t value_len)"
- .PP
- sets a given column in a row with data given a type, value, and length.
- .PP
- Data is memdup'ed by the function.
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 233 of file table_dataset.c.
- .PP
- 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, and netsnmp_table_data_set_storage_s::type.
- .PP
- Referenced by netsnmp_config_parse_add_row(), and netsnmp_table_data_set_create_row_from_defaults().
- .SS "fBnetsnmp_table_rowfP* netsnmp_table_data_set_clone_row (fBnetsnmp_table_rowfP * row)"
- .PP
- clones a dataset row, including all data.
- .PP
- Definition at line 347 of file table_dataset.c.
- .PP
- 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.
- .PP
- Referenced by netsnmp_table_data_set_helper_handler().
- .SS "fBnetsnmp_table_rowfP* netsnmp_table_data_set_create_row_from_defaults (fBnetsnmp_table_data_set_storagefP * defrow)"
- .PP
- creates a new row from an existing defined default set
- .PP
- Definition at line 389 of file table_dataset.c.
- .PP
- References netsnmp_table_row_s::data, netsnmp_create_table_data_row(), netsnmp_mark_row_column_writable(), netsnmp_set_row_column(), and NULL.
- .PP
- Referenced by netsnmp_table_data_set_create_newrowstash().
- .SS "fBnetsnmp_table_data_set_storagefP* netsnmp_table_data_set_find_column (fBnetsnmp_table_data_set_storagefP * start, unsigned int column)"
- .PP
- Finds a column within a given storage set, given the pointer to the start of the storage set list.
- .PP
- Definition at line 161 of file table_dataset.c.
- .PP
- References netsnmp_table_data_set_storage_s::column, and netsnmp_table_data_set_storage_s::next.
- .PP
- 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().
- .SS "int netsnmp_table_data_set_helper_handler (fBnetsnmp_mib_handlerfP * handler, fBnetsnmp_handler_registrationfP * reginfo, fBnetsnmp_agent_request_infofP * reqinfo, fBnetsnmp_request_infofP * requests)"
- .PP
- implements the table data helper.
- .PP
- This is the routine that takes care of all SNMP requests coming into the table.
- .PP
- Definition at line 427 of file table_dataset.c.
- .PP
- References netsnmp_table_data_set_s::allow_creation, netsnmp_table_request_info_s::colnum, newrow_stash_s::created, netsnmp_table_data_set_storage_s::data, netsnmp_table_row_s::data, netsnmp_table_data_set_storage_s::data_len, newrow_stash_s::deleted, netsnmp_table_request_info_s::index_oid, netsnmp_table_request_info_s::index_oid_len, netsnmp_vardata::integer, netsnmp_agent_request_info_s::mode, netsnmp_mib_handler_s::myvoid, netsnmp_table_data_s::name, variable_list::name, variable_list::name_length, netsnmp_create_data_list(), netsnmp_extract_table_info(), netsnmp_extract_table_row(), netsnmp_oid_stash_add_data(), netsnmp_oid_stash_get_data(), netsnmp_request_add_list_data(), netsnmp_set_request_error(), netsnmp_strdup_and_null(), netsnmp_table_data_build_result(), netsnmp_table_data_set_clone_row(), netsnmp_table_data_set_create_newrowstash(), netsnmp_table_data_set_find_column(), netsnmp_table_dataset_add_row(), netsnmp_table_dataset_delete_row(), netsnmp_table_dataset_remove_and_delete_row(), netsnmp_table_dataset_replace_row(), newrow_stash_s::newrow, netsnmp_request_info_s::next, NULL, netsnmp_request_info_s::processed, netsnmp_request_info_s::requestvb, netsnmp_handler_registration_s::rootoid_len, netsnmp_table_data_set_s::rowstatus_column, SNMP_FREE, snmp_log(), SNMP_MALLOC_TYPEDEF, snprint_objid(), newrow_stash_s::state, netsnmp_vardata::string, netsnmp_table_data_set_s::table, variable_list::type, netsnmp_table_data_set_storage_s::type, variable_list::val, variable_list::val_len, and netsnmp_table_data_set_storage_s::writable.
- .PP
- Referenced by netsnmp_get_table_data_set_handler().
- .SS "NETSNMP_INLINE void netsnmp_table_dataset_add_index (fBnetsnmp_table_data_setfP * table, u_char type)"
- .PP
- adds an index to the table.
- .PP
- Call this repeatly for each index.
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 1040 of file table_dataset.c.
- .PP
- References netsnmp_table_data_set_s::table.
- .PP
- Referenced by netsnmp_table_set_add_indexes().
- .SS "NETSNMP_INLINE void netsnmp_table_dataset_add_row (fBnetsnmp_table_data_setfP * table, fBnetsnmp_table_rowfP * row)"
- .PP
- adds a new row to a dataset table
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 1049 of file table_dataset.c.
- .PP
- References netsnmp_table_data_add_row(), and netsnmp_table_data_set_s::table.
- .PP
- Referenced by netsnmp_table_data_set_helper_handler().
- .SS "NETSNMP_INLINE void netsnmp_table_dataset_delete_all_data (fBnetsnmp_table_data_set_storagefP * data)"
- .PP
- deletes all the data from this node and beyond in the linked list
- .PP
- Definition at line 1085 of file table_dataset.c.
- .PP
- References netsnmp_table_dataset_delete_data().
- .PP
- Referenced by netsnmp_table_dataset_delete_row(), and netsnmp_table_dataset_remove_and_delete_row().
- .SS "NETSNMP_INLINE fBnetsnmp_table_data_set_storagefP* netsnmp_table_dataset_delete_data (fBnetsnmp_table_data_set_storagefP * data)"
- .PP
- deletes a single dataset table data.
- .PP
- returns the (possibly still good) next pointer of the deleted data object.
- .PP
- Definition at line 1072 of file table_dataset.c.
- .PP
- References netsnmp_table_data_set_storage_s::data, netsnmp_table_data_set_storage_s::next, NULL, and SNMP_FREE.
- .PP
- Referenced by netsnmp_table_dataset_delete_all_data().
- .SS "NETSNMP_INLINE void netsnmp_table_dataset_delete_row (fBnetsnmp_table_rowfP * row)"
- .PP
- deletes all the data from this node and beyond in the linked list
- .PP
- Definition at line 1095 of file table_dataset.c.
- .PP
- References netsnmp_table_data_delete_row(), and netsnmp_table_dataset_delete_all_data().
- .PP
- Referenced by netsnmp_table_data_set_clone_row(), and netsnmp_table_data_set_helper_handler().
- .SS "NETSNMP_INLINE void netsnmp_table_dataset_remove_and_delete_row (fBnetsnmp_table_data_setfP * table, fBnetsnmp_table_rowfP * row)"
- .PP
- removes a row from the table and then deletes it (and all it's data)
- .PP
- Definition at line 1119 of file table_dataset.c.
- .PP
- References netsnmp_table_data_remove_and_delete_row(), netsnmp_table_dataset_delete_all_data(), and netsnmp_table_data_set_s::table.
- .PP
- Referenced by netsnmp_table_data_set_helper_handler().
- .SS "NETSNMP_INLINE void netsnmp_table_dataset_remove_row (fBnetsnmp_table_data_setfP * table, fBnetsnmp_table_rowfP * row)"
- .PP
- removes a row from the table, but doesn't delete/free anything
- .PP
- Definition at line 1108 of file table_dataset.c.
- .PP
- References netsnmp_table_data_remove_and_delete_row(), and netsnmp_table_data_set_s::table.
- .SS "NETSNMP_INLINE void netsnmp_table_dataset_replace_row (fBnetsnmp_table_data_setfP * table, fBnetsnmp_table_rowfP * origrow, fBnetsnmp_table_rowfP * newrow)"
- .PP
- adds a new row to a dataset table
- .PP
- Definition at line 1059 of file table_dataset.c.
- .PP
- References netsnmp_table_data_replace_row(), and netsnmp_table_data_set_s::table.
- .PP
- Referenced by netsnmp_table_data_set_helper_handler().
- .SS "int netsnmp_table_set_add_default_row (fBnetsnmp_table_data_setfP * table_set, unsigned int column, int type, int writable, void * default_value, size_t default_value_len)"
- .PP
- adds a new default row to a table_set.
- .PP
- 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).
- .PP
- returns SNMPERR_SUCCESS or SNMPERR_FAILURE
- .PP
- Definition at line 289 of file table_dataset.c.
- .PP
- 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, and netsnmp_table_data_set_storage_s::writable.
- .PP
- Referenced by netsnmp_config_parse_table_set(), and netsnmp_table_set_multi_add_default_row().
- .SS "void netsnmp_table_set_add_indexes (va_alist)"
- .PP
- adds multiple indexes to a table_dataset helper object.
- .PP
- To end the list, use a 0 after the list of ASN index types.
- .PP
- Definition at line 1180 of file table_dataset.c.
- .PP
- References netsnmp_table_dataset_add_index().
- .SS "void netsnmp_table_set_multi_add_default_row (va_dcl)"
- .PP
- adds multiple data column definitions to each row.
- .PP
- Functionally, this is a wrapper around calling netsnmp_table_set_add_default_row repeatedly for you.
- .PP
- fBExamples: fP
- .in +1c
- fBdata_set.cfP.
- .PP
- Definition at line 1141 of file table_dataset.c.
- .PP
- References netsnmp_table_set_add_default_row().