diff options
author | Anish Bhatt <anish7@gmail.com> | 2015-09-04 14:00:30 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-09-12 18:24:52 -0700 |
commit | 242850f48a96ce0bf48e81fa20850792f27fd3ba (patch) | |
tree | 3aa951de95465bdbc63c4c8baafa56ae623e5560 /drivers/staging/wlan-ng | |
parent | a2f9ff6c75ad2c3110ad8464c0dbaef4902c9400 (diff) |
staging/wlan-ng : Remove duplicated defines from p80211
ETH_ALEN/ETH_HLEN can be used instead of
WLAN_ETHADDR_LEN & WLAN_ETHHDR_LEN, replace directly or
use eth_addr* functions where applicable.
Signed-off-by: Anish Bhatt <anish@chelsio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wlan-ng')
-rw-r--r-- | drivers/staging/wlan-ng/p80211conv.c | 50 | ||||
-rw-r--r-- | drivers/staging/wlan-ng/p80211conv.h | 7 |
2 files changed, 27 insertions, 30 deletions
diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index 49f2ef88929d..1b02cdf9d1fa 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -135,7 +135,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, /* it's 802.3, pass ether payload unchanged, */ /* trim off ethernet header */ - skb_pull(skb, WLAN_ETHHDR_LEN); + skb_pull(skb, ETH_HLEN); /* leave off any PAD octets. */ skb_trim(skb, proto); @@ -144,7 +144,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, /* it's DIXII, time for some conversion */ /* trim off ethernet header */ - skb_pull(skb, WLAN_ETHHDR_LEN); + skb_pull(skb, ETH_HLEN); /* tack on SNAP */ e_snap = @@ -281,8 +281,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, u16 fc; unsigned int payload_length; unsigned int payload_offset; - u8 daddr[WLAN_ETHADDR_LEN]; - u8 saddr[WLAN_ETHADDR_LEN]; + u8 daddr[ETH_ALEN]; + u8 saddr[ETH_ALEN]; union p80211_hdr *w_hdr; struct wlan_ethhdr *e_hdr; struct wlan_llc *e_llc; @@ -298,16 +298,16 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, /* setup some vars for convenience */ fc = le16_to_cpu(w_hdr->a3.fc); if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 0)) { - memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN); - memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN); + ether_addr_copy(daddr, w_hdr->a3.a1); + ether_addr_copy(saddr, w_hdr->a3.a2); } else if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 1)) { - memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN); - memcpy(saddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN); + ether_addr_copy(daddr, w_hdr->a3.a1); + ether_addr_copy(saddr, w_hdr->a3.a3); } else if ((WLAN_GET_FC_TODS(fc) == 1) && (WLAN_GET_FC_FROMDS(fc) == 0)) { - memcpy(daddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN); - memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN); + ether_addr_copy(daddr, w_hdr->a3.a3); + ether_addr_copy(saddr, w_hdr->a3.a2); } else { payload_offset = WLAN_HDR_A4_LEN; if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) { @@ -315,8 +315,8 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, return 1; } payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN); - memcpy(daddr, w_hdr->a4.a3, WLAN_ETHADDR_LEN); - memcpy(saddr, w_hdr->a4.a4, WLAN_ETHADDR_LEN); + ether_addr_copy(daddr, w_hdr->a4.a3); + ether_addr_copy(saddr, w_hdr->a4.a4); } /* perform de-wep if necessary.. */ @@ -360,16 +360,16 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, /* Test for the various encodings */ if ((payload_length >= sizeof(struct wlan_ethhdr)) && (e_llc->dsap != 0xaa || e_llc->ssap != 0xaa) && - ((memcmp(daddr, e_hdr->daddr, WLAN_ETHADDR_LEN) == 0) || - (memcmp(saddr, e_hdr->saddr, WLAN_ETHADDR_LEN) == 0))) { + ((!ether_addr_equal_unaligned(daddr, e_hdr->daddr)) || + (!ether_addr_equal_unaligned(saddr, e_hdr->saddr)))) { pr_debug("802.3 ENCAP len: %d\n", payload_length); /* 802.3 Encapsulated */ /* Test for an overlength frame */ - if (payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) { + if (payload_length > (netdev->mtu + ETH_HLEN)) { /* A bogus length ethfrm has been encap'd. */ /* Is someone trying an oflow attack? */ netdev_err(netdev, "ENCAP frame too large (%d > %d)\n", - payload_length, netdev->mtu + WLAN_ETHHDR_LEN); + payload_length, netdev->mtu + ETH_HLEN); return 1; } @@ -406,9 +406,9 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, skb_pull(skb, payload_offset); /* create 802.3 header at beginning of skb. */ - e_hdr = (struct wlan_ethhdr *) skb_push(skb, WLAN_ETHHDR_LEN); - memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN); - memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN); + e_hdr = (struct wlan_ethhdr *)skb_push(skb, ETH_HLEN); + ether_addr_copy(e_hdr->daddr, daddr); + ether_addr_copy(e_hdr->saddr, saddr); e_hdr->type = htons(payload_length); /* chop off the 802.11 CRC */ @@ -446,10 +446,10 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, skb_pull(skb, sizeof(struct wlan_snap)); /* create 802.3 header at beginning of skb. */ - e_hdr = (struct wlan_ethhdr *) skb_push(skb, WLAN_ETHHDR_LEN); + e_hdr = (struct wlan_ethhdr *)skb_push(skb, ETH_HLEN); e_hdr->type = e_snap->type; - memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN); - memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN); + ether_addr_copy(e_hdr->daddr, daddr); + ether_addr_copy(e_hdr->saddr, saddr); /* chop off the 802.11 CRC */ skb_trim(skb, skb->len - WLAN_CRC_LEN); @@ -473,9 +473,9 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, skb_pull(skb, payload_offset); /* create 802.3 header at beginning of skb. */ - e_hdr = (struct wlan_ethhdr *) skb_push(skb, WLAN_ETHHDR_LEN); - memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN); - memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN); + e_hdr = (struct wlan_ethhdr *)skb_push(skb, ETH_HLEN); + ether_addr_copy(e_hdr->daddr, daddr); + ether_addr_copy(e_hdr->saddr, saddr); e_hdr->type = htons(payload_length); /* chop off the 802.11 CRC */ diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h index e031a74d2ad4..8c10357bedf0 100644 --- a/drivers/staging/wlan-ng/p80211conv.h +++ b/drivers/staging/wlan-ng/p80211conv.h @@ -53,14 +53,11 @@ #ifndef _LINUX_P80211CONV_H #define _LINUX_P80211CONV_H -#define WLAN_ETHADDR_LEN 6 #define WLAN_IEEE_OUI_LEN 3 #define WLAN_ETHCONV_ENCAP 1 #define WLAN_ETHCONV_8021h 3 -#define WLAN_ETHHDR_LEN 14 - #define P80211CAPTURE_VERSION 0x80211001 #define P80211_FRMMETA_MAGIC 0x802110 @@ -131,8 +128,8 @@ struct p80211_metawep { /* local ether header type */ struct wlan_ethhdr { - u8 daddr[WLAN_ETHADDR_LEN]; - u8 saddr[WLAN_ETHADDR_LEN]; + u8 daddr[ETH_ALEN]; + u8 saddr[ETH_ALEN]; u16 type; } __packed; |