Ejemplo n.º 1
0
unsigned inet_addr_type(u32 addr)
{
	struct flowi		fl = { .nl_u = { .ip4_u = { .daddr = addr } } };
	struct fib_result	res;
	unsigned ret = RTN_BROADCAST;

	if (ZERONET(addr) || BADCLASS(addr))
		return RTN_BROADCAST;
	if (MULTICAST(addr))
		return RTN_MULTICAST;

#ifdef CONFIG_IP_MULTIPLE_TABLES
	res.r = NULL;
#endif
	
	if (ip_fib_local_table) {
		ret = RTN_UNICAST;
		if (!ip_fib_local_table->tb_lookup(ip_fib_local_table,
						   &fl, &res)) {
			ret = res.type;
			fib_res_put(&res);
		}
	}
	return ret;
}
Ejemplo n.º 2
0
void ssa_nodse_stat_entrance(struct sk_buff *skb, u32 dir)
{
    u32 packet_len = (u32)ntohs(skb->nh.iph->tot_len) + SSA_MAC_HEAD_LENGTH;
    s32 in_if_num;
    s32 out_if_num;
    u32 src_ip = skb->nh.iph->saddr;
    u32 dst_ip = skb->nh.iph->daddr;
    u32 dst_match_flag = 0;
    u32 src_match_flag = 0;
    u32 app_id = skb_get_application_id(skb);
    s32 i;
	struct net_device dev;
	u32 dev_type = 0;

    if (app_id >= SSA_APP_NUM_MAX)
    {
        app_id = 127;
    }
    
    if(LOOPBACK(src_ip) || MULTICAST(src_ip) || BADCLASS(src_ip) || ZERONET(src_ip) || LOCAL_MCAST(src_ip) || BROADCAST(src_ip) ||
          LOOPBACK(dst_ip) || MULTICAST(dst_ip) || BADCLASS(dst_ip) || ZERONET(dst_ip) || LOCAL_MCAST(dst_ip) || BROADCAST(dst_ip))
    {
        return ;
    }
    
    if (SSA_ON==g_ssa_conf.if_log_switch)
    {    	
		in_if_num = if_dev_get_phy_serial_num(skb->in_if);
		
		dev.ifindex = skb->in_if;
		eth_dev_ioctl( &dev, (void *)&dev_type, SIOCGPRIVATEIFTYPE);		
		if(dir == STREAM_IN||DEV_IFTYPE_SNIFF == dev_type)
    	{
	    	ssa_if_stat_entrance(packet_len, in_if_num, app_id, STREAM_IN);
			if (SSA_ON==g_ssa_firstpage_info.stat_flag)
			{				
				ssa_firstpage_data_stat(packet_len, in_if_num, STREAM_IN);
			}
    	}
		else
		{
			out_if_num = if_dev_get_phy_serial_num(skb->out_if);			
	    	ssa_if_stat_entrance(packet_len, in_if_num,  app_id, STREAM_IN);
	    	ssa_if_stat_entrance(packet_len, out_if_num, app_id, STREAM_OUT);
	    	if (SSA_ON==g_ssa_firstpage_info.stat_flag)
			{					
				ssa_firstpage_data_stat(packet_len, in_if_num, STREAM_IN);
				ssa_firstpage_data_stat(packet_len, out_if_num, STREAM_OUT);
			}
		}
    }


    if (g_ssa_conf.ip_log_switch == SSA_ON && dir == STREAM_OUT)
    {
        for(i = 0; (i < SSA_USER_GROUP_NUM)&&(g_ssa_conf.stat_group_id[i] != 0); i++)
        {
            if(1 == dst_match_flag && 1 == src_match_flag)
            {
                return;
            }
         
            if((0 == src_match_flag) && (net_user_ip_in_list == net_user_get_by_id_ip(g_ssa_conf.stat_group_id[i], src_ip)))
            {              
                src_match_flag = 1;
             
                ssa_ip_stat_entrance(packet_len, 1, 0, 0, src_ip, g_ssa_conf.stat_group_id[i], app_id, SSA_STREAM_UP, NULL);
            }
        
			if((0 == dst_match_flag) && (net_user_ip_in_list == net_user_get_by_id_ip(g_ssa_conf.stat_group_id[i], dst_ip)))
			{
				dst_match_flag = 1;			 
				ssa_ip_stat_entrance(packet_len, 1, 0, 0, dst_ip, g_ssa_conf.stat_group_id[i], app_id, SSA_STREAM_DOWN, NULL);
			}
        }

    }
    
    return;

}