📄 ipv4interfacetable.c
字号:
return rc;} /* ipv4InterfaceTable_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 * ipv4InterfaceTable.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 */intipv4InterfaceTable_commit(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; int save_flags; DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_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 ipv4InterfaceTable 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_IPV4INTERFACEENABLESTATUS_FLAG) { save_flags &= ~COLUMN_IPV4INTERFACEENABLESTATUS_FLAG; /* clear ipv4InterfaceEnableStatus */ /* * TODO:482:o: |-> commit column ipv4InterfaceEnableStatus. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "ipv4InterfaceTable column ipv4InterfaceEnableStatus commit failed\n"); } else { /* * set flag, in case we need to undo ipv4InterfaceEnableStatus */ rowreq_ctx->column_set_flags |= COLUMN_IPV4INTERFACEENABLESTATUS_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;} /* ipv4InterfaceTable_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 * ipv4InterfaceTable.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 */intipv4InterfaceTable_undo_commit(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceTable_undo_commit", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:485:M: |-> Undo ipv4InterfaceTable 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 & COLUMN__FLAG) {} */ /* * if we successfully un-commited this row, clear the dirty flag. */ if (MFD_SUCCESS == rc) { rowreq_ctx->rowreq_flags &= ~MFD_ROW_DIRTY; } return rc;} /* ipv4InterfaceTable_undo_commit *//* * TODO:440:M: Implement ipv4InterfaceTable node value checks. * TODO:450:M: Implement ipv4InterfaceTable undo functions. * TODO:460:M: Implement ipv4InterfaceTable set functions. * TODO:480:M: Implement ipv4InterfaceTable commit functions. *//*--------------------------------------------------------------------- * IP-MIB::ipv4InterfaceEntry.ipv4InterfaceEnableStatus * ipv4InterfaceEnableStatus is subid 3 of ipv4InterfaceEntry. * Its status is Current, and its access level is ReadWrite. * OID: .1.3.6.1.2.1.4.28.1.3 * Description:The indication of whether IPv4 is enabled (up) or disabled (down) on this interface. This object does not affect the state of the interface itself, only its connection to an IPv4 stack. The IF-MIB should be used to control the state of the interface. * * Attributes: * accessible 1 isscalar 0 enums 1 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 1 * * Enum range: 1/8. Values: up(1), down(2) * * Its syntax is INTEGER (based on perltype INTEGER) * The net-snmp type is ASN_INTEGER. The C type decl is long (u_long) *//** * Check that the proposed new value is potentially valid. * * @param rowreq_ctx * Pointer to the row request context. * @param ipv4InterfaceEnableStatus_val * A long containing the new value. * * @retval MFD_SUCCESS : incoming value is legal * @retval MFD_NOT_VALID_NOW : incoming value is not valid now * @retval MFD_NOT_VALID_EVER : incoming value is never valid * * This is the place to check for requirements that are not * expressed in the mib syntax (for example, a requirement that * is detailed in the description for an object). * * You should check that the requested change between the undo value and the * new value is legal (ie, the transistion from one value to another * is legal). * *@note * This check is only to determine if the new value * is \b potentially valid. This is the first check of many, and * is one of the simplest ones. * *@note * this is not the place to do any checks for values * which depend on some other value in the mib. Those * types of checks should be done in the * ipv4InterfaceTable_check_dependencies() function. * * The following checks have already been done for you: * The syntax is ASN_INTEGER * The value is one of up(1), down(2) * * If there a no other checks you need to do, simply return MFD_SUCCESS. * */intipv4InterfaceEnableStatus_check_value(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, u_long ipv4InterfaceEnableStatus_val){ DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_check_value", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:441:o: |-> Check for valid ipv4InterfaceEnableStatus value. */ /* * did the access code set the flag indicating that we can control * individual protocols on this interface? */ if (rowreq_ctx->data.ifentry->ns_flags & NETSNMP_INTERFACE_FLAGS_CAN_DOWN_PROTOCOL); else return MFD_NOT_VALID_EVER; return MFD_SUCCESS; /* ipv4InterfaceEnableStatus value not illegal */} /* ipv4InterfaceEnableStatus_check_value *//** * Save old value information * * @param rowreq_ctx * Pointer to the table context (ipv4InterfaceTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error. set will fail. * * This function will be called after the table level undo setup function * ipv4InterfaceTable_undo_setup has been called. * *@note * this function will only be called if a new value is set for this column. * * If there is any setup specific to a particular column (e.g. allocating * memory for a string), you should do that setup in this function, so it * won't be done unless it is necessary. */intipv4InterfaceEnableStatus_undo_setup(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_undo_setup", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:455:o: |-> Setup ipv4InterfaceEnableStatus undo. */ /* * copy ipv4InterfaceEnableStatus data * set rowreq_ctx->undo->ipv4InterfaceEnableStatus from rowreq_ctx->data.ipv4InterfaceEnableStatus */ rowreq_ctx->undo->ipv4InterfaceEnableStatus = rowreq_ctx->data.ipv4InterfaceEnableStatus; return MFD_SUCCESS;} /* ipv4InterfaceEnableStatus_undo_setup *//** * Set the new value. * * @param rowreq_ctx * Pointer to the users context. You should know how to * manipulate the value from this object. * @param ipv4InterfaceEnableStatus_val * A long containing the new value. */intipv4InterfaceEnableStatus_set(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx, u_long ipv4InterfaceEnableStatus_val){ DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_set", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:461:M: |-> Set ipv4InterfaceEnableStatus value. * set ipv4InterfaceEnableStatus value in rowreq_ctx->data */ rowreq_ctx->data.ipv4InterfaceEnableStatus = ipv4InterfaceEnableStatus_val; return MFD_SUCCESS;} /* ipv4InterfaceEnableStatus_set *//** * undo the previous set. * * @param rowreq_ctx * Pointer to the users context. */intipv4InterfaceEnableStatus_undo(ipv4InterfaceTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:ipv4InterfaceTable:ipv4InterfaceEnableStatus_undo", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:456:o: |-> Clean up ipv4InterfaceEnableStatus undo. */ /* * copy ipv4InterfaceEnableStatus data * set rowreq_ctx->data.ipv4InterfaceEnableStatus from rowreq_ctx->undo->ipv4InterfaceEnableStatus */ rowreq_ctx->data.ipv4InterfaceEnableStatus = rowreq_ctx->undo->ipv4InterfaceEnableStatus; return MFD_SUCCESS;} /* ipv4InterfaceEnableStatus_undo *//** @} *//** @{ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -