wifi: move wifi-utils into platform

Move wifi-utils into NMPlatform, and update callers to use the new
NMPlatform wrappers
This commit is contained in:
Dan Winship
2014-02-04 14:27:03 +01:00
parent 090a52217c
commit df435f4015
20 changed files with 534 additions and 77 deletions

View File

@@ -130,6 +130,11 @@ nm_sources = \
platform/nm-linux-platform.h \ platform/nm-linux-platform.h \
platform/nm-platform.c \ platform/nm-platform.c \
platform/nm-platform.h \ platform/nm-platform.h \
platform/wifi/wifi-utils-nl80211.c \
platform/wifi/wifi-utils-nl80211.h \
platform/wifi/wifi-utils-private.h \
platform/wifi/wifi-utils.c \
platform/wifi/wifi-utils.h \
\ \
rdisc/nm-fake-rdisc.c \ rdisc/nm-fake-rdisc.c \
rdisc/nm-fake-rdisc.h \ rdisc/nm-fake-rdisc.h \
@@ -194,12 +199,6 @@ nm_sources = \
vpn-manager/nm-vpn-service.c \ vpn-manager/nm-vpn-service.c \
vpn-manager/nm-vpn-service.h \ vpn-manager/nm-vpn-service.h \
\ \
wifi/wifi-utils-nl80211.c \
wifi/wifi-utils-nl80211.h \
wifi/wifi-utils-private.h \
wifi/wifi-utils.c \
wifi/wifi-utils.h \
\
nm-activation-request.c \ nm-activation-request.c \
nm-activation-request.h \ nm-activation-request.h \
nm-active-connection.c \ nm-active-connection.c \
@@ -270,7 +269,9 @@ nm_sources += nm-sleep-monitor-upower.c
endif endif
if WITH_WEXT if WITH_WEXT
nm_sources += wifi/wifi-utils-wext.c wifi/wifi-utils-wext.h nm_sources += \
platform/wifi/wifi-utils-wext.c \
platform/wifi/wifi-utils-wext.h
endif endif

View File

@@ -53,10 +53,6 @@
#include "nm-manager.h" #include "nm-manager.h"
#include "nm-enum-types.h" #include "nm-enum-types.h"
#include "nm-dbus-manager.h" #include "nm-dbus-manager.h"
#include "wifi-utils.h"
#if HAVE_WEXT
#include "wifi-utils-wext.h"
#endif
/* This is a bug; but we can't really change API now... */ /* This is a bug; but we can't really change API now... */
#include "NetworkManagerVPN.h" #include "NetworkManagerVPN.h"
@@ -83,8 +79,6 @@ enum {
struct _NMDeviceOlpcMeshPrivate { struct _NMDeviceOlpcMeshPrivate {
gboolean dispose_has_run; gboolean dispose_has_run;
WifiData * wifi_data;
NMDevice * companion; NMDevice * companion;
gboolean stage1_waiting; gboolean stage1_waiting;
guint device_added_id; guint device_added_id;
@@ -126,6 +120,7 @@ constructor (GType type,
GObjectClass *klass; GObjectClass *klass;
NMDeviceOlpcMesh *self; NMDeviceOlpcMesh *self;
NMDeviceOlpcMeshPrivate *priv; NMDeviceOlpcMeshPrivate *priv;
NMDeviceWifiCapabilities caps;
klass = G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class); klass = G_OBJECT_CLASS (nm_device_olpc_mesh_parent_class);
object = klass->constructor (type, n_construct_params, construct_params); object = klass->constructor (type, n_construct_params, construct_params);
@@ -139,17 +134,7 @@ constructor (GType type,
nm_device_get_iface (NM_DEVICE (self)), nm_device_get_iface (NM_DEVICE (self)),
nm_device_get_ifindex (NM_DEVICE (self))); nm_device_get_ifindex (NM_DEVICE (self)));
/* if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)), &caps)) {
* The kernel driver now uses nl80211, but we force use of WEXT because
* the cfg80211 interactions are not quite ready to support access to
* mesh control through nl80211 just yet.
*/
#if HAVE_WEXT
priv->wifi_data = wifi_wext_init (nm_device_get_iface (NM_DEVICE (self)),
nm_device_get_ifindex (NM_DEVICE (self)),
FALSE);
#endif
if (priv->wifi_data == NULL) {
nm_log_warn (LOGD_HW | LOGD_OLPC_MESH, "(%s): failed to initialize WiFi driver", nm_log_warn (LOGD_HW | LOGD_OLPC_MESH, "(%s): failed to initialize WiFi driver",
nm_device_get_iface (NM_DEVICE (self))); nm_device_get_iface (NM_DEVICE (self)));
g_object_unref (object); g_object_unref (object);
@@ -287,10 +272,10 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
static void static void
_mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel) _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel)
{ {
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self); int ifindex = nm_device_get_ifindex (NM_DEVICE (self));
if (wifi_utils_get_mesh_channel (priv->wifi_data) != channel) { if (nm_platform_mesh_get_channel (ifindex) != channel) {
if (wifi_utils_set_mesh_channel (priv->wifi_data, channel)) if (nm_platform_mesh_set_channel (ifindex, channel))
g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL); g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL);
} }
} }
@@ -299,7 +284,6 @@ static NMActStageReturn
act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason) act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
{ {
NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev); NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (dev);
NMDeviceOlpcMeshPrivate *priv = NM_DEVICE_OLPC_MESH_GET_PRIVATE (self);
NMConnection *connection; NMConnection *connection;
NMSettingOlpcMesh *s_mesh; NMSettingOlpcMesh *s_mesh;
guint32 channel; guint32 channel;
@@ -315,7 +299,8 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
channel = nm_setting_olpc_mesh_get_channel (s_mesh); channel = nm_setting_olpc_mesh_get_channel (s_mesh);
if (channel != 0) if (channel != 0)
_mesh_set_channel (self, channel); _mesh_set_channel (self, channel);
wifi_utils_set_mesh_ssid (priv->wifi_data, nm_setting_olpc_mesh_get_ssid (s_mesh)); nm_platform_mesh_set_ssid (nm_device_get_ifindex (dev),
nm_setting_olpc_mesh_get_ssid (s_mesh));
anycast_addr_array = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh); anycast_addr_array = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh);
if (anycast_addr_array) if (anycast_addr_array)
@@ -369,9 +354,6 @@ dispose (GObject *object)
} }
priv->dispose_has_run = TRUE; priv->dispose_has_run = TRUE;
if (priv->wifi_data)
wifi_utils_deinit (priv->wifi_data);
companion_cleanup (self); companion_cleanup (self);
if (priv->device_added_id) if (priv->device_added_id)
@@ -397,7 +379,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_boxed (value, "/"); g_value_set_boxed (value, "/");
break; break;
case PROP_ACTIVE_CHANNEL: case PROP_ACTIVE_CHANNEL:
g_value_set_uint (value, wifi_utils_get_mesh_channel (priv->wifi_data)); g_value_set_uint (value, nm_platform_mesh_get_channel (nm_device_get_ifindex (NM_DEVICE (device))));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View File

@@ -57,7 +57,6 @@
#include "nm-manager-auth.h" #include "nm-manager-auth.h"
#include "nm-settings-connection.h" #include "nm-settings-connection.h"
#include "nm-enum-types.h" #include "nm-enum-types.h"
#include "wifi-utils.h"
#include "nm-dbus-glib-types.h" #include "nm-dbus-glib-types.h"
@@ -149,7 +148,6 @@ struct _NMDeviceWifiPrivate {
gboolean requested_scan; gboolean requested_scan;
Supplicant supplicant; Supplicant supplicant;
WifiData * wifi_data;
gboolean ssid_found; gboolean ssid_found;
NM80211Mode mode; NM80211Mode mode;
@@ -304,16 +302,13 @@ constructor (GType type,
nm_device_get_iface (NM_DEVICE (self)), nm_device_get_iface (NM_DEVICE (self)),
nm_device_get_ifindex (NM_DEVICE (self))); nm_device_get_ifindex (NM_DEVICE (self)));
priv->wifi_data = wifi_utils_init (nm_device_get_iface (NM_DEVICE (self)), if (!nm_platform_wifi_get_capabilities (nm_device_get_ifindex (NM_DEVICE (self)),
nm_device_get_ifindex (NM_DEVICE (self)), &priv->capabilities)) {
TRUE);
if (priv->wifi_data == NULL) {
nm_log_warn (LOGD_HW | LOGD_WIFI, "(%s): failed to initialize WiFi driver", nm_log_warn (LOGD_HW | LOGD_WIFI, "(%s): failed to initialize WiFi driver",
nm_device_get_iface (NM_DEVICE (self))); nm_device_get_iface (NM_DEVICE (self)));
g_object_unref (object); g_object_unref (object);
return NULL; return NULL;
} }
priv->capabilities = wifi_utils_get_caps (priv->wifi_data);
if (priv->capabilities & NM_WIFI_DEVICE_CAP_AP) { if (priv->capabilities & NM_WIFI_DEVICE_CAP_AP) {
nm_log_info (LOGD_HW | LOGD_WIFI, "(%s): driver supports Access Point (AP) mode", nm_log_info (LOGD_HW | LOGD_WIFI, "(%s): driver supports Access Point (AP) mode",
@@ -487,6 +482,7 @@ find_active_ap (NMDeviceWifi *self,
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
const char *iface = nm_device_get_iface (NM_DEVICE (self)); const char *iface = nm_device_get_iface (NM_DEVICE (self));
int ifindex = nm_device_get_ifindex (NM_DEVICE (self));
struct ether_addr bssid; struct ether_addr bssid;
GByteArray *ssid; GByteArray *ssid;
GSList *iter; GSList *iter;
@@ -497,7 +493,7 @@ find_active_ap (NMDeviceWifi *self,
NM80211Mode devmode; NM80211Mode devmode;
guint32 devfreq; guint32 devfreq;
wifi_utils_get_bssid (priv->wifi_data, &bssid); nm_platform_wifi_get_bssid (ifindex, &bssid);
nm_log_dbg (LOGD_WIFI, "(%s): active BSSID: %02x:%02x:%02x:%02x:%02x:%02x", nm_log_dbg (LOGD_WIFI, "(%s): active BSSID: %02x:%02x:%02x:%02x:%02x:%02x",
iface, iface,
bssid.ether_addr_octet[0], bssid.ether_addr_octet[1], bssid.ether_addr_octet[0], bssid.ether_addr_octet[1],
@@ -507,15 +503,15 @@ find_active_ap (NMDeviceWifi *self,
if (!nm_ethernet_address_is_valid (&bssid)) if (!nm_ethernet_address_is_valid (&bssid))
return NULL; return NULL;
ssid = wifi_utils_get_ssid (priv->wifi_data); ssid = nm_platform_wifi_get_ssid (ifindex);
nm_log_dbg (LOGD_WIFI, "(%s): active SSID: %s%s%s", nm_log_dbg (LOGD_WIFI, "(%s): active SSID: %s%s%s",
iface, iface,
ssid ? "'" : "", ssid ? "'" : "",
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)", ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
ssid ? "'" : ""); ssid ? "'" : "");
devmode = wifi_utils_get_mode (priv->wifi_data); devmode = nm_platform_wifi_get_mode (ifindex);
devfreq = wifi_utils_get_freq (priv->wifi_data); devfreq = nm_platform_wifi_get_frequency (ifindex);
/* When matching hidden APs, do a second pass that ignores the SSID check, /* When matching hidden APs, do a second pass that ignores the SSID check,
* because NM might not yet know the SSID of the hidden AP in the scan list * because NM might not yet know the SSID of the hidden AP in the scan list
@@ -692,6 +688,7 @@ static void
periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap) periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
int ifindex = nm_device_get_ifindex (NM_DEVICE (self));
NMAccessPoint *new_ap; NMAccessPoint *new_ap;
guint32 new_rate; guint32 new_rate;
int percent; int percent;
@@ -730,7 +727,7 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
if (priv->current_ap && (nm_ap_get_mode (priv->current_ap) == NM_802_11_MODE_ADHOC)) { if (priv->current_ap && (nm_ap_get_mode (priv->current_ap) == NM_802_11_MODE_ADHOC)) {
struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} }; struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} };
wifi_utils_get_bssid (priv->wifi_data, &bssid); nm_platform_wifi_get_bssid (ifindex, &bssid);
/* 0x02 means "locally administered" and should be OR-ed into /* 0x02 means "locally administered" and should be OR-ed into
* the first byte of IBSS BSSIDs. * the first byte of IBSS BSSIDs.
*/ */
@@ -744,7 +741,7 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
/* Try to smooth out the strength. Atmel cards, for example, will give no strength /* Try to smooth out the strength. Atmel cards, for example, will give no strength
* one second and normal strength the next. * one second and normal strength the next.
*/ */
percent = wifi_utils_get_qual (priv->wifi_data); percent = nm_platform_wifi_get_quality (ifindex);
if (percent >= 0 || ++priv->invalid_strength_counter > 3) { if (percent >= 0 || ++priv->invalid_strength_counter > 3) {
nm_ap_set_strength (new_ap, (gint8) percent); nm_ap_set_strength (new_ap, (gint8) percent);
priv->invalid_strength_counter = 0; priv->invalid_strength_counter = 0;
@@ -782,7 +779,7 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
set_current_ap (self, new_ap, TRUE, FALSE); set_current_ap (self, new_ap, TRUE, FALSE);
} }
new_rate = wifi_utils_get_rate (priv->wifi_data); new_rate = nm_platform_wifi_get_rate (ifindex);
if (new_rate != priv->rate) { if (new_rate != priv->rate) {
priv->rate = new_rate; priv->rate = new_rate;
g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_BITRATE); g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_BITRATE);
@@ -854,6 +851,7 @@ deactivate (NMDevice *dev)
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (dev); NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
int ifindex = nm_device_get_ifindex (dev);
NMActRequest *req; NMActRequest *req;
NMConnection *connection; NMConnection *connection;
NM80211Mode old_mode = priv->mode; NM80211Mode old_mode = priv->mode;
@@ -882,7 +880,7 @@ deactivate (NMDevice *dev)
set_current_ap (self, NULL, TRUE, FALSE); set_current_ap (self, NULL, TRUE, FALSE);
/* Clear any critical protocol notification in the Wi-Fi stack */ /* Clear any critical protocol notification in the Wi-Fi stack */
wifi_utils_indicate_addressing_running (priv->wifi_data, FALSE); nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
/* Reset MAC address back to initial address */ /* Reset MAC address back to initial address */
nm_device_set_hw_addr (dev, priv->initial_hw_addr, "reset", LOGD_WIFI); nm_device_set_hw_addr (dev, priv->initial_hw_addr, "reset", LOGD_WIFI);
@@ -890,9 +888,9 @@ deactivate (NMDevice *dev)
/* Ensure we're in infrastructure mode after deactivation; some devices /* Ensure we're in infrastructure mode after deactivation; some devices
* (usually older ones) don't scan well in adhoc mode. * (usually older ones) don't scan well in adhoc mode.
*/ */
if (wifi_utils_get_mode (priv->wifi_data) != NM_802_11_MODE_INFRA) { if (nm_platform_wifi_get_mode (ifindex) != NM_802_11_MODE_INFRA) {
nm_device_take_down (NM_DEVICE (self), TRUE); nm_device_take_down (NM_DEVICE (self), TRUE);
wifi_utils_set_mode (priv->wifi_data, NM_802_11_MODE_INFRA); nm_platform_wifi_set_mode (ifindex, NM_802_11_MODE_INFRA);
nm_device_bring_up (NM_DEVICE (self), TRUE, NULL); nm_device_bring_up (NM_DEVICE (self), TRUE, NULL);
} }
@@ -2953,7 +2951,6 @@ ensure_hotspot_frequency (NMDeviceWifi *self,
NMSettingWireless *s_wifi, NMSettingWireless *s_wifi,
NMAccessPoint *ap) NMAccessPoint *ap)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
const char *band = nm_setting_wireless_get_band (s_wifi); const char *band = nm_setting_wireless_get_band (s_wifi);
const guint32 a_freqs[] = { 5180, 5200, 5220, 5745, 5765, 5785, 5805, 0 }; const guint32 a_freqs[] = { 5180, 5200, 5220, 5745, 5765, 5785, 5805, 0 };
const guint32 bg_freqs[] = { 2412, 2437, 2462, 2472, 0 }; const guint32 bg_freqs[] = { 2412, 2437, 2462, 2472, 0 };
@@ -2965,9 +2962,9 @@ ensure_hotspot_frequency (NMDeviceWifi *self,
return; return;
if (g_strcmp0 (band, "a") == 0) if (g_strcmp0 (band, "a") == 0)
freq = wifi_utils_find_freq (priv->wifi_data, a_freqs); freq = nm_platform_wifi_find_frequency (nm_device_get_ifindex (NM_DEVICE (self)), a_freqs);
else else
freq = wifi_utils_find_freq (priv->wifi_data, bg_freqs); freq = nm_platform_wifi_find_frequency (nm_device_get_ifindex (NM_DEVICE (self)), bg_freqs);
if (!freq) if (!freq)
freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462; freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462;
@@ -3099,7 +3096,6 @@ act_stage3_ip4_config_start (NMDevice *device,
NMIP4Config **out_config, NMIP4Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *reason)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
NMConnection *connection; NMConnection *connection;
NMSettingIP4Config *s_ip4; NMSettingIP4Config *s_ip4;
const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; const char *method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
@@ -3112,7 +3108,7 @@ act_stage3_ip4_config_start (NMDevice *device,
/* Indicate that a critical protocol is about to start */ /* Indicate that a critical protocol is about to start */
if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0) if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0)
wifi_utils_indicate_addressing_running (priv->wifi_data, TRUE); nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), TRUE);
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip4_config_start (device, out_config, reason); return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip4_config_start (device, out_config, reason);
} }
@@ -3122,7 +3118,6 @@ act_stage3_ip6_config_start (NMDevice *device,
NMIP6Config **out_config, NMIP6Config **out_config,
NMDeviceStateReason *reason) NMDeviceStateReason *reason)
{ {
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (device);
NMConnection *connection; NMConnection *connection;
NMSettingIP6Config *s_ip6; NMSettingIP6Config *s_ip6;
const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO; const char *method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;
@@ -3136,7 +3131,7 @@ act_stage3_ip6_config_start (NMDevice *device,
/* Indicate that a critical protocol is about to start */ /* Indicate that a critical protocol is about to start */
if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 || if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 ||
strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0)
wifi_utils_indicate_addressing_running (priv->wifi_data, TRUE); nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), TRUE);
return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason); return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason);
} }
@@ -3277,6 +3272,7 @@ activation_success_handler (NMDevice *dev)
{ {
NMDeviceWifi *self = NM_DEVICE_WIFI (dev); NMDeviceWifi *self = NM_DEVICE_WIFI (dev);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
int ifindex = nm_device_get_ifindex (dev);
NMAccessPoint *ap; NMAccessPoint *ap;
struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} }; struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} };
NMAccessPoint *tmp_ap = NULL; NMAccessPoint *tmp_ap = NULL;
@@ -3290,7 +3286,7 @@ activation_success_handler (NMDevice *dev)
g_assert (connection); g_assert (connection);
/* Clear any critical protocol notification in the wifi stack */ /* Clear any critical protocol notification in the wifi stack */
wifi_utils_indicate_addressing_running (priv->wifi_data, FALSE); nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
/* Clear wireless secrets tries on success */ /* Clear wireless secrets tries on success */
g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL); g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
@@ -3309,13 +3305,13 @@ activation_success_handler (NMDevice *dev)
* But if activation was successful, the card will know the BSSID. Grab * But if activation was successful, the card will know the BSSID. Grab
* the BSSID off the card and fill in the BSSID of the activation AP. * the BSSID off the card and fill in the BSSID of the activation AP.
*/ */
wifi_utils_get_bssid (priv->wifi_data, &bssid); nm_platform_wifi_get_bssid (ifindex, &bssid);
if (!nm_ethernet_address_is_valid (nm_ap_get_address (ap))) if (!nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
nm_ap_set_address (ap, &bssid); nm_ap_set_address (ap, &bssid);
if (!nm_ap_get_freq (ap)) if (!nm_ap_get_freq (ap))
nm_ap_set_freq (ap, wifi_utils_get_freq (priv->wifi_data)); nm_ap_set_freq (ap, nm_platform_wifi_get_frequency (ifindex));
if (!nm_ap_get_max_bitrate (ap)) if (!nm_ap_get_max_bitrate (ap))
nm_ap_set_max_bitrate (ap, wifi_utils_get_rate (priv->wifi_data)); nm_ap_set_max_bitrate (ap, nm_platform_wifi_get_rate (ifindex));
tmp_ap = find_active_ap (self, ap, TRUE); tmp_ap = find_active_ap (self, ap, TRUE);
if (tmp_ap) { if (tmp_ap) {
@@ -3363,7 +3359,7 @@ activation_failure_handler (NMDevice *dev)
g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL); g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL);
/* Clear any critical protocol notification in the wifi stack */ /* Clear any critical protocol notification in the wifi stack */
wifi_utils_indicate_addressing_running (NM_DEVICE_WIFI_GET_PRIVATE (dev)->wifi_data, FALSE); nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (dev), FALSE);
} }
static void static void
@@ -3426,7 +3422,7 @@ device_state_changed (NMDevice *device,
break; break;
case NM_DEVICE_STATE_IP_CHECK: case NM_DEVICE_STATE_IP_CHECK:
/* Clear any critical protocol notification in the wifi stack */ /* Clear any critical protocol notification in the wifi stack */
wifi_utils_indicate_addressing_running (priv->wifi_data, FALSE); nm_platform_wifi_indicate_addressing_running (nm_device_get_ifindex (device), FALSE);
break; break;
case NM_DEVICE_STATE_ACTIVATED: case NM_DEVICE_STATE_ACTIVATED:
activation_success_handler (device); activation_success_handler (device);
@@ -3555,9 +3551,6 @@ dispose (GObject *object)
remove_all_aps (self); remove_all_aps (self);
if (priv->wifi_data)
wifi_utils_deinit (priv->wifi_data);
g_free (priv->ipw_rfkill_path); g_free (priv->ipw_rfkill_path);
if (priv->ipw_rfkill_id) { if (priv->ipw_rfkill_id) {
g_source_remove (priv->ipw_rfkill_id); g_source_remove (priv->ipw_rfkill_id);

View File

@@ -678,6 +678,101 @@ gre_get_properties (NMPlatform *platform, int ifindex, NMPlatformGreProperties *
return FALSE; return FALSE;
} }
static gboolean
wifi_get_capabilities (NMPlatform *platform, int ifindex, NMDeviceWifiCapabilities *caps)
{
NMFakePlatformLink *device = link_get (platform, ifindex);
g_return_val_if_fail (device, FALSE);
if (device->link.type != NM_LINK_TYPE_WIFI)
return FALSE;
if (caps) {
*caps = ( NM_WIFI_DEVICE_CAP_CIPHER_WEP40
| NM_WIFI_DEVICE_CAP_CIPHER_WEP104
| NM_WIFI_DEVICE_CAP_CIPHER_TKIP
| NM_WIFI_DEVICE_CAP_CIPHER_CCMP
| NM_WIFI_DEVICE_CAP_WPA
| NM_WIFI_DEVICE_CAP_RSN
| NM_WIFI_DEVICE_CAP_AP
| NM_WIFI_DEVICE_CAP_ADHOC);
}
return TRUE;
}
static gboolean
wifi_get_bssid (NMPlatform *platform, int ifindex, struct ether_addr *bssid)
{
return FALSE;
}
static GByteArray *
wifi_get_ssid (NMPlatform *platform, int ifindex)
{
return NULL;
}
static guint32
wifi_get_frequency (NMPlatform *platform, int ifindex)
{
return 0;
}
static int
wifi_get_quality (NMPlatform *platform, int ifindex)
{
return 0;
}
static guint32
wifi_get_rate (NMPlatform *platform, int ifindex)
{
return 0;
}
static NM80211Mode
wifi_get_mode (NMPlatform *platform, int ifindex)
{
return NM_802_11_MODE_UNKNOWN;
}
static void
wifi_set_mode (NMPlatform *platform, int ifindex, NM80211Mode mode)
{
;
}
static guint32
wifi_find_frequency (NMPlatform *platform, int ifindex, const guint32 *freqs)
{
return freqs[0];
}
static void
wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean running)
{
;
}
static guint32
mesh_get_channel (NMPlatform *platform, int ifindex)
{
return 0;
}
static gboolean
mesh_set_channel (NMPlatform *platform, int ifindex, guint32 channel)
{
return FALSE;
}
static gboolean
mesh_set_ssid (NMPlatform *platform, int ifindex, const GByteArray *ssid)
{
return FALSE;
}
/******************************************************************/ /******************************************************************/
static GArray * static GArray *
@@ -1231,6 +1326,21 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass)
platform_class->vxlan_get_properties = vxlan_get_properties; platform_class->vxlan_get_properties = vxlan_get_properties;
platform_class->gre_get_properties = gre_get_properties; platform_class->gre_get_properties = gre_get_properties;
platform_class->wifi_get_capabilities = wifi_get_capabilities;
platform_class->wifi_get_bssid = wifi_get_bssid;
platform_class->wifi_get_ssid = wifi_get_ssid;
platform_class->wifi_get_frequency = wifi_get_frequency;
platform_class->wifi_get_quality = wifi_get_quality;
platform_class->wifi_get_rate = wifi_get_rate;
platform_class->wifi_get_mode = wifi_get_mode;
platform_class->wifi_set_mode = wifi_set_mode;
platform_class->wifi_find_frequency = wifi_find_frequency;
platform_class->wifi_indicate_addressing_running = wifi_indicate_addressing_running;
platform_class->mesh_get_channel = mesh_get_channel;
platform_class->mesh_set_channel = mesh_set_channel;
platform_class->mesh_set_ssid = mesh_set_ssid;
platform_class->ip4_address_get_all = ip4_address_get_all; platform_class->ip4_address_get_all = ip4_address_get_all;
platform_class->ip6_address_get_all = ip6_address_get_all; platform_class->ip6_address_get_all = ip6_address_get_all;
platform_class->ip4_address_add = ip4_address_add; platform_class->ip4_address_add = ip4_address_add;

