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

📄 web.c

📁 采用ajax技术
💻 C
📖 第 1 页 / 共 4 页
字号:
			{
				GetResponse((char*)&buf,"kind","0");
				i = StrToInt(list[1].value);
				
				if(list[0].value[0]=='0')
					GetEquStates(buf,i);
				else
					GetEquTxRx(buf,i);
			}
				
			break;
		case 8://bandwidth.htm
		case 9://loopback.htm
		case 10://parameter.htm
		case 11://vcg.htm
		case 12://gfp.htm
		case 13://clock.htm
		case 14://error.htm
			if(strncmp((char*)list[0].name,"query",5)==0
				&& list[0].value[0]=='1') 
			{
				GetResponse((char*)&buf,"kind","0");
				i = StrToInt(list[1].value);
				GetEquConfig(buf,type,i);
			}
			else if(strncmp((char*)list[0].name,"setting",7)==0
				&& list[0].value[0]=='1') 
			{
				GetResponse((char*)&buf,"kind","2");
				temp[0] = 0xCA;
				temp[1]=type;
				SetStates(list,temp);
			}	
			
			break;
		case 15://Mac
			if(strcmp((char*)list[0].name,"mac")==0)
			{
				GetResponse((char*)&buf,"kind","2");
				GetMac((uint8 *)mGloablCfg.pLocalMAC,(uint8 *)list[0].value);
				i = strlen((char*)&buf);
				memcpy((char*)&buf[i],"</result>",9);
				send( tcpid,(uint8*)httpHeadXML ,strlen((char*)httpHeadXML), 0 );
				SendToClient((uint8*) buf,tcpid);
				DelayNS(20);
				web_MacSet();
			}
			else
				GetResponse((char*)&buf,"kind","0");
				
			GetNetInfo(buf);
			break;
		case 16://Restart
			GetResponse((char*)&buf,"kind","2");
			break;
		case 17://Mac
			GetResponse((char*)&buf,"kind","0");
			GetNetInfo(buf);
			break;
		case 18://vlantable.htm
		case 19://vlanconfig.htm
			if(strncmp((char*)list[0].name,"query",5)==0
				&& list[0].value[0]=='1') 
			{
				GetResponse((char*)&buf,"kind","0");
				i = StrToInt(list[1].value);
				
				if(type==18)
				{
					if(strncmp((char*)list[3].name,"pos",3)==0)
						pos=StrToInt((char*)list[3].value);
					
					page = pos==-1?StrToInt(list[2].value):1;
					GetVlanId(buf,i,page,pos);
				}
				else
					GetVlanList(buf,i);
			}
			else if(strncmp((char*)list[0].name,"setting",7)==0
				&& list[0].value[0]=='1') 
			{
				GetResponse((char*)&buf,"kind","3");
				GetResponse((char*)&buf,"alt","VLAN ID is exists!");
				temp[0] = 0xCA;
				temp[1]=type;
				SetStates(list,temp);
				
				i = StrToInt(list[1].value);
				pos=StrToInt((char*)list[3].value);
				GetVlanId(buf,i,1,pos);
			}	
			
			break;
		case 20://mask.htm
			i = StrToInt(list[1].value);
			
			if(strncmp((char*)list[0].name,"query",5)==0
				&& list[0].value[0]=='1') 
			{
				GetResponse((char*)&buf,"kind","0");
				IntToStr(pBox[i].eth_mask,(char*)temp);
				GetResponse((char*)&buf,"eth",(char*)temp);
				IntToStr(pBox[i].e1_mask,(char*)temp);
				GetResponse((char*)&buf,"e1",(char*)temp);
			}
			else if(strncmp((char*)list[0].name,"setting",7)==0
				&& list[0].value[0]=='1') 
			{
				pBox[i].eth_mask = StrToInt((char*)list[2].value);
				pBox[i].e1_mask = StrToInt((char*)list[3].value);
			}
						
			break;
		case 21://capability.htm
			i = StrToInt(list[1].value);
				
			if(strncmp((char*)list[0].name,"query",5)==0
				&& list[0].value[0]=='1') 
			{
				GetResponse((char*)&buf,"kind","0");
				GetPackets(buf,i);
			}
			else if(strncmp((char*)list[0].name,"setting",7)==0
				&& list[0].value[0]=='1') 
			{
				pos = StrToInt((char*)list[2].value);
				
				if(pos&1)
					memset((uint8 *)&packet[i][0],0,sizeof(packet_t));
				if((pos>>1)&1)
					memset((uint8 *)&e1_packet[i][0],0,16*sizeof(uint32));
			}
			
			break;
	}
	
	i = strlen((char*)&buf);
	memcpy((char*)&buf[i],"</result>",9);
	send( tcpid,(uint8*)httpHeadXML ,strlen((char*)httpHeadXML), 0 );
	SendToClient((uint8*) buf,tcpid);
}
/*************************************************************************
* 名称:SetLimitValue
* 函数原型:SetLimitValue(http *list)
* 功能:设置机框门限值
* 入口参数:list 设置值
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void SetLimitValue(http *list)
{
	int i = StrToInt(list[1].value);
	char msg[4][7]={"lmt01","lmt02","lmt11","lmt12"};
	char str[10] ={0};
	uint8 j,k,n,*pt,pos;
	
	for(j=0;j<4;j++)
	{
		for(k=2;k<6;k++)
		{
			if(strncmp(msg[j],list[k].name,5)==0)
			{
				pt = (uint8*)((j<2)?&pBox[i].temp[j%2+1][0]:&pBox[i].vol[j%2+1][0]);
				memset(str,0,10);
				
				for(n=0; n<strlen((char*)list[k].value); n++)
				{
					if(list[k].value[n]=='.') break;
					
					str[n] = list[k].value[n];
				}
				
				*pt = StrToInt(str);
				memset(str,0,10);
				pos=0;
				
				for( n=n+1; n<strlen((char*)list[k].value); n++)
				{
					str[pos++] = list[k].value[n];
				}
				
				pt++;
				*pt = StrToInt(str);
				break;
			}
		}
	}
}
/*************************************************************************
* 名称:SetStates
* 函数原型:SetStates(http *list,uint8* buf)
* 功能:设置机框状态
* 入口参数:list 设置值
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void SetStates(http *list,uint8* buf)
{
	switch(buf[1])
	{
		case 8://bandwidth.htm
		case 9://loopback.htm
		case 10://parameter.htm
		case 11://vcg.htm
		case 12://gfp.htm
		case 13://clock.htm
		case 14://error.htm
		case 18://vlantable.htm
		case 19://vlanconfig.htm
			break;
	}
}
/*************************************************************************
* 名称:GetPackets
* 函数原型:GetPackets(uint8 *buf,int i)
* 功能:查询统计数据
* 入口参数:
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void GetPackets(uint8 *buf,int i)
{
	char str[10]={0},name[3]={0};
	int j,k=strlen((char*)buf);
	uint32 *pt;
	memcpy(&buf[k],"<eth>",5);
	
	for(j=0;j<4;j++)
	{
		pt = (uint32 *)&packet[i][j].p_in;
		name[0]=j+'A';
		
		for(k=0;k<7;k++)
		{
			name[1]=k+'0';
			IntToStr(*pt,str);
			GetResponse((char*)buf,name,str);
			pt++;
		}
	}
	
	k=strlen((char*)buf);
	memcpy(&buf[k],"</eth><e1>",10);
	name[0] = 'F';
	pt = (uint32 *)&e1_packet[i][0];
	
	for(j=0;j<16;j++)
	{
		name[1]= j<10?j+'0':(j-10)+'A';
		IntToStr(*pt,str);
		GetResponse((char*)buf,name,str);
		pt++;
	}
	
	k=strlen((char*)buf);
	memcpy(&buf[k],"</e1>",5);

}
/*************************************************************************
* 名称:GetVlanList
* 函数原型:GetVlanList(uint8 *buf,int i)
* 功能:查询Ethernet List
* 入口参数:
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void GetVlanList(uint8 *buf,int i)
{
	int j,k,len;
	char temp[10]={0};
	
	for(j=VlanListPos[i];j<4;j++)
	{
		if(pVlanList[i][j].id)
		{
			IntToStr(pVlanList[i][j].id,temp);
			GetResponse((char*)&buf,"p",temp);	
			GetResponse((char*)&buf,"tag",pVlanList[i][j].tag);
			IntToStr(pVlanList[i][j].pri,temp);
			GetResponse((char*)&buf,"pri",temp);
			len=strlen((char*)buf);
			memcpy(&buf[len],"<id>",4);
			
			for(k=0;k<=4095	;k++)
			{
				if(strlen((char*)buf)>950) break;
				
				if((pVlan[i][k].member>>(pVlanList[i][j].id-1))&1)
				{
					IntToStr(pVlan[i][k].id,temp);
					len=strlen((char*)buf);
					memcpy(&buf[len],temp,strlen(temp));
					len=strlen((char*)buf);
					buf[len]=';';
				}
			}
			
			len=strlen((char*)buf);
			
			if(k<4095)
				memcpy(&buf[len],";...</id>",9);
			else
				memcpy(&buf[len],"</id>",5);
				
			VlanListPos[i] = j+1;
			break;	
		}	
	}
	
	if(j>=4)
	{
		GetResponse((char*)buf,"END","1");
	}
}
/*************************************************************************
* 名称:GetVlanId
* 函数原型:GetVlanId(uint8 *buf,int i)
* 功能:查询VLAN Table
* 入口参数:
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void GetVlanId(uint8 *buf,int i,int n,int pos)
{
	int j,page=20,counts=0;
	char temp[10]={0},str[50]={0};
	
	for(j=0;j<4095;j++)
		if(pVlan[i][j].member !=0) counts++;
		
	counts =4095;
	counts = counts%page?counts/page+1:counts/page;
	IntToStr(counts,str);
	GetResponse((char*)buf,"pages",str);
	IntToStr(n,str);
	GetResponse((char*)buf,"cur",str);
	n = n*page;
	counts =0;
	
	for(j=0;j<4095;j++)
	{
		if(pVlan[i][j].member !=0)
		{
			counts++;
			
			if((pos==-1 && counts>n-page && counts<=n )
				|| (pVlan[i][j].id==(pos-1)))
			{
				memset(str,0,50);
				IntToStr(pVlan[i][j].id,temp);
				GetResponse(str,"i",temp);
				IntToStr(pVlan[i][j].member&0x1f,temp);
				GetResponse(str,"e",temp);
				GetResponse((char*)buf,"v",str);
				
				if(j==(pos-1)) break;
			}
			else if(pos==-1 && counts>n)
				break;
		}
	}
	
	if(strlen(str)==0)
	{
		n = strlen((char*)buf);
		memcpy(&buf[n],"<v><i></i><e></e></v>",21);
	}
}
/*************************************************************************
* 名称:GetEquConfig
* 函数原型:GetEquConfig(uint8 *buf,int i)
* 功能:查询设备配置
* 入口参数:
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void GetEquConfig(uint8 *buf,int type,int i)
{
	char temp[10] = {0},name[10]={0};
	int j;
	uint32 value;
	
	if(type==8)
	{
		value = pBox[i].bandwidth;
		strcpy(name,"bw");
	}
	else if(type==9)
	{
		value = pBox[i].loop;
		strcpy(name,"lp");
	}
	else if(type==10)
	{
		for(j=0;j<4;j++)
		{
			IntToStr(pBox[i].ethernet[j],temp);
			strcpy(name,"eth");
			name[3] = j+'0';
			GetResponse((char*)buf,name,temp);
		}
		
		return;
	}
	else if(type==11)
	{
		value = pBox[i].vcg;
		strcpy(name,"vcg");
	}
	else if(type==12)
	{
		value = pBox[i].gfp;
		strcpy(name,"gfp");
	}
	else if(type==13)
	{
		value = pBox[i].clock;
		strcpy(name,"clk");
	}
	else if(type==14)
	{
		value = pBox[i].err;
		strcpy(name,"err");
	}
	
	IntToStr(value,temp);
	GetResponse((char*)buf,name,temp);
	
}
/*************************************************************************
* 名称:GetEquStates
* 函数原型:GetEquStates(uint8 *buf,int i)
* 功能:查询设备状态
* 入口参数:
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void GetEquStates(uint8 *buf,int i)
{
	char str[10] ={0},name[4]={'r',0,0,0};
	int j,n;
	uint16 *p,value;
	GetResponse((char*)buf,"r1",(char*)mGlobalInf.sSysLocation);
	GetResponse((char*)buf,"r2","NE2048B16N");
	
	for(j=0;j<3;j++)
	{
		ValueToStr((uint8*)&pBox[i].temp[j],str);
		name[1] = '3' + j;
		GetResponse((char*)buf,name,str);
		ValueToStr((uint8*)&pBox[i].vol[j],str);
		name[1] = '6' + j;
		GetResponse((char*)buf,name,str);
	}
	
	IntToStr(pBox[i].global,str);
	name[1] = '9' ;
	GetResponse((char*)buf,name,str);
	IntToStr(pBox[i].vcr_del,str);
	name[1] = '1' ;
	name[2] = '0' ;
	GetResponse((char*)buf,name,str);
	
	p = (uint16*)&pBox[i].e1_mask;
	
	for(j=1; j<10; j++)
	{
		value = *p;
		
		for(n=0;n<16 && j>1;n++)
		{
			if((pBox[i].e1_mask>>n)&1)
				value &= ~(1<<n);
		}
		
		IntToStr(value,str);
		name[2] = j+'0' ;
		GetResponse((char*)buf,name,str);
		p++;
	}
	
	memset(name,0,4);
	
	for(j=0; j<4; j++)
	{
		IntToStr(pBox[i].ethernet[j],str);
		name[0] = 'e' ;
		name[1] = j+'0' ;
		GetResponse((char*)buf,name,str);
	}
	
}
/*************************************************************************
* 名称:GetEquTxRx
* 函数原型:GetEquTxRx(uint8 *buf,int i)
* 功能:查询设备状态
* 入口参数:
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void GetEquTxRx(uint8 *buf,int i)
{
	char str[10] ={0},name[4]={'r',0,0,0};
	int j;
	
	for(j=0;j<16;j++)
	{
		IntToStr(pBox[i].tx_sq[j],str);
		name[1] = '2';
		name[2] = j<10?'0'+j:'A'+j-10;
		GetResponse((char*)buf,name,str)
		;
		IntToStr(pBox[i].tx_ctrl[j],str);
		name[1] = '3';
		name[2] = j<10?'0'+j:'A'+j-10;
		GetResponse((char*)buf,name,str);
		
		IntToStr(pBox[i].rx_sq[j],str);
		name[1] = '4';
		name[2] = j<10?'0'+j:'A'+j-10;
		GetResponse((char*)buf,name,str);
		
		IntToStr(pBox[i].rx_ctrl[j],str);
		name[1] = '5';
		name[2] = j<10?'0'+j:'A'+j-10;
		GetResponse((char*)buf,name,str);
	}
}
/*************************************************************************
* 名称:GetTemp
* 函数原型:GetTemp(signed char t,char *buf)
* 功能:获取温度字符串
* 入口参数:
*
* 出口参数:
* 使用说明:
* 创建日期:
* 作者:Henry
**************************************************************************/
void GetTemp(uint8 t,char *buf)
{
	uint8 ch[10],i=0;
	memset(buf,0,10);
	
	if(t >=128)
	{
		buf[0] = '-';
		t -= 128;
		i=1;

⌨️ 快捷键说明

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