2
2
* Note: this file originally auto-generated by mib2c using
3
* version : 1.12 $ of : mfd-data-access.m2c,v $
3
* version : 1.17 $ of : mfd-data-access.m2c,v $
5
* $Id: usmDHUserKeyTable_data_access.c,v 1.6.2.3 2005/01/31 06:06:08 rstory Exp $
5
* $Id: usmDHUserKeyTable_data_access.c,v 1.9.2.1 2006/01/25 16:26:39 dts12 Exp $
8
8
* standard Net-SNMP includes
20
20
#include "usmDHUserKeyTable_data_access.h"
22
/** @defgroup data_access data_access: Routines to access data
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
34
35
**********************************************************************
35
36
**********************************************************************/
37
* usmDHUserKeyTable is subid 2 of usmDHPublicObjects.
38
* SNMP-USM-DH-OBJECTS-MIB::usmDHUserKeyTable is subid 2 of usmDHPublicObjects.
38
39
* Its status is Current.
39
40
* OID: .1.3.6.1.3.101.1.1.2, length: 9
52
53
* @retval MFD_ERROR : unrecoverable error.
55
usmDHUserKeyTable_init_data(usmDHUserKeyTable_registration_ptr
56
usmDHUserKeyTable_init_data(usmDHUserKeyTable_registration *
56
57
usmDHUserKeyTable_reg)
58
59
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_init_data",
66
67
} /* usmDHUserKeyTable_init_data */
69
* container-cached overview
73
/***********************************************************************
77
***********************************************************************/
79
75
* container initialization
108
104
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_init", "called\n"));
110
if ((NULL == cache) || (NULL == container_ptr_ptr)) {
106
if (NULL == container_ptr_ptr) {
111
107
snmp_log(LOG_ERR,
112
"bad params to usmDHUserKeyTable_container_init\n");
108
"bad container param to usmDHUserKeyTable_container_init\n");
132
134
* callback when the list is changed, or a last changed object to
133
135
* verify the list hasn't changed. Until then, reload the cache for
136
138
cache->timeout = -1; /* seconds */
137
139
} /* usmDHUserKeyTable_container_init */
142
* TODO:350:M: Implement usmDHUserKeyTable cache load
144
* @param container_ptr A pointer to the container.
146
* This function is called at shutdown to allow you to customize certain
147
* aspects of the access method. For the most part, it is for advanced
148
* users. The default code should suffice for most cases.
150
* This function is called before usmDHUserKeyTable_container_free().
153
* This would also be a good place to do any cleanup needed
154
* for you data source. For example, closing a connection to another
155
* process that supplied the data, closing a database, etc.
158
usmDHUserKeyTable_container_shutdown(netsnmp_container * container_ptr)
160
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_shutdown", "called\n"));
162
if (NULL == container_ptr) {
164
"bad params to usmDHUserKeyTable_container_shutdown\n");
168
} /* usmDHUserKeyTable_container_shutdown */
173
* TODO:350:M: Implement usmDHUserKeyTable data load
174
* This function will also be called by the cache helper to load
175
* the container again (after the container free function has been
176
* called to free the previous contents).
144
178
* @param container container to which items should be inserted
147
181
* @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source
148
182
* @retval MFD_ERROR : other error.
150
* This function is called to cache the index(es) (and data, optionally)
184
* This function is called to load the index(es) (and data, optionally)
151
185
* for the every row in the data set.
154
* While loading the cache, the only important thing is the indexes.
188
* While loading the data, the only important thing is the indexes.
155
189
* If access to your data is cheap/fast (e.g. you have a pointer to a
156
190
* structure in memory), it would make sense to update the data here.
157
191
* If, however, the accessing the data invovles more work (e.g. parsing
170
usmDHUserKeyTable_cache_load(netsnmp_container * container)
204
usmDHUserKeyTable_container_load(netsnmp_container * container)
172
206
usmDHUserKeyTable_rowreq_ctx *rowreq_ctx;
173
207
struct usmUser *usmuser;
174
208
size_t count = 0;
176
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_cache_load",
210
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_load", "called\n"));
180
213
* TODO:351:M: |-> Load/update data in the usmDHUserKeyTable container.
182
215
* set the index(es) [and data, optionally] and insert into
186
219
* Retrieve the first user from the USM DB
188
221
usmuser = usm_get_userList();
189
222
if (NULL == usmuser) {
190
223
return MFD_SUCCESS;
193
226
for (; usmuser; usmuser = usmuser->next) {
195
229
* TODO:352:M: | |-> set indexes in new usmDHUserKeyTable rowreq context.
196
* data context will be set from the param (unless NULL,
230
* data context will be set from the first param (unless NULL,
197
231
* in which case a new data context will be allocated)
232
* the second param will be passed, with the row context, to
233
* usmDHUserKeyTablerowreq_ctx_init.
199
rowreq_ctx = usmDHUserKeyTable_allocate_rowreq_ctx(usmuser);
235
rowreq_ctx = usmDHUserKeyTable_allocate_rowreq_ctx(usmuser, NULL);
200
236
if (NULL == rowreq_ctx) {
201
237
snmp_log(LOG_ERR, "memory allocation failed\n");
202
238
return MFD_RESOURCE_UNAVAILABLE;
209
245
strlen(usmuser->name))) {
210
246
snmp_log(LOG_ERR,
211
247
"error setting index while loading "
212
"usmDHUserKeyTable cache.\n");
248
"usmDHUserKeyTable data.\n");
213
249
usmDHUserKeyTable_release_rowreq_ctx(rowreq_ctx);
232
DEBUGMSGT(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_cache_load",
233
"inserted %d records\n", count));
268
DEBUGMSGT(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_load", "inserted %d records\n", count));
235
270
return MFD_SUCCESS;
236
} /* usmDHUserKeyTable_cache_load */
271
} /* usmDHUserKeyTable_container_load */
241
276
* @param container container with all current items
256
usmDHUserKeyTable_cache_free(netsnmp_container * container)
291
usmDHUserKeyTable_container_free(netsnmp_container * container)
258
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_cache_free",
293
DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_container_free", "called\n"));
262
* TODO:380:M: Free usmDHUserKeyTable cache.
296
* TODO:380:M: Free usmDHUserKeyTable container data.
264
} /* usmDHUserKeyTable_cache_free */
298
} /* usmDHUserKeyTable_container_free */
267
301
* prepare row for processing.