| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 14170 $ of $ |
| 4 |
* |
| 5 |
* $Id:$ |
| 6 |
*/ |
| 7 |
/* |
| 8 |
* standard Net-SNMP includes |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <net-snmp/net-snmp-config.h> |
| 12 |
#include <net-snmp/net-snmp-includes.h> |
| 13 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 14 |
|
| 15 |
#ifdef HAVE_UNISTD_H |
| 16 |
#include <unistd.h> |
| 17 |
#endif |
| 18 |
|
| 19 |
/* |
| 20 |
* include our parent header |
| 21 |
*/ |
| 22 |
#include "dot3StatsTable.h" |
| 23 |
#include "dot3StatsTable_data_access.h" |
| 24 |
|
| 25 |
#if defined(linux) |
| 26 |
#include "ioctl_imp_common.h" |
| 27 |
#endif |
| 28 |
|
| 29 |
/** @ingroup interface |
| 30 |
* @addtogroup data_access data_access: Routines to access data |
| 31 |
* |
| 32 |
* These routines are used to locate the data used to satisfy |
| 33 |
* requests. |
| 34 |
* |
| 35 |
* @{ |
| 36 |
*/ |
| 37 |
/********************************************************************** |
| 38 |
********************************************************************** |
| 39 |
*** |
| 40 |
*** Table dot3StatsTable |
| 41 |
*** |
| 42 |
********************************************************************** |
| 43 |
**********************************************************************/ |
| 44 |
/* |
| 45 |
* EtherLike-MIB::dot3StatsTable is subid 2 of dot3. |
| 46 |
* Its status is Current. |
| 47 |
* OID: .1.3.6.1.2.1.10.7.2, length: 9 |
| 48 |
*/ |
| 49 |
|
| 50 |
/** |
| 51 |
* initialization for dot3StatsTable data access |
| 52 |
* |
| 53 |
* This function is called during startup to allow you to |
| 54 |
* allocate any resources you need for the data table. |
| 55 |
* |
| 56 |
* @param dot3StatsTable_reg |
| 57 |
* Pointer to dot3StatsTable_registration |
| 58 |
* |
| 59 |
* @retval MFD_SUCCESS : success. |
| 60 |
* @retval MFD_ERROR : unrecoverable error. |
| 61 |
*/ |
| 62 |
int |
| 63 |
dot3StatsTable_init_data(dot3StatsTable_registration * dot3StatsTable_reg) |
| 64 |
{ |
| 65 |
DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_init_data", |
| 66 |
"called\n")); |
| 67 |
|
| 68 |
/* |
| 69 |
* TODO:303:o: Initialize dot3StatsTable data. |
| 70 |
*/ |
| 71 |
|
| 72 |
return MFD_SUCCESS; |
| 73 |
} /* dot3StatsTable_init_data */ |
| 74 |
|
| 75 |
/** |
| 76 |
* container overview |
| 77 |
* |
| 78 |
*/ |
| 79 |
|
| 80 |
/** |
| 81 |
* container initialization |
| 82 |
* |
| 83 |
* @param container_ptr_ptr A pointer to a container pointer. If you |
| 84 |
* create a custom container, use this parameter to return it |
| 85 |
* to the MFD helper. If set to NULL, the MFD helper will |
| 86 |
* allocate a container for you. |
| 87 |
* @param cache A pointer to a cache structure. You can set the timeout |
| 88 |
* and other cache flags using this pointer. |
| 89 |
* |
| 90 |
* This function is called at startup to allow you to customize certain |
| 91 |
* aspects of the access method. For the most part, it is for advanced |
| 92 |
* users. The default code should suffice for most cases. If no custom |
| 93 |
* container is allocated, the MFD code will create one for your. |
| 94 |
* |
| 95 |
* This is also the place to set up cache behavior. The default, to |
| 96 |
* simply set the cache timeout, will work well with the default |
| 97 |
* container. If you are using a custom container, you may want to |
| 98 |
* look at the cache helper documentation to see if there are any |
| 99 |
* flags you want to set. |
| 100 |
* |
| 101 |
* @remark |
| 102 |
* This would also be a good place to do any initialization needed |
| 103 |
* for you data source. For example, opening a connection to another |
| 104 |
* process that will supply the data, opening a database, etc. |
| 105 |
*/ |
| 106 |
void |
| 107 |
dot3StatsTable_container_init(netsnmp_container ** container_ptr_ptr, |
| 108 |
netsnmp_cache * cache) |
| 109 |
{ |
| 110 |
DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_init", |
| 111 |
"called\n")); |
| 112 |
|
| 113 |
if (NULL == container_ptr_ptr) { |
| 114 |
snmp_log(LOG_ERR, |
| 115 |
"bad container param to dot3StatsTable_container_init\n"); |
| 116 |
return; |
| 117 |
} |
| 118 |
|
| 119 |
/* |
| 120 |
* For advanced users, you can use a custom container. If you |
| 121 |
* do not create one, one will be created for you. |
| 122 |
*/ |
| 123 |
*container_ptr_ptr = NULL; |
| 124 |
|
| 125 |
if (NULL == cache) { |
| 126 |
snmp_log(LOG_ERR, |
| 127 |
"bad cache param to dot3StatsTable_container_init\n"); |
| 128 |
return; |
| 129 |
} |
| 130 |
|
| 131 |
/* |
| 132 |
* TODO:345:A: Set up dot3StatsTable cache properties. |
| 133 |
* |
| 134 |
* Also for advanced users, you can set parameters for the |
| 135 |
* cache. Do not change the magic pointer, as it is used |
| 136 |
* by the MFD helper. To completely disable caching, set |
| 137 |
* cache->enabled to 0. |
| 138 |
*/ |
| 139 |
cache->timeout = DOT3STATSTABLE_CACHE_TIMEOUT; /* seconds */ |
| 140 |
} /* dot3StatsTable_container_init */ |
| 141 |
|
| 142 |
/** |
| 143 |
* container shutdown |
| 144 |
* |
| 145 |
* @param container_ptr A pointer to the container. |
| 146 |
* |
| 147 |
* This function is called at shutdown to allow you to customize certain |
| 148 |
* aspects of the access method. For the most part, it is for advanced |
| 149 |
* users. The default code should suffice for most cases. |
| 150 |
* |
| 151 |
* This function is called before dot3StatsTable_container_free(). |
| 152 |
* |
| 153 |
* @remark |
| 154 |
* This would also be a good place to do any cleanup needed |
| 155 |
* for you data source. For example, closing a connection to another |
| 156 |
* process that supplied the data, closing a database, etc. |
| 157 |
*/ |
| 158 |
void |
| 159 |
dot3StatsTable_container_shutdown(netsnmp_container * container_ptr) |
| 160 |
{ |
| 161 |
DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_shutdown", |
| 162 |
"called\n")); |
| 163 |
|
| 164 |
if (NULL == container_ptr) { |
| 165 |
snmp_log(LOG_ERR, |
| 166 |
"bad params to dot3StatsTable_container_shutdown\n"); |
| 167 |
return; |
| 168 |
} |
| 169 |
|
| 170 |
} /* dot3StatsTable_container_shutdown */ |
| 171 |
|
| 172 |
/** |
| 173 |
* load initial data |
| 174 |
* |
| 175 |
* TODO:350:M: Implement dot3StatsTable data load |
| 176 |
* This function will also be called by the cache helper to load |
| 177 |
* the container again (after the container free function has been |
| 178 |
* called to free the previous contents). |
| 179 |
* |
| 180 |
* @param container container to which items should be inserted |
| 181 |
* |
| 182 |
* @retval MFD_SUCCESS : success. |
| 183 |
* @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source |
| 184 |
* @retval MFD_ERROR : other error. |
| 185 |
* |
| 186 |
* This function is called to load the index(es) (and data, optionally) |
| 187 |
* for the every row in the data set. |
| 188 |
* |
| 189 |
* @remark |
| 190 |
* While loading the data, the only important thing is the indexes. |
| 191 |
* If access to your data is cheap/fast (e.g. you have a pointer to a |
| 192 |
* structure in memory), it would make sense to update the data here. |
| 193 |
* If, however, the accessing the data involves more work (e.g. parsing |
| 194 |
* some other existing data, or performing calculations to derive the data), |
| 195 |
* then you can limit yourself to setting the indexes and saving any |
| 196 |
* information you will need later. Then use the saved information in |
| 197 |
* dot3StatsTable_row_prep() for populating data. |
| 198 |
* |
| 199 |
* @note |
| 200 |
* If you need consistency between rows (like you want statistics |
| 201 |
* for each row to be from the same time frame), you should set all |
| 202 |
* data here. |
| 203 |
* |
| 204 |
*/ |
| 205 |
|
| 206 |
/* |
| 207 |
* |
| 208 |
* @retval MFD_SUCCESS success |
| 209 |
* @retval MFD_ERROR could not get the interface names |
| 210 |
* @retval MFD_RESOURCE_UNAVAILABLE failed to allocate memory |
| 211 |
* @retval -2 could not open a socket |
| 212 |
*/ |
| 213 |
|
| 214 |
|
| 215 |
int |
| 216 |
dot3StatsTable_container_load(netsnmp_container * container) |
| 217 |
{ |
| 218 |
size_t count = 0; |
| 219 |
|
| 220 |
DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_load", |
| 221 |
"called\n")); |
| 222 |
|
| 223 |
/* |
| 224 |
* TODO:352:M: | |-> set indexes in new dot3StatsTable rowreq context. |
| 225 |
* data context will be set from the param (unless NULL, |
| 226 |
* in which case a new data context will be allocated) |
| 227 |
*/ |
| 228 |
|
| 229 |
#if defined(linux) |
| 230 |
dot3StatsTable_container_load_impl(container); |
| 231 |
#endif |
| 232 |
|
| 233 |
DEBUGMSGT(("verbose:dot3StatsTable:dot3StatsTable_container_load", |
| 234 |
"inserted %" NETSNMP_PRIz "d records\n", count)); |
| 235 |
|
| 236 |
return MFD_SUCCESS; |
| 237 |
} /* dot3StatsTable_container_load */ |
| 238 |
|
| 239 |
/** |
| 240 |
* container clean up |
| 241 |
* |
| 242 |
* @param container container with all current items |
| 243 |
* |
| 244 |
* This optional callback is called prior to all |
| 245 |
* item's being removed from the container. If you |
| 246 |
* need to do any processing before that, do it here. |
| 247 |
* |
| 248 |
* @note |
| 249 |
* The MFD helper will take care of releasing all the row contexts. |
| 250 |
* |
| 251 |
*/ |
| 252 |
void |
| 253 |
dot3StatsTable_container_free(netsnmp_container * container) |
| 254 |
{ |
| 255 |
DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_free", |
| 256 |
"called\n")); |
| 257 |
|
| 258 |
/* |
| 259 |
* TODO:380:M: Free dot3StatsTable container data. |
| 260 |
*/ |
| 261 |
} /* dot3StatsTable_container_free */ |
| 262 |
|
| 263 |
/** |
| 264 |
* prepare row for processing. |
| 265 |
* |
| 266 |
* When the agent has located the row for a request, this function is |
| 267 |
* called to prepare the row for processing. If you fully populated |
| 268 |
* the data context during the index setup phase, you may not need to |
| 269 |
* do anything. |
| 270 |
* |
| 271 |
* @param rowreq_ctx pointer to a context. |
| 272 |
* |
| 273 |
* @retval MFD_SUCCESS : success. |
| 274 |
* @retval MFD_ERROR : other error. |
| 275 |
*/ |
| 276 |
int |
| 277 |
dot3StatsTable_row_prep(dot3StatsTable_rowreq_ctx * rowreq_ctx) |
| 278 |
{ |
| 279 |
DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_row_prep", |
| 280 |
"called\n")); |
| 281 |
|
| 282 |
netsnmp_assert(NULL != rowreq_ctx); |
| 283 |
|
| 284 |
/* |
| 285 |
* TODO:390:o: Prepare row for request. |
| 286 |
* If populating row data was delayed, this is the place to |
| 287 |
* fill in the row for this request. |
| 288 |
*/ |
| 289 |
|
| 290 |
return MFD_SUCCESS; |
| 291 |
} /* dot3StatsTable_row_prep */ |
| 292 |
|
| 293 |
/** @} */ |