Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 70217d7f authored by Harvey Harrison's avatar Harvey Harrison Committed by John W. Linville
Browse files

mac80211: wep.c use new frame control helpers

parent 3a078876
Loading
Loading
Loading
Loading
+15 −24
Original line number Diff line number Diff line
@@ -85,19 +85,16 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local,
				struct ieee80211_key *key)
{
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
	u16 fc;
	int hdrlen;
	unsigned int hdrlen;
	u8 *newhdr;

	fc = le16_to_cpu(hdr->frame_control);
	fc |= IEEE80211_FCTL_PROTECTED;
	hdr->frame_control = cpu_to_le16(fc);
	hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);

	if (WARN_ON(skb_tailroom(skb) < WEP_ICV_LEN ||
		    skb_headroom(skb) < WEP_IV_LEN))
		return NULL;

	hdrlen = ieee80211_get_hdrlen(fc);
	hdrlen = ieee80211_hdrlen(hdr->frame_control);
	newhdr = skb_push(skb, WEP_IV_LEN);
	memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen);
	ieee80211_wep_get_iv(local, key, newhdr + hdrlen);
@@ -110,11 +107,9 @@ static void ieee80211_wep_remove_iv(struct ieee80211_local *local,
				    struct ieee80211_key *key)
{
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
	u16 fc;
	int hdrlen;
	unsigned int hdrlen;

	fc = le16_to_cpu(hdr->frame_control);
	hdrlen = ieee80211_get_hdrlen(fc);
	hdrlen = ieee80211_hdrlen(hdr->frame_control);
	memmove(skb->data + WEP_IV_LEN, skb->data, hdrlen);
	skb_pull(skb, WEP_IV_LEN);
}
@@ -225,16 +220,14 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
	u8 *rc4key;
	u8 keyidx;
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
	u16 fc;
	int hdrlen;
	unsigned int hdrlen;
	size_t len;
	int ret = 0;

	fc = le16_to_cpu(hdr->frame_control);
	if (!(fc & IEEE80211_FCTL_PROTECTED))
	if (!ieee80211_has_protected(hdr->frame_control))
		return -1;

	hdrlen = ieee80211_get_hdrlen(fc);
	hdrlen = ieee80211_hdrlen(hdr->frame_control);

	if (skb->len < 8 + hdrlen)
		return -1;
@@ -282,16 +275,14 @@ int ieee80211_wep_decrypt(struct ieee80211_local *local, struct sk_buff *skb,
u8 * ieee80211_wep_is_weak_iv(struct sk_buff *skb, struct ieee80211_key *key)
{
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
	u16 fc;
	int hdrlen;
	unsigned int hdrlen;
	u8 *ivpos;
	u32 iv;

	fc = le16_to_cpu(hdr->frame_control);
	if (!(fc & IEEE80211_FCTL_PROTECTED))
	if (!ieee80211_has_protected(hdr->frame_control))
		return NULL;

	hdrlen = ieee80211_get_hdrlen(fc);
	hdrlen = ieee80211_hdrlen(hdr->frame_control);
	ivpos = skb->data + hdrlen;
	iv = (ivpos[0] << 16) | (ivpos[1] << 8) | ivpos[2];