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