Esempio n. 1
0
/**
*  @brief 	ATWILC_WFI_mon_xmit
*  @details 	
*  @param[in]   
*  @return 	int : Return 0 on Success
*  @author	mdaftedar
*  @date	12 JUL 2012	
*  @version	1.0
*/
static netdev_tx_t ATWILC_WFI_mon_xmit(struct sk_buff *skb,
                                        struct net_device *dev)
{
	struct ieee80211_radiotap_header *rtap_hdr;
	ATL_Uint32 rtap_len,i,ret=0;
	struct ATWILC_WFI_mon_priv  *mon_priv ;

	 struct sk_buff *skb2;
	 struct atwilc_wfi_radiotap_cb_hdr *cb_hdr;

	//PRINT_D(HOSTAPD_DBG,"Monitor xmit function b4\n");
	/* Bug 4601 */
	if(atwilc_wfi_mon == NULL)
		return ATL_FAIL;
		
	//if(skb->data[3] == 0x10 || skb->data[3] == 0xb0)
	
	


	
	mon_priv = netdev_priv(atwilc_wfi_mon);
	
	if(mon_priv== NULL)
	{
	  PRINT_ER("Monitor interface private structure is NULL\n");
	  return ATL_FAIL;
	}	
	
	rtap_hdr = (struct ieee80211_radiotap_header *)skb->data;

	rtap_len = ieee80211_get_radiotap_len(skb->data);
	if (skb->len < rtap_len)
	{
		PRINT_ER("Error in radiotap header\n");
		return -1;
	}
	/* skip the radiotap header */
	PRINT_INFO(HOSTAPD_DBG,"Radiotap len: %d\n", rtap_len);

	if(INFO)
	{
		for(i=0; i<rtap_len ; i++)
			PRINT_INFO(HOSTAPD_DBG,"Radiotap_hdr[%d] %02x\n",i,skb->data[i]);
	}
	/* Skip the ratio tap header */
	skb_pull(skb, rtap_len);

	if( skb->data[0] == 0xc0)
		PRINT_INFO(HOSTAPD_DBG, "%x:%x:%x:%x:%x%x\n",skb->data[4],skb->data[5],skb->data[6],skb->data[7],skb->data[8],skb->data[9]);

	if( skb->data[0] == 0xc0 &&(!(memcmp(broadcast, &skb->data[4],6) ))  )
	{
		skb2 = dev_alloc_skb(skb->len+sizeof(struct atwilc_wfi_radiotap_cb_hdr));

		memcpy(skb_put(skb2,skb->len),skb->data, skb->len);

		cb_hdr = (struct atwilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr));
		memset(cb_hdr, 0, sizeof(struct atwilc_wfi_radiotap_cb_hdr));

		 cb_hdr->hdr.it_version = 0;//PKTHDR_RADIOTAP_VERSION;
        
      	        cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct atwilc_wfi_radiotap_cb_hdr));

       	 cb_hdr->hdr.it_present = cpu_to_le32(
                                          (1 << IEEE80211_RADIOTAP_RATE) |
                                         (1 << IEEE80211_RADIOTAP_TX_FLAGS));
 
        	cb_hdr->rate = 5;//txrate->bitrate / 5;
        	cb_hdr->tx_flags = 0x0004;
			
		skb2->dev = atwilc_wfi_mon;
	        skb_set_mac_header(skb2, 0);
	        skb2->ip_summed = CHECKSUM_UNNECESSARY;
	        skb2->pkt_type = PACKET_OTHERHOST;
	        skb2->protocol = htons(ETH_P_802_2);
	        memset(skb2->cb, 0, sizeof(skb2->cb));
			
		netif_rx(skb2);
		
		return 0;
	}
	skb->dev = mon_priv->real_ndev;
	
	PRINT_INFO(HOSTAPD_DBG,"Skipping the radiotap header\n");
	
	

	 /* actual deliver of data is device-specific, and not shown here */
	PRINT_INFO(HOSTAPD_DBG,"SKB netdevice name = %s\n", skb->dev->name);
	PRINT_INFO(HOSTAPD_DBG,"MONITOR real dev name = %s\n", mon_priv->real_ndev->name);
	
	#ifdef SIMULATION
    ret = ATWILC_WFI_Tx(skb,mon_priv->real_ndev);
	#elif USE_WIRELESS
	//Identify if Ethernet or MAC header (data or mgmt)
	memcpy(srcAdd,& skb->data[10],6);
	memcpy(bssid, &skb->data[16],6);
	//if source address and bssid fields are equal>>Mac header
	/*send it to mgmt frames handler */
	if(!(memcmp(srcAdd,bssid,6)))
	{
		//ATL_PRINTF("--MGMT PKT in mon_xmit--\n");
		mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len);
		dev_kfree_skb(skb);
	}
	else
    	ret = mac_xmit(skb,mon_priv->real_ndev);
	#endif

	//return NETDEV_TX_OK;
    return ret;
}
Esempio n. 2
0
/**
 *  @brief      WILC_WFI_mon_xmit
 *  @details
 *  @param[in]
 *  @return     int : Return 0 on Success
 *  @author	mdaftedar
 *  @date	12 JUL 2012
 *  @version	1.0
 */
