table: Helps you implement a table.(3) table: Helps you implement a table.(3)
NAME
netsnmptable - Helps you implement a table.
odules
grouptablearray:: Helps you implement a table when data can be stored
locally. The data is stored in a sorted array,, using a binary
search for lookups.
The tablearray handler is used (automatically) in conjuntion with
the table handler.
grouptablecontainer:: Helps you implement a table when data can be
found via a netsnmpcontainer.
The tablecontainer handler is used (automatically) in conjuntion
with the table handler.
grouptabledata:: Helps you implement a table with datamatted storage.
This helper helps you implement a table where all the indexes are
expected to be stored within the agent itself and not in some
external storage location.
grouptableiterator:: 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.
Functionally, it is a specialized version of the more generic table
helper but easies the burden of GETNEXT processing by manually
looping through all the data indexes retrieved through function
calls which should be supplied by the module that wishes help.
Defines
#define SPARSETABLEHANDLERNAME 'sparsetable'
Functions
netsnmpmibhandler * netsnmpgettablehandler
(netsnmptableregistrationinfo *tabreq)
Given a netsnmptableregistrationinfo object, creates a table
handler.
int netsnmpregistertable (netsnmphandlerregistration *reginfo,
netsnmptableregistrationinfo *tabreq)
creates a table handler given the netsnmptableregistrationinfo
object, inserts it into the request chain and then calls
netsnmpregisterhandler() to register the table into the agent.
NETSNMPINLINE netsnmptablerequestinfo ** netsnmpextracttableinfo
(netsnmprequestinfo **request)
Extracts the processed table information from a given request.
netsnmptableregistrationinfo ** netsnmpfindtableregistrationinfo
(netsnmphandlerregistration **reginfo)
extracts the registered netsnmptableregistrationinfo object from
a netsnmphandlerregistration object
int tablehelperhandler (netsnmpmibhandler **handler,,
netsnmphandlerregistration **reginfo,, netsnmpagentrequestinfo
**reqinfo,, netsnmprequestinfo **requests)
implements the table helper handler
netsnmpmibhandler ** netsnmpsparsetablehandlerget (void)
create sparse table handler
int netsnmpsparsetableregister (netsnmphandlerregistration
**reginfo,, netsnmptableregistrationinfo **tabreq)
creates a table handler given the netsnmptableregistrationinfo
object, inserts it into the request chain and then calls
netsnmpregisterhandler() to register the table into the agent.
int netsnmptablebuildresult (netsnmphandlerregistration **reginfo,,
netsnmprequestinfo **reqinfo,, netsnmptablerequestinfo
**tableinfo,, uchar type,, uchar **result,, sizet resultlen)
Builds the result to be returned to the agent given the table
information.
int netsnmptablebuildoid (netsnmphandlerregistration **reginfo,,
netsnmprequestinfo **reqinfo,, netsnmptablerequestinfo
**tableinfo)
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 tableinfo object.
int netsnmptablebuildoidfromindex (netsnmphandlerregistration
**reginfo,, netsnmprequestinfo **reqinfo,, netsnmptablerequestinfo
**tableinfo)
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 tableinfo object.
int netsnmpupdatevariablelistfromindex (netsnmptablerequestinfo
**tri)
parses an OID into table indexses
int netsnmpupdateindexesfromvariablelist
(netsnmptablerequestinfo **tri)
builds an oid given a set of indexes.
int netsnmpcheckgetnextreply (netsnmprequestinfo **request,, oid
**prefix,, sizet prefixlen,, netsnmpvariablelist **newvar,,
netsnmpvariablelist ****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
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 netsnmpregistertable() 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
tableregisterationinfo 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 netsnmpcheckgetnextreply (netsnmprequestinfo ** request,, oid **
prefix,, sizet prefixlen,, netsnmpvariablelist ** newvar,,
netsnmpvariablelist **** 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 872 of file table.c.
References variablelist::name, variablelist::namelength,
netsnmprequestinfos::requestvb, snmpoidcompare(),
snmpsetvartypedvalue(), variablelist::type, variablelist::val,
and variablelist::vallen.
Referenced by netsnmptableiteratorhelperhandler().
NETSNMPINLINE netsnmptablerequestinfo** netsnmpextracttableinfo
(netsnmprequestinfo ** request)
Extracts the processed table information from a given request. Call
this from subhandlers on a request to extract the processed
netsnmprequestinfo information. The resulting information includes
the index values and the column number.
Parameters::
request populated netsnmp request structure
Returns::
populated netsnmptablerequestinfo structure
Definition at line 128 of file table.c.
References netsnmprequestgetlistdata().
Referenced by netsnmpinsertiteratorcontext(),
netsnmpinserttablerow(), netsnmptabledatahelperhandler(),
netsnmptabledatasethelperhandler(),
netsnmptableiteratorhelperhandler(), and tablehelperhandler().
netsnmptableregistrationinfo** netsnmpfindtableregistrationinfo
(netsnmphandlerregistration ** reginfo)
extracts the registered netsnmptableregistrationinfo object from a
netsnmphandlerregistration object Definition at line 137 of file
table.c.
References netsnmpfindhandlerdatabyname(), and
netsnmphandlerregistration.
Referenced by netsnmptabledatahelperhandler(), and
netsnmptableiteratorhelperhandler().
netsnmpmibhandler** netsnmpgettablehandler
(netsnmptableregistrationinfo ** tabreq)
Given a netsnmptableregistrationinfo 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->parentdata 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 netsnmptableregistrationinfo struct.
The table handler needs to know up front how your table is
structured. A netsnmptableregisterationinfo 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 netsnmpmibhandler struct which contains
the handler's name and the access method
Definition at line 88 of file table.c.
References netsnmptableregistrationinfos::indexes,
netsnmpmibhandlers::myvoid, netsnmpcreatehandler(),
netsnmpmibhandler, netsnmptableregistrationinfos::numberindexes,
and snmplog().
Referenced by netsnmpregistertable(), and
netsnmpsparsetableregister().
int netsnmpregistertable (netsnmphandlerregistration ** reginfo,,
netsnmptableregistrationinfo ** tabreq)
creates a table handler given the netsnmptableregistrationinfo
object, inserts it into the request chain and then calls
netsnmpregisterhandler() to register the table into the agent.
Definition at line 111 of file table.c.
References netsnmpgettablehandler(), netsnmphandlerregistration,
netsnmpinjecthandler(), and netsnmpregisterhandler().
Referenced by netsnmpregistertabledata(),
netsnmpregistertableiterator(), and
netsnmptablecontainerregister().
netsnmpmibhandler** netsnmpsparsetablehandlerget (void)
create sparse table handler Definition at line 710 of file table.c.
References netsnmpcreatehandler().
int netsnmpsparsetableregister (netsnmphandlerregistration ** reginfo,,
netsnmptableregistrationinfo ** tabreq)
creates a table handler given the netsnmptableregistrationinfo
object, inserts it into the request chain and then calls
netsnmpregisterhandler() to register the table into the agent.
Definition at line 721 of file table.c.
References netsnmpcreatehandler(), netsnmpgettablehandler(),
netsnmphandlerregistration, netsnmpinjecthandler(), and
netsnmpregisterhandler().
int netsnmptablebuildoid (netsnmphandlerregistration ** reginfo,,
netsnmprequestinfo ** reqinfo,, netsnmptablerequestinfo **
tableinfo)
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 tableinfo object. Index values are
extracted from the tableinfo varbinds. .Entry
References buildoid(), netsnmptablerequestinfos::colnum,
netsnmptablerequestinfos::indexes, variablelist::name,
variablelist::namelength, netsnmphandlerregistration,
netsnmprequestinfos::requestvb,
netsnmphandlerregistrations::rootoid, and
netsnmphandlerregistrations::rootoidlen.
Referenced by netsnmptablebuildresult().
int netsnmptablebuildoidfromindex (netsnmphandlerregistration **
reginfo,, netsnmprequestinfo ** reqinfo,, netsnmptablerequestinfo **
tableinfo)
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 tableinfo object. Index values are
extracted from the tableinfo index oid. Definition at line 809 of file
table.c.
References netsnmptablerequestinfos::colnum,
netsnmptablerequestinfos::indexoid,
netsnmptablerequestinfos::indexoidlen, variablelist::name,
variablelist::namelength, variablelist::nameloc,
netsnmphandlerregistration, netsnmprequestinfos::requestvb,
netsnmphandlerregistrations::rootoid,
netsnmphandlerregistrations::rootoidlen, and SNMPFRE.
int netsnmptablebuildresult (netsnmphandlerregistration ** reginfo,,
netsnmprequestinfo ** reqinfo,, netsnmptablerequestinfo **
tableinfo,, uchar type,, uchar ** result,, sizet resultlen)
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 739 of file table.c.
References variablelist::name, variablelist::nameloc,
netsnmphandlerregistration, netsnmptablebuildoid(),
netsnmprequestinfos::requestvb, and snmpsetvartypedvalue().
int netsnmpupdateindexesfromvariablelist (netsnmptablerequestinfo **
tri)
builds an oid given a set of indexes. Definition at line 854 of file
table.c.
References netsnmptablerequestinfos::indexoid,
netsnmptablerequestinfos::indexoidlen, and
netsnmptablerequestinfos::indexes.
int netsnmpupdatevariablelistfromindex (netsnmptablerequestinfo **
tri)
parses an OID into table indexses Definition at line 838 of file
table.c.
References netsnmptablerequestinfos::indexoid,
netsnmptablerequestinfos::indexoidlen, and
netsnmptablerequestinfos::indexes.
int tablehelperhandler (netsnmpmibhandler ** handler,,
netsnmphandlerregistration ** reginfo,, netsnmpagentrequestinfo **
reqinfo,, netsnmprequestinfo ** requests)
implements the table helper handler X-rks: memory leak. add cleanup
handler?
none available
got one ok
for loop Definition at line 145 of file table.c.
References netsnmptablerequestinfos::colnum,
netsnmpmibhandlers::handlername,
netsnmptablerequestinfos::indexoid,
netsnmptablerequestinfos::indexoidlen,
netsnmptablerequestinfos::indexes,
netsnmptableregistrationinfos::indexes,
netsnmptableregistrationinfos::maxcolumn,
netsnmptableregistrationinfos::mincolumn,
netsnmpagentrequestinfos::mode, netsnmpmibhandlers::myvoid,
variablelist::name, variablelist::namelength,
variablelist::nameloc, netsnmpcallnexthandler(),
netsnmpcreatedatalist(), netsnmpextracttableinfo(),
netsnmphandlerregistration, netsnmpmibhandler,
netsnmprequestaddlistdata(), netsnmpsetrequesterror(),
netsnmprequestinfos::next, netsnmpmibhandlers::next,
netsnmptableregistrationinfos::numberindexes,
netsnmptablerequestinfos::numberindexes,
netsnmprequestinfos::processed,
netsnmptablerequestinfos::reginfo,
netsnmprequestinfos::requestvb,
netsnmphandlerregistrations::rootoid,
netsnmphandlerregistrations::rootoidlen, snmplog(),
SNMPMALOCTYPEDEF, snmpoidcompare(), sprintreallocbytype(),
netsnmprequestinfos::status, variablelist::type, and
netsnmptableregistrationinfos::validcolumns.
net-snmp 24 Janta0b0le: Helps you implement a table.(3)
|