commit 54cd428c9455764fe2958c8e7df2c6d665699dbb
parent efecce772f9a010ea70c6332de6e34bbbf5121bf
Author: James Prestwood <james.prestwood@linux.intel.com>
Date: Mon, 16 Jul 2018 15:29:14 -0700
netdev: Add IFTYPE_ADHOC interface type
netdev_set_iftype and get_iftype were also changed to
account for all three interface types.
Diffstat:
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
@@ -269,8 +269,18 @@ uint32_t netdev_get_ifindex(struct netdev *netdev)
enum netdev_iftype netdev_get_iftype(struct netdev *netdev)
{
- return netdev->type == NL80211_IFTYPE_AP ?
- NETDEV_IFTYPE_AP : NETDEV_IFTYPE_STATION;
+ switch (netdev->type) {
+ case NL80211_IFTYPE_STATION:
+ return NETDEV_IFTYPE_STATION;
+ case NL80211_IFTYPE_AP:
+ return NETDEV_IFTYPE_AP;
+ case NL80211_IFTYPE_ADHOC:
+ return NETDEV_IFTYPE_ADHOC;
+ default:
+ /* cant really do much here */
+ l_error("invalid iftype %u", netdev->type);
+ return NETDEV_IFTYPE_STATION;
+ }
}
const char *netdev_get_name(struct netdev *netdev)
@@ -3465,8 +3475,22 @@ static int netdev_cqm_rssi_update(struct netdev *netdev)
int netdev_set_iftype(struct netdev *netdev, enum netdev_iftype type)
{
struct l_genl_msg *msg;
- uint32_t iftype = (type == NETDEV_IFTYPE_AP) ?
- NL80211_IFTYPE_AP : NL80211_IFTYPE_STATION;
+ uint32_t iftype;
+
+ switch (type) {
+ case NETDEV_IFTYPE_AP:
+ iftype = NL80211_IFTYPE_AP;
+ break;
+ case NETDEV_IFTYPE_ADHOC:
+ iftype = NL80211_IFTYPE_ADHOC;
+ break;
+ case NETDEV_IFTYPE_STATION:
+ iftype = NL80211_IFTYPE_STATION;
+ break;
+ default:
+ l_error("unsupported iftype %u", type);
+ return -EINVAL;
+ }
msg = l_genl_msg_new_sized(NL80211_CMD_SET_INTERFACE, 32);
l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
diff --git a/src/netdev.h b/src/netdev.h
@@ -58,6 +58,7 @@ enum netdev_watch_event {
enum netdev_iftype {
NETDEV_IFTYPE_STATION,
NETDEV_IFTYPE_AP,
+ NETDEV_IFTYPE_ADHOC
};
typedef void (*netdev_command_func_t) (bool result, void *user_data);