📄 iftable.c
字号:
} } (*ifDescr_val_ptr_len_ptr) = tmp_len; memcpy((*ifDescr_val_ptr_ptr), tmp_descr, (*ifDescr_val_ptr_len_ptr) * sizeof((*ifDescr_val_ptr_ptr)[0])); 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. * set (* 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. * set (* 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. * set (* 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; } /* * TODO:231:o: |-> Extract the current value of the ifPhysAddress data. * set (* ifPhysAddress_val_ptr_ptr ) and (* ifPhysAddress_val_ptr_len_ptr ) from rowreq_ctx->data */ /* * make sure there is enough space for ifPhysAddress data */ if ((NULL == (*ifPhysAddress_val_ptr_ptr)) || ((*ifPhysAddress_val_ptr_len_ptr) < rowreq_ctx->data.ifPhysAddress_len)) { /* * allocate space for ifPhysAddress data */ (*ifPhysAddress_val_ptr_ptr) = malloc(rowreq_ctx->data.ifPhysAddress_len * sizeof((*ifPhysAddress_val_ptr_ptr)[0])); if (NULL == (*ifPhysAddress_val_ptr_ptr)) { snmp_log(LOG_ERR, "could not allocate memory\n"); return MFD_ERROR; } } (*ifPhysAddress_val_ptr_len_ptr) = rowreq_ctx->data.ifPhysAddress_len; memcpy((*ifPhysAddress_val_ptr_ptr), rowreq_ctx->data.ifPhysAddress, (*ifPhysAddress_val_ptr_len_ptr) * sizeof((*ifPhysAddress_val_ptr_ptr)[0])); return MFD_SUCCESS;} /* ifPhysAddress_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifAdminStatus * ifAdminStatus is subid 7 of ifEntry. * Its status is Current, and its access level is ReadWrite. * OID: .1.3.6.1.2.1.2.2.1.7 * Description:The desired state of the interface. The testing(3) state indicates that no operational packets can be passed. When a managed system initializes, all interfaces start with ifAdminStatus in the down(2) state. As a result of either explicit management action or per configuration information retained by the managed system, ifAdminStatus is then changed to either the up(1) or testing(3) states (or remains in the down(2) state). * * Attributes: * accessible 1 isscalar 0 enums 1 hasdefval 0 * readable 1 iscolumn 1 ranges 0 hashint 0 * settable 1 * * Enum range: 2/8. Values: up(1), down(2), testing(3) * * 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 ifAdminStatus data. * * Set a value using the data context for the row. * * @param rowreq_ctx * Pointer to the row request context. * @param ifAdminStatus_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 */intifAdminStatus_get(ifTable_rowreq_ctx * rowreq_ctx, u_long * ifAdminStatus_val_ptr){ /** we should have a non-NULL pointer */ netsnmp_assert(NULL != ifAdminStatus_val_ptr); DEBUGMSGTL(("verbose:ifTable:ifAdminStatus_get", "called\n")); netsnmp_assert(NULL != rowreq_ctx); /* * TODO:231:o: |-> Extract the current value of the ifAdminStatus data. * set (* ifAdminStatus_val_ptr ) from rowreq_ctx->data */ (*ifAdminStatus_val_ptr) = rowreq_ctx->data.ifAdminStatus; return MFD_SUCCESS;} /* ifAdminStatus_get *//*--------------------------------------------------------------------- * IF-MIB::ifEntry.ifOperStatus * ifOperStatus is subid 8 of ifEntry. * Its status is Current, and its access level is ReadOnly. * OID: .1.3.6.1.2.1.2.2.1.8 * Description:The current operational state of the interface. The testing(3) state indicates that no operational packets can be passed. If ifAdminStatus is down(2) then ifOperStatus should be down(2). If ifAdminStatus is changed to up(1) then ifOperStatus should change to up(1) if the interface is ready to transmit and receive network traffic; it should change to dormant(5) if the interface is waiting for external actions (such as a serial line waiting for an
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -