| 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 "ifTable.h" |
| 41 |
#include "ifTable_defs.h" |
| 42 |
|
| 43 |
|
| 44 |
#include <net-snmp/agent/table_container.h> |
| 45 |
#include <net-snmp/library/container.h> |
| 46 |
|
| 47 |
#include "ifTable_interface.h" |
| 48 |
|
| 49 |
#include <ctype.h> |
| 50 |
|
| 51 |
netsnmp_feature_child_of(ifTable_external_access, libnetsnmpmibs); |
| 52 |
|
| 53 |
netsnmp_feature_require(row_merge); |
| 54 |
netsnmp_feature_require(baby_steps); |
| 55 |
netsnmp_feature_require(check_all_requests_error); |
| 56 |
netsnmp_feature_child_of(iftable_container_get, ifTable_external_access); |
| 57 |
netsnmp_feature_child_of(ifxtable_shutdown_interface, netsnmp_unused); |
| 58 |
netsnmp_feature_child_of(ifXTable_container_size, ifXTable_external_access); |
| 59 |
netsnmp_feature_child_of(ifXTable_registration_set, ifXTable_external_access); |
| 60 |
netsnmp_feature_child_of(ifXTable_registration_get, ifXTable_external_access); |
| 61 |
netsnmp_feature_child_of(ifXTable_container_get, ifXTable_external_access); |
| 62 |
netsnmp_feature_child_of(iftable_container_size, ifTable_external_access); |
| 63 |
netsnmp_feature_child_of(iftable_registration_set, ifTable_external_access); |
| 64 |
netsnmp_feature_child_of(iftable_registration_get, ifTable_external_access); |
| 65 |
|
| 66 |
/********************************************************************** |
| 67 |
********************************************************************** |
| 68 |
*** |
| 69 |
*** Table ifTable |
| 70 |
*** |
| 71 |
********************************************************************** |
| 72 |
**********************************************************************/ |
| 73 |
/* |
| 74 |
* IF-MIB::ifTable is subid 2 of interfaces. |
| 75 |
* Its status is Current. |
| 76 |
* OID: .1.3.6.1.2.1.2.2, length: 8 |
| 77 |
*/ |
| 78 |
typedef struct ifTable_interface_ctx_s { |
| 79 |
|
| 80 |
netsnmp_container *container; |
| 81 |
netsnmp_cache *cache; |
| 82 |
|
| 83 |
ifTable_registration *user_ctx; |
| 84 |
|
| 85 |
netsnmp_table_registration_info tbl_info; |
| 86 |
|
| 87 |
netsnmp_baby_steps_access_methods access_multiplexer; |
| 88 |
|
| 89 |
u_int table_dirty; |
| 90 |
|
| 91 |
u_long last_changed; |
| 92 |
|
| 93 |
} ifTable_interface_ctx; |
| 94 |
|
| 95 |
static ifTable_interface_ctx ifTable_if_ctx; |
| 96 |
|
| 97 |
static void _ifTable_container_init(ifTable_interface_ctx * if_ctx); |
| 98 |
static void _ifTable_container_shutdown(ifTable_interface_ctx * |
| 99 |
if_ctx); |
| 100 |
|
| 101 |
#ifndef NETSNMP_FEATURE_REMOVE_IFTABLE_CONTAINER_GET |
| 102 |
netsnmp_container * |
| 103 |
ifTable_container_get(void) |
| 104 |
{ |
| 105 |
return ifTable_if_ctx.container; |
| 106 |
} |
| 107 |
#endif /* NETSNMP_FEATURE_REMOVE_IFTABLE_CONTAINER_GET */ |
| 108 |
|
| 109 |
#ifndef NETSNMP_FEATURE_REMOVE_IFTABLE_REGISTRATION_GET |
| 110 |
ifTable_registration * |
| 111 |
ifTable_registration_get(void) |
| 112 |
{ |
| 113 |
return ifTable_if_ctx.user_ctx; |
| 114 |
} |
| 115 |
#endif /* NETSNMP_FEATURE_REMOVE_IFTABLE_REGISTRATION_GET */ |
| 116 |
|
| 117 |
#ifndef NETSNMP_FEATURE_REMOVE_IFTABLE_REGISTRATION_SET |
| 118 |
ifTable_registration * |
| 119 |
ifTable_registration_set(ifTable_registration * newreg) |
| 120 |
{ |
| 121 |
ifTable_registration *old = ifTable_if_ctx.user_ctx; |
| 122 |
ifTable_if_ctx.user_ctx = newreg; |
| 123 |
return old; |
| 124 |
} |
| 125 |
#endif /* NETSNMP_FEATURE_REMOVE_IFTABLE_REGISTRATION_SET */ |
| 126 |
|
| 127 |
#ifndef NETSNMP_FEATURE_REMOVE_IFTABLE_CONTAINER_SIZE |
| 128 |
int |
| 129 |
ifTable_container_size(void) |
| 130 |
{ |
| 131 |
return CONTAINER_SIZE(ifTable_if_ctx.container); |
| 132 |
} |
| 133 |
#endif /* NETSNMP_FEATURE_REMOVE_IFTABLE_CONTAINER_SIZE */ |
| 134 |
|
| 135 |
u_int |
| 136 |
ifTable_dirty_get(void) |
| 137 |
{ |
| 138 |
return ifTable_if_ctx.table_dirty; |
| 139 |
} |
| 140 |
|
| 141 |
void |
| 142 |
ifTable_dirty_set(u_int status) |
| 143 |
{ |
| 144 |
DEBUGMSGTL(("ifTable:ifTable_dirty_set", |
| 145 |
"called. was %d, now %d\n", |
| 146 |
ifTable_if_ctx.table_dirty, status)); |
| 147 |
ifTable_if_ctx.table_dirty = status; |
| 148 |
} |
| 149 |
|
| 150 |
/* |
| 151 |
* ifTableLastChanged, which is not the last time that a row in |
| 152 |
* the table was changed, but rather is the last time a row was |
| 153 |
* added/deleted from the table. |
| 154 |
*/ |
| 155 |
void |
| 156 |
ifTable_lastChange_set(u_long table_changed) |
| 157 |
{ |
| 158 |
DEBUGMSGTL(("ifTable:ifTable_lastChanged_set", |
| 159 |
"called. was %ld, now %ld\n", |
| 160 |
ifTable_if_ctx.last_changed, table_changed)); |
| 161 |
ifTable_if_ctx.last_changed = table_changed; |
| 162 |
} |
| 163 |
|
| 164 |
/* |
| 165 |
* mfd multiplexer modes |
| 166 |
*/ |
| 167 |
static Netsnmp_Node_Handler _mfd_ifTable_pre_request; |
| 168 |
static Netsnmp_Node_Handler _mfd_ifTable_post_request; |
| 169 |
static Netsnmp_Node_Handler _mfd_ifTable_object_lookup; |
| 170 |
static Netsnmp_Node_Handler _mfd_ifTable_get_values; |
| 171 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 172 |
static Netsnmp_Node_Handler _mfd_ifTable_check_objects; |
| 173 |
static Netsnmp_Node_Handler _mfd_ifTable_undo_setup; |
| 174 |
static Netsnmp_Node_Handler _mfd_ifTable_set_values; |
| 175 |
static Netsnmp_Node_Handler _mfd_ifTable_undo_cleanup; |
| 176 |
static Netsnmp_Node_Handler _mfd_ifTable_undo_values; |
| 177 |
static Netsnmp_Node_Handler _mfd_ifTable_commit; |
| 178 |
static Netsnmp_Node_Handler _mfd_ifTable_undo_commit; |
| 179 |
static Netsnmp_Node_Handler _mfd_ifTable_irreversible_commit; |
| 180 |
static Netsnmp_Node_Handler _mfd_ifTable_check_dependencies; |
| 181 |
|
| 182 |
NETSNMP_STATIC_INLINE int _ifTable_undo_column(ifTable_rowreq_ctx * |
| 183 |
rowreq_ctx, |
| 184 |
netsnmp_variable_list * var, |
| 185 |
int column); |
| 186 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 187 |
|
| 188 |
ifTable_data *ifTable_allocate_data(void); |
| 189 |
|
| 190 |
/** |
| 191 |
* common init of container for ifTable and ifXTable |
| 192 |
*/ |
| 193 |
void |
| 194 |
if_mib_container_init(void) |
| 195 |
{ |
| 196 |
static int done = 0; |
| 197 |
|
| 198 |
if (done) |
| 199 |
return; |
| 200 |
|
| 201 |
DEBUGMSGTL(("internal:ifTable:ifTable_container_init", "called\n")); |
| 202 |
|
| 203 |
done = 1; |
| 204 |
|
| 205 |
/* |
| 206 |
* set up the container. This is outside the rewrite ifdef, because |
| 207 |
* the container is used by the ifXTable too.. |
| 208 |
*/ |
| 209 |
_ifTable_container_init(&ifTable_if_ctx); |
| 210 |
} |
| 211 |
|
| 212 |
/** |
| 213 |
* @internal |
| 214 |
* Initialize the table ifTable |
| 215 |
* (Define its contents and how it's structured) |
| 216 |
*/ |
| 217 |
void |
| 218 |
_ifTable_initialize_interface(ifTable_registration * reg_ptr, u_long flags) |
| 219 |
{ |
| 220 |
netsnmp_baby_steps_access_methods *access_multiplexer = |
| 221 |
&ifTable_if_ctx.access_multiplexer; |
| 222 |
netsnmp_table_registration_info *tbl_info = &ifTable_if_ctx.tbl_info; |
| 223 |
netsnmp_handler_registration *reginfo; |
| 224 |
netsnmp_mib_handler *handler; |
| 225 |
int mfd_modes = 0; |
| 226 |
|
| 227 |
DEBUGMSGTL(("internal:ifTable:_ifTable_initialize_interface", |
| 228 |
"called\n")); |
| 229 |
|
| 230 |
(void) if_mib_container_init(); |
| 231 |
if (NULL == ifTable_if_ctx.container) |
| 232 |
return; /* msg already logged */ |
| 233 |
|
| 234 |
#ifndef USING_MIBII_INTERFACES_MODULE |
| 235 |
/************************************************* |
| 236 |
* |
| 237 |
* save interface context for ifTable |
| 238 |
*/ |
| 239 |
/* |
| 240 |
* Setting up the table's definition |
| 241 |
*/ |
| 242 |
netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, |
| 243 |
/** index: ifIndex */ |
| 244 |
0); |
| 245 |
|
| 246 |
/* |
| 247 |
* Define the minimum and maximum accessible columns. This |
| 248 |
* optimizes retrieval. |
| 249 |
*/ |
| 250 |
tbl_info->min_column = IFTABLE_MIN_COL; |
| 251 |
tbl_info->max_column = IFTABLE_MAX_COL; |
| 252 |
|
| 253 |
/* |
| 254 |
* save users context |
| 255 |
*/ |
| 256 |
ifTable_if_ctx.user_ctx = reg_ptr; |
| 257 |
|
| 258 |
/* |
| 259 |
* call data access initialization code |
| 260 |
*/ |
| 261 |
ifTable_init_data(reg_ptr); |
| 262 |
|
| 263 |
/* |
| 264 |
* access_multiplexer: REQUIRED wrapper for get request handling |
| 265 |
*/ |
| 266 |
access_multiplexer->object_lookup = _mfd_ifTable_object_lookup; |
| 267 |
access_multiplexer->get_values = _mfd_ifTable_get_values; |
| 268 |
|
| 269 |
/* |
| 270 |
* no wrappers yet |
| 271 |
*/ |
| 272 |
access_multiplexer->pre_request = _mfd_ifTable_pre_request; |
| 273 |
access_multiplexer->post_request = _mfd_ifTable_post_request; |
| 274 |
|
| 275 |
|
| 276 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 277 |
/* |
| 278 |
* REQUIRED wrappers for set request handling |
| 279 |
*/ |
| 280 |
access_multiplexer->object_syntax_checks = _mfd_ifTable_check_objects; |
| 281 |
access_multiplexer->undo_setup = _mfd_ifTable_undo_setup; |
| 282 |
access_multiplexer->undo_cleanup = _mfd_ifTable_undo_cleanup; |
| 283 |
access_multiplexer->set_values = _mfd_ifTable_set_values; |
| 284 |
access_multiplexer->undo_sets = _mfd_ifTable_undo_values; |
| 285 |
|
| 286 |
/* |
| 287 |
* no wrappers yet |
| 288 |
*/ |
| 289 |
access_multiplexer->commit = _mfd_ifTable_commit; |
| 290 |
access_multiplexer->undo_commit = _mfd_ifTable_undo_commit; |
| 291 |
access_multiplexer->irreversible_commit = |
| 292 |
_mfd_ifTable_irreversible_commit; |
| 293 |
|
| 294 |
/* |
| 295 |
* REQUIRED for tables with dependencies |
| 296 |
*/ |
| 297 |
access_multiplexer->consistency_checks = |
| 298 |
_mfd_ifTable_check_dependencies; |
| 299 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 300 |
|
| 301 |
/************************************************* |
| 302 |
* |
| 303 |
* Create a registration, save our reg data, register table. |
| 304 |
*/ |
| 305 |
DEBUGMSGTL(("ifTable:init_ifTable", |
| 306 |
"Registering ifTable as a mibs-for-dummies table.\n")); |
| 307 |
handler = |
| 308 |
netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); |
| 309 |
reginfo = |
| 310 |
netsnmp_handler_registration_create("ifTable", handler, |
| 311 |
ifTable_oid, ifTable_oid_size, |
| 312 |
HANDLER_CAN_BABY_STEP | |
| 313 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 314 |
HANDLER_CAN_RWRITE |
| 315 |
#else |
| 316 |
HANDLER_CAN_RONLY |
| 317 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 318 |
); |
| 319 |
|
| 320 |
if (NULL == reginfo) { |
| 321 |
snmp_log(LOG_ERR, "error registering table ifTable\n"); |
| 322 |
return; |
| 323 |
} |
| 324 |
reginfo->my_reg_void = &ifTable_if_ctx; |
| 325 |
|
| 326 |
/************************************************* |
| 327 |
* |
| 328 |
* set up baby steps handler, create it and inject it |
| 329 |
*/ |
| 330 |
if (access_multiplexer->object_lookup) |
| 331 |
mfd_modes |= BABY_STEP_OBJECT_LOOKUP; |
| 332 |
if (access_multiplexer->pre_request) |
| 333 |
mfd_modes |= BABY_STEP_PRE_REQUEST; |
| 334 |
if (access_multiplexer->post_request) |
| 335 |
mfd_modes |= BABY_STEP_POST_REQUEST; |
| 336 |
|
| 337 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 338 |
if (access_multiplexer->set_values) |
| 339 |
mfd_modes |= BABY_STEP_SET_VALUES; |
| 340 |
if (access_multiplexer->irreversible_commit) |
| 341 |
mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; |
| 342 |
if (access_multiplexer->object_syntax_checks) |
| 343 |
mfd_modes |= BABY_STEP_CHECK_OBJECT; |
| 344 |
|
| 345 |
if (access_multiplexer->undo_setup) |
| 346 |
mfd_modes |= BABY_STEP_UNDO_SETUP; |
| 347 |
if (access_multiplexer->undo_cleanup) |
| 348 |
mfd_modes |= BABY_STEP_UNDO_CLEANUP; |
| 349 |
if (access_multiplexer->undo_sets) |
| 350 |
mfd_modes |= BABY_STEP_UNDO_SETS; |
| 351 |
|
| 352 |
if (access_multiplexer->row_creation) |
| 353 |
mfd_modes |= BABY_STEP_ROW_CREATE; |
| 354 |
if (access_multiplexer->consistency_checks) |
| 355 |
mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; |
| 356 |
if (access_multiplexer->commit) |
| 357 |
mfd_modes |= BABY_STEP_COMMIT; |
| 358 |
if (access_multiplexer->undo_commit) |
| 359 |
mfd_modes |= BABY_STEP_UNDO_COMMIT; |
| 360 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 361 |
|
| 362 |
handler = netsnmp_baby_steps_handler_get(mfd_modes); |
| 363 |
netsnmp_inject_handler(reginfo, handler); |
| 364 |
|
| 365 |
/************************************************* |
| 366 |
* |
| 367 |
* inject row_merge helper with prefix rootoid_len + 2 (entry.col) |
| 368 |
*/ |
| 369 |
handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); |
| 370 |
netsnmp_inject_handler(reginfo, handler); |
| 371 |
|
| 372 |
/************************************************* |
| 373 |
* |
| 374 |
* inject container_table helper |
| 375 |
*/ |
| 376 |
handler = |
| 377 |
netsnmp_container_table_handler_get(tbl_info, |
| 378 |
ifTable_if_ctx.container, |
| 379 |
TABLE_CONTAINER_KEY_NETSNMP_INDEX); |
| 380 |
netsnmp_inject_handler(reginfo, handler); |
| 381 |
|
| 382 |
/************************************************* |
| 383 |
* |
| 384 |
* inject cache helper |
| 385 |
*/ |
| 386 |
if (NULL != ifTable_if_ctx.cache) { |
| 387 |
handler = netsnmp_cache_handler_get(ifTable_if_ctx.cache); |
| 388 |
netsnmp_inject_handler(reginfo, handler); |
| 389 |
} |
| 390 |
|
| 391 |
/* |
| 392 |
* register table |
| 393 |
*/ |
| 394 |
netsnmp_register_table(reginfo, tbl_info); |
| 395 |
|
| 396 |
|
| 397 |
/* |
| 398 |
* register ifTableLastChanged |
| 399 |
*/ |
| 400 |
{ |
| 401 |
static const oid iftlc_oid[] = { IFTABLE_LAST_CHANGE }; |
| 402 |
netsnmp_handler_registration *reginfo; |
| 403 |
netsnmp_watcher_info *winfo; |
| 404 |
|
| 405 |
reginfo = netsnmp_create_handler_registration |
| 406 |
("ifTableLastChanged", NULL, |
| 407 |
iftlc_oid, OID_LENGTH(iftlc_oid), HANDLER_CAN_RONLY); |
| 408 |
winfo = netsnmp_create_watcher_info(&ifTable_if_ctx.last_changed, |
| 409 |
sizeof(u_long), ASN_TIMETICKS, |
| 410 |
WATCHER_FIXED_SIZE); |
| 411 |
netsnmp_register_watched_scalar2(reginfo, winfo); |
| 412 |
} |
| 413 |
#endif /* USING_MIBII_INTERFACES_MODULE */ |
| 414 |
|
| 415 |
} /* _ifTable_initialize_interface */ |
| 416 |
|
| 417 |
/** |
| 418 |
* @internal |
| 419 |
* Shutdown the table ifTable |
| 420 |
*/ |
| 421 |
void |
| 422 |
_ifTable_shutdown_interface(ifTable_registration * reg_ptr) |
| 423 |
{ |
| 424 |
/* |
| 425 |
* shutdown the container |
| 426 |
*/ |
| 427 |
_ifTable_container_shutdown(&ifTable_if_ctx); |
| 428 |
} |
| 429 |
|
| 430 |
void |
| 431 |
ifTable_valid_columns_set(netsnmp_column_info *vc) |
| 432 |
{ |
| 433 |
ifTable_if_ctx.tbl_info.valid_columns = vc; |
| 434 |
} /* ifTable_valid_columns_set */ |
| 435 |
|
| 436 |
/** |
| 437 |
* @internal |
| 438 |
* convert the index component stored in the context to an oid |
| 439 |
*/ |
| 440 |
int |
| 441 |
ifTable_index_to_oid(netsnmp_index * oid_idx, ifTable_mib_index * mib_idx) |
| 442 |
{ |
| 443 |
if (oid_idx->len < 1) |
| 444 |
return SNMP_ERR_GENERR; |
| 445 |
|
| 446 |
oid_idx->oids[0] = mib_idx->ifIndex; |
| 447 |
oid_idx->len = 1; |
| 448 |
|
| 449 |
return SNMP_ERR_NOERROR; |
| 450 |
} /* ifTable_index_to_oid */ |
| 451 |
|
| 452 |
/** |
| 453 |
* extract ifTable indexes from a netsnmp_index |
| 454 |
* |
| 455 |
* @retval SNMP_ERR_NOERROR : no error |
| 456 |
* @retval SNMP_ERR_GENERR : error |
| 457 |
*/ |
| 458 |
int |
| 459 |
ifTable_index_from_oid(netsnmp_index * oid_idx, |
| 460 |
ifTable_mib_index * mib_idx) |
| 461 |
{ |
| 462 |
int err = SNMP_ERR_NOERROR; |
| 463 |
|
| 464 |
/* |
| 465 |
* temp storage for parsing indexes |
| 466 |
*/ |
| 467 |
/* |
| 468 |
* ifIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H |
| 469 |
*/ |
| 470 |
netsnmp_variable_list var_ifIndex; |
| 471 |
|
| 472 |
/* |
| 473 |
* set up varbinds |
| 474 |
*/ |
| 475 |
memset(&var_ifIndex, 0x00, sizeof(var_ifIndex)); |
| 476 |
var_ifIndex.type = ASN_INTEGER; |
| 477 |
|
| 478 |
/* |
| 479 |
* chain temp index varbinds together |
| 480 |
*/ |
| 481 |
var_ifIndex.next_variable = NULL; |
| 482 |
|
| 483 |
|
| 484 |
DEBUGMSGTL(("verbose:ifTable:ifTable_index_from_oid", "called\n")); |
| 485 |
|
| 486 |
/* |
| 487 |
* parse the oid into the individual index components |
| 488 |
*/ |
| 489 |
err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_ifIndex); |
| 490 |
if (err == SNMP_ERR_NOERROR) { |
| 491 |
/* |
| 492 |
* copy out values |
| 493 |
*/ |
| 494 |
mib_idx->ifIndex = *((long *) var_ifIndex.val.string); |
| 495 |
} |
| 496 |
|
| 497 |
/* |
| 498 |
* parsing may have allocated memory. free it. |
| 499 |
*/ |
| 500 |
snmp_reset_var_buffers(&var_ifIndex); |
| 501 |
|
| 502 |
return err; |
| 503 |
} /* ifTable_index_from_oid */ |
| 504 |
|
| 505 |
|
| 506 |
/* |
| 507 |
* ifTable_allocate_data |
| 508 |
* |
| 509 |
* Purpose: create new ifTable_data. |
| 510 |
*/ |
| 511 |
ifTable_data * |
| 512 |
ifTable_allocate_data(void) |
| 513 |
{ |
| 514 |
ifTable_data *rtn = SNMP_MALLOC_TYPEDEF(ifTable_data); |
| 515 |
|
| 516 |
DEBUGMSGTL(("verbose:ifTable:ifTable_allocate_data", "called\n")); |
| 517 |
|
| 518 |
if (NULL == rtn) { |
| 519 |
snmp_log(LOG_ERR, "unable to malloc memory for new " |
| 520 |
"ifTable_data.\n"); |
| 521 |
} |
| 522 |
|
| 523 |
return rtn; |
| 524 |
} /* ifTable_allocate_data */ |
| 525 |
|
| 526 |
/* |
| 527 |
* ifTable_release_data |
| 528 |
* |
| 529 |
* Purpose: release ifTable data. |
| 530 |
*/ |
| 531 |
void |
| 532 |
ifTable_release_data(ifTable_data * data) |
| 533 |
{ |
| 534 |
DEBUGMSGTL(("verbose:ifTable:ifTable_release_data", "called\n")); |
| 535 |
|
| 536 |
free(data); |
| 537 |
} /* ifTable_release_data */ |
| 538 |
|
| 539 |
/* |
| 540 |
********************************************************************* |
| 541 |
* @internal |
| 542 |
* allocate resources for a ifTable_rowreq_ctx |
| 543 |
*/ |
| 544 |
ifTable_rowreq_ctx * |
| 545 |
ifTable_allocate_rowreq_ctx(netsnmp_interface_entry *ifentry) |
| 546 |
{ |
| 547 |
ifTable_rowreq_ctx *rowreq_ctx = |
| 548 |
SNMP_MALLOC_TYPEDEF(ifTable_rowreq_ctx); |
| 549 |
|
| 550 |
DEBUGMSGTL(("internal:ifTable:ifTable_allocate_rowreq_ctx", |
| 551 |
"called\n")); |
| 552 |
|
| 553 |
if (NULL == rowreq_ctx) { |
| 554 |
snmp_log(LOG_ERR, "Couldn't allocate memory for a " |
| 555 |
"ifTable_rowreq_ctx.\n"); |
| 556 |
return NULL; |
| 557 |
} |
| 558 |
|
| 559 |
rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; |
| 560 |
|
| 561 |
rowreq_ctx->ifTable_data_list = NULL; |
| 562 |
|
| 563 |
/* |
| 564 |
* if we allocated data, call init routine |
| 565 |
*/ |
| 566 |
if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) |
| 567 |
rowreq_ctx->data.ifentry = ifentry; |
| 568 |
|
| 569 |
return rowreq_ctx; |
| 570 |
} /* ifTable_allocate_rowreq_ctx */ |
| 571 |
|
| 572 |
/* |
| 573 |
* @internal |
| 574 |
* release resources for a ifTable_rowreq_ctx |
| 575 |
*/ |
| 576 |
void |
| 577 |
ifTable_release_rowreq_ctx(ifTable_rowreq_ctx * rowreq_ctx) |
| 578 |
{ |
| 579 |
DEBUGMSGTL(("internal:ifTable:ifTable_release_rowreq_ctx", |
| 580 |
"called\n")); |
| 581 |
|
| 582 |
netsnmp_assert(NULL != rowreq_ctx); |
| 583 |
|
| 584 |
if (rowreq_ctx->data.ifentry) { |
| 585 |
netsnmp_access_interface_entry_free(rowreq_ctx->data.ifentry); |
| 586 |
rowreq_ctx->data.ifentry = NULL; |
| 587 |
} |
| 588 |
|
| 589 |
if (rowreq_ctx->undo) { |
| 590 |
ifTable_release_data(rowreq_ctx->undo); |
| 591 |
rowreq_ctx->undo = NULL; |
| 592 |
} |
| 593 |
|
| 594 |
/* |
| 595 |
* free index oid pointer |
| 596 |
*/ |
| 597 |
if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) |
| 598 |
free(rowreq_ctx->oid_idx.oids); |
| 599 |
|
| 600 |
SNMP_FREE(rowreq_ctx); |
| 601 |
} /* ifTable_release_rowreq_ctx */ |
| 602 |
|
| 603 |
/** |
| 604 |
* @internal |
| 605 |
* wrapper |
| 606 |
*/ |
| 607 |
static int |
| 608 |
_mfd_ifTable_pre_request(netsnmp_mib_handler *handler, |
| 609 |
netsnmp_handler_registration *reginfo, |
| 610 |
netsnmp_agent_request_info *agtreq_info, |
| 611 |
netsnmp_request_info *requests) |
| 612 |
{ |
| 613 |
int rc; |
| 614 |
|
| 615 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_pre_request", "called\n")); |
| 616 |
|
| 617 |
if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { |
| 618 |
DEBUGMSGTL(("internal:ifTable", |
| 619 |
"skipping additional pre_request\n")); |
| 620 |
return SNMP_ERR_NOERROR; |
| 621 |
} |
| 622 |
|
| 623 |
rc = ifTable_pre_request(ifTable_if_ctx.user_ctx); |
| 624 |
if (MFD_SUCCESS != rc) { |
| 625 |
/* |
| 626 |
* nothing we can do about it but log it |
| 627 |
*/ |
| 628 |
DEBUGMSGTL(("ifTable", "error %d from " |
| 629 |
"ifTable_pre_request\n", rc)); |
| 630 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 631 |
} |
| 632 |
|
| 633 |
return SNMP_ERR_NOERROR; |
| 634 |
} /* _mfd_ifTable_pre_request */ |
| 635 |
|
| 636 |
/** |
| 637 |
* @internal |
| 638 |
* wrapper |
| 639 |
*/ |
| 640 |
static int |
| 641 |
_mfd_ifTable_post_request(netsnmp_mib_handler *handler, |
| 642 |
netsnmp_handler_registration *reginfo, |
| 643 |
netsnmp_agent_request_info *agtreq_info, |
| 644 |
netsnmp_request_info *requests) |
| 645 |
{ |
| 646 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 647 |
netsnmp_container_table_row_extract(requests); |
| 648 |
int rc, packet_rc; |
| 649 |
|
| 650 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_post_request", "called\n")); |
| 651 |
|
| 652 |
/* |
| 653 |
* release row context, if deleted |
| 654 |
*/ |
| 655 |
if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) |
| 656 |
ifTable_release_rowreq_ctx(rowreq_ctx); |
| 657 |
|
| 658 |
/* |
| 659 |
* wait for last call before calling user |
| 660 |
*/ |
| 661 |
if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { |
| 662 |
DEBUGMSGTL(("internal:ifTable", |
| 663 |
"waiting for last post_request\n")); |
| 664 |
return SNMP_ERR_NOERROR; |
| 665 |
} |
| 666 |
|
| 667 |
packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); |
| 668 |
if ((MFD_SUCCESS != packet_rc) && ifTable_dirty_get()) { |
| 669 |
/* |
| 670 |
* we shouldn't get here. the undo steps should also clear |
| 671 |
* the dirty flags. |
| 672 |
*/ |
| 673 |
snmp_log(LOG_WARNING, "ifTable dirty flag set in post_request " |
| 674 |
"but status != SUCCESS.\n"); |
| 675 |
} |
| 676 |
|
| 677 |
rc = ifTable_post_request(ifTable_if_ctx.user_ctx, packet_rc); |
| 678 |
if (MFD_SUCCESS != rc) { |
| 679 |
/* |
| 680 |
* nothing we can do about it but log it |
| 681 |
*/ |
| 682 |
DEBUGMSGTL(("ifTable", "error %d from " |
| 683 |
"ifTable_post_request\n", rc)); |
| 684 |
} |
| 685 |
|
| 686 |
return SNMP_ERR_NOERROR; |
| 687 |
} /* _mfd_ifTable_post_request */ |
| 688 |
|
| 689 |
/** |
| 690 |
* @internal |
| 691 |
* wrapper |
| 692 |
*/ |
| 693 |
static int |
| 694 |
_mfd_ifTable_object_lookup(netsnmp_mib_handler *handler, |
| 695 |
netsnmp_handler_registration *reginfo, |
| 696 |
netsnmp_agent_request_info *agtreq_info, |
| 697 |
netsnmp_request_info *requests) |
| 698 |
{ |
| 699 |
int rc = SNMP_ERR_NOERROR; |
| 700 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 701 |
netsnmp_container_table_row_extract(requests); |
| 702 |
|
| 703 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_object_lookup", |
| 704 |
"called\n")); |
| 705 |
|
| 706 |
/* |
| 707 |
* get our context from mfd |
| 708 |
* ifTable_interface_ctx *if_ctx = |
| 709 |
* (ifTable_interface_ctx *)reginfo->my_reg_void; |
| 710 |
*/ |
| 711 |
|
| 712 |
if (NULL == rowreq_ctx) { |
| 713 |
rc = SNMP_ERR_NOCREATION; |
| 714 |
} |
| 715 |
|
| 716 |
if (MFD_SUCCESS != rc) |
| 717 |
netsnmp_request_set_error_all(requests, rc); |
| 718 |
else |
| 719 |
ifTable_row_prep(rowreq_ctx); |
| 720 |
|
| 721 |
return SNMP_VALIDATE_ERR(rc); |
| 722 |
} /* _mfd_ifTable_object_lookup */ |
| 723 |
|
| 724 |
/*********************************************************************** |
| 725 |
* |
| 726 |
* GET processing |
| 727 |
* |
| 728 |
***********************************************************************/ |
| 729 |
/* |
| 730 |
* @internal |
| 731 |
* Retrieve the value for a particular column |
| 732 |
*/ |
| 733 |
NETSNMP_STATIC_INLINE int |
| 734 |
_ifTable_get_column(ifTable_rowreq_ctx * rowreq_ctx, |
| 735 |
netsnmp_variable_list * var, int column) |
| 736 |
{ |
| 737 |
int rc = SNMPERR_SUCCESS; |
| 738 |
|
| 739 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_get_column", |
| 740 |
"called for %d\n", column)); |
| 741 |
|
| 742 |
|
| 743 |
netsnmp_assert(NULL != rowreq_ctx); |
| 744 |
|
| 745 |
switch (column) { |
| 746 |
|
| 747 |
/* |
| 748 |
* (INDEX) ifIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H |
| 749 |
*/ |
| 750 |
case COLUMN_IFINDEX: |
| 751 |
var->type = ASN_INTEGER; |
| 752 |
var->val_len = sizeof(long); |
| 753 |
(*var->val.integer) = rowreq_ctx->tbl_idx.ifIndex; |
| 754 |
break; |
| 755 |
|
| 756 |
/* |
| 757 |
* ifDescr(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H |
| 758 |
*/ |
| 759 |
case COLUMN_IFDESCR: |
| 760 |
var->type = ASN_OCTET_STR; |
| 761 |
rc = ifDescr_get(rowreq_ctx, (char **) &var->val.string, |
| 762 |
&var->val_len); |
| 763 |
break; |
| 764 |
|
| 765 |
/* |
| 766 |
* ifType(3)/IANAifType/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h |
| 767 |
*/ |
| 768 |
case COLUMN_IFTYPE: |
| 769 |
var->val_len = sizeof(u_long); |
| 770 |
var->type = ASN_INTEGER; |
| 771 |
rc = ifType_get(rowreq_ctx, (u_long *) var->val.string); |
| 772 |
break; |
| 773 |
|
| 774 |
/* |
| 775 |
* ifMtu(4)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h |
| 776 |
*/ |
| 777 |
case COLUMN_IFMTU: |
| 778 |
var->val_len = sizeof(long); |
| 779 |
var->type = ASN_INTEGER; |
| 780 |
rc = ifMtu_get(rowreq_ctx, (long *) var->val.string); |
| 781 |
break; |
| 782 |
|
| 783 |
/* |
| 784 |
* ifSpeed(5)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h |
| 785 |
*/ |
| 786 |
case COLUMN_IFSPEED: |
| 787 |
var->val_len = sizeof(u_long); |
| 788 |
var->type = ASN_GAUGE; |
| 789 |
rc = ifSpeed_get(rowreq_ctx, (u_long *) var->val.string); |
| 790 |
break; |
| 791 |
|
| 792 |
/* |
| 793 |
* ifPhysAddress(6)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/w/e/r/d/H |
| 794 |
*/ |
| 795 |
case COLUMN_IFPHYSADDRESS: |
| 796 |
var->type = ASN_OCTET_STR; |
| 797 |
rc = ifPhysAddress_get(rowreq_ctx, (char **) &var->val.string, |
| 798 |
&var->val_len); |
| 799 |
break; |
| 800 |
|
| 801 |
/* |
| 802 |
* ifAdminStatus(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 803 |
*/ |
| 804 |
case COLUMN_IFADMINSTATUS: |
| 805 |
var->val_len = sizeof(u_long); |
| 806 |
var->type = ASN_INTEGER; |
| 807 |
rc = ifAdminStatus_get(rowreq_ctx, (u_long *) var->val.string); |
| 808 |
break; |
| 809 |
|
| 810 |
/* |
| 811 |
* ifOperStatus(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h |
| 812 |
*/ |
| 813 |
case COLUMN_IFOPERSTATUS: |
| 814 |
var->val_len = sizeof(u_long); |
| 815 |
var->type = ASN_INTEGER; |
| 816 |
rc = ifOperStatus_get(rowreq_ctx, (u_long *) var->val.string); |
| 817 |
break; |
| 818 |
|
| 819 |
/* |
| 820 |
* ifLastChange(9)/TICKS/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h |
| 821 |
*/ |
| 822 |
case COLUMN_IFLASTCHANGE: |
| 823 |
var->val_len = sizeof(u_long); |
| 824 |
var->type = ASN_TIMETICKS; |
| 825 |
rc = ifLastChange_get(rowreq_ctx, (u_long *) var->val.string); |
| 826 |
break; |
| 827 |
|
| 828 |
/* |
| 829 |
* ifInOctets(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 830 |
*/ |
| 831 |
case COLUMN_IFINOCTETS: |
| 832 |
var->val_len = sizeof(u_long); |
| 833 |
var->type = ASN_COUNTER; |
| 834 |
rc = ifInOctets_get(rowreq_ctx, (u_long *) var->val.string); |
| 835 |
break; |
| 836 |
|
| 837 |
/* |
| 838 |
* ifInUcastPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 839 |
*/ |
| 840 |
case COLUMN_IFINUCASTPKTS: |
| 841 |
var->val_len = sizeof(u_long); |
| 842 |
var->type = ASN_COUNTER; |
| 843 |
rc = ifInUcastPkts_get(rowreq_ctx, (u_long *) var->val.string); |
| 844 |
break; |
| 845 |
|
| 846 |
/* |
| 847 |
* ifInNUcastPkts(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 848 |
*/ |
| 849 |
case COLUMN_IFINNUCASTPKTS: |
| 850 |
var->val_len = sizeof(u_long); |
| 851 |
var->type = ASN_COUNTER; |
| 852 |
rc = ifInNUcastPkts_get(rowreq_ctx, (u_long *) var->val.string); |
| 853 |
break; |
| 854 |
|
| 855 |
/* |
| 856 |
* ifInDiscards(13)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 857 |
*/ |
| 858 |
case COLUMN_IFINDISCARDS: |
| 859 |
var->val_len = sizeof(u_long); |
| 860 |
var->type = ASN_COUNTER; |
| 861 |
rc = ifInDiscards_get(rowreq_ctx, (u_long *) var->val.string); |
| 862 |
break; |
| 863 |
|
| 864 |
/* |
| 865 |
* ifInErrors(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 866 |
*/ |
| 867 |
case COLUMN_IFINERRORS: |
| 868 |
var->val_len = sizeof(u_long); |
| 869 |
var->type = ASN_COUNTER; |
| 870 |
rc = ifInErrors_get(rowreq_ctx, (u_long *) var->val.string); |
| 871 |
break; |
| 872 |
|
| 873 |
/* |
| 874 |
* ifInUnknownProtos(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 875 |
*/ |
| 876 |
case COLUMN_IFINUNKNOWNPROTOS: |
| 877 |
var->val_len = sizeof(u_long); |
| 878 |
var->type = ASN_COUNTER; |
| 879 |
rc = ifInUnknownProtos_get(rowreq_ctx, (u_long *) var->val.string); |
| 880 |
break; |
| 881 |
|
| 882 |
/* |
| 883 |
* ifOutOctets(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 884 |
*/ |
| 885 |
case COLUMN_IFOUTOCTETS: |
| 886 |
var->val_len = sizeof(u_long); |
| 887 |
var->type = ASN_COUNTER; |
| 888 |
rc = ifOutOctets_get(rowreq_ctx, (u_long *) var->val.string); |
| 889 |
break; |
| 890 |
|
| 891 |
/* |
| 892 |
* ifOutUcastPkts(17)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 893 |
*/ |
| 894 |
case COLUMN_IFOUTUCASTPKTS: |
| 895 |
var->val_len = sizeof(u_long); |
| 896 |
var->type = ASN_COUNTER; |
| 897 |
rc = ifOutUcastPkts_get(rowreq_ctx, (u_long *) var->val.string); |
| 898 |
break; |
| 899 |
|
| 900 |
/* |
| 901 |
* ifOutNUcastPkts(18)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 902 |
*/ |
| 903 |
case COLUMN_IFOUTNUCASTPKTS: |
| 904 |
var->val_len = sizeof(u_long); |
| 905 |
var->type = ASN_COUNTER; |
| 906 |
rc = ifOutNUcastPkts_get(rowreq_ctx, (u_long *) var->val.string); |
| 907 |
break; |
| 908 |
|
| 909 |
/* |
| 910 |
* ifOutDiscards(19)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 911 |
*/ |
| 912 |
case COLUMN_IFOUTDISCARDS: |
| 913 |
var->val_len = sizeof(u_long); |
| 914 |
var->type = ASN_COUNTER; |
| 915 |
rc = ifOutDiscards_get(rowreq_ctx, (u_long *) var->val.string); |
| 916 |
break; |
| 917 |
|
| 918 |
/* |
| 919 |
* ifOutErrors(20)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 920 |
*/ |
| 921 |
case COLUMN_IFOUTERRORS: |
| 922 |
var->val_len = sizeof(u_long); |
| 923 |
var->type = ASN_COUNTER; |
| 924 |
rc = ifOutErrors_get(rowreq_ctx, (u_long *) var->val.string); |
| 925 |
break; |
| 926 |
|
| 927 |
/* |
| 928 |
* ifOutQLen(21)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h |
| 929 |
*/ |
| 930 |
case COLUMN_IFOUTQLEN: |
| 931 |
var->val_len = sizeof(u_long); |
| 932 |
var->type = ASN_GAUGE; |
| 933 |
rc = ifOutQLen_get(rowreq_ctx, (u_long *) var->val.string); |
| 934 |
break; |
| 935 |
|
| 936 |
/* |
| 937 |
* ifSpecific(22)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h |
| 938 |
*/ |
| 939 |
case COLUMN_IFSPECIFIC: |
| 940 |
var->type = ASN_OBJECT_ID; |
| 941 |
rc = ifSpecific_get(rowreq_ctx, (oid **) & var->val.string, |
| 942 |
&var->val_len); |
| 943 |
break; |
| 944 |
|
| 945 |
default: |
| 946 |
snmp_log(LOG_ERR, "unknown column %d in _ifTable_get_column\n", |
| 947 |
column); |
| 948 |
break; |
| 949 |
} |
| 950 |
|
| 951 |
return rc; |
| 952 |
} /* _ifTable_get_column */ |
| 953 |
|
| 954 |
int |
| 955 |
_mfd_ifTable_get_values(netsnmp_mib_handler *handler, |
| 956 |
netsnmp_handler_registration *reginfo, |
| 957 |
netsnmp_agent_request_info *agtreq_info, |
| 958 |
netsnmp_request_info *requests) |
| 959 |
{ |
| 960 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 961 |
netsnmp_container_table_row_extract(requests); |
| 962 |
netsnmp_table_request_info *tri; |
| 963 |
u_char *old_string; |
| 964 |
void (*dataFreeHook) (void *); |
| 965 |
int rc; |
| 966 |
|
| 967 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_get_values", "called\n")); |
| 968 |
|
| 969 |
netsnmp_assert(NULL != rowreq_ctx); |
| 970 |
|
| 971 |
for (; requests; requests = requests->next) { |
| 972 |
/* |
| 973 |
* save old pointer, so we can free it if replaced |
| 974 |
*/ |
| 975 |
old_string = requests->requestvb->val.string; |
| 976 |
dataFreeHook = requests->requestvb->dataFreeHook; |
| 977 |
if (NULL == requests->requestvb->val.string) { |
| 978 |
requests->requestvb->val.string = requests->requestvb->buf; |
| 979 |
requests->requestvb->val_len = |
| 980 |
sizeof(requests->requestvb->buf); |
| 981 |
} else if (requests->requestvb->buf == |
| 982 |
requests->requestvb->val.string) { |
| 983 |
if (requests->requestvb->val_len != |
| 984 |
sizeof(requests->requestvb->buf)) |
| 985 |
requests->requestvb->val_len = |
| 986 |
sizeof(requests->requestvb->buf); |
| 987 |
} |
| 988 |
|
| 989 |
/* |
| 990 |
* get column data |
| 991 |
*/ |
| 992 |
tri = netsnmp_extract_table_info(requests); |
| 993 |
if (NULL == tri) |
| 994 |
continue; |
| 995 |
|
| 996 |
rc = _ifTable_get_column(rowreq_ctx, requests->requestvb, |
| 997 |
tri->colnum); |
| 998 |
if (rc) { |
| 999 |
if (MFD_SKIP == rc) { |
| 1000 |
requests->requestvb->type = SNMP_NOSUCHINSTANCE; |
| 1001 |
rc = SNMP_ERR_NOERROR; |
| 1002 |
} |
| 1003 |
} else if (NULL == requests->requestvb->val.string) { |
| 1004 |
snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); |
| 1005 |
rc = SNMP_ERR_GENERR; |
| 1006 |
} |
| 1007 |
if (rc) |
| 1008 |
netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
| 1009 |
|
| 1010 |
/* |
| 1011 |
* if the buffer wasn't used previously for the old data (i.e. it |
| 1012 |
* was allocated memory) and the get routine replaced the pointer, |
| 1013 |
* we need to free the previous pointer. |
| 1014 |
*/ |
| 1015 |
if (old_string && (old_string != requests->requestvb->buf) && |
| 1016 |
(requests->requestvb->val.string != old_string)) { |
| 1017 |
if (dataFreeHook) |
| 1018 |
(*dataFreeHook) (old_string); |
| 1019 |
else |
| 1020 |
free(old_string); |
| 1021 |
} |
| 1022 |
} /* for results */ |
| 1023 |
|
| 1024 |
return SNMP_ERR_NOERROR; |
| 1025 |
} /* _mfd_ifTable_get_values */ |
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 1030 |
|
| 1031 |
/*********************************************************************** |
| 1032 |
* |
| 1033 |
* SET processing |
| 1034 |
* |
| 1035 |
***********************************************************************/ |
| 1036 |
|
| 1037 |
/*---------------------------------------------------------------------- |
| 1038 |
* |
| 1039 |
* SET: Syntax checks |
| 1040 |
* |
| 1041 |
*---------------------------------------------------------------------*/ |
| 1042 |
/* |
| 1043 |
* @internal |
| 1044 |
* Check the syntax for a particular column |
| 1045 |
*/ |
| 1046 |
NETSNMP_STATIC_INLINE int |
| 1047 |
_ifTable_check_column(ifTable_rowreq_ctx * rowreq_ctx, |
| 1048 |
netsnmp_variable_list * var, int column) |
| 1049 |
{ |
| 1050 |
int rc = SNMPERR_SUCCESS; |
| 1051 |
|
| 1052 |
DEBUGMSGTL(("internal:ifTable:_ifTable_check_column", |
| 1053 |
"called for %d\n", column)); |
| 1054 |
|
| 1055 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1056 |
|
| 1057 |
switch (column) { |
| 1058 |
/* |
| 1059 |
* (INDEX) ifIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H |
| 1060 |
*/ |
| 1061 |
case COLUMN_IFINDEX: |
| 1062 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 1063 |
break; |
| 1064 |
|
| 1065 |
/* |
| 1066 |
* ifDescr(2)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H |
| 1067 |
*/ |
| 1068 |
case COLUMN_IFDESCR: |
| 1069 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1070 |
break; |
| 1071 |
|
| 1072 |
/* |
| 1073 |
* ifType(3)/IANAifType/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h |
| 1074 |
*/ |
| 1075 |
case COLUMN_IFTYPE: |
| 1076 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1077 |
break; |
| 1078 |
|
| 1079 |
/* |
| 1080 |
* ifMtu(4)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h |
| 1081 |
*/ |
| 1082 |
case COLUMN_IFMTU: |
| 1083 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1084 |
break; |
| 1085 |
|
| 1086 |
/* |
| 1087 |
* ifSpeed(5)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h |
| 1088 |
*/ |
| 1089 |
case COLUMN_IFSPEED: |
| 1090 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1091 |
break; |
| 1092 |
|
| 1093 |
/* |
| 1094 |
* ifPhysAddress(6)/PhysAddress/ASN_OCTET_STR/char(char)//L/A/w/e/r/d/H |
| 1095 |
*/ |
| 1096 |
case COLUMN_IFPHYSADDRESS: |
| 1097 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1098 |
break; |
| 1099 |
|
| 1100 |
/* |
| 1101 |
* ifAdminStatus(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1102 |
*/ |
| 1103 |
case COLUMN_IFADMINSTATUS: |
| 1104 |
/** special case: we are using exernal storage w/smaller data size |
| 1105 |
** for storage, so we can't use sizeof on data context. So we |
| 1106 |
** just check that it's the expected size. The enum tests below |
| 1107 |
** will ensure that there is no data overflow. */ |
| 1108 |
rc = netsnmp_check_vb_type_and_size(var, ASN_INTEGER, |
| 1109 |
sizeof(u_long)); |
| 1110 |
/* |
| 1111 |
* check that the value is one of defined enums |
| 1112 |
*/ |
| 1113 |
if ((SNMPERR_SUCCESS == rc) |
| 1114 |
&& (*var->val.integer != IFADMINSTATUS_UP) |
| 1115 |
&& (*var->val.integer != IFADMINSTATUS_DOWN) |
| 1116 |
&& (*var->val.integer != IFADMINSTATUS_TESTING) |
| 1117 |
) { |
| 1118 |
rc = SNMP_ERR_WRONGVALUE; |
| 1119 |
} |
| 1120 |
if (SNMPERR_SUCCESS != rc) { |
| 1121 |
DEBUGMSGTL(("ifTable:_ifTable_check_column:ifAdminStatus", |
| 1122 |
"varbind validation failed (eg bad type or size)\n")); |
| 1123 |
} else { |
| 1124 |
rc = ifAdminStatus_check_value(rowreq_ctx, |
| 1125 |
*((u_long *) var->val.string)); |
| 1126 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1127 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1128 |
snmp_log(LOG_ERR, |
| 1129 |
"bad rc %d from ifAdminStatus_check_value\n", rc); |
| 1130 |
rc = SNMP_ERR_GENERR; |
| 1131 |
} |
| 1132 |
} |
| 1133 |
break; |
| 1134 |
|
| 1135 |
/* |
| 1136 |
* ifOperStatus(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h |
| 1137 |
*/ |
| 1138 |
case COLUMN_IFOPERSTATUS: |
| 1139 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1140 |
break; |
| 1141 |
|
| 1142 |
/* |
| 1143 |
* ifLastChange(9)/TICKS/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h |
| 1144 |
*/ |
| 1145 |
case COLUMN_IFLASTCHANGE: |
| 1146 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1147 |
break; |
| 1148 |
|
| 1149 |
/* |
| 1150 |
* ifInOctets(10)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1151 |
*/ |
| 1152 |
case COLUMN_IFINOCTETS: |
| 1153 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1154 |
break; |
| 1155 |
|
| 1156 |
/* |
| 1157 |
* ifInUcastPkts(11)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1158 |
*/ |
| 1159 |
case COLUMN_IFINUCASTPKTS: |
| 1160 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1161 |
break; |
| 1162 |
|
| 1163 |
/* |
| 1164 |
* ifInNUcastPkts(12)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1165 |
*/ |
| 1166 |
case COLUMN_IFINNUCASTPKTS: |
| 1167 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1168 |
break; |
| 1169 |
|
| 1170 |
/* |
| 1171 |
* ifInDiscards(13)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1172 |
*/ |
| 1173 |
case COLUMN_IFINDISCARDS: |
| 1174 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1175 |
break; |
| 1176 |
|
| 1177 |
/* |
| 1178 |
* ifInErrors(14)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1179 |
*/ |
| 1180 |
case COLUMN_IFINERRORS: |
| 1181 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1182 |
break; |
| 1183 |
|
| 1184 |
/* |
| 1185 |
* ifInUnknownProtos(15)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1186 |
*/ |
| 1187 |
case COLUMN_IFINUNKNOWNPROTOS: |
| 1188 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1189 |
break; |
| 1190 |
|
| 1191 |
/* |
| 1192 |
* ifOutOctets(16)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1193 |
*/ |
| 1194 |
case COLUMN_IFOUTOCTETS: |
| 1195 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1196 |
break; |
| 1197 |
|
| 1198 |
/* |
| 1199 |
* ifOutUcastPkts(17)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1200 |
*/ |
| 1201 |
case COLUMN_IFOUTUCASTPKTS: |
| 1202 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1203 |
break; |
| 1204 |
|
| 1205 |
/* |
| 1206 |
* ifOutNUcastPkts(18)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1207 |
*/ |
| 1208 |
case COLUMN_IFOUTNUCASTPKTS: |
| 1209 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1210 |
break; |
| 1211 |
|
| 1212 |
/* |
| 1213 |
* ifOutDiscards(19)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1214 |
*/ |
| 1215 |
case COLUMN_IFOUTDISCARDS: |
| 1216 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1217 |
break; |
| 1218 |
|
| 1219 |
/* |
| 1220 |
* ifOutErrors(20)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h |
| 1221 |
*/ |
| 1222 |
case COLUMN_IFOUTERRORS: |
| 1223 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1224 |
break; |
| 1225 |
|
| 1226 |
/* |
| 1227 |
* ifOutQLen(21)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h |
| 1228 |
*/ |
| 1229 |
case COLUMN_IFOUTQLEN: |
| 1230 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1231 |
break; |
| 1232 |
|
| 1233 |
/* |
| 1234 |
* ifSpecific(22)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/w/e/r/d/h |
| 1235 |
*/ |
| 1236 |
case COLUMN_IFSPECIFIC: |
| 1237 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1238 |
break; |
| 1239 |
|
| 1240 |
default: /** We shouldn't get here */ |
| 1241 |
rc = SNMP_ERR_GENERR; |
| 1242 |
snmp_log(LOG_ERR, "unknown column %d in _ifTable_check_column\n", |
| 1243 |
column); |
| 1244 |
} |
| 1245 |
|
| 1246 |
return rc; |
| 1247 |
} /* _ifTable_check_column */ |
| 1248 |
|
| 1249 |
int |
| 1250 |
_mfd_ifTable_check_objects(netsnmp_mib_handler *handler, |
| 1251 |
netsnmp_handler_registration *reginfo, |
| 1252 |
netsnmp_agent_request_info *agtreq_info, |
| 1253 |
netsnmp_request_info *requests) |
| 1254 |
{ |
| 1255 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1256 |
netsnmp_container_table_row_extract(requests); |
| 1257 |
netsnmp_table_request_info *tri; |
| 1258 |
int rc; |
| 1259 |
|
| 1260 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_check_objects", |
| 1261 |
"called\n")); |
| 1262 |
|
| 1263 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1264 |
|
| 1265 |
for (; requests; requests = requests->next) { |
| 1266 |
|
| 1267 |
/* |
| 1268 |
* get column number from table request info, and check that column |
| 1269 |
*/ |
| 1270 |
tri = netsnmp_extract_table_info(requests); |
| 1271 |
if (NULL == tri) |
| 1272 |
continue; |
| 1273 |
|
| 1274 |
rc = _ifTable_check_column(rowreq_ctx, requests->requestvb, |
| 1275 |
tri->colnum); |
| 1276 |
if (rc) { |
| 1277 |
netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
| 1278 |
break; |
| 1279 |
} |
| 1280 |
|
| 1281 |
} /* for results */ |
| 1282 |
|
| 1283 |
return SNMP_ERR_NOERROR; |
| 1284 |
} /* _mfd_ifTable_check_objects */ |
| 1285 |
|
| 1286 |
/*---------------------------------------------------------------------- |
| 1287 |
* |
| 1288 |
* SET: check dependencies |
| 1289 |
* |
| 1290 |
*---------------------------------------------------------------------*/ |
| 1291 |
/* |
| 1292 |
* @internal |
| 1293 |
* Check dependencies wrapper |
| 1294 |
*/ |
| 1295 |
static int |
| 1296 |
_mfd_ifTable_check_dependencies(netsnmp_mib_handler *handler, |
| 1297 |
netsnmp_handler_registration *reginfo, |
| 1298 |
netsnmp_agent_request_info *agtreq_info, |
| 1299 |
netsnmp_request_info *requests) |
| 1300 |
{ |
| 1301 |
int rc; |
| 1302 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1303 |
netsnmp_container_table_row_extract(requests); |
| 1304 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_check_dependencies", |
| 1305 |
"called\n")); |
| 1306 |
|
| 1307 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1308 |
|
| 1309 |
rc = ifTable_check_dependencies(rowreq_ctx); |
| 1310 |
if (rc) { |
| 1311 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1312 |
"ifTable_check_dependencies\n", rc)); |
| 1313 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 1314 |
} |
| 1315 |
|
| 1316 |
return SNMP_ERR_NOERROR; |
| 1317 |
} /* _mfd_ifTable_check_dependencies */ |
| 1318 |
|
| 1319 |
/*---------------------------------------------------------------------- |
| 1320 |
* |
| 1321 |
* SET: Undo setup |
| 1322 |
* |
| 1323 |
*---------------------------------------------------------------------*/ |
| 1324 |
/* |
| 1325 |
* @internal |
| 1326 |
* Set the value for a particular column |
| 1327 |
*/ |
| 1328 |
NETSNMP_STATIC_INLINE int |
| 1329 |
_ifTable_undo_setup_column(ifTable_rowreq_ctx * rowreq_ctx, int column) |
| 1330 |
{ |
| 1331 |
int rc = SNMPERR_SUCCESS; |
| 1332 |
|
| 1333 |
DEBUGMSGTL(("internal:ifTable:_ifTable_undo_setup_column", |
| 1334 |
"called for %d\n", column)); |
| 1335 |
|
| 1336 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1337 |
|
| 1338 |
switch (column) { |
| 1339 |
|
| 1340 |
/* |
| 1341 |
* ifAdminStatus(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1342 |
*/ |
| 1343 |
case COLUMN_IFADMINSTATUS: |
| 1344 |
rowreq_ctx->column_set_flags |= COLUMN_IFADMINSTATUS_FLAG; |
| 1345 |
rc = ifAdminStatus_undo_setup(rowreq_ctx); |
| 1346 |
break; |
| 1347 |
|
| 1348 |
default: |
| 1349 |
snmp_log(LOG_ERR, |
| 1350 |
"unknown column %d in _ifTable_undo_setup_column\n", |
| 1351 |
column); |
| 1352 |
break; |
| 1353 |
} |
| 1354 |
|
| 1355 |
return rc; |
| 1356 |
} /* _ifTable_undo_setup_column */ |
| 1357 |
|
| 1358 |
int |
| 1359 |
_mfd_ifTable_undo_setup_allocate(ifTable_rowreq_ctx *rowreq_ctx) |
| 1360 |
{ |
| 1361 |
int rc = MFD_SUCCESS; |
| 1362 |
|
| 1363 |
if (NULL == rowreq_ctx) |
| 1364 |
return MFD_ERROR; |
| 1365 |
|
| 1366 |
/* |
| 1367 |
* other tables share our container/context and call |
| 1368 |
* this function. so we need to check and see if |
| 1369 |
* someone else already allocated the ifentry |
| 1370 |
*/ |
| 1371 |
if (NULL == rowreq_ctx->undo) { |
| 1372 |
rowreq_ctx->undo = ifTable_allocate_data(); |
| 1373 |
if (NULL == rowreq_ctx->undo) { |
| 1374 |
/** msg already logged */ |
| 1375 |
rc = SNMP_ERR_RESOURCEUNAVAILABLE; |
| 1376 |
} |
| 1377 |
else { |
| 1378 |
rowreq_ctx->undo->ifentry = |
| 1379 |
netsnmp_access_interface_entry_create(rowreq_ctx->data.ifentry-> |
| 1380 |
name, |
| 1381 |
rowreq_ctx->data.ifentry-> |
| 1382 |
index); |
| 1383 |
if (NULL == rowreq_ctx->undo->ifentry) { |
| 1384 |
rc = SNMP_ERR_RESOURCEUNAVAILABLE; |
| 1385 |
ifTable_release_data(rowreq_ctx->undo); |
| 1386 |
rowreq_ctx->undo = NULL; |
| 1387 |
} |
| 1388 |
else { |
| 1389 |
netsnmp_access_interface_entry_copy(rowreq_ctx->undo->ifentry, |
| 1390 |
rowreq_ctx->data.ifentry); |
| 1391 |
netsnmp_assert(0 == rowreq_ctx->undo_ref_count); |
| 1392 |
} |
| 1393 |
} |
| 1394 |
} |
| 1395 |
++rowreq_ctx->undo_ref_count; |
| 1396 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_undo_setup_allocate", |
| 1397 |
"++undo_refcount = %d\n",rowreq_ctx->undo_ref_count)); |
| 1398 |
|
| 1399 |
return rc; |
| 1400 |
} |
| 1401 |
|
| 1402 |
/** |
| 1403 |
* @internal |
| 1404 |
* undo setup |
| 1405 |
*/ |
| 1406 |
int |
| 1407 |
_mfd_ifTable_undo_setup(netsnmp_mib_handler *handler, |
| 1408 |
netsnmp_handler_registration *reginfo, |
| 1409 |
netsnmp_agent_request_info *agtreq_info, |
| 1410 |
netsnmp_request_info *requests) |
| 1411 |
{ |
| 1412 |
int rc; |
| 1413 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1414 |
netsnmp_container_table_row_extract(requests); |
| 1415 |
|
| 1416 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_undo_setup", "called\n")); |
| 1417 |
|
| 1418 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1419 |
|
| 1420 |
/* |
| 1421 |
* allocate undo context |
| 1422 |
*/ |
| 1423 |
rc = _mfd_ifTable_undo_setup_allocate(rowreq_ctx); |
| 1424 |
if (MFD_SUCCESS != rc) { |
| 1425 |
netsnmp_request_set_error_all(requests, rc); |
| 1426 |
return SNMP_ERR_NOERROR; |
| 1427 |
} |
| 1428 |
|
| 1429 |
/* |
| 1430 |
* row undo setup |
| 1431 |
*/ |
| 1432 |
rc = ifTable_undo_setup(rowreq_ctx); |
| 1433 |
if (MFD_SUCCESS != rc) { |
| 1434 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1435 |
"ifTable_undo_setup\n", rc)); |
| 1436 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 1437 |
} else { |
| 1438 |
/* |
| 1439 |
* column undo setup |
| 1440 |
*/ |
| 1441 |
netsnmp_table_request_info *tri; |
| 1442 |
for (; requests; requests = requests->next) { |
| 1443 |
/* |
| 1444 |
* set column data |
| 1445 |
*/ |
| 1446 |
tri = netsnmp_extract_table_info(requests); |
| 1447 |
if (NULL == tri) |
| 1448 |
continue; |
| 1449 |
|
| 1450 |
rc = _ifTable_undo_setup_column(rowreq_ctx, tri->colnum); |
| 1451 |
if (MFD_SUCCESS != rc) { |
| 1452 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1453 |
"ifTable_undo_setup_column\n", rc)); |
| 1454 |
netsnmp_set_request_error(agtreq_info, requests, |
| 1455 |
SNMP_VALIDATE_ERR(rc)); |
| 1456 |
} |
| 1457 |
} /* for results */ |
| 1458 |
} |
| 1459 |
|
| 1460 |
return SNMP_ERR_NOERROR; |
| 1461 |
} /* _mfd_ifTable_undo_setup */ |
| 1462 |
|
| 1463 |
void |
| 1464 |
_mfd_ifTable_undo_setup_release(ifTable_rowreq_ctx *rowreq_ctx) |
| 1465 |
{ |
| 1466 |
netsnmp_assert(rowreq_ctx->undo_ref_count > 0); |
| 1467 |
--rowreq_ctx->undo_ref_count; |
| 1468 |
snmp_log(LOG_ERR, "undo_refcount at %d\n", rowreq_ctx->undo_ref_count); |
| 1469 |
|
| 1470 |
if (0 == rowreq_ctx->undo_ref_count) { |
| 1471 |
netsnmp_access_interface_entry_free(rowreq_ctx->undo->ifentry); |
| 1472 |
ifTable_release_data(rowreq_ctx->undo); |
| 1473 |
rowreq_ctx->undo = NULL; |
| 1474 |
} |
| 1475 |
} |
| 1476 |
|
| 1477 |
/** |
| 1478 |
* @internal |
| 1479 |
* undo setup |
| 1480 |
*/ |
| 1481 |
int |
| 1482 |
_mfd_ifTable_undo_cleanup(netsnmp_mib_handler *handler, |
| 1483 |
netsnmp_handler_registration *reginfo, |
| 1484 |
netsnmp_agent_request_info *agtreq_info, |
| 1485 |
netsnmp_request_info *requests) |
| 1486 |
{ |
| 1487 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1488 |
netsnmp_container_table_row_extract(requests); |
| 1489 |
int rc; |
| 1490 |
|
| 1491 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_undo_cleanup", "called\n")); |
| 1492 |
|
| 1493 |
/* |
| 1494 |
* failed row create in early stages has no rowreq_ctx |
| 1495 |
*/ |
| 1496 |
if (NULL == rowreq_ctx) |
| 1497 |
return MFD_SUCCESS; |
| 1498 |
|
| 1499 |
/* |
| 1500 |
* call user cleanup |
| 1501 |
*/ |
| 1502 |
rc = ifTable_undo_cleanup(rowreq_ctx); |
| 1503 |
if (MFD_SUCCESS != rc) { |
| 1504 |
/* |
| 1505 |
* nothing we can do about it but log it |
| 1506 |
*/ |
| 1507 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1508 |
"ifTable_undo_cleanup\n", rc)); |
| 1509 |
} |
| 1510 |
|
| 1511 |
/* |
| 1512 |
* release undo context, if needed |
| 1513 |
*/ |
| 1514 |
_mfd_ifTable_undo_setup_release(rowreq_ctx); |
| 1515 |
|
| 1516 |
|
| 1517 |
return SNMP_ERR_NOERROR; |
| 1518 |
} /* _mfd_ifTable_undo_cleanup */ |
| 1519 |
|
| 1520 |
/*---------------------------------------------------------------------- |
| 1521 |
* |
| 1522 |
* SET: Set values |
| 1523 |
* |
| 1524 |
*---------------------------------------------------------------------*/ |
| 1525 |
/* |
| 1526 |
* @internal |
| 1527 |
* Set the value for a particular column |
| 1528 |
*/ |
| 1529 |
NETSNMP_STATIC_INLINE int |
| 1530 |
_ifTable_set_column(ifTable_rowreq_ctx * rowreq_ctx, |
| 1531 |
netsnmp_variable_list * var, int column) |
| 1532 |
{ |
| 1533 |
int rc = SNMPERR_SUCCESS; |
| 1534 |
|
| 1535 |
DEBUGMSGTL(("internal:ifTable:_ifTable_set_column", |
| 1536 |
"called for %d\n", column)); |
| 1537 |
|
| 1538 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1539 |
|
| 1540 |
switch (column) { |
| 1541 |
|
| 1542 |
/* |
| 1543 |
* ifAdminStatus(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1544 |
*/ |
| 1545 |
case COLUMN_IFADMINSTATUS: |
| 1546 |
rowreq_ctx->column_set_flags |= COLUMN_IFADMINSTATUS_FLAG; |
| 1547 |
rc = ifAdminStatus_set(rowreq_ctx, *((u_long *) var->val.string)); |
| 1548 |
break; |
| 1549 |
|
| 1550 |
default: |
| 1551 |
snmp_log(LOG_ERR, "unknown column %d in _ifTable_set_column\n", |
| 1552 |
column); |
| 1553 |
rc = SNMP_ERR_GENERR; |
| 1554 |
break; |
| 1555 |
} |
| 1556 |
|
| 1557 |
return rc; |
| 1558 |
} /* _ifTable_set_column */ |
| 1559 |
|
| 1560 |
int |
| 1561 |
_mfd_ifTable_set_values(netsnmp_mib_handler *handler, |
| 1562 |
netsnmp_handler_registration *reginfo, |
| 1563 |
netsnmp_agent_request_info *agtreq_info, |
| 1564 |
netsnmp_request_info *requests) |
| 1565 |
{ |
| 1566 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1567 |
netsnmp_container_table_row_extract(requests); |
| 1568 |
netsnmp_table_request_info *tri; |
| 1569 |
int rc = SNMP_ERR_NOERROR; |
| 1570 |
|
| 1571 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_set_values", "called\n")); |
| 1572 |
|
| 1573 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1574 |
|
| 1575 |
rowreq_ctx->column_set_flags = 0; |
| 1576 |
for (; requests; requests = requests->next) { |
| 1577 |
/* |
| 1578 |
* set column data |
| 1579 |
*/ |
| 1580 |
tri = netsnmp_extract_table_info(requests); |
| 1581 |
if (NULL == tri) |
| 1582 |
continue; |
| 1583 |
|
| 1584 |
rc = _ifTable_set_column(rowreq_ctx, |
| 1585 |
requests->requestvb, tri->colnum); |
| 1586 |
if (MFD_SUCCESS != rc) { |
| 1587 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1588 |
"ifTable_set_column\n", rc)); |
| 1589 |
netsnmp_set_request_error(agtreq_info, requests, |
| 1590 |
SNMP_VALIDATE_ERR(rc)); |
| 1591 |
} |
| 1592 |
} /* for results */ |
| 1593 |
|
| 1594 |
return SNMP_ERR_NOERROR; |
| 1595 |
} /* _mfd_ifTable_set_values */ |
| 1596 |
|
| 1597 |
/*---------------------------------------------------------------------- |
| 1598 |
* |
| 1599 |
* SET: commit |
| 1600 |
* |
| 1601 |
*---------------------------------------------------------------------*/ |
| 1602 |
/** |
| 1603 |
* @internal |
| 1604 |
* commit the values |
| 1605 |
*/ |
| 1606 |
int |
| 1607 |
_mfd_ifTable_commit(netsnmp_mib_handler *handler, |
| 1608 |
netsnmp_handler_registration *reginfo, |
| 1609 |
netsnmp_agent_request_info *agtreq_info, |
| 1610 |
netsnmp_request_info *requests) |
| 1611 |
{ |
| 1612 |
int rc; |
| 1613 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1614 |
netsnmp_container_table_row_extract(requests); |
| 1615 |
|
| 1616 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_commit", "called\n")); |
| 1617 |
|
| 1618 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1619 |
|
| 1620 |
rc = ifTable_commit(rowreq_ctx); |
| 1621 |
if (MFD_SUCCESS != rc) { |
| 1622 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1623 |
"ifTable_commit\n", rc)); |
| 1624 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 1625 |
} |
| 1626 |
|
| 1627 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 1628 |
/* |
| 1629 |
* if we successfully committed this row, set the dirty flag. Use the |
| 1630 |
* current value + 1 (i.e. dirty = # rows changed). |
| 1631 |
* this is checked in post_request... |
| 1632 |
*/ |
| 1633 |
ifTable_dirty_set(ifTable_dirty_get() + 1); /* set table dirty flag */ |
| 1634 |
} |
| 1635 |
|
| 1636 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 1637 |
/* |
| 1638 |
* if we successfully committed this row, set the dirty flag. Use the |
| 1639 |
* current value + 1 (i.e. dirty = # rows changed). |
| 1640 |
* this is checked in post_request... |
| 1641 |
*/ |
| 1642 |
ifTable_dirty_set(ifTable_dirty_get() + 1); /* set table dirty flag */ |
| 1643 |
} |
| 1644 |
|
| 1645 |
return SNMP_ERR_NOERROR; |
| 1646 |
} |
| 1647 |
|
| 1648 |
int |
| 1649 |
_mfd_ifTable_undo_commit(netsnmp_mib_handler *handler, |
| 1650 |
netsnmp_handler_registration *reginfo, |
| 1651 |
netsnmp_agent_request_info *agtreq_info, |
| 1652 |
netsnmp_request_info *requests) |
| 1653 |
{ |
| 1654 |
int rc; |
| 1655 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1656 |
netsnmp_container_table_row_extract(requests); |
| 1657 |
|
| 1658 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_undo_commit", "called\n")); |
| 1659 |
|
| 1660 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1661 |
|
| 1662 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 1663 |
u_int d = ifTable_dirty_get(); |
| 1664 |
|
| 1665 |
netsnmp_assert(d != 0); |
| 1666 |
if (d) |
| 1667 |
ifTable_dirty_set(d - 1); |
| 1668 |
} |
| 1669 |
|
| 1670 |
rc = ifTable_undo_commit(rowreq_ctx); |
| 1671 |
if (MFD_SUCCESS != rc) { |
| 1672 |
/* |
| 1673 |
* nothing we can do about it but log it |
| 1674 |
*/ |
| 1675 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1676 |
"ifTable_undo_commit\n", rc)); |
| 1677 |
} |
| 1678 |
|
| 1679 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 1680 |
snmp_log(LOG_WARNING, |
| 1681 |
"ifTable row dirty flag still set after undo_commit\n"); |
| 1682 |
rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; |
| 1683 |
} |
| 1684 |
|
| 1685 |
return SNMP_ERR_NOERROR; |
| 1686 |
} /* _mfd_ifTable_commit */ |
| 1687 |
|
| 1688 |
/*---------------------------------------------------------------------- |
| 1689 |
* |
| 1690 |
* SET: Undo |
| 1691 |
* |
| 1692 |
*---------------------------------------------------------------------*/ |
| 1693 |
/** |
| 1694 |
* @internal |
| 1695 |
* undo the value for a particular column |
| 1696 |
*/ |
| 1697 |
NETSNMP_STATIC_INLINE int |
| 1698 |
_ifTable_undo_column(ifTable_rowreq_ctx * rowreq_ctx, |
| 1699 |
netsnmp_variable_list * var, int column) |
| 1700 |
{ |
| 1701 |
int rc = SNMPERR_SUCCESS; |
| 1702 |
|
| 1703 |
DEBUGMSGTL(("internal:ifTable:_ifTable_undo_column", |
| 1704 |
"called for %d\n", column)); |
| 1705 |
|
| 1706 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1707 |
|
| 1708 |
switch (column) { |
| 1709 |
|
| 1710 |
/* |
| 1711 |
* ifAdminStatus(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1712 |
*/ |
| 1713 |
case COLUMN_IFADMINSTATUS: |
| 1714 |
rc = ifAdminStatus_undo(rowreq_ctx); |
| 1715 |
break; |
| 1716 |
|
| 1717 |
default: |
| 1718 |
snmp_log(LOG_ERR, "unknown column %d in _ifTable_undo_column\n", |
| 1719 |
column); |
| 1720 |
break; |
| 1721 |
} |
| 1722 |
|
| 1723 |
return rc; |
| 1724 |
} /* _ifTable_undo_column */ |
| 1725 |
|
| 1726 |
int |
| 1727 |
_mfd_ifTable_undo_values(netsnmp_mib_handler *handler, |
| 1728 |
netsnmp_handler_registration *reginfo, |
| 1729 |
netsnmp_agent_request_info *agtreq_info, |
| 1730 |
netsnmp_request_info *requests) |
| 1731 |
{ |
| 1732 |
int rc; |
| 1733 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1734 |
netsnmp_container_table_row_extract(requests); |
| 1735 |
netsnmp_table_request_info *tri; |
| 1736 |
|
| 1737 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_undo_values", "called\n")); |
| 1738 |
|
| 1739 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1740 |
|
| 1741 |
rc = ifTable_undo(rowreq_ctx); |
| 1742 |
if (MFD_SUCCESS != rc) { |
| 1743 |
/* |
| 1744 |
* nothing we can do about it but log it |
| 1745 |
*/ |
| 1746 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " "ifTable_undo\n", rc)); |
| 1747 |
} |
| 1748 |
|
| 1749 |
for (; requests; requests = requests->next) { |
| 1750 |
/* |
| 1751 |
* set column data |
| 1752 |
*/ |
| 1753 |
tri = netsnmp_extract_table_info(requests); |
| 1754 |
if (NULL == tri) |
| 1755 |
continue; |
| 1756 |
|
| 1757 |
rc = _ifTable_undo_column(rowreq_ctx, requests->requestvb, |
| 1758 |
tri->colnum); |
| 1759 |
if (MFD_SUCCESS != rc) { |
| 1760 |
/* |
| 1761 |
* nothing we can do about it but log it |
| 1762 |
*/ |
| 1763 |
DEBUGMSGTL(("ifTable:mfd", "error %d from " |
| 1764 |
"ifTable_undo_column\n", rc)); |
| 1765 |
} |
| 1766 |
} /* for results */ |
| 1767 |
|
| 1768 |
return SNMP_ERR_NOERROR; |
| 1769 |
} /* _mfd_ifTable_undo_values */ |
| 1770 |
|
| 1771 |
/*---------------------------------------------------------------------- |
| 1772 |
* |
| 1773 |
* SET: irreversible commit |
| 1774 |
* |
| 1775 |
*---------------------------------------------------------------------*/ |
| 1776 |
/** |
| 1777 |
* @internal |
| 1778 |
* commit irreversible actions |
| 1779 |
*/ |
| 1780 |
int |
| 1781 |
_mfd_ifTable_irreversible_commit(netsnmp_mib_handler *handler, |
| 1782 |
netsnmp_handler_registration *reginfo, |
| 1783 |
netsnmp_agent_request_info *agtreq_info, |
| 1784 |
netsnmp_request_info *requests) |
| 1785 |
{ |
| 1786 |
ifTable_rowreq_ctx *rowreq_ctx = (ifTable_rowreq_ctx*) |
| 1787 |
netsnmp_container_table_row_extract(requests); |
| 1788 |
|
| 1789 |
DEBUGMSGTL(("internal:ifTable:_mfd_ifTable_irreversible:commit", |
| 1790 |
"called\n")); |
| 1791 |
|
| 1792 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1793 |
|
| 1794 |
/* |
| 1795 |
* check for and handle row creation/deletion |
| 1796 |
* and update column exist flags... |
| 1797 |
*/ |
| 1798 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { |
| 1799 |
CONTAINER_REMOVE(ifTable_if_ctx.container, rowreq_ctx); |
| 1800 |
} else { |
| 1801 |
if (rowreq_ctx->column_set_flags) { |
| 1802 |
rowreq_ctx->column_set_flags = 0; |
| 1803 |
} |
| 1804 |
} |
| 1805 |
|
| 1806 |
return SNMP_ERR_NOERROR; |
| 1807 |
} /* _mfd_ifTable_irreversible_commit */ |
| 1808 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 1809 |
|
| 1810 |
/*********************************************************************** |
| 1811 |
* |
| 1812 |
* DATA ACCESS |
| 1813 |
* |
| 1814 |
***********************************************************************/ |
| 1815 |
static void _container_free(netsnmp_container *container); |
| 1816 |
|
| 1817 |
/** |
| 1818 |
* @internal |
| 1819 |
*/ |
| 1820 |
static int |
| 1821 |
_cache_load(netsnmp_cache * cache, void *vmagic) |
| 1822 |
{ |
| 1823 |
DEBUGMSGTL(("internal:ifTable:_cache_load", "called\n")); |
| 1824 |
|
| 1825 |
if ((NULL == cache) || (NULL == cache->magic)) { |
| 1826 |
snmp_log(LOG_ERR, "invalid cache for ifTable_cache_load\n"); |
| 1827 |
return -1; |
| 1828 |
} |
| 1829 |
|
| 1830 |
/** should only be called for an invalid or expired cache */ |
| 1831 |
netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); |
| 1832 |
|
| 1833 |
/* |
| 1834 |
* call user code |
| 1835 |
*/ |
| 1836 |
return ifTable_container_load((netsnmp_container *) cache->magic); |
| 1837 |
} /* _cache_load */ |
| 1838 |
|
| 1839 |
/** |
| 1840 |
* @internal |
| 1841 |
*/ |
| 1842 |
static void |
| 1843 |
_cache_free(netsnmp_cache * cache, void *magic) |
| 1844 |
{ |
| 1845 |
netsnmp_container *container; |
| 1846 |
|
| 1847 |
DEBUGMSGTL(("internal:ifTable:_cache_free", "called\n")); |
| 1848 |
|
| 1849 |
if ((NULL == cache) || (NULL == cache->magic)) { |
| 1850 |
snmp_log(LOG_ERR, "invalid cache in ifTable_cache_free\n"); |
| 1851 |
return; |
| 1852 |
} |
| 1853 |
|
| 1854 |
container = (netsnmp_container *) cache->magic; |
| 1855 |
|
| 1856 |
_container_free(container); |
| 1857 |
} /* _cache_free */ |
| 1858 |
|
| 1859 |
/** |
| 1860 |
* @internal |
| 1861 |
*/ |
| 1862 |
static void |
| 1863 |
_container_item_free(ifTable_rowreq_ctx * rowreq_ctx, void *context) |
| 1864 |
{ |
| 1865 |
DEBUGMSGTL(("internal:ifTable:_container_item_free", "called\n")); |
| 1866 |
|
| 1867 |
if (NULL == rowreq_ctx) |
| 1868 |
return; |
| 1869 |
|
| 1870 |
ifTable_release_rowreq_ctx(rowreq_ctx); |
| 1871 |
} /* _container_item_free */ |
| 1872 |
|
| 1873 |
static void __container_item_free(void *rowreq_ctx, void *context) |
| 1874 |
{ |
| 1875 |
_container_item_free(rowreq_ctx, context); |
| 1876 |
} |
| 1877 |
|
| 1878 |
/** |
| 1879 |
* @internal |
| 1880 |
*/ |
| 1881 |
static void |
| 1882 |
_container_free(netsnmp_container *container) |
| 1883 |
{ |
| 1884 |
DEBUGMSGTL(("internal:ifTable:_container_free", "called\n")); |
| 1885 |
|
| 1886 |
if (NULL == container) { |
| 1887 |
snmp_log(LOG_ERR, "invalid container in ifTable_container_free\n"); |
| 1888 |
return; |
| 1889 |
} |
| 1890 |
|
| 1891 |
/* |
| 1892 |
* call user code |
| 1893 |
*/ |
| 1894 |
ifTable_container_free(container); |
| 1895 |
|
| 1896 |
/* |
| 1897 |
* free all items. inefficient, but easy. |
| 1898 |
*/ |
| 1899 |
CONTAINER_CLEAR(container, __container_item_free, NULL); |
| 1900 |
} /* _container_free */ |
| 1901 |
|
| 1902 |
/** |
| 1903 |
* @internal |
| 1904 |
* initialize the container with functions or wrappers |
| 1905 |
*/ |
| 1906 |
void |
| 1907 |
_ifTable_container_init(ifTable_interface_ctx * if_ctx) |
| 1908 |
{ |
| 1909 |
DEBUGMSGTL(("internal:ifTable:_ifTable_container_init", "called\n")); |
| 1910 |
|
| 1911 |
/* |
| 1912 |
* cache init |
| 1913 |
*/ |
| 1914 |
if_ctx->cache = netsnmp_cache_create(30, /* timeout in seconds */ |
| 1915 |
_cache_load, _cache_free, |
| 1916 |
ifTable_oid, ifTable_oid_size); |
| 1917 |
|
| 1918 |
if (NULL == if_ctx->cache) { |
| 1919 |
snmp_log(LOG_ERR, "error creating cache for ifTable\n"); |
| 1920 |
return; |
| 1921 |
} |
| 1922 |
|
| 1923 |
if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; |
| 1924 |
|
| 1925 |
ifTable_container_init(&if_ctx->container, if_ctx->cache); |
| 1926 |
if (NULL == if_ctx->container) |
| 1927 |
if_ctx->container = |
| 1928 |
netsnmp_container_find("ifTable:table_container"); |
| 1929 |
if (NULL == if_ctx->container) { |
| 1930 |
snmp_log(LOG_ERR, "error creating container in " |
| 1931 |
"ifTable_container_init\n"); |
| 1932 |
return; |
| 1933 |
} |
| 1934 |
|
| 1935 |
if_ctx->container->container_name = strdup("ifTable container"); |
| 1936 |
if (NULL != if_ctx->cache) |
| 1937 |
if_ctx->cache->magic = (void *) if_ctx->container; |
| 1938 |
} /* _ifTable_container_init */ |
| 1939 |
|
| 1940 |
/** |
| 1941 |
* @internal |
| 1942 |
* shutdown the container with functions or wrappers |
| 1943 |
*/ |
| 1944 |
void |
| 1945 |
_ifTable_container_shutdown(ifTable_interface_ctx * if_ctx) |
| 1946 |
{ |
| 1947 |
DEBUGMSGTL(("internal:ifTable:_ifTable_container_shutdown", |
| 1948 |
"called\n")); |
| 1949 |
|
| 1950 |
ifTable_container_shutdown(if_ctx->container); |
| 1951 |
|
| 1952 |
_container_free(if_ctx->container); |
| 1953 |
|
| 1954 |
} /* _ifTable_container_shutdown */ |
| 1955 |
|
| 1956 |
|
| 1957 |
#ifndef NETSNMP_FEATURE_REMOVE_IFTABLE_EXTERNAL_ACCESS |
| 1958 |
ifTable_rowreq_ctx * |
| 1959 |
ifTable_row_find_by_mib_index(ifTable_mib_index * mib_idx) |
| 1960 |
{ |
| 1961 |
oid oid_tmp[MAX_OID_LEN]; |
| 1962 |
netsnmp_index oid_idx = { MAX_OID_LEN, oid_tmp }; |
| 1963 |
int rc; |
| 1964 |
|
| 1965 |
rc = ifTable_index_to_oid(&oid_idx, mib_idx); |
| 1966 |
return rc == MFD_SUCCESS ? |
| 1967 |
CONTAINER_FIND(ifTable_if_ctx.container, &oid_idx) : NULL; |
| 1968 |
} |
| 1969 |
#endif /* NETSNMP_FEATURE_REMOVE_IFTABLE_EXTERNAL_ACCESS */ |