| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 15899 $ of $ |
| 4 |
* |
| 5 |
* $Id:ipv6ScopeZoneIndexTable_interface.c 14170 2007-04-29 00:12:32Z varun_c$ |
| 6 |
*/ |
| 7 |
/* |
| 8 |
* ********************************************************************* |
| 9 |
* ********************************************************************* |
| 10 |
* ********************************************************************* |
| 11 |
* *** *** |
| 12 |
* *** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE *** |
| 13 |
* *** *** |
| 14 |
* *** *** |
| 15 |
* *** THIS FILE DOES NOT CONTAIN ANY USER EDITABLE CODE. *** |
| 16 |
* *** *** |
| 17 |
* *** *** |
| 18 |
* *** THE GENERATED CODE IS INTERNAL IMPLEMENTATION, AND *** |
| 19 |
* *** *** |
| 20 |
* *** *** |
| 21 |
* *** IS SUBJECT TO CHANGE WITHOUT WARNING IN FUTURE RELEASES. *** |
| 22 |
* *** *** |
| 23 |
* *** *** |
| 24 |
* ********************************************************************* |
| 25 |
* ********************************************************************* |
| 26 |
* ********************************************************************* |
| 27 |
*/ |
| 28 |
|
| 29 |
/* |
| 30 |
* standard Net-SNMP includes |
| 31 |
*/ |
| 32 |
#include <net-snmp/net-snmp-config.h> |
| 33 |
#include <net-snmp/net-snmp-features.h> |
| 34 |
#include <net-snmp/net-snmp-includes.h> |
| 35 |
#include <net-snmp/agent/net-snmp-agent-includes.h> |
| 36 |
|
| 37 |
/* |
| 38 |
* include our parent header |
| 39 |
*/ |
| 40 |
#include "ipv6ScopeZoneIndexTable.h" |
| 41 |
|
| 42 |
|
| 43 |
#include <net-snmp/agent/table_container.h> |
| 44 |
#include <net-snmp/library/container.h> |
| 45 |
|
| 46 |
#include "ipv6ScopeZoneIndexTable_interface.h" |
| 47 |
|
| 48 |
#include <ctype.h> |
| 49 |
|
| 50 |
netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_external_access, libnetsnmpmibs); |
| 51 |
|
| 52 |
netsnmp_feature_require(row_merge); |
| 53 |
netsnmp_feature_require(baby_steps); |
| 54 |
netsnmp_feature_require(table_container_row_insert); |
| 55 |
netsnmp_feature_require(check_all_requests_error); |
| 56 |
|
| 57 |
|
| 58 |
netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_container_size, ipv6ScopeZoneIndexTable_external_access); |
| 59 |
netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_registration_set, ipv6ScopeZoneIndexTable_external_access); |
| 60 |
netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_registration_get, ipv6ScopeZoneIndexTable_external_access); |
| 61 |
netsnmp_feature_child_of(ipv6ScopeZoneIndexTable_container_get, ipv6ScopeZoneIndexTable_external_access); |
| 62 |
|
| 63 |
/********************************************************************** |
| 64 |
********************************************************************** |
| 65 |
*** |
| 66 |
*** Table ipv6ScopeZoneIndexTable |
| 67 |
*** |
| 68 |
********************************************************************** |
| 69 |
**********************************************************************/ |
| 70 |
/* |
| 71 |
* IP-MIB::ipv6ScopeZoneIndexTable is subid 36 of ip. |
| 72 |
* Its status is Current. |
| 73 |
* OID: .1.3.6.1.2.1.4.36, length: 8 |
| 74 |
*/ |
| 75 |
typedef struct ipv6ScopeZoneIndexTable_interface_ctx_s { |
| 76 |
|
| 77 |
netsnmp_container *container; |
| 78 |
netsnmp_cache *cache; |
| 79 |
ipv6ScopeZoneIndexTable_registration *user_ctx; |
| 80 |
|
| 81 |
netsnmp_table_registration_info tbl_info; |
| 82 |
|
| 83 |
netsnmp_baby_steps_access_methods access_multiplexer; |
| 84 |
|
| 85 |
} ipv6ScopeZoneIndexTable_interface_ctx; |
| 86 |
|
| 87 |
static ipv6ScopeZoneIndexTable_interface_ctx |
| 88 |
ipv6ScopeZoneIndexTable_if_ctx; |
| 89 |
|
| 90 |
static void |
| 91 |
_ipv6ScopeZoneIndexTable_container_init |
| 92 |
(ipv6ScopeZoneIndexTable_interface_ctx * if_ctx); |
| 93 |
static void |
| 94 |
_ipv6ScopeZoneIndexTable_container_shutdown |
| 95 |
(ipv6ScopeZoneIndexTable_interface_ctx * if_ctx); |
| 96 |
static int |
| 97 |
_cache_load(netsnmp_cache * cache, void *vmagic); |
| 98 |
static void |
| 99 |
_cache_free(netsnmp_cache * cache, void *magic); |
| 100 |
|
| 101 |
#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_GET |
| 102 |
netsnmp_container * |
| 103 |
ipv6ScopeZoneIndexTable_container_get(void) |
| 104 |
{ |
| 105 |
return ipv6ScopeZoneIndexTable_if_ctx.container; |
| 106 |
} |
| 107 |
#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_GET */ |
| 108 |
|
| 109 |
#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_GET |
| 110 |
ipv6ScopeZoneIndexTable_registration * |
| 111 |
ipv6ScopeZoneIndexTable_registration_get(void) |
| 112 |
{ |
| 113 |
return ipv6ScopeZoneIndexTable_if_ctx.user_ctx; |
| 114 |
} |
| 115 |
#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_GET */ |
| 116 |
|
| 117 |
#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_SET |
| 118 |
ipv6ScopeZoneIndexTable_registration * |
| 119 |
ipv6ScopeZoneIndexTable_registration_set |
| 120 |
(ipv6ScopeZoneIndexTable_registration * newreg) |
| 121 |
{ |
| 122 |
ipv6ScopeZoneIndexTable_registration *old = |
| 123 |
ipv6ScopeZoneIndexTable_if_ctx.user_ctx; |
| 124 |
ipv6ScopeZoneIndexTable_if_ctx.user_ctx = newreg; |
| 125 |
return old; |
| 126 |
} |
| 127 |
#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_REGISTRATION_SET */ |
| 128 |
|
| 129 |
#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_SIZE |
| 130 |
int |
| 131 |
ipv6ScopeZoneIndexTable_container_size(void) |
| 132 |
{ |
| 133 |
return CONTAINER_SIZE(ipv6ScopeZoneIndexTable_if_ctx.container); |
| 134 |
} |
| 135 |
#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_CONTAINER_SIZE */ |
| 136 |
|
| 137 |
/* |
| 138 |
* mfd multiplexer modes |
| 139 |
*/ |
| 140 |
static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_pre_request; |
| 141 |
static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_post_request; |
| 142 |
static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_object_lookup; |
| 143 |
static Netsnmp_Node_Handler _mfd_ipv6ScopeZoneIndexTable_get_values; |
| 144 |
/** |
| 145 |
* @internal |
| 146 |
* Initialize the table ipv6ScopeZoneIndexTable |
| 147 |
* (Define its contents and how it's structured) |
| 148 |
*/ |
| 149 |
void |
| 150 |
_ipv6ScopeZoneIndexTable_initialize_interface |
| 151 |
(ipv6ScopeZoneIndexTable_registration * reg_ptr, u_long flags) |
| 152 |
{ |
| 153 |
netsnmp_baby_steps_access_methods *access_multiplexer = |
| 154 |
&ipv6ScopeZoneIndexTable_if_ctx.access_multiplexer; |
| 155 |
netsnmp_table_registration_info *tbl_info = |
| 156 |
&ipv6ScopeZoneIndexTable_if_ctx.tbl_info; |
| 157 |
netsnmp_handler_registration *reginfo; |
| 158 |
netsnmp_mib_handler *handler; |
| 159 |
int mfd_modes = 0; |
| 160 |
|
| 161 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_ipv6ScopeZoneIndexTable_initialize_interface", "called\n")); |
| 162 |
|
| 163 |
|
| 164 |
/************************************************* |
| 165 |
* |
| 166 |
* save interface context for ipv6ScopeZoneIndexTable |
| 167 |
*/ |
| 168 |
/* |
| 169 |
* Setting up the table's definition |
| 170 |
*/ |
| 171 |
netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, |
| 172 |
/** index: ipv6ScopeZoneIndexIfIndex */ |
| 173 |
0); |
| 174 |
|
| 175 |
/* |
| 176 |
* Define the minimum and maximum accessible columns. This |
| 177 |
* optimizes retrieval. |
| 178 |
*/ |
| 179 |
tbl_info->min_column = IPV6SCOPEZONEINDEXTABLE_MIN_COL; |
| 180 |
tbl_info->max_column = IPV6SCOPEZONEINDEXTABLE_MAX_COL; |
| 181 |
|
| 182 |
/* |
| 183 |
* save users context |
| 184 |
*/ |
| 185 |
ipv6ScopeZoneIndexTable_if_ctx.user_ctx = reg_ptr; |
| 186 |
|
| 187 |
/* |
| 188 |
* call data access initialization code |
| 189 |
*/ |
| 190 |
ipv6ScopeZoneIndexTable_init_data(reg_ptr); |
| 191 |
|
| 192 |
/* |
| 193 |
* set up the container |
| 194 |
*/ |
| 195 |
_ipv6ScopeZoneIndexTable_container_init |
| 196 |
(&ipv6ScopeZoneIndexTable_if_ctx); |
| 197 |
if (NULL == ipv6ScopeZoneIndexTable_if_ctx.container) { |
| 198 |
snmp_log(LOG_ERR, |
| 199 |
"could not initialize container for ipv6ScopeZoneIndexTable\n"); |
| 200 |
return; |
| 201 |
} |
| 202 |
|
| 203 |
/* |
| 204 |
* access_multiplexer: REQUIRED wrapper for get request handling |
| 205 |
*/ |
| 206 |
access_multiplexer->object_lookup = |
| 207 |
_mfd_ipv6ScopeZoneIndexTable_object_lookup; |
| 208 |
access_multiplexer->get_values = |
| 209 |
_mfd_ipv6ScopeZoneIndexTable_get_values; |
| 210 |
|
| 211 |
/* |
| 212 |
* no wrappers yet |
| 213 |
*/ |
| 214 |
access_multiplexer->pre_request = |
| 215 |
_mfd_ipv6ScopeZoneIndexTable_pre_request; |
| 216 |
access_multiplexer->post_request = |
| 217 |
_mfd_ipv6ScopeZoneIndexTable_post_request; |
| 218 |
|
| 219 |
|
| 220 |
/************************************************* |
| 221 |
* |
| 222 |
* Create a registration, save our reg data, register table. |
| 223 |
*/ |
| 224 |
DEBUGMSGTL(("ipv6ScopeZoneIndexTable:init_ipv6ScopeZoneIndexTable", |
| 225 |
"Registering ipv6ScopeZoneIndexTable as a mibs-for-dummies table.\n")); |
| 226 |
handler = |
| 227 |
netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); |
| 228 |
reginfo = |
| 229 |
netsnmp_handler_registration_create("ipv6ScopeZoneIndexTable", |
| 230 |
handler, |
| 231 |
ipv6ScopeZoneIndexTable_oid, |
| 232 |
ipv6ScopeZoneIndexTable_oid_size, |
| 233 |
HANDLER_CAN_BABY_STEP | |
| 234 |
HANDLER_CAN_RONLY); |
| 235 |
if (NULL == reginfo) { |
| 236 |
snmp_log(LOG_ERR, |
| 237 |
"error registering table ipv6ScopeZoneIndexTable\n"); |
| 238 |
return; |
| 239 |
} |
| 240 |
reginfo->my_reg_void = &ipv6ScopeZoneIndexTable_if_ctx; |
| 241 |
|
| 242 |
/************************************************* |
| 243 |
* |
| 244 |
* set up baby steps handler, create it and inject it |
| 245 |
*/ |
| 246 |
if (access_multiplexer->object_lookup) |
| 247 |
mfd_modes |= BABY_STEP_OBJECT_LOOKUP; |
| 248 |
|
| 249 |
if (access_multiplexer->pre_request) |
| 250 |
mfd_modes |= BABY_STEP_PRE_REQUEST; |
| 251 |
if (access_multiplexer->post_request) |
| 252 |
mfd_modes |= BABY_STEP_POST_REQUEST; |
| 253 |
|
| 254 |
#ifndef NETSNMP_NO_WRITE_SUPPORT |
| 255 |
if (access_multiplexer->set_values) |
| 256 |
mfd_modes |= BABY_STEP_SET_VALUES; |
| 257 |
if (access_multiplexer->irreversible_commit) |
| 258 |
mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; |
| 259 |
if (access_multiplexer->object_syntax_checks) |
| 260 |
mfd_modes |= BABY_STEP_CHECK_OBJECT; |
| 261 |
|
| 262 |
if (access_multiplexer->undo_setup) |
| 263 |
mfd_modes |= BABY_STEP_UNDO_SETUP; |
| 264 |
if (access_multiplexer->undo_cleanup) |
| 265 |
mfd_modes |= BABY_STEP_UNDO_CLEANUP; |
| 266 |
if (access_multiplexer->undo_sets) |
| 267 |
mfd_modes |= BABY_STEP_UNDO_SETS; |
| 268 |
|
| 269 |
if (access_multiplexer->row_creation) |
| 270 |
mfd_modes |= BABY_STEP_ROW_CREATE; |
| 271 |
if (access_multiplexer->consistency_checks) |
| 272 |
mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; |
| 273 |
if (access_multiplexer->commit) |
| 274 |
mfd_modes |= BABY_STEP_COMMIT; |
| 275 |
if (access_multiplexer->undo_commit) |
| 276 |
mfd_modes |= BABY_STEP_UNDO_COMMIT; |
| 277 |
#endif /* !NETSNMP_NO_WRITE_SUPPORT */ |
| 278 |
|
| 279 |
handler = netsnmp_baby_steps_handler_get(mfd_modes); |
| 280 |
netsnmp_inject_handler(reginfo, handler); |
| 281 |
|
| 282 |
/************************************************* |
| 283 |
* |
| 284 |
* inject row_merge helper with prefix rootoid_len + 2 (entry.col) |
| 285 |
*/ |
| 286 |
handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); |
| 287 |
netsnmp_inject_handler(reginfo, handler); |
| 288 |
|
| 289 |
/************************************************* |
| 290 |
* |
| 291 |
* inject container_table helper |
| 292 |
*/ |
| 293 |
handler = |
| 294 |
netsnmp_container_table_handler_get(tbl_info, |
| 295 |
ipv6ScopeZoneIndexTable_if_ctx. |
| 296 |
container, |
| 297 |
TABLE_CONTAINER_KEY_NETSNMP_INDEX); |
| 298 |
netsnmp_inject_handler(reginfo, handler); |
| 299 |
|
| 300 |
if (NULL != ipv6ScopeZoneIndexTable_if_ctx.cache) { |
| 301 |
handler = |
| 302 |
netsnmp_cache_handler_get(ipv6ScopeZoneIndexTable_if_ctx.cache); |
| 303 |
netsnmp_inject_handler(reginfo, handler); |
| 304 |
} |
| 305 |
|
| 306 |
/* |
| 307 |
* register table |
| 308 |
*/ |
| 309 |
netsnmp_register_table(reginfo, tbl_info); |
| 310 |
|
| 311 |
} /* _ipv6ScopeZoneIndexTable_initialize_interface */ |
| 312 |
|
| 313 |
/** |
| 314 |
* @internal |
| 315 |
* Shutdown the table ipv6ScopeZoneIndexTable |
| 316 |
*/ |
| 317 |
void |
| 318 |
_ipv6ScopeZoneIndexTable_shutdown_interface |
| 319 |
(ipv6ScopeZoneIndexTable_registration * reg_ptr) |
| 320 |
{ |
| 321 |
/* |
| 322 |
* shutdown the container |
| 323 |
*/ |
| 324 |
_ipv6ScopeZoneIndexTable_container_shutdown |
| 325 |
(&ipv6ScopeZoneIndexTable_if_ctx); |
| 326 |
} |
| 327 |
|
| 328 |
void |
| 329 |
ipv6ScopeZoneIndexTable_valid_columns_set(netsnmp_column_info *vc) |
| 330 |
{ |
| 331 |
ipv6ScopeZoneIndexTable_if_ctx.tbl_info.valid_columns = vc; |
| 332 |
} /* ipv6ScopeZoneIndexTable_valid_columns_set */ |
| 333 |
|
| 334 |
/** |
| 335 |
* @internal |
| 336 |
* convert the index component stored in the context to an oid |
| 337 |
*/ |
| 338 |
int |
| 339 |
ipv6ScopeZoneIndexTable_index_to_oid(netsnmp_index * oid_idx, |
| 340 |
ipv6ScopeZoneIndexTable_mib_index * |
| 341 |
mib_idx) |
| 342 |
{ |
| 343 |
int err = SNMP_ERR_NOERROR; |
| 344 |
|
| 345 |
/* |
| 346 |
* temp storage for parsing indexes |
| 347 |
*/ |
| 348 |
/* |
| 349 |
* ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H |
| 350 |
*/ |
| 351 |
netsnmp_variable_list var_ipv6ScopeZoneIndexIfIndex; |
| 352 |
|
| 353 |
/* |
| 354 |
* set up varbinds |
| 355 |
*/ |
| 356 |
memset(&var_ipv6ScopeZoneIndexIfIndex, 0x00, |
| 357 |
sizeof(var_ipv6ScopeZoneIndexIfIndex)); |
| 358 |
var_ipv6ScopeZoneIndexIfIndex.type = ASN_INTEGER; |
| 359 |
|
| 360 |
/* |
| 361 |
* chain temp index varbinds together |
| 362 |
*/ |
| 363 |
var_ipv6ScopeZoneIndexIfIndex.next_variable = NULL; |
| 364 |
|
| 365 |
|
| 366 |
DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_index_to_oid", "called\n")); |
| 367 |
|
| 368 |
/* |
| 369 |
* ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H |
| 370 |
*/ |
| 371 |
snmp_set_var_value(&var_ipv6ScopeZoneIndexIfIndex, |
| 372 |
(u_char *) & mib_idx->ipv6ScopeZoneIndexIfIndex, |
| 373 |
sizeof(mib_idx->ipv6ScopeZoneIndexIfIndex)); |
| 374 |
|
| 375 |
|
| 376 |
err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, |
| 377 |
NULL, 0, &var_ipv6ScopeZoneIndexIfIndex); |
| 378 |
if (err) |
| 379 |
snmp_log(LOG_ERR, "error %d converting index to oid\n", err); |
| 380 |
|
| 381 |
/* |
| 382 |
* parsing may have allocated memory. free it. |
| 383 |
*/ |
| 384 |
snmp_reset_var_buffers(&var_ipv6ScopeZoneIndexIfIndex); |
| 385 |
|
| 386 |
return err; |
| 387 |
} /* ipv6ScopeZoneIndexTable_index_to_oid */ |
| 388 |
|
| 389 |
/** |
| 390 |
* extract ipv6ScopeZoneIndexTable indexes from a netsnmp_index |
| 391 |
* |
| 392 |
* @retval SNMP_ERR_NOERROR : no error |
| 393 |
* @retval SNMP_ERR_GENERR : error |
| 394 |
*/ |
| 395 |
int |
| 396 |
ipv6ScopeZoneIndexTable_index_from_oid(netsnmp_index * oid_idx, |
| 397 |
ipv6ScopeZoneIndexTable_mib_index * |
| 398 |
mib_idx) |
| 399 |
{ |
| 400 |
int err = SNMP_ERR_NOERROR; |
| 401 |
|
| 402 |
/* |
| 403 |
* temp storage for parsing indexes |
| 404 |
*/ |
| 405 |
/* |
| 406 |
* ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H |
| 407 |
*/ |
| 408 |
netsnmp_variable_list var_ipv6ScopeZoneIndexIfIndex; |
| 409 |
|
| 410 |
/* |
| 411 |
* set up varbinds |
| 412 |
*/ |
| 413 |
memset(&var_ipv6ScopeZoneIndexIfIndex, 0x00, |
| 414 |
sizeof(var_ipv6ScopeZoneIndexIfIndex)); |
| 415 |
var_ipv6ScopeZoneIndexIfIndex.type = ASN_INTEGER; |
| 416 |
|
| 417 |
/* |
| 418 |
* chain temp index varbinds together |
| 419 |
*/ |
| 420 |
var_ipv6ScopeZoneIndexIfIndex.next_variable = NULL; |
| 421 |
|
| 422 |
|
| 423 |
DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_index_from_oid", "called\n")); |
| 424 |
|
| 425 |
/* |
| 426 |
* parse the oid into the individual index components |
| 427 |
*/ |
| 428 |
err = parse_oid_indexes(oid_idx->oids, oid_idx->len, |
| 429 |
&var_ipv6ScopeZoneIndexIfIndex); |
| 430 |
if (err == SNMP_ERR_NOERROR) { |
| 431 |
/* |
| 432 |
* copy out values |
| 433 |
*/ |
| 434 |
mib_idx->ipv6ScopeZoneIndexIfIndex = |
| 435 |
*((long *) var_ipv6ScopeZoneIndexIfIndex.val.string); |
| 436 |
|
| 437 |
|
| 438 |
} |
| 439 |
|
| 440 |
/* |
| 441 |
* parsing may have allocated memory. free it. |
| 442 |
*/ |
| 443 |
snmp_reset_var_buffers(&var_ipv6ScopeZoneIndexIfIndex); |
| 444 |
|
| 445 |
return err; |
| 446 |
} /* ipv6ScopeZoneIndexTable_index_from_oid */ |
| 447 |
|
| 448 |
|
| 449 |
/* |
| 450 |
********************************************************************* |
| 451 |
* @internal |
| 452 |
* allocate resources for a ipv6ScopeZoneIndexTable_rowreq_ctx |
| 453 |
*/ |
| 454 |
ipv6ScopeZoneIndexTable_rowreq_ctx * |
| 455 |
ipv6ScopeZoneIndexTable_allocate_rowreq_ctx(ipv6ScopeZoneIndexTable_data *data, |
| 456 |
void *user_init_ctx) |
| 457 |
{ |
| 458 |
ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = |
| 459 |
SNMP_MALLOC_TYPEDEF(ipv6ScopeZoneIndexTable_rowreq_ctx); |
| 460 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_allocate_rowreq_ctx", "called\n")); |
| 461 |
|
| 462 |
if (NULL == rowreq_ctx) { |
| 463 |
snmp_log(LOG_ERR, "Couldn't allocate memory for a " |
| 464 |
"ipv6ScopeZoneIndexTable_rowreq_ctx.\n"); |
| 465 |
return NULL; |
| 466 |
} else { |
| 467 |
if (NULL != data) { |
| 468 |
/* |
| 469 |
* track if we got data from user |
| 470 |
*/ |
| 471 |
rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER; |
| 472 |
rowreq_ctx->data = data; |
| 473 |
} else if (NULL == |
| 474 |
(rowreq_ctx->data = |
| 475 |
ipv6ScopeZoneIndexTable_allocate_data())) { |
| 476 |
SNMP_FREE(rowreq_ctx); |
| 477 |
return NULL; |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
|
| 482 |
rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; |
| 483 |
|
| 484 |
rowreq_ctx->ipv6ScopeZoneIndexTable_data_list = NULL; |
| 485 |
|
| 486 |
/* |
| 487 |
* if we allocated data, call init routine |
| 488 |
*/ |
| 489 |
if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { |
| 490 |
if (SNMPERR_SUCCESS != |
| 491 |
ipv6ScopeZoneIndexTable_rowreq_ctx_init(rowreq_ctx, |
| 492 |
user_init_ctx)) { |
| 493 |
ipv6ScopeZoneIndexTable_release_rowreq_ctx(rowreq_ctx); |
| 494 |
rowreq_ctx = NULL; |
| 495 |
} |
| 496 |
} |
| 497 |
|
| 498 |
return rowreq_ctx; |
| 499 |
} /* ipv6ScopeZoneIndexTable_allocate_rowreq_ctx */ |
| 500 |
|
| 501 |
/* |
| 502 |
* @internal |
| 503 |
* release resources for a ipv6ScopeZoneIndexTable_rowreq_ctx |
| 504 |
*/ |
| 505 |
void |
| 506 |
ipv6ScopeZoneIndexTable_release_rowreq_ctx |
| 507 |
(ipv6ScopeZoneIndexTable_rowreq_ctx * rowreq_ctx) |
| 508 |
{ |
| 509 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_release_rowreq_ctx", "called\n")); |
| 510 |
|
| 511 |
netsnmp_assert(NULL != rowreq_ctx); |
| 512 |
|
| 513 |
ipv6ScopeZoneIndexTable_rowreq_ctx_cleanup(rowreq_ctx); |
| 514 |
/* |
| 515 |
* for non-transient data, don't free data we got from the user |
| 516 |
*/ |
| 517 |
if ((rowreq_ctx->data) && |
| 518 |
!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) |
| 519 |
ipv6ScopeZoneIndexTable_release_data(rowreq_ctx->data); |
| 520 |
|
| 521 |
|
| 522 |
/* |
| 523 |
* free index oid pointer |
| 524 |
*/ |
| 525 |
if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) |
| 526 |
free(rowreq_ctx->oid_idx.oids); |
| 527 |
|
| 528 |
SNMP_FREE(rowreq_ctx); |
| 529 |
} /* ipv6ScopeZoneIndexTable_release_rowreq_ctx */ |
| 530 |
|
| 531 |
/** |
| 532 |
* @internal |
| 533 |
* wrapper |
| 534 |
*/ |
| 535 |
static int |
| 536 |
_mfd_ipv6ScopeZoneIndexTable_pre_request(netsnmp_mib_handler *handler, |
| 537 |
netsnmp_handler_registration |
| 538 |
*reginfo, |
| 539 |
netsnmp_agent_request_info |
| 540 |
*agtreq_info, |
| 541 |
netsnmp_request_info *requests) |
| 542 |
{ |
| 543 |
int rc; |
| 544 |
|
| 545 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_pre_request", "called\n")); |
| 546 |
|
| 547 |
if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { |
| 548 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable", |
| 549 |
"skipping additional pre_request\n")); |
| 550 |
return SNMP_ERR_NOERROR; |
| 551 |
} |
| 552 |
|
| 553 |
rc = ipv6ScopeZoneIndexTable_pre_request |
| 554 |
(ipv6ScopeZoneIndexTable_if_ctx.user_ctx); |
| 555 |
if (MFD_SUCCESS != rc) { |
| 556 |
/* |
| 557 |
* nothing we can do about it but log it |
| 558 |
*/ |
| 559 |
DEBUGMSGTL(("ipv6ScopeZoneIndexTable", "error %d from " |
| 560 |
"ipv6ScopeZoneIndexTable_pre_request\n", rc)); |
| 561 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 562 |
} |
| 563 |
|
| 564 |
return SNMP_ERR_NOERROR; |
| 565 |
} /* _mfd_ipv6ScopeZoneIndexTable_pre_request */ |
| 566 |
|
| 567 |
/** |
| 568 |
* @internal |
| 569 |
* wrapper |
| 570 |
*/ |
| 571 |
static int |
| 572 |
_mfd_ipv6ScopeZoneIndexTable_post_request(netsnmp_mib_handler *handler, |
| 573 |
netsnmp_handler_registration |
| 574 |
*reginfo, |
| 575 |
netsnmp_agent_request_info |
| 576 |
*agtreq_info, |
| 577 |
netsnmp_request_info *requests) |
| 578 |
{ |
| 579 |
ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) |
| 580 |
netsnmp_container_table_row_extract(requests); |
| 581 |
int rc, packet_rc; |
| 582 |
|
| 583 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_post_request", "called\n")); |
| 584 |
|
| 585 |
/* |
| 586 |
* release row context, if deleted |
| 587 |
*/ |
| 588 |
if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) |
| 589 |
ipv6ScopeZoneIndexTable_release_rowreq_ctx(rowreq_ctx); |
| 590 |
|
| 591 |
/* |
| 592 |
* wait for last call before calling user |
| 593 |
*/ |
| 594 |
if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { |
| 595 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable", |
| 596 |
"waiting for last post_request\n")); |
| 597 |
return SNMP_ERR_NOERROR; |
| 598 |
} |
| 599 |
|
| 600 |
packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); |
| 601 |
rc = ipv6ScopeZoneIndexTable_post_request |
| 602 |
(ipv6ScopeZoneIndexTable_if_ctx.user_ctx, packet_rc); |
| 603 |
if (MFD_SUCCESS != rc) { |
| 604 |
/* |
| 605 |
* nothing we can do about it but log it |
| 606 |
*/ |
| 607 |
DEBUGMSGTL(("ipv6ScopeZoneIndexTable", "error %d from " |
| 608 |
"ipv6ScopeZoneIndexTable_post_request\n", rc)); |
| 609 |
} |
| 610 |
|
| 611 |
return SNMP_ERR_NOERROR; |
| 612 |
} /* _mfd_ipv6ScopeZoneIndexTable_post_request */ |
| 613 |
|
| 614 |
/** |
| 615 |
* @internal |
| 616 |
* wrapper |
| 617 |
*/ |
| 618 |
static ipv6ScopeZoneIndexTable_rowreq_ctx * |
| 619 |
_mfd_ipv6ScopeZoneIndexTable_rowreq_from_index(netsnmp_index * oid_idx, |
| 620 |
int *rc_ptr) |
| 621 |
{ |
| 622 |
ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx; |
| 623 |
ipv6ScopeZoneIndexTable_mib_index mib_idx; |
| 624 |
int rc; |
| 625 |
|
| 626 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_rowreq_from_index", "called\n")); |
| 627 |
|
| 628 |
if (NULL == rc_ptr) |
| 629 |
rc_ptr = &rc; |
| 630 |
*rc_ptr = MFD_SUCCESS; |
| 631 |
|
| 632 |
memset(&mib_idx, 0x0, sizeof(mib_idx)); |
| 633 |
|
| 634 |
/* |
| 635 |
* try to parse oid |
| 636 |
*/ |
| 637 |
*rc_ptr = ipv6ScopeZoneIndexTable_index_from_oid(oid_idx, &mib_idx); |
| 638 |
if (MFD_SUCCESS != *rc_ptr) { |
| 639 |
DEBUGMSGT(("ipv6ScopeZoneIndexTable", "error parsing index\n")); |
| 640 |
return NULL; |
| 641 |
} |
| 642 |
|
| 643 |
/* |
| 644 |
* allocate new context |
| 645 |
*/ |
| 646 |
rowreq_ctx = ipv6ScopeZoneIndexTable_allocate_rowreq_ctx(NULL, NULL); |
| 647 |
if (NULL == rowreq_ctx) { |
| 648 |
*rc_ptr = MFD_ERROR; |
| 649 |
return NULL; /* msg already logged */ |
| 650 |
} |
| 651 |
|
| 652 |
memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx)); |
| 653 |
|
| 654 |
|
| 655 |
/* |
| 656 |
* copy indexes |
| 657 |
*/ |
| 658 |
rowreq_ctx->oid_idx.len = oid_idx->len; |
| 659 |
memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids, |
| 660 |
oid_idx->len * sizeof(oid)); |
| 661 |
|
| 662 |
return rowreq_ctx; |
| 663 |
} /* _mfd_ipv6ScopeZoneIndexTable_rowreq_from_index */ |
| 664 |
|
| 665 |
/** |
| 666 |
* @internal |
| 667 |
* wrapper |
| 668 |
*/ |
| 669 |
static int |
| 670 |
_mfd_ipv6ScopeZoneIndexTable_object_lookup(netsnmp_mib_handler *handler, |
| 671 |
netsnmp_handler_registration |
| 672 |
*reginfo, |
| 673 |
netsnmp_agent_request_info |
| 674 |
*agtreq_info, |
| 675 |
netsnmp_request_info *requests) |
| 676 |
{ |
| 677 |
int rc = SNMP_ERR_NOERROR; |
| 678 |
ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) |
| 679 |
netsnmp_container_table_row_extract(requests); |
| 680 |
|
| 681 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_object_lookup", "called\n")); |
| 682 |
|
| 683 |
/* |
| 684 |
* get our context from mfd |
| 685 |
* ipv6ScopeZoneIndexTable_interface_ctx *if_ctx = |
| 686 |
* (ipv6ScopeZoneIndexTable_interface_ctx *)reginfo->my_reg_void; |
| 687 |
*/ |
| 688 |
|
| 689 |
if (NULL == rowreq_ctx) { |
| 690 |
netsnmp_table_request_info *tblreq_info; |
| 691 |
netsnmp_index oid_idx; |
| 692 |
|
| 693 |
tblreq_info = netsnmp_extract_table_info(requests); |
| 694 |
if (NULL == tblreq_info) { |
| 695 |
snmp_log(LOG_ERR, "request had no table info\n"); |
| 696 |
return MFD_ERROR; |
| 697 |
} |
| 698 |
|
| 699 |
/* |
| 700 |
* try create rowreq |
| 701 |
*/ |
| 702 |
oid_idx.oids = tblreq_info->index_oid; |
| 703 |
oid_idx.len = tblreq_info->index_oid_len; |
| 704 |
|
| 705 |
rowreq_ctx = |
| 706 |
_mfd_ipv6ScopeZoneIndexTable_rowreq_from_index(&oid_idx, &rc); |
| 707 |
if (MFD_SUCCESS == rc) { |
| 708 |
netsnmp_assert(NULL != rowreq_ctx); |
| 709 |
rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED; |
| 710 |
/* |
| 711 |
* add rowreq_ctx to request data lists |
| 712 |
*/ |
| 713 |
netsnmp_container_table_row_insert(requests, (netsnmp_index *) |
| 714 |
rowreq_ctx); |
| 715 |
} |
| 716 |
|
| 717 |
} |
| 718 |
|
| 719 |
if (MFD_SUCCESS != rc) |
| 720 |
netsnmp_request_set_error_all(requests, rc); |
| 721 |
else |
| 722 |
ipv6ScopeZoneIndexTable_row_prep(rowreq_ctx); |
| 723 |
|
| 724 |
return SNMP_VALIDATE_ERR(rc); |
| 725 |
} /* _mfd_ipv6ScopeZoneIndexTable_object_lookup */ |
| 726 |
|
| 727 |
/*********************************************************************** |
| 728 |
* |
| 729 |
* GET processing |
| 730 |
* |
| 731 |
***********************************************************************/ |
| 732 |
/* |
| 733 |
* @internal |
| 734 |
* Retrieve the value for a particular column |
| 735 |
*/ |
| 736 |
NETSNMP_STATIC_INLINE int |
| 737 |
_ipv6ScopeZoneIndexTable_get_column(ipv6ScopeZoneIndexTable_rowreq_ctx * |
| 738 |
rowreq_ctx, |
| 739 |
netsnmp_variable_list * var, |
| 740 |
int column) |
| 741 |
{ |
| 742 |
int rc = SNMPERR_SUCCESS; |
| 743 |
|
| 744 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_column", "called for %d\n", column)); |
| 745 |
|
| 746 |
|
| 747 |
netsnmp_assert(NULL != rowreq_ctx); |
| 748 |
|
| 749 |
switch (column) { |
| 750 |
|
| 751 |
/* |
| 752 |
* ipv6ScopeZoneIndexLinkLocal(2)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 753 |
*/ |
| 754 |
case COLUMN_IPV6SCOPEZONEINDEXLINKLOCAL: |
| 755 |
var->val_len = sizeof(u_long); |
| 756 |
var->type = ASN_UNSIGNED; |
| 757 |
rc = ipv6ScopeZoneIndexLinkLocal_get(rowreq_ctx, |
| 758 |
(u_long *) var->val.string); |
| 759 |
break; |
| 760 |
|
| 761 |
/* |
| 762 |
* ipv6ScopeZoneIndex3(3)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 763 |
*/ |
| 764 |
case COLUMN_IPV6SCOPEZONEINDEX3: |
| 765 |
var->val_len = sizeof(u_long); |
| 766 |
var->type = ASN_UNSIGNED; |
| 767 |
rc = ipv6ScopeZoneIndex3_get(rowreq_ctx, |
| 768 |
(u_long *) var->val.string); |
| 769 |
break; |
| 770 |
|
| 771 |
/* |
| 772 |
* ipv6ScopeZoneIndexAdminLocal(4)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 773 |
*/ |
| 774 |
case COLUMN_IPV6SCOPEZONEINDEXADMINLOCAL: |
| 775 |
var->val_len = sizeof(u_long); |
| 776 |
var->type = ASN_UNSIGNED; |
| 777 |
rc = ipv6ScopeZoneIndexAdminLocal_get(rowreq_ctx, |
| 778 |
(u_long *) var->val.string); |
| 779 |
break; |
| 780 |
|
| 781 |
/* |
| 782 |
* ipv6ScopeZoneIndexSiteLocal(5)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 783 |
*/ |
| 784 |
case COLUMN_IPV6SCOPEZONEINDEXSITELOCAL: |
| 785 |
var->val_len = sizeof(u_long); |
| 786 |
var->type = ASN_UNSIGNED; |
| 787 |
rc = ipv6ScopeZoneIndexSiteLocal_get(rowreq_ctx, |
| 788 |
(u_long *) var->val.string); |
| 789 |
break; |
| 790 |
|
| 791 |
/* |
| 792 |
* ipv6ScopeZoneIndex6(6)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 793 |
*/ |
| 794 |
case COLUMN_IPV6SCOPEZONEINDEX6: |
| 795 |
var->val_len = sizeof(u_long); |
| 796 |
var->type = ASN_UNSIGNED; |
| 797 |
rc = ipv6ScopeZoneIndex6_get(rowreq_ctx, |
| 798 |
(u_long *) var->val.string); |
| 799 |
break; |
| 800 |
|
| 801 |
/* |
| 802 |
* ipv6ScopeZoneIndex7(7)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 803 |
*/ |
| 804 |
case COLUMN_IPV6SCOPEZONEINDEX7: |
| 805 |
var->val_len = sizeof(u_long); |
| 806 |
var->type = ASN_UNSIGNED; |
| 807 |
rc = ipv6ScopeZoneIndex7_get(rowreq_ctx, |
| 808 |
(u_long *) var->val.string); |
| 809 |
break; |
| 810 |
|
| 811 |
/* |
| 812 |
* ipv6ScopeZoneIndexOrganizationLocal(8)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 813 |
*/ |
| 814 |
case COLUMN_IPV6SCOPEZONEINDEXORGANIZATIONLOCAL: |
| 815 |
var->val_len = sizeof(u_long); |
| 816 |
var->type = ASN_UNSIGNED; |
| 817 |
rc = ipv6ScopeZoneIndexOrganizationLocal_get(rowreq_ctx, |
| 818 |
(u_long *) var->val. |
| 819 |
string); |
| 820 |
break; |
| 821 |
|
| 822 |
/* |
| 823 |
* ipv6ScopeZoneIndex9(9)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 824 |
*/ |
| 825 |
case COLUMN_IPV6SCOPEZONEINDEX9: |
| 826 |
var->val_len = sizeof(u_long); |
| 827 |
var->type = ASN_UNSIGNED; |
| 828 |
rc = ipv6ScopeZoneIndex9_get(rowreq_ctx, |
| 829 |
(u_long *) var->val.string); |
| 830 |
break; |
| 831 |
|
| 832 |
/* |
| 833 |
* ipv6ScopeZoneIndexA(10)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 834 |
*/ |
| 835 |
case COLUMN_IPV6SCOPEZONEINDEXA: |
| 836 |
var->val_len = sizeof(u_long); |
| 837 |
var->type = ASN_UNSIGNED; |
| 838 |
rc = ipv6ScopeZoneIndexA_get(rowreq_ctx, |
| 839 |
(u_long *) var->val.string); |
| 840 |
break; |
| 841 |
|
| 842 |
/* |
| 843 |
* ipv6ScopeZoneIndexB(11)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 844 |
*/ |
| 845 |
case COLUMN_IPV6SCOPEZONEINDEXB: |
| 846 |
var->val_len = sizeof(u_long); |
| 847 |
var->type = ASN_UNSIGNED; |
| 848 |
rc = ipv6ScopeZoneIndexB_get(rowreq_ctx, |
| 849 |
(u_long *) var->val.string); |
| 850 |
break; |
| 851 |
|
| 852 |
/* |
| 853 |
* ipv6ScopeZoneIndexC(12)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 854 |
*/ |
| 855 |
case COLUMN_IPV6SCOPEZONEINDEXC: |
| 856 |
var->val_len = sizeof(u_long); |
| 857 |
var->type = ASN_UNSIGNED; |
| 858 |
rc = ipv6ScopeZoneIndexC_get(rowreq_ctx, |
| 859 |
(u_long *) var->val.string); |
| 860 |
break; |
| 861 |
|
| 862 |
/* |
| 863 |
* ipv6ScopeZoneIndexD(13)/InetZoneIndex/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/H |
| 864 |
*/ |
| 865 |
case COLUMN_IPV6SCOPEZONEINDEXD: |
| 866 |
var->val_len = sizeof(u_long); |
| 867 |
var->type = ASN_UNSIGNED; |
| 868 |
rc = ipv6ScopeZoneIndexD_get(rowreq_ctx, |
| 869 |
(u_long *) var->val.string); |
| 870 |
break; |
| 871 |
|
| 872 |
default: |
| 873 |
if (IPV6SCOPEZONEINDEXTABLE_MIN_COL <= column |
| 874 |
&& column <= IPV6SCOPEZONEINDEXTABLE_MAX_COL) { |
| 875 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_column", "assume column %d is reserved\n", column)); |
| 876 |
rc = MFD_SKIP; |
| 877 |
} else { |
| 878 |
snmp_log(LOG_ERR, |
| 879 |
"unknown column %d in _ipv6ScopeZoneIndexTable_get_column\n", |
| 880 |
column); |
| 881 |
} |
| 882 |
break; |
| 883 |
} |
| 884 |
|
| 885 |
return rc; |
| 886 |
} /* _ipv6ScopeZoneIndexTable_get_column */ |
| 887 |
|
| 888 |
int |
| 889 |
_mfd_ipv6ScopeZoneIndexTable_get_values(netsnmp_mib_handler *handler, |
| 890 |
netsnmp_handler_registration |
| 891 |
*reginfo, |
| 892 |
netsnmp_agent_request_info |
| 893 |
*agtreq_info, |
| 894 |
netsnmp_request_info *requests) |
| 895 |
{ |
| 896 |
ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) |
| 897 |
netsnmp_container_table_row_extract(requests); |
| 898 |
netsnmp_table_request_info *tri; |
| 899 |
u_char *old_string; |
| 900 |
void (*dataFreeHook) (void *); |
| 901 |
int rc; |
| 902 |
|
| 903 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_mfd_ipv6ScopeZoneIndexTable_get_values", "called\n")); |
| 904 |
netsnmp_assert(NULL != rowreq_ctx); |
| 905 |
|
| 906 |
for (; requests; requests = requests->next) { |
| 907 |
/* |
| 908 |
* save old pointer, so we can free it if replaced |
| 909 |
*/ |
| 910 |
old_string = requests->requestvb->val.string; |
| 911 |
dataFreeHook = requests->requestvb->dataFreeHook; |
| 912 |
if (NULL == requests->requestvb->val.string) { |
| 913 |
requests->requestvb->val.string = requests->requestvb->buf; |
| 914 |
requests->requestvb->val_len = |
| 915 |
sizeof(requests->requestvb->buf); |
| 916 |
} else if (requests->requestvb->buf == |
| 917 |
requests->requestvb->val.string) { |
| 918 |
if (requests->requestvb->val_len != |
| 919 |
sizeof(requests->requestvb->buf)) |
| 920 |
requests->requestvb->val_len = |
| 921 |
sizeof(requests->requestvb->buf); |
| 922 |
} |
| 923 |
|
| 924 |
/* |
| 925 |
* get column data |
| 926 |
*/ |
| 927 |
tri = netsnmp_extract_table_info(requests); |
| 928 |
if (NULL == tri) |
| 929 |
continue; |
| 930 |
|
| 931 |
rc = _ipv6ScopeZoneIndexTable_get_column(rowreq_ctx, |
| 932 |
requests->requestvb, |
| 933 |
tri->colnum); |
| 934 |
if (rc) { |
| 935 |
if (MFD_SKIP == rc) { |
| 936 |
requests->requestvb->type = SNMP_NOSUCHINSTANCE; |
| 937 |
rc = SNMP_ERR_NOERROR; |
| 938 |
} |
| 939 |
} else if (NULL == requests->requestvb->val.string) { |
| 940 |
snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); |
| 941 |
rc = SNMP_ERR_GENERR; |
| 942 |
} |
| 943 |
if (rc) |
| 944 |
netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
| 945 |
|
| 946 |
/* |
| 947 |
* if the buffer wasn't used previously for the old data (i.e. it |
| 948 |
* was allocated memory) and the get routine replaced the pointer, |
| 949 |
* we need to free the previous pointer. |
| 950 |
*/ |
| 951 |
if (old_string && (old_string != requests->requestvb->buf) && |
| 952 |
(requests->requestvb->val.string != old_string)) { |
| 953 |
if (dataFreeHook) |
| 954 |
(*dataFreeHook) (old_string); |
| 955 |
else |
| 956 |
free(old_string); |
| 957 |
} |
| 958 |
} /* for results */ |
| 959 |
|
| 960 |
return SNMP_ERR_NOERROR; |
| 961 |
} /* _mfd_ipv6ScopeZoneIndexTable_get_values */ |
| 962 |
|
| 963 |
|
| 964 |
/*********************************************************************** |
| 965 |
* |
| 966 |
* SET processing |
| 967 |
* |
| 968 |
***********************************************************************/ |
| 969 |
|
| 970 |
/* |
| 971 |
* SET PROCESSING NOT APPLICABLE (per MIB or user setting) |
| 972 |
*/ |
| 973 |
/*********************************************************************** |
| 974 |
* |
| 975 |
* DATA ACCESS |
| 976 |
* |
| 977 |
***********************************************************************/ |
| 978 |
/** |
| 979 |
* @internal |
| 980 |
*/ |
| 981 |
static void |
| 982 |
_container_item_free(void *rowreq_ctx, void *context) |
| 983 |
{ |
| 984 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_container_item_free", |
| 985 |
"called\n")); |
| 986 |
|
| 987 |
if (NULL == rowreq_ctx) |
| 988 |
return; |
| 989 |
|
| 990 |
ipv6ScopeZoneIndexTable_release_rowreq_ctx(rowreq_ctx); |
| 991 |
} /* _container_item_free */ |
| 992 |
|
| 993 |
/** |
| 994 |
* @internal |
| 995 |
*/ |
| 996 |
static void |
| 997 |
_container_free(netsnmp_container * container) |
| 998 |
{ |
| 999 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_container_free", |
| 1000 |
"called\n")); |
| 1001 |
|
| 1002 |
if (NULL == container) { |
| 1003 |
snmp_log(LOG_ERR, |
| 1004 |
"invalid container in ipv6ScopeZoneIndexTable_container_free\n"); |
| 1005 |
return; |
| 1006 |
} |
| 1007 |
|
| 1008 |
/* |
| 1009 |
* call user code |
| 1010 |
*/ |
| 1011 |
ipv6ScopeZoneIndexTable_container_free(container); |
| 1012 |
|
| 1013 |
/* |
| 1014 |
* free all items. inefficient, but easy. |
| 1015 |
*/ |
| 1016 |
CONTAINER_CLEAR(container, _container_item_free, NULL); |
| 1017 |
} /* _container_free */ |
| 1018 |
|
| 1019 |
/** |
| 1020 |
* @internal |
| 1021 |
* initialize the container with functions or wrappers |
| 1022 |
*/ |
| 1023 |
void |
| 1024 |
_ipv6ScopeZoneIndexTable_container_init |
| 1025 |
(ipv6ScopeZoneIndexTable_interface_ctx * if_ctx) |
| 1026 |
{ |
| 1027 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_ipv6ScopeZoneIndexTable_container_init", "called\n")); |
| 1028 |
|
| 1029 |
/* |
| 1030 |
* container init |
| 1031 |
*/ |
| 1032 |
if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ |
| 1033 |
_cache_load, _cache_free, |
| 1034 |
ipv6ScopeZoneIndexTable_oid, |
| 1035 |
ipv6ScopeZoneIndexTable_oid_size); |
| 1036 |
|
| 1037 |
if (NULL == if_ctx->cache) { |
| 1038 |
snmp_log(LOG_ERR, "error creating cache for ipScopeZoneIndexTable\n"); |
| 1039 |
return; |
| 1040 |
} |
| 1041 |
|
| 1042 |
if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; |
| 1043 |
|
| 1044 |
ipv6ScopeZoneIndexTable_container_init(&if_ctx->container, if_ctx->cache); |
| 1045 |
if (NULL == if_ctx->container) { |
| 1046 |
if_ctx->container = |
| 1047 |
netsnmp_container_find |
| 1048 |
("ipv6ScopeZoneIndexTable:table_container"); |
| 1049 |
if (if_ctx->container) |
| 1050 |
if_ctx->container->container_name = |
| 1051 |
strdup("ipv6ScopeZoneIndexTable"); |
| 1052 |
} |
| 1053 |
if (NULL == if_ctx->container) { |
| 1054 |
snmp_log(LOG_ERR, "error creating container in " |
| 1055 |
"ipv6ScopeZoneIndexTable_container_init\n"); |
| 1056 |
return; |
| 1057 |
} |
| 1058 |
if (NULL != if_ctx->cache) |
| 1059 |
if_ctx->cache->magic = (void *) if_ctx->container; |
| 1060 |
|
| 1061 |
|
| 1062 |
} /* _ipv6ScopeZoneIndexTable_container_init */ |
| 1063 |
|
| 1064 |
/** |
| 1065 |
* @internal |
| 1066 |
* shutdown the container with functions or wrappers |
| 1067 |
*/ |
| 1068 |
void |
| 1069 |
_ipv6ScopeZoneIndexTable_container_shutdown |
| 1070 |
(ipv6ScopeZoneIndexTable_interface_ctx * if_ctx) |
| 1071 |
{ |
| 1072 |
DEBUGMSGTL(("internal:ipv6ScopeZoneIndexTable:_ipv6ScopeZoneIndexTable_container_shutdown", "called\n")); |
| 1073 |
|
| 1074 |
ipv6ScopeZoneIndexTable_container_shutdown(if_ctx->container); |
| 1075 |
|
| 1076 |
_container_free(if_ctx->container); |
| 1077 |
|
| 1078 |
} /* _ipv6ScopeZoneIndexTable_container_shutdown */ |
| 1079 |
|
| 1080 |
|
| 1081 |
#ifndef NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_EXTERNAL_ACCESS |
| 1082 |
ipv6ScopeZoneIndexTable_rowreq_ctx * |
| 1083 |
ipv6ScopeZoneIndexTable_row_find_by_mib_index |
| 1084 |
(ipv6ScopeZoneIndexTable_mib_index * mib_idx) |
| 1085 |
{ |
| 1086 |
ipv6ScopeZoneIndexTable_rowreq_ctx *rowreq_ctx; |
| 1087 |
oid oid_tmp[MAX_OID_LEN]; |
| 1088 |
netsnmp_index oid_idx; |
| 1089 |
int rc; |
| 1090 |
|
| 1091 |
/* |
| 1092 |
* set up storage for OID |
| 1093 |
*/ |
| 1094 |
oid_idx.oids = oid_tmp; |
| 1095 |
oid_idx.len = sizeof(oid_tmp) / sizeof(oid); |
| 1096 |
|
| 1097 |
/* |
| 1098 |
* convert |
| 1099 |
*/ |
| 1100 |
rc = ipv6ScopeZoneIndexTable_index_to_oid(&oid_idx, mib_idx); |
| 1101 |
if (MFD_SUCCESS != rc) |
| 1102 |
return NULL; |
| 1103 |
|
| 1104 |
rowreq_ctx = (ipv6ScopeZoneIndexTable_rowreq_ctx*) |
| 1105 |
CONTAINER_FIND(ipv6ScopeZoneIndexTable_if_ctx.container, &oid_idx); |
| 1106 |
|
| 1107 |
return rowreq_ctx; |
| 1108 |
} |
| 1109 |
#endif /* NETSNMP_FEATURE_REMOVE_IPV6SCOPEZONEINDEXTABLE_EXTERNAL_ACCESS */ |
| 1110 |
|
| 1111 |
static int |
| 1112 |
_cache_load(netsnmp_cache * cache, void *vmagic) |
| 1113 |
{ |
| 1114 |
DEBUGMSGTL(("internal:ipScopeZoneIndexTable:_cache_load", "called\n")); |
| 1115 |
|
| 1116 |
if ((NULL == cache) || (NULL == cache->magic)) { |
| 1117 |
snmp_log(LOG_ERR, |
| 1118 |
"invalid cache for ipScopeZoneIndexTable_cache_load\n"); |
| 1119 |
return -1; |
| 1120 |
} |
| 1121 |
/** should only be called for an invalid or expired cache */ |
| 1122 |
netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); |
| 1123 |
|
| 1124 |
/* |
| 1125 |
* call user code |
| 1126 |
*/ |
| 1127 |
return ipv6ScopeZoneIndexTable_container_load((netsnmp_container *) cache-> |
| 1128 |
magic); |
| 1129 |
} /* _cache_load */ |
| 1130 |
|
| 1131 |
/** |
| 1132 |
* @internal |
| 1133 |
*/ |
| 1134 |
static void |
| 1135 |
_cache_free(netsnmp_cache * cache, void *magic) |
| 1136 |
{ |
| 1137 |
netsnmp_container *container; |
| 1138 |
|
| 1139 |
DEBUGMSGTL(("internal:ipScopeZoneIndexTable:_cache_free", "called\n")); |
| 1140 |
|
| 1141 |
if ((NULL == cache) || (NULL == cache->magic)) { |
| 1142 |
snmp_log(LOG_ERR, |
| 1143 |
"invalid cache in ipScopeZoneIndexTable_cache_free\n"); |
| 1144 |
return; |
| 1145 |
} |
| 1146 |
|
| 1147 |
container = (netsnmp_container *) cache->magic; |
| 1148 |
|
| 1149 |
_container_free(container); |
| 1150 |
} /* _cache_free */ |
| 1151 |
|