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

📄 ipsystemstatstable_interface.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 3 页
字号:
         * ipSystemStatsOutTransmits(30)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSOUTTRANSMITS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsOutTransmits_get(rowreq_ctx,                                           (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCOutTransmits(31)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCOUTTRANSMITS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCOutTransmits_get(rowreq_ctx,                                             (U64 *) var->val.string);        break;        /*         * ipSystemStatsOutOctets(32)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSOUTOCTETS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsOutOctets_get(rowreq_ctx,                                        (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCOutOctets(33)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCOUTOCTETS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCOutOctets_get(rowreq_ctx,                                          (U64 *) var->val.string);        break;        /*         * ipSystemStatsInMcastPkts(34)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSINMCASTPKTS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsInMcastPkts_get(rowreq_ctx,                                          (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCInMcastPkts(35)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCINMCASTPKTS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCInMcastPkts_get(rowreq_ctx,                                            (U64 *) var->val.string);        break;        /*         * ipSystemStatsInMcastOctets(36)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSINMCASTOCTETS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsInMcastOctets_get(rowreq_ctx,                                            (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCInMcastOctets(37)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCINMCASTOCTETS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCInMcastOctets_get(rowreq_ctx,                                              (U64 *) var->val.string);        break;        /*         * ipSystemStatsOutMcastPkts(38)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSOUTMCASTPKTS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsOutMcastPkts_get(rowreq_ctx,                                           (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCOutMcastPkts(39)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCOUTMCASTPKTS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCOutMcastPkts_get(rowreq_ctx,                                             (U64 *) var->val.string);        break;        /*         * ipSystemStatsOutMcastOctets(40)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSOUTMCASTOCTETS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsOutMcastOctets_get(rowreq_ctx,                                             (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCOutMcastOctets(41)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCOUTMCASTOCTETS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCOutMcastOctets_get(rowreq_ctx,                                               (U64 *) var->val.string);        break;        /*         * ipSystemStatsInBcastPkts(42)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSINBCASTPKTS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsInBcastPkts_get(rowreq_ctx,                                          (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCInBcastPkts(43)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCINBCASTPKTS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCInBcastPkts_get(rowreq_ctx,                                            (U64 *) var->val.string);        break;        /*         * ipSystemStatsOutBcastPkts(44)/COUNTER/ASN_COUNTER/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSOUTBCASTPKTS:        var->val_len = sizeof(u_long);        var->type = ASN_COUNTER;        rc = ipSystemStatsOutBcastPkts_get(rowreq_ctx,                                           (u_long *) var->val.string);        break;        /*         * ipSystemStatsHCOutBcastPkts(45)/COUNTER64/ASN_COUNTER64/U64(U64)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSHCOUTBCASTPKTS:        var->val_len = sizeof(U64);        var->type = ASN_COUNTER64;        rc = ipSystemStatsHCOutBcastPkts_get(rowreq_ctx,                                             (U64 *) var->val.string);        break;        /*         * ipSystemStatsDiscontinuityTime(46)/TimeStamp/ASN_TIMETICKS/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSDISCONTINUITYTIME:        var->val_len = sizeof(u_long);        var->type = ASN_TIMETICKS;        rc = ipSystemStatsDiscontinuityTime_get(rowreq_ctx,                                                (u_long *) var->val.                                                string);        break;        /*         * ipSystemStatsRefreshRate(47)/UNSIGNED32/ASN_UNSIGNED/u_long(u_long)//l/A/w/e/r/d/h          */    case COLUMN_IPSYSTEMSTATSREFRESHRATE:        var->val_len = sizeof(u_long);        var->type = ASN_UNSIGNED;        rc = ipSystemStatsRefreshRate_get(rowreq_ctx,                                          (u_long *) var->val.string);        break;    default:        snmp_log(LOG_ERR,                 "unknown column %d in _ipSystemStatsTable_get_column\n",                 column);        break;    }    return rc;}                               /* _ipSystemStatsTable_get_column */int_mfd_ipSystemStatsTable_get_values(netsnmp_mib_handler *handler,                                   netsnmp_handler_registration *reginfo,                                   netsnmp_agent_request_info *agtreq_info,                                   netsnmp_request_info *requests){    ipSystemStatsTable_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:ipSystemStatsTable:_mfd_ipSystemStatsTable_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 = _ipSystemStatsTable_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_ipSystemStatsTable_get_values *//*********************************************************************** * * SET processing * ***********************************************************************//* * SET PROCESSING NOT APPLICABLE (per MIB or user setting) *//*********************************************************************** * * DATA ACCESS * ***********************************************************************/static void     _container_free(netsnmp_container *container);/** * @internal */static int_cache_load(netsnmp_cache * cache, void *vmagic){    DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_load", "called\n"));    if ((NULL == cache) || (NULL == cache->magic)) {        snmp_log(LOG_ERR,                 "invalid cache for ipSystemStatsTable_cache_load\n");        return -1;    }    /** should only be called for an invalid or expired cache */    netsnmp_assert((0 == cache->valid) || (1 == cache->expired));    /*     * call user code     */    return ipSystemStatsTable_container_load((netsnmp_container *) cache->                                             magic);}                               /* _cache_load *//** * @internal */static void_cache_free(netsnmp_cache * cache, void *magic){    netsnmp_container *container;    DEBUGMSGTL(("internal:ipSystemStatsTable:_cache_free", "called\n"));    if ((NULL == cache) || (NULL == cache->magic)) {        snmp_log(LOG_ERR,                 "invalid cache in ipSystemStatsTable_cache_free\n");        return;    }    container = (netsnmp_container *) cache->magic;    _container_free(container);}                               /* _cache_free *//** * @internal */static void_container_item_free(ipSystemStatsTable_rowreq_ctx * rowreq_ctx,                     void *context){    DEBUGMSGTL(("internal:ipSystemStatsTable:_container_item_free",                "called\n"));    if (NULL == rowreq_ctx)        return;    ipSystemStatsTable_release_rowreq_ctx(rowreq_ctx);}                               /* _container_item_free *//** * @internal */static void_container_free(netsnmp_container *container){    DEBUGMSGTL(("internal:ipSystemStatsTable:_container_free",                "called\n"));    if (NULL == container) {        snmp_log(LOG_ERR,                 "invalid container in ipSystemStatsTable_container_free\n");        return;    }    /*     * call user code     */    ipSystemStatsTable_container_free(container);    /*     * free all items. inefficient, but easy.     */    CONTAINER_CLEAR(container,                    (netsnmp_container_obj_func *) _container_item_free,                    NULL);}                               /* _container_free *//** * @internal * initialize the container with functions or wrappers */void_ipSystemStatsTable_container_init(ipSystemStatsTable_interface_ctx *                                   if_ctx){    DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_container_init", "called\n"));    /*     * cache init     */    if_ctx->cache = netsnmp_cache_create(30,    /* timeout in seconds */                                         _cache_load, _cache_free,                                         ipSystemStatsTable_oid,                                         ipSystemStatsTable_oid_size);    if (NULL == if_ctx->cache) {        snmp_log(LOG_ERR, "error creating cache for ipSystemStatsTable\n");        return;    }    if_ctx->cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;    ipSystemStatsTable_container_init(&if_ctx->container, if_ctx->cache);    if (NULL == if_ctx->container)        if_ctx->container =            netsnmp_container_find("ipSystemStatsTable:table_container");    if (NULL == if_ctx->container) {        snmp_log(LOG_ERR, "error creating container in "                 "ipSystemStatsTable_container_init\n");        return;    }    if (NULL != if_ctx->cache)        if_ctx->cache->magic = (void *) if_ctx->container;}                               /* _ipSystemStatsTable_container_init *//** * @internal * shutdown the container with functions or wrappers */void_ipSystemStatsTable_container_shutdown(ipSystemStatsTable_interface_ctx *                                       if_ctx){    DEBUGMSGTL(("internal:ipSystemStatsTable:_ipSystemStatsTable_container_shutdown", "called\n"));    ipSystemStatsTable_container_shutdown(if_ctx->container);    _container_free(if_ctx->container);}                               /* _ipSystemStatsTable_container_shutdown */ipSystemStatsTable_rowreq_ctx *ipSystemStatsTable_row_find_by_mib_index(ipSystemStatsTable_mib_index *                                         mib_idx){    ipSystemStatsTable_rowreq_ctx *rowreq_ctx;    oid             oid_tmp[MAX_OID_LEN];    netsnmp_index   oid_idx;    int             rc;    /*     * set up storage for OID     */    oid_idx.oids = oid_tmp;    oid_idx.len = sizeof(oid_tmp) / sizeof(oid);    /*     * convert     */    rc = ipSystemStatsTable_index_to_oid(&oid_idx, mib_idx);    if (MFD_SUCCESS != rc)        return NULL;    rowreq_ctx =        CONTAINER_FIND(ipSystemStatsTable_if_ctx.container, &oid_idx);    return rowreq_ctx;}

⌨️ 快捷键说明

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