]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Pass signal strength through, fix units
authorJohannes Berg <johannes.berg@intel.com>
Sun, 1 Apr 2012 15:48:12 +0000 (18:48 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 1 Apr 2012 15:48:12 +0000 (18:48 +0300)
The signal strength is currently never used as the only driver reporting
it is nl80211 which uses IEEE80211_RADIOTAP_DB_ANTSIGNAL which is never
populated by the kernel. The kernel will (soon) populate
IEEE80211_RADIOTAP_DBM_ANTSIGNAL instead though, so use that.

Also, since it was never really populated, we can redefine the signal
field to be in dBm units only.

My next patch will also require knowing the signal strength of probe
requests throughout the code (where available), so add it to the
necessary APIs.

Signed-hostap: Johannes Berg <johannes.berg@intel.com>

13 files changed:
src/ap/beacon.c
src/ap/beacon.h
src/ap/drv_callbacks.c
src/ap/hostapd.h
src/ap/ieee802_11.c
src/ap/utils.c
src/ap/wps_hostapd.c
src/drivers/driver.h
src/drivers/driver_nl80211.c
wpa_supplicant/ap.c
wpa_supplicant/events.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index 0253663d0663fce68f8268a9b024608d4521a045..b71106381aab24793f3fbdab86c06d109397f17e 100644 (file)
@@ -293,7 +293,8 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
 
 
 void handle_probe_req(struct hostapd_data *hapd,
-                     const struct ieee80211_mgmt *mgmt, size_t len)
+                     const struct ieee80211_mgmt *mgmt, size_t len,
+                     int ssi_signal)
 {
        u8 *resp;
        struct ieee802_11_elems elems;
@@ -311,7 +312,7 @@ void handle_probe_req(struct hostapd_data *hapd,
        for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
                if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
                                            mgmt->sa, mgmt->da, mgmt->bssid,
-                                           ie, ie_len) > 0)
+                                           ie, ie_len, ssi_signal) > 0)
                        return;
 
        if (!hapd->iconf->send_probe_response)
index 0dd6021a8a1201e2279e6c0dc18f6a471fa5472c..37f10d2f587a577b1486f68182f96bd4ac6de2da 100644 (file)
@@ -19,7 +19,8 @@
 struct ieee80211_mgmt;
 
 void handle_probe_req(struct hostapd_data *hapd,
-                     const struct ieee80211_mgmt *mgmt, size_t len);
+                     const struct ieee80211_mgmt *mgmt, size_t len,
+                     int ssi_signal);
 void ieee802_11_set_beacon(struct hostapd_data *hapd);
 void ieee802_11_set_beacons(struct hostapd_iface *iface);
 void ieee802_11_update_beacons(struct hostapd_iface *iface);
index 820a903142339fc05dd037af6414eedbf8039204..bd5b908fc996bb091e9a34889188146634210f71 100644 (file)
@@ -265,7 +265,8 @@ void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr)
 
 
 int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
-                        const u8 *bssid, const u8 *ie, size_t ie_len)
+                        const u8 *bssid, const u8 *ie, size_t ie_len,
+                        int ssi_signal)
 {
        size_t i;
        int ret = 0;
@@ -276,7 +277,8 @@ int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
        random_add_randomness(sa, ETH_ALEN);
        for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) {
                if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
-                                           sa, da, bssid, ie, ie_len) > 0) {
+                                           sa, da, bssid, ie, ie_len,
+                                           ssi_signal) > 0) {
                        ret = 1;
                        break;
                }
@@ -541,7 +543,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                     data->rx_probe_req.da,
                                     data->rx_probe_req.bssid,
                                     data->rx_probe_req.ie,
-                                    data->rx_probe_req.ie_len);
+                                    data->rx_probe_req.ie_len,
+                                    data->rx_probe_req.ssi_signal);
                break;
        case EVENT_NEW_STA:
                hostapd_event_new_sta(hapd, data->new_sta.addr);
