📄 inetcidrroutetable.c
字号:
* * All of the individual index validation functions have been called, so this * is the place to make sure they are valid as a whole when combined. If * you only have one index, * * * * @param inetCidrRouteTable_reg * Pointer to the user registration data * @param inetCidrRouteTable_rowreq_ctx * Pointer to the users context. * @retval MFD_SUCCESS : success * @retval MFD_CANNOT_CREATE_NOW : index not valid right now * @retval MFD_CANNOT_CREATE_EVER : index never valid */intinetCidrRouteTable_validate_index(inetCidrRouteTable_registration_ptr inetCidrRouteTable_reg, inetCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_validate_index", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:430:M: |-> Validate potential inetCidrRouteTable index. */ if (1) { snmp_log(LOG_WARNING, "invalid index for a new row in the " "inetCidrRouteTable table.\n"); /* * determine failure type. * * If the index could not ever be created, return MFD_NOT_EVER * If the index can not be created under the present circumstances * (even though it could be created under other circumstances), * return MFD_NOT_NOW. */ if (0) { return MFD_CANNOT_CREATE_EVER; } else { return MFD_CANNOT_CREATE_NOW; } } return rc;} /* inetCidrRouteTable_validate_index *//** * 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 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 (inetCidrRouteTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. */intinetCidrRouteTable_undo_setup(inetCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_undo_setup", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:451:M: |-> Setup inetCidrRouteTable undo. * set up inetCidrRouteTable undo information, in preparation for a set. */ return rc;} /* inetCidrRouteTable_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 (inetCidrRouteTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */intinetCidrRouteTable_undo_cleanup(inetCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_undo_cleanup", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:452:M: |-> Cleanup inetCidrRouteTable undo. */ return rc;} /* inetCidrRouteTable_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 FLAG_* bits can be found in * inetCidrRouteTable.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param inetCidrRouteTable_rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */intinetCidrRouteTable_commit(inetCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; int save_flags; DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_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 inetCidrRouteTable 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. */#warning inetCidrRouteTable commit if (save_flags & FLAG_INETCIDRROUTEIFINDEX) { save_flags &= ~FLAG_INETCIDRROUTEIFINDEX; /* clear inetCidrRouteIfIndex */ /* * TODO:482:o: |-> commit column inetCidrRouteIfIndex. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "inetCidrRouteTable column inetCidrRouteIfIndex commit failed\n"); } else { /* * set flag, in case we need to undo inetCidrRouteIfIndex */ rowreq_ctx->column_set_flags |= FLAG_INETCIDRROUTEIFINDEX; } } if (save_flags & FLAG_INETCIDRROUTETYPE) { save_flags &= ~FLAG_INETCIDRROUTETYPE; /* clear inetCidrRouteType */ /* * TODO:482:o: |-> commit column inetCidrRouteType. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "inetCidrRouteTable column inetCidrRouteType commit failed\n"); } else { /* * set flag, in case we need to undo inetCidrRouteType */ rowreq_ctx->column_set_flags |= FLAG_INETCIDRROUTETYPE; } } if (save_flags & FLAG_INETCIDRROUTENEXTHOPAS) { save_flags &= ~FLAG_INETCIDRROUTENEXTHOPAS; /* clear inetCidrRouteNextHopAS */ /* * TODO:482:o: |-> commit column inetCidrRouteNextHopAS. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "inetCidrRouteTable column inetCidrRouteNextHopAS commit failed\n"); } else { /* * set flag, in case we need to undo inetCidrRouteNextHopAS */ rowreq_ctx->column_set_flags |= FLAG_INETCIDRROUTENEXTHOPAS; } } if (save_flags & FLAG_INETCIDRROUTEMETRIC1) { save_flags &= ~FLAG_INETCIDRROUTEMETRIC1; /* clear inetCidrRouteMetric1 */ /* * TODO:482:o: |-> commit column inetCidrRouteMetric1. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "inetCidrRouteTable column inetCidrRouteMetric1 commit failed\n"); } else { /* * set flag, in case we need to undo inetCidrRouteMetric1 */ rowreq_ctx->column_set_flags |= FLAG_INETCIDRROUTEMETRIC1; } } if (save_flags & FLAG_INETCIDRROUTESTATUS) { save_flags &= ~FLAG_INETCIDRROUTESTATUS; /* clear inetCidrRouteStatus */ /* * TODO:482:o: |-> commit column inetCidrRouteStatus. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "inetCidrRouteTable column inetCidrRouteStatus commit failed\n"); } else { /* * set flag, in case we need to undo inetCidrRouteStatus */ rowreq_ctx->column_set_flags |= FLAG_INETCIDRROUTESTATUS; } } if (save_flags) { snmp_log(LOG_ERR, "unhandled columns (0x%x) in commit\n", save_flags); return MFD_ERROR; } return rc;} /* inetCidrRouteTable_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 FLAG_* bits can be found in * inetCidrRouteTable.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param inetCidrRouteTable_rowreq_ctx * Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */intinetCidrRouteTable_undo_commit(inetCidrRouteTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteTable_undo_commit", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:485:M: |-> Undo inetCidrRouteTable commit. * check the column's flag in rowreq_ctx->column_set_flags to see * if it was set during commit, then undo it. * * eg: if (rowreq_ctx->column_set_flags & FLAG_) {} */ return rc;} /* inetCidrRouteTable_undo_commit *//* * TODO:420:r: Implement inetCidrRouteTable index validation. *//*--------------------------------------------------------------------- * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteDestType * inetCidrRouteDestType is subid 1 of inetCidrRouteEntry. * Its status is Current, and its access level is NoAccess. * OID: .1.3.6.1.2.1.4.24.7.1.1 * Description:The type of the inetCidrRouteDest address, as defined in the InetAddress MIB. Only those address types that may appear in an actual routing table are allowed as values of this object. * * Attributes: * accessible 0 isscalar 0 enums 1 hasdefval 0 * readable 0 iscolumn 1 ranges 0 hashint 0 * settable 0 * * Enum range: 5/8. Values: unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16) * * Its syntax is InetAddressType (based on perltype INTEGER) * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) * * * * NOTE: NODE inetCidrRouteDestType IS NOT ACCESSIBLE * * *//** * check validity of inetCidrRouteDestType index portion * * @retval MFD_SUCCESS : the incoming value is legal * @retval MFD_BAD_VALUE : the incoming value is NOT legal * * @note this is not the place to do any checks for the sanity * of multiple indexes. Those types of checks should be done in the * inetCidrRouteTable_validate_index() function. */intinetCidrRouteDestType_check_index(inetCidrRouteTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:inetCidrRouteTable:inetCidrRouteDestType_check_index", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:426:M: |-> Check inetCidrRouteTable index inetCidrRouteDestType. * check that index value in the table context (rowreq_ctx) * for inetCidrRouteDestType is legal. */ return MFD_SUCCESS; /* inetCidrRouteDestType index ok */} /* inetCidrRouteDestType_check_index *//*--------------------------------------------------------------------- * IP-FORWARD-MIB::inetCidrRouteEntry.inetCidrRouteDest * inetCidrRouteDest is subid 2 of inetCidrRouteEntry. * Its status is Current, and its access level is NoAccess. * OID: .1.3.6.1.2.1.4.24.7.1.2 * Description:The destination IP address of this route. The type of this address is determined by the value of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -