From 61d0abe910cd25c07f0eee75dc29dc3ca3e8c413 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 16 Apr 2021 15:16:33 -0500 Subject: [PATCH] netdev: Move iftype_to_string utility Move and rename this utility into netdev_iftype_to_string away from dbus.c. This also allows us to drop including nl80211.h in dbus.c --- src/dbus.c | 24 ------------------------ src/dbus.h | 2 -- src/device.c | 2 +- src/netdev.c | 22 ++++++++++++++++++++++ src/netdev.h | 2 ++ src/wiphy.c | 2 +- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/dbus.c b/src/dbus.c index c2f1e1ec..32de1e1a 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -30,36 +30,12 @@ #include -#include "linux/nl80211.h" - #include "src/agent.h" #include "src/iwd.h" #include "src/dbus.h" static struct l_dbus *g_dbus = NULL; -const char *dbus_iftype_to_string(uint32_t iftype) -{ - switch (iftype) { - case NL80211_IFTYPE_ADHOC: - return "ad-hoc"; - case NL80211_IFTYPE_STATION: - return "station"; - case NL80211_IFTYPE_AP: - return "ap"; - case NL80211_IFTYPE_P2P_CLIENT: - return "p2p-client"; - case NL80211_IFTYPE_P2P_GO: - return "p2p-go"; - case NL80211_IFTYPE_P2P_DEVICE: - return "p2p-device"; - default: - break; - } - - return NULL; -} - struct l_dbus_message *dbus_error_busy(struct l_dbus_message *msg) { return l_dbus_message_new_error(msg, IWD_SERVICE ".InProgress", diff --git a/src/dbus.h b/src/dbus.h index f98ade7a..4936dc6c 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -56,8 +56,6 @@ bool dbus_append_dict_basic(struct l_dbus_message_builder *builder, const char *name, char type, const void *data); -const char *dbus_iftype_to_string(unsigned int iftype); - struct l_dbus_message *dbus_error_busy(struct l_dbus_message *msg); struct l_dbus_message *dbus_error_failed(struct l_dbus_message *msg); struct l_dbus_message *dbus_error_aborted(struct l_dbus_message *msg); diff --git a/src/device.c b/src/device.c index 86eea6e9..dc2c181a 100644 --- a/src/device.c +++ b/src/device.c @@ -194,7 +194,7 @@ static bool device_property_get_mode(struct l_dbus *dbus, { struct device *device = user_data; uint32_t iftype = netdev_get_iftype(device->netdev); - const char *modestr = dbus_iftype_to_string(iftype); + const char *modestr = netdev_iftype_to_string(iftype); if (modestr == NULL) modestr = "unknown"; diff --git a/src/netdev.c b/src/netdev.c index ce5613c1..a63c6b12 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -194,6 +194,28 @@ static struct watchlist netdev_watches; static bool pae_over_nl80211; static bool mac_per_ssid; +const char *netdev_iftype_to_string(uint32_t iftype) +{ + switch (iftype) { + case NL80211_IFTYPE_ADHOC: + return "ad-hoc"; + case NL80211_IFTYPE_STATION: + return "station"; + case NL80211_IFTYPE_AP: + return "ap"; + case NL80211_IFTYPE_P2P_CLIENT: + return "p2p-client"; + case NL80211_IFTYPE_P2P_GO: + return "p2p-go"; + case NL80211_IFTYPE_P2P_DEVICE: + return "p2p-device"; + default: + break; + } + + return NULL; +} + static inline bool is_offload(struct handshake_state *hs) { struct netdev_handshake_state *nhs = diff --git a/src/netdev.h b/src/netdev.h index 19b6be6c..7b321bfb 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -122,6 +122,8 @@ typedef void (*netdev_get_station_cb_t)( const struct diagnostic_station_info *info, void *user_data); +const char *netdev_iftype_to_string(uint32_t iftype); + struct wiphy *netdev_get_wiphy(struct netdev *netdev); const uint8_t *netdev_get_address(struct netdev *netdev); uint32_t netdev_get_ifindex(struct netdev *netdev); diff --git a/src/wiphy.c b/src/wiphy.c index 5943721e..7d5dc4b5 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -604,7 +604,7 @@ static char **wiphy_get_supported_iftypes(struct wiphy *wiphy, uint16_t mask) if (!(supported_mask & (1 << i))) continue; - str = dbus_iftype_to_string(i + 1); + str = netdev_iftype_to_string(i + 1); if (str) ret[j++] = l_strdup(str); }