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

📄 iftable.c

📁 开发snmp的开发包有两个开放的SNMP开发库
💻 C
📖 第 1 页 / 共 5 页
字号:
        return MFD_ERROR;    }    return MFD_SUCCESS;}                               /* ifTable_indexes_set *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifDescr * ifDescr is subid 2 of ifEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.2 * Description:A textual string containing information about the            interface.  This string should include the name of the            manufacturer, the product name and the version of the            interface hardware/software. * * Attributes: *   accessible 1     isscalar 0     enums  0      hasdefval 0 *   readable   1     iscolumn 1     ranges 1      hashint   1 *   settable   0 *   hint: 255a * * Ranges:  0 - 255; * * Its syntax is DisplayString (based on perltype OCTETSTR) * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) * This data type requires a length.  (Max 255) *//** * Extract the current value of the ifDescr data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ifDescr_val_ptr_ptr *        Pointer to storage for a char variable * @param ifDescr_val_ptr_len_ptr *        Pointer to a size_t. On entry, it will contain the size (in bytes) *        pointed to by ifDescr. *        On exit, this value should contain the data size (in bytes). * * @retval MFD_SUCCESS         : success * @retval MFD_SKIP            : skip this node (no value for now) * @retval MFD_ERROR           : Any other error* * @note If you need more than (*ifDescr_val_ptr_len_ptr) bytes of memory, *       allocate it using malloc() and update ifDescr_val_ptr_ptr. *       <b>DO NOT</b> free the previous pointer. *       The MFD helper will release the memory you allocate. * * @remark If you call this function yourself, you are responsible *         for checking if the pointer changed, and freeing any *         previously allocated memory. (Not necessary if you pass *         in a pointer to static memory, obviously.) */intifDescr_get(ifTable_rowreq_ctx * rowreq_ctx, char **ifDescr_val_ptr_ptr,            size_t * ifDescr_val_ptr_len_ptr){    char           *tmp_descr = NULL;    u_char          tmp_len = 0;   /** we should have a non-NULL pointer and enough storage */    netsnmp_assert((NULL != ifDescr_val_ptr_ptr)                   && (NULL != *ifDescr_val_ptr_ptr));    netsnmp_assert(NULL != ifDescr_val_ptr_len_ptr);    DEBUGMSGTL(("verbose:ifTable:ifDescr_get", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * if ifDescr is NULL, use the ifName     */    if (NULL == rowreq_ctx->data.ifDescr) {#ifdef USING_IF_MIB_IFXTABLE_IFXTABLE_MODULE        tmp_descr = rowreq_ctx->data.ifName;#else        tmp_descr = NULL;#endif    } else        tmp_descr = rowreq_ctx->data.ifDescr;    if (NULL != tmp_descr)        tmp_len = strlen(tmp_descr);    else        tmp_len = 0;    /*     * TODO:231:o: |-> Extract the current value of the ifDescr data.     * copy (* ifDescr_val_ptr_ptr ) data and (* ifDescr_val_ptr_len_ptr ) from rowreq_ctx->data     */    /*     * make sure there is enough space for ifDescr data     */    if ((NULL == (*ifDescr_val_ptr_ptr)) ||        ((*ifDescr_val_ptr_len_ptr) < tmp_len)) {        /*         * allocate space for ifDescr data         */        (*ifDescr_val_ptr_ptr) =            malloc(tmp_len * sizeof(rowreq_ctx->data.ifDescr[0]));        if (NULL == (*ifDescr_val_ptr_ptr)) {            snmp_log(LOG_ERR, "could not allocate memory\n");            return MFD_ERROR;        }    }    (*ifDescr_val_ptr_len_ptr) =        tmp_len * sizeof(rowreq_ctx->data.ifDescr[0]);    memcpy((*ifDescr_val_ptr_ptr), tmp_descr, (*ifDescr_val_ptr_len_ptr));    return MFD_SUCCESS;}                               /* ifDescr_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifType * ifType is subid 3 of ifEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.3 * Description:The type of interface.  Additional values for ifType are            assigned by the Internet Assigned Numbers Authority (IANA),            through updating the syntax of the IANAifType textual            convention. * * Attributes: *   accessible 1     isscalar 0     enums  1      hasdefval 0 *   readable   1     iscolumn 1     ranges 0      hashint   0 *   settable   0 * * Enum range: 149/256. Values:  other(1), regular1822(2), hdh1822(3), ddnX25(4), rfc877x25(5), ethernetCsmacd(6), iso88023Csmacd(7), iso88024TokenBus(8), iso88025TokenRing(9), iso88026Man(10), starLan(11), proteon10Mbit(12), proteon80Mbit(13), hyperchannel(14), fddi(15), lapb(16), sdlc(17), ds1(18), e1(19), basicISDN(20), primaryISDN(21), propPointToPointSerial(22), ppp(23), softwareLoopback(24), eon(25), ethernet3Mbit(26), nsip(27), slip(28), ultra(29), ds3(30), sip(31), frameRelay(32), rs232(33), para(34), arcnet(35), arcnetPlus(36), atm(37), miox25(38), sonet(39), x25ple(40), iso88022llc(41), localTalk(42), smdsDxi(43), frameRelayService(44), v35(45), hssi(46), hippi(47), modem(48), aal5(49), sonetPath(50), sonetVT(51), smdsIcip(52), propVirtual(53), propMultiplexor(54), ieee80212(55), fibreChannel(56), hippiInterface(57), frameRelayInterconnect(58), aflane8023(59), aflane8025(60), cctEmul(61), fastEther(62), isdn(63), v11(64), v36(65), g703at64k(66), g703at2mb(67), qllc(68), fastEtherFX(69), channel(70), ieee80211(71), ibm370parChan(72), escon(73), dlsw(74), isdns(75), isdnu(76), lapd(77), ipSwitch(78), rsrb(79), atmLogical(80), ds0(81), ds0Bundle(82), bsc(83), async(84), cnr(85), iso88025Dtr(86), eplrs(87), arap(88), propCnls(89), hostPad(90), termPad(91), frameRelayMPI(92), x213(93), adsl(94), radsl(95), sdsl(96), vdsl(97), iso88025CRFPInt(98), myrinet(99), voiceEM(100), voiceFXO(101), voiceFXS(102), voiceEncap(103), voiceOverIp(104), atmDxi(105), atmFuni(106), atmIma(107), pppMultilinkBundle(108), ipOverCdlc(109), ipOverClaw(110), stackToStack(111), virtualIpAddress(112), mpc(113), ipOverAtm(114), iso88025Fiber(115), tdlc(116), gigabitEthernet(117), hdlc(118), lapf(119), v37(120), x25mlp(121), x25huntGroup(122), trasnpHdlc(123), interleave(124), fast(125), ip(126), docsCableMaclayer(127), docsCableDownstream(128), docsCableUpstream(129), a12MppSwitch(130), tunnel(131), coffee(132), ces(133), atmSubInterface(134), l2vlan(135), l3ipvlan(136), l3ipxvlan(137), digitalPowerline(138), mediaMailOverIp(139), dtm(140), dcn(141), ipForward(142), msdsl(143), ieee1394(144), if_gsn(145), dvbRccMacLayer(146), dvbRccDownstream(147), dvbRccUpstream(148), atmVirtual(149), mplsTunnel(150), srp(151), voiceOverAtm(152), voiceOverFrameRelay(153), idsl(154), compositeLink(155), ss7SigLink(156), propWirelessP2P(157), frForward(158), rfc1483(159), usb(160), ieee8023adLag(161), bgppolicyaccounting(162), frf16MfrBundle(163), h323Gatekeeper(164), h323Proxy(165), mpls(166), mfSigLink(167), hdsl2(168), shdsl(169), ds1FDL(170), pos(171), dvbAsiIn(172), dvbAsiOut(173), plc(174), nfas(175), tr008(176), gr303RDT(177), gr303IDT(178), isup(179), propDocsWirelessMaclayer(180), propDocsWirelessDownstream(181), propDocsWirelessUpstream(182), hiperlan2(183), propBWAp2Mp(184), sonetOverheadChannel(185), digitalWrapperOverheadChannel(186), aal2(187), radioMAC(188), atmRadio(189), imt(190), mvl(191), reachDSL(192), frDlciEndPt(193), atmVciEndPt(194), opticalChannel(195), opticalTransport(196), propAtm(197), voiceOverCable(198), infiniband(199), teLink(200), q2931(201), virtualTg(202), sipTg(203), sipSig(204), docsCableUpstreamChannel(205), econet(206), pon155(207), pon622(208), bridge(209), linegroup(210), voiceEMFGD(211), voiceFGDEANA(212), voiceDID(213), mpegTransport(214), sixToFour(215), gtp(216), pdnEtherLoop1(217), pdnEtherLoop2(218), opticalChannelGroup(219), homepna(220), gfp(221), ciscoISLvlan(222), actelisMetaLOOP(223), fcipLink(224) * * Its syntax is IANAifType (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 ifType data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ifType_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 */intifType_get(ifTable_rowreq_ctx * rowreq_ctx, u_long * ifType_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != ifType_val_ptr);    DEBUGMSGTL(("verbose:ifTable:ifType_get", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:231:o: |-> Extract the current value of the ifType data.     * copy (* ifType_val_ptr ) from rowreq_ctx->data     */    (*ifType_val_ptr) = rowreq_ctx->data.ifType;    return MFD_SUCCESS;}                               /* ifType_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifMtu * ifMtu is subid 4 of ifEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.4 * Description:The size of the largest packet which can be sent/received            on the interface, specified in octets.  For interfaces that            are used for transmitting network datagrams, this is the            size of the largest network datagram that can be sent on the            interface. * * Attributes: *   accessible 1     isscalar 0     enums  0      hasdefval 0 *   readable   1     iscolumn 1     ranges 0      hashint   0 *   settable   0 * * * Its syntax is INTEGER32 (based on perltype INTEGER32) * The net-snmp type is ASN_INTEGER. The C type decl is long (long) *//** * Extract the current value of the ifMtu data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ifMtu_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 */intifMtu_get(ifTable_rowreq_ctx * rowreq_ctx, long *ifMtu_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != ifMtu_val_ptr);    DEBUGMSGTL(("verbose:ifTable:ifMtu_get", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:231:o: |-> Extract the current value of the ifMtu data.     * copy (* ifMtu_val_ptr ) from rowreq_ctx->data     */    (*ifMtu_val_ptr) = rowreq_ctx->data.ifMtu;    return MFD_SUCCESS;}                               /* ifMtu_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifSpeed * ifSpeed is subid 5 of ifEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.5 * Description:An estimate of the interface's current bandwidth in bits            per second.  For interfaces which do not vary in bandwidth            or for those where no accurate estimation can be made, this            object should contain the nominal bandwidth.  If the            bandwidth of the interface is greater than the maximum value            reportable by this object then this object should report its            maximum value (4,294,967,295) and ifHighSpeed must be used            to report the interace's speed.  For a sub-layer which has            no concept of bandwidth, this object should be zero. * * Attributes: *   accessible 1     isscalar 0     enums  0      hasdefval 0 *   readable   1     iscolumn 1     ranges 0      hashint   0 *   settable   0 * * * Its syntax is GAUGE (based on perltype GAUGE) * The net-snmp type is ASN_GAUGE. The C type decl is u_long (u_long) *//** * Extract the current value of the ifSpeed data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ifSpeed_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 */intifSpeed_get(ifTable_rowreq_ctx * rowreq_ctx, u_long * ifSpeed_val_ptr){   /** we should have a non-NULL pointer */    netsnmp_assert(NULL != ifSpeed_val_ptr);    DEBUGMSGTL(("verbose:ifTable:ifSpeed_get", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    /*     * TODO:231:o: |-> Extract the current value of the ifSpeed data.     * copy (* ifSpeed_val_ptr ) from rowreq_ctx->data     */    (*ifSpeed_val_ptr) = rowreq_ctx->data.ifSpeed;    return MFD_SUCCESS;}                               /* ifSpeed_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifPhysAddress * ifPhysAddress is subid 6 of ifEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.6 * Description:The interface's address at its protocol sub-layer.  For            example, for an 802.x interface, this object normally            contains a MAC address.  The interface's media-specific MIB            must define the bit and byte ordering and the format of the            value of this object.  For interfaces which do not have such            an address (e.g., a serial line), this object should contain            an octet string of zero length. * * Attributes: *   accessible 1     isscalar 0     enums  0      hasdefval 0 *   readable   1     iscolumn 1     ranges 0      hashint   1 *   settable   0 *   hint: 1x: * * * Its syntax is PhysAddress (based on perltype OCTETSTR) * The net-snmp type is ASN_OCTET_STR. The C type decl is char (char) * This data type requires a length.  (Max 255) *//** * Extract the current value of the ifPhysAddress data. * * Set a value using the data context for the row. * * @param rowreq_ctx *        Pointer to the row request context. * @param ifPhysAddress_val_ptr_ptr *        Pointer to storage for a char variable * @param ifPhysAddress_val_ptr_len_ptr *        Pointer to a size_t. On entry, it will contain the size (in bytes) *        pointed to by ifPhysAddress. *        On exit, this value should contain the data size (in bytes). * * @retval MFD_SUCCESS         : success * @retval MFD_SKIP            : skip this node (no value for now) * @retval MFD_ERROR           : Any other error* * @note If you need more than (*ifPhysAddress_val_ptr_len_ptr) bytes of memory, *       allocate it using malloc() and update ifPhysAddress_val_ptr_ptr. *       <b>DO NOT</b> free the previous pointer. *       The MFD helper will release the memory you allocate. * * @remark If you call this function yourself, you are responsible *         for checking if the pointer changed, and freeing any *         previously allocated memory. (Not necessary if you pass *         in a pointer to static memory, obviously.) */intifPhysAddress_get(ifTable_rowreq_ctx * rowreq_ctx,                  char **ifPhysAddress_val_ptr_ptr,                  size_t * ifPhysAddress_val_ptr_len_ptr){   /** we should have a non-NULL pointer and enough storage */    netsnmp_assert((NULL != ifPhysAddress_val_ptr_ptr)                   && (NULL != *ifPhysAddress_val_ptr_ptr));    netsnmp_assert(NULL != ifPhysAddress_val_ptr_len_ptr);    DEBUGMSGTL(("verbose:ifTable:ifPhysAddress_get", "called\n"));    netsnmp_assert(NULL != rowreq_ctx);    if ((rowreq_ctx->data.ifPhysAddress[0] == 0) &&        (rowreq_ctx->data.ifPhysAddress[1] == 0) &&        (rowreq_ctx->data.ifPhysAddress[2] == 0) &&        (rowreq_ctx->data.ifPhysAddress[3] == 0) &&        (rowreq_ctx->data.ifPhysAddress[4] == 0) &&        (rowreq_ctx->data.ifPhysAddress[5] == 0)) {        /*         * all 0s = empty string         */        (*ifPhysAddress_val_ptr_len_ptr) = 0;        return MFD_SUCCESS;    }    /*

⌨️ 快捷键说明

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