/* Now, for the addresses in the spy list */ 
/* Now, update the spy stuff */ 
static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned int pkt_addr,              int rx_len){    struct sk_buff *skb = NULL;    struct rcs __iomem *prcslink = prcs;    ray_dev_t *local = dev->priv;    UCHAR *rx_ptr;    int total_len;    int tmp;#ifdef WIRELESS_SPY    int siglev = local->last_rsl;    u_char linksrcaddr[ETH_ALEN];	/* Other end of the wireless link */#endif    if (!sniffer) {        if (translate) {/* TBD length needs fixing for translated header */            if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||                rx_len > (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN + FCS_LEN))             {                DEBUG(0,"ray_cs invalid packet length %d received \n",rx_len);                return;            }        }        else /* encapsulated ethernet */ {            if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||                rx_len > (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN + FCS_LEN))            {                DEBUG(0,"ray_cs invalid packet length %d received \n",rx_len);                return;            }        }    }    DEBUG(4,"ray_cs rx_data packet\n");    /* If fragmented packet, verify sizes of fragments add up */    if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {        DEBUG(1,"ray_cs rx'ed fragment\n");        tmp = (readb(&prcs->var.rx_packet.totalpacketlength[0]) << 8)            +  readb(&prcs->var.rx_packet.totalpacketlength[1]);        total_len = tmp;        prcslink = prcs;        do {            tmp -= (readb(&prcslink->var.rx_packet.rx_data_length[0]) << 8)                +   readb(&prcslink->var.rx_packet.rx_data_length[1]);            if (readb(&prcslink->var.rx_packet.next_frag_rcs_index) == 0xFF                || tmp < 0) break;            prcslink = rcs_base(local)                + readb(&prcslink->link_field);        } while (1);        if (tmp < 0)        {            DEBUG(0,"ray_cs rx_data fragment lengths don't add up\n");            local->stats.rx_dropped++;             release_frag_chain(local, prcs);            return;        }    }    else { /* Single unfragmented packet */        total_len = rx_len;    }    skb = dev_alloc_skb( total_len+5 );    if (skb == NULL)    {        DEBUG(0,"ray_cs rx_data could not allocate skb\n");        local->stats.rx_dropped++;         if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF)            release_frag_chain(local, prcs);        return;    }    skb_reserve( skb, 2);   /* Align IP on 16 byte (TBD check this)*/    skb->dev = dev;    DEBUG(4,"ray_cs rx_data total_len = %x, rx_len = %x\n",total_len,rx_len);/************************/    /* Reserve enough room for the whole damn packet. */    rx_ptr = skb_put( skb, total_len);    /* Copy the whole packet to sk_buff */    rx_ptr += copy_from_rx_buff(local, rx_ptr, pkt_addr & RX_BUFF_END, rx_len);    /* Get source address */#ifdef WIRELESS_SPY    memcpy(linksrcaddr, ((struct mac_header *)skb->data)->addr_2, ETH_ALEN);#endif    /* Now, deal with encapsulation/translation/sniffer */    if (!sniffer) {        if (!translate) {             /* Encapsulated ethernet, so just lop off 802.11 MAC header *//* TBD reserve            skb_reserve( skb, RX_MAC_HEADER_LENGTH); */            skb_pull( skb, RX_MAC_HEADER_LENGTH);        }        else {            /* Do translation */            untranslate(local, skb, total_len);        }    }    else     {  /* sniffer mode, so just pass whole packet */  };/************************/    /* Now pick up the rest of the fragments if any */    tmp = 17;     if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {        prcslink = prcs;        DEBUG(1,"ray_cs rx_data in fragment loop\n");        do {            prcslink = rcs_base(local)                + readb(&prcslink->var.rx_packet.next_frag_rcs_index);            rx_len = (( readb(&prcslink->var.rx_packet.rx_data_length[0]) << 8)                      + readb(&prcslink->var.rx_packet.rx_data_length[1]))                & RX_BUFF_END;            pkt_addr = (( readb(&prcslink->var.rx_packet.rx_data_ptr[0]) << 8)                        + readb(&prcslink->var.rx_packet.rx_data_ptr[1]))                & RX_BUFF_END;            rx_ptr += copy_from_rx_buff(local, rx_ptr, pkt_addr, rx_len);        } while (tmp-- &&                  readb(&prcslink->var.rx_packet.next_frag_rcs_index) != 0xFF);        release_frag_chain(local, prcs);    }    skb->protocol = eth_type_trans(skb,dev);    netif_rx(skb);    dev->last_rx = jiffies;    local->stats.rx_packets++;    local->stats.rx_bytes += total_len;    /* Gather signal strength per address */#ifdef WIRELESS_SPY    /* For the Access Point or the node having started the ad-hoc net     * note : ad-hoc work only in some specific configurations, but we     * kludge in ray_get_wireless_stats... */    if(!memcmp(linksrcaddr, local->bss_id, ETH_ALEN))      {	/* Update statistics */	/*local->wstats.qual.qual = none ? */	local->wstats.qual.level = siglev;	/*local->wstats.qual.noise = none ? */	local->wstats.qual.updated = 0x2;      }    /* Now, for the addresses in the spy list */    {      int	i;      /* Look all addresses */      for(i = 0; i < local->spy_number; i++)	/* If match */	if(!memcmp(linksrcaddr, local->spy_address[i], ETH_ALEN))	  {	    /* Update statistics */	    /*local->spy_stat[i].qual = none ? */	    local->spy_stat[i].level = siglev;	    /*local->spy_stat[i].noise = none ? */	    local->spy_stat[i].updated = 0x2;	  }    }#endif	/* WIRELESS_SPY */} /* end rx_data */
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/3d5d5ac085c467f05cce85d32985e78912db4a7e/ray_cs.c/buggy/drivers/net/wireless/ray_cs.c