nl80211: Register read_sta_data() handler for station only builds
This driver_op can now be used in station mode, too, to fetch
information about the connection with the AP, so allow this to be used
even if wpa_supplicant is built without AP mode support.
Change-Id: Ibef1d27ed0e2df312e715a88d500500c661860d1
Signed-hostap: Jouni Malinen <j@w1.fi>
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index e392072..e9f926f 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1638,7 +1638,7 @@
int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
/**
- * read_sta_data - Fetch station data (AP only)
+ * read_sta_data - Fetch station data
* @priv: Private driver interface data
* @data: Buffer for returning station information
* @addr: MAC address of the station
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index eeec609..a9e6139 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -7391,6 +7391,8 @@
return -ENOBUFS;
}
+#endif /* HOSTAPD || CONFIG_AP */
+
static int get_sta_handler(struct nl_msg *msg, void *arg)
{
@@ -7404,6 +7406,7 @@
[NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
[NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
[NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
+ [NL80211_STA_INFO_TX_FAILED] = { .type = NLA_U32 },
};
nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
@@ -7439,6 +7442,9 @@
if (stats[NL80211_STA_INFO_TX_PACKETS])
data->tx_packets =
nla_get_u32(stats[NL80211_STA_INFO_TX_PACKETS]);
+ if (stats[NL80211_STA_INFO_TX_FAILED])
+ data->tx_retry_failed =
+ nla_get_u32(stats[NL80211_STA_INFO_TX_FAILED]);
return NL_SKIP;
}
@@ -7467,6 +7473,8 @@
}
+#if defined(HOSTAPD) || defined(CONFIG_AP)
+
static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
int cw_min, int cw_max, int burst_time)
{
@@ -9204,7 +9212,6 @@
#if defined(HOSTAPD) || defined(CONFIG_AP)
.get_seqnum = i802_get_seqnum,
.flush = i802_flush,
- .read_sta_data = i802_read_sta_data,
.get_inact_sec = i802_get_inact_sec,
.sta_clear_stats = i802_sta_clear_stats,
.set_rts = i802_set_rts,
@@ -9214,6 +9221,7 @@
.sta_deauth = i802_sta_deauth,
.sta_disassoc = i802_sta_disassoc,
#endif /* HOSTAPD || CONFIG_AP */
+ .read_sta_data = i802_read_sta_data,
.set_freq = i802_set_freq,
.send_action = wpa_driver_nl80211_send_action,
.send_action_cancel_wait = wpa_driver_nl80211_send_action_cancel_wait,
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 059c586..dbf8a84 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -4331,6 +4331,7 @@
return ret;
}
+
static int wpa_supplicant_pktcnt_poll(struct wpa_supplicant *wpa_s, char *buf,
size_t buflen)
{
@@ -4342,8 +4343,8 @@
return -1;
ret = os_snprintf(buf, buflen, "TXGOOD=%lu\nTXBAD=%lu\nRXGOOD=%lu\n",
- sta.tx_packets, sta.tx_retry_failed, sta.rx_packets);
- if (ret < 0 || (unsigned int) ret > buflen)
+ sta.tx_packets, sta.tx_retry_failed, sta.rx_packets);
+ if (ret < 0 || (size_t) ret > buflen)
return -1;
return ret;
}
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
index ee9f6b0..bc148ca 100644
--- a/wpa_supplicant/driver_i.h
+++ b/wpa_supplicant/driver_i.h
@@ -467,7 +467,8 @@
struct hostap_sta_driver_data *sta)
{
if (wpa_s->driver->read_sta_data)
- return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta, wpa_s->bssid);
+ return wpa_s->driver->read_sta_data(wpa_s->drv_priv, sta,
+ wpa_s->bssid);
return -1;
}