]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/hostap/hostap_main.c
[NET]: Move hardware header operations out of netdevice.
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / hostap / hostap_main.c
index 446de51bab74399d8b18db7cd07e085701327693..b75cf9205ce026902b2042b600c9d430b5ecdc3e 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/rtnetlink.h>
 #include <linux/wireless.h>
 #include <linux/etherdevice.h>
+#include <net/net_namespace.h>
 #include <net/iw_handler.h>
 #include <net/ieee80211.h>
 #include <net/ieee80211_crypt.h>
@@ -529,6 +530,10 @@ int hostap_set_auth_algs(local_info_t *local)
 void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
 {
        u16 status, fc;
+       DECLARE_MAC_BUF(mac);
+       DECLARE_MAC_BUF(mac2);
+       DECLARE_MAC_BUF(mac3);
+       DECLARE_MAC_BUF(mac4);
 
        status = __le16_to_cpu(rx->status);
 
@@ -547,13 +552,12 @@ void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
               fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
               fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
 
-       printk(KERN_DEBUG "   A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4="
-              MACSTR "\n",
-              MAC2STR(rx->addr1), MAC2STR(rx->addr2), MAC2STR(rx->addr3),
-              MAC2STR(rx->addr4));
+       printk(KERN_DEBUG "   A1=%s A2=%s A3=%s A4=%s\n",
+              print_mac(mac, rx->addr1), print_mac(mac2, rx->addr2),
+              print_mac(mac3, rx->addr3), print_mac(mac4, rx->addr4));
 
-       printk(KERN_DEBUG "   dst=" MACSTR " src=" MACSTR " len=%d\n",
-              MAC2STR(rx->dst_addr), MAC2STR(rx->src_addr),
+       printk(KERN_DEBUG "   dst=%s src=%s len=%d\n",
+              print_mac(mac, rx->dst_addr), print_mac(mac2, rx->src_addr),
               __be16_to_cpu(rx->len));
 }
 
@@ -561,6 +565,10 @@ void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx)
 void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
 {
        u16 fc;
+       DECLARE_MAC_BUF(mac);
+       DECLARE_MAC_BUF(mac2);
+       DECLARE_MAC_BUF(mac3);
+       DECLARE_MAC_BUF(mac4);
 
        printk(KERN_DEBUG "%s: TX status=0x%04x retry_count=%d tx_rate=%d "
               "tx_control=0x%04x; jiffies=%ld\n",
@@ -576,35 +584,37 @@ void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
               fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "",
               fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : "");
 
-       printk(KERN_DEBUG "   A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4="
-              MACSTR "\n",
-              MAC2STR(tx->addr1), MAC2STR(tx->addr2), MAC2STR(tx->addr3),
-              MAC2STR(tx->addr4));
+       printk(KERN_DEBUG "   A1=%s A2=%s A3=%s A4=%s\n",
+              print_mac(mac, tx->addr1), print_mac(mac2, tx->addr2),
+              print_mac(mac3, tx->addr3), print_mac(mac4, tx->addr4));
 
-       printk(KERN_DEBUG "   dst=" MACSTR " src=" MACSTR " len=%d\n",
-              MAC2STR(tx->dst_addr), MAC2STR(tx->src_addr),
+       printk(KERN_DEBUG "   dst=%s src=%s len=%d\n",
+              print_mac(mac, tx->dst_addr), print_mac(mac2, tx->src_addr),
               __be16_to_cpu(tx->len));
 }
 
 
-int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr)
+int hostap_80211_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 {
-       memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
-       return ETH_ALEN;
-}
-
+       struct hostap_interface *iface = netdev_priv(skb->dev);
+       local_info_t *local = iface->local;
+
+       if (local->monitor_type == PRISM2_MONITOR_PRISM ||
+           local->monitor_type == PRISM2_MONITOR_CAPHDR) {
+               const unsigned char *mac = skb_mac_header(skb);
+
+               if (*(u32 *)mac == LWNG_CAP_DID_BASE) {
+                       memcpy(haddr,
+                              mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10,
+                              ETH_ALEN); /* addr2 */
+               } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */
+                       memcpy(haddr,
+                              mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10,
+                              ETH_ALEN); /* addr2 */
+               }
+       } else
+               memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
 
-int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr)
-{
-       const unsigned char *mac = skb_mac_header(skb);
-
-       if (*(u32 *)mac == LWNG_CAP_DID_BASE) {
-               memcpy(haddr, mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10,
-                      ETH_ALEN); /* addr2 */
-       } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */
-               memcpy(haddr, mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10,
-                      ETH_ALEN); /* addr2 */
-       }
        return ETH_ALEN;
 }
 
@@ -836,6 +846,15 @@ static void prism2_tx_timeout(struct net_device *dev)
        local->func->schedule_reset(local);
 }
 
+const struct header_ops hostap_80211_ops = {
+       .create         = eth_header,
+       .rebuild        = eth_rebuild_header,
+       .cache          = eth_header_cache,
+       .cache_update   = eth_header_cache_update,
+
+       .parse          = hostap_80211_header_parse,
+};
+EXPORT_SYMBOL(hostap_80211_ops);
 
 void hostap_setup_dev(struct net_device *dev, local_info_t *local,
                      int main_dev)
@@ -876,7 +895,6 @@ void hostap_setup_dev(struct net_device *dev, local_info_t *local,
        netif_stop_queue(dev);
 }
 
-
 static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked)
 {
        struct net_device *dev = local->dev;
@@ -894,7 +912,7 @@ static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked)
 
        local->apdev->hard_start_xmit = hostap_mgmt_start_xmit;
        local->apdev->type = ARPHRD_IEEE80211;
-       local->apdev->hard_header_parse = hostap_80211_header_parse;
+       local->apdev->header_ops = &hostap_80211_ops;
 
        return 0;
 }
@@ -1093,8 +1111,8 @@ struct proc_dir_entry *hostap_proc;
 
 static int __init hostap_init(void)
 {
-       if (proc_net != NULL) {
-               hostap_proc = proc_mkdir("hostap", proc_net);
+       if (init_net.proc_net != NULL) {
+               hostap_proc = proc_mkdir("hostap", init_net.proc_net);
                if (!hostap_proc)
                        printk(KERN_WARNING "Failed to mkdir "
                               "/proc/net/hostap\n");
@@ -1109,7 +1127,7 @@ static void __exit hostap_exit(void)
 {
        if (hostap_proc != NULL) {
                hostap_proc = NULL;
-               remove_proc_entry("hostap", proc_net);
+               remove_proc_entry("hostap", init_net.proc_net);
        }
 }