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

📄 snmp_ol100cr.c

📁 在freescale 的ne64上开发的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
#include "snmptype.h"
#include "snmpdef.h"
#include "snmp_ol100cr.h"
#include "msom_mac.h"
#include "datatypes.h"
#include "MOTTYPES.h"
#include "hw_api.h"
#include "stdio.h"
#include "cli_lib.h"

extern UINT8 localDTEType;
extern UINT8 localHWVersion;
extern UINT8 gSnmpRebootFlag;
extern UINT8 gSnmpPort1Flag;
extern UINT8 gSnmpPort2Flag;
extern UINT8 gSnmpFlowCtrlFlag1;
extern UINT8 gSnmpFlowCtrlFlag2;
extern void hwReboot();
extern void port_no_shutdown_cmd();
extern void port_shutdown_cmd();
extern UINT8 hwSetPortCfg(UINT8 port, UINT8 an, UINT8 dplx, UINT16 spd);
extern UINT8 locAutoCfg[];
extern UINT8 locDuplexCfg[];
extern UINT16 locSpeedCfg[];
extern UINT8 bSnmpFlowCtrl1;
extern UINT8 bSnmpFlowCtrl2;
extern void sys_cfg_save(void);
extern UINT8 device_descr[];

/**********************************************************************************
* ol100crLocDeviceInfo_Handler - This routine handles the objects of ol100cr local device info.
***********************************************************************************/
_INT16 ol100crLocDeviceInfo_Handler(_UINT8 request,void *ptr)
{
	UINT32 temp;
  UINT8 temp_u8;
	VB_T *vbp=(VB_T *)ptr;
	switch(*(vbp->pLeafId))
	{
		default:
			return GEN_ERR;
			break;

		/* ================================================================= */
		case LEAF_ol100crLocalType:    /*1  ,Scalar Object INTEGER, read-only */
		{
			
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				temp = localDTEType;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				return NOT_WRITABLE;
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalDeviceDescription:    /*1  ,Scalar Object INTEGER, read-only */
		{			
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:				
				octetSet(vbp,device_descr,strlen(device_descr));
				break;
			case SET_REQUEST_PDU:				
				if(strlen((UINT8 *)octetGet(vbp)) <= 15)
					strcpy(device_descr,(UINT8 *)octetGet(vbp));
				else
					return WRONG_LENGTH;
				break;
			}
			break;
		}
		
		/* ================================================================= */
		case LEAF_ol100crLocalReset:    /* 2 ,Scalar Object INTEGER, read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				Int32Set(vbp,0);
				break;
			case SET_REQUEST_PDU:
				if(Int32Get(vbp) != 0)
				{
					gSnmpRebootFlag = 1;
				}
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalHwVersion:    /*3  ,Scalar Object INTEGER, read-only */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				temp = localHWVersion;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				return NOT_WRITABLE;
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalSoftVersion:    /*3  ,Scalar Object INTEGER, read-only */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				octetSet(vbp,"V1.3",strlen("V1.3"));
				break;
			case SET_REQUEST_PDU:
				return NOT_WRITABLE;
				break;
			}
			break;
		}
		
		/* ================================================================= */
		case LEAF_ol100crLocalOamPort:    /*4  ,Scalar Object INTEGER, read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				{
				dot3ah_port_get(&temp_u8);
				temp = temp_u8;
				Int32Set(vbp,temp);
				}
				break;
			case SET_REQUEST_PDU:
				dot3ah_port_set((UINT8)Int32Get(vbp));
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalOamEnable:    /*5  ,Scalar Object INTEGER, read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				dot3ah_enable_get(&temp_u8);
				temp = temp_u8;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				dot3ah_enable_set((UINT8)Int32Get(vbp));
				break;
			}
			break;
		}
		
		/* ================================================================= */
		case LEAF_ol100crLocalLFP:    /*6  ,Scalar Object INTEGER, read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetLfp(&temp_u8);
				temp = temp_u8;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				hwSetLfp((UINT8)Int32Get(vbp));
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalFEF:    /*7  ,Scalar Object OCTET_STRING, read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetFef(&temp_u8);
				temp = temp_u8;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				hwSetFef((UINT8)Int32Get(vbp));
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalSaveCfg:    /* 8 ,Scalar Object INTEGER, read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				Int32Set(vbp,0);
				break;
			case SET_REQUEST_PDU:
				if(Int32Get(vbp) != 0)
				{
					sys_cfg_save();
				}
				break;
			}
			break;
		}

	}
	return(NO_ERROR);
}

/**********************************************************************************
* ValidateIndex_ol100crLocPortTableEntry - validate the index of ValidateIndex_ol100crLocPortTableEntry.
***********************************************************************************/
_INT16 ValidateIndex_ol100crLocPortTableEntry(_UINT8 request,VB_T *vbp)
{	
	return NO_ERROR;
}
/**********************************************************************************
* GetNextIndex_ol100crLocPortTableEntry - Get the next index of GetNextIndex_ol100crLocPortTableEntry.
***********************************************************************************/
_INT16 GetNextIndex_ol100crLocPortTableEntry(VB_T *vbp)
{
	if(vbp->vb_obj_id.num_components<=vbp->defined_prefix_len)
	{
		/*get the first index*/
		vbp->pIndex[0]=1;
		vbp->vb_obj_id.num_components=vbp->defined_prefix_len+vbp->defined_index_cnt;
		return NO_ERROR;
	}
	else
	{
		/*get the next index*/		
		if(vbp->pIndex[0]>=2)
		{
			(*(vbp->pLeafId))++;
			vbp->pIndex[0]=1;
			return NO_ERROR;
		}
		vbp->pIndex[0]++;
		vbp->vb_obj_id.num_components=vbp->defined_prefix_len+vbp->defined_index_cnt;
		return NO_ERROR;
	}
	return GEN_ERR;
}
/**********************************************************************************
* ol100crLocPortTableEntry_Handler - This routine handles the objects of ol100crLocPortTableEntry_Handler.
***********************************************************************************/
_INT16 ol100crLocPortTableEntry_Handler(_UINT8 request,void *ptr)
{  
	
	VB_T *vbp=(VB_T *)ptr;
	_UINT8 port;
	if(request==GET_NEXT_REQUEST_PDU)
	{ 		
		if(GetNextIndex_ol100crLocPortTableEntry(vbp)!=NO_ERROR)
		{
			return GEN_ERR;
		}
	}	
	if(ValidateIndex_ol100crLocPortTableEntry(request,vbp)!=NO_ERROR)
		return GEN_ERR;
	if(vbp->pIndex[0]==1)
		port=1;
	else if(vbp->pIndex[0]==2)
		port=2;
	else 
		return GEN_ERR;
	
	switch(*(vbp->pLeafId))
	{
		UINT32 temp,temp1,temp2;
		UINT16 temp_u16;
		UINT8 temp_u08,temp1_u08,temp2_u08,type;

		default:
			return GEN_ERR;
			break;

		/* ================================================================= */
		case LEAF_ol100crLocalPortIndex:    /* 1, Table Object INTEGER, read-only */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				Int32Set(vbp,vbp->pIndex[0]);
				break;
			case SET_REQUEST_PDU:
				return NOT_WRITABLE;
				break;
			}
			break;
		}

		/* ================================================================= */
		
		case LEAF_ol100crLocalPortStatus:    /* 2, Table Object INTEGER, read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetPortStat(port,&temp_u08);
				temp = temp_u08;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				if(Int32Get(vbp) != 0)
					hwSetPortStat(port, 1);
				else
					hwSetPortStat(port, 0);
				break;
			}
			break;
		}

		/* ================================================================= */
		
		case LEAF_ol100crLocalPortLinkStatus:    /* 3, Table Object INTEGER, read-only */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetPortLink(port,&temp_u08);
				temp = temp_u08;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				return NOT_WRITABLE;
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalPortSpeedStatus:    /* 4, Table Object INTEGER , read-only */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetPortDplxSpd(port,&temp_u08,&temp_u16);
				temp = temp_u16;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				return NOT_WRITABLE;
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalPortDuplexStatus:    /* 5, Table Object INTEGER , read-only */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetPortDplxSpd(port,&temp_u08,&temp_u16);
				temp = temp_u08;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				return NOT_WRITABLE;
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalPortSpeed:    /* 6, Table Object INTEGER , read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetPortCfg(port,&temp_u08,&temp1_u08,&temp_u16);
				temp = temp_u16;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				locSpeedCfg[port-1] = (UINT16)Int32Get(vbp);
				if(port ==1)
					gSnmpPort1Flag =1;
				else
					gSnmpPort2Flag =1;
				//hwSetPortCfg(port,locAutoCfg[port-1],locDuplexCfg[port-1],(UINT16)Int32Get(vbp));
				break;
			}
			break;
		}


		/* ================================================================= */
		case LEAF_ol100crLocalPortDuplex:    /*7, Table Object INTEGER , read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetPortCfg(port,&temp_u08,&temp1_u08,&temp_u16);
				temp = temp1_u08;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				locDuplexCfg[port-1] = (UINT8)Int32Get(vbp);
				if(port ==1)
					gSnmpPort1Flag =1;
				else
					gSnmpPort2Flag =1;
				//hwSetPortCfg(port,locAutoCfg[port-1],(UINT8)Int32Get(vbp),locSpeedCfg[port-1]);
				break;
			}
			break;
		}

		/* ================================================================= */
		case LEAF_ol100crLocalPortAN:    /* 8, Table Object INTEGER , read-write */
		{
			switch(request)
			{
			case GET_NEXT_REQUEST_PDU:/*do nothing*/
			case GET_REQUEST_PDU:
				hwGetPortCfg(port,&temp_u08,&temp1_u08,&temp_u16);
				temp = temp_u08;
				Int32Set(vbp,temp);
				break;
			case SET_REQUEST_PDU:
				locAutoCfg[port-1] = (UINT8)Int32Get(vbp);
				if(port ==1)
					gSnmpPort1Flag =1;
				else
					gSnmpPort2Flag =1;
				//hwSetPortCfg(port,(UINT8)Int32Get(vbp),locDuplexCfg[port-1],locSpeedCfg[port-1]);

⌨️ 快捷键说明

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