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