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

📄 ipaddresstable.c

📁 snmp的源代码,已经在我的ubuntu下编译通过
💻 C
📖 第 1 页 / 共 5 页
字号:
            can be modified.  The value of this object has no effect on            whether other objects in this conceptual row can be            modified.            A conceptual row can not be made active until the            ipAddressIfIndex has been set to a valid index.   * * Attributes: *   accessible 1     isscalar 0     enums  1      hasdefval 0 *   readable   1     iscolumn 1     ranges 0      hashint   0 *   settable   1 * * Enum range: 3/8. Values:  active(1), notInService(2), notReady(3), createAndGo(4), createAndWait(5), destroy(6) * * Its syntax is RowStatus (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 ipAddressRowStatus data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ipAddressRowStatus_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 */intipAddressRowStatus_get(ipAddressTable_rowreq_ctx * rowreq_ctx,                       u_long * ipAddressRowStatus_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != ipAddressRowStatus_val_ptr);    /** WARNING: this code might not work for netsnmp_ipaddress_entry */    (*ipAddressRowStatus_val_ptr) = rowreq_ctx->ipAddressRowStatus;    return MFD_SUCCESS;}                               /* ipAddressRowStatus_get *//*--------------------------------------------------------------------- * IP-MIB::ipAddressEntry.ipAddressStorageType * ipAddressStorageType is subid 11 of ipAddressEntry. * Its status is Current, and its access level is Create. * OID: .1.3.6.1.2.1.4.34.1.11 * Description:The storage type for this conceptual row.  If this object            has a value of 'permanent' then no other objects are            required to be able to be modified. * * Attributes: *   accessible 1     isscalar 0     enums  1      hasdefval 1 *   readable   1     iscolumn 1     ranges 0      hashint   0 *   settable   1 *   defval: volatile * * Enum range: 4/8. Values:  other(1), volatile(2), nonVolatile(3), permanent(4), readOnly(5) * * Its syntax is StorageType (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 ipAddressStorageType data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ipAddressStorageType_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 */intipAddressStorageType_get(ipAddressTable_rowreq_ctx * rowreq_ctx,                         u_long * ipAddressStorageType_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != ipAddressStorageType_val_ptr);    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressStorageType_get",                "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:231:o: |-> Extract the current value of the ipAddressStorageType data.     * set (* ipAddressStorageType_val_ptr ) from rowreq_ctx->data     */    (*ipAddressStorageType_val_ptr) = rowreq_ctx->data->ia_storagetype;    return MFD_SUCCESS;}                               /* ipAddressStorageType_get *//** @} *//********************************************************************** ********************************************************************** *** *** Table ipAddressTable *** ********************************************************************** **********************************************************************//* * ipAddressTable is subid 34 of ip. * Its status is Current. * OID: .1.3.6.1.2.1.4.34, 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     * +-------------+        +==============+     * |    row    |f|<-------||  object    ||     * |  create   |1|      E ||  lookup    ||     * +-------------+        +==============+     *     E |   | S                 | 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     *                               |     *                          (err && f1)------------------->+     *                               |                         |     *                        +--------------+         +--------------+     *                        |    post      |<--------|      row     |     *                        |   request    |       U |    release   |     *                        +--------------+         +--------------+     *     *//** * verify specified index is valid. * * This check is independent of whether or not the values specified for * the columns of the new row are valid. Column values and row consistency * will be checked later. At this point, only the index values should be * checked. * * 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 ipAddressTable_reg *        Pointer to the user registration data * @param ipAddressTable_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 */intipAddressTable_validate_index(ipAddressTable_registration_ptr                              ipAddressTable_reg,                              ipAddressTable_rowreq_ctx * rowreq_ctx){    int             rc = MFD_SUCCESS;    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_validate_index",                "called\n"));    /** we should have a non-NULL pointer */    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:430:M: |-> Validate potential ipAddressTable index.     *     * xxx-rks: we only plan ipv4 support initially     */    if ((4 != rowreq_ctx->tbl_idx.ipAddressAddr_len)) {        snmp_log(LOG_WARNING, "invalid index for a new row in the "                 "ipAddressTable 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;        }    } else {        rowreq_ctx->data->ia_address[0] =            rowreq_ctx->tbl_idx.ipAddressAddr[0];        rowreq_ctx->data->ia_address[1] =            rowreq_ctx->tbl_idx.ipAddressAddr[1];        rowreq_ctx->data->ia_address[2] =            rowreq_ctx->tbl_idx.ipAddressAddr[2];        rowreq_ctx->data->ia_address[3] =            rowreq_ctx->tbl_idx.ipAddressAddr[3];        rowreq_ctx->data->ia_address_len = 4;    }    return rc;}                               /* ipAddressTable_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 (ipAddressTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR   : error. set will fail. */intipAddressTable_undo_setup(ipAddressTable_rowreq_ctx * rowreq_ctx){    int             rc = MFD_SUCCESS;    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_undo_setup",                "called\n"));    /** we should have a non-NULL pointer */    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:451:M: |-> Setup ipAddressTable undo.     * set up ipAddressTable undo information, in preparation for a set.     */    /*     * check for storage types that don't allow modification.     * probably should try and do this earlier (and we could, by     * adding code to the interface file), but this ought to suffice.     */    if (STORAGETYPE_READONLY == rowreq_ctx->data->ia_storagetype) {        DEBUGMSGTL(("ipAddressTable", "can't change readonly row\n"));        return MFD_NOT_VALID_EVER;    }    /*     * save last changed     */    rowreq_ctx->ipAddressLastChanged_undo =        rowreq_ctx->ipAddressLastChanged;    rowreq_ctx->ipAddressLastChanged =        rowreq_ctx->ipAddressLastChanged_undo;    /*     * just copy everything     */    rc = netsnmp_access_ipaddress_entry_copy(rowreq_ctx->undo,                                             rowreq_ctx->data);    return rc;}                               /* ipAddressTable_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 (ipAddressTable_rowreq_ctx) * * @retval MFD_SUCCESS : success * @retval MFD_ERROR   : error */intipAddressTable_undo_cleanup(ipAddressTable_rowreq_ctx * rowreq_ctx){    int             rc = MFD_SUCCESS;    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_undo_cleanup",                "called\n"));    /** we should have a non-NULL pointer */    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:452:M: |-> Cleanup ipAddressTable undo.     */    return rc;}                               /* ipAddressTable_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 * ipAddressTable.h. * A new row will have the MFD_ROW_CREATED bit set in rowreq_flags. * * @param ipAddressTable_rowreq_ctx *        Pointer to the users context. * * @retval MFD_SUCCESS : success * @retval MFD_ERROR   : error */intipAddressTable_commit(ipAddressTable_rowreq_ctx * rowreq_ctx){    int             rc = MFD_SUCCESS;    int             save_flags;    DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_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 ipAddressTable 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

⌨️ 快捷键说明

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