View File

@@ -49,6 +49,7 @@
#include "nm-utils.h" #include "nm-utils.h"
#include "nm-logging.h" #include "nm-logging.h"
#include "wifi/wifi-utils.h" #include "wifi/wifi-utils.h"
#include "wifi/wifi-utils-wext.h"
/* This is only included for the translation of VLAN flags */ /* This is only included for the translation of VLAN flags */
#include "nm-setting-vlan.h" #include "nm-setting-vlan.h"
@@ -69,6 +70,8 @@ typedef struct {
GUdevClient *udev_client; GUdevClient *udev_client;
GHashTable *udev_devices; GHashTable *udev_devices;
GHashTable *wifi_data;
int support_kernel_extended_ifa_flags; int support_kernel_extended_ifa_flags;
} NMLinuxPlatformPrivate; } NMLinuxPlatformPrivate;
@@ -1220,6 +1223,7 @@ announce_object (NMPlatform *platform, const struct nl_object *object, ObjectSta
case REMOVED: case REMOVED:
check_cache_items (platform, priv->address_cache, device.ifindex); check_cache_items (platform, priv->address_cache, device.ifindex);
check_cache_items (platform, priv->route_cache, device.ifindex); check_cache_items (platform, priv->route_cache, device.ifindex);
g_hash_table_remove (priv->wifi_data, GINT_TO_POINTER (device.ifindex));
break; break;
default: default:
break; break;
@@ -2699,6 +2703,176 @@ gre_get_properties (NMPlatform *platform, int ifindex, NMPlatformGreProperties *
return (err == 0); return (err == 0);
} }
static WifiData *
wifi_get_wifi_data (NMPlatform *platform, int ifindex)
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
WifiData *wifi_data;
wifi_data = g_hash_table_lookup (priv->wifi_data, GINT_TO_POINTER (ifindex));
if (!wifi_data) {
NMLinkType type;
const char *ifname;
type = link_get_type (platform, ifindex);
ifname = link_get_name (platform, ifindex);
if (type == NM_LINK_TYPE_WIFI)
wifi_data = wifi_utils_init (ifname, ifindex, TRUE);
else if (type == NM_LINK_TYPE_OLPC_MESH) {
/* The kernel driver now uses nl80211, but we force use of WEXT because
* the cfg80211 interactions are not quite ready to support access to
* mesh control through nl80211 just yet.
*/
#if HAVE_WEXT
wifi_data = wifi_wext_init (ifname, ifindex, FALSE);
#endif
}
if (wifi_data)
g_hash_table_insert (priv->wifi_data, GINT_TO_POINTER (ifindex), wifi_data);
}
return wifi_data;
}
static gboolean
wifi_get_capabilities (NMPlatform *platform, int ifindex, NMDeviceWifiCapabilities *caps)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return FALSE;
if (caps)
*caps = wifi_utils_get_caps (wifi_data);
return TRUE;
}
static gboolean
wifi_get_bssid (NMPlatform *platform, int ifindex, struct ether_addr *bssid)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return FALSE;
return wifi_utils_get_bssid (wifi_data, bssid);
}
static GByteArray *
wifi_get_ssid (NMPlatform *platform, int ifindex)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return NULL;
return wifi_utils_get_ssid (wifi_data);
}
static guint32
wifi_get_frequency (NMPlatform *platform, int ifindex)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return 0;
return wifi_utils_get_freq (wifi_data);
}
static gboolean
wifi_get_quality (NMPlatform *platform, int ifindex)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return FALSE;
return wifi_utils_get_qual (wifi_data);
}
static guint32
wifi_get_rate (NMPlatform *platform, int ifindex)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return FALSE;
return wifi_utils_get_rate (wifi_data);
}
static NM80211Mode
wifi_get_mode (NMPlatform *platform, int ifindex)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return NM_802_11_MODE_UNKNOWN;
return wifi_utils_get_mode (wifi_data);
}
static void
wifi_set_mode (NMPlatform *platform, int ifindex, NM80211Mode mode)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (wifi_data)
wifi_utils_set_mode (wifi_data, mode);
}
static guint32
wifi_find_frequency (NMPlatform *platform, int ifindex, const guint32 *freqs)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return 0;
return wifi_utils_find_freq (wifi_data, freqs);
}
static void
wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean running)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (wifi_data)
wifi_utils_indicate_addressing_running (wifi_data, running);
}
static guint32
mesh_get_channel (NMPlatform *platform, int ifindex)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return 0;
return wifi_utils_get_mesh_channel (wifi_data);
}
static gboolean
mesh_set_channel (NMPlatform *platform, int ifindex, guint32 channel)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return FALSE;
return wifi_utils_set_mesh_channel (wifi_data, channel);
}
static gboolean
mesh_set_ssid (NMPlatform *platform, int ifindex, const GByteArray *ssid)
{
WifiData *wifi_data = wifi_get_wifi_data (platform, ifindex);
if (!wifi_data)
return FALSE;
return wifi_utils_set_mesh_ssid (wifi_data, ssid);
}
/******************************************************************/ /******************************************************************/
static int static int
@@ -3402,6 +3576,8 @@ setup (NMPlatform *platform)
if (nle < 0) if (nle < 0)
nm_log_warn (LOGD_PLATFORM, "Netlink error: requesting RTM_GETADDR failed with %s", nl_geterror (nle)); nm_log_warn (LOGD_PLATFORM, "Netlink error: requesting RTM_GETADDR failed with %s", nl_geterror (nle));
priv->wifi_data = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) wifi_utils_deinit);
return TRUE; return TRUE;
} }
@@ -3421,6 +3597,7 @@ nm_linux_platform_finalize (GObject *object)
g_object_unref (priv->udev_client); g_object_unref (priv->udev_client);
g_hash_table_unref (priv->udev_devices); g_hash_table_unref (priv->udev_devices);
g_hash_table_unref (priv->wifi_data);
G_OBJECT_CLASS (nm_linux_platform_parent_class)->finalize (object); G_OBJECT_CLASS (nm_linux_platform_parent_class)->finalize (object);
} }
@@ -3492,6 +3669,21 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
platform_class->vxlan_get_properties = vxlan_get_properties; platform_class->vxlan_get_properties = vxlan_get_properties;
platform_class->gre_get_properties = gre_get_properties; platform_class->gre_get_properties = gre_get_properties;
platform_class->wifi_get_capabilities = wifi_get_capabilities;
platform_class->wifi_get_bssid = wifi_get_bssid;
platform_class->wifi_get_ssid = wifi_get_ssid;
platform_class->wifi_get_frequency = wifi_get_frequency;
platform_class->wifi_get_quality = wifi_get_quality;
platform_class->wifi_get_rate = wifi_get_rate;
platform_class->wifi_get_mode = wifi_get_mode;
platform_class->wifi_set_mode = wifi_set_mode;
platform_class->wifi_find_frequency = wifi_find_frequency;
platform_class->wifi_indicate_addressing_running = wifi_indicate_addressing_running;
platform_class->mesh_get_channel = mesh_get_channel;
platform_class->mesh_set_channel = mesh_set_channel;
platform_class->mesh_set_ssid = mesh_set_ssid;
platform_class->ip4_address_get_all = ip4_address_get_all; platform_class->ip4_address_get_all = ip4_address_get_all;
platform_class->ip6_address_get_all = ip6_address_get_all; platform_class->ip6_address_get_all = ip6_address_get_all;
platform_class->ip4_address_add = ip4_address_add; platform_class->ip4_address_add = ip4_address_add;

View File

@@ -1221,6 +1221,138 @@ nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props)
return klass->gre_get_properties (platform, ifindex, props); return klass->gre_get_properties (platform, ifindex, props);
} }
gboolean
nm_platform_wifi_get_capabilities (int ifindex, NMDeviceWifiCapabilities *caps)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, FALSE);
return klass->wifi_get_capabilities (platform, ifindex, caps);
}
gboolean
nm_platform_wifi_get_bssid (int ifindex, struct ether_addr *bssid)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, FALSE);
return klass->wifi_get_bssid (platform, ifindex, bssid);
}
GByteArray *
nm_platform_wifi_get_ssid (int ifindex)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, NULL);
return klass->wifi_get_ssid (platform, ifindex);
}
guint32
nm_platform_wifi_get_frequency (int ifindex)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, 0);
return klass->wifi_get_frequency (platform, ifindex);
}
int
nm_platform_wifi_get_quality (int ifindex)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, 0);
return klass->wifi_get_quality (platform, ifindex);
}
guint32
nm_platform_wifi_get_rate (int ifindex)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, 0);
return klass->wifi_get_rate (platform, ifindex);
}
NM80211Mode
nm_platform_wifi_get_mode (int ifindex)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, NM_802_11_MODE_UNKNOWN);
return klass->wifi_get_mode (platform, ifindex);
}
void
nm_platform_wifi_set_mode (int ifindex, NM80211Mode mode)
{
reset_error ();
g_return_if_fail (ifindex > 0);
klass->wifi_set_mode (platform, ifindex, mode);
}
guint32
nm_platform_wifi_find_frequency (int ifindex, const guint32 *freqs)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, 0);
g_return_val_if_fail (freqs != NULL, 0);
return klass->wifi_find_frequency (platform, ifindex, freqs);
}
void
nm_platform_wifi_indicate_addressing_running (int ifindex, gboolean running)
{
reset_error ();
g_return_if_fail (ifindex > 0);
klass->wifi_indicate_addressing_running (platform, ifindex, running);
}
guint32
nm_platform_mesh_get_channel (int ifindex)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, 0);
return klass->mesh_get_channel (platform, ifindex);
}
gboolean
nm_platform_mesh_set_channel (int ifindex, guint32 channel)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, FALSE);
return klass->mesh_set_channel (platform, ifindex, channel);
}
gboolean
nm_platform_mesh_set_ssid (int ifindex, const GByteArray *ssid)
{
reset_error ();
g_return_val_if_fail (ifindex > 0, FALSE);
g_return_val_if_fail (ssid != NULL, FALSE);
return klass->mesh_set_ssid (platform, ifindex, ssid);
}
/******************************************************************/ /******************************************************************/
GArray * GArray *

View File

@@ -24,9 +24,12 @@
#include <glib-object.h> #include <glib-object.h>
#include "nm-glib-compat.h" #include "nm-glib-compat.h"
#include <netinet/in.h> #include <netinet/in.h>
#include <net/ethernet.h>
#include <linux/if.h> #include <linux/if.h>
#include <linux/if_addr.h> #include <linux/if_addr.h>
#include <NetworkManager.h>
#define NM_TYPE_PLATFORM (nm_platform_get_type ()) #define NM_TYPE_PLATFORM (nm_platform_get_type ())
#define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform)) #define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform))
#define NM_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PLATFORM, NMPlatformClass)) #define NM_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PLATFORM, NMPlatformClass))
@@ -343,6 +346,21 @@ typedef struct {
gboolean (*vxlan_get_properties) (NMPlatform *, int ifindex, NMPlatformVxlanProperties *props); gboolean (*vxlan_get_properties) (NMPlatform *, int ifindex, NMPlatformVxlanProperties *props);
gboolean (*gre_get_properties) (NMPlatform *, int ifindex, NMPlatformGreProperties *props); gboolean (*gre_get_properties) (NMPlatform *, int ifindex, NMPlatformGreProperties *props);
gboolean (*wifi_get_capabilities) (NMPlatform *, int ifindex, NMDeviceWifiCapabilities *caps);
gboolean (*wifi_get_bssid) (NMPlatform *, int ifindex, struct ether_addr *bssid);
GByteArray *(*wifi_get_ssid) (NMPlatform *, int ifindex);
guint32 (*wifi_get_frequency) (NMPlatform *, int ifindex);
int (*wifi_get_quality) (NMPlatform *, int ifindex);
guint32 (*wifi_get_rate) (NMPlatform *, int ifindex);
NM80211Mode (*wifi_get_mode) (NMPlatform *, int ifindex);
void (*wifi_set_mode) (NMPlatform *, int ifindex, NM80211Mode mode);
guint32 (*wifi_find_frequency) (NMPlatform *, int ifindex, const guint32 *freqs);
void (*wifi_indicate_addressing_running) (NMPlatform *, int ifindex, gboolean running);
guint32 (*mesh_get_channel) (NMPlatform *, int ifindex);
gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel);
gboolean (*mesh_set_ssid) (NMPlatform *, int ifindex, const GByteArray *ssid);
GArray * (*ip4_address_get_all) (NMPlatform *, int ifindex); GArray * (*ip4_address_get_all) (NMPlatform *, int ifindex);
GArray * (*ip6_address_get_all) (NMPlatform *, int ifindex); GArray * (*ip6_address_get_all) (NMPlatform *, int ifindex);
gboolean (*ip4_address_add) (NMPlatform *, int ifindex, gboolean (*ip4_address_add) (NMPlatform *, int ifindex,
@@ -474,6 +492,21 @@ gboolean nm_platform_macvlan_get_properties (int ifindex, NMPlatformMacvlanPrope
gboolean nm_platform_vxlan_get_properties (int ifindex, NMPlatformVxlanProperties *props); gboolean nm_platform_vxlan_get_properties (int ifindex, NMPlatformVxlanProperties *props);
gboolean nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props); gboolean nm_platform_gre_get_properties (int ifindex, NMPlatformGreProperties *props);
gboolean nm_platform_wifi_get_capabilities (int ifindex, NMDeviceWifiCapabilities *caps);
gboolean nm_platform_wifi_get_bssid (int ifindex, struct ether_addr *bssid);
GByteArray *nm_platform_wifi_get_ssid (int ifindex);
guint32 nm_platform_wifi_get_frequency (int ifindex);
int nm_platform_wifi_get_quality (int ifindex);
guint32 nm_platform_wifi_get_rate (int ifindex);
NM80211Mode nm_platform_wifi_get_mode (int ifindex);
void nm_platform_wifi_set_mode (int ifindex, NM80211Mode mode);
guint32 nm_platform_wifi_find_frequency (int ifindex, const guint32 *freqs);
void nm_platform_wifi_indicate_addressing_running (int ifindex, gboolean running);
guint32 nm_platform_mesh_get_channel (int ifindex);
gboolean nm_platform_mesh_set_channel (int ifindex, guint32 channel);
gboolean nm_platform_mesh_set_ssid (int ifindex, const GByteArray *ssid);
GArray *nm_platform_ip4_address_get_all (int ifindex); GArray *nm_platform_ip4_address_get_all (int ifindex);
GArray *nm_platform_ip6_address_get_all (int ifindex); GArray *nm_platform_ip6_address_get_all (int ifindex);
gboolean nm_platform_ip4_address_add (int ifindex, gboolean nm_platform_ip4_address_add (int ifindex,

View File

@@ -27,7 +27,6 @@ libifcfg_rh_io_la_SOURCES = \
AM_CPPFLAGS = \ AM_CPPFLAGS = \
-I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/ \
-I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/platform \
-I$(top_srcdir)/src/wifi \
-I$(top_srcdir)/src/settings \ -I$(top_srcdir)/src/settings \
-I$(top_srcdir)/src/posix-signals \ -I$(top_srcdir)/src/posix-signals \
-I$(top_srcdir)/src/config \ -I$(top_srcdir)/src/config \

View File

@@ -53,7 +53,7 @@
#include <nm-util-private.h> #include <nm-util-private.h>
#include <nm-utils.h> #include <nm-utils.h>
#include "wifi-utils.h" #include "nm-platform.h"
#include "nm-posix-signals.h" #include "nm-posix-signals.h"
#include "NetworkManagerUtils.h" #include "NetworkManagerUtils.h"
@@ -4723,6 +4723,21 @@ is_vlan_device (const char *name, shvarFile *parsed)
return FALSE; return FALSE;
} }
static gboolean
is_wifi_device (const char *name, shvarFile *parsed)
{
int ifindex;
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (parsed != NULL, FALSE);
ifindex = nm_platform_link_get_ifindex (name);
if (ifindex == 0)
return FALSE;
return nm_platform_link_get_type (ifindex) == NM_LINK_TYPE_WIFI;
}
static void static void
parse_prio_map_list (NMSettingVlan *s_vlan, parse_prio_map_list (NMSettingVlan *s_vlan,
shvarFile *ifcfg, shvarFile *ifcfg,
@@ -5130,8 +5145,7 @@ connection_from_file (const char *filename,
type = g_strdup (TYPE_BOND); type = g_strdup (TYPE_BOND);
else if (is_vlan_device (device, parsed)) else if (is_vlan_device (device, parsed))
type = g_strdup (TYPE_VLAN); type = g_strdup (TYPE_VLAN);
/* Test wireless extensions */ else if (is_wifi_device (device, parsed))
else if (wifi_utils_is_wifi (device, NULL))
type = g_strdup (TYPE_WIRELESS); type = g_strdup (TYPE_WIRELESS);
else else
type = g_strdup (TYPE_ETHERNET); type = g_strdup (TYPE_ETHERNET);

View File

@@ -16,7 +16,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/ \ -I$(top_srcdir)/src/ \
-I$(top_srcdir)/src/platform \ -I$(top_srcdir)/src/platform \
-I$(top_srcdir)/src/settings \ -I$(top_srcdir)/src/settings \
-I$(top_srcdir)/src/wifi \
-I$(top_srcdir)/src/posix-signals \ -I$(top_srcdir)/src/posix-signals \
-I$(srcdir)/../ \ -I$(srcdir)/../ \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \

View File

@@ -5,7 +5,7 @@ SUBDIRS = . tests
AM_CPPFLAGS = \ AM_CPPFLAGS = \
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \
-I$(top_srcdir)/src/config \ -I$(top_srcdir)/src/config \
-I$(top_srcdir)/src/wifi \ -I$(top_srcdir)/src/platform \
-I$(top_srcdir)/src/settings \ -I$(top_srcdir)/src/settings \
-I$(top_srcdir)/include \ -I$(top_srcdir)/include \
-I$(top_builddir)/include \ -I$(top_builddir)/include \

View File

@@ -24,11 +24,10 @@
#include <stdio.h> #include <stdio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <net/if.h>
#include <unistd.h> #include <unistd.h>
#include "plugin.h" #include "plugin.h"
#include "wifi-utils.h" #include "nm-platform.h"
#include "net_parser.h" #include "net_parser.h"
#include "net_utils.h" #include "net_utils.h"
@@ -172,13 +171,16 @@ init_block_by_line (gchar * buf)
else if (ignore_connection_name (pos)) { else if (ignore_connection_name (pos)) {
/* ignored connection */ /* ignored connection */
conn = add_new_connection_config ("ignore", pos); conn = add_new_connection_config ("ignore", pos);
} else } else {
if (if_nametoindex (pos) && !wifi_utils_is_wifi (pos, NULL)) int ifindex = nm_platform_link_get_ifindex (pos);
if (ifindex && nm_platform_link_get_type (ifindex) != NM_LINK_TYPE_WIFI)
/* wired connection */ /* wired connection */
conn = add_new_connection_config ("wired", pos); conn = add_new_connection_config ("wired", pos);
else else
/* wireless connection */ /* wireless connection */
conn = add_new_connection_config ("wireless", pos); conn = add_new_connection_config ("wireless", pos);
}
} }
data = g_strdup (key_value[1]); data = g_strdup (key_value[1]);
tmp = strip_string (data, '"'); tmp = strip_string (data, '"');

View File

@@ -12,7 +12,7 @@ AM_CPPFLAGS= \
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \
-I$(top_srcdir)/src/config \ -I$(top_srcdir)/src/config \
-I$(top_srcdir)/src/settings \ -I$(top_srcdir)/src/settings \
-I$(top_srcdir)/src/wifi \ -I$(top_srcdir)/src/platform \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \
$(CHECK_CFLAGS) \ $(CHECK_CFLAGS) \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \