Staging: wlan-ng: p80211conv.c: Coding style cleanups

Signed-off-by: Moritz Muehlenhoff <jmm@debian.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Moritz Muehlenhoff 2009-02-08 02:20:56 +01:00 committed by Greg Kroah-Hartman
parent c979aec791
commit 82eaca7d9a

View File

@ -48,10 +48,8 @@
* 802.11 frame conversions.
*
* --------------------------------------------------------------------
*/
/*================================================================*/
/* System Includes */
*
*================================================================ */
#include <linux/module.h>
#include <linux/kernel.h>
@ -69,9 +67,6 @@
#include "wlan_compat.h"
/*================================================================*/
/* Project Includes */
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211conv.h"
@ -81,16 +76,9 @@
#include "p80211ioctl.h"
#include "p80211req.h"
/*================================================================*/
/* Local Static Definitions */
static u8 oui_rfc1042[] = { 0x00, 0x00, 0x00 };
static u8 oui_8021h[] = { 0x00, 0x00, 0xf8 };
/*================================================================*/
/* Function Definitions */
/*----------------------------------------------------------------
* p80211pb_ether_to_80211
*
@ -116,7 +104,9 @@ static u8 oui_8021h[] = {0x00, 0x00, 0xf8};
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int skb_ether_to_p80211( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep)
int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
struct sk_buff *skb, p80211_hdr_t *p80211_hdr,
p80211_metawep_t *p80211_wep)
{
u16 fc;
@ -159,16 +149,21 @@ int skb_ether_to_p80211( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
skb_pull(skb, WLAN_ETHHDR_LEN);
/* tack on SNAP */
e_snap = (wlan_snap_t *) skb_push(skb, sizeof(wlan_snap_t));
e_snap =
(wlan_snap_t *) skb_push(skb, sizeof(wlan_snap_t));
e_snap->type = htons(proto);
if ( ethconv == WLAN_ETHCONV_8021h && p80211_stt_findproto(proto) ) {
memcpy( e_snap->oui, oui_8021h, WLAN_IEEE_OUI_LEN);
if (ethconv == WLAN_ETHCONV_8021h
&& p80211_stt_findproto(proto)) {
memcpy(e_snap->oui, oui_8021h,
WLAN_IEEE_OUI_LEN);
} else {
memcpy( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN);
memcpy(e_snap->oui, oui_rfc1042,
WLAN_IEEE_OUI_LEN);
}
/* tack on llc */
e_llc = (wlan_llc_t *) skb_push(skb, sizeof(wlan_llc_t));
e_llc =
(wlan_llc_t *) skb_push(skb, sizeof(wlan_llc_t));
e_llc->dsap = 0xAA; /* SNAP, see IEEE 802 */
e_llc->ssap = 0xAA;
e_llc->ctl = 0x03;
@ -200,30 +195,34 @@ int skb_ether_to_p80211( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN);
break;
default:
printk(KERN_ERR "Error: Converting eth to wlan in unknown mode.\n");
printk(KERN_ERR
"Error: Converting eth to wlan in unknown mode.\n");
return 1;
break;
}
p80211_wep->data = NULL;
if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && (wlandev->hostwep & HOSTWEP_ENCRYPT)) {
// XXXX need to pick keynum other than default?
if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
&& (wlandev->hostwep & HOSTWEP_ENCRYPT)) {
/* XXXX need to pick keynum other than default? */
p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
if ((foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
skb->len,
(wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK),
(wlandev->
hostwep & HOSTWEP_DEFAULTKEY_MASK),
p80211_wep->iv, p80211_wep->icv))) {
printk(KERN_WARNING "Host en-WEP failed, dropping frame (%d).\n", foo);
printk(KERN_WARNING
"Host en-WEP failed, dropping frame (%d).\n",
foo);
return 2;
}
fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
}
// skb->nh.raw = skb->data;
/* skb->nh.raw = skb->data; */
p80211_hdr->a3.fc = fc;
p80211_hdr->a3.dur = 0;
@ -247,8 +246,10 @@ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
wlandev->spy_stat[i].level = rxmeta->signal;
wlandev->spy_stat[i].noise = rxmeta->noise;
wlandev->spy_stat[i].qual = (rxmeta->signal > rxmeta->noise) ? \
(rxmeta->signal - rxmeta->noise) : 0;
wlandev->spy_stat[i].qual =
(rxmeta->signal >
rxmeta->noise) ? (rxmeta->signal -
rxmeta->noise) : 0;
wlandev->spy_stat[i].updated = 0x7;
}
}
@ -273,7 +274,8 @@ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb)
int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv,
struct sk_buff *skb)
{
netdevice_t *netdev = wlandev->netdev;
u16 fc;
@ -316,7 +318,8 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
}
/* perform de-wep if necessary.. */
if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc) && (wlandev->hostwep & HOSTWEP_DECRYPT)) {
if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc)
&& (wlandev->hostwep & HOSTWEP_DECRYPT)) {
if (payload_length <= 8) {
printk(KERN_ERR "WEP frame too short (%u).\n",
skb->len);
@ -325,9 +328,12 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
if ((foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
payload_length - 8, -1,
skb->data + payload_offset,
skb->data + payload_offset + payload_length - 4))) {
skb->data + payload_offset +
payload_length - 4))) {
/* de-wep failed, drop skb. */
pr_debug("Host de-WEP failed, dropping frame (%d).\n", foo);
printk(KERN_DEBUG
"Host de-WEP failed, dropping frame (%d).\n",
foo);
wlandev->rx.decrypt_err++;
return 2;
}
@ -345,7 +351,8 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
e_hdr = (wlan_ethhdr_t *) (skb->data + payload_offset);
e_llc = (wlan_llc_t *) (skb->data + payload_offset);
e_snap = (wlan_snap_t *) (skb->data + payload_offset + sizeof(wlan_llc_t));
e_snap =
(wlan_snap_t *) (skb->data + payload_offset + sizeof(wlan_llc_t));
/* Test for the various encodings */
if ((payload_length >= sizeof(wlan_ethhdr_t)) &&
@ -368,15 +375,15 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
/* chop off the 802.11 CRC */
skb_trim(skb, skb->len - WLAN_CRC_LEN);
} else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) &&
(e_llc->dsap == 0xaa) &&
(e_llc->ssap == 0xaa) &&
(e_llc->ctl == 0x03) &&
(((memcmp( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN)==0) &&
(ethconv == WLAN_ETHCONV_8021h) &&
(p80211_stt_findproto(le16_to_cpu(e_snap->type)))) ||
(memcmp( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN)!=0)))
{
} else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t))
&& (e_llc->dsap == 0xaa) && (e_llc->ssap == 0xaa)
&& (e_llc->ctl == 0x03)
&&
(((memcmp(e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN) == 0)
&& (ethconv == WLAN_ETHCONV_8021h)
&& (p80211_stt_findproto(le16_to_cpu(e_snap->type))))
|| (memcmp(e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN) !=
0))) {
pr_debug("SNAP+RFC1042 len: %d\n", payload_length);
/* it's a SNAP + RFC1042 frame && protocol is in STT */
/* build 802.3 + RFC1042 */
@ -402,10 +409,9 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
/* chop off the 802.11 CRC */
skb_trim(skb, skb->len - WLAN_CRC_LEN);
} else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) &&
(e_llc->dsap == 0xaa) &&
(e_llc->ssap == 0xaa) &&
(e_llc->ctl == 0x03) ) {
} else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t))
&& (e_llc->dsap == 0xaa) && (e_llc->ssap == 0xaa)
&& (e_llc->ctl == 0x03)) {
pr_debug("802.1h/RFC1042 len: %d\n", payload_length);
/* it's an 802.1h frame || (an RFC1042 && protocol is not in STT) */
/* build a DIXII + RFC894 */
@ -417,8 +423,7 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
/* Is someone trying an oflow attack? */
printk(KERN_ERR "DIXII frame too large (%ld > %d)\n",
(long int)(payload_length - sizeof(wlan_llc_t) -
sizeof(wlan_snap_t)),
netdev->mtu);
sizeof(wlan_snap_t)), netdev->mtu);
return 1;
}
@ -451,8 +456,7 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
/* A bogus length ethfrm has been sent. */
/* Is someone trying an oflow attack? */
printk(KERN_ERR "OTHER frame too large (%d > %d)\n",
payload_length,
netdev->mtu);
payload_length, netdev->mtu);
return 1;
}
@ -484,7 +488,8 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, u32 ethconv, struct sk_buff *skb
/* jkriegl: process signal and noise as set in hfa384x_int_rx() */
/* jkriegl: only process signal/noise if requested by iwspy */
if (wlandev->spy_number)
orinoco_spy_gather(wlandev, eth_hdr(skb)->h_source, P80211SKB_RXMETA(skb));
orinoco_spy_gather(wlandev, eth_hdr(skb)->h_source,
P80211SKB_RXMETA(skb));
/* Free the metadata */
p80211skb_rxmeta_detach(skb);
@ -538,8 +543,7 @@ int p80211_stt_findproto(u16 proto)
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
void
p80211skb_rxmeta_detach(struct sk_buff *skb)
void p80211skb_rxmeta_detach(struct sk_buff *skb)
{
p80211_rxmeta_t *rxmeta;
p80211_frmmeta_t *frmmeta;
@ -585,8 +589,7 @@ exit:
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int
p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
{
int result = 0;
p80211_rxmeta_t *rxmeta;
@ -640,18 +643,15 @@ exit:
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
void
p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb)
void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb)
{
p80211_frmmeta_t *meta;
meta = P80211SKB_FRMMETA(skb);
if ( meta && meta->rx) {
if (meta && meta->rx)
p80211skb_rxmeta_detach(skb);
} else {
else
printk(KERN_ERR "Freeing an skb (%p) w/ no frmmeta.\n", skb);
}
dev_kfree_skb(skb);
return;
}