Commit 4ed4b491 authored by Dan Williams's avatar Dan Williams
Browse files

2005-12-31 Dan Williams <dcbw@redhat.com>

	* refactor NMDevice into a GObject-based framework with separate
		objects for wired and wireless.  The following files are no
		longer used but should stick around for a bit so we don't
		loose code through the cracks:
			NetworkManagerDevice.c
			NetworkManagerDevice.h
			NetworkManagerWireless.c
			NetworkManagerWireless.h

	The intent here is to allow each device type to manage its own
	connection & activation life-cycle, ie to allow wireless devices
	to interface with wpa_supplicant, etc.  There's a fair bit of
	encapsulation breakage right now that should gradually get pulled
	back into each device, along with things like periodic property
	updates and link probing.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1244 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent d717e1ad
2005-12-31 Dan Williams <dcbw@redhat.com>
* refactor NMDevice into a GObject-based framework with separate
objects for wired and wireless. The following files are no
longer used but should stick around for a bit so we don't
loose code through the cracks:
NetworkManagerDevice.c
NetworkManagerDevice.h
NetworkManagerWireless.c
NetworkManagerWireless.h
The intent here is to allow each device type to manage its own
connection & activation life-cycle, ie to allow wireless devices
to interface with wpa_supplicant, etc. There's a fair bit of
encapsulation breakage right now that should gradually get pulled
back into each device, along with things like periodic property
updates and link probing.
2005-12-29 Dan Williams <dcbw@redhat.com>
* include/NetworkManager.h
......
......@@ -11,6 +11,13 @@ INCLUDES = -I${top_srcdir} \
bin_PROGRAMS = NetworkManager
NetworkManager_SOURCES = \
nm-device.c \
nm-device.h \
nm-device-private.h \
nm-device-802-3-ethernet.c \
nm-device-802-3-ethernet.h \
nm-device-802-11-wireless.c \
nm-device-802-11-wireless.h \
NetworkManagerAP.c \
NetworkManagerAP.h \
NetworkManagerAPList.c \
......@@ -28,9 +35,6 @@ NetworkManager_SOURCES = \
nm-dbus-net.h \
nm-dbus-nmi.c \
nm-dbus-nmi.h \
NetworkManagerDevice.c \
NetworkManagerDevice.h \
NetworkManagerDevicePrivate.h \
nm-ip4-config.c \
nm-ip4-config.h \
NetworkManager.c \
......@@ -39,8 +43,6 @@ NetworkManager_SOURCES = \
NetworkManagerPolicy.h \
NetworkManagerUtils.c \
NetworkManagerUtils.h \
NetworkManagerWireless.c \
NetworkManagerWireless.h \
NetworkManagerSystem.c \
NetworkManagerSystem.h \
nm-netlink-monitor.c \
......
......@@ -36,9 +36,10 @@
#include "NetworkManager.h"
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "NetworkManagerDevice.h"
#include "nm-device.h"
#include "nm-device-802-3-ethernet.h"
#include "nm-device-802-11-wireless.h"
#include "NetworkManagerPolicy.h"
#include "NetworkManagerWireless.h"
#include "NetworkManagerDbus.h"
#include "NetworkManagerAP.h"
#include "NetworkManagerAPList.h"
......@@ -143,7 +144,7 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons
{
/* If we couldn't add the device to our list, free its data. */
nm_warning ("could not acquire device list mutex." );
nm_device_unref (dev);
g_object_unref (G_OBJECT (dev));
dev = NULL;
}
} else nm_warning ("could not allocate device data." );
......@@ -168,7 +169,7 @@ void nm_remove_device (NMData *data, NMDevice *dev)
nm_device_worker_thread_stop (dev);
nm_dbus_schedule_device_status_change_signal (data, dev, NULL, DEVICE_REMOVED);
nm_device_unref (dev);
g_object_unref (G_OBJECT (dev));
/* Remove the device entry from the device list and free its data */
data->dev_list = g_slist_remove (data->dev_list, dev);
......@@ -442,7 +443,7 @@ static void device_stop_and_free (NMDevice *dev, gpointer user_data)
nm_device_set_removed (dev, TRUE);
nm_device_deactivate (dev);
nm_device_unref (dev);
g_object_unref (G_OBJECT (dev));
}
......@@ -555,7 +556,7 @@ static gboolean nm_poll_and_update_wireless_link_state (NMData *data)
{
if ((dev = (NMDevice *)(elt->data)))
{
nm_device_ref (dev);
g_object_ref (G_OBJECT (dev));
copy = g_slist_append (copy, dev);
}
}
......@@ -568,10 +569,11 @@ static gboolean nm_poll_and_update_wireless_link_state (NMData *data)
{
if (nm_device_is_802_11_wireless (dev) && !nm_device_is_activating (dev))
{
nm_device_set_link_active (dev, nm_device_probe_link_state (dev));
nm_device_update_signal_strength (dev);
NMDevice80211Wireless *wdev = NM_DEVICE_802_11_WIRELESS (dev);
nm_device_set_active_link (dev, nm_device_probe_link_state (dev));
nm_device_802_11_wireless_update_signal_strength (wdev);
}
nm_device_unref (dev);
g_object_unref (G_OBJECT (dev));
}
}
......@@ -598,7 +600,7 @@ static void nm_device_link_activated (NmNetlinkMonitor *monitor, const gchar *in
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
{
if ((dev = nm_get_device_by_iface (data, interface_name)))
nm_device_ref (dev);
g_object_ref (G_OBJECT (dev));
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
}
......@@ -607,10 +609,10 @@ static void nm_device_link_activated (NmNetlinkMonitor *monitor, const gchar *in
{
if (nm_device_is_802_3_ethernet (dev) && !nm_device_has_active_link (dev))
{
nm_device_set_link_active (dev, TRUE);
nm_device_set_active_link (dev, TRUE);
nm_policy_schedule_device_change_check (data);
}
nm_device_unref (dev);
g_object_unref (G_OBJECT (dev));
}
}
......@@ -621,15 +623,15 @@ static void nm_device_link_deactivated (NmNetlinkMonitor *monitor, const gchar *
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
{
if ((dev = nm_get_device_by_iface (data, interface_name)))
nm_device_ref (dev);
g_object_ref (G_OBJECT (dev));
nm_unlock_mutex (data->dev_list_mutex, __FUNCTION__);
}
if (dev)
{
if (nm_device_is_802_3_ethernet (dev))
nm_device_set_link_active (dev, FALSE);
nm_device_unref (dev);
nm_device_set_active_link (dev, FALSE);
g_object_unref (G_OBJECT (dev));
}
}
......
......@@ -22,7 +22,6 @@
#include "NetworkManagerAP.h"
#include "NetworkManagerUtils.h"
#include "nm-utils.h"
#include "NetworkManagerWireless.h"
#include "nm-ap-security.h"
#include <wireless.h>
......@@ -85,6 +84,7 @@ NMAccessPoint * nm_ap_new (void)
ap->mode = IW_MODE_INFRA;
ap->refcount = 1;
ap->capabilities = NM_802_11_CAP_PROTO_NONE;
return ap;
}
......@@ -203,12 +203,20 @@ void nm_ap_set_essid (NMAccessPoint *ap, const char * essid)
guint32 nm_ap_get_capabilities (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, -1);
g_return_val_if_fail (ap != NULL, NM_802_11_CAP_NONE);
return ap->capabilities;
}
void nm_ap_set_capabilities (NMAccessPoint *ap, guint32 capabilities)
{
g_return_if_fail (ap != NULL);
ap->capabilities = capabilities;
}
/*
* Get/set functions for encrypted flag
*
......@@ -222,16 +230,6 @@ gboolean nm_ap_get_encrypted (const NMAccessPoint *ap)
|| (ap->capabilities & NM_802_11_CAP_PROTO_WPA2));
}
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean privacy)
{
#define ALL_WEP (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP104 | NM_802_11_CAP_CIPHER_WEP40)
g_return_if_fail (ap != NULL);
if (privacy)
ap->capabilities |= ALL_WEP;
else
ap->capabilities &= ~ALL_WEP;
}
/*
* Accessorts for AP security info
......@@ -544,41 +542,72 @@ gboolean nm_ap_has_manufacturer_default_essid (NMAccessPoint *ap)
}
static void set_capabilities_from_cipher (NMAccessPoint *ap, int cipher)
static guint32 add_capabilities_from_cipher (guint32 caps, int cipher)
{
if (cipher & IW_AUTH_CIPHER_WEP40)
ap->capabilities |= NM_802_11_CAP_CIPHER_WEP40;
{
caps |= (NM_802_11_CAP_PROTO_WEP & NM_802_11_CAP_CIPHER_WEP40);
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
if (cipher & IW_AUTH_CIPHER_WEP104)
ap->capabilities |= NM_802_11_CAP_CIPHER_WEP104;
{
caps |= (NM_802_11_CAP_PROTO_WEP & NM_802_11_CAP_CIPHER_WEP104);
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
if (cipher & IW_AUTH_CIPHER_TKIP)
ap->capabilities |= NM_802_11_CAP_CIPHER_TKIP;
{
caps |= NM_802_11_CAP_CIPHER_TKIP;
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
if (cipher & IW_AUTH_CIPHER_CCMP)
ap->capabilities |= NM_802_11_CAP_CIPHER_CCMP;
{
caps |= NM_802_11_CAP_CIPHER_CCMP;
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
return caps;
}
void nm_ap_set_capabilities_from_wpa_ie (NMAccessPoint *ap, const guint8 *wpa_ie, guint32 length)
void nm_ap_add_capabilities_from_ie (NMAccessPoint *ap, const guint8 *wpa_ie, guint32 length)
{
wpa_ie_data * cap_data;
guint32 caps;
g_return_if_fail (ap != NULL);
if (!(cap_data = wpa_parse_wpa_ie (wpa_ie, length)))
return;
ap->capabilities = NM_802_11_CAP_NONE;
caps = nm_ap_get_capabilities (ap);
if (cap_data->proto & IW_AUTH_WPA_VERSION_WPA)
ap->capabilities |= NM_802_11_CAP_PROTO_WPA;
{
caps |= NM_802_11_CAP_PROTO_WPA;
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
if (cap_data->proto & IW_AUTH_WPA_VERSION_WPA2)
ap->capabilities |= NM_802_11_CAP_PROTO_WPA2;
{
caps |= NM_802_11_CAP_PROTO_WPA2;
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
set_capabilities_from_cipher (ap, cap_data->pairwise_cipher);
set_capabilities_from_cipher (ap, cap_data->group_cipher);
caps = add_capabilities_from_cipher (caps, cap_data->pairwise_cipher);
caps = add_capabilities_from_cipher (caps, cap_data->group_cipher);
if (cap_data->key_mgmt & IW_AUTH_KEY_MGMT_802_1X)
ap->capabilities |= NM_802_11_CAP_KEY_MGMT_802_1X;
caps |= NM_802_11_CAP_KEY_MGMT_802_1X;
if (cap_data->key_mgmt & IW_AUTH_KEY_MGMT_PSK)
ap->capabilities |= NM_802_11_CAP_KEY_MGMT_PSK;
caps |= NM_802_11_CAP_KEY_MGMT_PSK;
nm_ap_set_capabilities (ap, caps);
}
void nm_ap_add_capabilities_for_wep (NMAccessPoint *ap)
{
guint32 caps;
g_return_if_fail (ap != NULL);
ap->capabilities |= (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP40 | NM_802_11_CAP_CIPHER_WEP104);
ap->capabilities &= ~NM_802_11_CAP_PROTO_NONE;
}
......@@ -44,9 +44,9 @@ char * nm_ap_get_essid (const NMAccessPoint *ap);
void nm_ap_set_essid (NMAccessPoint *ap, const char *essid);
guint32 nm_ap_get_capabilities (NMAccessPoint *ap);
void nm_ap_set_capabilities (NMAccessPoint *ap, guint32 capabilities);
gboolean nm_ap_get_encrypted (const NMAccessPoint *ap);
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean privacy);
NMAPSecurity * nm_ap_get_security (const NMAccessPoint *ap);
void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security);
......@@ -87,7 +87,8 @@ void nm_ap_set_user_created (NMAccessPoint *ap, gboolean user_created);
GSList * nm_ap_get_user_addresses (const NMAccessPoint *ap);
void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list);
void nm_ap_set_capabilities_from_wpa_ie (NMAccessPoint *ap, const guint8 *wpa_ie, guint32 length);
void nm_ap_add_capabilities_from_ie (NMAccessPoint *ap, const guint8 *wpa_ie, guint32 length);
void nm_ap_add_capabilities_for_wep (NMAccessPoint *ap);
/*
* NOTE:
......
......@@ -457,8 +457,8 @@ gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *me
const GTimeVal *merge_ap_seen = nm_ap_get_last_seen (merge_ap);
nm_ap_set_encrypted (list_ap_addr, nm_ap_get_encrypted (merge_ap));
if (nm_ap_get_strength (merge_ap) != nm_ap_get_strength (list_ap_addr))
nm_ap_set_capabilities (list_ap_addr, nm_ap_get_capabilities (merge_ap));
if (nm_ap_get_strength (merge_ap) != nm_ap_get_strength (list_ap_addr))
{
nm_ap_set_strength (list_ap_addr, nm_ap_get_strength (merge_ap));
*strength_changed = TRUE;
......@@ -480,7 +480,7 @@ gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *me
const GTimeVal *merge_ap_seen = nm_ap_get_last_seen (merge_ap);
const GTimeVal *list_ap_essid_seen = nm_ap_get_last_seen (list_ap_essid);
nm_ap_set_encrypted (list_ap_essid, nm_ap_get_encrypted (merge_ap));
nm_ap_set_capabilities (list_ap_essid, nm_ap_get_capabilities (merge_ap));
if (!((list_ap_essid_seen->tv_sec == merge_ap_seen->tv_sec)
&& (nm_ap_get_strength (list_ap_essid) >= nm_ap_get_strength (merge_ap))))
......@@ -600,7 +600,7 @@ void nm_ap_list_copy_essids_by_address (NMAccessPointList *dest, NMAccessPointLi
* may result in undesired behavior.
*
*/
void nm_ap_list_diff (NMData *data, NMDevice *dev, NMAccessPointList *old, NMAccessPointList *new)
void nm_ap_list_diff (NMData *data, NMDevice80211Wireless *dev, NMAccessPointList *old, NMAccessPointList *new)
{
NMAPListIter *iter;
NMAccessPoint *old_ap;
......
......@@ -24,8 +24,10 @@
#include <glib.h>
#include "NetworkManager.h"
#include "NetworkManagerDevice.h"
#include "NetworkManagerMain.h"
#include "NetworkManagerAP.h"
#include "nm-device.h"
#include "nm-device-802-11-wireless.h"
typedef struct NMAccessPointList NMAccessPointList;
typedef struct NMAPListIter NMAPListIter;
......@@ -49,7 +51,7 @@ void nm_ap_list_copy_properties (NMAccessPointList *dest, NMAccessPointList
void nm_ap_list_copy_essids_by_address (NMAccessPointList *dest, NMAccessPointList *source);
void nm_ap_list_copy_one_essid_by_address (NMAccessPoint *ap, NMAccessPointList *search_list);
void nm_ap_list_diff (NMData *data, NMDevice *dev, NMAccessPointList *old, NMAccessPointList *new);
void nm_ap_list_diff (NMData *data, NMDevice80211Wireless *dev, NMAccessPointList *old, NMAccessPointList *new);
gboolean nm_ap_list_merge_scanned_ap (NMAccessPointList *list, NMAccessPoint *merge_ap, gboolean *new, gboolean *strength_changed);
NMNetworkType nm_ap_list_get_type (NMAccessPointList *list);
......
......@@ -30,13 +30,12 @@
#include "NetworkManager.h"
#include "NetworkManagerUtils.h"
#include "NetworkManagerDevice.h"
#include "nm-device.h"
#include "NetworkManagerDbus.h"
#include "NetworkManagerDbusUtils.h"
#include "NetworkManagerAP.h"
#include "NetworkManagerAPList.h"
#include "NetworkManagerPolicy.h"
#include "NetworkManagerWireless.h"
#include "nm-dbus-nm.h"
#include "nm-dbus-device.h"
#include "nm-dbus-net.h"
......@@ -251,7 +250,7 @@ static gboolean nm_dbus_signal_device_status_change (gpointer user_data)
dbus_message_unref (message);
nm_device_unref (cb_data->dev);
g_object_unref (G_OBJECT (cb_data->dev));
g_free (cb_data);
return FALSE;
......@@ -267,7 +266,7 @@ void nm_dbus_schedule_device_status_change_signal (NMData *data, NMDevice *dev,
g_return_if_fail (dev != NULL);
cb_data = g_malloc0 (sizeof (NMStatusChangeData));
nm_device_ref (dev);
g_object_ref (G_OBJECT (dev));
cb_data->data = data;
cb_data->dev = dev;
if (ap)
......@@ -351,7 +350,7 @@ void nm_dbus_signal_state_change (DBusConnection *connection, NMData *data)
* Notifies the bus that a new wireless network has come into range
*
*/
void nm_dbus_signal_wireless_network_change (DBusConnection *connection, NMDevice *dev, NMAccessPoint *ap, NMNetworkStatus status, gint strength)
void nm_dbus_signal_wireless_network_change (DBusConnection *connection, NMDevice80211Wireless *dev, NMAccessPoint *ap, NMNetworkStatus status, gint strength)
{
DBusMessage * message;
char * dev_path = NULL;
......@@ -362,10 +361,10 @@ void nm_dbus_signal_wireless_network_change (DBusConnection *connection, NMDevic
g_return_if_fail (dev != NULL);
g_return_if_fail (ap != NULL);
if (!(dev_path = nm_dbus_get_object_path_for_device (dev)))
if (!(dev_path = nm_dbus_get_object_path_for_device (NM_DEVICE (dev))))
goto out;
if (!(net_path = nm_dbus_get_object_path_for_network (dev, ap)))
if (!(net_path = nm_dbus_get_object_path_for_network (NM_DEVICE (dev), ap)))
goto out;
switch (status)
......@@ -410,7 +409,7 @@ out:
}
void nm_dbus_signal_device_strength_change (DBusConnection *connection, NMDevice *dev, gint strength)
void nm_dbus_signal_device_strength_change (DBusConnection *connection, NMDevice80211Wireless *dev, gint strength)
{
DBusMessage * message;
char * dev_path = NULL;
......@@ -418,7 +417,7 @@ void nm_dbus_signal_device_strength_change (DBusConnection *connection, NMDevice
g_return_if_fail (connection != NULL);
g_return_if_fail (dev != NULL);
if (!(dev_path = nm_dbus_get_object_path_for_device (dev)))
if (!(dev_path = nm_dbus_get_object_path_for_device (NM_DEVICE (dev))))
goto out;
if (!(message = dbus_message_new_signal (NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeviceStrengthChanged")))
......@@ -494,7 +493,7 @@ static DBusHandlerResult nm_dbus_signal_filter (DBusConnection *connection, DBus
}
else if (dbus_message_is_signal (message, NMI_DBUS_INTERFACE, "UserInterfaceActivated"))
{
nm_wireless_set_scan_interval (data, NULL, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
nm_device_802_11_wireless_set_scan_interval (data, NULL, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
handled = TRUE;
}
}
......
......@@ -26,6 +26,9 @@
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include "NetworkManager.h"
#include "NetworkManagerMain.h"
#include "nm-device.h"
#include "nm-device-802-11-wireless.h"
#include "NetworkManagerAPList.h"
......@@ -51,7 +54,6 @@ static inline gboolean message_is_error (DBusMessage *msg)
return (dbus_message_get_type (msg) == DBUS_MESSAGE_TYPE_ERROR);
}
DBusConnection *nm_dbus_init (NMData *data);
gboolean nm_dbus_is_info_daemon_running (DBusConnection *connection);
......@@ -64,8 +66,8 @@ void nm_dbus_schedule_device_status_change_signal (NMData *data, NMDevice *dev
void nm_dbus_signal_state_change (DBusConnection *connection, NMData *data);
void nm_dbus_signal_wireless_network_change (DBusConnection *connection, NMDevice *dev, NMAccessPoint *ap, NMNetworkStatus status, gint strength);
void nm_dbus_signal_device_strength_change (DBusConnection *connection, NMDevice *dev, gint strength);
void nm_dbus_signal_wireless_network_change (DBusConnection *connection, NMDevice80211Wireless *dev, NMAccessPoint *ap, NMNetworkStatus status, gint strength);
void nm_dbus_signal_device_strength_change (DBusConnection *connection, NMDevice80211Wireless *dev, gint strength);
NMDevice * nm_dbus_get_device_from_object_path (NMData *data, const char *path);
......
......@@ -27,7 +27,8 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus-glib.h>
#include "NetworkManagerDevice.h"
#include "nm-device.h"
#include "NetworkManagerMain.h"
typedef struct NMDbusCBData
{
......
......@@ -857,6 +857,20 @@ guint32 nm_device_get_capabilities (NMDevice *dev)
}
/*
* Accessor for type-specific device capabilities
*/
guint32 nm_device_get_type_capabilities (NMDevice *dev)
{
g_return_val_if_fail (dev != NULL, NM_DEVICE_CAP_NONE);
if (dev->type == DEVICE_TYPE_802_11_WIRELESS)
return dev->options.wireless.capabilities;
return NM_DEVICE_CAP_NONE;
}
/*
* Get/set functions for link_active
*/
......@@ -3700,7 +3714,7 @@ static void nm_device_fake_ap_list (NMDevice *dev)
{{0x12, 0x34, 0x56, 0x78, 0x90, 0xab}},
{{0xcd, 0xef, 0x12, 0x34, 0x56, 0x78}},
{{0x90, 0xab, 0xcd, 0xef, 0x12, 0x34}} };
guint8 fake_qualities[NUM_FAKE_APS] = { 150, 26, 200, 100 };
guint8 fake_qualities[NUM_FAKE_APS] = { 45, 26, 12, 93 };
double fake_freqs[NUM_FAKE_APS] = { 3.1416, 4.1416, 5.1415, 6.1415 };
gboolean fake_enc[NUM_FAKE_APS] = { FALSE, TRUE, FALSE, TRUE };
......@@ -3718,9 +3732,7 @@ static void nm_device_fake_ap_list (NMDevice *dev)
nm_ap_set_essid (nm_ap, fake_essids[i]);
if (fake_enc[i])
nm_ap_set_encrypted (nm_ap, FALSE);
else
nm_ap_set_encrypted (nm_ap, TRUE);
nm_ap_add_capabilities_for_wep (nm_ap);
nm_ap_set_address (nm_ap, (const struct ether_addr *)(&fake_addrs[i]));
nm_ap_set_strength (nm_ap, fake_qualities[i]);
......@@ -4497,7 +4509,7 @@ static gboolean process_scan_results (NMDevice *dev, const guint8 *res_buf, guin
break;
case SIOCGIWENCODE:
if (!(iwe->u.data.flags & IW_ENCODE_DISABLED))
nm_ap_set_encrypted (ap, TRUE);
nm_ap_add_capabilities_for_wep (ap);
break;
#if 0
case SIOCGIWRATE:
......@@ -4539,10 +4551,10 @@ static gboolean process_scan_results (NMDevice *dev, const guint8 *res_buf, guin
case WPA_GENERIC_INFO_ELEM:
if ((ielen < 2 + 4) || (memcmp (&gpos[2], "\x00\x50\xf2\x01", 4) != 0))
break;
nm_ap_set_capabilities_from_wpa_ie (ap, (const guint8 *)gpos, ielen);
nm_ap_add_capabilities_from_ie (ap, (const guint8 *)gpos, ielen);
break;
case WPA_RSN_INFO_ELEM:
nm_ap_set_capabilities_from_wpa_ie (ap, (const guint8 *)gpos, ielen);
nm_ap_add_capabilities_from_ie (ap, (const guint8 *)gpos, ielen);
break;
}
gpos += ielen;
......@@ -4571,9 +4583,9 @@ static gboolean process_scan_results (NMDevice *dev, const guint8 *res_buf, guin
ie_buf = g_malloc0 (bytes);
hexstr2bin (spos, ie_buf, bytes);
if (strncmp (custom, "wpa_ie=", 7) == 0)
nm_ap_set_capabilities_from_wpa_ie (ap, (const guint8 *)ie_buf, bytes);
nm_ap_add_capabilities_from_ie (ap, (const guint8 *)ie_buf, bytes);
else if (strncmp (custom, "rsn_ie=", 7) == 0)
nm_ap_set_capabilities_from_wpa_ie (ap, (const guint8 *)ie_buf, bytes);
nm_ap_add_capabilities_from_ie (ap, (const guint8 *)ie_buf, bytes);
g_free (ie_buf);
}
break;
......
......@@ -60,6 +60,7 @@ const char * nm_device_get_driver (NMDevice *dev);
NMDeviceType nm_device_get_type (NMDevice *dev);
guint32 nm_device_get_capabilities (NMDevice *dev);
guint32 nm_device_get_type_capabilities (NMDevice *dev);
gboolean nm_device_is_802_11_wireless (NMDevice *dev);
gboolean nm_device_is_802_3_ethernet (NMDevice *dev);
......
......@@ -30,6 +30,7 @@
#include "NetworkManagerAP.h"
#include "nm-netlink-monitor.h"
#include "nm-named-manager.h"
#include "nm-device.h"
typedef enum NMIntState
......@@ -92,14 +93,14 @@ typedef struct NMData
} NMData;
struct NMDevice * nm_get_active_device (NMData *data);
NMDevice * nm_get_active_device (NMData *data);
struct NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, const char *iface,
NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, const char *iface,
gboolean test_device, NMDeviceType test_device_type);
void nm_add_initial_devices (NMData *data);
void nm_remove_device (NMData *data, struct NMDevice *dev);
void nm_remove_device (NMData *data, NMDevice *dev);
void nm_schedule_state_change_signal_broadcast (NMData *data);
......
......@@ -36,6 +36,8 @@
#include "nm-activation-request.h"
#include "nm-utils.h"
#include "nm-dbus-nmi.h"
#include "nm-device-802-11-wireless.h"
#include "nm-device-802-3-ethernet.h"
/*
......@@ -61,6 +63,7 @@ static gboolean nm_policy_activation_finish (NMActRequest *req)
/* Tell NetworkManagerInfo to store the MAC address of the active device's AP */
if (nm_device_is_802_11_wireless (dev))
{
NMDevice80211Wireless * wdev = NM_DEVICE_802_11_WIRELESS (dev);
struct ether_addr addr;
NMAccessPoint * ap = nm_act_request_get_ap (req);
NMAccessPoint * tmp_ap;
......@@ -69,7 +72,7 @@ static gboolean nm_policy_activation_finish (NMActRequest *req)
/* Cache details in the info-daemon since the connect was successful */
automatic = !nm_act_request_get_user_requested (req);
nm_device_get_ap_address (dev, &addr);
nm_device_802_11_wireless_get_bssid (wdev, &addr);
if (!nm_ap_get_address (ap) || !nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
nm_ap_set_address (ap, &addr);
......@@ -203,12 +206,12 @@ void nm_policy_schedule_activation_failed (NMActRequest *req)
*/
static NMDevice * nm_policy_auto_get_best_device (NMData *data, NMAccessPoint **ap)