📄 ipcidrroutetable.c
字号:
* | | | S U |<--------+ * | | +--------------+ +==============+ * | | | irreversible | || undo || * | | | commit | || set || * | | +--------------+ +==============+ * | | | U U | * | +-------------->|<------------------------+ * | +==============+ * | || undo || * | || cleanup || * | +==============+ * +---------------------->| U * | * (err && f1)------------------->+ * | | * +--------------+ +--------------+ * | post |<--------| row | * | request | U | release | * +--------------+ +--------------+ * *//** * Setup up context with information needed to undo a set request. * * This function will be called before the individual node undo setup * functions are called. If you need to do any undo setup that is not * related to a specific column, you can do it here. * * Note that the undo context has been allocated with * ipCidrRouteTable_allocate_data(), but may need extra * initialization similar to what you may have done in * ipCidrRouteTable_rowreq_ctx_init(). * Note that an individual node's undo_setup function will only be called * if that node is being set to a new value. * * If there is any setup specific to a particular column (e.g. allocating * memory for a string), you should do that setup in the node's undo_setup * function, so it won't be done unless it is necessary. * * @param rowreq_ctx * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. */intipCidrRouteTable_undo_setup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_undo_setup", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:451:M: |-> Setup ipCidrRouteTable undo. * set up ipCidrRouteTable undo information, in preparation for a set. * Undo storage is in (* ipCidrRouteStatus_val_ptr )* */ return rc;} /* ipCidrRouteTable_undo_setup *//** * Undo a set request. * * This function will be called before the individual node undo * functions are called. If you need to do any undo that is not * related to a specific column, you can do it here. * * Note that an individual node's undo function will only be called * if that node is being set to a new value. * * If there is anything specific to a particular column (e.g. releasing * memory for a string), you should do that setup in the node's undo * function, so it won't be done unless it is necessary. * * @param rowreq_ctx * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. */intipCidrRouteTable_undo(ipCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_undo", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:451:M: |-> ipCidrRouteTable undo. * ipCidrRouteTable undo information, in response to a failed set. * Undo storage is in (* ipCidrRouteStatus_val_ptr )* */ return rc;} /* ipCidrRouteTable_undo_setup *//** * Cleanup up context undo information. * * This function will be called after set/commit processing. If you * allocated any resources in undo_setup, this is the place to release * those resources. * * This function is called regardless of the success or failure of the set * request. If you need to perform different steps for cleanup depending * on success or failure, you can add a flag to the rowreq_ctx. * * @param rowreq_ctx * Pointer to the table context (ipCidrRouteTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */intipCidrRouteTable_undo_cleanup(ipCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_undo_cleanup", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:452:M: |-> Cleanup ipCidrRouteTable undo. * Undo storage is in (* ipCidrRouteStatus_val_ptr )* */ return rc;} /* ipCidrRouteTable_undo_cleanup *//** * commit new values. * * At this point, you should have done everything you can to ensure that * this commit will not fail. * * Should you need different behavior depending on which columns were * set, rowreq_ctx->column_set_flags will indicate which writeable columns were * set. The definitions for the COLUMN_*_FLAG bits can be found in * ipCidrRouteTable.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */intipCidrRouteTable_commit(ipCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; int save_flags; DEBUGMSGTL(("verbose:ipCidrRouteTable:ipCidrRouteTable_commit", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * save flags, then clear until we actually do something */ save_flags = rowreq_ctx->column_set_flags; rowreq_ctx->column_set_flags = 0; /* * commit ipCidrRouteTable data * 1) check the column's flag in save_flags to see if it was set. * 2) clear the flag when you handle that column * 3) set the column's flag in column_set_flags if it needs undo * processing in case of a failure. */ if (save_flags & COLUMN_IPCIDRROUTEIFINDEX_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTEIFINDEX_FLAG; /* clear ipCidrRouteIfIndex */ /* * TODO:482:o: |-> commit column ipCidrRouteIfIndex. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteIfIndex commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteIfIndex */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEIFINDEX_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTETYPE_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTETYPE_FLAG; /* clear ipCidrRouteType */ /* * TODO:482:o: |-> commit column ipCidrRouteType. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteType commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteType */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTETYPE_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTEINFO_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTEINFO_FLAG; /* clear ipCidrRouteInfo */ /* * TODO:482:o: |-> commit column ipCidrRouteInfo. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteInfo commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteInfo */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEINFO_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTENEXTHOPAS_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTENEXTHOPAS_FLAG; /* clear ipCidrRouteNextHopAS */ /* * TODO:482:o: |-> commit column ipCidrRouteNextHopAS. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteNextHopAS commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteNextHopAS */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTENEXTHOPAS_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTEMETRIC1_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTEMETRIC1_FLAG; /* clear ipCidrRouteMetric1 */ /* * TODO:482:o: |-> commit column ipCidrRouteMetric1. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteMetric1 commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteMetric1 */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC1_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTEMETRIC2_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTEMETRIC2_FLAG; /* clear ipCidrRouteMetric2 */ /* * TODO:482:o: |-> commit column ipCidrRouteMetric2. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteMetric2 commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteMetric2 */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC2_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTEMETRIC3_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTEMETRIC3_FLAG; /* clear ipCidrRouteMetric3 */ /* * TODO:482:o: |-> commit column ipCidrRouteMetric3. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteMetric3 commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteMetric3 */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC3_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTEMETRIC4_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTEMETRIC4_FLAG; /* clear ipCidrRouteMetric4 */ /* * TODO:482:o: |-> commit column ipCidrRouteMetric4. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteMetric4 commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteMetric4 */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC4_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTEMETRIC5_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTEMETRIC5_FLAG; /* clear ipCidrRouteMetric5 */ /* * TODO:482:o: |-> commit column ipCidrRouteMetric5. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteMetric5 commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteMetric5 */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTEMETRIC5_FLAG; } } if (save_flags & COLUMN_IPCIDRROUTESTATUS_FLAG) { save_flags &= ~COLUMN_IPCIDRROUTESTATUS_FLAG; /* clear ipCidrRouteStatus */ /* * TODO:482:o: |-> commit column ipCidrRouteStatus. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipCidrRouteTable column ipCidrRouteStatus commit failed\n"); } else { /* * set flag, in case we need to undo ipCidrRouteStatus */ rowreq_ctx->column_set_flags |= COLUMN_IPCIDRROUTESTATUS_FLAG; } } /* * if we successfully commited this row, set the dirty flag. */ if (MFD_SUCCESS == rc) { rowreq_ctx->rowreq_flags |= MFD_ROW_DIRTY; } if (save_flags) { snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags); return MFD_ERROR; } return rc;} /* ipCidrRouteTable_commit *//** * undo commit new values. * * Should you need different behavior depending on which columns were * set, rowreq_ctx->column_set_flags will indicate which writeable columns were * set. The definitions for the COLUMN_*_FLAG bits can be found in * ipCidrRouteTable.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */intipCidrRouteTable_undo_commit(ipCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -