netdev: Mirror nl80211.h iftype enum values

This makes conversions simpler.  Also fixes a bug where P2P devices were
printed with an incorrect Mode value since dbus_iftype_to_string was
assuming that an iftype as defined in nl80211.h was being passed in,
while netdev was returning an enum value defined in netdev.h.
This commit is contained in:
Denis Kenzior 2021-04-16 15:13:01 -05:00
parent 89b3d34dd3
commit 6096d8895d
2 changed files with 4 additions and 18 deletions

View File

@ -315,22 +315,7 @@ uint64_t netdev_get_wdev_id(struct netdev *netdev)
enum netdev_iftype netdev_get_iftype(struct netdev *netdev)
{
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;
case NL80211_IFTYPE_P2P_CLIENT:
return NETDEV_IFTYPE_P2P_CLIENT;
case NL80211_IFTYPE_P2P_GO:
return NETDEV_IFTYPE_P2P_GO;
default:
/* can't really do much here */
l_error("unknown iftype %u", netdev->type);
return NETDEV_IFTYPE_STATION;
}
return netdev->type;
}
const char *netdev_get_name(struct netdev *netdev)

View File

@ -59,12 +59,13 @@ enum netdev_watch_event {
NETDEV_WATCH_EVENT_ADDRESS_CHANGE,
};
/* Mirror definitions from nl80211.h to make conversions simpler */
enum netdev_iftype {
NETDEV_IFTYPE_ADHOC = 1,
NETDEV_IFTYPE_STATION = 2,
NETDEV_IFTYPE_AP = 3,
NETDEV_IFTYPE_P2P_CLIENT,
NETDEV_IFTYPE_P2P_GO,
NETDEV_IFTYPE_P2P_CLIENT = 8,
NETDEV_IFTYPE_P2P_GO = 9,
};
typedef void (*netdev_command_cb_t)(struct netdev *netdev, int result,