/** * @internal * commit the values */ int _mfd_ipv4InterfaceTable_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_commit", "called\n")); netsnmp_assert(NULL != rowreq_ctx); rc = ipv4InterfaceTable_commit(rowreq_ctx); if (MFD_SUCCESS != rc) { DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " "ipv4InterfaceTable_commit\n", rc)); netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc)); } if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { /* * if we successfully commited this row, set the dirty flag. Use the * current value + 1 (i.e. dirty = # rows changed). * this is checked in post_request... */ ipv4InterfaceTable_dirty_set(ipv4InterfaceTable_dirty_get() + 1); /* set table dirty flag */ } return SNMP_ERR_NOERROR; }
/** * post-request callback * * Note: * New rows have been inserted into the container, and * deleted rows have been removed from the container and * released. * * @param user_context * @param rc : MFD_SUCCESS if all requests succeeded * * @retval MFD_SUCCESS : success. * @retval MFD_ERROR : other error (ignored) */ int ipv4InterfaceTable_post_request(ipv4InterfaceTable_registration * user_context, int rc) { DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_post_request", "called\n")); /* * TODO:511:o: Perform ipv4InterfaceTable post-request actions. */ /* * check to set if any rows were changed. */ if (ipv4InterfaceTable_dirty_get()) { /* * check if request was successful. If so, this would be * a good place to save data to its persistent store. */ if (MFD_SUCCESS == rc) { /* * save changed rows, if you haven't already */ } ipv4InterfaceTable_dirty_set(0); /* clear table dirty flag */ } return MFD_SUCCESS; } /* ipv4InterfaceTable_post_request */
/** * @internal * wrapper */ static int _mfd_ipv4InterfaceTable_post_request(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); int rc, packet_rc; DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_post_request", "called\n")); /* * wait for last call before calling user */ if (1 != netsnmp_row_merge_status_last(reginfo, agtreq_info)) { DEBUGMSGTL(("internal:ipv4InterfaceTable", "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) && ipv4InterfaceTable_dirty_get()) { /* * we shouldn't get here. the undo steps should also clear * the dirty flags. */ snmp_log(LOG_WARNING, "ipv4InterfaceTable dirty flag set in post_request " "but status != SUCCESS.\n"); } rc = ipv4InterfaceTable_post_request(ipv4InterfaceTable_if_ctx. user_ctx, packet_rc); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("ipv4InterfaceTable", "error %d from " "ipv4InterfaceTable_post_request\n", rc)); } return SNMP_ERR_NOERROR; } /* _mfd_ipv4InterfaceTable_post_request */
int _mfd_ipv4InterfaceTable_undo_commit(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *agtreq_info, netsnmp_request_info *requests) { int rc; ipv4InterfaceTable_rowreq_ctx *rowreq_ctx = netsnmp_container_table_row_extract(requests); DEBUGMSGTL(("internal:ipv4InterfaceTable:_mfd_ipv4InterfaceTable_undo_commit", "called\n")); netsnmp_assert(NULL != rowreq_ctx); if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { u_int d = ipv4InterfaceTable_dirty_get(); netsnmp_assert(d != 0); if (d) ipv4InterfaceTable_dirty_set(d - 1); } rc = ipv4InterfaceTable_undo_commit(rowreq_ctx); if (MFD_SUCCESS != rc) { /* * nothing we can do about it but log it */ DEBUGMSGTL(("ipv4InterfaceTable:mfd", "error %d from " "ipv4InterfaceTable_undo_commit\n", rc)); } if (rowreq_ctx->rowreq_flags & MFD_ROW_DIRTY) { snmp_log(LOG_WARNING, "ipv4InterfaceTable row dirty flag still set after undo_commit\n"); rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; } return SNMP_ERR_NOERROR; } /* _mfd_ipv4InterfaceTable_commit */