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

📄 ipcidrroutetable_interface.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 5 页
字号:
    }    /*     * copy indexes     */    rowreq_ctx->oid_idx.len = oid_idx->len;    memcpy(rowreq_ctx->oid_idx.oids, oid_idx->oids,           oid_idx->len * sizeof(oid));    return rowreq_ctx;}                               /* _mfd_ipCidrRouteTable_rowreq_from_index *//** * @internal * wrapper */static int_mfd_ipCidrRouteTable_object_lookup(netsnmp_mib_handler *handler,                                    netsnmp_handler_registration *reginfo,                                    netsnmp_agent_request_info                                    *agtreq_info,                                    netsnmp_request_info *requests){    int             rc = SNMP_ERR_NOERROR;    ipCidrRouteTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_object_lookup", "called\n"));    /*     * get our context from mfd     * ipCidrRouteTable_interface_ctx *if_ctx =     *             (ipCidrRouteTable_interface_ctx *)reginfo->my_reg_void;     */    if (NULL == rowreq_ctx) {        netsnmp_table_request_info *tblreq_info;        netsnmp_index   oid_idx;        tblreq_info = netsnmp_extract_table_info(requests);        if (NULL == tblreq_info) {            snmp_log(LOG_ERR, "request had no table info\n");            return MFD_ERROR;        }        /*         * try create rowreq         */        oid_idx.oids = tblreq_info->index_oid;        oid_idx.len = tblreq_info->index_oid_len;        rowreq_ctx =            _mfd_ipCidrRouteTable_rowreq_from_index(&oid_idx, &rc);        if (MFD_SUCCESS == rc) {            netsnmp_assert(NULL != rowreq_ctx);            rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED;            /*             * add rowreq_ctx to request data lists             */            netsnmp_container_table_row_insert(requests, (netsnmp_index *)                                               rowreq_ctx);        }    }    if (MFD_SUCCESS != rc)        netsnmp_request_set_error_all(requests, rc);    else        ipCidrRouteTable_row_prep(rowreq_ctx);    return SNMP_VALIDATE_ERR(rc);}                               /* _mfd_ipCidrRouteTable_object_lookup *//*********************************************************************** * * GET processing * ***********************************************************************//* * @internal * Retrieve the value for a particular column */NETSNMP_STATIC_INLINE int_ipCidrRouteTable_get_column(ipCidrRouteTable_rowreq_ctx * rowreq_ctx,                             netsnmp_variable_list * var, int column){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_column", "called for %d\n", column));    netsnmp_assert(NULL != rowreq_ctx);    switch (column) {        /*         * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPCIDRROUTEDEST:        var->type = ASN_IPADDRESS;        var->val_len = sizeof(u_long);        (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteDest;        break;        /*         * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPCIDRROUTEMASK:        var->type = ASN_IPADDRESS;        var->val_len = sizeof(u_long);        (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteMask;        break;        /*         * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h          */    case COLUMN_IPCIDRROUTETOS:        var->type = ASN_INTEGER;        var->val_len = sizeof(long);        (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteTos;        break;        /*         * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPCIDRROUTENEXTHOP:        var->type = ASN_IPADDRESS;        var->val_len = sizeof(u_long);        (*var->val.integer) = rowreq_ctx->tbl_idx.ipCidrRouteNextHop;        break;        /*         * ipCidrRouteIfIndex(5)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h          */    case COLUMN_IPCIDRROUTEIFINDEX:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteIfIndex_get(rowreq_ctx, (long *) var->val.string);        break;        /*         * ipCidrRouteType(6)/INTEGER/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPCIDRROUTETYPE:        var->val_len = sizeof(u_long);        var->type = ASN_INTEGER;        rc = ipCidrRouteType_get(rowreq_ctx, (u_long *) var->val.string);        break;        /*         * ipCidrRouteProto(7)/INTEGER/ASN_INTEGER/long(u_long)//l/A/w/E/r/d/h          */    case COLUMN_IPCIDRROUTEPROTO:        var->val_len = sizeof(u_long);        var->type = ASN_INTEGER;        rc = ipCidrRouteProto_get(rowreq_ctx, (u_long *) var->val.string);        break;        /*         * ipCidrRouteAge(8)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/D/h          */    case COLUMN_IPCIDRROUTEAGE:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteAge_get(rowreq_ctx, (long *) var->val.string);        break;        /*         * ipCidrRouteInfo(9)/OBJECTID/ASN_OBJECT_ID/oid(oid)//L/A/W/e/r/d/h          */    case COLUMN_IPCIDRROUTEINFO:        var->type = ASN_OBJECT_ID;        rc = ipCidrRouteInfo_get(rowreq_ctx, (oid **) & var->val.string,                                 &var->val_len);        break;        /*         * ipCidrRouteNextHopAS(10)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h          */    case COLUMN_IPCIDRROUTENEXTHOPAS:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteNextHopAS_get(rowreq_ctx,                                      (long *) var->val.string);        break;        /*         * ipCidrRouteMetric1(11)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h          */    case COLUMN_IPCIDRROUTEMETRIC1:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteMetric1_get(rowreq_ctx, (long *) var->val.string);        break;        /*         * ipCidrRouteMetric2(12)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h          */    case COLUMN_IPCIDRROUTEMETRIC2:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteMetric2_get(rowreq_ctx, (long *) var->val.string);        break;        /*         * ipCidrRouteMetric3(13)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h          */    case COLUMN_IPCIDRROUTEMETRIC3:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteMetric3_get(rowreq_ctx, (long *) var->val.string);        break;        /*         * ipCidrRouteMetric4(14)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h          */    case COLUMN_IPCIDRROUTEMETRIC4:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteMetric4_get(rowreq_ctx, (long *) var->val.string);        break;        /*         * ipCidrRouteMetric5(15)/INTEGER32/ASN_INTEGER/long(long)//l/A/W/e/r/D/h          */    case COLUMN_IPCIDRROUTEMETRIC5:        var->val_len = sizeof(long);        var->type = ASN_INTEGER;        rc = ipCidrRouteMetric5_get(rowreq_ctx, (long *) var->val.string);        break;        /*         * ipCidrRouteStatus(16)/RowStatus/ASN_INTEGER/long(u_long)//l/A/W/E/r/d/h          */    case COLUMN_IPCIDRROUTESTATUS:        var->val_len = sizeof(u_long);        var->type = ASN_INTEGER;        rc = ipCidrRouteStatus_get(rowreq_ctx, (u_long *) var->val.string);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ipCidrRouteTable_get_column\n",                 column);        break;    }    return rc;}                               /* _ipCidrRouteTable_get_column */int_mfd_ipCidrRouteTable_get_values(netsnmp_mib_handler *handler,                                 netsnmp_handler_registration *reginfo,                                 netsnmp_agent_request_info *agtreq_info,                                 netsnmp_request_info *requests){    ipCidrRouteTable_rowreq_ctx *rowreq_ctx =        netsnmp_container_table_row_extract(requests);    netsnmp_table_request_info *tri;    u_char         *old_string;    void            (*dataFreeHook) (void *);    int             rc;    DEBUGMSGTL(("internal:ipCidrRouteTable:_mfd_ipCidrRouteTable_get_values", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    for (; requests; requests = requests->next) {        /*         * save old pointer, so we can free it if replaced         */        old_string = requests->requestvb->val.string;        dataFreeHook = requests->requestvb->dataFreeHook;        if (NULL == requests->requestvb->val.string) {            requests->requestvb->val.string = requests->requestvb->buf;            requests->requestvb->val_len =                sizeof(requests->requestvb->buf);        } else if (requests->requestvb->buf ==                   requests->requestvb->val.string) {            if (requests->requestvb->val_len !=                sizeof(requests->requestvb->buf))                requests->requestvb->val_len =                    sizeof(requests->requestvb->buf);        }        /*         * get column data         */        tri = netsnmp_extract_table_info(requests);        if (NULL == tri)            continue;        rc = _ipCidrRouteTable_get_column(rowreq_ctx, requests->requestvb,                                          tri->colnum);        if (rc) {            if (MFD_SKIP == rc) {                requests->requestvb->type = SNMP_NOSUCHINSTANCE;                rc = SNMP_ERR_NOERROR;            }        } else if (NULL == requests->requestvb->val.string) {            snmp_log(LOG_ERR, "NULL varbind data pointer!\n");            rc = SNMP_ERR_GENERR;        }        if (rc)            netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));        /*         * if the buffer wasn't used previously for the old data (i.e. it         * was allcoated memory)  and the get routine replaced the pointer,         * we need to free the previous pointer.         */        if (old_string && (old_string != requests->requestvb->buf) &&            (requests->requestvb->val.string != old_string)) {            if (dataFreeHook)                (*dataFreeHook) (old_string);            else                free(old_string);        }    }                           /* for results */    return SNMP_ERR_NOERROR;}                               /* _mfd_ipCidrRouteTable_get_values */NETSNMP_STATIC_INLINE int_ipCidrRouteTable_check_indexes(ipCidrRouteTable_rowreq_ctx * rowreq_ctx){    int             rc = SNMPERR_SUCCESS;    DEBUGMSGTL(("internal:ipCidrRouteTable:_ipCidrRouteTable_check_indexes", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * (INDEX) ipCidrRouteDest(1)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h      */    if (MFD_SUCCESS != rc)        return rc;    rc = ipCidrRouteDest_check_index(rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * (INDEX) ipCidrRouteMask(2)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h      */    if (MFD_SUCCESS != rc)        return rc;    rc = ipCidrRouteMask_check_index(rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * (INDEX) ipCidrRouteTos(3)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/R/d/h      */    /*     * check defined range(s).      */    if ((SNMPERR_SUCCESS == rc)        && ((rowreq_ctx->tbl_idx.ipCidrRouteTos < 0)            || (rowreq_ctx->tbl_idx.ipCidrRouteTos > 2147483647))        ) {        rc = SNMP_ERR_WRONGVALUE;    }    if (MFD_SUCCESS != rc)        return rc;    rc = ipCidrRouteTos_check_index(rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * (INDEX) ipCidrRouteNextHop(4)/IPADDR/ASN_IPADDRESS/u_long(u_long)//l/A/w/e/r/d/h      */    if (MFD_SUCCESS != rc)        return rc;    rc = ipCidrRouteNextHop_check_index(rowreq_ctx);    if (MFD_SUCCESS != rc)        return SNMP_ERR_NOCREATION;    /*     * if individual parts look ok, check them as a whole     */

⌨️ 快捷键说明

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