index 2cb4a65004be027201cf945454c3d8ef386e940f..63cf494ec03b252b6d8101ae79f19b1329dc48f9 100644 (file)
@@ -31,7 +31,7 @@ struct hapd_interfaces {
 
 struct hostapd_probereq_cb {
        int (*cb)(void *ctx, const u8 *sa, const u8 *da, const u8 *bssid,
-                 const u8 *ie, size_t ie_len);
+                 const u8 *ie, size_t ie_len, int ssi_signal);
        void *ctx;
 };
 
@@ -45,7 +45,7 @@ struct hostapd_rate_data {
 struct hostapd_frame_info {
        u32 channel;
        u32 datarate;
-       u32 ssi_signal;
+       int ssi_signal; /* dBm */
 };
 
 
@@ -269,7 +269,8 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
                                 int (*cb)(void *ctx, const u8 *sa,
                                           const u8 *da, const u8 *bssid,
-                                          const u8 *ie, size_t ie_len),
+                                          const u8 *ie, size_t ie_len,
+                                          int ssi_signal),
                                 void *ctx);
 void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr);
 
@@ -279,6 +280,7 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
 void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr);
 int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da,
-                        const u8 *bssid, const u8 *ie, size_t ie_len);
+                        const u8 *bssid, const u8 *ie, size_t ie_len,
+                        int ssi_signal);
 
 #endif /* HOSTAPD_H */
index 9c931ca4b955f7068aea922e72e4ceb83a150e31..f305b07de18b68152d4b773605858fc297305d88 100644 (file)
@@ -1392,7 +1392,7 @@ void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
 
 
        if (stype == WLAN_FC_STYPE_PROBE_REQ) {
-               handle_probe_req(hapd, mgmt, len);
+               handle_probe_req(hapd, mgmt, len, fi->ssi_signal);
                return;
        }
 
index 36c1182bffd4af063c9a8db4f7968065fd6ba875..3e9fc0810ce664a43f4308e6a39cfe02f2705ac9 100644 (file)
@@ -17,7 +17,8 @@
 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
                                 int (*cb)(void *ctx, const u8 *sa,
                                           const u8 *da, const u8 *bssid,
-                                          const u8 *ie, size_t ie_len),
+                                          const u8 *ie, size_t ie_len,
+                                          int ssi_signal),
                                 void *ctx)
 {
        struct hostapd_probereq_cb *n;
index 01038e9e24137b1e9ba5e52c8d5a3663fd6d33fc..e47e7e73464d2b2c6eb4497a7c24375015c91777 100644 (file)
@@ -37,7 +37,8 @@ static void hostapd_wps_upnp_deinit(struct hostapd_data *hapd);
 
 static int hostapd_wps_probe_req_rx(void *ctx, const u8 *addr, const u8 *da,
                                    const u8 *bssid,
-                                   const u8 *ie, size_t ie_len);
+                                   const u8 *ie, size_t ie_len,
+                                   int ssi_signal);
 static void hostapd_wps_ap_pin_timeout(void *eloop_data, void *user_ctx);
 
 
