⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpconnectiontable.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 3 页
字号:
    if ((NULL == tbl_idx->tcpConnectionRemAddress) ||        (tbl_idx->tcpConnectionRemAddress_len <         (tcpConnectionRemAddress_val_ptr_len))) {        snmp_log(LOG_ERR, "not enough space for value\n");        return MFD_ERROR;    }    tbl_idx->tcpConnectionRemAddress_len =        tcpConnectionRemAddress_val_ptr_len;    memcpy(tbl_idx->tcpConnectionRemAddress,           tcpConnectionRemAddress_val_ptr,           tcpConnectionRemAddress_val_ptr_len *           sizeof(tcpConnectionRemAddress_val_ptr[0]));    /*     * tcpConnectionRemPort(6)/InetPortNumber/ASN_UNSIGNED/u_long(u_long)//l/a/w/e/R/d/H      */    /** WARNING: this code might not work for netsnmp_tcpconn_entry */    tbl_idx->tcpConnectionRemPort = tcpConnectionRemPort_val;    return MFD_SUCCESS;}                               /* tcpConnectionTable_indexes_set_tbl_idx *//** * @internal * set row context indexes * * @param reqreq_ctx the row context that needs updated indexes * * @retval MFD_SUCCESS     : success. * @retval MFD_ERROR       : other error. * * @remark *  This function sets the mib indexs, then updates the oid indexs *  from the mib index. */inttcpConnectionTable_indexes_set(tcpConnectionTable_rowreq_ctx * rowreq_ctx,                               u_long tcpConnectionLocalAddressType_val,                               char *tcpConnectionLocalAddress_val_ptr,                               size_t                               tcpConnectionLocalAddress_val_ptr_len,                               u_long tcpConnectionLocalPort_val,                               u_long tcpConnectionRemAddressType_val,                               char *tcpConnectionRemAddress_val_ptr,                               size_t tcpConnectionRemAddress_val_ptr_len,                               u_long tcpConnectionRemPort_val){    DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_indexes_set", "called\n"));    if (MFD_SUCCESS !=        tcpConnectionTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,                                               tcpConnectionLocalAddressType_val,                                               tcpConnectionLocalAddress_val_ptr,                                               tcpConnectionLocalAddress_val_ptr_len,                                               tcpConnectionLocalPort_val,                                               tcpConnectionRemAddressType_val,                                               tcpConnectionRemAddress_val_ptr,                                               tcpConnectionRemAddress_val_ptr_len,                                               tcpConnectionRemPort_val))        return MFD_ERROR;    /*     * convert mib index to oid index     */    rowreq_ctx->oid_idx.len = sizeof(rowreq_ctx->oid_tmp) / sizeof(oid);    if (0 != tcpConnectionTable_index_to_oid(&rowreq_ctx->oid_idx,                                             &rowreq_ctx->tbl_idx)) {        return MFD_ERROR;    }    return MFD_SUCCESS;}                               /* tcpConnectionTable_indexes_set *//*--------------------------------------------------------------------- * 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) *//** * Extract the current value of the tcpConnectionState data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param tcpConnectionState_val_ptr *        Pointer to storage for a long variable * * @retval MFD_SUCCESS         : success * @retval MFD_SKIP            : skip this node (no value for now) * @retval MFD_ERROR           : Any other error */inttcpConnectionState_get(tcpConnectionTable_rowreq_ctx * rowreq_ctx,                       u_long * tcpConnectionState_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != tcpConnectionState_val_ptr);    DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionState_get",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:231:o: |-> Extract the current value of the tcpConnectionState data.     * copy (* tcpConnectionState_val_ptr ) from rowreq_ctx->data     */    (*tcpConnectionState_val_ptr) = rowreq_ctx->data->tcpConnState;    return MFD_SUCCESS;}                               /* tcpConnectionState_get *//*--------------------------------------------------------------------- * TCP-MIB::tcpConnectionEntry.tcpConnectionProcess * tcpConnectionProcess is subid 8 of tcpConnectionEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.6.19.1.8 * Description:The system's process ID for the process associated with             this connection, or zero if there is no such process.  This            value is expected to be the same as HOST-RESOURCES-MIB::            hrSWRunIndex or SYSAPPL-MIB::sysApplElmtRunIndex for some            row in the appropriate tables. * * Attributes: *   accessible 1     isscalar 0     enums  0      hasdefval 0 *   readable   1     iscolumn 1     ranges 0      hashint   0 *   settable   0 * * * Its syntax is UNSIGNED32 (based on perltype UNSIGNED32) * The net-snmp type is ASN_UNSIGNED. The C type decl is u_long (u_long) *//** * Extract the current value of the tcpConnectionProcess data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param tcpConnectionProcess_val_ptr *        Pointer to storage for a u_long variable * * @retval MFD_SUCCESS         : success * @retval MFD_SKIP            : skip this node (no value for now) * @retval MFD_ERROR           : Any other error */inttcpConnectionProcess_get(tcpConnectionTable_rowreq_ctx * rowreq_ctx,                         u_long * tcpConnectionProcess_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != tcpConnectionProcess_val_ptr);    DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionProcess_get",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:231:o: |-> Extract the current value of the tcpConnectionProcess data.     * copy (* tcpConnectionProcess_val_ptr ) from rowreq_ctx->data     */    (*tcpConnectionProcess_val_ptr) = rowreq_ctx->data->pid;    return MFD_SUCCESS;}                               /* tcpConnectionProcess_get *//** @} *//********************************************************************** ********************************************************************** *** *** Table tcpConnectionTable *** ********************************************************************** **********************************************************************//* * TCP-MIB::tcpConnectionTable is subid 19 of tcp. * Its status is Current. * OID: .1.3.6.1.2.1.6.19, length: 8 */    /*     * NOTE: if you update this chart, please update the versions in     *       local/mib2c-conf.d/parent-set.m2i     *       agent/mibgroup/helpers/baby_steps.c     * while you're at it.     */    /*     ***********************************************************************     * Baby Steps Flow Chart (2004.06.05)                                  *     *                                                                     *     * +--------------+    +================+    U = unconditional path    *     * |optional state|    ||required state||    S = path for success      *     * +--------------+    +================+    E = path for error        *     ***********************************************************************     *     *                        +--------------+     *                        |     pre      |     *                        |   request    |     *                        +--------------+     *                               | U     *                        +==============+     *       +----------------||  object    ||     *       |              E ||  lookup    ||     *       |                +==============+     *       |                       | S     *       |                +==============+     *       |              E ||   check    ||     *       |<---------------||   values   ||     *       |                +==============+     *       |                       | S     *       |                +==============+     *       |       +<-------||   undo     ||     *       |       |      E ||   setup    ||     *       |       |        +==============+     *       |       |               | S     *       |       |        +==============+     *       |       |        ||    set     ||-------------------------->+     *       |       |        ||   value    || E                         |     *       |       |        +==============+                           |     *       |       |               | S                                 |     *       |       |        +--------------+                           |     *       |       |        |    check     |-------------------------->|     *       |       |        |  consistency | E                         |     *       |       |        +--------------+                           |     *       |       |               | S                                 |     *       |       |        +==============+         +==============+  |     *       |       |        ||   commit   ||-------->||     undo   ||  |     *       |       |        ||            || E       ||    commit  ||  |     *       |       |        +==============+         +==============+  |     *       |       |               | S                     U |<--------+     *       |       |        +--------------+         +==============+     *       |       |        | irreversible |         ||    undo    ||     *       |       |        |    commit    |         ||     set    ||     *       |       |        +--------------+         +==============+     *       |       |               | U                     U |     *       |       +-------------->|<------------------------+     *       |                +==============+     *       |                ||   undo     ||     *       |                ||  cleanup   ||     *       |                +==============+     *       +---------------------->| U     *                        +--------------+     *                        |    post      |     *                        |   request    |     *                        +--------------+     *     *//** * 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 * tcpConnectionTable_allocate_data(), but may need extra * initialization similar to what you may have done in * tcpConnectionTable_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 (tcpConnectionTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR   : error. set will fail. */inttcpConnectionTable_undo_setup(tcpConnectionTable_rowreq_ctx * rowreq_ctx){    int             rc = MFD_SUCCESS;    DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo_setup",                "called\n"));    /** we should have a non-NULL pointer */    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:451:M: |-> Setup tcpConnectionTable undo.     * set up tcpConnectionTable undo information, in preparation for a set.     * Undo storage is in (* tcpConnectionProcess_val_ptr )*     */    return rc;}                               /* tcpConnectionTable_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 (tcpConnectionTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR   : error. set will fail. */inttcpConnectionTable_undo(tcpConnectionTable_rowreq_ctx * rowreq_ctx){    int             rc = MFD_SUCCESS;    DEBUGMSGTL(("verbose:tcpConnectionTable:tcpConnectionTable_undo",                "called\n"));    /** we should have a non-NULL pointer */    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:451:M: |-> tcpConnectionTable undo.     * tcpConnectionTable undo information, in response to a failed set.     * Undo storage is in (* tcpConnectionProcess_val_ptr )*     */    return rc;}                               /* tcpConnectionTable_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. *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -