📄 tcpconnectiontable.c
字号:
* 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 (tcpConnectionTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR : error */inttcpConnectionTable_undo_cleanup(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo_cleanup", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:452:M: |-> Cleanup tcpConnectionTable undo. * Undo storage is in (* tcpConnectionProcess_val_ptr )* */ return rc;} /* tcpConnectionTable_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 * tcpConnectionTable.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 */inttcpConnectionTable_commit(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; int save_flags; DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_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 tcpConnectionTable 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_TCPCONNECTIONSTATE_FLAG) { save_flags &= ~COLUMN_TCPCONNECTIONSTATE_FLAG; /* clear tcpConnectionState */ /* * TODO:482:o: |-> commit column tcpConnectionState. */ rc = -1; if (-1 == rc) { snmp_log(LOG_ERR, "tcpConnectionTable column tcpConnectionState commit failed\n"); } else { /* * set flag, in case we need to undo tcpConnectionState */ rowreq_ctx->column_set_flags |= COLUMN_TCPCONNECTIONSTATE_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;} /* tcpConnectionTable_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 * tcpConnectionTable.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 */inttcpConnectionTable_undo_commit(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo_commit", "called\n")); /** we should have a non-NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:485:M: |-> Undo tcpConnectionTable 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;} /* tcpConnectionTable_undo_commit *//* * TODO:440:M: Implement tcpConnectionTable node value checks. * TODO:450:M: Implement tcpConnectionTable undo functions. * TODO:460:M: Implement tcpConnectionTable set functions. * TODO:480:M: Implement tcpConnectionTable commit functions. *//*--------------------------------------------------------------------- * TCP-MIB::tcpConnectionEntry.tcpConnectionState * tcpConnectionState is subid 7 of tcpConnectionEntry. * Its status is Current, and its access level is ReadWrite. * OID: .1.3.6.1.2.1.6.19.1.7 * Description:The state of this TCP connection. The value listen(2) is included only for parallelism to the old tcpConnTable, and should not be used. A connection in LISTEN state should be present in the tcpListenerTable. The only value which may be set by a management station is deleteTCB(12). Accordingly, it is appropriate for an agent to return a `badValue' response if a management station attempts to set this object to any other value. If a management station sets this object to the value deleteTCB(12), then this has the effect of deleting the TCB (as defined in RFC 793) of the corresponding connection on the managed node, resulting in immediate termination of the connection. As an implementation-specific option, a RST segment may be sent from the managed node to the other TCP endpoint (note however that RST segments are not sent reliably). * * Attributes: * accessible 1 isscalar 0 enums 1 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 1 * * Enum range: 9/16. Values: closed(1), listen(2), synSent(3), synReceived(4), established(5), finWait1(6), finWait2(7), closeWait(8), lastAck(9), closing(10), timeWait(11), deleteTCB(12) * * 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 tcpConnectionState_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 * tcpConnectionTable_check_dependencies() function. * * The following checks have already been done for you: * The syntax is ASN_INTEGER * The value is one of closed(1), listen(2), synSent(3), synReceived(4), established(5), finWait1(6), finWait2(7), closeWait(8), lastAck(9), closing(10), timeWait(11), deleteTCB(12) * * If there a no other checks you need to do, simply return MFD_SUCCESS. * */inttcpConnectionState_check_value(tcpConnectionTable_rowreq_ctx * rowreq_ctx, u_long tcpConnectionState_val){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_check_value", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:441:o: |-> Check for valid tcpConnectionState value. */ return MFD_SUCCESS; /* tcpConnectionState value not illegal */} /* tcpConnectionState_check_value *//** * Save old value information * * @param rowreq_ctx * Pointer to the table context (tcpConnectionTable_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 * tcpConnectionTable_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. */inttcpConnectionState_undo_setup(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_undo_setup", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:455:o: |-> Setup tcpConnectionState undo. */ /* * copy tcpConnectionState data * set rowreq_ctx->undo->tcpConnectionState from rowreq_ctx->data->tcpConnectionState */ return MFD_SUCCESS;} /* tcpConnectionState_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 tcpConnectionState_val * A long containing the new value. */inttcpConnectionState_set(tcpConnectionTable_rowreq_ctx * rowreq_ctx, u_long tcpConnectionState_val){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_set", "called\n")); /** should never get a NULL pointer */ netsnmp_assert(NULL != rowreq_ctx); /* * TODO:461:M: |-> Set tcpConnectionState value. * set tcpConnectionState value in rowreq_ctx->data */ return MFD_SUCCESS;} /* tcpConnectionState_set *//** * undo the previous set. * * @param rowreq_ctx * Pointer to the users context. */inttcpConnectionState_undo(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_undo", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:456:o: |-> Clean up tcpConnectionState undo. */ /* * copy tcpConnectionState data * set rowreq_ctx->data->tcpConnectionState from rowreq_ctx->undo->tcpConnectionState */ return MFD_SUCCESS;} /* tcpConnectionState_undo *//** * check dependencies * * This is useful for for tables which have dependencies between columns * (or rows, or tables). For example, two columns allocating a percentage * of something add up 100%. * * 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 * tcpConnectionTable.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @retval MFD_SUCCESS all the changes to the row are legal * @retval MFD_ERROR one or more changes are not legal * * (see README-table-tcpConnectionTable if you don't have dependencies) */inttcpConnectionTable_check_dependencies(tcpConnectionTable_rowreq_ctx * rowreq_ctx){ int rc = MFD_SUCCESS; DEBUGMSGTL(("internal:tcpConnectionTable:tcpConnectionTable_check_dependencies", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:470:o: Check tcpConnectionTable row dependencies. * check that all new value are legal and consistent with each other */ return rc;} /* tcpConnectionTable_check_dependencies *//** @} *//** @{ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -