Commit 034a7178 authored by Tobin C. Harding's avatar Tobin C. Harding Committed by Greg Kroah-Hartman

staging: ks7010: move WPA code to separate function

Checkpatch emits WARNING: Too many leading tabs - consider code
refactoring. Function contains 5 levels of nesting and 14 local
variables. Code can be simplified and nesting reduced by refactoring
into separate functions.

WPA code is contained and may be factored out into a separate
function. This will reduce the length and complexity of
hostif_data_indication(). At times within the WPA code errors result
in the function returning. In order to maintain this behaviour new
function should return a status integer.

Factor out WPA code into separate function. Add only code needed to
get compilation to pass, including modifying return statements. Make
no other code changes, program logic is unchanged.
Signed-off-by: default avatarTobin C. Harding <me@tobin.cc>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 33590c18
......@@ -308,59 +308,26 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info,
}
static
void hostif_data_indication(struct ks_wlan_private *priv)
int hostif_data_indication_wpa(struct ks_wlan_private *priv,
unsigned short auth_type)
{
unsigned int rx_ind_size; /* indicate data size */
struct sk_buff *skb;
unsigned short auth_type;
unsigned char temp[256];
unsigned char RecvMIC[8];
char buf[128];
struct ether_hdr *eth_hdr;
unsigned short eth_proto;
unsigned char RecvMIC[8];
char buf[128];
unsigned long now;
struct mic_failure_t *mic_failure;
struct ieee802_1x_hdr *aa1x_hdr;
struct wpa_eapol_key *eap_key;
struct michel_mic_t michel_mic;
union iwreq_data wrqu;
DPRINTK(3, "\n");
/* min length check */
if (priv->rx_size <= ETH_HLEN) {
DPRINTK(3, "rx_size = %d\n", priv->rx_size);
priv->nstats.rx_errors++;
return;
}
auth_type = get_WORD(priv); /* AuthType */
get_WORD(priv); /* Reserve Area */
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
DPRINTK(3, "ether protocol = %04X\n", eth_proto);
/* source address check */
if (!memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN)) {
DPRINTK(1, "invalid : source is own mac address !!\n");
DPRINTK(1,
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
eth_hdr->h_source[0], eth_hdr->h_source[1],
eth_hdr->h_source[2], eth_hdr->h_source[3],
eth_hdr->h_source[4], eth_hdr->h_source[5]);
priv->nstats.rx_errors++;
return;
}
/* for WPA */
if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled) {
if (memcmp(&eth_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN)) { /* source address check */
if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
DPRINTK(1, "invalid data format\n");
priv->nstats.rx_errors++;
return;
return -EINVAL;
}
if (((auth_type == TYPE_PMK1
&& priv->wpa.pairwise_suite ==
......@@ -424,10 +391,61 @@ void hostif_data_indication(struct ks_wlan_private *priv)
wireless_send_event(priv->net_dev,
IWEVCUSTOM, &wrqu,
buf);
return;
return -EINVAL;
}
}
}
return 0;
}
static
void hostif_data_indication(struct ks_wlan_private *priv)
{
unsigned int rx_ind_size; /* indicate data size */
struct sk_buff *skb;
unsigned short auth_type;
unsigned char temp[256];
struct ether_hdr *eth_hdr;
unsigned short eth_proto;
struct ieee802_1x_hdr *aa1x_hdr;
struct wpa_eapol_key *eap_key;
int rc;
DPRINTK(3, "\n");
/* min length check */
if (priv->rx_size <= ETH_HLEN) {
DPRINTK(3, "rx_size = %d\n", priv->rx_size);
priv->nstats.rx_errors++;
return;
}
auth_type = get_WORD(priv); /* AuthType */
get_WORD(priv); /* Reserve Area */
eth_hdr = (struct ether_hdr *)(priv->rxp);
eth_proto = ntohs(eth_hdr->h_proto);
DPRINTK(3, "ether protocol = %04X\n", eth_proto);
/* source address check */
if (!memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN)) {
DPRINTK(1, "invalid : source is own mac address !!\n");
DPRINTK(1,
"eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n",
eth_hdr->h_source[0], eth_hdr->h_source[1],
eth_hdr->h_source[2], eth_hdr->h_source[3],
eth_hdr->h_source[4], eth_hdr->h_source[5]);
priv->nstats.rx_errors++;
return;
}
/* for WPA */
if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled) {
rc = hostif_data_indication_wpa(priv, auth_type);
if (rc)
return;
}
if ((priv->connect_status & FORCE_DISCONNECT) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment