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

📄 mibip.c

📁 VxWorks操作系统下的SNMP协议以及MIB协议的实现源码,并且实现了HP标准打印类的MIB框架.
💻 C
字号:

#include "VxWorks.h"
#include "sockLib.h"
#include "inetLib.h"
#include "taskLib.h"
#include "stdioLib.h"
#include "strLib.h"
#include "ioLib.h"
#include "fioLib.h"

#include "snmp.h"
#include "Mib2Func.h"

//0x2b,6,1,2,1,2,4,x
int  IPGetVar(VARLIST *pVar)
{
	U32		u32Index;
	U32		u32GetFirstIndex;
	U32		u32GetIndex;

	MibFuncPara para;

	switch(pVar->oid[6])
	{
		case 1://IpForwarding
		case 2://IpDefaultTTL
		case 3://ipInReceives
		case 4://ipInHdrErrors
		case 5://ipInAddrErrors
		case 6://ipForwDatagrams
		case 7://ipInUnknownProtos
		case 8://ipInDiscards
		case 9://ipInDelivers
		case 10://ipOutRequests
		case 11://ipOutDiscards
		case 12://ipOutNoRoutes
		case 13://ipReasmTimeout
		case 14://ipReasmReqds
		case 15://ipReasmOKs
		case 16://ipReasmFails
		case 17://ipFragOKs
		case 18://ipFragFails
		case 19://ipFragCreates
		case 23://IpRoutingDiscards
			u32Index = pVar->oid[6];
			u32GetFirstIndex	= g_MFIndex.Ip.Get.Forwarding____________ps32GetValue;
			u32GetIndex = u32GetFirstIndex + u32Index - 1;				
			pVar->type = TAG_INTERGER;
			break;
			
		case 20://ipAddrTable
			if(pVar->oid[7] == 1)
			{
				u32Index = pVar->oid[8];
				u32GetFirstIndex =  g_MFIndex.Ip.Get.AdEntAddr_____________pcBuf_s32BufSize_ps32Used;
				u32GetIndex = u32GetFirstIndex + u32Index - 1;
				
				switch(pVar->oid[8])
				{
					case 1://ipAdEntAddr
					case 3://ipAdEntNetMask						
						pVar->type = TAG_OCTET;
						break;
						
					case 2://ipAdEntIfIndex
					case 4://ipAdEntBcastAddr
					case 5://ipAdEntReasmMaxSize
						pVar->type = TAG_INTERGER;
						break;
						
					default:
						return ERROR;
				}
			}
			break;
			
		case 21://ipRouteTable:
			if(pVar->oid[7] == 1)
			{
				u32Index = pVar->oid[8];
				u32GetFirstIndex =  g_MFIndex.Ip.Get.RouteDest_____________pcBuf_s32BufSize_ps32Used;
				u32GetIndex = u32GetFirstIndex + u32Index - 1;

				switch(pVar->oid[8])
				{
					case 2://ipRouteIfIndex
					case 3://ipRouteMetric1
					case 4://ipRouteMetric2
					case 5://ipRouteMetric3
					case 6://ipRouteMetric4
					case 8://ipRouteType
					case 9://ipRouteProto
					case 10://ipRouteAge
					case 12://ipRouteMetric5
						pVar->type = TAG_INTERGER;
						break;
						
					case 1://ipRouteDest
					case 7://ipRouteNextHop
					case 11://ipRouteMask
					case 13://ipRouteInfo
						pVar->type = TAG_OCTET;
						break;
						
					default:
						return ERROR;
				}
			}
			break;
			
		case 22://ipNetToMediaTable
			if(pVar->oid[7] == 1)
			{
				u32Index = pVar->oid[8];
				u32GetFirstIndex =  g_MFIndex.Ip.Get.NetToMediaIfIndex_____ps32GetValue;
				u32GetIndex = u32GetFirstIndex + u32Index - 1;

				switch(pVar->oid[8])
				{
					case 1://ipNetToMediaIfIndex
					case 4://ipNetToMediaType
						pVar->type = TAG_INTERGER;
						break;
						
					case 2://ipNetToMediaPhysAddres
					case 3://ipNetToMediaNetAddress
						pVar->type = TAG_OCTET;
						break;
						
					default:
						return ERROR;
				}
			}
			break;
			
		default:
			return ERROR;
	}
	
	if (OK != Mib2GetOne(u32GetIndex, &para))
	{
		return ERROR;
	}

	return Mib2Get(pVar, &para);
}

⌨️ 快捷键说明

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