static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
				     struct net_device *dev)
{
	u32 rtap_len, ret = 0;
	struct WILC_WFI_mon_priv  *mon_priv;

	struct sk_buff *skb2;
	struct wilc_wfi_radiotap_cb_hdr *cb_hdr;

	if (!wilc_wfi_mon)
		return -EFAULT;

	mon_priv = netdev_priv(wilc_wfi_mon);
	if (!mon_priv)
		return -EFAULT;
	rtap_len = ieee80211_get_radiotap_len(skb->data);
	if (skb->len < rtap_len)
		return -1;

	skb_pull(skb, rtap_len);

	if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) {
		skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr));

		memcpy(skb_put(skb2, skb->len), skb->data, skb->len);

		cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *)skb_push(skb2, sizeof(*cb_hdr));
		memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));

		cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */

		cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));

		cb_hdr->hdr.it_present = cpu_to_le32(
				(1 << IEEE80211_RADIOTAP_RATE) |
				(1 << IEEE80211_RADIOTAP_TX_FLAGS));

		cb_hdr->rate = 5; /* txrate->bitrate / 5; */
		cb_hdr->tx_flags = 0x0004;

		skb2->dev = wilc_wfi_mon;
		skb_set_mac_header(skb2, 0);
		skb2->ip_summed = CHECKSUM_UNNECESSARY;
		skb2->pkt_type = PACKET_OTHERHOST;
		skb2->protocol = htons(ETH_P_802_2);
		memset(skb2->cb, 0, sizeof(skb2->cb));

		netif_rx(skb2);

		return 0;
	}
	skb->dev = mon_priv->real_ndev;

	/* Identify if Ethernet or MAC header (data or mgmt) */
	memcpy(srcadd, &skb->data[10], 6);
	memcpy(bssid, &skb->data[16], 6);
	/* if source address and bssid fields are equal>>Mac header */
	/*send it to mgmt frames handler */
	if (!(memcmp(srcadd, bssid, 6))) {
		ret = mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len);
		if (ret)
			netdev_err(dev, "fail to mgmt tx\n");
		dev_kfree_skb(skb);
	} else {
		ret = wilc_mac_xmit(skb, mon_priv->real_ndev);
	}

	return ret;
}
Esempio n. 3
0
static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb,
				     struct net_device *dev)
{
	u32 rtap_len, ret = 0;
	struct wilc_wfi_mon_priv  *mon_priv;
	struct sk_buff *skb2;
	struct wilc_wfi_radiotap_cb_hdr *cb_hdr;

	if (!wilc_wfi_mon)
		return -EFAULT;

	mon_priv = netdev_priv(wilc_wfi_mon);
	if (!mon_priv)
		return -EFAULT;
	rtap_len = ieee80211_get_radiotap_len(skb->data);
	if (skb->len < rtap_len)
		return -1;

	skb_pull(skb, rtap_len);

	if (skb->data[0] == 0xc0 && is_broadcast_ether_addr(&skb->data[4])) {
		skb2 = dev_alloc_skb(skb->len + sizeof(*cb_hdr));
		if (!skb2)
			return -ENOMEM;

		skb_put_data(skb2, skb->data, skb->len);

		cb_hdr = skb_push(skb2, sizeof(*cb_hdr));
		memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));

		cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */

		cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr));

		cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT);

		cb_hdr->rate = 5;
		cb_hdr->tx_flags = 0x0004;

		skb2->dev = wilc_wfi_mon;
		skb_reset_mac_header(skb2);
		skb2->ip_summed = CHECKSUM_UNNECESSARY;
		skb2->pkt_type = PACKET_OTHERHOST;
		skb2->protocol = htons(ETH_P_802_2);
		memset(skb2->cb, 0, sizeof(skb2->cb));

		netif_rx(skb2);

		return 0;
	}
	skb->dev = mon_priv->real_ndev;

	memcpy(srcadd, &skb->data[10], 6);
	memcpy(bssid, &skb->data[16], 6);
	/*
	 * Identify if data or mgmt packet, if source address and bssid
	 * fields are equal send it to mgmt frames handler
	 */
	if (!(memcmp(srcadd, bssid, 6))) {
		ret = mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len);
		if (ret)
			netdev_err(dev, "fail to mgmt tx\n");
		dev_kfree_skb(skb);
	} else {
		ret = wilc_mac_xmit(skb, mon_priv->real_ndev);
	}

	return ret;
}