| 1 |
/* |
| 2 |
* Note: this file originally auto-generated by mib2c using |
| 3 |
* version : 1.67 $ of : mfd-interface.m2c,v $ |
| 4 |
* |
| 5 |
* $Id$ |
| 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 "ipv6InterfaceTable.h" |
| 41 |
|
| 42 |
|
| 43 |
#include <net-snmp/agent/table_container.h> |
| 44 |
#include <net-snmp/library/container.h> |
| 45 |
|
| 46 |
#include "ipv6InterfaceTable_interface.h" |
| 47 |
|
| 48 |
#include "if-mib/ifTable/ifTable.h" |
| 49 |
|
| 50 |
#include <ctype.h> |
| 51 |
|
| 52 |
netsnmp_feature_require(row_merge); |
| 53 |
netsnmp_feature_require(baby_steps); |
| 54 |
netsnmp_feature_require(check_all_requests_error); |
| 55 |
|
| 56 |
/********************************************************************** |
| 57 |
********************************************************************** |
| 58 |
*** |
| 59 |
*** Table ipv6InterfaceTable |
| 60 |
*** |
| 61 |
********************************************************************** |
| 62 |
**********************************************************************/ |
| 63 |
/* |
| 64 |
* IP-MIB::ipv6InterfaceTable is subid 30 of ip. |
| 65 |
* Its status is Current. |
| 66 |
* OID: .1.3.6.1.2.1.4.30, length: 8 |
| 67 |
*/ |
| 68 |
typedef struct ipv6InterfaceTable_interface_ctx_s { |
| 69 |
|
| 70 |
netsnmp_container *container; |
| 71 |
|
| 72 |
ipv6InterfaceTable_registration *user_ctx; |
| 73 |
|
| 74 |
netsnmp_table_registration_info tbl_info; |
| 75 |
|
| 76 |
netsnmp_baby_steps_access_methods access_multiplexer; |
| 77 |
|
| 78 |
u_long last_changed; |
| 79 |
|
| 80 |
} ipv6InterfaceTable_interface_ctx; |
| 81 |
|
| 82 |
static ipv6InterfaceTable_interface_ctx ipv6InterfaceTable_if_ctx; |
| 83 |
|
| 84 |
static void |
| 85 |
_ipv6InterfaceTable_container_init(ipv6InterfaceTable_interface_ctx * |
| 86 |
if_ctx); |
| 87 |
static void |
| 88 |
_ipv6InterfaceTable_container_shutdown(ipv6InterfaceTable_interface_ctx * |
| 89 |
if_ctx); |
| 90 |
|
| 91 |
|
| 92 |
netsnmp_container * |
| 93 |
ipv6InterfaceTable_container_get(void) |
| 94 |
{ |
| 95 |
return ipv6InterfaceTable_if_ctx.container; |
| 96 |
} |
| 97 |
|
| 98 |
ipv6InterfaceTable_registration * |
| 99 |
ipv6InterfaceTable_registration_get(void) |
| 100 |
{ |
| 101 |
return ipv6InterfaceTable_if_ctx.user_ctx; |
| 102 |
} |
| 103 |
|
| 104 |
ipv6InterfaceTable_registration * |
| 105 |
ipv6InterfaceTable_registration_set(ipv6InterfaceTable_registration * |
| 106 |
newreg) |
| 107 |
{ |
| 108 |
ipv6InterfaceTable_registration *old = |
| 109 |
ipv6InterfaceTable_if_ctx.user_ctx; |
| 110 |
ipv6InterfaceTable_if_ctx.user_ctx = newreg; |
| 111 |
return old; |
| 112 |
} |
| 113 |
|
| 114 |
int |
| 115 |
ipv6InterfaceTable_container_size(void) |
| 116 |
{ |
| 117 |
return CONTAINER_SIZE(ipv6InterfaceTable_if_ctx.container); |
| 118 |
} |
| 119 |
|
| 120 |
u_int |
| 121 |
ipv6InterfaceTable_dirty_get(void) |
| 122 |
{ |
| 123 |
return ifTable_dirty_get(); |
| 124 |
} |
| 125 |
|
| 126 |
void |
| 127 |
ipv6InterfaceTable_dirty_set(u_int status) |
| 128 |
{ |
| 129 |
ifTable_dirty_set(status); |
| 130 |
} |
| 131 |
|
| 132 |
/* |
| 133 |
* ipv6InterfaceTableLastChanged, which is the last time that a row in |
| 134 |
* the table was changed or the last time a row was added/deleted from the |
| 135 |
* table. |
| 136 |
*/ |
| 137 |
void |
| 138 |
ipv6InterfaceTable_lastChange_set(u_long table_changed) |
| 139 |
{ |
| 140 |
DEBUGMSGTL(("ipv6InterfaceTable:lastChanged_set", |
| 141 |
"called. was %ld, now %ld\n", |
| 142 |
ipv6InterfaceTable_if_ctx.last_changed, table_changed)); |
| 143 |
ipv6InterfaceTable_if_ctx.last_changed = table_changed; |
| 144 |
} |
| 145 |
|
| 146 |
/* |
| 147 |
* mfd multiplexer modes |
| 148 |
*/ |
| 149 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_pre_request; |
| 150 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_post_request; |
| 151 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_object_lookup; |
| 152 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_get_values; |
| 153 |
#ifndef NETSNMP_DISABLE_SET_SUPPORT |
| 154 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_check_objects; |
| 155 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_setup; |
| 156 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_set_values; |
| 157 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_cleanup; |
| 158 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_values; |
| 159 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_commit; |
| 160 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_undo_commit; |
| 161 |
static Netsnmp_Node_Handler _mfd_ipv6InterfaceTable_irreversible_commit; |
| 162 |
|
| 163 |
NETSNMP_STATIC_INLINE int |
| 164 |
_ipv6InterfaceTable_undo_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 165 |
netsnmp_variable_list * |
| 166 |
var, int column); |
| 167 |
#endif |
| 168 |
|
| 169 |
/** |
| 170 |
* @internal |
| 171 |
* Initialize the table ipv6InterfaceTable |
| 172 |
* (Define its contents and how it's structured) |
| 173 |
*/ |
| 174 |
void |
| 175 |
_ipv6InterfaceTable_initialize_interface(ipv6InterfaceTable_registration * |
| 176 |
reg_ptr, u_long flags) |
| 177 |
{ |
| 178 |
netsnmp_baby_steps_access_methods *access_multiplexer = |
| 179 |
&ipv6InterfaceTable_if_ctx.access_multiplexer; |
| 180 |
netsnmp_table_registration_info *tbl_info = |
| 181 |
&ipv6InterfaceTable_if_ctx.tbl_info; |
| 182 |
netsnmp_handler_registration *reginfo; |
| 183 |
netsnmp_mib_handler *handler; |
| 184 |
int mfd_modes = 0; |
| 185 |
|
| 186 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_initialize_interface", "called\n")); |
| 187 |
|
| 188 |
|
| 189 |
/************************************************* |
| 190 |
* |
| 191 |
* save interface context for ipv6InterfaceTable |
| 192 |
*/ |
| 193 |
/* |
| 194 |
* Setting up the table's definition |
| 195 |
*/ |
| 196 |
netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, |
| 197 |
/** index: ipv6InterfaceIfIndex */ |
| 198 |
0); |
| 199 |
|
| 200 |
/* |
| 201 |
* Define the minimum and maximum accessible columns. This |
| 202 |
* optimizes retrieval. |
| 203 |
*/ |
| 204 |
tbl_info->min_column = IPV6INTERFACETABLE_MIN_COL; |
| 205 |
tbl_info->max_column = IPV6INTERFACETABLE_MAX_COL; |
| 206 |
|
| 207 |
/* |
| 208 |
* save users context |
| 209 |
*/ |
| 210 |
ipv6InterfaceTable_if_ctx.user_ctx = reg_ptr; |
| 211 |
|
| 212 |
/* |
| 213 |
* call data access initialization code |
| 214 |
*/ |
| 215 |
ipv6InterfaceTable_init_data(reg_ptr); |
| 216 |
|
| 217 |
/* |
| 218 |
* set up the container |
| 219 |
*/ |
| 220 |
_ipv6InterfaceTable_container_init(&ipv6InterfaceTable_if_ctx); |
| 221 |
if (NULL == ipv6InterfaceTable_if_ctx.container) { |
| 222 |
snmp_log(LOG_ERR, |
| 223 |
"could not initialize container for ipv6InterfaceTable\n"); |
| 224 |
return; |
| 225 |
} |
| 226 |
|
| 227 |
/* |
| 228 |
* access_multiplexer: REQUIRED wrapper for get request handling |
| 229 |
*/ |
| 230 |
access_multiplexer->object_lookup = |
| 231 |
_mfd_ipv6InterfaceTable_object_lookup; |
| 232 |
access_multiplexer->get_values = _mfd_ipv6InterfaceTable_get_values; |
| 233 |
|
| 234 |
/* |
| 235 |
* no wrappers yet |
| 236 |
*/ |
| 237 |
access_multiplexer->pre_request = _mfd_ipv6InterfaceTable_pre_request; |
| 238 |
access_multiplexer->post_request = |
| 239 |
_mfd_ipv6InterfaceTable_post_request; |
| 240 |
|
| 241 |
|
| 242 |
#ifndef NETSNMP_DISABLE_SET_SUPPORT |
| 243 |
/* |
| 244 |
* REQUIRED wrappers for set request handling |
| 245 |
*/ |
| 246 |
access_multiplexer->object_syntax_checks = |
| 247 |
_mfd_ipv6InterfaceTable_check_objects; |
| 248 |
access_multiplexer->undo_setup = _mfd_ipv6InterfaceTable_undo_setup; |
| 249 |
access_multiplexer->undo_cleanup = |
| 250 |
_mfd_ipv6InterfaceTable_undo_cleanup; |
| 251 |
access_multiplexer->set_values = _mfd_ipv6InterfaceTable_set_values; |
| 252 |
access_multiplexer->undo_sets = _mfd_ipv6InterfaceTable_undo_values; |
| 253 |
|
| 254 |
/* |
| 255 |
* no wrappers yet |
| 256 |
*/ |
| 257 |
access_multiplexer->commit = _mfd_ipv6InterfaceTable_commit; |
| 258 |
access_multiplexer->undo_commit = _mfd_ipv6InterfaceTable_undo_commit; |
| 259 |
access_multiplexer->irreversible_commit = |
| 260 |
_mfd_ipv6InterfaceTable_irreversible_commit; |
| 261 |
#endif |
| 262 |
|
| 263 |
/************************************************* |
| 264 |
* |
| 265 |
* Create a registration, save our reg data, register table. |
| 266 |
*/ |
| 267 |
DEBUGMSGTL(("ipv6InterfaceTable:init_ipv6InterfaceTable", |
| 268 |
"Registering ipv6InterfaceTable as a mibs-for-dummies table.\n")); |
| 269 |
handler = |
| 270 |
netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); |
| 271 |
reginfo = |
| 272 |
netsnmp_handler_registration_create("ipv6InterfaceTable", handler, |
| 273 |
ipv6InterfaceTable_oid, |
| 274 |
ipv6InterfaceTable_oid_size, |
| 275 |
HANDLER_CAN_BABY_STEP | |
| 276 |
#ifndef NETSNMP_DISABLE_SET_SUPPORT |
| 277 |
HANDLER_CAN_RWRITE |
| 278 |
#else |
| 279 |
HANDLER_CAN_RONLY |
| 280 |
#endif /* NETSNMP_DISABLE_SET_SUPPORT */ |
| 281 |
); |
| 282 |
if (NULL == reginfo) { |
| 283 |
snmp_log(LOG_ERR, "error registering table ipv6InterfaceTable\n"); |
| 284 |
return; |
| 285 |
} |
| 286 |
reginfo->my_reg_void = &ipv6InterfaceTable_if_ctx; |
| 287 |
|
| 288 |
/************************************************* |
| 289 |
* |
| 290 |
* set up baby steps handler, create it and inject it |
| 291 |
*/ |
| 292 |
if (access_multiplexer->object_lookup) |
| 293 |
mfd_modes |= BABY_STEP_OBJECT_LOOKUP; |
| 294 |
if (access_multiplexer->pre_request) |
| 295 |
mfd_modes |= BABY_STEP_PRE_REQUEST; |
| 296 |
if (access_multiplexer->post_request) |
| 297 |
mfd_modes |= BABY_STEP_POST_REQUEST; |
| 298 |
|
| 299 |
#ifndef NETSNMP_DISABLE_SET_SUPPORT |
| 300 |
if (access_multiplexer->set_values) |
| 301 |
mfd_modes |= BABY_STEP_SET_VALUES; |
| 302 |
if (access_multiplexer->irreversible_commit) |
| 303 |
mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; |
| 304 |
if (access_multiplexer->object_syntax_checks) |
| 305 |
mfd_modes |= BABY_STEP_CHECK_OBJECT; |
| 306 |
|
| 307 |
if (access_multiplexer->undo_setup) |
| 308 |
mfd_modes |= BABY_STEP_UNDO_SETUP; |
| 309 |
if (access_multiplexer->undo_cleanup) |
| 310 |
mfd_modes |= BABY_STEP_UNDO_CLEANUP; |
| 311 |
if (access_multiplexer->undo_sets) |
| 312 |
mfd_modes |= BABY_STEP_UNDO_SETS; |
| 313 |
|
| 314 |
if (access_multiplexer->row_creation) |
| 315 |
mfd_modes |= BABY_STEP_ROW_CREATE; |
| 316 |
if (access_multiplexer->consistency_checks) |
| 317 |
mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; |
| 318 |
if (access_multiplexer->commit) |
| 319 |
mfd_modes |= BABY_STEP_COMMIT; |
| 320 |
if (access_multiplexer->undo_commit) |
| 321 |
mfd_modes |= BABY_STEP_UNDO_COMMIT; |
| 322 |
#endif |
| 323 |
|
| 324 |
handler = netsnmp_baby_steps_handler_get(mfd_modes); |
| 325 |
netsnmp_inject_handler(reginfo, handler); |
| 326 |
|
| 327 |
/************************************************* |
| 328 |
* |
| 329 |
* inject row_merge helper with prefix rootoid_len + 2 (entry.col) |
| 330 |
*/ |
| 331 |
handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); |
| 332 |
netsnmp_inject_handler(reginfo, handler); |
| 333 |
|
| 334 |
/************************************************* |
| 335 |
* |
| 336 |
* inject container_table helper |
| 337 |
*/ |
| 338 |
handler = |
| 339 |
netsnmp_container_table_handler_get(tbl_info, |
| 340 |
ipv6InterfaceTable_if_ctx. |
| 341 |
container, |
| 342 |
TABLE_CONTAINER_KEY_NETSNMP_INDEX); |
| 343 |
netsnmp_inject_handler(reginfo, handler); |
| 344 |
|
| 345 |
/* |
| 346 |
* register table |
| 347 |
*/ |
| 348 |
netsnmp_register_table(reginfo, tbl_info); |
| 349 |
|
| 350 |
/* |
| 351 |
* register LastChanged |
| 352 |
*/ |
| 353 |
{ |
| 354 |
oid lc_oid[] = { IPV6INTERFACETABLELASTCHANGE_OID }; |
| 355 |
netsnmp_register_watched_scalar2(netsnmp_create_handler_registration |
| 356 |
("ipv6TableLastChanged", NULL, |
| 357 |
lc_oid, OID_LENGTH(lc_oid), |
| 358 |
HANDLER_CAN_RONLY), |
| 359 |
netsnmp_create_watcher_info((void |
| 360 |
*) |
| 361 |
&ipv6InterfaceTable_if_ctx. |
| 362 |
last_changed, |
| 363 |
sizeof |
| 364 |
(u_long), |
| 365 |
ASN_TIMETICKS, |
| 366 |
WATCHER_FIXED_SIZE)); |
| 367 |
} |
| 368 |
} /* _ipv6InterfaceTable_initialize_interface */ |
| 369 |
|
| 370 |
/** |
| 371 |
* @internal |
| 372 |
* Shutdown the table ipv6InterfaceTable |
| 373 |
*/ |
| 374 |
void |
| 375 |
_ipv6InterfaceTable_shutdown_interface(ipv6InterfaceTable_registration * |
| 376 |
reg_ptr) |
| 377 |
{ |
| 378 |
/* |
| 379 |
* shutdown the container |
| 380 |
*/ |
| 381 |
_ipv6InterfaceTable_container_shutdown(&ipv6InterfaceTable_if_ctx); |
| 382 |
} |
| 383 |
|
| 384 |
void |
| 385 |
ipv6InterfaceTable_valid_columns_set(netsnmp_column_info *vc) |
| 386 |
{ |
| 387 |
ipv6InterfaceTable_if_ctx.tbl_info.valid_columns = vc; |
| 388 |
} /* ipv6InterfaceTable_valid_columns_set */ |
| 389 |
|
| 390 |
/** |
| 391 |
* @internal |
| 392 |
* wrapper |
| 393 |
*/ |
| 394 |
static int |
| 395 |
_mfd_ipv6InterfaceTable_pre_request(netsnmp_mib_handler *handler, |
| 396 |
netsnmp_handler_registration *reginfo, |
| 397 |
netsnmp_agent_request_info |
| 398 |
*agtreq_info, |
| 399 |
netsnmp_request_info *requests) |
| 400 |
{ |
| 401 |
int rc; |
| 402 |
|
| 403 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_pre_request", "called\n")); |
| 404 |
|
| 405 |
if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { |
| 406 |
DEBUGMSGTL(("internal:ipv6InterfaceTable", |
| 407 |
"skipping additional pre_request\n")); |
| 408 |
return SNMP_ERR_NOERROR; |
| 409 |
} |
| 410 |
|
| 411 |
rc = ipv6InterfaceTable_pre_request(ipv6InterfaceTable_if_ctx. |
| 412 |
user_ctx); |
| 413 |
if (MFD_SUCCESS != rc) { |
| 414 |
/* |
| 415 |
* nothing we can do about it but log it |
| 416 |
*/ |
| 417 |
DEBUGMSGTL(("ipv6InterfaceTable", "error %d from " |
| 418 |
"ipv6InterfaceTable_pre_request\n", rc)); |
| 419 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 420 |
} |
| 421 |
|
| 422 |
return SNMP_ERR_NOERROR; |
| 423 |
} /* _mfd_ipv6InterfaceTable_pre_request */ |
| 424 |
|
| 425 |
/** |
| 426 |
* @internal |
| 427 |
* wrapper |
| 428 |
*/ |
| 429 |
static int |
| 430 |
_mfd_ipv6InterfaceTable_post_request(netsnmp_mib_handler *handler, |
| 431 |
netsnmp_handler_registration *reginfo, |
| 432 |
netsnmp_agent_request_info |
| 433 |
*agtreq_info, |
| 434 |
netsnmp_request_info *requests) |
| 435 |
{ |
| 436 |
int rc, packet_rc; |
| 437 |
|
| 438 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_post_request", "called\n")); |
| 439 |
|
| 440 |
/* |
| 441 |
* wait for last call before calling user |
| 442 |
*/ |
| 443 |
if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { |
| 444 |
DEBUGMSGTL(("internal:ipv6InterfaceTable", |
| 445 |
"waiting for last post_request\n")); |
| 446 |
return SNMP_ERR_NOERROR; |
| 447 |
} |
| 448 |
|
| 449 |
packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); |
| 450 |
if ((MFD_SUCCESS != packet_rc) && ipv6InterfaceTable_dirty_get()) { |
| 451 |
/* |
| 452 |
* we shouldn't get here. the undo steps should also clear |
| 453 |
* the dirty flags. |
| 454 |
*/ |
| 455 |
snmp_log(LOG_WARNING, |
| 456 |
"ipv6InterfaceTable dirty flag set in post_request " |
| 457 |
"but status != SUCCESS.\n"); |
| 458 |
} |
| 459 |
|
| 460 |
rc = ipv6InterfaceTable_post_request(ipv6InterfaceTable_if_ctx. |
| 461 |
user_ctx, packet_rc); |
| 462 |
if (MFD_SUCCESS != rc) { |
| 463 |
/* |
| 464 |
* nothing we can do about it but log it |
| 465 |
*/ |
| 466 |
DEBUGMSGTL(("ipv6InterfaceTable", "error %d from " |
| 467 |
"ipv6InterfaceTable_post_request\n", rc)); |
| 468 |
} |
| 469 |
|
| 470 |
return SNMP_ERR_NOERROR; |
| 471 |
} /* _mfd_ipv6InterfaceTable_post_request */ |
| 472 |
|
| 473 |
/** |
| 474 |
* @internal |
| 475 |
* wrapper |
| 476 |
*/ |
| 477 |
static int |
| 478 |
_mfd_ipv6InterfaceTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration |
| 479 |
*reginfo, netsnmp_agent_request_info |
| 480 |
*agtreq_info, |
| 481 |
netsnmp_request_info *requests) |
| 482 |
{ |
| 483 |
int rc = SNMP_ERR_NOERROR; |
| 484 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 485 |
netsnmp_container_table_row_extract(requests); |
| 486 |
|
| 487 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_object_lookup", "called\n")); |
| 488 |
|
| 489 |
/* |
| 490 |
* get our context from mfd |
| 491 |
* ipv6InterfaceTable_interface_ctx *if_ctx = |
| 492 |
* (ipv6InterfaceTable_interface_ctx *)reginfo->my_reg_void; |
| 493 |
*/ |
| 494 |
|
| 495 |
if (NULL == rowreq_ctx) { |
| 496 |
rc = SNMP_ERR_NOCREATION; |
| 497 |
} |
| 498 |
|
| 499 |
if (MFD_SUCCESS != rc) |
| 500 |
netsnmp_request_set_error_all(requests, rc); |
| 501 |
else |
| 502 |
ipv6InterfaceTable_row_prep(rowreq_ctx); |
| 503 |
|
| 504 |
return SNMP_VALIDATE_ERR(rc); |
| 505 |
} /* _mfd_ipv6InterfaceTable_object_lookup */ |
| 506 |
|
| 507 |
/*********************************************************************** |
| 508 |
* |
| 509 |
* GET processing |
| 510 |
* |
| 511 |
***********************************************************************/ |
| 512 |
/* |
| 513 |
* @internal |
| 514 |
* Retrieve the value for a particular column |
| 515 |
*/ |
| 516 |
NETSNMP_STATIC_INLINE int |
| 517 |
_ipv6InterfaceTable_get_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 518 |
netsnmp_variable_list * var, int column) |
| 519 |
{ |
| 520 |
int rc = SNMPERR_SUCCESS; |
| 521 |
|
| 522 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_get_column", "called for %d\n", column)); |
| 523 |
|
| 524 |
|
| 525 |
netsnmp_assert(NULL != rowreq_ctx); |
| 526 |
|
| 527 |
switch (column) { |
| 528 |
|
| 529 |
/* |
| 530 |
* ipv6InterfaceReasmMaxSize(2)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/R/d/h |
| 531 |
*/ |
| 532 |
case COLUMN_IPV6INTERFACEREASMMAXSIZE: |
| 533 |
var->val_len = sizeof(u_long); |
| 534 |
var->type = ASN_UNSIGNED; |
| 535 |
rc = ipv6InterfaceReasmMaxSize_get(rowreq_ctx, |
| 536 |
(u_long *) var->val.string); |
| 537 |
break; |
| 538 |
|
| 539 |
/* |
| 540 |
* ipv6InterfaceIdentifier(3)/Ipv6AddressIfIdentifierTC/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H |
| 541 |
*/ |
| 542 |
case COLUMN_IPV6INTERFACEIDENTIFIER: |
| 543 |
var->type = ASN_OCTET_STR; |
| 544 |
rc = ipv6InterfaceIdentifier_get(rowreq_ctx, |
| 545 |
(char **) &var->val.string, |
| 546 |
&var->val_len); |
| 547 |
break; |
| 548 |
|
| 549 |
/* |
| 550 |
* ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 551 |
*/ |
| 552 |
case COLUMN_IPV6INTERFACEENABLESTATUS: |
| 553 |
var->val_len = sizeof(u_long); |
| 554 |
var->type = ASN_INTEGER; |
| 555 |
rc = ipv6InterfaceEnableStatus_get(rowreq_ctx, |
| 556 |
(u_long *) var->val.string); |
| 557 |
break; |
| 558 |
|
| 559 |
/* |
| 560 |
* ipv6InterfaceReachableTime(6)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h |
| 561 |
*/ |
| 562 |
case COLUMN_IPV6INTERFACEREACHABLETIME: |
| 563 |
var->val_len = sizeof(u_long); |
| 564 |
var->type = ASN_UNSIGNED; |
| 565 |
rc = ipv6InterfaceReachableTime_get(rowreq_ctx, |
| 566 |
(u_long *) var->val.string); |
| 567 |
break; |
| 568 |
|
| 569 |
/* |
| 570 |
* ipv6InterfaceRetransmitTime(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h |
| 571 |
*/ |
| 572 |
case COLUMN_IPV6INTERFACERETRANSMITTIME: |
| 573 |
var->val_len = sizeof(u_long); |
| 574 |
var->type = ASN_UNSIGNED; |
| 575 |
rc = ipv6InterfaceRetransmitTime_get(rowreq_ctx, |
| 576 |
(u_long *) var->val.string); |
| 577 |
break; |
| 578 |
|
| 579 |
/* |
| 580 |
* ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 581 |
*/ |
| 582 |
case COLUMN_IPV6INTERFACEFORWARDING: |
| 583 |
var->val_len = sizeof(u_long); |
| 584 |
var->type = ASN_INTEGER; |
| 585 |
rc = ipv6InterfaceForwarding_get(rowreq_ctx, |
| 586 |
(u_long *) var->val.string); |
| 587 |
break; |
| 588 |
|
| 589 |
default: |
| 590 |
if (COLUMN_IPV6INTERFACEREASMMAXSIZE <= column && column <= COLUMN_IPV6INTERFACEFORWARDING) { |
| 591 |
DEBUGMSGTL(("internal:${context}:_ipv6InterfaceTable_get_column", |
| 592 |
"assume column %d is reserved\n", column)); |
| 593 |
rc = MFD_SKIP; |
| 594 |
} else { |
| 595 |
snmp_log(LOG_ERR, |
| 596 |
"unknown column %d in _ipv6InterfaceTable_get_column\n", |
| 597 |
column); |
| 598 |
} |
| 599 |
break; |
| 600 |
} |
| 601 |
|
| 602 |
return rc; |
| 603 |
} /* _ipv6InterfaceTable_get_column */ |
| 604 |
|
| 605 |
int |
| 606 |
_mfd_ipv6InterfaceTable_get_values(netsnmp_mib_handler *handler, |
| 607 |
netsnmp_handler_registration *reginfo, |
| 608 |
netsnmp_agent_request_info *agtreq_info, |
| 609 |
netsnmp_request_info *requests) |
| 610 |
{ |
| 611 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 612 |
netsnmp_container_table_row_extract(requests); |
| 613 |
netsnmp_table_request_info *tri; |
| 614 |
u_char *old_string; |
| 615 |
void (*dataFreeHook) (void *); |
| 616 |
int rc; |
| 617 |
|
| 618 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_get_values", "called\n")); |
| 619 |
|
| 620 |
netsnmp_assert(NULL != rowreq_ctx); |
| 621 |
|
| 622 |
for (; requests; requests = requests->next) { |
| 623 |
/* |
| 624 |
* save old pointer, so we can free it if replaced |
| 625 |
*/ |
| 626 |
old_string = requests->requestvb->val.string; |
| 627 |
dataFreeHook = requests->requestvb->dataFreeHook; |
| 628 |
if (NULL == requests->requestvb->val.string) { |
| 629 |
requests->requestvb->val.string = requests->requestvb->buf; |
| 630 |
requests->requestvb->val_len = |
| 631 |
sizeof(requests->requestvb->buf); |
| 632 |
} else if (requests->requestvb->buf == |
| 633 |
requests->requestvb->val.string) { |
| 634 |
if (requests->requestvb->val_len != |
| 635 |
sizeof(requests->requestvb->buf)) |
| 636 |
requests->requestvb->val_len = |
| 637 |
sizeof(requests->requestvb->buf); |
| 638 |
} |
| 639 |
|
| 640 |
/* |
| 641 |
* get column data |
| 642 |
*/ |
| 643 |
tri = netsnmp_extract_table_info(requests); |
| 644 |
if (NULL == tri) |
| 645 |
continue; |
| 646 |
|
| 647 |
rc = _ipv6InterfaceTable_get_column(rowreq_ctx, |
| 648 |
requests->requestvb, |
| 649 |
tri->colnum); |
| 650 |
if (rc) { |
| 651 |
if (MFD_SKIP == rc) { |
| 652 |
requests->requestvb->type = SNMP_NOSUCHINSTANCE; |
| 653 |
rc = SNMP_ERR_NOERROR; |
| 654 |
} |
| 655 |
} else if (NULL == requests->requestvb->val.string) { |
| 656 |
snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); |
| 657 |
rc = SNMP_ERR_GENERR; |
| 658 |
} |
| 659 |
if (rc) |
| 660 |
netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
| 661 |
|
| 662 |
/* |
| 663 |
* if the buffer wasn't used previously for the old data (i.e. it |
| 664 |
* was allocated memory) and the get routine replaced the pointer, |
| 665 |
* we need to free the previous pointer. |
| 666 |
*/ |
| 667 |
if (old_string && (old_string != requests->requestvb->buf) && |
| 668 |
(requests->requestvb->val.string != old_string)) { |
| 669 |
if (dataFreeHook) |
| 670 |
(*dataFreeHook) (old_string); |
| 671 |
else |
| 672 |
free(old_string); |
| 673 |
} |
| 674 |
} /* for results */ |
| 675 |
|
| 676 |
return SNMP_ERR_NOERROR; |
| 677 |
} /* _mfd_ipv6InterfaceTable_get_values */ |
| 678 |
|
| 679 |
|
| 680 |
#ifndef NETSNMP_DISABLE_SET_SUPPORT |
| 681 |
/*********************************************************************** |
| 682 |
* |
| 683 |
* SET processing |
| 684 |
* |
| 685 |
***********************************************************************/ |
| 686 |
|
| 687 |
/*---------------------------------------------------------------------- |
| 688 |
* |
| 689 |
* SET: Syntax checks |
| 690 |
* |
| 691 |
*---------------------------------------------------------------------*/ |
| 692 |
/* |
| 693 |
* @internal |
| 694 |
* Check the syntax for a particular column |
| 695 |
*/ |
| 696 |
NETSNMP_STATIC_INLINE int |
| 697 |
_ipv6InterfaceTable_check_column(ipv6InterfaceTable_rowreq_ctx * |
| 698 |
rowreq_ctx, netsnmp_variable_list * var, |
| 699 |
int column) |
| 700 |
{ |
| 701 |
int rc = SNMPERR_SUCCESS; |
| 702 |
|
| 703 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_check_column", "called for %d\n", column)); |
| 704 |
|
| 705 |
netsnmp_assert(NULL != rowreq_ctx); |
| 706 |
|
| 707 |
switch (column) { |
| 708 |
/* |
| 709 |
* (INDEX) ipv6InterfaceIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H |
| 710 |
*/ |
| 711 |
case COLUMN_IPV6INTERFACEIFINDEX: |
| 712 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 713 |
break; |
| 714 |
|
| 715 |
/* |
| 716 |
* ipv6InterfaceReasmMaxSize(2)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/R/d/h |
| 717 |
*/ |
| 718 |
case COLUMN_IPV6INTERFACEREASMMAXSIZE: |
| 719 |
rc = SNMP_ERR_NOTWRITABLE; |
| 720 |
break; |
| 721 |
|
| 722 |
/* |
| 723 |
* ipv6InterfaceIdentifier(3)/Ipv6AddressIfIdentifierTC/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H |
| 724 |
*/ |
| 725 |
case COLUMN_IPV6INTERFACEIDENTIFIER: |
| 726 |
rc = SNMP_ERR_NOTWRITABLE; |
| 727 |
break; |
| 728 |
|
| 729 |
/* |
| 730 |
* ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 731 |
*/ |
| 732 |
case COLUMN_IPV6INTERFACEENABLESTATUS: |
| 733 |
rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, |
| 734 |
sizeof(rowreq_ctx->data. |
| 735 |
ipv6InterfaceEnableStatus)); |
| 736 |
/* |
| 737 |
* check that the value is one of defined enums |
| 738 |
*/ |
| 739 |
if ((SNMPERR_SUCCESS == rc) |
| 740 |
&& (*var->val.integer != IPV6INTERFACEENABLESTATUS_UP) |
| 741 |
&& (*var->val.integer != IPV6INTERFACEENABLESTATUS_DOWN) |
| 742 |
) { |
| 743 |
rc = SNMP_ERR_WRONGVALUE; |
| 744 |
} |
| 745 |
if (SNMPERR_SUCCESS != rc) { |
| 746 |
DEBUGMSGTL(("ipv6InterfaceTable:_ipv6InterfaceTable_check_column:ipv6InterfaceEnableStatus", "varbind validation failed (eg bad type or size)\n")); |
| 747 |
} else { |
| 748 |
rc = ipv6InterfaceEnableStatus_check_value(rowreq_ctx, |
| 749 |
*((u_long *) var-> |
| 750 |
val.string)); |
| 751 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 752 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 753 |
snmp_log(LOG_ERR, |
| 754 |
"bad rc %d from ipv6InterfaceEnableStatus_check_value\n", |
| 755 |
rc); |
| 756 |
rc = SNMP_ERR_GENERR; |
| 757 |
} |
| 758 |
} |
| 759 |
break; |
| 760 |
|
| 761 |
/* |
| 762 |
* ipv6InterfaceReachableTime(6)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h |
| 763 |
*/ |
| 764 |
case COLUMN_IPV6INTERFACEREACHABLETIME: |
| 765 |
rc = SNMP_ERR_NOTWRITABLE; |
| 766 |
break; |
| 767 |
|
| 768 |
/* |
| 769 |
* ipv6InterfaceRetransmitTime(7)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h |
| 770 |
*/ |
| 771 |
case COLUMN_IPV6INTERFACERETRANSMITTIME: |
| 772 |
rc = SNMP_ERR_NOTWRITABLE; |
| 773 |
break; |
| 774 |
|
| 775 |
/* |
| 776 |
* ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 777 |
*/ |
| 778 |
case COLUMN_IPV6INTERFACEFORWARDING: |
| 779 |
rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, |
| 780 |
sizeof(rowreq_ctx->data. |
| 781 |
ipv6InterfaceForwarding)); |
| 782 |
/* |
| 783 |
* check that the value is one of defined enums |
| 784 |
*/ |
| 785 |
if ((SNMPERR_SUCCESS == rc) |
| 786 |
&& (*var->val.integer != IPV6INTERFACEFORWARDING_FORWARDING) |
| 787 |
&& (*var->val.integer != IPV6INTERFACEFORWARDING_NOTFORWARDING) |
| 788 |
) { |
| 789 |
rc = SNMP_ERR_WRONGVALUE; |
| 790 |
} |
| 791 |
if (SNMPERR_SUCCESS != rc) { |
| 792 |
DEBUGMSGTL(("ipv6InterfaceTable:_ipv6InterfaceTable_check_column:ipv6InterfaceForwarding", "varbind validation failed (eg bad type or size)\n")); |
| 793 |
} else { |
| 794 |
rc = ipv6InterfaceForwarding_check_value(rowreq_ctx, |
| 795 |
*((u_long *) var->val. |
| 796 |
string)); |
| 797 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 798 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 799 |
snmp_log(LOG_ERR, |
| 800 |
"bad rc %d from ipv6InterfaceForwarding_check_value\n", |
| 801 |
rc); |
| 802 |
rc = SNMP_ERR_GENERR; |
| 803 |
} |
| 804 |
} |
| 805 |
break; |
| 806 |
|
| 807 |
default: /** We shouldn't get here */ |
| 808 |
rc = SNMP_ERR_GENERR; |
| 809 |
snmp_log(LOG_ERR, |
| 810 |
"unknown column %d in _ipv6InterfaceTable_check_column\n", |
| 811 |
column); |
| 812 |
} |
| 813 |
|
| 814 |
return rc; |
| 815 |
} /* _ipv6InterfaceTable_check_column */ |
| 816 |
|
| 817 |
int |
| 818 |
_mfd_ipv6InterfaceTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration |
| 819 |
*reginfo, netsnmp_agent_request_info |
| 820 |
*agtreq_info, |
| 821 |
netsnmp_request_info *requests) |
| 822 |
{ |
| 823 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 824 |
netsnmp_container_table_row_extract(requests); |
| 825 |
netsnmp_table_request_info *tri; |
| 826 |
int rc; |
| 827 |
|
| 828 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_check_objects", "called\n")); |
| 829 |
|
| 830 |
netsnmp_assert(NULL != rowreq_ctx); |
| 831 |
|
| 832 |
for (; requests; requests = requests->next) { |
| 833 |
|
| 834 |
/* |
| 835 |
* get column number from table request info, and check that column |
| 836 |
*/ |
| 837 |
tri = netsnmp_extract_table_info(requests); |
| 838 |
if (NULL == tri) |
| 839 |
continue; |
| 840 |
|
| 841 |
rc = _ipv6InterfaceTable_check_column(rowreq_ctx, |
| 842 |
requests->requestvb, |
| 843 |
tri->colnum); |
| 844 |
if (rc) { |
| 845 |
netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
| 846 |
break; |
| 847 |
} |
| 848 |
|
| 849 |
} /* for results */ |
| 850 |
|
| 851 |
return SNMP_ERR_NOERROR; |
| 852 |
} /* _mfd_ipv6InterfaceTable_check_objects */ |
| 853 |
|
| 854 |
|
| 855 |
/*---------------------------------------------------------------------- |
| 856 |
* |
| 857 |
* SET: Undo setup |
| 858 |
* |
| 859 |
*---------------------------------------------------------------------*/ |
| 860 |
/* |
| 861 |
* @internal |
| 862 |
* Set the value for a particular column |
| 863 |
*/ |
| 864 |
NETSNMP_STATIC_INLINE int |
| 865 |
_ipv6InterfaceTable_undo_setup_column(ipv6InterfaceTable_rowreq_ctx * |
| 866 |
rowreq_ctx, int column) |
| 867 |
{ |
| 868 |
int rc = SNMPERR_SUCCESS; |
| 869 |
|
| 870 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_undo_setup_column", "called for %d\n", column)); |
| 871 |
|
| 872 |
netsnmp_assert(NULL != rowreq_ctx); |
| 873 |
|
| 874 |
switch (column) { |
| 875 |
|
| 876 |
/* |
| 877 |
* ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 878 |
*/ |
| 879 |
case COLUMN_IPV6INTERFACEENABLESTATUS: |
| 880 |
rowreq_ctx->column_set_flags |= |
| 881 |
COLUMN_IPV6INTERFACEENABLESTATUS_FLAG; |
| 882 |
rc = ipv6InterfaceEnableStatus_undo_setup(rowreq_ctx); |
| 883 |
break; |
| 884 |
|
| 885 |
/* |
| 886 |
* ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 887 |
*/ |
| 888 |
case COLUMN_IPV6INTERFACEFORWARDING: |
| 889 |
rowreq_ctx->column_set_flags |= |
| 890 |
COLUMN_IPV6INTERFACEFORWARDING_FLAG; |
| 891 |
rc = ipv6InterfaceForwarding_undo_setup(rowreq_ctx); |
| 892 |
break; |
| 893 |
|
| 894 |
default: |
| 895 |
snmp_log(LOG_ERR, |
| 896 |
"unknown column %d in _ipv6InterfaceTable_undo_setup_column\n", |
| 897 |
column); |
| 898 |
break; |
| 899 |
} |
| 900 |
|
| 901 |
return rc; |
| 902 |
} /* _ipv6InterfaceTable_undo_setup_column */ |
| 903 |
|
| 904 |
|
| 905 |
/** |
| 906 |
* @internal |
| 907 |
* undo setup |
| 908 |
*/ |
| 909 |
int |
| 910 |
_mfd_ipv6InterfaceTable_undo_setup(netsnmp_mib_handler *handler, |
| 911 |
netsnmp_handler_registration *reginfo, |
| 912 |
netsnmp_agent_request_info *agtreq_info, |
| 913 |
netsnmp_request_info *requests) |
| 914 |
{ |
| 915 |
int rc; |
| 916 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 917 |
netsnmp_container_table_row_extract(requests); |
| 918 |
|
| 919 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_undo_setup", "called\n")); |
| 920 |
|
| 921 |
netsnmp_assert(NULL != rowreq_ctx); |
| 922 |
|
| 923 |
/* |
| 924 |
* allocate undo context |
| 925 |
*/ |
| 926 |
rc = _mfd_ifTable_undo_setup_allocate(rowreq_ctx); |
| 927 |
if (MFD_SUCCESS != rc) { |
| 928 |
netsnmp_request_set_error_all(requests,rc); |
| 929 |
return SNMP_ERR_NOERROR; |
| 930 |
} |
| 931 |
|
| 932 |
/* |
| 933 |
* row undo setup |
| 934 |
*/ |
| 935 |
rc = ipv6InterfaceTable_undo_setup(rowreq_ctx); |
| 936 |
if (MFD_SUCCESS != rc) { |
| 937 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 938 |
"ipv6InterfaceTable_undo_setup\n", rc)); |
| 939 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 940 |
} else { |
| 941 |
/* |
| 942 |
* column undo setup |
| 943 |
*/ |
| 944 |
netsnmp_table_request_info *tri; |
| 945 |
for (; requests; requests = requests->next) { |
| 946 |
/* |
| 947 |
* set column data |
| 948 |
*/ |
| 949 |
tri = netsnmp_extract_table_info(requests); |
| 950 |
if (NULL == tri) |
| 951 |
continue; |
| 952 |
|
| 953 |
rc = _ipv6InterfaceTable_undo_setup_column(rowreq_ctx, |
| 954 |
tri->colnum); |
| 955 |
if (MFD_SUCCESS != rc) { |
| 956 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 957 |
"ipv6InterfaceTable_undo_setup_column\n", rc)); |
| 958 |
netsnmp_set_request_error(agtreq_info, requests, |
| 959 |
SNMP_VALIDATE_ERR(rc)); |
| 960 |
} |
| 961 |
} /* for results */ |
| 962 |
} |
| 963 |
|
| 964 |
return SNMP_ERR_NOERROR; |
| 965 |
} /* _mfd_ipv6InterfaceTable_undo_setup */ |
| 966 |
|
| 967 |
/** |
| 968 |
* @internal |
| 969 |
* undo setup |
| 970 |
*/ |
| 971 |
int |
| 972 |
_mfd_ipv6InterfaceTable_undo_cleanup(netsnmp_mib_handler *handler, |
| 973 |
netsnmp_handler_registration *reginfo, |
| 974 |
netsnmp_agent_request_info |
| 975 |
*agtreq_info, |
| 976 |
netsnmp_request_info *requests) |
| 977 |
{ |
| 978 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 979 |
netsnmp_container_table_row_extract(requests); |
| 980 |
int rc; |
| 981 |
|
| 982 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_undo_cleanup", "called\n")); |
| 983 |
|
| 984 |
/* |
| 985 |
* failed row create in early stages has no rowreq_ctx |
| 986 |
*/ |
| 987 |
if (NULL == rowreq_ctx) |
| 988 |
return MFD_SUCCESS; |
| 989 |
|
| 990 |
/* |
| 991 |
* call user cleanup |
| 992 |
*/ |
| 993 |
rc = ipv6InterfaceTable_undo_cleanup(rowreq_ctx); |
| 994 |
if (MFD_SUCCESS != rc) { |
| 995 |
/* |
| 996 |
* nothing we can do about it but log it |
| 997 |
*/ |
| 998 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 999 |
"ipv6InterfaceTable_undo_cleanup\n", rc)); |
| 1000 |
} |
| 1001 |
|
| 1002 |
/* |
| 1003 |
* release undo context, if needed |
| 1004 |
*/ |
| 1005 |
_mfd_ifTable_undo_setup_release(rowreq_ctx); |
| 1006 |
|
| 1007 |
return SNMP_ERR_NOERROR; |
| 1008 |
} /* _mfd_ipv6InterfaceTable_undo_cleanup */ |
| 1009 |
|
| 1010 |
/*---------------------------------------------------------------------- |
| 1011 |
* |
| 1012 |
* SET: Set values |
| 1013 |
* |
| 1014 |
*---------------------------------------------------------------------*/ |
| 1015 |
/* |
| 1016 |
* @internal |
| 1017 |
* Set the value for a particular column |
| 1018 |
*/ |
| 1019 |
NETSNMP_STATIC_INLINE int |
| 1020 |
_ipv6InterfaceTable_set_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 1021 |
netsnmp_variable_list * var, int column) |
| 1022 |
{ |
| 1023 |
int rc = SNMPERR_SUCCESS; |
| 1024 |
|
| 1025 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_set_column", "called for %d\n", column)); |
| 1026 |
|
| 1027 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1028 |
|
| 1029 |
switch (column) { |
| 1030 |
|
| 1031 |
/* |
| 1032 |
* ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1033 |
*/ |
| 1034 |
case COLUMN_IPV6INTERFACEENABLESTATUS: |
| 1035 |
rowreq_ctx->column_set_flags |= |
| 1036 |
COLUMN_IPV6INTERFACEENABLESTATUS_FLAG; |
| 1037 |
rc = ipv6InterfaceEnableStatus_set(rowreq_ctx, |
| 1038 |
*((u_long *) var->val.string)); |
| 1039 |
break; |
| 1040 |
|
| 1041 |
/* |
| 1042 |
* ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1043 |
*/ |
| 1044 |
case COLUMN_IPV6INTERFACEFORWARDING: |
| 1045 |
rowreq_ctx->column_set_flags |= |
| 1046 |
COLUMN_IPV6INTERFACEFORWARDING_FLAG; |
| 1047 |
rc = ipv6InterfaceForwarding_set(rowreq_ctx, |
| 1048 |
*((u_long *) var->val.string)); |
| 1049 |
break; |
| 1050 |
|
| 1051 |
default: |
| 1052 |
snmp_log(LOG_ERR, |
| 1053 |
"unknown column %d in _ipv6InterfaceTable_set_column\n", |
| 1054 |
column); |
| 1055 |
rc = SNMP_ERR_GENERR; |
| 1056 |
break; |
| 1057 |
} |
| 1058 |
|
| 1059 |
return rc; |
| 1060 |
} /* _ipv6InterfaceTable_set_column */ |
| 1061 |
|
| 1062 |
int |
| 1063 |
_mfd_ipv6InterfaceTable_set_values(netsnmp_mib_handler *handler, |
| 1064 |
netsnmp_handler_registration *reginfo, |
| 1065 |
netsnmp_agent_request_info *agtreq_info, |
| 1066 |
netsnmp_request_info *requests) |
| 1067 |
{ |
| 1068 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 1069 |
netsnmp_container_table_row_extract(requests); |
| 1070 |
netsnmp_table_request_info *tri; |
| 1071 |
int rc = SNMP_ERR_NOERROR; |
| 1072 |
|
| 1073 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_set_values", "called\n")); |
| 1074 |
|
| 1075 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1076 |
|
| 1077 |
rowreq_ctx->column_set_flags = 0; |
| 1078 |
for (; requests; requests = requests->next) { |
| 1079 |
/* |
| 1080 |
* set column data |
| 1081 |
*/ |
| 1082 |
tri = netsnmp_extract_table_info(requests); |
| 1083 |
if (NULL == tri) |
| 1084 |
continue; |
| 1085 |
|
| 1086 |
rc = _ipv6InterfaceTable_set_column(rowreq_ctx, |
| 1087 |
requests->requestvb, |
| 1088 |
tri->colnum); |
| 1089 |
if (MFD_SUCCESS != rc) { |
| 1090 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 1091 |
"ipv6InterfaceTable_set_column\n", rc)); |
| 1092 |
netsnmp_set_request_error(agtreq_info, requests, |
| 1093 |
SNMP_VALIDATE_ERR(rc)); |
| 1094 |
} |
| 1095 |
} /* for results */ |
| 1096 |
|
| 1097 |
return SNMP_ERR_NOERROR; |
| 1098 |
} /* _mfd_ipv6InterfaceTable_set_values */ |
| 1099 |
|
| 1100 |
/*---------------------------------------------------------------------- |
| 1101 |
* |
| 1102 |
* SET: commit |
| 1103 |
* |
| 1104 |
*---------------------------------------------------------------------*/ |
| 1105 |
/** |
| 1106 |
* @internal |
| 1107 |
* commit the values |
| 1108 |
*/ |
| 1109 |
int |
| 1110 |
_mfd_ipv6InterfaceTable_commit(netsnmp_mib_handler *handler, |
| 1111 |
netsnmp_handler_registration *reginfo, |
| 1112 |
netsnmp_agent_request_info *agtreq_info, |
| 1113 |
netsnmp_request_info *requests) |
| 1114 |
{ |
| 1115 |
int rc; |
| 1116 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 1117 |
netsnmp_container_table_row_extract(requests); |
| 1118 |
|
| 1119 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_commit", "called\n")); |
| 1120 |
|
| 1121 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1122 |
|
| 1123 |
rc = ipv6InterfaceTable_commit(rowreq_ctx); |
| 1124 |
if (MFD_SUCCESS != rc) { |
| 1125 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 1126 |
"ipv6InterfaceTable_commit\n", rc)); |
| 1127 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 1128 |
} |
| 1129 |
|
| 1130 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 1131 |
/* |
| 1132 |
* if we successfully committed this row, set the dirty flag. Use the |
| 1133 |
* current value + 1 (i.e. dirty = # rows changed). |
| 1134 |
* this is checked in post_request... |
| 1135 |
*/ |
| 1136 |
ipv6InterfaceTable_dirty_set(ipv6InterfaceTable_dirty_get() + 1); /* set table dirty flag */ |
| 1137 |
} |
| 1138 |
|
| 1139 |
return SNMP_ERR_NOERROR; |
| 1140 |
} |
| 1141 |
|
| 1142 |
int |
| 1143 |
_mfd_ipv6InterfaceTable_undo_commit(netsnmp_mib_handler *handler, |
| 1144 |
netsnmp_handler_registration *reginfo, |
| 1145 |
netsnmp_agent_request_info |
| 1146 |
*agtreq_info, |
| 1147 |
netsnmp_request_info *requests) |
| 1148 |
{ |
| 1149 |
int rc; |
| 1150 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 1151 |
netsnmp_container_table_row_extract(requests); |
| 1152 |
|
| 1153 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_undo_commit", "called\n")); |
| 1154 |
|
| 1155 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1156 |
|
| 1157 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 1158 |
u_int d = ipv6InterfaceTable_dirty_get(); |
| 1159 |
|
| 1160 |
netsnmp_assert(d != 0); |
| 1161 |
if (d) |
| 1162 |
ipv6InterfaceTable_dirty_set(d - 1); |
| 1163 |
} |
| 1164 |
|
| 1165 |
rc = ipv6InterfaceTable_undo_commit(rowreq_ctx); |
| 1166 |
if (MFD_SUCCESS != rc) { |
| 1167 |
/* |
| 1168 |
* nothing we can do about it but log it |
| 1169 |
*/ |
| 1170 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 1171 |
"ipv6InterfaceTable_undo_commit\n", rc)); |
| 1172 |
} |
| 1173 |
|
| 1174 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 1175 |
snmp_log(LOG_WARNING, |
| 1176 |
"ipv6InterfaceTable row dirty flag still set after undo_commit\n"); |
| 1177 |
rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; |
| 1178 |
} |
| 1179 |
|
| 1180 |
return SNMP_ERR_NOERROR; |
| 1181 |
} /* _mfd_ipv6InterfaceTable_commit */ |
| 1182 |
|
| 1183 |
/*---------------------------------------------------------------------- |
| 1184 |
* |
| 1185 |
* SET: Undo |
| 1186 |
* |
| 1187 |
*---------------------------------------------------------------------*/ |
| 1188 |
/** |
| 1189 |
* @internal |
| 1190 |
* undo the value for a particular column |
| 1191 |
*/ |
| 1192 |
NETSNMP_STATIC_INLINE int |
| 1193 |
_ipv6InterfaceTable_undo_column(ipv6InterfaceTable_rowreq_ctx * rowreq_ctx, |
| 1194 |
netsnmp_variable_list * var, int column) |
| 1195 |
{ |
| 1196 |
int rc = SNMPERR_SUCCESS; |
| 1197 |
|
| 1198 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_undo_column", "called for %d\n", column)); |
| 1199 |
|
| 1200 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1201 |
|
| 1202 |
switch (column) { |
| 1203 |
|
| 1204 |
/* |
| 1205 |
* ipv6InterfaceEnableStatus(5)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1206 |
*/ |
| 1207 |
case COLUMN_IPV6INTERFACEENABLESTATUS: |
| 1208 |
rc = ipv6InterfaceEnableStatus_undo(rowreq_ctx); |
| 1209 |
break; |
| 1210 |
|
| 1211 |
/* |
| 1212 |
* ipv6InterfaceForwarding(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1213 |
*/ |
| 1214 |
case COLUMN_IPV6INTERFACEFORWARDING: |
| 1215 |
rc = ipv6InterfaceForwarding_undo(rowreq_ctx); |
| 1216 |
break; |
| 1217 |
|
| 1218 |
default: |
| 1219 |
snmp_log(LOG_ERR, |
| 1220 |
"unknown column %d in _ipv6InterfaceTable_undo_column\n", |
| 1221 |
column); |
| 1222 |
break; |
| 1223 |
} |
| 1224 |
|
| 1225 |
return rc; |
| 1226 |
} /* _ipv6InterfaceTable_undo_column */ |
| 1227 |
|
| 1228 |
int |
| 1229 |
_mfd_ipv6InterfaceTable_undo_values(netsnmp_mib_handler *handler, |
| 1230 |
netsnmp_handler_registration *reginfo, |
| 1231 |
netsnmp_agent_request_info |
| 1232 |
*agtreq_info, |
| 1233 |
netsnmp_request_info *requests) |
| 1234 |
{ |
| 1235 |
int rc; |
| 1236 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 1237 |
netsnmp_container_table_row_extract(requests); |
| 1238 |
netsnmp_table_request_info *tri; |
| 1239 |
|
| 1240 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_undo_values", "called\n")); |
| 1241 |
|
| 1242 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1243 |
|
| 1244 |
rc = ipv6InterfaceTable_undo(rowreq_ctx); |
| 1245 |
if (MFD_SUCCESS != rc) { |
| 1246 |
/* |
| 1247 |
* nothing we can do about it but log it |
| 1248 |
*/ |
| 1249 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 1250 |
"ipv6InterfaceTable_undo\n", rc)); |
| 1251 |
} |
| 1252 |
|
| 1253 |
for (; requests; requests = requests->next) { |
| 1254 |
/* |
| 1255 |
* set column data |
| 1256 |
*/ |
| 1257 |
tri = netsnmp_extract_table_info(requests); |
| 1258 |
if (NULL == tri) |
| 1259 |
continue; |
| 1260 |
|
| 1261 |
rc = _ipv6InterfaceTable_undo_column(rowreq_ctx, |
| 1262 |
requests->requestvb, |
| 1263 |
tri->colnum); |
| 1264 |
if (MFD_SUCCESS != rc) { |
| 1265 |
/* |
| 1266 |
* nothing we can do about it but log it |
| 1267 |
*/ |
| 1268 |
DEBUGMSGTL(("ipv6InterfaceTable:mfd", "error %d from " |
| 1269 |
"ipv6InterfaceTable_undo_column\n", rc)); |
| 1270 |
} |
| 1271 |
} /* for results */ |
| 1272 |
|
| 1273 |
return SNMP_ERR_NOERROR; |
| 1274 |
} /* _mfd_ipv6InterfaceTable_undo_values */ |
| 1275 |
|
| 1276 |
/*---------------------------------------------------------------------- |
| 1277 |
* |
| 1278 |
* SET: irreversible commit |
| 1279 |
* |
| 1280 |
*---------------------------------------------------------------------*/ |
| 1281 |
/** |
| 1282 |
* @internal |
| 1283 |
* commit irreversible actions |
| 1284 |
*/ |
| 1285 |
int |
| 1286 |
_mfd_ipv6InterfaceTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration |
| 1287 |
*reginfo, netsnmp_agent_request_info |
| 1288 |
*agtreq_info, |
| 1289 |
netsnmp_request_info *requests) |
| 1290 |
{ |
| 1291 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx = |
| 1292 |
netsnmp_container_table_row_extract(requests); |
| 1293 |
|
| 1294 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_mfd_ipv6InterfaceTable_irreversible:commit", "called\n")); |
| 1295 |
|
| 1296 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1297 |
|
| 1298 |
/* |
| 1299 |
* check for and handle row creation/deletion |
| 1300 |
* and update column exist flags... |
| 1301 |
*/ |
| 1302 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { |
| 1303 |
CONTAINER_REMOVE(ipv6InterfaceTable_if_ctx.container, rowreq_ctx); |
| 1304 |
} else { |
| 1305 |
if (rowreq_ctx->column_set_flags) { |
| 1306 |
rowreq_ctx->column_set_flags = 0; |
| 1307 |
} |
| 1308 |
} |
| 1309 |
|
| 1310 |
return SNMP_ERR_NOERROR; |
| 1311 |
} /* _mfd_ipv6InterfaceTable_irreversible_commit */ |
| 1312 |
#endif |
| 1313 |
|
| 1314 |
/*********************************************************************** |
| 1315 |
* |
| 1316 |
* DATA ACCESS |
| 1317 |
* |
| 1318 |
***********************************************************************/ |
| 1319 |
/** |
| 1320 |
* @internal |
| 1321 |
*/ |
| 1322 |
static void |
| 1323 |
_container_free(netsnmp_container *container) |
| 1324 |
{ |
| 1325 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_container_free", |
| 1326 |
"called\n")); |
| 1327 |
|
| 1328 |
if (NULL == container) { |
| 1329 |
snmp_log(LOG_ERR, |
| 1330 |
"invalid container in ipv6InterfaceTable_container_free\n"); |
| 1331 |
return; |
| 1332 |
} |
| 1333 |
|
| 1334 |
/* |
| 1335 |
* call user code |
| 1336 |
*/ |
| 1337 |
ipv6InterfaceTable_container_free(container); |
| 1338 |
} /* _container_free */ |
| 1339 |
|
| 1340 |
/** |
| 1341 |
* @internal |
| 1342 |
* initialize the container with functions or wrappers |
| 1343 |
*/ |
| 1344 |
void |
| 1345 |
_ipv6InterfaceTable_container_init(ipv6InterfaceTable_interface_ctx * |
| 1346 |
if_ctx) |
| 1347 |
{ |
| 1348 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_container_init", "called\n")); |
| 1349 |
|
| 1350 |
/* |
| 1351 |
* container init |
| 1352 |
*/ |
| 1353 |
ipv6InterfaceTable_container_init(&if_ctx->container); |
| 1354 |
if (NULL == if_ctx->container) |
| 1355 |
if_ctx->container = |
| 1356 |
netsnmp_container_find("ipv6InterfaceTable:table_container"); |
| 1357 |
if (NULL == if_ctx->container) { |
| 1358 |
snmp_log(LOG_ERR, "error creating container in " |
| 1359 |
"ipv6InterfaceTable_container_init\n"); |
| 1360 |
return; |
| 1361 |
} |
| 1362 |
if_ctx->container->container_name = strdup("ipv6InterfaceTable"); |
| 1363 |
} /* _ipv6InterfaceTable_container_init */ |
| 1364 |
|
| 1365 |
/** |
| 1366 |
* @internal |
| 1367 |
* shutdown the container with functions or wrappers |
| 1368 |
*/ |
| 1369 |
void |
| 1370 |
_ipv6InterfaceTable_container_shutdown(ipv6InterfaceTable_interface_ctx * |
| 1371 |
if_ctx) |
| 1372 |
{ |
| 1373 |
DEBUGMSGTL(("internal:ipv6InterfaceTable:_ipv6InterfaceTable_container_shutdown", "called\n")); |
| 1374 |
|
| 1375 |
ipv6InterfaceTable_container_shutdown(if_ctx->container); |
| 1376 |
|
| 1377 |
_container_free(if_ctx->container); |
| 1378 |
|
| 1379 |
} /* _ipv6InterfaceTable_container_shutdown */ |
| 1380 |
|
| 1381 |
|
| 1382 |
ipv6InterfaceTable_rowreq_ctx * |
| 1383 |
ipv6InterfaceTable_row_find_by_mib_index(ipv6InterfaceTable_mib_index * |
| 1384 |
mib_idx) |
| 1385 |
{ |
| 1386 |
ipv6InterfaceTable_rowreq_ctx *rowreq_ctx; |
| 1387 |
oid oid_tmp[MAX_OID_LEN]; |
| 1388 |
netsnmp_index oid_idx; |
| 1389 |
int rc; |
| 1390 |
|
| 1391 |
/* |
| 1392 |
* set up storage for OID |
| 1393 |
*/ |
| 1394 |
oid_idx.oids = oid_tmp; |
| 1395 |
oid_idx.len = sizeof(oid_tmp) / sizeof(oid); |
| 1396 |
|
| 1397 |
/* |
| 1398 |
* convert |
| 1399 |
*/ |
| 1400 |
rc = ifTable_index_to_oid(&oid_idx, mib_idx); |
| 1401 |
if (MFD_SUCCESS != rc) |
| 1402 |
return NULL; |
| 1403 |
|
| 1404 |
rowreq_ctx = |
| 1405 |
CONTAINER_FIND(ipv6InterfaceTable_if_ctx.container, &oid_idx); |
| 1406 |
|
| 1407 |
return rowreq_ctx; |
| 1408 |
} |