libertas: move SIOCGIWAP calls to wext.c
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / wext.c
index 69dd19b..dc63b33 100644 (file)
@@ -45,6 +45,39 @@ static inline void lbs_cancel_association_work(struct lbs_private *priv)
        priv->pending_assoc_req = NULL;
 }
 
+void lbs_send_disconnect_notification(struct lbs_private *priv)
+{
+       union iwreq_data wrqu;
+
+       memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
+       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
+       wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
+}
+
+void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
+{
+       union iwreq_data iwrq;
+       u8 buf[50];
+
+       lbs_deb_enter(LBS_DEB_WEXT);
+
+       memset(&iwrq, 0, sizeof(union iwreq_data));
+       memset(buf, 0, sizeof(buf));
+
+       snprintf(buf, sizeof(buf) - 1, "%s", str);
+
+       iwrq.data.length = strlen(buf) + 1 + IW_EV_LCP_LEN;
+
+       /* Send Event to upper layer */
+       lbs_deb_wext("event indication string %s\n", (char *)buf);
+       lbs_deb_wext("event indication length %d\n", iwrq.data.length);
+       lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str);
+
+       wireless_send_event(priv->dev, IWEVCUSTOM, &iwrq, buf);
+
+       lbs_deb_leave(LBS_DEB_WEXT);
+}
+
 /**
  *  @brief Find the channel frequency power info with specific channel
  *
@@ -65,8 +98,6 @@ struct chan_freq_power *lbs_find_cfp_by_band_and_channel(
        for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
                rc = &priv->region_channel[j];
 
-               if (priv->enable11d)
-                       rc = &priv->universal_channel[j];
                if (!rc->valid || !rc->CFP)
                        continue;
                if (rc->band != band)
@@ -106,8 +137,6 @@ static struct chan_freq_power *find_cfp_by_band_and_freq(
        for (j = 0; !cfp && (j < ARRAY_SIZE(priv->region_channel)); j++) {
                rc = &priv->region_channel[j];
 
-               if (priv->enable11d)
-                       rc = &priv->universal_channel[j];
                if (!rc->valid || !rc->CFP)
                        continue;
                if (rc->band != band)
@@ -168,12 +197,12 @@ static int lbs_get_freq(struct net_device *dev, struct iw_request_info *info,
        lbs_deb_enter(LBS_DEB_WEXT);
 
        cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
-                                          priv->curbssparams.channel);
+                                          priv->channel);
 
        if (!cfp) {
-               if (priv->curbssparams.channel)
+               if (priv->channel)
                        lbs_deb_wext("invalid channel %d\n",
-                              priv->curbssparams.channel);
+                              priv->channel);
                return -EINVAL;
        }
 
@@ -546,8 +575,6 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
        struct chan_freq_power *cfp;
        u8 rates[MAX_RATES + 1];
 
-       u8 flag = 0;
-
        lbs_deb_enter(LBS_DEB_WEXT);
 
        dwrq->length = sizeof(struct iw_range);
@@ -569,52 +596,21 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
 
        range->scan_capa = IW_SCAN_CAPA_ESSID;
 
-       if (priv->enable11d &&
-           (priv->connect_status == LBS_CONNECTED ||
-           priv->mesh_connect_status == LBS_CONNECTED)) {
-               u8 chan_no;
-               u8 band;
-
-               struct parsed_region_chan_11d *parsed_region_chan =
-                   &priv->parsed_region_chan;
-
-               if (parsed_region_chan == NULL) {
-                       lbs_deb_wext("11d: parsed_region_chan is NULL\n");
-                       goto out;
-               }
-               band = parsed_region_chan->band;
-               lbs_deb_wext("band %d, nr_char %d\n", band,
-                      parsed_region_chan->nr_chan);
-
+       for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
+            && (j < ARRAY_SIZE(priv->region_channel)); j++) {
+               cfp = priv->region_channel[j].CFP;
                for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
-                    && (i < parsed_region_chan->nr_chan); i++) {
-                       chan_no = parsed_region_chan->chanpwr[i].chan;
-                       lbs_deb_wext("chan_no %d\n", chan_no);
-                       range->freq[range->num_frequency].i = (long)chan_no;
+                    && priv->region_channel[j].valid
+                    && cfp
+                    && (i < priv->region_channel[j].nrcfp); i++) {
+                       range->freq[range->num_frequency].i =
+                           (long)cfp->channel;
                        range->freq[range->num_frequency].m =
-                           (long)lbs_chan_2_freq(chan_no) * 100000;
+                           (long)cfp->freq * 100000;
                        range->freq[range->num_frequency].e = 1;
+                       cfp++;
                        range->num_frequency++;
                }
-               flag = 1;
-       }
-       if (!flag) {
-               for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
-                    && (j < ARRAY_SIZE(priv->region_channel)); j++) {
-                       cfp = priv->region_channel[j].CFP;
-                       for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
-                            && priv->region_channel[j].valid
-                            && cfp
-                            && (i < priv->region_channel[j].nrcfp); i++) {
-                               range->freq[range->num_frequency].i =
-                                   (long)cfp->channel;
-                               range->freq[range->num_frequency].m =
-                                   (long)cfp->freq * 100000;
-                               range->freq[range->num_frequency].e = 1;
-                               cfp++;
-                               range->num_frequency++;
-                       }
-               }
        }
 
        lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
@@ -699,7 +695,6 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
                                  | IW_ENC_CAPA_CIPHER_CCMP;
        }
 
-out:
        lbs_deb_leave(LBS_DEB_WEXT);
        return 0;
 }
@@ -832,7 +827,7 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
        u32 rssi_qual;
        u32 tx_qual;
        u32 quality = 0;
-       int stats_valid = 0;
+       int ret, stats_valid = 0;
        u8 rssi;
        u32 tx_retries;
        struct cmd_ds_802_11_get_log log;
@@ -881,7 +876,9 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
 
        memset(&log, 0, sizeof(log));
        log.hdr.size = cpu_to_le16(sizeof(log));
-       lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
+       ret = lbs_cmd_with_response(priv, CMD_802_11_GET_LOG, &log);
+       if (ret)
+               goto out;
 
        tx_retries = le32_to_cpu(log.retry);
 
@@ -909,8 +906,10 @@ static struct iw_statistics *lbs_get_wireless_stats(struct net_device *dev)
        stats_valid = 1;
 
        /* update stats asynchronously for future calls */
-       lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
+       ret = lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
                                        0, 0, NULL);
+       if (ret)
+               lbs_pr_err("RSSI command failed\n");
 out:
        if (!stats_valid) {
                priv->wstats.miss.beacon = 0;
@@ -1020,7 +1019,7 @@ static int lbs_mesh_set_freq(struct net_device *dev,
                goto out;
        }
 
-       if (fwrq->m != priv->curbssparams.channel) {
+       if (fwrq->m != priv->channel) {
                lbs_deb_wext("mesh channel change forces eth disconnect\n");
                if (priv->mode == IW_MODE_INFRA)
                        lbs_cmd_80211_deauthenticate(priv,
@@ -2023,7 +2022,7 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
 {
        struct lbs_private *priv = dev->ml_priv;
        int ret = 0;
-       u8 ssid[IW_ESSID_MAX_SIZE];
+       u8 ssid[IEEE80211_MAX_SSID_LEN];
        u8 ssid_len = 0;
        struct assoc_request * assoc_req;
        int in_ssid_len = dwrq->length;
@@ -2037,7 +2036,7 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
        }
 
        /* Check the size of the string */
-       if (in_ssid_len > IW_ESSID_MAX_SIZE) {
+       if (in_ssid_len > IEEE80211_MAX_SSID_LEN) {
                ret = -E2BIG;
                goto out;
        }
@@ -2068,7 +2067,7 @@ out:
                        ret = -ENOMEM;
                } else {
                        /* Copy the SSID to the association request */
-                       memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE);
+                       memcpy(&assoc_req->ssid, &ssid, IEEE80211_MAX_SSID_LEN);
                        assoc_req->ssid_len = ssid_len;
                        set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
                        lbs_postpone_association_work(priv);
@@ -2119,7 +2118,7 @@ static int lbs_mesh_set_essid(struct net_device *dev,
        }
 
        /* Check the size of the string */
-       if (dwrq->length > IW_ESSID_MAX_SIZE) {
+       if (dwrq->length > IEEE80211_MAX_SSID_LEN) {
                ret = -E2BIG;
                goto out;
        }
@@ -2134,7 +2133,7 @@ static int lbs_mesh_set_essid(struct net_device *dev,
        }
 
        lbs_mesh_config(priv, CMD_ACT_MESH_CONFIG_START,
-                       priv->curbssparams.channel);
+                       priv->channel);
  out:
        lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
        return ret;