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