📄 snmpif.c
字号:
return; case LEAF_ifOutErrors: getproc_got_uint32 (pktp, vbp, pIfEntry->ifOutErrors, VT_COUNTER); return; case LEAF_ifOutQLen: getproc_got_uint32 (pktp, vbp, pIfEntry->ifOutQLen, VT_GAUGE); return; case LEAF_ifSpecific: getproc_got_object_id (pktp, vbp, pIfEntry->ifSpecific.idLength, (OIDC_T*) pIfEntry->ifSpecific.idArray, 0); return; default: getproc_error (pktp, vbp, GEN_ERR); return; } }/******************************************************************************* ifXEntryGet ** Get method routine for interfaces group tabular variables.** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <tcount> - count of components remaining in the unmatched portion i.e.* the length of the instance portion.* <tlist> - ptr to the oid sequence remaining, i.e. the instance portion.* <pktp> - ptr to internal representation of the snmp pkt.* <vbp> - ptr to var bind being processed.** RETURNS: N/A*/ void ifXEntryGet ( OIDC_T lastmatch, int tcount, OIDC_T * tlist, SNMP_PKT_T * pktp, VB_T * vbp ) { M2_DATA ifData; /* Group together all varbinds which have the same getproc and instance */ snmpdGroupByGetprocAndInstance(pktp, vbp, tcount, tlist); if (tcount != 1) { for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_nosuchins (pktp, vbp); } return; } /* Extract the interface index for indexing into the interface table */ ifData.mibIfTbl.ifIndex = *tlist; /* Support for non ip interfaces: Your code to test the value of ifIndex * could go in here. Based on the value, you should decide wether to index * into the ip or the non ip interface tables. If ifIndex > maxIpIf then the * m2IfTblEntryGet routine should be bypassed and the search should be carried * out in the non ip interface table. */ if (m2IfTblEntryGet (M2_EXACT_VALUE, &ifData) != OK) { for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_nosuchins (pktp, vbp); } return; } for ( ; vbp; vbp = vbp->vb_link) { ifXEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &ifData); } }/******************************************************************************* ifEntryXNext** Next method routine for interfaces group tabular variables.** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <tcount> - count of components remaining in the unmatched portion i.e.* the length of the instance portion.* <tlist> - ptr to the oid sequence remaining, i.e. the instance portion.* <pktp> - ptr to internal representation of the snmp pkt.* <vbp> - ptr to var bind being processed.*** RETURNS: N/A* */ void ifXEntryNext ( OIDC_T lastmatch, int tcount, OIDC_T * tlist, SNMP_PKT_T * pktp, VB_T * vbp ) { OIDC_T ifIndex [IF_INDEX_LEN]; /* Oid sequence for interface index */ M2_DATA ifData; /* Group together all varbinds which have the same getproc and instance */ snmpdGroupByGetprocAndInstance (pktp, vbp, tcount, tlist); *ifIndex = (tlist != NULL) ? *tlist : 0;#if 0 /* This is the way we normally process a next request for a table entry. However in the case of the interfaces table using the M2_NEXT_VALUE flag with m2IfTblEntryGet returns the instance which is lexi greater than the argument while other m2 functions return the lexi greater *or equal* value. Therefore we bypass the increment of the index in this case. Ideally the m2IfTblEntryGet should be changed to be consistent but that could break existing code. */ if (snmpNextIndex (tcount, tlist, ifIndex, maxIfIndex, IF_INDEX_LEN)) { for ( ; vbp != NULL; vbp = vbp->vb_link) { nextproc_no_next (pktp, vbp); } return; }#endif ifData.mibIfTbl.ifIndex = *ifIndex; if (m2IfTblEntryGet (M2_NEXT_VALUE, &ifData) != OK) { for ( ; vbp != NULL; vbp = vbp->vb_link) { nextproc_no_next (pktp, vbp); } return; } /* Create oid sequence for interface index retrieved */ *ifIndex = ifData.mibIfTbl.ifIndex; for ( ; vbp; vbp = vbp->vb_link) { /* install instance part of next instance found */ nextproc_next_instance (pktp, vbp, IF_INDEX_LEN, ifIndex); ifXEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &ifData); } }/**************************************************************************** ifXEntryInfoGet** Routine for extracting info interface group table entries,* from the corresponding M2_INTERFACETBL.** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <pktp> - ptr to internal representation of the snmp pkt.* <vbp> - ptr to var bind being processed.* <pIfEntry> - pointer to structure containing interface info.*** RETURNS: N/A*/LOCAL void ifXEntryInfoGet ( OIDC_T lastmatch, SNMP_PKT_T * pktp, VB_T * vbp, M2_DATA * pIfData ) { M2_2233TBL * pIfXEntry = &pIfData->mibXIfTbl; switch (lastmatch) { case LEAF_ifName: getproc_got_string(pktp, vbp, strlen(pIfXEntry->ifName), (OCTET_T *) pIfXEntry->ifName, 0, VT_STRING); return; case LEAF_ifInMulticastPkts: getproc_got_uint32(pktp, vbp, pIfXEntry->ifInMulticastPkts, VT_COUNTER); return; case LEAF_ifInBroadcastPkts: getproc_got_uint32(pktp, vbp, pIfXEntry->ifInBroadcastPkts, VT_COUNTER); return; case LEAF_ifOutMulticastPkts: getproc_got_uint32(pktp, vbp, pIfXEntry->ifOutMulticastPkts, VT_COUNTER); return; case LEAF_ifOutBroadcastPkts: getproc_got_uint32(pktp, vbp, pIfXEntry->ifOutBroadcastPkts, VT_COUNTER); return; case LEAF_ifHCInOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCInOctets)); return; case LEAF_ifHCInUcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCInUcastPkts)); return; case LEAF_ifHCInMulticastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCInMulticastPkts)); return; case LEAF_ifHCInBroadcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCInBroadcastPkts)); return; case LEAF_ifHCOutOctets: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCOutOctets)); return; case LEAF_ifHCOutUcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCOutUcastPkts)); return; case LEAF_ifHCOutMulticastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCOutMulticastPkts)); return; case LEAF_ifHCOutBroadcastPkts: getproc_got_uint64(pktp, vbp, (UINT_64_T *)&(pIfXEntry->ifHCOutBroadcastPkts)); return; case LEAF_ifLinkUpDownTrapEnable: /* Values: * enabled(1) = VAL_ifLinkUpDownTrapEnable_enabled * disabled(2) = VAL_ifLinkUpDownTrapEnable_disabled */ getproc_got_int32(pktp, vbp, (INT_32_T)pIfXEntry->ifLinkUpDownTrapEnable); return; case LEAF_ifHighSpeed: getproc_got_uint32(pktp, vbp, pIfXEntry->ifHighSpeed, VT_GAUGE); return; case LEAF_ifPromiscuousMode: /* Values: * true(1) = VAL_ifPromiscuousMode_true * false(2) = VAL_ifPromiscuousMode_false */ getproc_got_int32(pktp, vbp, pIfXEntry->ifPromiscuousMode); return; case LEAF_ifConnectorPresent: /* Values: * true(1) = VAL_ifConnectorPresent_true * false(2) = VAL_ifConnectorPresent_false */ getproc_got_int32(pktp, vbp, pIfXEntry->ifConnectorPresent); return; case LEAF_ifAlias: getproc_got_string(pktp, vbp, strlen(pIfXEntry->ifAlias), (OCTET_T *) pIfXEntry->ifAlias, 0, VT_STRING); return; case LEAF_ifCounterDiscontinuityTime: getproc_got_uint32(pktp, vbp, pIfXEntry->ifCounterDiscontinuityTime, VT_TIMETICKS); return; default: getproc_error (pktp, vbp, GEN_ERR); return; } }/* * Method routines for the ifStackTable: * * ifStackHigherLayer -- not-accessible * The value of ifIndex corresponding to the higher * sub-layer of the relationship, i.e., the sub-layer * which runs on 'top' of the sub-layer identified by the * corresponding instance of ifStackLowerLayer. If there * is no higher sub-layer (below the internetwork layer), * then this object has the value 0. * * ifStackLowerLayer -- not-accessible * The value of ifIndex corresponding to the lower sub- * layer of the relationship, i.e., the sub-layer which * runs 'below' the sub-layer identified by the * corresponding instance of ifStackHigherLayer. If * there is no lower sub-layer, then this object has the * value 0. * * ifStackStatus -- read-create * The status of the relationship between two sub- * layers. * * Changing the value of this object from 'active' to * 'notInService' or 'destroy' will likely have * consequences up and down the interface stack. Thus, * write access to this object is likely to be * inappropriate for some types of interfaces, and many * implementations will choose not to support write- * access for any type of interface. */void ifStackEntryInfoGet ( OIDC_T lastmatch, SNMP_PKT_T * pktp, VB_T * vbp, M2_IFSTACKTBL * pData ) { switch(lastmatch) { case LEAF_ifStackStatus: getproc_got_int32(pktp, vbp, pData->status); break; default: getproc_error (pktp, vbp, GEN_ERR); return; } return; }/******************************************************************************* ifStackEntryGet ** Get method routine for interfaces group tabular variables.** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <tcount> - count of components remaining in the unmatched portion i.e.* the length of the instance portion.* <tlist> - ptr to the oid sequence remaining, i.e. the instance portion.* <pktp> - ptr to internal representation of the snmp pkt.* <vbp> - ptr to var bind being processed.** RETURNS: N/A*/void ifStackEntryGet ( OIDC_T lastmatch, int tcount, OIDC_T * tlist, SNMP_PKT_T * pktp, VB_T * vbp ) { int highIndex; M2_IFSTACKTBL ifStackData; /* Group together all varbinds which have the same getproc and instance */ snmpdGroupByGetprocAndInstance(pktp, vbp, tcount, tlist); if (tcount != IF_STACKTBL_INDEX_LEN) { for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_nosuchins (pktp, vbp); } return; } /* Extract the interface index for indexing into the interface table */ highIndex = *tlist; ifStackData.index = *(tlist + 1); /* Call the m2 API to get the status for this index */ if (m2IfStackEntryGet (M2_EXACT_VALUE, &highIndex, &ifStackData) != OK) { for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_nosuchins (pktp, vbp); } return; } for ( ; vbp; vbp = vbp->vb_link) { ifStackEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &ifStackData); } }/******************************************************************************* ifStackEntryNext** Next method routine for interfaces group tabular variables.** Parameters to this routine are
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -