diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-06-30 18:20:48 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-01-16 17:37:14 +0100 |
commit | 0150b644ed0bd2ef6db4175c5cffef2ee4d4d501 (patch) | |
tree | 0240608205c37550e2f71fa5f229c19fd4048082 /src | |
parent | 17da42704ab3510bd32bed1e6a4293c1e3424bad (diff) |
supplicant: add an enum to specify the driver
With macsec we now have 3 drivers and a boolean is no longer enough.
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/nm-device-ethernet.c | 2 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 2 | ||||
-rw-r--r-- | src/supplicant/nm-supplicant-interface.c | 41 | ||||
-rw-r--r-- | src/supplicant/nm-supplicant-interface.h | 4 | ||||
-rw-r--r-- | src/supplicant/nm-supplicant-manager.c | 4 | ||||
-rw-r--r-- | src/supplicant/nm-supplicant-manager.h | 2 | ||||
-rw-r--r-- | src/supplicant/nm-supplicant-types.h | 6 |
7 files changed, 41 insertions, 20 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index dbea209eca..f9d753a58f 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -776,7 +776,7 @@ supplicant_interface_init (NMDeviceEthernet *self) priv->supplicant.iface = nm_supplicant_manager_create_interface (priv->supplicant.mgr, nm_device_get_iface (NM_DEVICE (self)), - FALSE); + NM_SUPPLICANT_DRIVER_WIRED); if (!priv->supplicant.iface) { _LOGE (LOGD_DEVICE | LOGD_ETHER, diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 9d002e8362..9e7196d3ec 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -232,7 +232,7 @@ supplicant_interface_acquire (NMDeviceWifi *self) priv->sup_iface = nm_supplicant_manager_create_interface (priv->sup_mgr, nm_device_get_iface (NM_DEVICE (self)), - TRUE); + NM_SUPPLICANT_DRIVER_WIRELESS); if (!priv->sup_iface) { _LOGE (LOGD_WIFI, "Couldn't initialize supplicant interface"); return FALSE; diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index 408704bc60..6fc8553584 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -56,14 +56,14 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSupplicantInterface, PROP_IFACE, PROP_SCANNING, PROP_CURRENT_BSS, - PROP_IS_WIRELESS, + PROP_DRIVER, PROP_FAST_SUPPORTED, PROP_AP_SUPPORT, ); typedef struct { char * dev; - bool is_wireless; + NMSupplicantDriver driver; bool fast_supported; gboolean has_credreq; /* Whether querying 802.1x credentials is supported */ NMSupplicantFeature ap_support; /* Lightweight AP mode support */ @@ -918,6 +918,7 @@ on_wpas_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_d gs_free_error GError *error = NULL; GDBusProxy *wpas_proxy; GVariantBuilder props; + const char *driver_name = NULL; wpas_proxy = g_dbus_proxy_new_for_bus_finish (result, &error); if (!wpas_proxy) { @@ -939,10 +940,24 @@ on_wpas_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_d * when the supplicant has started. */ + switch (priv->driver) { + case NM_SUPPLICANT_DRIVER_WIRELESS: + driver_name = DEFAULT_WIFI_DRIVER; + break; + case NM_SUPPLICANT_DRIVER_WIRED: + driver_name = "wired"; + break; + case NM_SUPPLICANT_DRIVER_MACSEC: + driver_name = "macsec_linux"; + break; + } + + g_return_if_fail (driver_name); + g_variant_builder_init (&props, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&props, "{sv}", "Driver", - g_variant_new_string (priv->is_wireless ? DEFAULT_WIFI_DRIVER : "wired")); + g_variant_new_string (driver_name)); g_variant_builder_add (&props, "{sv}", "Ifname", g_variant_new_string (priv->dev)); @@ -1448,7 +1463,7 @@ nm_supplicant_interface_get_max_scan_ssids (NMSupplicantInterface *self) NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname, - gboolean is_wireless, + NMSupplicantDriver driver, gboolean fast_supported, NMSupplicantFeature ap_support) { @@ -1456,7 +1471,7 @@ nm_supplicant_interface_new (const char *ifname, return g_object_new (NM_TYPE_SUPPLICANT_INTERFACE, NM_SUPPLICANT_INTERFACE_IFACE, ifname, - NM_SUPPLICANT_INTERFACE_IS_WIRELESS, is_wireless, + NM_SUPPLICANT_INTERFACE_DRIVER, (guint) driver, NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, fast_supported, NM_SUPPLICANT_INTERFACE_AP_SUPPORT, (int) ap_support, NULL); @@ -1485,9 +1500,9 @@ set_property (GObject *object, priv->dev = g_value_dup_string (value); g_return_if_fail (priv->dev); break; - case PROP_IS_WIRELESS: + case PROP_DRIVER: /* construct-only */ - priv->is_wireless = g_value_get_boolean (value); + priv->driver = g_value_get_uint (value); break; case PROP_FAST_SUPPORTED: /* construct-only */ @@ -1576,12 +1591,12 @@ nm_supplicant_interface_class_init (NMSupplicantInterfaceClass *klass) G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_IS_WIRELESS] = - g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_IS_WIRELESS, "", "", - TRUE, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); + obj_properties[PROP_DRIVER] = + g_param_spec_uint (NM_SUPPLICANT_INTERFACE_DRIVER, "", "", + 0, G_MAXUINT, NM_SUPPLICANT_DRIVER_WIRELESS, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); obj_properties[PROP_FAST_SUPPORTED] = g_param_spec_boolean (NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED, "", "", TRUE, diff --git a/src/supplicant/nm-supplicant-interface.h b/src/supplicant/nm-supplicant-interface.h index 852bf10409..5ab66d5dee 100644 --- a/src/supplicant/nm-supplicant-interface.h +++ b/src/supplicant/nm-supplicant-interface.h @@ -57,7 +57,7 @@ enum { #define NM_SUPPLICANT_INTERFACE_IFACE "iface" #define NM_SUPPLICANT_INTERFACE_SCANNING "scanning" #define NM_SUPPLICANT_INTERFACE_CURRENT_BSS "current-bss" -#define NM_SUPPLICANT_INTERFACE_IS_WIRELESS "is-wireless" +#define NM_SUPPLICANT_INTERFACE_DRIVER "driver" #define NM_SUPPLICANT_INTERFACE_FAST_SUPPORTED "fast-supported" #define NM_SUPPLICANT_INTERFACE_AP_SUPPORT "ap-support" @@ -76,7 +76,7 @@ typedef struct _NMSupplicantInterfaceClass NMSupplicantInterfaceClass; GType nm_supplicant_interface_get_type (void); NMSupplicantInterface * nm_supplicant_interface_new (const char *ifname, - gboolean is_wireless, + NMSupplicantDriver driver, gboolean fast_supported, NMSupplicantFeature ap_support); diff --git a/src/supplicant/nm-supplicant-manager.c b/src/supplicant/nm-supplicant-manager.c index 573fdaa0fa..2fbfa391ba 100644 --- a/src/supplicant/nm-supplicant-manager.c +++ b/src/supplicant/nm-supplicant-manager.c @@ -137,7 +137,7 @@ _sup_iface_last_ref (gpointer data, NMSupplicantInterface * nm_supplicant_manager_create_interface (NMSupplicantManager *self, const char *ifname, - gboolean is_wireless) + NMSupplicantDriver driver) { NMSupplicantManagerPrivate *priv; NMSupplicantInterface *iface; @@ -157,7 +157,7 @@ nm_supplicant_manager_create_interface (NMSupplicantManager *self, } iface = nm_supplicant_interface_new (ifname, - is_wireless, + driver, priv->fast_supported, priv->ap_support); diff --git a/src/supplicant/nm-supplicant-manager.h b/src/supplicant/nm-supplicant-manager.h index 3c1627b5aa..8928cf206b 100644 --- a/src/supplicant/nm-supplicant-manager.h +++ b/src/supplicant/nm-supplicant-manager.h @@ -40,6 +40,6 @@ NMSupplicantManager *nm_supplicant_manager_get (void); NMSupplicantInterface *nm_supplicant_manager_create_interface (NMSupplicantManager *mgr, const char *ifname, - gboolean is_wireless); + NMSupplicantDriver driver); #endif /* __NETWORKMANAGER_SUPPLICANT_MANAGER_H__ */ diff --git a/src/supplicant/nm-supplicant-types.h b/src/supplicant/nm-supplicant-types.h index e9be5be463..f75827ec60 100644 --- a/src/supplicant/nm-supplicant-types.h +++ b/src/supplicant/nm-supplicant-types.h @@ -46,6 +46,12 @@ typedef enum { NM_SUPPLICANT_ERROR_CONFIG = 1, /*< nick=Config >*/ } NMSupplicantError; +typedef enum { + NM_SUPPLICANT_DRIVER_WIRELESS, + NM_SUPPLICANT_DRIVER_WIRED, + NM_SUPPLICANT_DRIVER_MACSEC, +} NMSupplicantDriver; + #define NM_SUPPLICANT_ERROR (nm_supplicant_error_quark ()) GQuark nm_supplicant_error_quark (void); |