📄 snmpip.c
字号:
break; default: errorStatus = GEN_ERR; goto errorReturn; } testproc_good (pktp, vbp); } return;errorReturn: testproc_error (pktp, vbp, errorStatus); return; } /******************************************************************************* ipGet - Get method routine for ip group scalars** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <compc> - count of components remaining in the unmatched portion i.e.* the length of the instance portion.* <compl> - 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.** NOMANUAL** RETURN: N/A** **/ void ipGet ( OIDC_T lastmatch, int compc, OIDC_T * compl, SNMP_PKT_T * pktp, VB_T * vbp ) { M2_IP ipVars; snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl); if ((compc != 1) || (*compl != 0)) { /* Instance does not exist */ for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_nosuchins (pktp, vbp); } return; } if (m2IpGroupInfoGet (&ipVars) != OK) { for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_error (pktp, vbp, GEN_ERR); } return; } for ( ; vbp; vbp = vbp->vb_link) { switch (vbp->vb_ml.ml_last_match) { case LEAF_ipForwarding: getproc_got_int32 (pktp, vbp, (INT_32_T)ipVars.ipForwarding); break; case LEAF_ipDefaultTTL: getproc_got_int32 (pktp, vbp, min(IP_MAX_TTL, (INT_32_T)ipVars.ipDefaultTTL)); break; case LEAF_ipInReceives: getproc_got_uint32 (pktp, vbp, ipVars.ipInReceives, VT_COUNTER); break; case LEAF_ipInHdrErrors: getproc_got_uint32 (pktp, vbp, ipVars.ipInHdrErrors, VT_COUNTER); break; case LEAF_ipInAddrErrors: getproc_got_uint32 (pktp, vbp, ipVars.ipInAddrErrors, VT_COUNTER); break; case LEAF_ipForwDatagrams: getproc_got_uint32 (pktp, vbp, ipVars.ipForwDatagrams, VT_COUNTER); break; case LEAF_ipInUnknownProtos: getproc_got_uint32 (pktp, vbp, ipVars.ipInUnknownProtos, VT_COUNTER); break; case LEAF_ipInDiscards: getproc_got_uint32 (pktp, vbp, ipVars.ipInDiscards, VT_COUNTER); break; case LEAF_ipInDelivers: getproc_got_uint32 (pktp, vbp, ipVars.ipInDelivers, VT_COUNTER); break; case LEAF_ipOutRequests: getproc_got_uint32 (pktp, vbp, ipVars.ipOutRequests, VT_COUNTER); break; case LEAF_ipOutDiscards: getproc_got_uint32 (pktp, vbp, ipVars.ipOutDiscards, VT_COUNTER); break; case LEAF_ipOutNoRoutes: getproc_got_uint32 (pktp, vbp, ipVars.ipOutNoRoutes, VT_COUNTER); break; case LEAF_ipReasmTimeout: getproc_got_int32 (pktp, vbp, (INT_32_T)ipVars.ipReasmTimeout); break; case LEAF_ipReasmReqds: getproc_got_uint32 (pktp, vbp, ipVars.ipReasmReqds, VT_COUNTER); break; case LEAF_ipReasmOKs: getproc_got_uint32 (pktp, vbp, ipVars.ipReasmOKs, VT_COUNTER); break; case LEAF_ipReasmFails: getproc_got_uint32 (pktp, vbp, ipVars.ipReasmFails, VT_COUNTER); break; case LEAF_ipFragOKs: getproc_got_uint32 (pktp, vbp, ipVars.ipFragOKs, VT_COUNTER); break; case LEAF_ipFragFails: getproc_got_uint32 (pktp, vbp, ipVars.ipFragFails, VT_COUNTER); break; case LEAF_ipFragCreates: getproc_got_uint32 (pktp, vbp, ipVars.ipFragCreates, VT_COUNTER); break; case LEAF_ipRoutingDiscards: getproc_got_uint32 (pktp, vbp, ipVars.ipRoutingDiscards, VT_COUNTER); break; default: getproc_error (pktp, vbp, GEN_ERR); break; } } } /******************************************************************************* ipAddrEntryGet** Get method routine for ip addresses table** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <compc> - count of components remaining in the unmatched portion i.e.* the length of the instance portion.* <compl> - 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.** NOMANUAL** RETURN: N/A**/ void ipAddrEntryGet ( OIDC_T lastmatch, int compc, OIDC_T * compl, SNMP_PKT_T * pktp, VB_T * vbp ) { M2_IPADDRTBL ipAddrEntry; memset (&ipAddrEntry, 0, sizeof ipAddrEntry); snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl); if ( (compc != IP_ADDR_LEN) || snmpOidToIpHostOrder (IP_ADDR_LEN, compl, &ipAddrEntry.ipAdEntAddr) || m2IpAddrTblEntryGet (M2_EXACT_VALUE, &ipAddrEntry) != OK) { for ( ; vbp != NULL; vbp = vbp->vb_link) { getproc_nosuchins (pktp, vbp); } return; } for ( ; vbp; vbp = vbp->vb_link) { ipAddrEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &ipAddrEntry); } } /******************************************************************************* ipAddrEntryInfoGet _ Extract ip addr table info from M2_IPADDRTBL struct.** 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.* <pIpAddrEntry> - ptr to ip address table struct containing the reqd info.* NOMANUAL** RETURNS: N/A*/ LOCAL void ipAddrEntryInfoGet ( OIDC_T lastmatch, SNMP_PKT_T * pktp, VB_T * vbp, M2_IPADDRTBL * pIpAddrEntry ) { switch (lastmatch) { case LEAF_ipAdEntAddr: getproc_got_ip_address (pktp, vbp, htonl (pIpAddrEntry->ipAdEntAddr)); return; case LEAF_ipAdEntIfIndex: getproc_got_int32 (pktp, vbp, (INT_32_T)pIpAddrEntry->ipAdEntIfIndex); return; case LEAF_ipAdEntNetMask: getproc_got_ip_address (pktp, vbp, htonl (pIpAddrEntry->ipAdEntNetMask)); return; case LEAF_ipAdEntBcastAddr: getproc_got_int32 (pktp, vbp, (INT_32_T) pIpAddrEntry->ipAdEntBcastAddr); return; case LEAF_ipAdEntReasmMaxSize: getproc_got_int32 (pktp, vbp, (INT_32_T) pIpAddrEntry->ipAdEntReasmMaxSize); return; default: getproc_error (pktp, vbp, GEN_ERR); return; } } /******************************************************************************* ipAddrEntryNext - Next method routine for ip addresses table** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <compc> - count of components remaining in the unmatched portion i.e.* the length of the instance portion.* <compl> - 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.** NOMANUAL** RETURNS: N/A*/ void ipAddrEntryNext ( OIDC_T lastmatch, int compc, OIDC_T * compl, SNMP_PKT_T * pktp, VB_T * vbp ) { OIDC_T addr [IP_ADDR_LEN]; /* ip address */ M2_IPADDRTBL ipAddrEntry; memset (&ipAddrEntry, 0, sizeof ipAddrEntry); snmpdGroupByGetprocAndInstance (pktp, vbp, compc, compl); /* Increment instance part by 1 */ if (snmpNextIndex (compc, compl, addr, maxIpAddr, IP_ADDR_LEN)) { /* instance part was already no less than max possible index */ for ( ; vbp != NULL; vbp = vbp->vb_link) { nextproc_no_next (pktp, vbp); } return; } /* get ip address for indexing into the table */ snmpOidToIpHostOrder (IP_ADDR_LEN, addr, &ipAddrEntry.ipAdEntAddr); if (m2IpAddrTblEntryGet (M2_NEXT_VALUE, &ipAddrEntry) != OK) { for ( ; vbp != NULL; vbp = vbp->vb_link) { snmpNextError (pktp, vbp); } return; } /* Convert ip address to oid form for transmission */ (void)ip_to_rlist ( htonl (ipAddrEntry.ipAdEntAddr), addr); for ( ; vbp; vbp = vbp->vb_link) { /* Install instance part for next value found */ nextproc_next_instance (pktp, vbp, IP_ADDR_LEN, addr); /* Install the next value */ ipAddrEntryInfoGet (vbp->vb_ml.ml_last_match, pktp, vbp, &ipAddrEntry); } } /******************************************************************************* ipNetToMediaEntryInfoGet - Routine to extract net to media table info from m2 structure.** 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.* <pNetMediaEntry> - ptr to net media entry struct containing the reqd info.* * NOMANUAL** RETURNS: N/A*/ LOCAL void ipNetToMediaEntryInfoGet ( OIDC_T lastmatch, SNMP_PKT_T * pktp, VB_T * vbp, M2_IPATRANSTBL * pNetMediaEntry ) { int length; uchar_t * pBuf; switch (lastmatch) { case LEAF_ipNetToMediaIfIndex: getproc_got_int32 (pktp, vbp, (INT_32_T)pNetMediaEntry->ipNetToMediaIfIndex); return; case LEAF_ipNetToMediaPhysAddress: length = pNetMediaEntry->ipNetToMediaPhysAddress.addrLength; pBuf = snmpdMemoryAlloc (length); if (pBuf == NULL) { getproc_error (pktp, vbp, GEN_ERR); return; } memcpy (pBuf, pNetMediaEntry->ipNetToMediaPhysAddress.phyAddress, length); getproc_got_string (pktp, vbp, length, (OCTET_T *) pBuf, BFL_IS_DYNAMIC, VT_STRING); return; case LEAF_ipNetToMediaNetAddress: getproc_got_ip_address (pktp, vbp, htonl (pNetMediaEntry->ipNetToMediaNetAddress)); return; case LEAF_ipNetToMediaType: getproc_got_int32 (pktp, vbp, (INT_32_T)pNetMediaEntry->ipNetToMediaType); return; default: getproc_error (pktp, vbp, GEN_ERR); return; } } /******************************************************************************* ipNetToMediaEntryTest - Test method routine for netToMedia table ** Parameters to this routine are * * <lastmatch> - the last oid component that was matched to get to this leaf.* <compc> - count of components remaining in the unmatched portion i.e.* the length of the instance portion.* <compl> - 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.** NOMANUAL** RETURNS: N/A*/void ipNetToMediaEntryTest ( OIDC_T lastmatch, int compc, OIDC_T * compl, SNMP_PKT_T * pktp, VB_T * vbp ) { M2_IPATRANSTBL * pNetMediaEntry; INT_32_T errorStatus; unsigned long addr; BOOL physAddrFlag = FALSE; BOOL entryExists = TRUE; VB_T * pVbpSaved = vbp; int length; /* get undo buffer for existing entry */ vbp->vb_priv = snmpdMemoryAlloc (sizeof (M2_IPATRANSTBL)); pNetMediaEntry = (M2_IPATRANSTBL *) vbp->vb_priv; if (pNetMediaEntry == NULL) { errorStatus = RESOURCE_UNAVAILABLE; goto errorReturn; } else { /* callback for freeing undo buffer */ vbp->vb_free_priv = (VBPRIVPROC_T *) snmpVbPrivFree; } /* get the ip address part of the index */ if ((compc != IP_NET_TO_MEDIA_INDEX_LEN ) || snmpOidToIpHostOrder (IP_ADDR_LEN, compl + 1, &pNetMediaEntry-> ipNetToMediaNetAddress)) { errorStatus = NO_SUCH_NAME; goto errorReturn; } /* get interface index part of the index */ pNetMediaEntry->ipNetToMediaIfIndex = *compl; if (m2IpAtransTblEntryGet (M2_EXACT_VALUE, pNetMediaEntry) != OK) { /* new row is being created so undo action is to delete it */ pNetMediaEntry->ipNetToMediaType = M2_ipNetToMediaType_invalid;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -