NAME
netsnmptabledataset - Helps you implement a table with automatted
storage. FFuunnccttiioonnss void nneettssnnmmppiinniittttaabblleeddaattaasseett (void) netsnmptabledataset * nneettssnnmmppccrreeaatteettaabblleeddaattaasseett (const char *tablename) Create a netsnmptabledataset structure given a tabledata definition. nneettssnnmmppmmiibbhhaannddlleerr * nneettssnnmmppggeettttaabblleeddaattaasseetthhaannddlleerr (netsnmptabledataset *dataset) Given a netsnmptabledataset definition, create a handler for it. int nneettssnnmmpprreeggiisstteerrttaabblleeddaattaasseett (nneettssnnmmpphhaannddlleerrrreeggiissttrraattiioonn *reginfo, netsnmptabledataset *dataset, nneettssnnmmppttaabblleerreeggiissttrraattiioonniinnffoo *tableinfo) register a given dataset at a given oid (specified in the netsnmphandlerregistration pointer). netsnmptabledatasetstorage * nneettssnnmmppttaabblleeddaattaasseettffiinnddccoolluummnn (netsnmptabledatasetstorage *start, unsigned int column) Finds a column within a given storage set, given the pointer to the start of the storage set list. netsnmptabledatasetstorage * nneettssnnmmppeexxttrraaccttttaabblleeddaattaasseettccoolluummnn (nneettssnnmmpprreeqquueessttiinnffoo *request, unsigned int column) extracts a netsnmptabledataset pointer from a given request NETSNMPINLINE netsnmptabledataset * nneettssnnmmppeexxttrraaccttttaabblleeddaattaasseett (nneettssnnmmpprreeqquueessttiinnffoo *request) extracts a netsnmptabledataset pointer from a given request int nneettssnnmmppmmaarrkkrroowwccoolluummnnwwrriittaabbllee (netsnmptablerow *row, int column, int writable) marks a given column in a row as writable or not. int nneettssnnmmppsseettrroowwccoolluummnn (netsnmptablerow *row, unsigned int column, int type, const char *value, sizet valuelen) sets a given column in a row with data given a type, value, and length. int nneettssnnmmppttaabblleesseettaaddddddeeffaauullttrrooww (netsnmptabledataset *tableset, unsigned int column, int type, int writable, void *defaultvalue, sizet defaultvaluelen) adds a new default row to a tableset. netsnmptablerow * nneettssnnmmppttaabblleeddaattaasseettcclloonneerrooww (netsnmptablerow *row) clones a dataset row, including all data. netsnmptablerow * nneettssnnmmppttaabblleeddaattaasseettccrreeaatteerroowwffrroommddeeffaauullttss (netsnmptabledatasetstorage *defrow) creates a new row from an existing defined default set newrowstash * nneettssnnmmppttaabblleeddaattaasseettccrreeaatteenneewwrroowwssttaasshh (netsnmptabledataset *datatable, nneettssnnmmppttaabblleerreeqquueessttiinnffoo *tableinfo) int nneettssnnmmppttaabblleeddaattaasseetthheellppeerrhhaannddlleerr (nneettssnnmmppmmiibbhhaannddlleerr *handler, nneettssnnmmpphhaannddlleerrrreeggiissttrraattiioonn *reginfo, nneettssnnmmppaaggeennttrreeqquueessttiinnffoo *reqinfo, nneettssnnmmpprreeqquueessttiinnffoo *requests) implements the table data helper. void nneettssnnmmpprreeggiisstteerraauuttooddaattaattaabbllee (netsnmptabledataset *tableset, char *registrationname) registers a tabledataset so that the 'addrow' snmpd.conf token can be used to add data to this table. void nneettssnnmmppccoonnffiiggppaarrsseettaabblleesseett (const char *token, char *line) void nneettssnnmmppccoonnffiiggppaarrsseeaaddddrrooww (const char *token, char *line) NETSNMPINLINE void nneettssnnmmppttaabblleeddaattaasseettaaddddiinnddeexx (netsnmptabledataset *table, uchar type) adds an index to the table. NETSNMPINLINE void nneettssnnmmppttaabblleeddaattaasseettaaddddrrooww (netsnmptabledataset *table, netsnmptablerow *row) adds a new row to a dataset table NETSNMPINLINE void nneettssnnmmppttaabblleeddaattaasseettrreeppllaacceerrooww (netsnmptabledataset *table, netsnmptablerow *origrow, netsnmptablerow *newrow) adds a new row to a dataset table NETSNMPINLINE netsnmptabledatasetstorage * nneettssnnmmppttaabblleeddaattaasseettddeelleetteeddaattaa (netsnmptabledatasetstorage *data) deletes a single dataset table data. NETSNMPINLINE void nneettssnnmmppttaabblleeddaattaasseettddeelleetteeaallllddaattaa (netsnmptabledatasetstorage *data) deletes all the data from this node and beyond in the linked list NETSNMPINLINE void nneettssnnmmppttaabblleeddaattaasseettddeelleetteerrooww (netsnmptablerow *row) deletes all the data from this node and beyond in the linked list NETSNMPINLINE void nneettssnnmmppttaabblleeddaattaasseettrreemmoovveerrooww (netsnmptabledataset *table, netsnmptablerow *row) removes a row from the table, but doesn't delete/free anything NETSNMPINLINE void nneettssnnmmppttaabblleeddaattaasseettrreemmoovveeaannddddeelleetteerrooww (netsnmptabledataset *table, netsnmptablerow *row) removes a row from the table and then deletes it (and all it's data) void nneettssnnmmppttaabblleesseettmmuullttiiaaddddddeeffaauullttrrooww (vadcl) adds multiple data column definitions to each row. void nneettssnnmmppttaabblleesseettaaddddiinnddeexxeess (vaalist) adds multiple indexes to a tabledataset helper object. int nneettssnnmmppttaabblleesseettnnuummrroowwss (netsnmptabledataset *table) DDeettaaiilleedd DDeessccrriippttiioonn 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 thedata, 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. FFuunnccttiioonn DDooccuummeennttaattiioonn nneettssnnmmppttaabblleeddaattaasseett** nneettssnnmmppccrreeaatteettaabblleeddaattaasseett ((ccoonnsstt cchhaarr ** ttaabblleennaammee)) Create a netsnmptabledataset structure given a tabledata definition. EExxaammpplleess:: ddaattaasseett..cc. Definition at line 74 of file tabledataset.c. References netsnmpcreatetabledata(), and SNMPMALLOCTYPEDEF. NNEETTSSNNMMPPIINNLLIINNEE nneettssnnmmppttaabblleeddaattaasseett** nneettssnnmmppeexxttrraaccttttaabblleeddaattaasseett ((nneettssnnmmpprreeqquueessttiinnffoo ** rreeqquueesstt)) extracts a netsnmptabledataset pointer from a given request Definition at line 187 of file tabledataset.c. References netsnmprequestgetlistdata(). nneettssnnmmppttaabblleeddaattaasseettssttoorraaggee** nneettssnnmmppeexxttrraaccttttaabblleeddaattaasseettccoolluummnn ((nneettssnnmmpprreeqquueessttiinnffoo ** rreeqquueesstt,, uunnssiiggnneedd iinntt ccoolluummnn)) extracts a netsnmptabledataset pointer from a given request Definition at line 173 of file tabledataset.c. References netsnmpextracttablerowdata(), and netsnmptabledatasetfindcolumn(). nneettssnnmmppmmiibbhhaannddlleerr** nneettssnnmmppggeettttaabblleeddaattaasseetthhaannddlleerr ((nneettssnnmmppttaabblleeddaattaasseett ** ddaattaasseett)) Given a netsnmptabledataset definition, create a handler for it. Definition at line 86 of file tabledataset.c. References netsnmpmibhandlers::flags, netsnmpmibhandlers::myvoid, netsnmpcreatehandler(), netsnmpmibhandler, and snmplog(). Referenced by netsnmpregistertabledataset(). iinntt nneettssnnmmppmmaarrkkrroowwccoolluummnnwwrriittaabbllee ((nneettssnnmmppttaabblleerrooww ** rrooww,, iinntt ccoolluummnn,, iinntt wwrriittaabbllee)) marks a given column in a row as writable or not. EExxaammpplleess:: ddaattaasseett..cc. Definition at line 197 of file tabledataset.c. References netsnmptabledatasetfindcolumn(), snmplog(), and SNMPMALLOCTYPEDEF. Referenced by netsnmptabledatasetcreaterowfromdefaults(). vvooiidd nneettssnnmmpprreeggiisstteerraauuttooddaattaattaabbllee ((nneettssnnmmppttaabblleeddaattaasseett ** ttaabblleesseett,, cchhaarr ** rreeggiissttrraattiioonnnnaammee)) registers a tabledataset so that the 'addrow' snmpd.conf token can be used to add data to this table. If registrationname is NULL then the name used when the table was created will be used instead. TTooddoo create a properly free'ing registeration pointer for the datalist, and get the datalist freed at shutdown. EExxaammpplleess:: ddaattaasseett..cc. Definition at line 783 of file tabledataset.c. References netsnmpaddlistdata(), netsnmpcreatedatalist(), and SNMPMALLOCTYPEDEF. iinntt nneettssnnmmpprreeggiisstteerrttaabblleeddaattaasseett ((nneettssnnmmpphhaannddlleerrrreeggiissttrraattiioonn ** rreeggiinnffoo,, nneettssnnmmppttaabblleeddaattaasseett ** ddaattaasseett,, nneettssnnmmppttaabblleerreeggiissttrraattiioonniinnffoo ** ttaabblleeiinnffoo)) register a given dataset at a given oid (specified in the netsnmphandlerregistration pointer). Thereginfo->handler->accessmethod *may* be null if the call doesn't ever
want to be called for SNMP operations. EExxaammpplleess:: ddaattaasseett..cc. Definition at line 113 of file tabledataset.c. References netsnmptableregistrationinfos::indexes, netsnmptableregistrationinfos::maxcolumn, netsnmptableregistrationinfos::mincolumn, netsnmpgettabledatasethandler(), netsnmphandlerregistration, netsnmpinjecthandler(), netsnmpregistertabledata(), SNMPMALLOCTYPEDEF, SNMPMAX, and SNMPMIN. iinntt nneettssnnmmppsseettrroowwccoolluummnn ((nneettssnnmmppttaabblleerrooww ** rrooww,, uunnssiiggnneedd iinntt ccoolluummnn,, iinntt ttyyppee,, ccoonnsstt cchhaarr ** vvaalluuee,, ssiizzeett vvaalluueelleenn)) sets a given column in a row with data given a type, value, and length. Data is memdup'ed by the function. EExxaammpplleess:: ddaattaasseett..cc. Definition at line 233 of file tabledataset.c. References memdup(), netsnmptabledatasetfindcolumn(), SNMPFREE, snmplog(), and SNMPMALLOCTYPEDEF. Referenced by netsnmptabledatasetcreaterowfromdefaults(). nneettssnnmmppttaabblleerrooww** nneettssnnmmppttaabblleeddaattaasseettcclloonneerrooww ((nneettssnnmmppttaabblleerrooww ** rrooww)) clones a dataset row, including all data. Definition at line 347 of file tabledataset.c. References memdup(), netsnmptabledataclonerow(), and netsnmptabledatasetdeleterow(). Referenced by netsnmptabledatasethelperhandler(). nneettssnnmmppttaabblleerrooww** nneettssnnmmppttaabblleeddaattaasseettccrreeaatteerroowwffrroommddeeffaauullttss ((nneettssnnmmppttaabblleeddaattaasseettssttoorraaggee ** ddeeffrrooww)) creates a new row from an existing defined default set Definition at line 389 of file tabledataset.c. References netsnmpcreatetabledatarow(), netsnmpmarkrowcolumnwritable(), and netsnmpsetrowcolumn(). nneettssnnmmppttaabblleeddaattaasseettssttoorraaggee** nneettssnnmmppttaabblleeddaattaasseettffiinnddccoolluummnn ((nneettssnnmmppttaabblleeddaattaasseettssttoorraaggee ** ssttaarrtt,, uunnssiiggnneedd iinntt ccoolluummnn)) Finds a column within a given storage set, given the pointer to the start of the storage set list. Definition at line 161 of file tabledataset.c. Referenced by netsnmpextracttabledatasetcolumn(), netsnmpmarkrowcolumnwritable(), netsnmpsetrowcolumn(), netsnmptabledatasethelperhandler(), and netsnmptablesetadddefaultrow(). iinntt nneettssnnmmppttaabblleeddaattaasseetthheellppeerrhhaannddlleerr ((nneettssnnmmppmmiibbhhaannddlleerr ** hhaannddlleerr,, nneettssnnmmpphhaannddlleerrrreeggiissttrraattiioonn ** rreeggiinnffoo,, nneettssnnmmppaaggeennttrreeqquueessttiinnffoo ** rreeqqiinnffoo,, nneettssnnmmpprreeqquueessttiinnffoo ** rreeqquueessttss)) implements the table data helper. This is the routine that takes care of all SNMP requests coming into the table. Definition at line 427 of file tabledataset.c. References netsnmptablerequestinfos::colnum, netsnmptablerequestinfos::indexoid, netsnmptablerequestinfos::indexoidlen, netsnmpagentrequestinfos::mode, netsnmpmibhandlers::myvoid, netsnmpcreatedatalist(), netsnmpextracttableinfo(), netsnmpextracttablerow(), netsnmphandlerregistration, netsnmpmibhandler, netsnmpoidstashadddata(), netsnmpoidstashgetdata(), netsnmprequestaddlistdata(), netsnmpsetrequesterror(), netsnmpstrdupandnull(), netsnmptabledatabuildresult(), netsnmptabledatasetclonerow(), netsnmptabledatasetfindcolumn(), netsnmptabledatasetaddrow(), netsnmptabledatasetdeleterow(), netsnmptabledatasetremoveanddeleterow(), netsnmptabledatasetreplacerow(), netsnmprequestinfos::next, netsnmprequestinfos::processed, netsnmprequestinfos::requestvb, netsnmphandlerregistrations::rootoidlen, SNMPFREE, snmplog(), SNMPMALLOCTYPEDEF, variablelist::type, variablelist::val, and variablelist::vallen. NNEETTSSNNMMPPIINNLLIINNEE vvooiidd nneettssnnmmppttaabblleeddaattaasseettaaddddiinnddeexx ((nneettssnnmmppttaabblleeddaattaasseett ** ttaabbllee,, uucchhaarr ttyyppee)) adds an index to the table. Call this repeatly for each index. EExxaammpplleess:: ddaattaasseett..cc. Definition at line 1052 of file tabledataset.c. Referenced by netsnmptablesetaddindexes(). NNEETTSSNNMMPPIINNLLIINNEE vvooiidd nneettssnnmmppttaabblleeddaattaasseettaaddddrrooww ((nneettssnnmmppttaabblleeddaattaasseett ** ttaabbllee,, nneettssnnmmppttaabblleerrooww ** rrooww)) adds a new row to a dataset table EExxaammpplleess:: ddaattaasseett..cc. Definition at line 1061 of file tabledataset.c. References netsnmptabledataaddrow(). Referenced by netsnmptabledatasethelperhandler(). NNEETTSSNNMMPPIINNLLIINNEE vvooiidd nneettssnnmmppttaabblleeddaattaasseettddeelleetteeaallllddaattaa ((nneettssnnmmppttaabblleeddaattaasseettssttoorraaggee ** ddaattaa)) deletes all the data from this node and beyond in the linked list Definition at line 1097 of file tabledataset.c. References netsnmptabledatasetdeletedata(). Referenced by netsnmptabledatasetdeleterow(), and netsnmptabledatasetremoveanddeleterow(). NNEETTSSNNMMPPIINNLLIINNEE nneettssnnmmppttaabblleeddaattaasseettssttoorraaggee** nneettssnnmmppttaabblleeddaattaasseettddeelleetteeddaattaa ((nneettssnnmmppttaabblleeddaattaasseettssttoorraaggee ** ddaattaa)) deletes a single dataset table data. returns the (possibly still good) next pointer of the deleted data object. Definition at line 1084 of file tabledataset.c. References SNMPFREE. Referenced by netsnmptabledatasetdeletealldata(). NNEETTSSNNMMPPIINNLLIINNEE vvooiidd nneettssnnmmppttaabblleeddaattaasseettddeelleetteerrooww ((nneettssnnmmppttaabblleerrooww ** rrooww)) deletes all the data from this node and beyond in the linked list Definition at line 1107 of file tabledataset.c. References netsnmptabledatadeleterow(), and netsnmptabledatasetdeletealldata(). Referenced by netsnmptabledatasetclonerow(), and netsnmptabledatasethelperhandler(). NNEETTSSNNMMPPIINNLLIINNEE vvooiidd nneettssnnmmppttaabblleeddaattaasseettrreemmoovveeaannddddeelleetteerrooww ((nneettssnnmmppttaabblleeddaattaasseett ** ttaabbllee,, nneettssnnmmppttaabblleerrooww ** rrooww)) removes a row from the table and then deletes it (and all it's data) Definition at line 1131 of file tabledataset.c. References netsnmptabledataremoveanddeleterow(), and netsnmptabledatasetdeletealldata(). Referenced by netsnmptabledatasethelperhandler(). NNEETTSSNNMMPPIINNLLIINNEE vvooiidd nneettssnnmmppttaabblleeddaattaasseettrreemmoovveerrooww ((nneettssnnmmppttaabblleeddaattaasseett ** ttaabbllee,, nneettssnnmmppttaabblleerrooww ** rrooww)) removes a row from the table, but doesn't delete/free anything Definition at line 1120 of file tabledataset.c. References netsnmptabledataremoveanddeleterow(). NNEETTSSNNMMPPIINNLLIINNEE vvooiidd nneettssnnmmppttaabblleeddaattaasseettrreeppllaacceerrooww ((nneettssnnmmppttaabblleeddaattaasseett ** ttaabbllee,, nneettssnnmmppttaabblleerrooww ** oorriiggrrooww,, nneettssnnmmppttaabblleerrooww ** nneewwrrooww)) adds a new row to a dataset table Definition at line 1071 of file tabledataset.c. References netsnmptabledatareplacerow(). Referenced by netsnmptabledatasethelperhandler(). iinntt nneettssnnmmppttaabblleesseettaaddddddeeffaauullttrrooww ((nneettssnnmmppttaabblleeddaattaasseett ** ttaabblleesseett,, uunnssiiggnneedd iinntt ccoolluummnn,, iinntt ttyyppee,, iinntt wwrriittaabbllee,, vvooiidd ** ddeeffaauullttvvaalluuee,, ssiizzeett ddeeffaauullttvvaalluueelleenn)) adds a new default row to a tableset. Arguments should be the tableset, column number, variable type and finally a 1 if it is allowed to be writable, or a 0 if not. If the defaultvalue 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 SNMPERRSUCCESS or SNMPERRFAILURE Definition at line 289 of file tabledataset.c. References memdup(), netsnmptabledatasetfindcolumn(), snmplog(), and SNMPMALLOCTYPEDEF. Referenced by netsnmptablesetmultiadddefaultrow(). vvooiidd nneettssnnmmppttaabblleesseettaaddddiinnddeexxeess ((vvaaaalliisstt)) adds multiple indexes to a tabledataset helper object. To end the list, use a 0 after the list of ASN index types. Definition at line 1192 of file tabledataset.c. References netsnmptabledatasetaddindex(). vvooiidd nneettssnnmmppttaabblleesseettmmuullttiiaaddddddeeffaauullttrrooww ((vvaaddccll)) adds multiple data column definitions to each row. Functionally, this is a wrapper around calling netsnmptablesetadddefaultrow repeatedly for you. Definition at line 1153 of file tabledataset.c. References netsnmptablesetadddefaultrow(), and netsnmptablesetmultiadddefaultrow(). Referenced by netsnmptablesetmultiadddefaultrow().net-snmptabledataset: Helps you i2m4plJeamnen2t00a5table with automatted storage.(3)