[RFCv2,6/6] cfg80211: implement cfg80211_get_station cfg80211 API

Message ID 1396211704-4677-7-git-send-email-antonio@meshcoding.com (mailing list archive)
State Not Applicable, archived
Headers

Commit Message

Antonio Quartulli March 30, 2014, 8:35 p.m. UTC
  From: Antonio Quartulli <antonio@open-mesh.com>

Implement and export the new cfg80211_get_station() API.
This utility can be used by other kernel modules to obtain
detailed information about a given wireless station.

It will be in particular useful to batman-adv which will
implement a wireless rate based metric.

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
---
 include/net/cfg80211.h | 11 +++++++++++
 net/wireless/util.c    | 18 ++++++++++++++++++
 2 files changed, 29 insertions(+)
  

Comments

Johannes Berg April 8, 2014, 10:06 a.m. UTC | #1
On Sun, 2014-03-30 at 22:35 +0200, Antonio Quartulli wrote:

>  /**
> + * cfg80211_get_station - retrieve information about a given station
> + * @dev: the device where the station is supposed to be connected to
> + * @mac_addr: the mac address of the station of interest
> + * @sinfo: pointer to the structure to fill with the information
> + *
> + * Returns 0 on success or a negative error code otherwise.
> + */
> +int cfg80211_get_station(struct net_device *dev, u8 *mac_addr,
> +			 struct station_info *sinfo);

mac_addr should be const

Any thoughts about clearing/filling/partially filling *sinfo when
returning an error?

johannes
  
Antonio Quartulli April 10, 2014, 4:02 p.m. UTC | #2
On 08/04/14 12:06, Johannes Berg wrote:
> On Sun, 2014-03-30 at 22:35 +0200, Antonio Quartulli wrote:
> 
>>  /**
>> + * cfg80211_get_station - retrieve information about a given station
>> + * @dev: the device where the station is supposed to be connected to
>> + * @mac_addr: the mac address of the station of interest
>> + * @sinfo: pointer to the structure to fill with the information
>> + *
>> + * Returns 0 on success or a negative error code otherwise.
>> + */
>> +int cfg80211_get_station(struct net_device *dev, u8 *mac_addr,
>> +			 struct station_info *sinfo);
> 
> mac_addr should be const

True

> 
> Any thoughts about clearing/filling/partially filling *sinfo when
> returning an error?

At the moment this function relies on what rdev_get_station() does and I
always assumed that in case of error the content of *sinfo should be
considered "undefined".

An option can be to set the object to 0 in case of error, but is it
really needed?

Any other change should be applied to rdev->ops->get_station(), not
here. I.e. fill the object as much as possible and never return an error
- just flag what was filled.


Cheers,
  
Johannes Berg April 10, 2014, 5:12 p.m. UTC | #3
On Thu, 2014-04-10 at 18:02 +0200, Antonio Quartulli wrote:

> > Any thoughts about clearing/filling/partially filling *sinfo when
> > returning an error?
> 
> At the moment this function relies on what rdev_get_station() does and I
> always assumed that in case of error the content of *sinfo should be
> considered "undefined".

That's fine, maybe add a line of documentation?

johannes
  
Antonio Quartulli April 11, 2014, 7:04 a.m. UTC | #4
On 10/04/14 19:12, Johannes Berg wrote:
> On Thu, 2014-04-10 at 18:02 +0200, Antonio Quartulli wrote:
> 
>>> Any thoughts about clearing/filling/partially filling *sinfo when
>>> returning an error?
>>
>> At the moment this function relies on what rdev_get_station() does and I
>> always assumed that in case of error the content of *sinfo should be
>> considered "undefined".
> 
> That's fine, maybe add a line of documentation?

Oky! will do.

Cheers,
  

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 4c8ebe9..45062aa 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1065,6 +1065,17 @@  struct station_info {
 };
 
 /**
+ * cfg80211_get_station - retrieve information about a given station
+ * @dev: the device where the station is supposed to be connected to
+ * @mac_addr: the mac address of the station of interest
+ * @sinfo: pointer to the structure to fill with the information
+ *
+ * Returns 0 on success or a negative error code otherwise.
+ */
+int cfg80211_get_station(struct net_device *dev, u8 *mac_addr,
+			 struct station_info *sinfo);
+
+/**
  * enum monitor_flags - monitor flags
  *
  * Monitor interface configuration flags. Note that these must be the bits
diff --git a/net/wireless/util.c b/net/wireless/util.c
index c5d0208..c691cf8 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1482,6 +1482,24 @@  unsigned int ieee80211_get_num_supported_channels(struct wiphy *wiphy)
 }
 EXPORT_SYMBOL(ieee80211_get_num_supported_channels);
 
+int cfg80211_get_station(struct net_device *dev, u8 *mac_addr,
+			 struct station_info *sinfo)
+{
+	struct cfg80211_registered_device *rdev;
+	struct wireless_dev *wdev;
+
+	wdev = dev->ieee80211_ptr;
+	if (!wdev)
+		return -EOPNOTSUPP;
+
+	rdev = wiphy_to_dev(wdev->wiphy);
+	if (!rdev->ops->get_station)
+		return -EOPNOTSUPP;
+
+	return rdev_get_station(rdev, dev, mac_addr, sinfo);
+}
+EXPORT_SYMBOL(cfg80211_get_station);
+
 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
 const unsigned char rfc1042_header[] __aligned(2) =