| 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 "inetCidrRouteTable.h" |
| 41 |
|
| 42 |
|
| 43 |
#include <net-snmp/agent/table_container.h> |
| 44 |
#include <net-snmp/library/container.h> |
| 45 |
|
| 46 |
#include "inetCidrRouteTable_interface.h" |
| 47 |
|
| 48 |
#include <ctype.h> |
| 49 |
|
| 50 |
netsnmp_feature_child_of(inetCidrRouteTable_external_access, libnetsnmpmibs); |
| 51 |
netsnmp_feature_require(row_merge); |
| 52 |
netsnmp_feature_require(baby_steps); |
| 53 |
netsnmp_feature_require(table_container_row_insert); |
| 54 |
netsnmp_feature_require(check_all_requests_error); |
| 55 |
|
| 56 |
netsnmp_feature_child_of(inetCidrRouteTable_container_size, inetCidrRouteTable_external_access); |
| 57 |
netsnmp_feature_child_of(inetCidrRouteTable_registration_set, inetCidrRouteTable_external_access); |
| 58 |
netsnmp_feature_child_of(inetCidrRouteTable_registration_get, inetCidrRouteTable_external_access); |
| 59 |
netsnmp_feature_child_of(inetCidrRouteTable_container_get, inetCidrRouteTable_external_access); |
| 60 |
/********************************************************************** |
| 61 |
********************************************************************** |
| 62 |
*** |
| 63 |
*** Table inetCidrRouteTable |
| 64 |
*** |
| 65 |
********************************************************************** |
| 66 |
**********************************************************************/ |
| 67 |
/* |
| 68 |
* IP-FORWARD-MIB::inetCidrRouteTable is subid 7 of ipForward. |
| 69 |
* Its status is Current. |
| 70 |
* OID: .1.3.6.1.2.1.4.24.7, length: 9 |
| 71 |
*/ |
| 72 |
typedef struct inetCidrRouteTable_interface_ctx_s { |
| 73 |
|
| 74 |
netsnmp_container *container; |
| 75 |
netsnmp_cache *cache; |
| 76 |
|
| 77 |
inetCidrRouteTable_registration *user_ctx; |
| 78 |
|
| 79 |
netsnmp_table_registration_info tbl_info; |
| 80 |
|
| 81 |
netsnmp_baby_steps_access_methods access_multiplexer; |
| 82 |
|
| 83 |
u_int table_dirty; |
| 84 |
|
| 85 |
} inetCidrRouteTable_interface_ctx; |
| 86 |
|
| 87 |
static inetCidrRouteTable_interface_ctx inetCidrRouteTable_if_ctx; |
| 88 |
|
| 89 |
static void |
| 90 |
_inetCidrRouteTable_container_init(inetCidrRouteTable_interface_ctx * |
| 91 |
if_ctx); |
| 92 |
static void |
| 93 |
_inetCidrRouteTable_container_shutdown(inetCidrRouteTable_interface_ctx * |
| 94 |
if_ctx); |
| 95 |
|
| 96 |
#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_GET |
| 97 |
netsnmp_container * |
| 98 |
inetCidrRouteTable_container_get(void) |
| 99 |
{ |
| 100 |
return inetCidrRouteTable_if_ctx.container; |
| 101 |
} |
| 102 |
#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_GET */ |
| 103 |
|
| 104 |
#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_GET |
| 105 |
inetCidrRouteTable_registration * |
| 106 |
inetCidrRouteTable_registration_get(void) |
| 107 |
{ |
| 108 |
return inetCidrRouteTable_if_ctx.user_ctx; |
| 109 |
} |
| 110 |
#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_GET */ |
| 111 |
|
| 112 |
#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_SET |
| 113 |
inetCidrRouteTable_registration * |
| 114 |
inetCidrRouteTable_registration_set(inetCidrRouteTable_registration * |
| 115 |
newreg) |
| 116 |
{ |
| 117 |
inetCidrRouteTable_registration *old = |
| 118 |
inetCidrRouteTable_if_ctx.user_ctx; |
| 119 |
inetCidrRouteTable_if_ctx.user_ctx = newreg; |
| 120 |
return old; |
| 121 |
} |
| 122 |
#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_REGISTRATION_SET */ |
| 123 |
|
| 124 |
#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_SIZE |
| 125 |
int |
| 126 |
inetCidrRouteTable_container_size(void) |
| 127 |
{ |
| 128 |
return CONTAINER_SIZE(inetCidrRouteTable_if_ctx.container); |
| 129 |
} |
| 130 |
#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_CONTAINER_SIZE */ |
| 131 |
|
| 132 |
u_int |
| 133 |
inetCidrRouteTable_dirty_get(void) |
| 134 |
{ |
| 135 |
return inetCidrRouteTable_if_ctx.table_dirty; |
| 136 |
} |
| 137 |
|
| 138 |
void |
| 139 |
inetCidrRouteTable_dirty_set(u_int status) |
| 140 |
{ |
| 141 |
DEBUGMSGTL(("inetCidrRouteTable:inetCidrRouteTable_dirty_set", |
| 142 |
"called. was %d, now %d\n", |
| 143 |
inetCidrRouteTable_if_ctx.table_dirty, status)); |
| 144 |
inetCidrRouteTable_if_ctx.table_dirty = status; |
| 145 |
} |
| 146 |
|
| 147 |
netsnmp_cache * |
| 148 |
inetCidrRouteTable_get_cache(void) |
| 149 |
{ |
| 150 |
return inetCidrRouteTable_if_ctx.cache; |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
/* |
| 155 |
* mfd multiplexer modes |
| 156 |
*/ |
| 157 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_pre_request; |
| 158 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_post_request; |
| 159 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_object_lookup; |
| 160 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_get_values; |
| 161 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 162 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_check_objects; |
| 163 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_setup; |
| 164 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_set_values; |
| 165 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_cleanup; |
| 166 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_values; |
| 167 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_commit; |
| 168 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_undo_commit; |
| 169 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_irreversible_commit; |
| 170 |
static Netsnmp_Node_Handler _mfd_inetCidrRouteTable_check_dependencies; |
| 171 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 172 |
|
| 173 |
NETSNMP_STATIC_INLINE int |
| 174 |
_inetCidrRouteTable_check_indexes(inetCidrRouteTable_rowreq_ctx * rowreq_ctx); |
| 175 |
/** |
| 176 |
* @internal |
| 177 |
* Initialize the table inetCidrRouteTable |
| 178 |
* (Define its contents and how it's structured) |
| 179 |
*/ |
| 180 |
void |
| 181 |
_inetCidrRouteTable_initialize_interface(inetCidrRouteTable_registration * |
| 182 |
reg_ptr, u_long flags) |
| 183 |
{ |
| 184 |
netsnmp_baby_steps_access_methods *access_multiplexer = |
| 185 |
&inetCidrRouteTable_if_ctx.access_multiplexer; |
| 186 |
netsnmp_table_registration_info *tbl_info = |
| 187 |
&inetCidrRouteTable_if_ctx.tbl_info; |
| 188 |
netsnmp_handler_registration *reginfo; |
| 189 |
netsnmp_mib_handler *handler; |
| 190 |
int mfd_modes = 0; |
| 191 |
|
| 192 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_initialize_interface", "called\n")); |
| 193 |
|
| 194 |
|
| 195 |
/************************************************* |
| 196 |
* |
| 197 |
* save interface context for inetCidrRouteTable |
| 198 |
*/ |
| 199 |
/* |
| 200 |
* Setting up the table's definition |
| 201 |
*/ |
| 202 |
netsnmp_table_helper_add_indexes(tbl_info, ASN_INTEGER, |
| 203 |
/** index: inetCidrRouteDestType */ |
| 204 |
ASN_OCTET_STR, |
| 205 |
/** index: inetCidrRouteDest */ |
| 206 |
ASN_UNSIGNED, |
| 207 |
/** index: inetCidrRoutePfxLen */ |
| 208 |
ASN_OBJECT_ID, |
| 209 |
/** index: inetCidrRoutePolicy */ |
| 210 |
ASN_INTEGER, |
| 211 |
/** index: inetCidrRouteNextHopType */ |
| 212 |
ASN_OCTET_STR, |
| 213 |
/** index: inetCidrRouteNextHop */ |
| 214 |
0); |
| 215 |
|
| 216 |
/* |
| 217 |
* Define the minimum and maximum accessible columns. This |
| 218 |
* optimizes retrieval. |
| 219 |
*/ |
| 220 |
tbl_info->min_column = INETCIDRROUTETABLE_MIN_COL; |
| 221 |
tbl_info->max_column = INETCIDRROUTETABLE_MAX_COL; |
| 222 |
|
| 223 |
/* |
| 224 |
* save users context |
| 225 |
*/ |
| 226 |
inetCidrRouteTable_if_ctx.user_ctx = reg_ptr; |
| 227 |
|
| 228 |
/* |
| 229 |
* call data access initialization code |
| 230 |
*/ |
| 231 |
inetCidrRouteTable_init_data(reg_ptr); |
| 232 |
|
| 233 |
/* |
| 234 |
* set up the container |
| 235 |
*/ |
| 236 |
_inetCidrRouteTable_container_init(&inetCidrRouteTable_if_ctx); |
| 237 |
if (NULL == inetCidrRouteTable_if_ctx.container) { |
| 238 |
snmp_log(LOG_ERR, |
| 239 |
"could not initialize container for inetCidrRouteTable\n"); |
| 240 |
return; |
| 241 |
} |
| 242 |
|
| 243 |
/* |
| 244 |
* access_multiplexer: REQUIRED wrapper for get request handling |
| 245 |
*/ |
| 246 |
access_multiplexer->object_lookup = |
| 247 |
_mfd_inetCidrRouteTable_object_lookup; |
| 248 |
access_multiplexer->get_values = _mfd_inetCidrRouteTable_get_values; |
| 249 |
|
| 250 |
/* |
| 251 |
* no wrappers yet |
| 252 |
*/ |
| 253 |
access_multiplexer->pre_request = _mfd_inetCidrRouteTable_pre_request; |
| 254 |
access_multiplexer->post_request = |
| 255 |
_mfd_inetCidrRouteTable_post_request; |
| 256 |
|
| 257 |
|
| 258 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 259 |
/* |
| 260 |
* REQUIRED wrappers for set request handling |
| 261 |
*/ |
| 262 |
access_multiplexer->object_syntax_checks = |
| 263 |
_mfd_inetCidrRouteTable_check_objects; |
| 264 |
access_multiplexer->undo_setup = _mfd_inetCidrRouteTable_undo_setup; |
| 265 |
access_multiplexer->undo_cleanup = |
| 266 |
_mfd_inetCidrRouteTable_undo_cleanup; |
| 267 |
access_multiplexer->set_values = _mfd_inetCidrRouteTable_set_values; |
| 268 |
access_multiplexer->undo_sets = _mfd_inetCidrRouteTable_undo_values; |
| 269 |
|
| 270 |
/* |
| 271 |
* no wrappers yet |
| 272 |
*/ |
| 273 |
access_multiplexer->commit = _mfd_inetCidrRouteTable_commit; |
| 274 |
access_multiplexer->undo_commit = _mfd_inetCidrRouteTable_undo_commit; |
| 275 |
access_multiplexer->irreversible_commit = |
| 276 |
_mfd_inetCidrRouteTable_irreversible_commit; |
| 277 |
|
| 278 |
/* |
| 279 |
* REQUIRED for tables with dependencies |
| 280 |
*/ |
| 281 |
access_multiplexer->consistency_checks = |
| 282 |
_mfd_inetCidrRouteTable_check_dependencies; |
| 283 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 284 |
|
| 285 |
/************************************************* |
| 286 |
* |
| 287 |
* Create a registration, save our reg data, register table. |
| 288 |
*/ |
| 289 |
DEBUGMSGTL(("inetCidrRouteTable:init_inetCidrRouteTable", |
| 290 |
"Registering inetCidrRouteTable as a mibs-for-dummies table.\n")); |
| 291 |
handler = |
| 292 |
netsnmp_baby_steps_access_multiplexer_get(access_multiplexer); |
| 293 |
reginfo = |
| 294 |
netsnmp_handler_registration_create("inetCidrRouteTable", handler, |
| 295 |
inetCidrRouteTable_oid, |
| 296 |
inetCidrRouteTable_oid_size, |
| 297 |
HANDLER_CAN_BABY_STEP | |
| 298 |
#ifndef NETSNMP_DISABLE_SET_SUPPORT |
| 299 |
HANDLER_CAN_RWRITE |
| 300 |
#else |
| 301 |
HANDLER_CAN_RONLY |
| 302 |
#endif /* NETSNMP_DISABLE_SET_SUPPORT */ |
| 303 |
); |
| 304 |
if (NULL == reginfo) { |
| 305 |
snmp_log(LOG_ERR, "error registering table inetCidrRouteTable\n"); |
| 306 |
return; |
| 307 |
} |
| 308 |
reginfo->my_reg_void = &inetCidrRouteTable_if_ctx; |
| 309 |
|
| 310 |
/************************************************* |
| 311 |
* |
| 312 |
* set up baby steps handler, create it and inject it |
| 313 |
*/ |
| 314 |
if (access_multiplexer->object_lookup) |
| 315 |
mfd_modes |= BABY_STEP_OBJECT_LOOKUP; |
| 316 |
if (access_multiplexer->pre_request) |
| 317 |
mfd_modes |= BABY_STEP_PRE_REQUEST; |
| 318 |
if (access_multiplexer->post_request) |
| 319 |
mfd_modes |= BABY_STEP_POST_REQUEST; |
| 320 |
|
| 321 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 322 |
if (access_multiplexer->set_values) |
| 323 |
mfd_modes |= BABY_STEP_SET_VALUES; |
| 324 |
if (access_multiplexer->irreversible_commit) |
| 325 |
mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT; |
| 326 |
if (access_multiplexer->object_syntax_checks) |
| 327 |
mfd_modes |= BABY_STEP_CHECK_OBJECT; |
| 328 |
|
| 329 |
if (access_multiplexer->undo_setup) |
| 330 |
mfd_modes |= BABY_STEP_UNDO_SETUP; |
| 331 |
if (access_multiplexer->undo_cleanup) |
| 332 |
mfd_modes |= BABY_STEP_UNDO_CLEANUP; |
| 333 |
if (access_multiplexer->undo_sets) |
| 334 |
mfd_modes |= BABY_STEP_UNDO_SETS; |
| 335 |
|
| 336 |
if (access_multiplexer->row_creation) |
| 337 |
mfd_modes |= BABY_STEP_ROW_CREATE; |
| 338 |
if (access_multiplexer->consistency_checks) |
| 339 |
mfd_modes |= BABY_STEP_CHECK_CONSISTENCY; |
| 340 |
if (access_multiplexer->commit) |
| 341 |
mfd_modes |= BABY_STEP_COMMIT; |
| 342 |
if (access_multiplexer->undo_commit) |
| 343 |
mfd_modes |= BABY_STEP_UNDO_COMMIT; |
| 344 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 345 |
|
| 346 |
handler = netsnmp_baby_steps_handler_get(mfd_modes); |
| 347 |
netsnmp_inject_handler(reginfo, handler); |
| 348 |
|
| 349 |
/************************************************* |
| 350 |
* |
| 351 |
* inject row_merge helper with prefix rootoid_len + 2 (entry.col) |
| 352 |
*/ |
| 353 |
handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2); |
| 354 |
netsnmp_inject_handler(reginfo, handler); |
| 355 |
|
| 356 |
/************************************************* |
| 357 |
* |
| 358 |
* inject container_table helper |
| 359 |
*/ |
| 360 |
handler = |
| 361 |
netsnmp_container_table_handler_get(tbl_info, |
| 362 |
inetCidrRouteTable_if_ctx. |
| 363 |
container, |
| 364 |
TABLE_CONTAINER_KEY_NETSNMP_INDEX); |
| 365 |
netsnmp_inject_handler(reginfo, handler); |
| 366 |
|
| 367 |
/************************************************* |
| 368 |
* |
| 369 |
* inject cache helper |
| 370 |
*/ |
| 371 |
if (NULL != inetCidrRouteTable_if_ctx.cache) { |
| 372 |
handler = |
| 373 |
netsnmp_cache_handler_get(inetCidrRouteTable_if_ctx.cache); |
| 374 |
netsnmp_inject_handler(reginfo, handler); |
| 375 |
} |
| 376 |
|
| 377 |
/* |
| 378 |
* register table |
| 379 |
*/ |
| 380 |
netsnmp_register_table(reginfo, tbl_info); |
| 381 |
|
| 382 |
} /* _inetCidrRouteTable_initialize_interface */ |
| 383 |
|
| 384 |
/** |
| 385 |
* @internal |
| 386 |
* Shutdown the table inetCidrRouteTable |
| 387 |
*/ |
| 388 |
void |
| 389 |
_inetCidrRouteTable_shutdown_interface(inetCidrRouteTable_registration * |
| 390 |
reg_ptr) |
| 391 |
{ |
| 392 |
/* |
| 393 |
* shutdown the container |
| 394 |
*/ |
| 395 |
_inetCidrRouteTable_container_shutdown(&inetCidrRouteTable_if_ctx); |
| 396 |
} |
| 397 |
|
| 398 |
void |
| 399 |
inetCidrRouteTable_valid_columns_set(netsnmp_column_info *vc) |
| 400 |
{ |
| 401 |
inetCidrRouteTable_if_ctx.tbl_info.valid_columns = vc; |
| 402 |
} /* inetCidrRouteTable_valid_columns_set */ |
| 403 |
|
| 404 |
/** |
| 405 |
* @internal |
| 406 |
* convert the index component stored in the context to an oid |
| 407 |
*/ |
| 408 |
int |
| 409 |
inetCidrRouteTable_index_to_oid(netsnmp_index * oid_idx, |
| 410 |
inetCidrRouteTable_mib_index * mib_idx) |
| 411 |
{ |
| 412 |
int err = SNMP_ERR_NOERROR; |
| 413 |
|
| 414 |
/* |
| 415 |
* temp storage for parsing indexes |
| 416 |
*/ |
| 417 |
/* |
| 418 |
* inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 419 |
*/ |
| 420 |
netsnmp_variable_list var_inetCidrRouteDestType; |
| 421 |
/* |
| 422 |
* inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 423 |
*/ |
| 424 |
netsnmp_variable_list var_inetCidrRouteDest; |
| 425 |
/* |
| 426 |
* inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H |
| 427 |
*/ |
| 428 |
netsnmp_variable_list var_inetCidrRoutePfxLen; |
| 429 |
/* |
| 430 |
* inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h |
| 431 |
*/ |
| 432 |
netsnmp_variable_list var_inetCidrRoutePolicy; |
| 433 |
/* |
| 434 |
* inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 435 |
*/ |
| 436 |
netsnmp_variable_list var_inetCidrRouteNextHopType; |
| 437 |
/* |
| 438 |
* inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 439 |
*/ |
| 440 |
netsnmp_variable_list var_inetCidrRouteNextHop; |
| 441 |
|
| 442 |
/* |
| 443 |
* set up varbinds |
| 444 |
*/ |
| 445 |
memset(&var_inetCidrRouteDestType, 0x00, |
| 446 |
sizeof(var_inetCidrRouteDestType)); |
| 447 |
var_inetCidrRouteDestType.type = ASN_INTEGER; |
| 448 |
memset(&var_inetCidrRouteDest, 0x00, sizeof(var_inetCidrRouteDest)); |
| 449 |
var_inetCidrRouteDest.type = ASN_OCTET_STR; |
| 450 |
memset(&var_inetCidrRoutePfxLen, 0x00, |
| 451 |
sizeof(var_inetCidrRoutePfxLen)); |
| 452 |
var_inetCidrRoutePfxLen.type = ASN_UNSIGNED; |
| 453 |
memset(&var_inetCidrRoutePolicy, 0x00, |
| 454 |
sizeof(var_inetCidrRoutePolicy)); |
| 455 |
var_inetCidrRoutePolicy.type = ASN_OBJECT_ID; |
| 456 |
memset(&var_inetCidrRouteNextHopType, 0x00, |
| 457 |
sizeof(var_inetCidrRouteNextHopType)); |
| 458 |
var_inetCidrRouteNextHopType.type = ASN_INTEGER; |
| 459 |
memset(&var_inetCidrRouteNextHop, 0x00, |
| 460 |
sizeof(var_inetCidrRouteNextHop)); |
| 461 |
var_inetCidrRouteNextHop.type = ASN_OCTET_STR; |
| 462 |
|
| 463 |
/* |
| 464 |
* chain temp index varbinds together |
| 465 |
*/ |
| 466 |
var_inetCidrRouteDestType.next_variable = &var_inetCidrRouteDest; |
| 467 |
var_inetCidrRouteDest.next_variable = &var_inetCidrRoutePfxLen; |
| 468 |
var_inetCidrRoutePfxLen.next_variable = &var_inetCidrRoutePolicy; |
| 469 |
var_inetCidrRoutePolicy.next_variable = &var_inetCidrRouteNextHopType; |
| 470 |
var_inetCidrRouteNextHopType.next_variable = &var_inetCidrRouteNextHop; |
| 471 |
var_inetCidrRouteNextHop.next_variable = NULL; |
| 472 |
|
| 473 |
|
| 474 |
DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_index_to_oid", "called\n")); |
| 475 |
|
| 476 |
/* |
| 477 |
* inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 478 |
*/ |
| 479 |
snmp_set_var_value(&var_inetCidrRouteDestType, |
| 480 |
(u_char *) & mib_idx->inetCidrRouteDestType, |
| 481 |
sizeof(mib_idx->inetCidrRouteDestType)); |
| 482 |
|
| 483 |
/* |
| 484 |
* inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 485 |
*/ |
| 486 |
snmp_set_var_value(&var_inetCidrRouteDest, |
| 487 |
(u_char *) & mib_idx->inetCidrRouteDest, |
| 488 |
mib_idx->inetCidrRouteDest_len * |
| 489 |
sizeof(mib_idx->inetCidrRouteDest[0])); |
| 490 |
|
| 491 |
/* |
| 492 |
* inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H |
| 493 |
*/ |
| 494 |
snmp_set_var_value(&var_inetCidrRoutePfxLen, |
| 495 |
(u_char *) & mib_idx->inetCidrRoutePfxLen, |
| 496 |
sizeof(mib_idx->inetCidrRoutePfxLen)); |
| 497 |
|
| 498 |
/* |
| 499 |
* inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h |
| 500 |
*/ |
| 501 |
snmp_set_var_value(&var_inetCidrRoutePolicy, |
| 502 |
(u_char *) & mib_idx->inetCidrRoutePolicy, |
| 503 |
mib_idx->inetCidrRoutePolicy_len * |
| 504 |
sizeof(mib_idx->inetCidrRoutePolicy[0])); |
| 505 |
|
| 506 |
/* |
| 507 |
* inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 508 |
*/ |
| 509 |
snmp_set_var_value(&var_inetCidrRouteNextHopType, |
| 510 |
(u_char *) & mib_idx->inetCidrRouteNextHopType, |
| 511 |
sizeof(mib_idx->inetCidrRouteNextHopType)); |
| 512 |
|
| 513 |
/* |
| 514 |
* inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 515 |
*/ |
| 516 |
snmp_set_var_value(&var_inetCidrRouteNextHop, |
| 517 |
(u_char *) & mib_idx->inetCidrRouteNextHop, |
| 518 |
mib_idx->inetCidrRouteNextHop_len * |
| 519 |
sizeof(mib_idx->inetCidrRouteNextHop[0])); |
| 520 |
|
| 521 |
|
| 522 |
err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, |
| 523 |
NULL, 0, &var_inetCidrRouteDestType); |
| 524 |
if (err) |
| 525 |
snmp_log(LOG_ERR, "error %d converting index to oid\n", err); |
| 526 |
|
| 527 |
/* |
| 528 |
* parsing may have allocated memory. free it. |
| 529 |
*/ |
| 530 |
snmp_reset_var_buffers(&var_inetCidrRouteDestType); |
| 531 |
|
| 532 |
return err; |
| 533 |
} /* inetCidrRouteTable_index_to_oid */ |
| 534 |
|
| 535 |
/** |
| 536 |
* extract inetCidrRouteTable indexes from a netsnmp_index |
| 537 |
* |
| 538 |
* @retval SNMP_ERR_NOERROR : no error |
| 539 |
* @retval SNMP_ERR_GENERR : error |
| 540 |
*/ |
| 541 |
int |
| 542 |
inetCidrRouteTable_index_from_oid(netsnmp_index * oid_idx, |
| 543 |
inetCidrRouteTable_mib_index * mib_idx) |
| 544 |
{ |
| 545 |
int err = SNMP_ERR_NOERROR; |
| 546 |
|
| 547 |
/* |
| 548 |
* temp storage for parsing indexes |
| 549 |
*/ |
| 550 |
/* |
| 551 |
* inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 552 |
*/ |
| 553 |
netsnmp_variable_list var_inetCidrRouteDestType; |
| 554 |
/* |
| 555 |
* inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 556 |
*/ |
| 557 |
netsnmp_variable_list var_inetCidrRouteDest; |
| 558 |
/* |
| 559 |
* inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H |
| 560 |
*/ |
| 561 |
netsnmp_variable_list var_inetCidrRoutePfxLen; |
| 562 |
/* |
| 563 |
* inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h |
| 564 |
*/ |
| 565 |
netsnmp_variable_list var_inetCidrRoutePolicy; |
| 566 |
/* |
| 567 |
* inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 568 |
*/ |
| 569 |
netsnmp_variable_list var_inetCidrRouteNextHopType; |
| 570 |
/* |
| 571 |
* inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 572 |
*/ |
| 573 |
netsnmp_variable_list var_inetCidrRouteNextHop; |
| 574 |
|
| 575 |
/* |
| 576 |
* set up varbinds |
| 577 |
*/ |
| 578 |
memset(&var_inetCidrRouteDestType, 0x00, |
| 579 |
sizeof(var_inetCidrRouteDestType)); |
| 580 |
var_inetCidrRouteDestType.type = ASN_INTEGER; |
| 581 |
memset(&var_inetCidrRouteDest, 0x00, sizeof(var_inetCidrRouteDest)); |
| 582 |
var_inetCidrRouteDest.type = ASN_OCTET_STR; |
| 583 |
memset(&var_inetCidrRoutePfxLen, 0x00, |
| 584 |
sizeof(var_inetCidrRoutePfxLen)); |
| 585 |
var_inetCidrRoutePfxLen.type = ASN_UNSIGNED; |
| 586 |
memset(&var_inetCidrRoutePolicy, 0x00, |
| 587 |
sizeof(var_inetCidrRoutePolicy)); |
| 588 |
var_inetCidrRoutePolicy.type = ASN_OBJECT_ID; |
| 589 |
memset(&var_inetCidrRouteNextHopType, 0x00, |
| 590 |
sizeof(var_inetCidrRouteNextHopType)); |
| 591 |
var_inetCidrRouteNextHopType.type = ASN_INTEGER; |
| 592 |
memset(&var_inetCidrRouteNextHop, 0x00, |
| 593 |
sizeof(var_inetCidrRouteNextHop)); |
| 594 |
var_inetCidrRouteNextHop.type = ASN_OCTET_STR; |
| 595 |
|
| 596 |
/* |
| 597 |
* chain temp index varbinds together |
| 598 |
*/ |
| 599 |
var_inetCidrRouteDestType.next_variable = &var_inetCidrRouteDest; |
| 600 |
var_inetCidrRouteDest.next_variable = &var_inetCidrRoutePfxLen; |
| 601 |
var_inetCidrRoutePfxLen.next_variable = &var_inetCidrRoutePolicy; |
| 602 |
var_inetCidrRoutePolicy.next_variable = &var_inetCidrRouteNextHopType; |
| 603 |
var_inetCidrRouteNextHopType.next_variable = &var_inetCidrRouteNextHop; |
| 604 |
var_inetCidrRouteNextHop.next_variable = NULL; |
| 605 |
|
| 606 |
|
| 607 |
DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_index_from_oid", "called\n")); |
| 608 |
|
| 609 |
/* |
| 610 |
* parse the oid into the individual index components |
| 611 |
*/ |
| 612 |
err = parse_oid_indexes(oid_idx->oids, oid_idx->len, |
| 613 |
&var_inetCidrRouteDestType); |
| 614 |
if (err == SNMP_ERR_NOERROR) { |
| 615 |
/* |
| 616 |
* copy out values |
| 617 |
*/ |
| 618 |
mib_idx->inetCidrRouteDestType = |
| 619 |
*((u_long *) var_inetCidrRouteDestType.val.string); |
| 620 |
/* |
| 621 |
* NOTE: val_len is in bytes, inetCidrRouteDest_len might not be |
| 622 |
*/ |
| 623 |
if (var_inetCidrRouteDest.val_len > |
| 624 |
sizeof(mib_idx->inetCidrRouteDest)) |
| 625 |
err = SNMP_ERR_GENERR; |
| 626 |
else { |
| 627 |
memcpy(mib_idx->inetCidrRouteDest, |
| 628 |
var_inetCidrRouteDest.val.string, |
| 629 |
var_inetCidrRouteDest.val_len); |
| 630 |
mib_idx->inetCidrRouteDest_len = |
| 631 |
var_inetCidrRouteDest.val_len / |
| 632 |
sizeof(mib_idx->inetCidrRouteDest[0]); |
| 633 |
} |
| 634 |
mib_idx->inetCidrRoutePfxLen = |
| 635 |
*((u_long *) var_inetCidrRoutePfxLen.val.string); |
| 636 |
/* |
| 637 |
* NOTE: val_len is in bytes, inetCidrRoutePolicy_len might not be |
| 638 |
*/ |
| 639 |
if (var_inetCidrRoutePolicy.val_len > |
| 640 |
sizeof(mib_idx->inetCidrRoutePolicy)) |
| 641 |
err = SNMP_ERR_GENERR; |
| 642 |
else { |
| 643 |
memcpy(mib_idx->inetCidrRoutePolicy, |
| 644 |
var_inetCidrRoutePolicy.val.string, |
| 645 |
var_inetCidrRoutePolicy.val_len); |
| 646 |
mib_idx->inetCidrRoutePolicy_len = |
| 647 |
var_inetCidrRoutePolicy.val_len / |
| 648 |
sizeof(mib_idx->inetCidrRoutePolicy[0]); |
| 649 |
} |
| 650 |
mib_idx->inetCidrRouteNextHopType = |
| 651 |
*((u_long *) var_inetCidrRouteNextHopType.val.string); |
| 652 |
/* |
| 653 |
* NOTE: val_len is in bytes, inetCidrRouteNextHop_len might not be |
| 654 |
*/ |
| 655 |
if (var_inetCidrRouteNextHop.val_len > |
| 656 |
sizeof(mib_idx->inetCidrRouteNextHop)) |
| 657 |
err = SNMP_ERR_GENERR; |
| 658 |
else { |
| 659 |
memcpy(mib_idx->inetCidrRouteNextHop, |
| 660 |
var_inetCidrRouteNextHop.val.string, |
| 661 |
var_inetCidrRouteNextHop.val_len); |
| 662 |
mib_idx->inetCidrRouteNextHop_len = |
| 663 |
var_inetCidrRouteNextHop.val_len / |
| 664 |
sizeof(mib_idx->inetCidrRouteNextHop[0]); |
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
} |
| 669 |
|
| 670 |
/* |
| 671 |
* parsing may have allocated memory. free it. |
| 672 |
*/ |
| 673 |
snmp_reset_var_buffers(&var_inetCidrRouteDestType); |
| 674 |
|
| 675 |
return err; |
| 676 |
} /* inetCidrRouteTable_index_from_oid */ |
| 677 |
|
| 678 |
|
| 679 |
/* |
| 680 |
********************************************************************* |
| 681 |
* @internal |
| 682 |
* allocate resources for a inetCidrRouteTable_rowreq_ctx |
| 683 |
*/ |
| 684 |
inetCidrRouteTable_rowreq_ctx * |
| 685 |
inetCidrRouteTable_allocate_rowreq_ctx(inetCidrRouteTable_data * data, |
| 686 |
void *user_init_ctx) |
| 687 |
{ |
| 688 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = |
| 689 |
SNMP_MALLOC_TYPEDEF(inetCidrRouteTable_rowreq_ctx); |
| 690 |
|
| 691 |
DEBUGMSGTL(("internal:inetCidrRouteTable:inetCidrRouteTable_allocate_rowreq_ctx", "called\n")); |
| 692 |
|
| 693 |
if (NULL == rowreq_ctx) { |
| 694 |
snmp_log(LOG_ERR, "Couldn't allocate memory for a " |
| 695 |
"inetCidrRouteTable_rowreq_ctx.\n"); |
| 696 |
return NULL; |
| 697 |
} else { |
| 698 |
if (NULL != data) { |
| 699 |
/* |
| 700 |
* track if we got data from user |
| 701 |
*/ |
| 702 |
rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER; |
| 703 |
rowreq_ctx->data = data; |
| 704 |
} else if (NULL == |
| 705 |
(rowreq_ctx->data = |
| 706 |
inetCidrRouteTable_allocate_data())) { |
| 707 |
SNMP_FREE(rowreq_ctx); |
| 708 |
return NULL; |
| 709 |
} |
| 710 |
} |
| 711 |
|
| 712 |
/* |
| 713 |
* undo context will be allocated when needed (in *_undo_setup) |
| 714 |
*/ |
| 715 |
|
| 716 |
rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; |
| 717 |
|
| 718 |
rowreq_ctx->inetCidrRouteTable_data_list = NULL; |
| 719 |
|
| 720 |
/* |
| 721 |
* if we allocated data, call init routine |
| 722 |
*/ |
| 723 |
if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { |
| 724 |
if (SNMPERR_SUCCESS != |
| 725 |
inetCidrRouteTable_rowreq_ctx_init(rowreq_ctx, |
| 726 |
user_init_ctx)) { |
| 727 |
inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); |
| 728 |
rowreq_ctx = NULL; |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
return rowreq_ctx; |
| 733 |
} /* inetCidrRouteTable_allocate_rowreq_ctx */ |
| 734 |
|
| 735 |
/* |
| 736 |
* @internal |
| 737 |
* release resources for a inetCidrRouteTable_rowreq_ctx |
| 738 |
*/ |
| 739 |
void |
| 740 |
inetCidrRouteTable_release_rowreq_ctx(inetCidrRouteTable_rowreq_ctx * |
| 741 |
rowreq_ctx) |
| 742 |
{ |
| 743 |
DEBUGMSGTL(("internal:inetCidrRouteTable:inetCidrRouteTable_release_rowreq_ctx", "called\n")); |
| 744 |
|
| 745 |
netsnmp_assert(NULL != rowreq_ctx); |
| 746 |
|
| 747 |
inetCidrRouteTable_rowreq_ctx_cleanup(rowreq_ctx); |
| 748 |
|
| 749 |
/* |
| 750 |
* for non-transient data, don't free data we got from the user |
| 751 |
*/ |
| 752 |
if ((rowreq_ctx->data) && |
| 753 |
!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) |
| 754 |
inetCidrRouteTable_release_data(rowreq_ctx->data); |
| 755 |
|
| 756 |
if (rowreq_ctx->undo) |
| 757 |
inetCidrRouteTable_release_data(rowreq_ctx->undo); |
| 758 |
|
| 759 |
/* |
| 760 |
* free index oid pointer |
| 761 |
*/ |
| 762 |
if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) |
| 763 |
free(rowreq_ctx->oid_idx.oids); |
| 764 |
|
| 765 |
SNMP_FREE(rowreq_ctx); |
| 766 |
} /* inetCidrRouteTable_release_rowreq_ctx */ |
| 767 |
|
| 768 |
/** |
| 769 |
* @internal |
| 770 |
* wrapper |
| 771 |
*/ |
| 772 |
static int |
| 773 |
_mfd_inetCidrRouteTable_pre_request(netsnmp_mib_handler *handler, |
| 774 |
netsnmp_handler_registration *reginfo, |
| 775 |
netsnmp_agent_request_info |
| 776 |
*agtreq_info, |
| 777 |
netsnmp_request_info *requests) |
| 778 |
{ |
| 779 |
int rc; |
| 780 |
|
| 781 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_pre_request", "called\n")); |
| 782 |
|
| 783 |
if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { |
| 784 |
DEBUGMSGTL(("internal:inetCidrRouteTable", |
| 785 |
"skipping additional pre_request\n")); |
| 786 |
return SNMP_ERR_NOERROR; |
| 787 |
} |
| 788 |
|
| 789 |
rc = inetCidrRouteTable_pre_request(inetCidrRouteTable_if_ctx. |
| 790 |
user_ctx); |
| 791 |
if (MFD_SUCCESS != rc) { |
| 792 |
/* |
| 793 |
* nothing we can do about it but log it |
| 794 |
*/ |
| 795 |
DEBUGMSGTL(("inetCidrRouteTable", "error %d from " |
| 796 |
"inetCidrRouteTable_pre_request\n", rc)); |
| 797 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 798 |
} |
| 799 |
|
| 800 |
return SNMP_ERR_NOERROR; |
| 801 |
} /* _mfd_inetCidrRouteTable_pre_request */ |
| 802 |
|
| 803 |
/** |
| 804 |
* @internal |
| 805 |
* wrapper |
| 806 |
*/ |
| 807 |
static int |
| 808 |
_mfd_inetCidrRouteTable_post_request(netsnmp_mib_handler *handler, |
| 809 |
netsnmp_handler_registration *reginfo, |
| 810 |
netsnmp_agent_request_info |
| 811 |
*agtreq_info, |
| 812 |
netsnmp_request_info *requests) |
| 813 |
{ |
| 814 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 815 |
netsnmp_container_table_row_extract(requests); |
| 816 |
int rc, packet_rc; |
| 817 |
|
| 818 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_post_request", "called\n")); |
| 819 |
|
| 820 |
/* |
| 821 |
* release row context, if deleted |
| 822 |
*/ |
| 823 |
if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) |
| 824 |
inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); |
| 825 |
|
| 826 |
/* |
| 827 |
* wait for last call before calling user |
| 828 |
*/ |
| 829 |
if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { |
| 830 |
DEBUGMSGTL(("internal:inetCidrRouteTable", |
| 831 |
"waiting for last post_request\n")); |
| 832 |
return SNMP_ERR_NOERROR; |
| 833 |
} |
| 834 |
|
| 835 |
packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); |
| 836 |
if ((MFD_SUCCESS != packet_rc) && inetCidrRouteTable_dirty_get()) { |
| 837 |
/* |
| 838 |
* we shouldn't get here. the undo steps should also clear |
| 839 |
* the dirty flags. |
| 840 |
*/ |
| 841 |
snmp_log(LOG_WARNING, |
| 842 |
"inetCidrRouteTable dirty flag set in post_request " |
| 843 |
"but status != SUCCESS.\n"); |
| 844 |
} |
| 845 |
|
| 846 |
rc = inetCidrRouteTable_post_request(inetCidrRouteTable_if_ctx. |
| 847 |
user_ctx, packet_rc); |
| 848 |
if (MFD_SUCCESS != rc) { |
| 849 |
/* |
| 850 |
* nothing we can do about it but log it |
| 851 |
*/ |
| 852 |
DEBUGMSGTL(("inetCidrRouteTable", "error %d from " |
| 853 |
"inetCidrRouteTable_post_request\n", rc)); |
| 854 |
} |
| 855 |
|
| 856 |
return SNMP_ERR_NOERROR; |
| 857 |
} /* _mfd_inetCidrRouteTable_post_request */ |
| 858 |
|
| 859 |
/** |
| 860 |
* @internal |
| 861 |
* wrapper |
| 862 |
*/ |
| 863 |
static inetCidrRouteTable_rowreq_ctx * |
| 864 |
_mfd_inetCidrRouteTable_rowreq_from_index(netsnmp_index * oid_idx, |
| 865 |
int *rc_ptr) |
| 866 |
{ |
| 867 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx; |
| 868 |
inetCidrRouteTable_mib_index mib_idx; |
| 869 |
int rc; |
| 870 |
|
| 871 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_rowreq_from_index", "called\n")); |
| 872 |
|
| 873 |
if (NULL == rc_ptr) |
| 874 |
rc_ptr = &rc; |
| 875 |
*rc_ptr = MFD_SUCCESS; |
| 876 |
|
| 877 |
memset(&mib_idx, 0x0, sizeof(mib_idx)); |
| 878 |
|
| 879 |
/* |
| 880 |
* try to parse oid |
| 881 |
*/ |
| 882 |
*rc_ptr = inetCidrRouteTable_index_from_oid(oid_idx, &mib_idx); |
| 883 |
if (MFD_SUCCESS != *rc_ptr) { |
| 884 |
DEBUGMSGT(("inetCidrRouteTable", "error parsing index\n")); |
| 885 |
return NULL; |
| 886 |
} |
| 887 |
|
| 888 |
/* |
| 889 |
* allocate new context |
| 890 |
*/ |
| 891 |
rowreq_ctx = inetCidrRouteTable_allocate_rowreq_ctx(NULL, NULL); |
| 892 |
if (NULL == rowreq_ctx) { |
| 893 |
*rc_ptr = MFD_ERROR; |
| 894 |
return NULL; /* msg already logged */ |
| 895 |
} |
| 896 |
|
| 897 |
memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx)); |
| 898 |
|
| 899 |
/* |
| 900 |
* check indexes |
| 901 |
*/ |
| 902 |
*rc_ptr = _inetCidrRouteTable_check_indexes(rowreq_ctx); |
| 903 |
if (MFD_SUCCESS != *rc_ptr) { |
| 904 |
netsnmp_assert((*rc_ptr == SNMP_ERR_NOCREATION) || |
| 905 |
(*rc_ptr == SNMP_ERR_INCONSISTENTNAME)); |
| 906 |
inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); |
| 907 |
return NULL; |
| 908 |
} |
| 909 |
|
| 910 |
/* |
| 911 |
* copy indexes |
| 912 |
*/ |
| 913 |
rowreq_ctx->oid_idx.len = oid_idx->len; |
| 914 |
memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids, |
| 915 |
oid_idx->len * sizeof(oid)); |
| 916 |
|
| 917 |
return rowreq_ctx; |
| 918 |
} /* _mfd_inetCidrRouteTable_rowreq_from_index */ |
| 919 |
|
| 920 |
|
| 921 |
/** |
| 922 |
* @internal |
| 923 |
* wrapper |
| 924 |
*/ |
| 925 |
static int |
| 926 |
_mfd_inetCidrRouteTable_object_lookup(netsnmp_mib_handler *handler, netsnmp_handler_registration |
| 927 |
*reginfo, netsnmp_agent_request_info |
| 928 |
*agtreq_info, |
| 929 |
netsnmp_request_info *requests) |
| 930 |
{ |
| 931 |
int rc = SNMP_ERR_NOERROR; |
| 932 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 933 |
netsnmp_container_table_row_extract(requests); |
| 934 |
|
| 935 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_object_lookup", "called\n")); |
| 936 |
|
| 937 |
/* |
| 938 |
* get our context from mfd |
| 939 |
* inetCidrRouteTable_interface_ctx *if_ctx = |
| 940 |
* (inetCidrRouteTable_interface_ctx *)reginfo->my_reg_void; |
| 941 |
*/ |
| 942 |
|
| 943 |
if (NULL == rowreq_ctx) { |
| 944 |
netsnmp_table_request_info *tblreq_info; |
| 945 |
netsnmp_index oid_idx; |
| 946 |
|
| 947 |
tblreq_info = netsnmp_extract_table_info(requests); |
| 948 |
if (NULL == tblreq_info) { |
| 949 |
snmp_log(LOG_ERR, "request had no table info\n"); |
| 950 |
return MFD_ERROR; |
| 951 |
} |
| 952 |
|
| 953 |
/* |
| 954 |
* try create rowreq |
| 955 |
*/ |
| 956 |
oid_idx.oids = tblreq_info->index_oid; |
| 957 |
oid_idx.len = tblreq_info->index_oid_len; |
| 958 |
|
| 959 |
rowreq_ctx = |
| 960 |
_mfd_inetCidrRouteTable_rowreq_from_index(&oid_idx, &rc); |
| 961 |
if (MFD_SUCCESS == rc) { |
| 962 |
netsnmp_assert(NULL != rowreq_ctx); |
| 963 |
rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED; |
| 964 |
/* |
| 965 |
* add rowreq_ctx to request data lists |
| 966 |
*/ |
| 967 |
netsnmp_container_table_row_insert(requests, (netsnmp_index *) |
| 968 |
rowreq_ctx); |
| 969 |
} |
| 970 |
} |
| 971 |
|
| 972 |
if (MFD_SUCCESS != rc) |
| 973 |
netsnmp_request_set_error_all(requests, rc); |
| 974 |
else |
| 975 |
inetCidrRouteTable_row_prep(rowreq_ctx); |
| 976 |
|
| 977 |
return SNMP_VALIDATE_ERR(rc); |
| 978 |
} /* _mfd_inetCidrRouteTable_object_lookup */ |
| 979 |
|
| 980 |
/*********************************************************************** |
| 981 |
* |
| 982 |
* GET processing |
| 983 |
* |
| 984 |
***********************************************************************/ |
| 985 |
/* |
| 986 |
* @internal |
| 987 |
* Retrieve the value for a particular column |
| 988 |
*/ |
| 989 |
NETSNMP_STATIC_INLINE int |
| 990 |
_inetCidrRouteTable_get_column(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, |
| 991 |
netsnmp_variable_list * var, int column) |
| 992 |
{ |
| 993 |
int rc = SNMPERR_SUCCESS; |
| 994 |
|
| 995 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_get_column", "called for %d\n", column)); |
| 996 |
|
| 997 |
|
| 998 |
netsnmp_assert(NULL != rowreq_ctx); |
| 999 |
|
| 1000 |
switch (column) { |
| 1001 |
|
| 1002 |
/* |
| 1003 |
* inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H |
| 1004 |
*/ |
| 1005 |
case COLUMN_INETCIDRROUTEIFINDEX: |
| 1006 |
var->val_len = sizeof(long); |
| 1007 |
var->type = ASN_INTEGER; |
| 1008 |
rc = inetCidrRouteIfIndex_get(rowreq_ctx, |
| 1009 |
(long *) var->val.string); |
| 1010 |
break; |
| 1011 |
|
| 1012 |
/* |
| 1013 |
* inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1014 |
*/ |
| 1015 |
case COLUMN_INETCIDRROUTETYPE: |
| 1016 |
var->val_len = sizeof(u_long); |
| 1017 |
var->type = ASN_INTEGER; |
| 1018 |
rc = inetCidrRouteType_get(rowreq_ctx, (u_long *) var->val.string); |
| 1019 |
break; |
| 1020 |
|
| 1021 |
/* |
| 1022 |
* inetCidrRouteProto(9)/IANAipRouteProtocol/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h |
| 1023 |
*/ |
| 1024 |
case COLUMN_INETCIDRROUTEPROTO: |
| 1025 |
var->val_len = sizeof(u_long); |
| 1026 |
var->type = ASN_INTEGER; |
| 1027 |
rc = inetCidrRouteProto_get(rowreq_ctx, |
| 1028 |
(u_long *) var->val.string); |
| 1029 |
break; |
| 1030 |
|
| 1031 |
/* |
| 1032 |
* inetCidrRouteAge(10)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h |
| 1033 |
*/ |
| 1034 |
case COLUMN_INETCIDRROUTEAGE: |
| 1035 |
var->val_len = sizeof(u_long); |
| 1036 |
var->type = ASN_GAUGE; |
| 1037 |
rc = inetCidrRouteAge_get(rowreq_ctx, (u_long *) var->val.string); |
| 1038 |
break; |
| 1039 |
|
| 1040 |
/* |
| 1041 |
* inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H |
| 1042 |
*/ |
| 1043 |
case COLUMN_INETCIDRROUTENEXTHOPAS: |
| 1044 |
var->val_len = sizeof(u_long); |
| 1045 |
var->type = ASN_UNSIGNED; |
| 1046 |
rc = inetCidrRouteNextHopAS_get(rowreq_ctx, |
| 1047 |
(u_long *) var->val.string); |
| 1048 |
break; |
| 1049 |
|
| 1050 |
/* |
| 1051 |
* inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1052 |
*/ |
| 1053 |
case COLUMN_INETCIDRROUTEMETRIC1: |
| 1054 |
var->val_len = sizeof(long); |
| 1055 |
var->type = ASN_INTEGER; |
| 1056 |
rc = inetCidrRouteMetric1_get(rowreq_ctx, |
| 1057 |
(long *) var->val.string); |
| 1058 |
break; |
| 1059 |
|
| 1060 |
/* |
| 1061 |
* inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1062 |
*/ |
| 1063 |
case COLUMN_INETCIDRROUTEMETRIC2: |
| 1064 |
var->val_len = sizeof(long); |
| 1065 |
var->type = ASN_INTEGER; |
| 1066 |
rc = inetCidrRouteMetric2_get(rowreq_ctx, |
| 1067 |
(long *) var->val.string); |
| 1068 |
break; |
| 1069 |
|
| 1070 |
/* |
| 1071 |
* inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1072 |
*/ |
| 1073 |
case COLUMN_INETCIDRROUTEMETRIC3: |
| 1074 |
var->val_len = sizeof(long); |
| 1075 |
var->type = ASN_INTEGER; |
| 1076 |
rc = inetCidrRouteMetric3_get(rowreq_ctx, |
| 1077 |
(long *) var->val.string); |
| 1078 |
break; |
| 1079 |
|
| 1080 |
/* |
| 1081 |
* inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1082 |
*/ |
| 1083 |
case COLUMN_INETCIDRROUTEMETRIC4: |
| 1084 |
var->val_len = sizeof(long); |
| 1085 |
var->type = ASN_INTEGER; |
| 1086 |
rc = inetCidrRouteMetric4_get(rowreq_ctx, |
| 1087 |
(long *) var->val.string); |
| 1088 |
break; |
| 1089 |
|
| 1090 |
/* |
| 1091 |
* inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1092 |
*/ |
| 1093 |
case COLUMN_INETCIDRROUTEMETRIC5: |
| 1094 |
var->val_len = sizeof(long); |
| 1095 |
var->type = ASN_INTEGER; |
| 1096 |
rc = inetCidrRouteMetric5_get(rowreq_ctx, |
| 1097 |
(long *) var->val.string); |
| 1098 |
break; |
| 1099 |
|
| 1100 |
/* |
| 1101 |
* inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1102 |
*/ |
| 1103 |
case COLUMN_INETCIDRROUTESTATUS: |
| 1104 |
var->val_len = sizeof(u_long); |
| 1105 |
var->type = ASN_INTEGER; |
| 1106 |
rc = inetCidrRouteStatus_get(rowreq_ctx, |
| 1107 |
(u_long *) var->val.string); |
| 1108 |
break; |
| 1109 |
|
| 1110 |
default: |
| 1111 |
snmp_log(LOG_ERR, |
| 1112 |
"unknown column %d in _inetCidrRouteTable_get_column\n", |
| 1113 |
column); |
| 1114 |
break; |
| 1115 |
} |
| 1116 |
|
| 1117 |
return rc; |
| 1118 |
} /* _inetCidrRouteTable_get_column */ |
| 1119 |
|
| 1120 |
int |
| 1121 |
_mfd_inetCidrRouteTable_get_values(netsnmp_mib_handler *handler, |
| 1122 |
netsnmp_handler_registration *reginfo, |
| 1123 |
netsnmp_agent_request_info *agtreq_info, |
| 1124 |
netsnmp_request_info *requests) |
| 1125 |
{ |
| 1126 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 1127 |
netsnmp_container_table_row_extract(requests); |
| 1128 |
netsnmp_table_request_info *tri; |
| 1129 |
u_char *old_string; |
| 1130 |
void (*dataFreeHook) (void *); |
| 1131 |
int rc; |
| 1132 |
|
| 1133 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_get_values", "called\n")); |
| 1134 |
|
| 1135 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1136 |
|
| 1137 |
for (; requests; requests = requests->next) { |
| 1138 |
/* |
| 1139 |
* save old pointer, so we can free it if replaced |
| 1140 |
*/ |
| 1141 |
old_string = requests->requestvb->val.string; |
| 1142 |
dataFreeHook = requests->requestvb->dataFreeHook; |
| 1143 |
if (NULL == requests->requestvb->val.string) { |
| 1144 |
requests->requestvb->val.string = requests->requestvb->buf; |
| 1145 |
requests->requestvb->val_len = |
| 1146 |
sizeof(requests->requestvb->buf); |
| 1147 |
} else if (requests->requestvb->buf == |
| 1148 |
requests->requestvb->val.string) { |
| 1149 |
if (requests->requestvb->val_len != |
| 1150 |
sizeof(requests->requestvb->buf)) |
| 1151 |
requests->requestvb->val_len = |
| 1152 |
sizeof(requests->requestvb->buf); |
| 1153 |
} |
| 1154 |
|
| 1155 |
/* |
| 1156 |
* get column data |
| 1157 |
*/ |
| 1158 |
tri = netsnmp_extract_table_info(requests); |
| 1159 |
if (NULL == tri) |
| 1160 |
continue; |
| 1161 |
|
| 1162 |
rc = _inetCidrRouteTable_get_column(rowreq_ctx, |
| 1163 |
requests->requestvb, |
| 1164 |
tri->colnum); |
| 1165 |
if (rc) { |
| 1166 |
if (MFD_SKIP == rc) { |
| 1167 |
requests->requestvb->type = SNMP_NOSUCHINSTANCE; |
| 1168 |
rc = SNMP_ERR_NOERROR; |
| 1169 |
} |
| 1170 |
} else if (NULL == requests->requestvb->val.string) { |
| 1171 |
snmp_log(LOG_ERR, "NULL varbind data pointer!\n"); |
| 1172 |
rc = SNMP_ERR_GENERR; |
| 1173 |
} |
| 1174 |
if (rc) |
| 1175 |
netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
| 1176 |
|
| 1177 |
/* |
| 1178 |
* if the buffer wasn't used previously for the old data (i.e. it |
| 1179 |
* was allocated memory) and the get routine replaced the pointer, |
| 1180 |
* we need to free the previous pointer. |
| 1181 |
*/ |
| 1182 |
if (old_string && (old_string != requests->requestvb->buf) && |
| 1183 |
(requests->requestvb->val.string != old_string)) { |
| 1184 |
if (dataFreeHook) |
| 1185 |
(*dataFreeHook) (old_string); |
| 1186 |
else |
| 1187 |
free(old_string); |
| 1188 |
} |
| 1189 |
} /* for results */ |
| 1190 |
|
| 1191 |
return SNMP_ERR_NOERROR; |
| 1192 |
} /* _mfd_inetCidrRouteTable_get_values */ |
| 1193 |
|
| 1194 |
NETSNMP_STATIC_INLINE int |
| 1195 |
_inetCidrRouteTable_check_indexes(inetCidrRouteTable_rowreq_ctx * |
| 1196 |
rowreq_ctx) |
| 1197 |
{ |
| 1198 |
int rc = SNMPERR_SUCCESS; |
| 1199 |
|
| 1200 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_check_indexes", "called\n")); |
| 1201 |
|
| 1202 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1203 |
|
| 1204 |
|
| 1205 |
/* |
| 1206 |
* (INDEX) inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 1207 |
*/ |
| 1208 |
/* |
| 1209 |
* check that the value is one of defined enums |
| 1210 |
*/ |
| 1211 |
if ((SNMPERR_SUCCESS == rc) |
| 1212 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteDestType != |
| 1213 |
INETADDRESSTYPE_UNKNOWN) |
| 1214 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteDestType != |
| 1215 |
INETADDRESSTYPE_IPV4) |
| 1216 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteDestType != |
| 1217 |
INETADDRESSTYPE_IPV6) |
| 1218 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteDestType != |
| 1219 |
INETADDRESSTYPE_IPV4Z) |
| 1220 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteDestType != |
| 1221 |
INETADDRESSTYPE_IPV6Z) |
| 1222 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteDestType != |
| 1223 |
INETADDRESSTYPE_DNS) |
| 1224 |
) { |
| 1225 |
rc = SNMP_ERR_WRONGVALUE; |
| 1226 |
} |
| 1227 |
if (MFD_SUCCESS != rc) |
| 1228 |
return rc; |
| 1229 |
rc = inetCidrRouteDestType_check_index(rowreq_ctx); |
| 1230 |
if (MFD_SUCCESS != rc) |
| 1231 |
return SNMP_ERR_NOCREATION; |
| 1232 |
|
| 1233 |
/* MORE CHECKING REQUIRED */ |
| 1234 |
|
| 1235 |
/* |
| 1236 |
* (INDEX) inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 1237 |
*/ |
| 1238 |
/* |
| 1239 |
* check defined range(s). |
| 1240 |
*/ |
| 1241 |
if (rc == SNMPERR_SUCCESS && |
| 1242 |
rowreq_ctx->tbl_idx.inetCidrRouteDest_len > 255) { |
| 1243 |
rc = SNMP_ERR_WRONGLENGTH; |
| 1244 |
} |
| 1245 |
if (MFD_SUCCESS != rc) |
| 1246 |
return rc; |
| 1247 |
rc = inetCidrRouteDest_check_index(rowreq_ctx); |
| 1248 |
if (MFD_SUCCESS != rc) |
| 1249 |
return SNMP_ERR_NOCREATION; |
| 1250 |
|
| 1251 |
/* |
| 1252 |
* (INDEX) inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H |
| 1253 |
*/ |
| 1254 |
/* |
| 1255 |
* check defined range(s). |
| 1256 |
*/ |
| 1257 |
if (rc == SNMPERR_SUCCESS && |
| 1258 |
rowreq_ctx->tbl_idx.inetCidrRoutePfxLen > 2040) { |
| 1259 |
rc = SNMP_ERR_WRONGVALUE; |
| 1260 |
} |
| 1261 |
if (MFD_SUCCESS != rc) |
| 1262 |
return rc; |
| 1263 |
rc = inetCidrRoutePfxLen_check_index(rowreq_ctx); |
| 1264 |
if (MFD_SUCCESS != rc) |
| 1265 |
return SNMP_ERR_NOCREATION; |
| 1266 |
|
| 1267 |
/* |
| 1268 |
* (INDEX) inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h |
| 1269 |
*/ |
| 1270 |
if (MFD_SUCCESS != rc) |
| 1271 |
return rc; |
| 1272 |
rc = inetCidrRoutePolicy_check_index(rowreq_ctx); |
| 1273 |
if (MFD_SUCCESS != rc) |
| 1274 |
return SNMP_ERR_NOCREATION; |
| 1275 |
|
| 1276 |
/* |
| 1277 |
* (INDEX) inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 1278 |
*/ |
| 1279 |
/* |
| 1280 |
* check that the value is one of defined enums |
| 1281 |
*/ |
| 1282 |
if ((SNMPERR_SUCCESS == rc) |
| 1283 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != |
| 1284 |
INETADDRESSTYPE_UNKNOWN) |
| 1285 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != |
| 1286 |
INETADDRESSTYPE_IPV4) |
| 1287 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != |
| 1288 |
INETADDRESSTYPE_IPV6) |
| 1289 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != |
| 1290 |
INETADDRESSTYPE_IPV4Z) |
| 1291 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != |
| 1292 |
INETADDRESSTYPE_IPV6Z) |
| 1293 |
&& (rowreq_ctx->tbl_idx.inetCidrRouteNextHopType != |
| 1294 |
INETADDRESSTYPE_DNS) |
| 1295 |
) { |
| 1296 |
rc = SNMP_ERR_WRONGVALUE; |
| 1297 |
} |
| 1298 |
if (MFD_SUCCESS != rc) |
| 1299 |
return rc; |
| 1300 |
rc = inetCidrRouteNextHopType_check_index(rowreq_ctx); |
| 1301 |
if (MFD_SUCCESS != rc) |
| 1302 |
return SNMP_ERR_NOCREATION; |
| 1303 |
|
| 1304 |
/* |
| 1305 |
* (INDEX) inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 1306 |
*/ |
| 1307 |
/* |
| 1308 |
* check defined range(s). |
| 1309 |
*/ |
| 1310 |
if (rc == SNMPERR_SUCCESS && |
| 1311 |
rowreq_ctx->tbl_idx.inetCidrRouteNextHop_len > 255) { |
| 1312 |
rc = SNMP_ERR_WRONGLENGTH; |
| 1313 |
} |
| 1314 |
if (MFD_SUCCESS != rc) |
| 1315 |
return rc; |
| 1316 |
rc = inetCidrRouteNextHop_check_index(rowreq_ctx); |
| 1317 |
if (MFD_SUCCESS != rc) |
| 1318 |
return SNMP_ERR_NOCREATION; |
| 1319 |
|
| 1320 |
/* |
| 1321 |
* if individual parts look ok, check them as a whole |
| 1322 |
*/ |
| 1323 |
return inetCidrRouteTable_validate_index(inetCidrRouteTable_if_ctx. |
| 1324 |
user_ctx, rowreq_ctx); |
| 1325 |
} /* _inetCidrRouteTable_check_indexes */ |
| 1326 |
|
| 1327 |
#if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT)) |
| 1328 |
/*********************************************************************** |
| 1329 |
* |
| 1330 |
* SET processing |
| 1331 |
* |
| 1332 |
***********************************************************************/ |
| 1333 |
|
| 1334 |
/*---------------------------------------------------------------------- |
| 1335 |
* |
| 1336 |
* SET: Syntax checks |
| 1337 |
* |
| 1338 |
*---------------------------------------------------------------------*/ |
| 1339 |
/* |
| 1340 |
* @internal |
| 1341 |
* Check the syntax for a particular column |
| 1342 |
*/ |
| 1343 |
NETSNMP_STATIC_INLINE int |
| 1344 |
_inetCidrRouteTable_check_column(inetCidrRouteTable_rowreq_ctx * |
| 1345 |
rowreq_ctx, netsnmp_variable_list * var, |
| 1346 |
int column) |
| 1347 |
{ |
| 1348 |
int rc = SNMPERR_SUCCESS; |
| 1349 |
|
| 1350 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_check_column", "called for %d\n", column)); |
| 1351 |
|
| 1352 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1353 |
|
| 1354 |
switch (column) { |
| 1355 |
/* |
| 1356 |
* (INDEX) inetCidrRouteDestType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 1357 |
*/ |
| 1358 |
case COLUMN_INETCIDRROUTEDESTTYPE: |
| 1359 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 1360 |
break; |
| 1361 |
/* |
| 1362 |
* (INDEX) inetCidrRouteDest(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 1363 |
*/ |
| 1364 |
case COLUMN_INETCIDRROUTEDEST: |
| 1365 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 1366 |
break; |
| 1367 |
/* |
| 1368 |
* (INDEX) inetCidrRoutePfxLen(3)/InetAddressPrefixLength/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H |
| 1369 |
*/ |
| 1370 |
case COLUMN_INETCIDRROUTEPFXLEN: |
| 1371 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 1372 |
break; |
| 1373 |
/* |
| 1374 |
* (INDEX) inetCidrRoutePolicy(4)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h |
| 1375 |
*/ |
| 1376 |
case COLUMN_INETCIDRROUTEPOLICY: |
| 1377 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 1378 |
break; |
| 1379 |
/* |
| 1380 |
* (INDEX) inetCidrRouteNextHopType(5)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h |
| 1381 |
*/ |
| 1382 |
case COLUMN_INETCIDRROUTENEXTHOPTYPE: |
| 1383 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 1384 |
break; |
| 1385 |
/* |
| 1386 |
* (INDEX) inetCidrRouteNextHop(6)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h |
| 1387 |
*/ |
| 1388 |
case COLUMN_INETCIDRROUTENEXTHOP: |
| 1389 |
rc = SNMP_ERR_NOTWRITABLE; /* can not change index of active row */ |
| 1390 |
break; |
| 1391 |
|
| 1392 |
/* |
| 1393 |
* inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H |
| 1394 |
*/ |
| 1395 |
case COLUMN_INETCIDRROUTEIFINDEX: |
| 1396 |
rc = netsnmp_check_vb_type(var, ASN_INTEGER); |
| 1397 |
/* |
| 1398 |
* check defined range(s). |
| 1399 |
*/ |
| 1400 |
if ((SNMPERR_SUCCESS == rc) |
| 1401 |
&& ((*var->val.integer < 0) |
| 1402 |
|| (*var->val.integer > 2147483647)) |
| 1403 |
) { |
| 1404 |
rc = SNMP_ERR_WRONGVALUE; |
| 1405 |
} |
| 1406 |
if (SNMPERR_SUCCESS != rc) { |
| 1407 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteIfIndex", "varbind validation failed (eg bad type or size)\n")); |
| 1408 |
} else { |
| 1409 |
rc = inetCidrRouteIfIndex_check_value(rowreq_ctx, |
| 1410 |
*((long *) var->val. |
| 1411 |
string)); |
| 1412 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1413 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1414 |
snmp_log(LOG_ERR, |
| 1415 |
"bad rc %d from inetCidrRouteIfIndex_check_value\n", |
| 1416 |
rc); |
| 1417 |
rc = SNMP_ERR_GENERR; |
| 1418 |
} |
| 1419 |
} |
| 1420 |
break; |
| 1421 |
|
| 1422 |
/* |
| 1423 |
* inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1424 |
*/ |
| 1425 |
case COLUMN_INETCIDRROUTETYPE: |
| 1426 |
rc = netsnmp_check_vb_type(var, ASN_INTEGER); |
| 1427 |
/* |
| 1428 |
* check that the value is one of defined enums |
| 1429 |
*/ |
| 1430 |
if ((SNMPERR_SUCCESS == rc) |
| 1431 |
&& (*var->val.integer != INETCIDRROUTETYPE_OTHER) |
| 1432 |
&& (*var->val.integer != INETCIDRROUTETYPE_REJECT) |
| 1433 |
&& (*var->val.integer != INETCIDRROUTETYPE_LOCAL) |
| 1434 |
&& (*var->val.integer != INETCIDRROUTETYPE_REMOTE) |
| 1435 |
&& (*var->val.integer != INETCIDRROUTETYPE_BLACKHOLE) |
| 1436 |
) { |
| 1437 |
rc = SNMP_ERR_WRONGVALUE; |
| 1438 |
} |
| 1439 |
if (SNMPERR_SUCCESS != rc) { |
| 1440 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteType", "varbind validation failed (eg bad type or size)\n")); |
| 1441 |
} else { |
| 1442 |
rc = inetCidrRouteType_check_value(rowreq_ctx, |
| 1443 |
*((u_long *) var->val. |
| 1444 |
string)); |
| 1445 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1446 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1447 |
snmp_log(LOG_ERR, |
| 1448 |
"bad rc %d from inetCidrRouteType_check_value\n", |
| 1449 |
rc); |
| 1450 |
rc = SNMP_ERR_GENERR; |
| 1451 |
} |
| 1452 |
} |
| 1453 |
break; |
| 1454 |
|
| 1455 |
/* |
| 1456 |
* inetCidrRouteProto(9)/IANAipRouteProtocol/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h |
| 1457 |
*/ |
| 1458 |
case COLUMN_INETCIDRROUTEPROTO: |
| 1459 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1460 |
break; |
| 1461 |
|
| 1462 |
/* |
| 1463 |
* inetCidrRouteAge(10)/GAUGE/ASN_GAUGE/u_long(u_long)//l/A/w/e/r/d/h |
| 1464 |
*/ |
| 1465 |
case COLUMN_INETCIDRROUTEAGE: |
| 1466 |
rc = SNMP_ERR_NOTWRITABLE; |
| 1467 |
break; |
| 1468 |
|
| 1469 |
/* |
| 1470 |
* inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H |
| 1471 |
*/ |
| 1472 |
case COLUMN_INETCIDRROUTENEXTHOPAS: |
| 1473 |
rc = netsnmp_check_vb_type(var, ASN_UNSIGNED); |
| 1474 |
if (SNMPERR_SUCCESS != rc) { |
| 1475 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteNextHopAS", "varbind validation failed (eg bad type or size)\n")); |
| 1476 |
} else { |
| 1477 |
rc = inetCidrRouteNextHopAS_check_value(rowreq_ctx, |
| 1478 |
*((u_long *) var->val. |
| 1479 |
string)); |
| 1480 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1481 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1482 |
snmp_log(LOG_ERR, |
| 1483 |
"bad rc %d from inetCidrRouteNextHopAS_check_value\n", |
| 1484 |
rc); |
| 1485 |
rc = SNMP_ERR_GENERR; |
| 1486 |
} |
| 1487 |
} |
| 1488 |
break; |
| 1489 |
|
| 1490 |
/* |
| 1491 |
* inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1492 |
*/ |
| 1493 |
case COLUMN_INETCIDRROUTEMETRIC1: |
| 1494 |
rc = netsnmp_check_vb_type(var, ASN_INTEGER); |
| 1495 |
if (SNMPERR_SUCCESS != rc) { |
| 1496 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric1", "varbind validation failed (eg bad type or size)\n")); |
| 1497 |
} else { |
| 1498 |
rc = inetCidrRouteMetric1_check_value(rowreq_ctx, |
| 1499 |
*((long *) var->val. |
| 1500 |
string)); |
| 1501 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1502 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1503 |
snmp_log(LOG_ERR, |
| 1504 |
"bad rc %d from inetCidrRouteMetric1_check_value\n", |
| 1505 |
rc); |
| 1506 |
rc = SNMP_ERR_GENERR; |
| 1507 |
} |
| 1508 |
} |
| 1509 |
break; |
| 1510 |
|
| 1511 |
/* |
| 1512 |
* inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1513 |
*/ |
| 1514 |
case COLUMN_INETCIDRROUTEMETRIC2: |
| 1515 |
rc = netsnmp_check_vb_type(var, ASN_INTEGER); |
| 1516 |
if (SNMPERR_SUCCESS != rc) { |
| 1517 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric2", "varbind validation failed (eg bad type or size)\n")); |
| 1518 |
} else { |
| 1519 |
rc = inetCidrRouteMetric2_check_value(rowreq_ctx, |
| 1520 |
*((long *) var->val. |
| 1521 |
string)); |
| 1522 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1523 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1524 |
snmp_log(LOG_ERR, |
| 1525 |
"bad rc %d from inetCidrRouteMetric2_check_value\n", |
| 1526 |
rc); |
| 1527 |
rc = SNMP_ERR_GENERR; |
| 1528 |
} |
| 1529 |
} |
| 1530 |
break; |
| 1531 |
|
| 1532 |
/* |
| 1533 |
* inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1534 |
*/ |
| 1535 |
case COLUMN_INETCIDRROUTEMETRIC3: |
| 1536 |
rc = netsnmp_check_vb_type(var, ASN_INTEGER); |
| 1537 |
if (SNMPERR_SUCCESS != rc) { |
| 1538 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric3", "varbind validation failed (eg bad type or size)\n")); |
| 1539 |
} else { |
| 1540 |
rc = inetCidrRouteMetric3_check_value(rowreq_ctx, |
| 1541 |
*((long *) var->val. |
| 1542 |
string)); |
| 1543 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1544 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1545 |
snmp_log(LOG_ERR, |
| 1546 |
"bad rc %d from inetCidrRouteMetric3_check_value\n", |
| 1547 |
rc); |
| 1548 |
rc = SNMP_ERR_GENERR; |
| 1549 |
} |
| 1550 |
} |
| 1551 |
break; |
| 1552 |
|
| 1553 |
/* |
| 1554 |
* inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1555 |
*/ |
| 1556 |
case COLUMN_INETCIDRROUTEMETRIC4: |
| 1557 |
rc = netsnmp_check_vb_type(var, ASN_INTEGER); |
| 1558 |
if (SNMPERR_SUCCESS != rc) { |
| 1559 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric4", "varbind validation failed (eg bad type or size)\n")); |
| 1560 |
} else { |
| 1561 |
rc = inetCidrRouteMetric4_check_value(rowreq_ctx, |
| 1562 |
*((long *) var->val. |
| 1563 |
string)); |
| 1564 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1565 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1566 |
snmp_log(LOG_ERR, |
| 1567 |
"bad rc %d from inetCidrRouteMetric4_check_value\n", |
| 1568 |
rc); |
| 1569 |
rc = SNMP_ERR_GENERR; |
| 1570 |
} |
| 1571 |
} |
| 1572 |
break; |
| 1573 |
|
| 1574 |
/* |
| 1575 |
* inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1576 |
*/ |
| 1577 |
case COLUMN_INETCIDRROUTEMETRIC5: |
| 1578 |
rc = netsnmp_check_vb_type(var, ASN_INTEGER); |
| 1579 |
if (SNMPERR_SUCCESS != rc) { |
| 1580 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteMetric5", "varbind validation failed (eg bad type or size)\n")); |
| 1581 |
} else { |
| 1582 |
rc = inetCidrRouteMetric5_check_value(rowreq_ctx, |
| 1583 |
*((long *) var->val. |
| 1584 |
string)); |
| 1585 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1586 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1587 |
snmp_log(LOG_ERR, |
| 1588 |
"bad rc %d from inetCidrRouteMetric5_check_value\n", |
| 1589 |
rc); |
| 1590 |
rc = SNMP_ERR_GENERR; |
| 1591 |
} |
| 1592 |
} |
| 1593 |
break; |
| 1594 |
|
| 1595 |
/* |
| 1596 |
* inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1597 |
*/ |
| 1598 |
case COLUMN_INETCIDRROUTESTATUS: |
| 1599 |
rc = netsnmp_check_vb_rowstatus_value(var); |
| 1600 |
if (SNMPERR_SUCCESS != rc) { |
| 1601 |
DEBUGMSGTL(("inetCidrRouteTable:_inetCidrRouteTable_check_column:inetCidrRouteStatus", "varbind validation failed (eg bad type or size)\n")); |
| 1602 |
} else { |
| 1603 |
rc = inetCidrRouteStatus_check_value(rowreq_ctx, |
| 1604 |
*((u_long *) var->val. |
| 1605 |
string)); |
| 1606 |
if ((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) |
| 1607 |
&& (MFD_NOT_VALID_NOW != rc)) { |
| 1608 |
snmp_log(LOG_ERR, |
| 1609 |
"bad rc %d from inetCidrRouteStatus_check_value\n", |
| 1610 |
rc); |
| 1611 |
rc = SNMP_ERR_GENERR; |
| 1612 |
} |
| 1613 |
} |
| 1614 |
break; |
| 1615 |
|
| 1616 |
default: /** We shouldn't get here */ |
| 1617 |
rc = SNMP_ERR_GENERR; |
| 1618 |
snmp_log(LOG_ERR, |
| 1619 |
"unknown column %d in _inetCidrRouteTable_check_column\n", |
| 1620 |
column); |
| 1621 |
} |
| 1622 |
|
| 1623 |
return rc; |
| 1624 |
} /* _inetCidrRouteTable_check_column */ |
| 1625 |
|
| 1626 |
int |
| 1627 |
_mfd_inetCidrRouteTable_check_objects(netsnmp_mib_handler *handler, netsnmp_handler_registration |
| 1628 |
*reginfo, netsnmp_agent_request_info |
| 1629 |
*agtreq_info, |
| 1630 |
netsnmp_request_info *requests) |
| 1631 |
{ |
| 1632 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 1633 |
netsnmp_container_table_row_extract(requests); |
| 1634 |
netsnmp_table_request_info *tri; |
| 1635 |
int rc; |
| 1636 |
|
| 1637 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_check_objects", "called\n")); |
| 1638 |
|
| 1639 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1640 |
|
| 1641 |
for (; requests; requests = requests->next) { |
| 1642 |
|
| 1643 |
/* |
| 1644 |
* get column number from table request info, and check that column |
| 1645 |
*/ |
| 1646 |
tri = netsnmp_extract_table_info(requests); |
| 1647 |
if (NULL == tri) |
| 1648 |
continue; |
| 1649 |
|
| 1650 |
rc = _inetCidrRouteTable_check_column(rowreq_ctx, |
| 1651 |
requests->requestvb, |
| 1652 |
tri->colnum); |
| 1653 |
if (rc) { |
| 1654 |
netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc)); |
| 1655 |
break; |
| 1656 |
} |
| 1657 |
|
| 1658 |
} /* for results */ |
| 1659 |
|
| 1660 |
return SNMP_ERR_NOERROR; |
| 1661 |
} /* _mfd_inetCidrRouteTable_check_objects */ |
| 1662 |
|
| 1663 |
|
| 1664 |
/*---------------------------------------------------------------------- |
| 1665 |
* |
| 1666 |
* SET: check dependencies |
| 1667 |
* |
| 1668 |
*---------------------------------------------------------------------*/ |
| 1669 |
/* |
| 1670 |
* @internal |
| 1671 |
* Check dependencies wrapper |
| 1672 |
*/ |
| 1673 |
static int |
| 1674 |
_mfd_inetCidrRouteTable_check_dependencies(netsnmp_mib_handler *handler, netsnmp_handler_registration |
| 1675 |
*reginfo, netsnmp_agent_request_info |
| 1676 |
*agtreq_info, |
| 1677 |
netsnmp_request_info *requests) |
| 1678 |
{ |
| 1679 |
int rc; |
| 1680 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 1681 |
netsnmp_container_table_row_extract(requests); |
| 1682 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_check_dependencies", "called\n")); |
| 1683 |
|
| 1684 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1685 |
|
| 1686 |
rc = inetCidrRouteTable_check_dependencies(rowreq_ctx); |
| 1687 |
if (rc) { |
| 1688 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 1689 |
"inetCidrRouteTable_check_dependencies\n", rc)); |
| 1690 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 1691 |
} |
| 1692 |
|
| 1693 |
return SNMP_ERR_NOERROR; |
| 1694 |
} /* _mfd_inetCidrRouteTable_check_dependencies */ |
| 1695 |
|
| 1696 |
/*---------------------------------------------------------------------- |
| 1697 |
* |
| 1698 |
* SET: Undo setup |
| 1699 |
* |
| 1700 |
*---------------------------------------------------------------------*/ |
| 1701 |
/* |
| 1702 |
* @internal |
| 1703 |
* Set the value for a particular column |
| 1704 |
*/ |
| 1705 |
NETSNMP_STATIC_INLINE int |
| 1706 |
_inetCidrRouteTable_undo_setup_column(inetCidrRouteTable_rowreq_ctx * |
| 1707 |
rowreq_ctx, int column) |
| 1708 |
{ |
| 1709 |
int rc = SNMPERR_SUCCESS; |
| 1710 |
|
| 1711 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_undo_setup_column", "called for %d\n", column)); |
| 1712 |
|
| 1713 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1714 |
|
| 1715 |
switch (column) { |
| 1716 |
|
| 1717 |
/* |
| 1718 |
* inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H |
| 1719 |
*/ |
| 1720 |
case COLUMN_INETCIDRROUTEIFINDEX: |
| 1721 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEIFINDEX_FLAG; |
| 1722 |
break; |
| 1723 |
|
| 1724 |
/* |
| 1725 |
* inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1726 |
*/ |
| 1727 |
case COLUMN_INETCIDRROUTETYPE: |
| 1728 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTETYPE_FLAG; |
| 1729 |
break; |
| 1730 |
|
| 1731 |
/* |
| 1732 |
* inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H |
| 1733 |
*/ |
| 1734 |
case COLUMN_INETCIDRROUTENEXTHOPAS: |
| 1735 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTENEXTHOPAS_FLAG; |
| 1736 |
break; |
| 1737 |
|
| 1738 |
/* |
| 1739 |
* inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1740 |
*/ |
| 1741 |
case COLUMN_INETCIDRROUTEMETRIC1: |
| 1742 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC1_FLAG; |
| 1743 |
break; |
| 1744 |
|
| 1745 |
/* |
| 1746 |
* inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1747 |
*/ |
| 1748 |
case COLUMN_INETCIDRROUTEMETRIC2: |
| 1749 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC2_FLAG; |
| 1750 |
break; |
| 1751 |
|
| 1752 |
/* |
| 1753 |
* inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1754 |
*/ |
| 1755 |
case COLUMN_INETCIDRROUTEMETRIC3: |
| 1756 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC3_FLAG; |
| 1757 |
break; |
| 1758 |
|
| 1759 |
/* |
| 1760 |
* inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1761 |
*/ |
| 1762 |
case COLUMN_INETCIDRROUTEMETRIC4: |
| 1763 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC4_FLAG; |
| 1764 |
break; |
| 1765 |
|
| 1766 |
/* |
| 1767 |
* inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1768 |
*/ |
| 1769 |
case COLUMN_INETCIDRROUTEMETRIC5: |
| 1770 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC5_FLAG; |
| 1771 |
break; |
| 1772 |
|
| 1773 |
/* |
| 1774 |
* inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1775 |
*/ |
| 1776 |
case COLUMN_INETCIDRROUTESTATUS: |
| 1777 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTESTATUS_FLAG; |
| 1778 |
break; |
| 1779 |
|
| 1780 |
default: |
| 1781 |
snmp_log(LOG_ERR, |
| 1782 |
"unknown column %d in _inetCidrRouteTable_undo_setup_column\n", |
| 1783 |
column); |
| 1784 |
break; |
| 1785 |
} |
| 1786 |
|
| 1787 |
return rc; |
| 1788 |
} /* _inetCidrRouteTable_undo_setup_column */ |
| 1789 |
|
| 1790 |
|
| 1791 |
/** |
| 1792 |
* @internal |
| 1793 |
* undo setup |
| 1794 |
*/ |
| 1795 |
int |
| 1796 |
_mfd_inetCidrRouteTable_undo_setup(netsnmp_mib_handler *handler, |
| 1797 |
netsnmp_handler_registration *reginfo, |
| 1798 |
netsnmp_agent_request_info *agtreq_info, |
| 1799 |
netsnmp_request_info *requests) |
| 1800 |
{ |
| 1801 |
int rc; |
| 1802 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 1803 |
netsnmp_container_table_row_extract(requests); |
| 1804 |
|
| 1805 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_setup", "called\n")); |
| 1806 |
|
| 1807 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1808 |
|
| 1809 |
/* |
| 1810 |
* allocate undo context |
| 1811 |
*/ |
| 1812 |
rowreq_ctx->undo = inetCidrRouteTable_allocate_data(); |
| 1813 |
if (NULL == rowreq_ctx->undo) { |
| 1814 |
/** msg already logged */ |
| 1815 |
netsnmp_request_set_error_all(requests, |
| 1816 |
SNMP_ERR_RESOURCEUNAVAILABLE); |
| 1817 |
return SNMP_ERR_NOERROR; |
| 1818 |
} |
| 1819 |
|
| 1820 |
/* |
| 1821 |
* row undo setup |
| 1822 |
*/ |
| 1823 |
rowreq_ctx->column_set_flags = 0; |
| 1824 |
rc = inetCidrRouteTable_undo_setup(rowreq_ctx); |
| 1825 |
if (MFD_SUCCESS != rc) { |
| 1826 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 1827 |
"inetCidrRouteTable_undo_setup\n", rc)); |
| 1828 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 1829 |
} else { |
| 1830 |
/* |
| 1831 |
* column undo setup |
| 1832 |
*/ |
| 1833 |
netsnmp_table_request_info *tri; |
| 1834 |
for (; requests; requests = requests->next) { |
| 1835 |
/* |
| 1836 |
* set column data |
| 1837 |
*/ |
| 1838 |
tri = netsnmp_extract_table_info(requests); |
| 1839 |
if (NULL == tri) |
| 1840 |
continue; |
| 1841 |
|
| 1842 |
rc = _inetCidrRouteTable_undo_setup_column(rowreq_ctx, |
| 1843 |
tri->colnum); |
| 1844 |
if (MFD_SUCCESS != rc) { |
| 1845 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 1846 |
"inetCidrRouteTable_undo_setup_column\n", rc)); |
| 1847 |
netsnmp_set_request_error(agtreq_info, requests, |
| 1848 |
SNMP_VALIDATE_ERR(rc)); |
| 1849 |
} |
| 1850 |
} /* for results */ |
| 1851 |
} |
| 1852 |
|
| 1853 |
return SNMP_ERR_NOERROR; |
| 1854 |
} /* _mfd_inetCidrRouteTable_undo_setup */ |
| 1855 |
|
| 1856 |
/** |
| 1857 |
* @internal |
| 1858 |
* undo setup |
| 1859 |
*/ |
| 1860 |
int |
| 1861 |
_mfd_inetCidrRouteTable_undo_cleanup(netsnmp_mib_handler *handler, |
| 1862 |
netsnmp_handler_registration *reginfo, |
| 1863 |
netsnmp_agent_request_info |
| 1864 |
*agtreq_info, |
| 1865 |
netsnmp_request_info *requests) |
| 1866 |
{ |
| 1867 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 1868 |
netsnmp_container_table_row_extract(requests); |
| 1869 |
int rc; |
| 1870 |
|
| 1871 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_cleanup", "called\n")); |
| 1872 |
|
| 1873 |
/* |
| 1874 |
* failed row create in early stages has no rowreq_ctx |
| 1875 |
*/ |
| 1876 |
if (NULL == rowreq_ctx) |
| 1877 |
return MFD_SUCCESS; |
| 1878 |
|
| 1879 |
/* |
| 1880 |
* call user cleanup |
| 1881 |
*/ |
| 1882 |
rc = inetCidrRouteTable_undo_cleanup(rowreq_ctx); |
| 1883 |
if (MFD_SUCCESS != rc) { |
| 1884 |
/* |
| 1885 |
* nothing we can do about it but log it |
| 1886 |
*/ |
| 1887 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 1888 |
"inetCidrRouteTable_undo_cleanup\n", rc)); |
| 1889 |
} |
| 1890 |
|
| 1891 |
/* |
| 1892 |
* release undo context, if needed |
| 1893 |
*/ |
| 1894 |
if (rowreq_ctx->undo) { |
| 1895 |
inetCidrRouteTable_release_data(rowreq_ctx->undo); |
| 1896 |
rowreq_ctx->undo = NULL; |
| 1897 |
} |
| 1898 |
|
| 1899 |
|
| 1900 |
return SNMP_ERR_NOERROR; |
| 1901 |
} /* _mfd_inetCidrRouteTable_undo_cleanup */ |
| 1902 |
|
| 1903 |
/*---------------------------------------------------------------------- |
| 1904 |
* |
| 1905 |
* SET: Set values |
| 1906 |
* |
| 1907 |
*---------------------------------------------------------------------*/ |
| 1908 |
/* |
| 1909 |
* @internal |
| 1910 |
* Set the value for a particular column |
| 1911 |
*/ |
| 1912 |
NETSNMP_STATIC_INLINE int |
| 1913 |
_inetCidrRouteTable_set_column(inetCidrRouteTable_rowreq_ctx * rowreq_ctx, |
| 1914 |
netsnmp_variable_list * var, int column) |
| 1915 |
{ |
| 1916 |
int rc = SNMPERR_SUCCESS; |
| 1917 |
|
| 1918 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_set_column", "called for %d\n", column)); |
| 1919 |
|
| 1920 |
netsnmp_assert(NULL != rowreq_ctx); |
| 1921 |
|
| 1922 |
switch (column) { |
| 1923 |
|
| 1924 |
/* |
| 1925 |
* inetCidrRouteIfIndex(7)/InterfaceIndexOrZero/ASN_INTEGER/long(long)//l/A/W/e/R/d/H |
| 1926 |
*/ |
| 1927 |
case COLUMN_INETCIDRROUTEIFINDEX: |
| 1928 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEIFINDEX_FLAG; |
| 1929 |
rc = inetCidrRouteIfIndex_set(rowreq_ctx, |
| 1930 |
*((long *) var->val.string)); |
| 1931 |
break; |
| 1932 |
|
| 1933 |
/* |
| 1934 |
* inetCidrRouteType(8)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1935 |
*/ |
| 1936 |
case COLUMN_INETCIDRROUTETYPE: |
| 1937 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTETYPE_FLAG; |
| 1938 |
rc = inetCidrRouteType_set(rowreq_ctx, |
| 1939 |
*((u_long *) var->val.string)); |
| 1940 |
break; |
| 1941 |
|
| 1942 |
/* |
| 1943 |
* inetCidrRouteNextHopAS(11)/InetAutonomousSystemNumber/ASN_UNSIGNED/u_long(u_long)//l/A/W/e/r/D/H |
| 1944 |
*/ |
| 1945 |
case COLUMN_INETCIDRROUTENEXTHOPAS: |
| 1946 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTENEXTHOPAS_FLAG; |
| 1947 |
rc = inetCidrRouteNextHopAS_set(rowreq_ctx, |
| 1948 |
*((u_long *) var->val.string)); |
| 1949 |
break; |
| 1950 |
|
| 1951 |
/* |
| 1952 |
* inetCidrRouteMetric1(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1953 |
*/ |
| 1954 |
case COLUMN_INETCIDRROUTEMETRIC1: |
| 1955 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC1_FLAG; |
| 1956 |
rc = inetCidrRouteMetric1_set(rowreq_ctx, |
| 1957 |
*((long *) var->val.string)); |
| 1958 |
break; |
| 1959 |
|
| 1960 |
/* |
| 1961 |
* inetCidrRouteMetric2(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1962 |
*/ |
| 1963 |
case COLUMN_INETCIDRROUTEMETRIC2: |
| 1964 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC2_FLAG; |
| 1965 |
rc = inetCidrRouteMetric2_set(rowreq_ctx, |
| 1966 |
*((long *) var->val.string)); |
| 1967 |
break; |
| 1968 |
|
| 1969 |
/* |
| 1970 |
* inetCidrRouteMetric3(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1971 |
*/ |
| 1972 |
case COLUMN_INETCIDRROUTEMETRIC3: |
| 1973 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC3_FLAG; |
| 1974 |
rc = inetCidrRouteMetric3_set(rowreq_ctx, |
| 1975 |
*((long *) var->val.string)); |
| 1976 |
break; |
| 1977 |
|
| 1978 |
/* |
| 1979 |
* inetCidrRouteMetric4(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1980 |
*/ |
| 1981 |
case COLUMN_INETCIDRROUTEMETRIC4: |
| 1982 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC4_FLAG; |
| 1983 |
rc = inetCidrRouteMetric4_set(rowreq_ctx, |
| 1984 |
*((long *) var->val.string)); |
| 1985 |
break; |
| 1986 |
|
| 1987 |
/* |
| 1988 |
* inetCidrRouteMetric5(16)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h |
| 1989 |
*/ |
| 1990 |
case COLUMN_INETCIDRROUTEMETRIC5: |
| 1991 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTEMETRIC5_FLAG; |
| 1992 |
rc = inetCidrRouteMetric5_set(rowreq_ctx, |
| 1993 |
*((long *) var->val.string)); |
| 1994 |
break; |
| 1995 |
|
| 1996 |
/* |
| 1997 |
* inetCidrRouteStatus(17)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h |
| 1998 |
*/ |
| 1999 |
case COLUMN_INETCIDRROUTESTATUS: |
| 2000 |
rowreq_ctx->column_set_flags |= COLUMN_INETCIDRROUTESTATUS_FLAG; |
| 2001 |
rc = inetCidrRouteStatus_set(rowreq_ctx, |
| 2002 |
*((u_long *) var->val.string)); |
| 2003 |
break; |
| 2004 |
|
| 2005 |
default: |
| 2006 |
snmp_log(LOG_ERR, |
| 2007 |
"unknown column %d in _inetCidrRouteTable_set_column\n", |
| 2008 |
column); |
| 2009 |
rc = SNMP_ERR_GENERR; |
| 2010 |
break; |
| 2011 |
} |
| 2012 |
|
| 2013 |
return rc; |
| 2014 |
} /* _inetCidrRouteTable_set_column */ |
| 2015 |
|
| 2016 |
int |
| 2017 |
_mfd_inetCidrRouteTable_set_values(netsnmp_mib_handler *handler, |
| 2018 |
netsnmp_handler_registration *reginfo, |
| 2019 |
netsnmp_agent_request_info *agtreq_info, |
| 2020 |
netsnmp_request_info *requests) |
| 2021 |
{ |
| 2022 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 2023 |
netsnmp_container_table_row_extract(requests); |
| 2024 |
netsnmp_table_request_info *tri; |
| 2025 |
int rc = SNMP_ERR_NOERROR; |
| 2026 |
|
| 2027 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_set_values", "called\n")); |
| 2028 |
|
| 2029 |
netsnmp_assert(NULL != rowreq_ctx); |
| 2030 |
|
| 2031 |
rowreq_ctx->column_set_flags = 0; |
| 2032 |
for (; requests; requests = requests->next) { |
| 2033 |
/* |
| 2034 |
* set column data |
| 2035 |
*/ |
| 2036 |
tri = netsnmp_extract_table_info(requests); |
| 2037 |
if (NULL == tri) |
| 2038 |
continue; |
| 2039 |
|
| 2040 |
rc = _inetCidrRouteTable_set_column(rowreq_ctx, |
| 2041 |
requests->requestvb, |
| 2042 |
tri->colnum); |
| 2043 |
if (MFD_SUCCESS != rc) { |
| 2044 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 2045 |
"inetCidrRouteTable_set_column\n", rc)); |
| 2046 |
netsnmp_set_request_error(agtreq_info, requests, |
| 2047 |
SNMP_VALIDATE_ERR(rc)); |
| 2048 |
} |
| 2049 |
} /* for results */ |
| 2050 |
|
| 2051 |
return SNMP_ERR_NOERROR; |
| 2052 |
} /* _mfd_inetCidrRouteTable_set_values */ |
| 2053 |
|
| 2054 |
/*---------------------------------------------------------------------- |
| 2055 |
* |
| 2056 |
* SET: commit |
| 2057 |
* |
| 2058 |
*---------------------------------------------------------------------*/ |
| 2059 |
/** |
| 2060 |
* @internal |
| 2061 |
* commit the values |
| 2062 |
*/ |
| 2063 |
int |
| 2064 |
_mfd_inetCidrRouteTable_commit(netsnmp_mib_handler *handler, |
| 2065 |
netsnmp_handler_registration *reginfo, |
| 2066 |
netsnmp_agent_request_info *agtreq_info, |
| 2067 |
netsnmp_request_info *requests) |
| 2068 |
{ |
| 2069 |
int rc; |
| 2070 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 2071 |
netsnmp_container_table_row_extract(requests); |
| 2072 |
|
| 2073 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_commit", "called\n")); |
| 2074 |
|
| 2075 |
netsnmp_assert(NULL != rowreq_ctx); |
| 2076 |
|
| 2077 |
rc = inetCidrRouteTable_commit(rowreq_ctx); |
| 2078 |
if (MFD_SUCCESS != rc) { |
| 2079 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 2080 |
"inetCidrRouteTable_commit\n", rc)); |
| 2081 |
netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); |
| 2082 |
} |
| 2083 |
|
| 2084 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 2085 |
/* |
| 2086 |
* if we successfully committed this row, set the dirty flag. Use the |
| 2087 |
* current value + 1 (i.e. dirty = # rows changed). |
| 2088 |
* this is checked in post_request... |
| 2089 |
*/ |
| 2090 |
inetCidrRouteTable_dirty_set(inetCidrRouteTable_dirty_get() + 1); /* set table dirty flag */ |
| 2091 |
} |
| 2092 |
|
| 2093 |
return SNMP_ERR_NOERROR; |
| 2094 |
} |
| 2095 |
|
| 2096 |
int |
| 2097 |
_mfd_inetCidrRouteTable_undo_commit(netsnmp_mib_handler *handler, |
| 2098 |
netsnmp_handler_registration *reginfo, |
| 2099 |
netsnmp_agent_request_info |
| 2100 |
*agtreq_info, |
| 2101 |
netsnmp_request_info *requests) |
| 2102 |
{ |
| 2103 |
int rc; |
| 2104 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 2105 |
netsnmp_container_table_row_extract(requests); |
| 2106 |
|
| 2107 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_commit", "called\n")); |
| 2108 |
|
| 2109 |
netsnmp_assert(NULL != rowreq_ctx); |
| 2110 |
|
| 2111 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 2112 |
u_int d = inetCidrRouteTable_dirty_get(); |
| 2113 |
|
| 2114 |
netsnmp_assert(d != 0); |
| 2115 |
if (d) |
| 2116 |
inetCidrRouteTable_dirty_set(d - 1); |
| 2117 |
} |
| 2118 |
|
| 2119 |
rc = inetCidrRouteTable_undo_commit(rowreq_ctx); |
| 2120 |
if (MFD_SUCCESS != rc) { |
| 2121 |
/* |
| 2122 |
* nothing we can do about it but log it |
| 2123 |
*/ |
| 2124 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 2125 |
"inetCidrRouteTable_undo_commit\n", rc)); |
| 2126 |
} |
| 2127 |
|
| 2128 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { |
| 2129 |
snmp_log(LOG_WARNING, |
| 2130 |
"inetCidrRouteTable row dirty flag still set after undo_commit\n"); |
| 2131 |
rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; |
| 2132 |
} |
| 2133 |
|
| 2134 |
return SNMP_ERR_NOERROR; |
| 2135 |
} /* _mfd_inetCidrRouteTable_commit */ |
| 2136 |
|
| 2137 |
/*---------------------------------------------------------------------- |
| 2138 |
* |
| 2139 |
* SET: Undo |
| 2140 |
* |
| 2141 |
*---------------------------------------------------------------------*/ |
| 2142 |
int |
| 2143 |
_mfd_inetCidrRouteTable_undo_values(netsnmp_mib_handler *handler, |
| 2144 |
netsnmp_handler_registration *reginfo, |
| 2145 |
netsnmp_agent_request_info |
| 2146 |
*agtreq_info, |
| 2147 |
netsnmp_request_info *requests) |
| 2148 |
{ |
| 2149 |
int rc; |
| 2150 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 2151 |
netsnmp_container_table_row_extract(requests); |
| 2152 |
|
| 2153 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_undo_values", "called\n")); |
| 2154 |
|
| 2155 |
netsnmp_assert(NULL != rowreq_ctx); |
| 2156 |
|
| 2157 |
rc = inetCidrRouteTable_undo(rowreq_ctx); |
| 2158 |
if (MFD_SUCCESS != rc) { |
| 2159 |
/* |
| 2160 |
* nothing we can do about it but log it |
| 2161 |
*/ |
| 2162 |
DEBUGMSGTL(("inetCidrRouteTable:mfd", "error %d from " |
| 2163 |
"inetCidrRouteTable_undo\n", rc)); |
| 2164 |
} |
| 2165 |
|
| 2166 |
return SNMP_ERR_NOERROR; |
| 2167 |
} /* _mfd_inetCidrRouteTable_undo_values */ |
| 2168 |
|
| 2169 |
/*---------------------------------------------------------------------- |
| 2170 |
* |
| 2171 |
* SET: irreversible commit |
| 2172 |
* |
| 2173 |
*---------------------------------------------------------------------*/ |
| 2174 |
/** |
| 2175 |
* @internal |
| 2176 |
* commit irreversible actions |
| 2177 |
*/ |
| 2178 |
int |
| 2179 |
_mfd_inetCidrRouteTable_irreversible_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration |
| 2180 |
*reginfo, netsnmp_agent_request_info |
| 2181 |
*agtreq_info, |
| 2182 |
netsnmp_request_info *requests) |
| 2183 |
{ |
| 2184 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 2185 |
netsnmp_container_table_row_extract(requests); |
| 2186 |
|
| 2187 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_mfd_inetCidrRouteTable_irreversible:commit", "called\n")); |
| 2188 |
|
| 2189 |
netsnmp_assert(NULL != rowreq_ctx); |
| 2190 |
|
| 2191 |
/* |
| 2192 |
* check for and handle row creation/deletion |
| 2193 |
* and update column exist flags... |
| 2194 |
*/ |
| 2195 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) { |
| 2196 |
if (!(rowreq_ctx->rowreq_flags & MFD_ROW_CREATED)) |
| 2197 |
CONTAINER_REMOVE(inetCidrRouteTable_if_ctx.container, rowreq_ctx); |
| 2198 |
} else { |
| 2199 |
if (rowreq_ctx->column_set_flags) { |
| 2200 |
rowreq_ctx->column_set_flags = 0; |
| 2201 |
} |
| 2202 |
if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) { |
| 2203 |
rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED; |
| 2204 |
CONTAINER_INSERT(inetCidrRouteTable_if_ctx.container, |
| 2205 |
rowreq_ctx); |
| 2206 |
} |
| 2207 |
} |
| 2208 |
|
| 2209 |
return SNMP_ERR_NOERROR; |
| 2210 |
} /* _mfd_inetCidrRouteTable_irreversible_commit */ |
| 2211 |
#endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */ |
| 2212 |
|
| 2213 |
/*********************************************************************** |
| 2214 |
* |
| 2215 |
* DATA ACCESS |
| 2216 |
* |
| 2217 |
***********************************************************************/ |
| 2218 |
static void _container_free(netsnmp_container *container); |
| 2219 |
|
| 2220 |
/** |
| 2221 |
* @internal |
| 2222 |
*/ |
| 2223 |
static int |
| 2224 |
_cache_load(netsnmp_cache * cache, void *vmagic) |
| 2225 |
{ |
| 2226 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_cache_load", "called\n")); |
| 2227 |
|
| 2228 |
if ((NULL == cache) || (NULL == cache->magic)) { |
| 2229 |
snmp_log(LOG_ERR, |
| 2230 |
"invalid cache for inetCidrRouteTable_cache_load\n"); |
| 2231 |
return -1; |
| 2232 |
} |
| 2233 |
|
| 2234 |
/** should only be called for an invalid or expired cache */ |
| 2235 |
netsnmp_assert((0 == cache->valid) || (1 == cache->expired)); |
| 2236 |
|
| 2237 |
/* |
| 2238 |
* call user code |
| 2239 |
*/ |
| 2240 |
return inetCidrRouteTable_container_load((netsnmp_container *) cache-> |
| 2241 |
magic); |
| 2242 |
} /* _cache_load */ |
| 2243 |
|
| 2244 |
/** |
| 2245 |
* @internal |
| 2246 |
*/ |
| 2247 |
static void |
| 2248 |
_cache_free(netsnmp_cache * cache, void *magic) |
| 2249 |
{ |
| 2250 |
netsnmp_container *container; |
| 2251 |
|
| 2252 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_cache_free", "called\n")); |
| 2253 |
|
| 2254 |
if ((NULL == cache) || (NULL == cache->magic)) { |
| 2255 |
snmp_log(LOG_ERR, |
| 2256 |
"invalid cache in inetCidrRouteTable_cache_free\n"); |
| 2257 |
return; |
| 2258 |
} |
| 2259 |
|
| 2260 |
container = (netsnmp_container *) cache->magic; |
| 2261 |
|
| 2262 |
_container_free(container); |
| 2263 |
} /* _cache_free */ |
| 2264 |
|
| 2265 |
/** |
| 2266 |
* @internal |
| 2267 |
*/ |
| 2268 |
static void |
| 2269 |
_container_item_free(void *rowreq_ctx, void *context) |
| 2270 |
{ |
| 2271 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_container_item_free", |
| 2272 |
"called\n")); |
| 2273 |
|
| 2274 |
if (NULL == rowreq_ctx) |
| 2275 |
return; |
| 2276 |
|
| 2277 |
inetCidrRouteTable_release_rowreq_ctx(rowreq_ctx); |
| 2278 |
} /* _container_item_free */ |
| 2279 |
|
| 2280 |
/** |
| 2281 |
* @internal |
| 2282 |
*/ |
| 2283 |
static void |
| 2284 |
_container_free(netsnmp_container *container) |
| 2285 |
{ |
| 2286 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_container_free", |
| 2287 |
"called\n")); |
| 2288 |
|
| 2289 |
if (NULL == container) { |
| 2290 |
snmp_log(LOG_ERR, |
| 2291 |
"invalid container in inetCidrRouteTable_container_free\n"); |
| 2292 |
return; |
| 2293 |
} |
| 2294 |
|
| 2295 |
/* |
| 2296 |
* call user code |
| 2297 |
*/ |
| 2298 |
inetCidrRouteTable_container_free(container); |
| 2299 |
|
| 2300 |
/* |
| 2301 |
* free all items. inefficient, but easy. |
| 2302 |
*/ |
| 2303 |
CONTAINER_CLEAR(container, _container_item_free, NULL); |
| 2304 |
} /* _container_free */ |
| 2305 |
|
| 2306 |
/** |
| 2307 |
* @internal |
| 2308 |
* initialize the container with functions or wrappers |
| 2309 |
*/ |
| 2310 |
void |
| 2311 |
_inetCidrRouteTable_container_init(inetCidrRouteTable_interface_ctx * |
| 2312 |
if_ctx) |
| 2313 |
{ |
| 2314 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_container_init", "called\n")); |
| 2315 |
|
| 2316 |
/* |
| 2317 |
* cache init |
| 2318 |
*/ |
| 2319 |
if_ctx->cache = netsnmp_cache_create(INETCIDRROUTETABLE_CACHE_TIMEOUT, |
| 2320 |
_cache_load, _cache_free, |
| 2321 |
inetCidrRouteTable_oid, |
| 2322 |
inetCidrRouteTable_oid_size); |
| 2323 |
|
| 2324 |
if (NULL == if_ctx->cache) { |
| 2325 |
snmp_log(LOG_ERR, "error creating cache for ipCidrRouteTable\n"); |
| 2326 |
return; |
| 2327 |
} |
| 2328 |
|
| 2329 |
if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET; |
| 2330 |
|
| 2331 |
inetCidrRouteTable_container_init(&if_ctx->container, if_ctx->cache); |
| 2332 |
if (NULL == if_ctx->container) { |
| 2333 |
if_ctx->container = |
| 2334 |
netsnmp_container_find("inetCidrRouteTable:table_container"); |
| 2335 |
if (NULL == if_ctx->container) { |
| 2336 |
snmp_log(LOG_ERR, "error creating container in " |
| 2337 |
"inetCidrRouteTable_container_init\n"); |
| 2338 |
return; |
| 2339 |
} |
| 2340 |
} |
| 2341 |
|
| 2342 |
if_ctx->container->container_name = strdup("inetCidrRouteTable"); |
| 2343 |
|
| 2344 |
/* set allow duplicates this makes insert O(1) */ |
| 2345 |
netsnmp_binary_array_options_set(if_ctx->container, 1, |
| 2346 |
CONTAINER_KEY_ALLOW_DUPLICATES); |
| 2347 |
|
| 2348 |
if (NULL != if_ctx->cache) |
| 2349 |
if_ctx->cache->magic = (void *) if_ctx->container; |
| 2350 |
} /* _inetCidrRouteTable_container_init */ |
| 2351 |
|
| 2352 |
/** |
| 2353 |
* @internal |
| 2354 |
* shutdown the container with functions or wrappers |
| 2355 |
*/ |
| 2356 |
void |
| 2357 |
_inetCidrRouteTable_container_shutdown(inetCidrRouteTable_interface_ctx * |
| 2358 |
if_ctx) |
| 2359 |
{ |
| 2360 |
DEBUGMSGTL(("internal:inetCidrRouteTable:_inetCidrRouteTable_container_shutdown", "called\n")); |
| 2361 |
|
| 2362 |
inetCidrRouteTable_container_shutdown(if_ctx->container); |
| 2363 |
|
| 2364 |
_container_free(if_ctx->container); |
| 2365 |
|
| 2366 |
} /* _inetCidrRouteTable_container_shutdown */ |
| 2367 |
|
| 2368 |
|
| 2369 |
#ifndef NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_EXTERNAL_ACCESS |
| 2370 |
inetCidrRouteTable_rowreq_ctx * |
| 2371 |
inetCidrRouteTable_row_find_by_mib_index(inetCidrRouteTable_mib_index * |
| 2372 |
mib_idx) |
| 2373 |
{ |
| 2374 |
inetCidrRouteTable_rowreq_ctx *rowreq_ctx; |
| 2375 |
oid oid_tmp[MAX_OID_LEN]; |
| 2376 |
netsnmp_index oid_idx; |
| 2377 |
int rc; |
| 2378 |
|
| 2379 |
/* |
| 2380 |
* set up storage for OID |
| 2381 |
*/ |
| 2382 |
oid_idx.oids = oid_tmp; |
| 2383 |
oid_idx.len = sizeof(oid_tmp) / sizeof(oid); |
| 2384 |
|
| 2385 |
/* |
| 2386 |
* convert |
| 2387 |
*/ |
| 2388 |
rc = inetCidrRouteTable_index_to_oid(&oid_idx, mib_idx); |
| 2389 |
if (MFD_SUCCESS != rc) |
| 2390 |
return NULL; |
| 2391 |
|
| 2392 |
rowreq_ctx = (inetCidrRouteTable_rowreq_ctx*) |
| 2393 |
CONTAINER_FIND(inetCidrRouteTable_if_ctx.container, &oid_idx); |
| 2394 |
|
| 2395 |
return rowreq_ctx; |
| 2396 |
} |
| 2397 |
#endif /* NETSNMP_FEATURE_REMOVE_INETCIDRROUTETABLE_EXTERNAL_ACCESS */ |