diff options
| author | Joshua Tolley | 2010-11-26 17:22:01 +0000 |
|---|---|---|
| committer | Joshua Tolley | 2010-11-26 17:22:01 +0000 |
| commit | fe9d8f21bbdfb442b8233b4627a0c67dc458a8bd (patch) | |
| tree | a88daa49fc47e64777af3d331cf142e0604c2d48 /PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable | |
Diffstat (limited to 'PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable')
12 files changed, 2608 insertions, 0 deletions
diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.c new file mode 100644 index 0000000..5d427c0 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.c @@ -0,0 +1,129 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsqlPgAggregateTable.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/** \mainpage MFD helper for pgsqlPgAggregateTable + * + * \section intro Introduction + * Introductory text. + * + */ +/* standard Net-SNMP includes */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + +#include <net-snmp/agent/mib_modules.h> + +#include "pgsqlPgAggregateTable_interface.h" + +oid pgsqlPgAggregateTable_oid[] = { PGSQLPGAGGREGATETABLE_OID }; +int pgsqlPgAggregateTable_oid_size = OID_LENGTH(pgsqlPgAggregateTable_oid); + +void initialize_table_pgsqlPgAggregateTable(void); + + +/** + * Initializes the pgsqlPgAggregateTable module + */ +void +init_pgsqlPgAggregateTable(void) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:init_pgsqlPgAggregateTable","called\n")); + + /* + * TODO:300:o: Perform pgsqlPgAggregateTable one-time module initialization. + */ + + /* + * here we initialize all the tables we're planning on supporting + */ + if (should_init("pgsqlPgAggregateTable")) + initialize_table_pgsqlPgAggregateTable(); + +} /* init_pgsqlPgAggregateTable */ + +/** + * Initialize the table pgsqlPgAggregateTable + * (Define its contents and how it's structured) + */ +void +initialize_table_pgsqlPgAggregateTable(void) +{ + pgsqlPgAggregateTable_registration_ptr user_context; + u_long flags; + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:initialize_table_pgsqlPgAggregateTable","called\n")); + + /* + * TODO:301:o: Perform pgsqlPgAggregateTable one-time table initialization. + */ + + /* + * TODO:302:o: |->Initialize pgsqlPgAggregateTable user context + * if you'd like to pass in a pointer to some data for this + * table, allocate or set it up here. + */ + /* + * a netsnmp_data_list is a simple way to store void pointers. A simple + * string token is used to add, find or remove pointers. + */ + user_context = netsnmp_create_data_list("pgsqlPgAggregateTable", NULL, NULL); + + /* + * No support for any flags yet, but in the future you would + * set any flags here. + */ + flags = 0; + + /* + * call interface initialization code + */ + _pgsqlPgAggregateTable_initialize_interface(user_context, flags); +} /* initialize_table_pgsqlPgAggregateTable */ + +/** + * pre-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error + */ +int +pgsqlPgAggregateTable_pre_request(pgsqlPgAggregateTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_pre_request","called\n")); + + /* + * TODO:510:o: Perform pgsqlPgAggregateTable pre-request actions. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_pre_request */ + +/** + * post-request callback + * + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error (ignored) + */ +int +pgsqlPgAggregateTable_post_request(pgsqlPgAggregateTable_registration_ptr user_context) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_post_request","called\n")); + + /* + * TODO:511:o: Perform pgsqlPgAggregateTable pos-request actions. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_post_request */ + + +/** @{ */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.h new file mode 100644 index 0000000..18c7e4d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable.h @@ -0,0 +1,221 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.32.2.3 $ of : mfd-top.m2c,v $ + * + * $Id: pgsqlPgAggregateTable.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_H +#define PGSQLPGAGGREGATETABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** @defgroup misc misc: Miscelaneous routines + * + * @{ + */ +#include <net-snmp/library/asn1.h> + +/* other required module components */ + /* *INDENT-OFF* */ +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface); +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access); +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get); +config_require(PGSQL-MIB/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set); + /* *INDENT-ON* */ + +/* OID and column number definitions for */ +#include "pgsqlPgAggregateTable_oids.h" + +/* enum definions */ +#include "pgsqlPgAggregateTable_enums.h" + +/* ********************************************************************* + * function declarations + */ +void init_pgsqlPgAggregateTable(void); + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ +/* ********************************************************************* + * When you register your mib, you get to provide a generic + * pointer that will be passed back to you for most of the + * functions calls. + * + * TODO:100:r: Review all context structures + */ + /* + * TODO:101:o: |-> Review pgsqlPgAggregateTable registration context. + */ +typedef netsnmp_data_list * pgsqlPgAggregateTable_registration_ptr; + +/**********************************************************************/ +/* + * TODO:110:r: |-> Review pgsqlPgAggregateTable data context structure. + * This structure is used to represent the data for pgsqlPgAggregateTable. + */ +/* + * This structure contains storage for all the columns defined in the + * pgsqlPgAggregateTable. + */ +typedef struct pgsqlPgAggregateTable_data_s { + + /* + * pgsqlPgAggregateAggfnoid(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggfnoid; + + /* + * pgsqlPgAggregateAggtransfn(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggtransfn; + + /* + * pgsqlPgAggregateAggfinalfn(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggfinalfn; + + /* + * pgsqlPgAggregateAggsortop(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggsortop; + + /* + * pgsqlPgAggregateAggtranstype(6)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h + */ + long pgsqlPgAggregateAggtranstype; + + /* + * pgsqlPgAggregateAgginitval(7)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H + */ + char pgsqlPgAggregateAgginitval[255]; +size_t pgsqlPgAggregateAgginitval_len; /* # of char elements, not bytes */ + +} pgsqlPgAggregateTable_data; + + +/* + * TODO:120:r: |-> Review pgsqlPgAggregateTable mib index. + * This structure is used to represent the index for pgsqlPgAggregateTable. + */ +typedef struct pgsqlPgAggregateTable_mib_index_s { + + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + /** 128 - 2(other indexes) - oid length(12) = 113 */ + char pgsnmpdConnID[113]; + size_t pgsnmpdConnID_len; + + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + long rdbmsDbIndex; + + /* + * pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + long pgsqlPgAggregateEntryOID; + + +} pgsqlPgAggregateTable_mib_index; + + /* + * TODO:121:r: | |-> Review pgsqlPgAggregateTable max index length. + * If you KNOW that your indexes will never exceed a certain + * length, update this macro to that length. + * + * BE VERY CAREFUL TO TAKE INTO ACCOUNT THE MAXIMUM + * POSSIBLE LENGHT FOR EVERY VARIABLE LENGTH INDEX! + * Guessing 128 - col/entry(2) - oid len(10) +*/ +#define MAX_pgsqlPgAggregateTable_IDX_LEN 116 + + +/* ********************************************************************* + * TODO:130:o: |-> Review pgsqlPgAggregateTable Row request (rowreq) context. + * When your functions are called, you will be passed a + * pgsqlPgAggregateTable_rowreq_ctx pointer. + */ +typedef struct pgsqlPgAggregateTable_rowreq_ctx_s { + + /** this must be first for container compare to work */ + netsnmp_index oid_idx; + oid oid_tmp[MAX_pgsqlPgAggregateTable_IDX_LEN]; + + pgsqlPgAggregateTable_mib_index tbl_idx; + + pgsqlPgAggregateTable_data data; + + /* + * flags per row. Currently, the first (lower) 8 bits are reserved + * for the user. See mfd.h for other flags. + */ + u_int rowreq_flags; + + /* + * implementor's context pointer (provided during registration) + */ + pgsqlPgAggregateTable_registration_ptr pgsqlPgAggregateTable_reg; + + /* + * TODO:131:o: | |-> Add useful data to pgsqlPgAggregateTable rowreq context. + */ + + /* + * storage for future expansion + */ + netsnmp_data_list *pgsqlPgAggregateTable_data_list; + +} pgsqlPgAggregateTable_rowreq_ctx; + +typedef struct pgsqlPgAggregateTable_ref_rowreq_ctx_s { + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx; +} pgsqlPgAggregateTable_ref_rowreq_ctx; + +/* ********************************************************************* + * function prototypes + */ + int pgsqlPgAggregateTable_pre_request(pgsqlPgAggregateTable_registration_ptr user_context); + int pgsqlPgAggregateTable_post_request(pgsqlPgAggregateTable_registration_ptr user_context); + + +extern oid pgsqlPgAggregateTable_oid[]; +extern int pgsqlPgAggregateTable_oid_size; + + +#include "pgsqlPgAggregateTable_interface.h" +#include "pgsqlPgAggregateTable_data_access.h" +#include "pgsqlPgAggregateTable_data_get.h" +#include "pgsqlPgAggregateTable_data_set.h" + +/* + * DUMMY markers, ignore + * + * TODO:099:x: ************************************************************* + * TODO:199:x: ************************************************************* + * TODO:299:x: ************************************************************* + * TODO:399:x: ************************************************************* + * TODO:499:x: ************************************************************* + */ + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.c new file mode 100644 index 0000000..2f55780 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.c @@ -0,0 +1,297 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.12 $ of : mfd-data-access.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_access.c,v 1.2 2008/01/17 12:29:36 eggyknap Exp $ + */ +#include "pgsnmpd.h" + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" +#include "pgsqlPgAggregateTable_data_access.h" + +/** @defgroup data_access data_access: Routines to access data + * + * These routines are used to locate the data used to satisfy + * requests. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + +/** + * initialization for pgsqlPgAggregateTable data access + * + * This function is called during startup to allow you to + * allocate any resources you need for the data table. + * + * @param pgsqlPgAggregateTable_reg + * Pointer to pgsqlPgAggregateTable_registration + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : unrecoverable error. + */ +int +pgsqlPgAggregateTable_init_data(pgsqlPgAggregateTable_registration_ptr pgsqlPgAggregateTable_reg) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_init_data","called\n")); + + /* + * TODO:303:o: Initialize pgsqlPgAggregateTable data. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_init_data */ + +/** + * container-cached overview + * + */ + +/*********************************************************************** + * + * cache + * + ***********************************************************************/ +/** + * container initialization + * + * @param container_ptr_ptr A pointer to a container pointer. If you + * create a custom container, use this parameter to return it + * to the MFD helper. If set to NULL, the MFD helper will + * allocate a container for you. + * @param cache A pointer to a cache structure. You can set the timeout + * and other cache flags using this pointer. + * + * This function is called at startup to allow you to customize certain + * aspects of the access method. For the most part, it is for advanced + * users. The default code should suffice for most cases. If no custom + * container is allocated, the MFD code will create one for your. + * + * This is also the place to set up cache behavior. The default, to + * simply set the cache timeout, will work well with the default + * container. If you are using a custom container, you may want to + * look at the cache helper documentation to see if there are any + * flags you want to set. + * + * @remark + * This would also be a good place to do any initialization needed + * for you data source. For example, opening a connection to another + * process that will supply the data, opening a database, etc. + */ +void +pgsqlPgAggregateTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_container_init","called\n")); + + if((NULL == cache) || (NULL == container_ptr_ptr)) { + snmp_log(LOG_ERR,"bad params to pgsqlPgAggregateTable_container_init\n"); + return; + } + + /* + * For advanced users, you can use a custom container. If you + * do not create one, one will be created for you. + */ + *container_ptr_ptr = NULL; + + /* + * TODO:345:A: Set up pgsqlPgAggregateTable cache properties. + * + * Also for advanced users, you can set parameters for the + * cache. Do not change the magic pointer, as it is used + * by the MFD helper. To completely disable caching, set + * cache->enabled to 0. + */ + cache->timeout = PGSQLPGAGGREGATETABLE_CACHE_TIMEOUT; /* seconds */ +} /* pgsqlPgAggregateTable_container_init */ + +/** + * load cache data + * + * TODO:350:M: Implement pgsqlPgAggregateTable cache load + * + * @param container container to which items should be inserted + * + * @retval MFD_SUCCESS : success. + * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source + * @retval MFD_ERROR : other error. + * + * This function is called to cache the index(es) (and data, optionally) + * for the every row in the data set. + * + * @remark + * While loading the cache, the only important thing is the indexes. + * If access to your data is cheap/fast (e.g. you have a pointer to a + * structure in memory), it would make sense to update the data here. + * If, however, the accessing the data invovles more work (e.g. parsing + * some other existing data, or peforming calculations to derive the data), + * then you can limit yourself to setting the indexes and saving any + * information you will need later. Then use the saved information in + * pgsqlPgAggregateTable_row_prep() for populating data. + * + * @note + * If you need consistency between rows (like you want statistics + * for each row to be from the same time frame), you should set all + * data here. + * + */ +int +pgsqlPgAggregateTable_cache_load(netsnmp_container *container) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx; + size_t count = 0; + + char pgsnmpdConnID[112] = "Default conn ID"; + size_t pgsnmpdConnID_len = strlen(pgsnmpdConnID); + long rdbmsDbIndex = 1; + int i, resultCount, tmpInt; + char *tmpString; + PGresult *pg_db_qry; + +snmp_log(LOG_INFO, "Running pgsqlPgAggregateTable\n"); + if (PQstatus(dbconn) == CONNECTION_OK) + pg_db_qry = PQexec(dbconn, "SELECT aggfnoid::INTEGER, aggfnoid, aggtransfn, aggfinalfn, aggsortop, aggtranstype, agginitval FROM pg_aggregate ORDER BY 1 ASC"); + else { + snmp_log(LOG_ERR, "Can't get connected to database\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_cache_load","called\n")); + + if (PQresultStatus(pg_db_qry) != PGRES_TUPLES_OK) { + snmp_log(LOG_ERR, "Didn't get any results from the database\n"); + PQclear(pg_db_qry); + return MFD_RESOURCE_UNAVAILABLE; + } + resultCount = PQntuples(pg_db_qry); + + /* + * TODO:351:M: |-> Load/update data in the pgsqlPgAggregateTable container. + * loop over your pgsqlPgAggregateTable data, allocate a rowreq context, + * set the index(es) [and data, optionally] and insert into + * the container. + */ + for (i = 0; i < resultCount; i++) { + + /* + * TODO:352:M: | |-> set indexes in new pgsqlPgAggregateTable rowreq context. + */ + rowreq_ctx = pgsqlPgAggregateTable_allocate_rowreq_ctx(); + if (NULL == rowreq_ctx) { + snmp_log(LOG_ERR, "memory allocation failed\n"); + return MFD_RESOURCE_UNAVAILABLE; + } + if(MFD_SUCCESS != pgsqlPgAggregateTable_indexes_set(rowreq_ctx + , pgsnmpdConnID, pgsnmpdConnID_len + , rdbmsDbIndex + , atol(PQgetvalue(pg_db_qry, i, 0)) + )) { + snmp_log(LOG_ERR,"error setting index while loading " + "pgsqlPgAggregateTable cache.\n"); + pgsqlPgAggregateTable_release_rowreq_ctx(rowreq_ctx); + continue; + } + rowreq_ctx->data.pgsqlPgAggregateAgginitval_len = 255; + + rowreq_ctx->data.pgsqlPgAggregateAggfnoid = strtoul(PQgetvalue(pg_db_qry, i, 1), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggtransfn = strtoul(PQgetvalue(pg_db_qry, i, 2), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggfinalfn = strtoul(PQgetvalue(pg_db_qry, i, 3), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggsortop = strtoul(PQgetvalue(pg_db_qry, i, 4), NULL, 10); + + rowreq_ctx->data.pgsqlPgAggregateAggtranstype = strtoul(PQgetvalue(pg_db_qry, i, 5), NULL, 10); + + tmpString = PQgetvalue(pg_db_qry, i, 6); + tmpInt = strlen(tmpString); + if ((NULL == rowreq_ctx->data.pgsqlPgAggregateAgginitval) || + (rowreq_ctx->data.pgsqlPgAggregateAgginitval_len < (tmpInt * sizeof(rowreq_ctx->data.pgsqlPgAggregateAgginitval[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + rowreq_ctx->data.pgsqlPgAggregateAgginitval_len = tmpInt * sizeof(rowreq_ctx->data.pgsqlPgAggregateAgginitval[0]); + memcpy( rowreq_ctx->data.pgsqlPgAggregateAgginitval, tmpString, rowreq_ctx->data.pgsqlPgAggregateAgginitval_len ); + + + /* + * insert into table container + */ + CONTAINER_INSERT(container, rowreq_ctx); + ++count; + } + + + DEBUGMSGT(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_cache_load", + "inserted %d records\n", count)); + PQclear(pg_db_qry); + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_cache_load */ + +/** + * cache clean up + * + * @param container container with all current items + * + * This optional callback is called prior to all + * item's being removed from the container. If you + * need to do any processing before that, do it here. + * + * @note + * The MFD helper will take care of releasing all the row contexts. + * + */ +void +pgsqlPgAggregateTable_cache_free(netsnmp_container *container) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_cache_free","called\n")); + + /* + * TODO:380:M: Free pgsqlPgAggregateTable cache. + */ +} /* pgsqlPgAggregateTable_cache_free */ + +/** + * prepare row for processing. + * + * When the agent has located the row for a request, this function is + * called to prepare the row for processing. If you fully populated + * the data context during the index setup phase, you may not need to + * do anything. + * + * @param rowreq_ctx pointer to a context. + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + */ +int +pgsqlPgAggregateTable_row_prep( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_row_prep","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + /* + * TODO:390:o: Prepare row for request. + * If populating row data was delayed, this is the place to + * fill in the row for this request. + */ + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_row_prep */ + +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.h new file mode 100644 index 0000000..6831083 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_access.h @@ -0,0 +1,70 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.12 $ of : mfd-data-access.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_access.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_DATA_ACCESS_H +#define PGSQLPGAGGREGATETABLE_DATA_ACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ********************************************************************* + * function declarations + */ + +/* ********************************************************************* + * Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + + + int pgsqlPgAggregateTable_init_data(pgsqlPgAggregateTable_registration_ptr pgsqlPgAggregateTable_reg); + + +/* + * TODO:180:o: Review pgsqlPgAggregateTable cache timeout. + * The number of seconds before the cache times out + */ +#define PGSQLPGAGGREGATETABLE_CACHE_TIMEOUT 60 + +void pgsqlPgAggregateTable_container_init(netsnmp_container **container_ptr_ptr, + netsnmp_cache *cache); +int pgsqlPgAggregateTable_cache_load(netsnmp_container *container); +void pgsqlPgAggregateTable_cache_free(netsnmp_container *container); + + /* + *************************************************** + *** START EXAMPLE CODE *** + ***---------------------------------------------***/ +/* ********************************************************************* + * Since we have no idea how you really access your data, we'll go with + * a worst case example: a flat text file. + */ +#define MAX_LINE_SIZE 256 + /* + ***---------------------------------------------*** + *** END EXAMPLE CODE *** + ***************************************************/ + int pgsqlPgAggregateTable_row_prep( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx); + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_DATA_ACCESS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.c new file mode 100644 index 0000000..c156328 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.c @@ -0,0 +1,839 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_get.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/* standard Net-SNMP includes */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + + +/** @defgroup data_get data_get: Routines to get data + * + * TODO:230:M: Implement pgsqlPgAggregateTable get routines. + * TODO:240:M: Implement pgsqlPgAggregateTable mapping routines (if any). + * + * These routine are used to get the value for individual objects. The + * row context is passed, along with a pointer to the memory where the + * value should be copied. + * + * @{ + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + +/* --------------------------------------------------------------------- + * TODO:200:r: Implement pgsqlPgAggregateTable data context functions. + */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsnmpdConnectionEntry.pgsnmpdConnID + * pgsnmpdConnID is subid 1 of pgsnmpdConnectionEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.1.1.1.1 + * Description: +Identifying string for this connection. Default is host:port:database. + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + * + * + * + * NOTE: NODE pgsnmpdConnID IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsnmpdConnID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsnmpdConnID_map(char **mib_pgsnmpdConnID_val_ptr_ptr, size_t *mib_pgsnmpdConnID_val_ptr_len_ptr, char *raw_pgsnmpdConnID_val_ptr, size_t raw_pgsnmpdConnID_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_pgsnmpdConnID_val_ptr); + netsnmp_assert((NULL != mib_pgsnmpdConnID_val_ptr_ptr) && (NULL != mib_pgsnmpdConnID_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsnmpdConnID_map","called\n")); + + /* + * TODO:241:r: |-> Implement pgsnmpdConnID non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_pgsnmpdConnID_val_ptr_len; /* assume equal */ + if((NULL == *mib_pgsnmpdConnID_val_ptr_ptr) || (*mib_pgsnmpdConnID_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_pgsnmpdConnID_val_ptr_ptr = realloc( *mib_pgsnmpdConnID_val_ptr_ptr, converted_len * sizeof(**mib_pgsnmpdConnID_val_ptr_ptr)); + if(NULL == *mib_pgsnmpdConnID_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_pgsnmpdConnID_val_ptr_len_ptr = converted_len; + memcpy( *mib_pgsnmpdConnID_val_ptr_ptr, raw_pgsnmpdConnID_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* pgsnmpdConnID_map */ + + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateEntryOID + * pgsqlPgAggregateEntryOID is subid 1 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is NoAccess. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.1 + * Description: +OID of this entry + * + * Attributes: + * accessible 0 isscalar 0 enums 0 hasdefval 0 + * readable 0 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + * + * + * + * NOTE: NODE pgsqlPgAggregateEntryOID IS NOT ACCESSIBLE + * + * + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateEntryOID.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateEntryOID_map(long *mib_pgsqlPgAggregateEntryOID_val_ptr, long raw_pgsqlPgAggregateEntryOID_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateEntryOID_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateEntryOID_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateEntryOID mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateEntryOID_val_ptr) = raw_pgsqlPgAggregateEntryOID_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateEntryOID_map */ + + +/** + * set mib index(es) + * + * @param tbl_idx mib index structure + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This convenience function is useful for setting all the MIB index + * components with a single function call. It is assume that the C values + * have already been mapped from their native/rawformat to the MIB format. + */ +int +pgsqlPgAggregateTable_indexes_set_tbl_idx(pgsqlPgAggregateTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_indexes_set_tbl_idx","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + tbl_idx->pgsnmpdConnID_len = sizeof(tbl_idx->pgsnmpdConnID); + /* + * make sure there is enough space for pgsnmpdConnID data + */ + if ((NULL == tbl_idx->pgsnmpdConnID) || + (tbl_idx->pgsnmpdConnID_len < (pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0])))) { + snmp_log(LOG_ERR,"not enough space for value\n"); + return MFD_ERROR; + } + tbl_idx->pgsnmpdConnID_len = pgsnmpdConnID_val_ptr_len * sizeof(tbl_idx->pgsnmpdConnID[0]); + memcpy( tbl_idx->pgsnmpdConnID, pgsnmpdConnID_val_ptr, tbl_idx->pgsnmpdConnID_len ); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + tbl_idx->rdbmsDbIndex = rdbmsDbIndex_val; + + /* pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h */ + tbl_idx->pgsqlPgAggregateEntryOID = pgsqlPgAggregateEntryOID_val; + + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_indexes_set_tbl_idx */ + +/** + * @internal + * set row context indexes + * + * @param reqreq_ctx the row context that needs updated indexes + * + * @retval MFD_SUCCESS : success. + * @retval MFD_ERROR : other error. + * + * @remark + * This function sets the mib indexs, then updates the oid indexs + * from the mib index. + */ +int +pgsqlPgAggregateTable_indexes_set(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val) +{ + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_indexes_set","called\n")); + + if(MFD_SUCCESS != pgsqlPgAggregateTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx + , pgsnmpdConnID_val_ptr, pgsnmpdConnID_val_ptr_len + , rdbmsDbIndex_val + , pgsqlPgAggregateEntryOID_val + )) + return MFD_ERROR; + + /* + * convert mib index to oid index + */ + rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid); + if(0 != pgsqlPgAggregateTable_index_to_oid(&rowreq_ctx->oid_idx, + &rowreq_ctx->tbl_idx)) { + return MFD_ERROR; + } + + return MFD_SUCCESS; +} /* pgsqlPgAggregateTable_indexes_set */ + + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggfnoid + * pgsqlPgAggregateAggfnoid is subid 2 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.2 + * Description: +pg_proc OID of the aggregate function + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggfnoid.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggfnoid_map(long *mib_pgsqlPgAggregateAggfnoid_val_ptr, long raw_pgsqlPgAggregateAggfnoid_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggfnoid_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfnoid_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggfnoid mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggfnoid_val_ptr) = raw_pgsqlPgAggregateAggfnoid_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfnoid_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggfnoid data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggfnoid_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggfnoid_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfnoid_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggfnoid_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfnoid_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggfnoid data. + * set (* pgsqlPgAggregateAggfnoid_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggfnoid_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggfnoid; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfnoid_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggtransfn + * pgsqlPgAggregateAggtransfn is subid 3 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.3 + * Description: +Transition function + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggtransfn.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggtransfn_map(long *mib_pgsqlPgAggregateAggtransfn_val_ptr, long raw_pgsqlPgAggregateAggtransfn_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggtransfn_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtransfn_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggtransfn mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggtransfn_val_ptr) = raw_pgsqlPgAggregateAggtransfn_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtransfn_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggtransfn data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggtransfn_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggtransfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtransfn_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggtransfn_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtransfn_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggtransfn data. + * set (* pgsqlPgAggregateAggtransfn_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggtransfn_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggtransfn; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtransfn_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggfinalfn + * pgsqlPgAggregateAggfinalfn is subid 4 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.4 + * Description: +Final function (zero if none) + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggfinalfn.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggfinalfn_map(long *mib_pgsqlPgAggregateAggfinalfn_val_ptr, long raw_pgsqlPgAggregateAggfinalfn_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggfinalfn_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfinalfn_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggfinalfn mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggfinalfn_val_ptr) = raw_pgsqlPgAggregateAggfinalfn_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfinalfn_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggfinalfn data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggfinalfn_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggfinalfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfinalfn_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggfinalfn_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggfinalfn_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggfinalfn data. + * set (* pgsqlPgAggregateAggfinalfn_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggfinalfn_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggfinalfn; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggfinalfn_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggsortop + * pgsqlPgAggregateAggsortop is subid 5 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.5 + * Description: +Associated sort operator (zero if none) + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggsortop.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggsortop_map(long *mib_pgsqlPgAggregateAggsortop_val_ptr, long raw_pgsqlPgAggregateAggsortop_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggsortop_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggsortop_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggsortop mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggsortop_val_ptr) = raw_pgsqlPgAggregateAggsortop_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggsortop_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggsortop data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggsortop_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggsortop_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggsortop_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggsortop_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggsortop_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggsortop data. + * set (* pgsqlPgAggregateAggsortop_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggsortop_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggsortop; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggsortop_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAggtranstype + * pgsqlPgAggregateAggtranstype is subid 6 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.6 + * Description: +Data type of the aggregate function's internal transition (state) data + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 0 hashint 0 + * settable 0 + * + * + * Its syntax is INTEGER (based on perltype INTEGER) + * The net-snmp type is ASN_INTEGER. The C type decl is long (long) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAggtranstype.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAggtranstype_map(long *mib_pgsqlPgAggregateAggtranstype_val_ptr, long raw_pgsqlPgAggregateAggtranstype_val) +{ + netsnmp_assert(NULL != mib_pgsqlPgAggregateAggtranstype_val_ptr); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtranstype_map","called\n")); + + /* + * TODO:241:o: |-> Implement pgsqlPgAggregateAggtranstype mapping. + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + */ + (*mib_pgsqlPgAggregateAggtranstype_val_ptr) = raw_pgsqlPgAggregateAggtranstype_val; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtranstype_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAggtranstype data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAggtranstype_val_ptr + * Pointer to storage for a long variable + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error + */ +int +pgsqlPgAggregateAggtranstype_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtranstype_val_ptr ) +{ + /** we should have a non-NULL pointer */ + netsnmp_assert( NULL != pgsqlPgAggregateAggtranstype_val_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAggtranstype_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAggtranstype data. + * set (* pgsqlPgAggregateAggtranstype_val_ptr ) from rowreq_ctx->data + */ + (* pgsqlPgAggregateAggtranstype_val_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAggtranstype; + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAggtranstype_get */ + +/*--------------------------------------------------------------------- + * PGSQL-MIB::pgsqlPgAggregateEntry.pgsqlPgAggregateAgginitval + * pgsqlPgAggregateAgginitval is subid 7 of pgsqlPgAggregateEntry. + * Its status is Current, and its access level is ReadOnly. + * OID: .1.3.6.1.4.1.27645.1.2.1.1.7 + * Description: +The initial value of the transition state. This is a text field containing the initial value in its external string representation. If this field is NULL, the transition state value starts out NULL + * + * Attributes: + * accessible 1 isscalar 0 enums 0 hasdefval 0 + * readable 1 iscolumn 1 ranges 1 hashint 1 + * settable 0 + * hint: 255a + * + * Ranges: 0 - 255; + * + * Its syntax is DisplayString (based on perltype OCTETSTR) + * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) + * This data type requires a length. (Max 255) + */ +/** + * map a value from its original native format to the MIB format. + * + * @retval MFD_SUCCESS : success + * @retval MFD_ERROR : Any other error + * + * @note parameters follow the memset convention (dest, src). + * + * @note generation and use of this function can be turned off by re-running + * mib2c after adding the following line to the file + * default-node-pgsqlPgAggregateAgginitval.m2d : + * @eval $m2c_node_skip_mapping = 1@ + * + * @remark + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them here. + * Otherwise, just do a direct copy. + */ +int +pgsqlPgAggregateAgginitval_map(char **mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr, char *raw_pgsqlPgAggregateAgginitval_val_ptr, size_t raw_pgsqlPgAggregateAgginitval_val_ptr_len, int allow_realloc) +{ + int converted_len; + + netsnmp_assert(NULL != raw_pgsqlPgAggregateAgginitval_val_ptr); + netsnmp_assert((NULL != mib_pgsqlPgAggregateAgginitval_val_ptr_ptr) && (NULL != mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr)); + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAgginitval_map","called\n")); + + /* + * TODO:241:r: |-> Implement pgsqlPgAggregateAgginitval non-integer mapping + * it is hard to autogenerate code for mapping types that are not simple + * integers, so here is an idea of what you might need to do. It will + * probably need some tweaking to get right. + */ + /* + * if the length of the raw data doesn't directly correspond with + * the length of the mib data, set converted_len to the + * space required. + */ + converted_len = raw_pgsqlPgAggregateAgginitval_val_ptr_len; /* assume equal */ + if((NULL == *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr) || (*mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr < converted_len)) { + if(! allow_realloc) { + snmp_log(LOG_ERR,"not enough space for value mapping\n"); + return SNMP_ERR_GENERR; + } + *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr = realloc( *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, converted_len * sizeof(**mib_pgsqlPgAggregateAgginitval_val_ptr_ptr)); + if(NULL == *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return SNMP_ERR_GENERR; + } + } + *mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr = converted_len; + memcpy( *mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, raw_pgsqlPgAggregateAgginitval_val_ptr, converted_len ); + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAgginitval_map */ + +/** + * Extract the current value of the pgsqlPgAggregateAgginitval data. + * + * Set a value using the data context for the row. + * + * @param rowreq_ctx + * Pointer to the row request context. + * @param pgsqlPgAggregateAgginitval_val_ptr_ptr + * Pointer to storage for a char variable + * @param pgsqlPgAggregateAgginitval_val_ptr_len_ptr + * Pointer to a size_t. On entry, it will contain the size (in bytes) + * pointed to by pgsqlPgAggregateAgginitval. + * On exit, this value should contain the data size (in bytes). + * + * @retval MFD_SUCCESS : success + * @retval MFD_SKIP : skip this node (no value for now) + * @retval MFD_ERROR : Any other error +* + * @note If you need more than (*pgsqlPgAggregateAgginitval_val_ptr_len_ptr) bytes of memory, + * allocate it using malloc() and update pgsqlPgAggregateAgginitval_val_ptr_ptr. + * <b>DO NOT</b> free the previous pointer. + * The MFD helper will release the memory you allocate. + * + * @remark If you call this function yourself, you are responsible + * for checking if the pointer changed, and freeing any + * previously allocated memory. (Not necessary if you pass + * in a pointer to static memory, obviously.) + */ +int +pgsqlPgAggregateAgginitval_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char **pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) +{ + /** we should have a non-NULL pointer and enough storage */ + netsnmp_assert( (NULL != pgsqlPgAggregateAgginitval_val_ptr_ptr) && (NULL != *pgsqlPgAggregateAgginitval_val_ptr_ptr)); + netsnmp_assert( NULL != pgsqlPgAggregateAgginitval_val_ptr_len_ptr ); + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateAgginitval_get","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + +/* + * TODO:231:o: |-> Extract the current value of the pgsqlPgAggregateAgginitval data. + * set (* pgsqlPgAggregateAgginitval_val_ptr_ptr ) and (* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) from rowreq_ctx->data + */ + /* + * make sure there is enough space for pgsqlPgAggregateAgginitval data + */ + if ((NULL == (* pgsqlPgAggregateAgginitval_val_ptr_ptr )) || + ((* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) < (rowreq_ctx->data.pgsqlPgAggregateAgginitval_len * sizeof((* pgsqlPgAggregateAgginitval_val_ptr_ptr )[0])))) { + /* + * allocate space for pgsqlPgAggregateAgginitval data + */ + (* pgsqlPgAggregateAgginitval_val_ptr_ptr ) = malloc(rowreq_ctx->data.pgsqlPgAggregateAgginitval_len * sizeof((* pgsqlPgAggregateAgginitval_val_ptr_ptr )[0])); + if(NULL == (* pgsqlPgAggregateAgginitval_val_ptr_ptr )) { + snmp_log(LOG_ERR,"could not allocate memory\n"); + return MFD_ERROR; + } + } + (* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) = rowreq_ctx->data.pgsqlPgAggregateAgginitval_len * sizeof((* pgsqlPgAggregateAgginitval_val_ptr_ptr )[0]); + memcpy( (* pgsqlPgAggregateAgginitval_val_ptr_ptr ), rowreq_ctx->data.pgsqlPgAggregateAgginitval, (* pgsqlPgAggregateAgginitval_val_ptr_len_ptr ) ); + + return MFD_SUCCESS; +} /* pgsqlPgAggregateAgginitval_get */ + + + +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.h new file mode 100644 index 0000000..c5c1e73 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_get.h @@ -0,0 +1,72 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18.2.1 $ of : mfd-data-get.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_get.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + * + * @file pgsqlPgAggregateTable_data_get.h + * + * @addtogroup get + * + * Prototypes for get functions + * + * @{ + */ +#ifndef PGSQLPGAGGREGATETABLE_DATA_GET_H +#define PGSQLPGAGGREGATETABLE_DATA_GET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * GET function declarations + */ + +/* ********************************************************************* + * GET Table declarations + */ +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ + /* + * indexes + */ + int pgsnmpdConnID_map(char **mib_pgsnmpdConnID_val_ptr_ptr, size_t *mib_pgsnmpdConnID_val_ptr_len_ptr, char *raw_pgsnmpdConnID_val_ptr, size_t raw_pgsnmpdConnID_val_ptr_len, int allow_realloc); + int pgsqlPgAggregateEntryOID_map(long *mib_pgsqlPgAggregateEntryOID_val_ptr, long raw_pgsqlPgAggregateEntryOID_val); + + int pgsqlPgAggregateAggfnoid_map(long *mib_pgsqlPgAggregateAggfnoid_val_ptr, long raw_pgsqlPgAggregateAggfnoid_val); + int pgsqlPgAggregateAggfnoid_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfnoid_val_ptr ); + int pgsqlPgAggregateAggtransfn_map(long *mib_pgsqlPgAggregateAggtransfn_val_ptr, long raw_pgsqlPgAggregateAggtransfn_val); + int pgsqlPgAggregateAggtransfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtransfn_val_ptr ); + int pgsqlPgAggregateAggfinalfn_map(long *mib_pgsqlPgAggregateAggfinalfn_val_ptr, long raw_pgsqlPgAggregateAggfinalfn_val); + int pgsqlPgAggregateAggfinalfn_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggfinalfn_val_ptr ); + int pgsqlPgAggregateAggsortop_map(long *mib_pgsqlPgAggregateAggsortop_val_ptr, long raw_pgsqlPgAggregateAggsortop_val); + int pgsqlPgAggregateAggsortop_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggsortop_val_ptr ); + int pgsqlPgAggregateAggtranstype_map(long *mib_pgsqlPgAggregateAggtranstype_val_ptr, long raw_pgsqlPgAggregateAggtranstype_val); + int pgsqlPgAggregateAggtranstype_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, long * pgsqlPgAggregateAggtranstype_val_ptr ); + int pgsqlPgAggregateAgginitval_map(char **mib_pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *mib_pgsqlPgAggregateAgginitval_val_ptr_len_ptr, char *raw_pgsqlPgAggregateAgginitval_val_ptr, size_t raw_pgsqlPgAggregateAgginitval_val_ptr_len, int allow_realloc); + int pgsqlPgAggregateAgginitval_get( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char **pgsqlPgAggregateAgginitval_val_ptr_ptr, size_t *pgsqlPgAggregateAgginitval_val_ptr_len_ptr ); + + +int pgsqlPgAggregateTable_indexes_set_tbl_idx(pgsqlPgAggregateTable_mib_index *tbl_idx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val); +int pgsqlPgAggregateTable_indexes_set(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, char *pgsnmpdConnID_val_ptr, size_t pgsnmpdConnID_val_ptr_len, long rdbmsDbIndex_val, long pgsqlPgAggregateEntryOID_val); + + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_DATA_GET_H */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.c new file mode 100644 index 0000000..b266046 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.c @@ -0,0 +1,24 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_set.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + * + */ +/* standard Net-SNMP includes */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + + +/** @defgroup data_set data_set: Routines to set data + * + * These routines are used to set the value for individual objects. The + * row context is passed, along with the new value. + * + * @{ + */ +/** @} */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.h new file mode 100644 index 0000000..52061bc --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_data_set.h @@ -0,0 +1,27 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.18 $ of : mfd-data-set.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_data_set.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_DATA_SET_H +#define PGSQLPGAGGREGATETABLE_DATA_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* ********************************************************************* + * SET function declarations + */ + +/* ********************************************************************* + * SET Table declarations + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_DATA_SET_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_enums.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_enums.h new file mode 100644 index 0000000..161cc07 --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_enums.h @@ -0,0 +1,40 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-enums.m2c,v 1.3 2004/05/18 17:44:32 rstory Exp $ + * + * $Id: pgsqlPgAggregateTable_enums.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_ENUMS_H +#define PGSQLPGAGGREGATETABLE_ENUMS_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * NOTES on enums + * ============== + * + * Value Mapping + * ------------- + * If the values for your data type don't exactly match the + * possible values defined by the mib, you should map them + * below. For example, a boolean flag (1/0) is usually represented + * as a TruthValue in a MIB, which maps to the values (1/2). + * + */ +/************************************************************************* + ************************************************************************* + * + * enum definitions for table pgsqlPgAggregateTable + * + ************************************************************************* + *************************************************************************/ + + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_ENUMS_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.c b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.c new file mode 100644 index 0000000..8215a2d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.c @@ -0,0 +1,784 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_interface.c,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ + +/* standard Net-SNMP includes */ +#include <net-snmp/net-snmp-config.h> +#include <net-snmp/net-snmp-includes.h> +#include <net-snmp/agent/net-snmp-agent-includes.h> + +/* include our parent header */ +#include "pgsqlPgAggregateTable.h" + + +#include <net-snmp/library/container.h> + +#include "pgsqlPgAggregateTable_interface.h" + +/********************************************************************** + ********************************************************************** + *** + *** Table pgsqlPgAggregateTable + *** + ********************************************************************** + **********************************************************************/ +/* + * pgsqlPgAggregateTable is subid 1 of pgsqlCatalogTables. + * Its status is Current. + * OID: .1.3.6.1.4.1.27645.1.2.1, length: 10 +*/ +typedef struct pgsqlPgAggregateTable_interface_ctx_s { + + netsnmp_container *container; + netsnmp_cache *cache; /* optional cache */ + + pgsqlPgAggregateTable_registration_ptr user_ctx; + + netsnmp_table_registration_info tbl_info; + + netsnmp_baby_steps_access_methods access_multiplexer; + +} pgsqlPgAggregateTable_interface_ctx; + +static pgsqlPgAggregateTable_interface_ctx pgsqlPgAggregateTable_if_ctx; + +static void _pgsqlPgAggregateTable_container_init( + pgsqlPgAggregateTable_interface_ctx *if_ctx); + + +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_pre_request; +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_post_request; +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_object_lookup; +static Netsnmp_Node_Handler _mfd_pgsqlPgAggregateTable_get_values; +/** + * @internal + * Initialize the table pgsqlPgAggregateTable + * (Define its contents and how it's structured) + */ +void +_pgsqlPgAggregateTable_initialize_interface(pgsqlPgAggregateTable_registration_ptr reg_ptr, u_long flags) +{ + netsnmp_baby_steps_access_methods *access_multiplexer = + &pgsqlPgAggregateTable_if_ctx.access_multiplexer; + netsnmp_table_registration_info *tbl_info = &pgsqlPgAggregateTable_if_ctx.tbl_info; + netsnmp_handler_registration *reginfo; + netsnmp_mib_handler *handler; + int mfd_modes = 0; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_pgsqlPgAggregateTable_initialize_interface","called\n")); + + + /************************************************* + * + * save interface context for pgsqlPgAggregateTable + */ + /* + * Setting up the table's definition + */ + netsnmp_table_helper_add_indexes(tbl_info, + ASN_OCTET_STR, /** index: pgsnmpdConnID */ + ASN_INTEGER, /** index: rdbmsDbIndex */ + ASN_INTEGER, /** index: pgsqlPgAggregateEntryOID */ + 0); + + /* Define the minimum and maximum accessible columns. This + optimizes retrival. */ + tbl_info->min_column = PGSQLPGAGGREGATETABLE_MIN_COL; + tbl_info->max_column = PGSQLPGAGGREGATETABLE_MAX_COL; + + /* + * save users context + */ + pgsqlPgAggregateTable_if_ctx.user_ctx = reg_ptr; + + /* + * call data access initialization code + */ + pgsqlPgAggregateTable_init_data(reg_ptr); + + /* + * set up the container + */ + _pgsqlPgAggregateTable_container_init(&pgsqlPgAggregateTable_if_ctx); + if (NULL == pgsqlPgAggregateTable_if_ctx.container) { + snmp_log(LOG_ERR,"could not initialize container for pgsqlPgAggregateTable\n"); + return; + } + + /* + * access_multiplexer: REQUIRED wrapper for get request handling + */ + access_multiplexer->object_lookup = _mfd_pgsqlPgAggregateTable_object_lookup; + access_multiplexer->get_values = _mfd_pgsqlPgAggregateTable_get_values; + + /* + * no wrappers yet + */ + access_multiplexer->pre_request = _mfd_pgsqlPgAggregateTable_pre_request; + access_multiplexer->post_request = _mfd_pgsqlPgAggregateTable_post_request; + + + /************************************************* + * + * Create a registration, save our reg data, register table. + */ + DEBUGMSGTL(("pgsqlPgAggregateTable:init_pgsqlPgAggregateTable", + "Registering pgsqlPgAggregateTable as a mibs-for-dummies table.\n")); + handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); + reginfo = netsnmp_handler_registration_create("pgsqlPgAggregateTable", handler, + pgsqlPgAggregateTable_oid, + pgsqlPgAggregateTable_oid_size, + HANDLER_CAN_BABY_STEP | + HANDLER_CAN_RONLY + ); + if(NULL == reginfo) { + snmp_log(LOG_ERR,"error registering table pgsqlPgAggregateTable\n"); + return; + } + reginfo->my_reg_void = &pgsqlPgAggregateTable_if_ctx; + + /************************************************* + * + * set up baby steps handler, create it and inject it + */ + if( access_multiplexer->object_lookup ) + mfd_modes |= BABY_STEP_OBJECT_LOOKUP; + if( access_multiplexer->set_values ) + mfd_modes |= BABY_STEP_SET_VALUES; + if( access_multiplexer->irreversible_commit ) + mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; + if( access_multiplexer->object_syntax_checks ) + mfd_modes |= BABY_STEP_CHECK_OBJECT; + + if( access_multiplexer->pre_request ) + mfd_modes |= BABY_STEP_PRE_REQUEST; + if( access_multiplexer->post_request ) + mfd_modes |= BABY_STEP_POST_REQUEST; + + if( access_multiplexer->undo_setup ) + mfd_modes |= BABY_STEP_UNDO_SETUP; + if( access_multiplexer->undo_cleanup ) + mfd_modes |= BABY_STEP_UNDO_CLEANUP; + if( access_multiplexer->undo_sets ) + mfd_modes |= BABY_STEP_UNDO_SETS; + + if( access_multiplexer->row_creation ) + mfd_modes |= BABY_STEP_ROW_CREATE; + if( access_multiplexer->consistency_checks ) + mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; + if( access_multiplexer->commit ) + mfd_modes |= BABY_STEP_COMMIT; + if( access_multiplexer->undo_commit ) + mfd_modes |= BABY_STEP_UNDO_COMMIT; + + handler = netsnmp_baby_steps_handler_get(mfd_modes); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject row_merge helper with prefix rootoid_len + 2 (entry.col) + */ + handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); + netsnmp_inject_handler(reginfo, handler); + + /************************************************* + * + * inject container_table helper + */ + handler = + netsnmp_container_table_handler_get(tbl_info, + pgsqlPgAggregateTable_if_ctx.container, + TABLE_CONTAINER_KEY_NETSNMP_INDEX); + netsnmp_inject_handler( reginfo, handler ); + + /************************************************* + * + * inject cache helper + */ + if(NULL != pgsqlPgAggregateTable_if_ctx.cache) { + handler = netsnmp_cache_handler_get(pgsqlPgAggregateTable_if_ctx.cache); + netsnmp_inject_handler( reginfo, handler ); + } + + /* + * register table + */ + netsnmp_register_table(reginfo, tbl_info); +} /* _pgsqlPgAggregateTable_initialize_interface */ + +void +pgsqlPgAggregateTable_valid_columns_set(netsnmp_column_info *vc) +{ + pgsqlPgAggregateTable_if_ctx.tbl_info.valid_columns = vc; +} /* pgsqlPgAggregateTable_valid_columns_set */ + +/** + * @internal + * convert the index component stored in the context to an oid + */ +int +pgsqlPgAggregateTable_index_to_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + netsnmp_variable_list var_pgsqlPgAggregateEntryOID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_pgsqlPgAggregateEntryOID, 0x00, sizeof(var_pgsqlPgAggregateEntryOID) ); + var_pgsqlPgAggregateEntryOID.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = &var_rdbmsDbIndex; var_rdbmsDbIndex.next_variable = &var_pgsqlPgAggregateEntryOID; var_pgsqlPgAggregateEntryOID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_index_to_oid","called\n")); + + /* pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ + snmp_set_var_value(&var_pgsnmpdConnID, (u_char*)&mib_idx->pgsnmpdConnID, + mib_idx->pgsnmpdConnID_len * sizeof(mib_idx->pgsnmpdConnID[0])); + + /* rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ + snmp_set_var_value(&var_rdbmsDbIndex, (u_char*)&mib_idx->rdbmsDbIndex, + sizeof(mib_idx->rdbmsDbIndex)); + + /* pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h */ + snmp_set_var_value(&var_pgsqlPgAggregateEntryOID, (u_char*)&mib_idx->pgsqlPgAggregateEntryOID, + sizeof(mib_idx->pgsqlPgAggregateEntryOID)); + + + err = build_oid_noalloc(oid_idx->oids, oid_idx->len, (size_t *)&oid_idx->len, + NULL, 0, &var_pgsnmpdConnID); + if(err) + snmp_log(LOG_ERR,"error %d converting index to oid\n", err); + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsqlPgAggregateTable_index_to_oid */ + +/** + * extract pgsqlPgAggregateTable indexes from a netsnmp_index + * + * @retval SNMP_ERR_NOERROR : no error + * @retval SNMP_ERR_GENERR : error + */ +int +pgsqlPgAggregateTable_index_from_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx) +{ + int err = SNMP_ERR_NOERROR; + + /* + * temp storage for parsing indexes + */ + /* + * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H + */ + netsnmp_variable_list var_pgsnmpdConnID; + /* + * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h + */ + netsnmp_variable_list var_rdbmsDbIndex; + /* + * pgsqlPgAggregateEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h + */ + netsnmp_variable_list var_pgsqlPgAggregateEntryOID; + + /* + * set up varbinds + */ + memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); + var_pgsnmpdConnID.type = ASN_OCTET_STR; + memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); + var_rdbmsDbIndex.type = ASN_INTEGER; + memset( &var_pgsqlPgAggregateEntryOID, 0x00, sizeof(var_pgsqlPgAggregateEntryOID) ); + var_pgsqlPgAggregateEntryOID.type = ASN_INTEGER; + + /* + * chain temp index varbinds together + */ + var_pgsnmpdConnID.next_variable = &var_rdbmsDbIndex; var_rdbmsDbIndex.next_variable = &var_pgsqlPgAggregateEntryOID; var_pgsqlPgAggregateEntryOID.next_variable = NULL; + + + DEBUGMSGTL(("verbose:pgsqlPgAggregateTable:pgsqlPgAggregateTable_index_from_oid","called\n")); + + /* + * parse the oid into the individual index components + */ + err = parse_oid_indexes( oid_idx->oids, oid_idx->len, + &var_pgsnmpdConnID ); + if (err == SNMP_ERR_NOERROR) { + /* + * copy out values + */ + /* + * NOTE: val_len is in bytes, pgsnmpdConnID_len might not be + */ + if(var_pgsnmpdConnID.val_len > sizeof(mib_idx->pgsnmpdConnID)) + err = SNMP_ERR_GENERR; + else { + memcpy(mib_idx->pgsnmpdConnID, var_pgsnmpdConnID.val.string, var_pgsnmpdConnID.val_len); + mib_idx->pgsnmpdConnID_len = var_pgsnmpdConnID.val_len / sizeof(mib_idx->pgsnmpdConnID[0]); + } + mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); + mib_idx->pgsqlPgAggregateEntryOID = *((long *)var_pgsqlPgAggregateEntryOID.val.string); + + + } + + /* + * parsing may have allocated memory. free it. + */ + snmp_reset_var_buffers( &var_pgsnmpdConnID ); + + return err; +} /* pgsqlPgAggregateTable_index_from_oid */ + + +/* ********************************************************************* + * @internal + * allocate resources for a pgsqlPgAggregateTable_rowreq_ctx + */ +pgsqlPgAggregateTable_rowreq_ctx * +pgsqlPgAggregateTable_allocate_rowreq_ctx(void) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx = + SNMP_MALLOC_TYPEDEF(pgsqlPgAggregateTable_rowreq_ctx); + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:pgsqlPgAggregateTable_allocate_rowreq_ctx","called\n")); + + if(NULL == rowreq_ctx) { + snmp_log(LOG_ERR,"Couldn't allocate memory for a " + "pgsqlPgAggregateTable_rowreq_ctx.\n"); + } + + rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; + + rowreq_ctx->pgsqlPgAggregateTable_data_list = NULL; + rowreq_ctx->pgsqlPgAggregateTable_reg = pgsqlPgAggregateTable_if_ctx.user_ctx; + + + return rowreq_ctx; +} /* pgsqlPgAggregateTable_allocate_rowreq_ctx */ + +/* + * @internal + * release resources for a pgsqlPgAggregateTable_rowreq_ctx + */ +void +pgsqlPgAggregateTable_release_rowreq_ctx(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:pgsqlPgAggregateTable_release_rowreq_ctx","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + + /* + * free index oid pointer + */ + if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) + free(rowreq_ctx->oid_idx.oids); + + SNMP_FREE(rowreq_ctx); +} /* pgsqlPgAggregateTable_release_rowreq_ctx */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAggregateTable_pre_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + int rc = pgsqlPgAggregateTable_pre_request(pgsqlPgAggregateTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable","error %d from " + "pgsqlPgAggregateTable_pre_request\n", rc)); + netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_pre_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAggregateTable_post_request(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx; + int rc = pgsqlPgAggregateTable_post_request(pgsqlPgAggregateTable_if_ctx.user_ctx); + if (MFD_SUCCESS != rc) { + /* + * nothing we can do about it but log it + */ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable","error %d from " + "pgsqlPgAggregateTable_post_request\n", rc)); + } + + /* + * if there are no errors, check for and handle row creation/deletion + */ + rc = netsnmp_check_requests_error(requests); + if ((SNMP_ERR_NOERROR == rc) && + (NULL != + (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) { + if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { + rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; + CONTAINER_INSERT(pgsqlPgAggregateTable_if_ctx.container, rowreq_ctx); + } + else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { + CONTAINER_REMOVE(pgsqlPgAggregateTable_if_ctx.container, rowreq_ctx); + pgsqlPgAggregateTable_release_rowreq_ctx(rowreq_ctx); + } + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_post_request */ + +/** + * @internal + * wrapper + */ +static int +_mfd_pgsqlPgAggregateTable_object_lookup(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_mfd_pgsqlPgAggregateTable_object_lookup","called\n")); + + /* + * get our context from mfd + * pgsqlPgAggregateTable_interface_ctx *if_ctx = + * (pgsqlPgAggregateTable_interface_ctx *)reginfo->my_reg_void; + */ + + if(NULL == rowreq_ctx) { + netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION); + } + else { + pgsqlPgAggregateTable_row_prep(rowreq_ctx); + } + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_object_lookup */ + +/*********************************************************************** + * + * GET processing + * + ***********************************************************************/ +/* + * @internal + * Retrieve the value for a particular column + */ +NETSNMP_STATIC_INLINE int +_pgsqlPgAggregateTable_get_column( pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, + netsnmp_variable_list *var, int column ) +{ + int rc = SNMPERR_SUCCESS; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_mfd_pgsqlPgAggregateTable_get_column","called\n")); + + + netsnmp_assert(NULL != rowreq_ctx); + + switch(column) { + + /* pgsqlPgAggregateAggfnoid(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGFNOID: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggfnoid_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggtransfn(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGTRANSFN: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggtransfn_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggfinalfn(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGFINALFN: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggfinalfn_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggsortop(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGSORTOP: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggsortop_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAggtranstype(6)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ + case COLUMN_PGSQLPGAGGREGATEAGGTRANSTYPE: + var->val_len = sizeof(long); + var->type = ASN_INTEGER; +rc = pgsqlPgAggregateAggtranstype_get(rowreq_ctx, (long *)var->val.string ); + break; + + /* pgsqlPgAggregateAgginitval(7)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ + case COLUMN_PGSQLPGAGGREGATEAGGINITVAL: + var->type = ASN_OCTET_STR; +rc = pgsqlPgAggregateAgginitval_get(rowreq_ctx, (char **)&var->val.string, &var->val_len ); + break; + + default: + snmp_log(LOG_ERR,"unknown column %d in _pgsqlPgAggregateTable_get_column\n", column); + break; + } + + return rc; +} /* _pgsqlPgAggregateTable_get_column */ + +int +_mfd_pgsqlPgAggregateTable_get_values(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *agtreq_info, + netsnmp_request_info *requests) +{ + pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx = + netsnmp_container_table_row_extract(requests); + netsnmp_table_request_info * tri; + u_char * old_string; + void (*dataFreeHook)(void *); + int rc; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_mfd_pgsqlPgAggregateTable_get_values","called\n")); + + netsnmp_assert(NULL != rowreq_ctx); + + for(;requests; requests = requests->next) { + /* + * save old pointer, so we can free it if replaced + */ + old_string = requests->requestvb->val.string; + dataFreeHook = requests->requestvb->dataFreeHook; + if(NULL == requests->requestvb->val.string) { + requests->requestvb->val.string = requests->requestvb->buf; + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + else if(requests->requestvb->buf == requests->requestvb->val.string) { + if(requests->requestvb->val_len != sizeof(requests->requestvb->buf)) + requests->requestvb->val_len = sizeof(requests->requestvb->buf); + } + + /* + * get column data + */ + tri = netsnmp_extract_table_info(requests); + if(NULL == tri) + continue; + + rc = _pgsqlPgAggregateTable_get_column(rowreq_ctx, requests->requestvb, tri->colnum); + if(rc) { + if(MFD_SKIP == rc) { + requests->requestvb->type = ASN_PRIV_RETRY; + rc = SNMP_ERR_NOERROR; + } + } + else if (NULL == requests->requestvb->val.string) { + snmp_log(LOG_ERR,"NULL varbind data pointer!\n"); + rc = SNMP_ERR_GENERR; + } + if(rc) + netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); + + /* + * if the buffer wasn't used previously for the old data (i.e. it + * was allcoated memory) and the get routine replaced the pointer, + * we need to free the previous pointer. + */ + if(old_string && (old_string != requests->requestvb->buf) && + (requests->requestvb->val.string != old_string)) { + if(dataFreeHook) + (*dataFreeHook)(old_string); + else + free(old_string); + } + } /* for results */ + + return SNMP_ERR_NOERROR; +} /* _mfd_pgsqlPgAggregateTable_get_values */ + +/*********************************************************************** + * + * SET processing + * + ***********************************************************************/ + +/* + * NOT APPLICABLE (per MIB or user setting) + */ +/*********************************************************************** + * + * DATA ACCESS + * + ***********************************************************************/ +/** + * @internal + */ +static int +_cache_load(netsnmp_cache *cache, void *vmagic) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_cache_load","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache for pgsqlPgAggregateTable_cache_load\n"); + return -1; + } + + /** should only be called for an invalid or expired cache */ + netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); + + /* + * call user code + */ + return pgsqlPgAggregateTable_cache_load((netsnmp_container*)cache->magic); +} /* _cache_load */ + +/** + * @internal + */ +static void +_cache_item_free(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx, void *context) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_cache_item_free","called\n")); + + if(NULL == rowreq_ctx) + return; + + pgsqlPgAggregateTable_release_rowreq_ctx(rowreq_ctx); +} /* _cache_item_free */ + +/** + * @internal + */ +static void +_cache_free(netsnmp_cache *cache, void *magic) +{ + netsnmp_container *container; + + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_cache_free","called\n")); + + if((NULL == cache) || (NULL == cache->magic)) { + snmp_log(LOG_ERR, "invalid cache in pgsqlPgAggregateTable_cache_free\n"); + return; + } + + container = (netsnmp_container*)cache->magic; + + /* + * call user code + */ + pgsqlPgAggregateTable_cache_free(container); + + /* + * free all items. inefficient, but easy. + */ + CONTAINER_CLEAR(container, + (netsnmp_container_obj_func *)_cache_item_free, + NULL); +} /* _cache_free */ + +/** + * @internal + * initialize the iterator container with functions or wrappers + */ +void +_pgsqlPgAggregateTable_container_init(pgsqlPgAggregateTable_interface_ctx *if_ctx) +{ + DEBUGMSGTL(("internal:pgsqlPgAggregateTable:_pgsqlPgAggregateTable_container_init","called\n")); + + /* + * set up the cache + */ + if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ + _cache_load, _cache_free, + pgsqlPgAggregateTable_oid, + pgsqlPgAggregateTable_oid_size); + + if(NULL == if_ctx->cache) { + snmp_log(LOG_ERR, "error creating cache for pgsqlPgAggregateTable\n"); + return; + } + + if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; + + pgsqlPgAggregateTable_container_init(&if_ctx->container, if_ctx->cache); + if(NULL == if_ctx->container) + if_ctx->container = netsnmp_container_find("pgsqlPgAggregateTable:table_container"); + if(NULL == if_ctx->container) { + snmp_log(LOG_ERR,"error creating container in " + "pgsqlPgAggregateTable_container_init\n"); + return; + } + if_ctx->cache->magic = (void*)if_ctx->container; +} /* _pgsqlPgAggregateTable_container_init */ + diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.h new file mode 100644 index 0000000..94a4e9a --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_interface.h @@ -0,0 +1,72 @@ +/* + * Note: this file originally auto-generated by mib2c using + * version : 1.43.2.3 $ of : mfd-interface.m2c,v $ + * + * $Id: pgsqlPgAggregateTable_interface.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +/** @defgroup interface: Routines to interface to Net-SNMP + * + * \warning This code should not be modified, called directly, + * or used to interpret functionality. It is subject to + * change at any time. + * + * @{ + */ +/* + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + * *** *** + * *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** + * *** *** + * *** *** + * *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** + * *** *** + * *** *** + * *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** + * *** *** + * *** *** + * *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** + * *** *** + * *** *** + * ********************************************************************* + * ********************************************************************* + * ********************************************************************* + */ +#ifndef PGSQLPGAGGREGATETABLE_INTERFACE_H +#define PGSQLPGAGGREGATETABLE_INTERFACE_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "pgsqlPgAggregateTable.h" + +/* ******************************************************************** + * Table declarations + */ + +/* PUBLIC interface initialization routine */ +void _pgsqlPgAggregateTable_initialize_interface(pgsqlPgAggregateTable_registration_ptr user_ctx, + u_long flags); + + pgsqlPgAggregateTable_rowreq_ctx * pgsqlPgAggregateTable_allocate_rowreq_ctx(void); +void pgsqlPgAggregateTable_release_rowreq_ctx(pgsqlPgAggregateTable_rowreq_ctx *rowreq_ctx); + +int pgsqlPgAggregateTable_index_to_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx); +int pgsqlPgAggregateTable_index_from_oid(netsnmp_index *oid_idx, + pgsqlPgAggregateTable_mib_index *mib_idx); + +/* + * access to certain internals. use with caution! + */ +void pgsqlPgAggregateTable_valid_columns_set(netsnmp_column_info *vc); + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_INTERFACE_H */ diff --git a/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_oids.h b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_oids.h new file mode 100644 index 0000000..bb5a69d --- /dev/null +++ b/PGSQL-MIB_src/pgsqlCatalogTables/pgsqlPgAggregateTable/pgsqlPgAggregateTable_oids.h @@ -0,0 +1,33 @@ +/* + * Note: this file originally auto-generated by mib2c using + * : generic-table-oids.m2c,v 1.10 2004/10/08 23:39:17 rstory Exp $ + * + * $Id: pgsqlPgAggregateTable_oids.h,v 1.1 2008/01/17 11:49:24 eggyknap Exp $ + */ +#ifndef PGSQLPGAGGREGATETABLE_OIDS_H +#define PGSQLPGAGGREGATETABLE_OIDS_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* column number definitions for table pgsqlPgAggregateTable */ +#define PGSQLPGAGGREGATETABLE_OID 1,3,6,1,4,1,27645,1,2,1 +#define COLUMN_PGSQLPGAGGREGATEENTRYOID 1 +#define COLUMN_PGSQLPGAGGREGATEAGGFNOID 2 +#define COLUMN_PGSQLPGAGGREGATEAGGTRANSFN 3 +#define COLUMN_PGSQLPGAGGREGATEAGGFINALFN 4 +#define COLUMN_PGSQLPGAGGREGATEAGGSORTOP 5 +#define COLUMN_PGSQLPGAGGREGATEAGGTRANSTYPE 6 +#define COLUMN_PGSQLPGAGGREGATEAGGINITVAL 7 + +#define PGSQLPGAGGREGATETABLE_MIN_COL COLUMN_PGSQLPGAGGREGATEAGGFNOID +#define PGSQLPGAGGREGATETABLE_MAX_COL COLUMN_PGSQLPGAGGREGATEAGGINITVAL + + +#ifdef __cplusplus +} +#endif + +#endif /* PGSQLPGAGGREGATETABLE_OIDS_H */ |
