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