@@ -1178,7 +1179,8 @@ error:
 
 static int hostapd_wps_probe_req_rx(void *ctx, const u8 *addr, const u8 *da,
                                    const u8 *bssid,
-                                   const u8 *ie, size_t ie_len)
+                                   const u8 *ie, size_t ie_len,
+                                   int ssi_signal)
 {
        struct hostapd_data *hapd = ctx;
        struct wpabuf *wps_ie;
index c4f6b5f3d4730ffcfb053fc0d97651b0b53a5cf6..3c7ebe863e50fcc280b1d75806f1b4b5e92ba034 100644 (file)
@@ -3271,7 +3271,7 @@ union wpa_event_data {
                const u8 *frame;
                size_t frame_len;
                u32 datarate;
-               u32 ssi_signal;
+               int ssi_signal; /* dBm */
        } rx_mgmt;
 
        /**
@@ -3389,6 +3389,11 @@ union wpa_event_data {
                 * ie_len - Length of ie buffer in octets
                 */
                size_t ie_len;
+
+               /**
+                * signal - signal strength in dBm (or 0 if not available)
+                */
+               int ssi_signal;
        } rx_probe_req;
 
        /**
index 0c99ff8084050c66004253056688685aba094be2..512893327e378e7762b968a822089fa73c285ff5 100644 (file)
@@ -5879,8 +5879,8 @@ static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
                case IEEE80211_RADIOTAP_RATE:
                        datarate = *iter.this_arg * 5;
                        break;
-               case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
-                       ssi_signal = *iter.this_arg;
+               case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
+                       ssi_signal = (s8) *iter.this_arg;
                        break;
                }
        }
index 66b0e1f8f9882d2ba5895d01353970bfe717fbbf..d0fb1b0560b5b09e471d18fa26b735c4f84794a3 100644 (file)
@@ -357,11 +357,13 @@ static int ap_vendor_action_rx(void *ctx, const u8 *buf, size_t len, int freq)
 
 
 static int ap_probe_req_rx(void *ctx, const u8 *sa, const u8 *da,
-                          const u8 *bssid, const u8 *ie, size_t ie_len)
+                          const u8 *bssid, const u8 *ie, size_t ie_len,
+                          int ssi_signal)
 {
 #ifdef CONFIG_P2P
        struct wpa_supplicant *wpa_s = ctx;
-       return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len);
+       return wpas_p2p_probe_req_rx(wpa_s, sa, da, bssid, ie, ie_len,
+                                    ssi_signal);
 #else /* CONFIG_P2P */
        return 0;
 #endif /* CONFIG_P2P */
index 0fb2d682e129e7f074daacfab386f99162dfa5fc..1f4084050e3ebcbd95e27817de43cf0e26370764 100644 (file)
@@ -2325,8 +2325,10 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                size_t ie_len = data->rx_mgmt.frame_len -
                                        (mgmt->u.probe_req.variable -
                                         data->rx_mgmt.frame);
-                               wpas_p2p_probe_req_rx(wpa_s, src, mgmt->da,
-                                                     mgmt->bssid, ie, ie_len);
+                               wpas_p2p_probe_req_rx(
+                                       wpa_s, src, mgmt->da,
+                                       mgmt->bssid, ie, ie_len,
+                                       data->rx_mgmt.ssi_signal);
                                break;
                        }
 #endif /* CONFIG_P2P */
@@ -2402,7 +2404,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                             data->rx_probe_req.da,
                                             data->rx_probe_req.bssid,
                                             data->rx_probe_req.ie,
-                                            data->rx_probe_req.ie_len);
+                                            data->rx_probe_req.ie_len,
+                                            data->rx_probe_req.ssi_signal);
                        break;
                }
 #endif /* CONFIG_AP */
@@ -2411,7 +2414,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
                                      data->rx_probe_req.da,
                                      data->rx_probe_req.bssid,
                                      data->rx_probe_req.ie,
-                                     data->rx_probe_req.ie_len);
+                                     data->rx_probe_req.ie_len,
+                                     data->rx_probe_req.ssi_signal);
 #endif /* CONFIG_P2P */
                break;
        case EVENT_REMAIN_ON_CHANNEL:
index 874fe819d1bdeacd0406837f115dc0df43b5f2f8..bf5804ddc91d79a2e200a9912bb1205b5f6d1663 100644 (file)
@@ -3697,7 +3697,7 @@ int wpas_p2p_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
 
 int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
                          const u8 *dst, const u8 *bssid,
-                         const u8 *ie, size_t ie_len)
+                         const u8 *ie, size_t ie_len, int ssi_signal)
 {
        if (wpa_s->global->p2p_disabled)
                return 0;
index cf46eaf1b90de8175a0d4f35ed3dafa7ea41087a..4cd71932e643ee16d0550977c469e4f5656ef052 100644 (file)
@@ -54,7 +54,8 @@ int wpas_p2p_assoc_req_ie(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
                          u8 *buf, size_t len, int p2p_group);
 int wpas_p2p_probe_req_rx(struct wpa_supplicant *wpa_s, const u8 *addr,
                          const u8 *dst, const u8 *bssid,
-                         const u8 *ie, size_t ie_len);
+                         const u8 *ie, size_t ie_len,
+                         int ssi_signal);
 void wpas_p2p_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
                        const u8 *sa, const u8 *bssid,
                        u8 category, const u8 *data, size_t len, int freq);