📄 snmpnotifyfiltertable_interface.c
字号:
_snmpNotifyFilterTable_shutdown_interface (snmpNotifyFilterTable_registration * reg_ptr) { /* * shutdown the container */ _snmpNotifyFilterTable_container_shutdown (&snmpNotifyFilterTable_if_ctx);}voidsnmpNotifyFilterTable_valid_columns_set(netsnmp_column_info *vc){ snmpNotifyFilterTable_if_ctx.tbl_info.valid_columns = vc;} /* snmpNotifyFilterTable_valid_columns_set *//** * @internal * convert the index component stored in the context to an oid */intsnmpNotifyFilterTable_index_to_oid(netsnmp_index * oid_idx, snmpNotifyFilterTable_mib_index * mib_idx){ int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * snmpNotifyFilterProfileName(1)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ netsnmp_variable_list var_snmpNotifyFilterProfileName; /* * snmpNotifyFilterSubtree(1)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h */ netsnmp_variable_list var_snmpNotifyFilterSubtree; /* * set up varbinds */ memset(&var_snmpNotifyFilterProfileName, 0x00, sizeof(var_snmpNotifyFilterProfileName)); var_snmpNotifyFilterProfileName.type = ASN_OCTET_STR; memset(&var_snmpNotifyFilterSubtree, 0x00, sizeof(var_snmpNotifyFilterSubtree)); var_snmpNotifyFilterSubtree.type = ASN_PRIV_IMPLIED_OBJECT_ID; /* * chain temp index varbinds together */ var_snmpNotifyFilterProfileName.next_variable = &var_snmpNotifyFilterSubtree; var_snmpNotifyFilterSubtree.next_variable = NULL; DEBUGMSGTL(("verbose:snmpNotifyFilterTable:snmpNotifyFilterTable_index_to_oid", "called\n")); /* * snmpNotifyFilterProfileName(1)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ snmp_set_var_value(&var_snmpNotifyFilterProfileName, (u_char *) & mib_idx->snmpNotifyFilterProfileName, mib_idx->snmpNotifyFilterProfileName_len * sizeof(mib_idx->snmpNotifyFilterProfileName[0])); /* * snmpNotifyFilterSubtree(1)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h */ snmp_set_var_value(&var_snmpNotifyFilterSubtree, (u_char *) & mib_idx->snmpNotifyFilterSubtree, mib_idx->snmpNotifyFilterSubtree_len * sizeof(mib_idx->snmpNotifyFilterSubtree[0])); err = build_oid_noalloc(oid_idx->oids, oid_idx->len, &oid_idx->len, NULL, 0, &var_snmpNotifyFilterProfileName); if (err) snmp_log(LOG_ERR, "error %d converting index to oid\n", err); /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_snmpNotifyFilterProfileName); return err;} /* snmpNotifyFilterTable_index_to_oid *//** * extract snmpNotifyFilterTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */intsnmpNotifyFilterTable_index_from_oid(netsnmp_index * oid_idx, snmpNotifyFilterTable_mib_index * mib_idx){ int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * snmpNotifyFilterProfileName(1)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/A/W/e/R/d/H */ netsnmp_variable_list var_snmpNotifyFilterProfileName; /* * snmpNotifyFilterSubtree(1)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/a/w/e/r/d/h */ netsnmp_variable_list var_snmpNotifyFilterSubtree; /* * set up varbinds */ memset(&var_snmpNotifyFilterProfileName, 0x00, sizeof(var_snmpNotifyFilterProfileName)); var_snmpNotifyFilterProfileName.type = ASN_OCTET_STR; memset(&var_snmpNotifyFilterSubtree, 0x00, sizeof(var_snmpNotifyFilterSubtree)); var_snmpNotifyFilterSubtree.type = ASN_PRIV_IMPLIED_OBJECT_ID; /* * chain temp index varbinds together */ var_snmpNotifyFilterProfileName.next_variable = &var_snmpNotifyFilterSubtree; var_snmpNotifyFilterSubtree.next_variable = NULL; DEBUGMSGTL(("verbose:snmpNotifyFilterTable:snmpNotifyFilterTable_index_from_oid", "called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_snmpNotifyFilterProfileName); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ /* * NOTE: val_len is in bytes, snmpNotifyFilterProfileName_len might not be */ if (var_snmpNotifyFilterProfileName.val_len > sizeof(mib_idx->snmpNotifyFilterProfileName)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->snmpNotifyFilterProfileName, var_snmpNotifyFilterProfileName.val.string, var_snmpNotifyFilterProfileName.val_len); mib_idx->snmpNotifyFilterProfileName_len = var_snmpNotifyFilterProfileName.val_len / sizeof(mib_idx->snmpNotifyFilterProfileName[0]); } /* * NOTE: val_len is in bytes, snmpNotifyFilterSubtree_len might not be */ if (var_snmpNotifyFilterSubtree.val_len > sizeof(mib_idx->snmpNotifyFilterSubtree)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->snmpNotifyFilterSubtree, var_snmpNotifyFilterSubtree.val.string, var_snmpNotifyFilterSubtree.val_len); mib_idx->snmpNotifyFilterSubtree_len = var_snmpNotifyFilterSubtree.val_len / sizeof(mib_idx->snmpNotifyFilterSubtree[0]); } } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_snmpNotifyFilterProfileName); return err;} /* snmpNotifyFilterTable_index_from_oid *//* * snmpNotifyFilterTable_allocate_data * * Purpose: create new snmpNotifyFilterTable_data. */snmpNotifyFilterTable_data *snmpNotifyFilterTable_allocate_data(void){ snmpNotifyFilterTable_data *rtn = SNMP_MALLOC_TYPEDEF(snmpNotifyFilterTable_data); DEBUGMSGTL(("verbose:snmpNotifyFilterTable:snmpNotifyFilterTable_allocate_data", "called\n")); if (NULL == rtn) { snmp_log(LOG_ERR, "unable to malloc memory for new " "snmpNotifyFilterTable_data.\n"); } return rtn;} /* snmpNotifyFilterTable_allocate_data *//* * snmpNotifyFilterTable_release_data * * Purpose: release snmpNotifyFilterTable data. */voidsnmpNotifyFilterTable_release_data(snmpNotifyFilterTable_data * data){ DEBUGMSGTL(("verbose:snmpNotifyFilterTable:snmpNotifyFilterTable_release_data", "called\n")); free(data);} /* snmpNotifyFilterTable_release_data *//* ********************************************************************* * @internal * allocate resources for a snmpNotifyFilterTable_rowreq_ctx */snmpNotifyFilterTable_rowreq_ctx *snmpNotifyFilterTable_allocate_rowreq_ctx(void *user_init_ctx){ snmpNotifyFilterTable_rowreq_ctx *rowreq_ctx = SNMP_MALLOC_TYPEDEF(snmpNotifyFilterTable_rowreq_ctx); DEBUGMSGTL(("internal:snmpNotifyFilterTable:snmpNotifyFilterTable_allocate_rowreq_ctx", "called\n")); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "Couldn't allocate memory for a " "snmpNotifyFilterTable_rowreq_ctx.\n"); return NULL; } rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp; rowreq_ctx->snmpNotifyFilterTable_data_list = NULL; /* * if we allocated data, call init routine */ if (!(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER)) { if (SNMPERR_SUCCESS != snmpNotifyFilterTable_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) { snmpNotifyFilterTable_release_rowreq_ctx(rowreq_ctx); rowreq_ctx = NULL; } } return rowreq_ctx;} /* snmpNotifyFilterTable_allocate_rowreq_ctx *//* * @internal * release resources for a snmpNotifyFilterTable_rowreq_ctx */voidsnmpNotifyFilterTable_release_rowreq_ctx(snmpNotifyFilterTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("internal:snmpNotifyFilterTable:snmpNotifyFilterTable_release_rowreq_ctx", "called\n")); netsnmp_assert(NULL != rowreq_ctx); snmpNotifyFilterTable_rowreq_ctx_cleanup(rowreq_ctx); if (rowreq_ctx->undo) snmpNotifyFilterTable_release_data(rowreq_ctx->undo); /* * free index oid pointer */ if (rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp) free(rowreq_ctx->oid_idx.oids); SNMP_FREE(rowreq_ctx);} /* snmpNotifyFilterTable_release_rowreq_ctx *//** * @internal * wrapper */static int_mfd_snmpNotifyFilterTable_pre_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ int rc; DEBUGMSGTL(("internal:snmpNotifyFilterTable:_mfd_snmpNotifyFilterTable_pre_request", "called\n")); if (1 != netsnmp_row_merge_status_first(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:snmpNotifyFilterTable", "skipping additional pre_request\n")); return SNMP_ERR_NOERROR; } rc = snmpNotifyFilterTable_pre_request(snmpNotifyFilterTable_if_ctx. user_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("snmpNotifyFilterTable", "error %d from " "snmpNotifyFilterTable_pre_request\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } return SNMP_ERR_NOERROR;} /* _mfd_snmpNotifyFilterTable_pre_request *//** * @internal * wrapper */static int_mfd_snmpNotifyFilterTable_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests){ snmpNotifyFilterTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc, packet_rc; DEBUGMSGTL(("internal:snmpNotifyFilterTable:_mfd_snmpNotifyFilterTable_post_request", "called\n")); /* * release row context, if deleted */ if (rowreq_ctx && (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED)) snmpNotifyFilterTable_release_rowreq_ctx(rowreq_ctx); /* * wait for last call before calling user */ if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:snmpNotifyFilterTable", "waiting for last post_request\n")); return SNMP_ERR_NOERROR; } packet_rc = netsnmp_check_all_requests_error(agtreq_info->asp, 0); if ((MFD_SUCCESS != packet_rc) && snmpNotifyFilterTable_dirty_get()) { /* * we shouldn't get here. the undo steps should also clear * the dirty flags. */ snmp_log(LOG_WARNING, "snmpNotifyFilterTable dirty flag set in post_request " "but status != SUCCESS.\n"); } rc = snmpNotifyFilterTable_post_request(snmpNotifyFilterTable_if_ctx. user_ctx, packet_rc); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("snmpNotifyFilterTable", "error %d from " "snmpNotifyFilterTable_post_request\n", rc)); } return SNMP_ERR_NOERROR;} /* _mfd_snmpNotifyFilterTable_post_request *//** * @internal * wrapper */static snmpNotifyFilterTable_rowreq_ctx *_mfd_snmpNotifyFilterTable_rowreq_from_index(netsnmp_index * oid_idx, int *rc_ptr){ snmpNotifyFilterTable_rowreq_ctx *rowreq_ctx; snmpNotifyFilterTable_mib_index mib_idx; int rc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -