Exemple #1
0
/*****************************************************************
功能:初始化自动清扫
*****************************************************************/
void Init_Sweep(void)
{					 
    /******初始化显示***********/
    clr_display();
    Dis_On = TRUE;            //显示标志。
    Dis_PrOn = TRUE; 			//预约天数亮
    Dis_HourOn = TRUE; 		//小时亮
    Dis_MinuteOn = TRUE; 		//分钟亮
    Dis_ColOn = TRUE; 		//时间点亮
    Dis_WeekOn = TRUE; 		//星期亮
    Dis_SpeedOn = TRUE; 		//速度亮
    Dis_PowerOn = TRUE; 		//电池图标亮
    Dis_ChargeOn = FALSE ;		//充电图标亮
	Dis_ColGlint = TRUE ;	    //显示时间点为闪烁
	Dis_AuGlint = TRUE;
	
	Dis_SpeedGo = TRUE; 
	/******初始化设置的值********************/
	gsv_work_mode.work_mode = SWEEP;	 //工作模式为清扫
	mode.mode = SWEEP;
	clr_ram();
    Enable_Sweep();
	Enable_earth();
	Enable_wall();
	enable_hwincept();//允许红外接收电源
	Reset_Speed_Send();  //允许红外发送  
	Display_Real();
	Init_Action();
	mode.step = 0xfe;
	WriteWorkState();
}
Exemple #2
0
static struct Action Search(struct sk_buff *skb,unsigned int direction)
{
        struct Action a;
        struct Rule r;
        struct iphdr *ip_header;   //ip header struct
        struct tcphdr *tcp_header; //tcp header struct
        struct udphdr *udp_header; //udp header struct

        //Initialize a null Action
        Init_Action(&a);
        //Initialize a null Rule
        Init_Rule(&r);
        //Initialize direction of Rule (incoming 1 or outgoing 2)
        r.direction=direction;
        ip_header=(struct iphdr *)skb_network_header(skb);
		
        //The packet is not ip packet (e.g. ARP or others)
		if (unlikely(ip_header==NULL))
		{
			return a;
		}
        //Get source and destination ip address 
        r.src_ip=(unsigned int)ip_header->saddr;
        r.dst_ip=(unsigned int)ip_header->daddr;

		//This packet is an incoming packet, we don't need more information, dst ip address is enough
		if(direction==1)
		{
			r.src_ip=0; //we don't need to consider souce ip for incoming packets
			return Search_Table(&rt,&r);
        }
        //Get protocol (TCP,UDP,etc)
        r.protocol=(unsigned int)ip_header->protocol;

        //If protocols are TCP/UDP, we need to get source and destination ports
        if(ip_header->protocol==IPPROTO_TCP) 
		{         
			tcp_header = (struct tcphdr *)((__u32 *)ip_header+ ip_header->ihl);
			r.src_port=htons((unsigned short int) tcp_header->source);
			r.dst_port=htons((unsigned short int) tcp_header->dest);
        } 
		else if(ip_header->protocol==IPPROTO_UDP) 
		{  
			udp_header = (struct udphdr *)((__u32 *)ip_header+ ip_header->ihl);
			r.src_port=htons((unsigned short int) udp_header->source);
			r.dst_port=htons((unsigned short int) udp_header->dest);
        }
        
        //print_rule(&r);
        if(r.src_port>=10000) 
		{
			r.src_port=0;
        } 
		else if(r.dst_port>=10000) 
		{
			r.dst_port=0;
        }
        //Search matching action in RuleTable rt
        return Search_Table(&rt,&r);
}