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@xxxxxxxxxxx> --- drivers/staging/wlan-ng/p80211conv.c | 50 ++++++++++++++++++------------------ 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 75f6524..29924b8 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 e031a74..8c10357 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; -- 2.5.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel