2007-03-15 Tambet Ingo <tambet@ximian.com>
* src/nm-device-802-11-wireless.c (constructor): Initialize the iw_ext structures with zeroes before passing them to functions - the functions never do that and reading the values back may produce wrong values. (real_bring_up): Store the signal handler id ... (real_bring_down): ... So that it can be removed here. Disconnect the supplicant interface here as well. (nm_device_802_11_wireless_ap_list_get_ap_by_obj_path): Use the dbus object path from the access point instead of old $device/Networks/$essid. * src/nm-manager.c (nm_manager_get_state): Return NM_STATE_CONNECTED when the device state is connected (instead of just having link/carrier). * src/nm-activation-request.c: Don't store NMData in activation request, it's already easily accessible through the device. * src/NetworkManagerAP.c (nm_ap_init): Construct the dbus object path here and store it within the object. (nm_ap_get_dbus_path): Export it to public as well. * src/dhcp-manager/nm-dhcp-manager.c (nm_dhcp_manager_get): Keep the ownership of the singleton. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2478 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
24
ChangeLog
24
ChangeLog
@@ -1,3 +1,27 @@
|
|||||||
|
2007-03-15 Tambet Ingo <tambet@ximian.com>
|
||||||
|
|
||||||
|
* src/nm-device-802-11-wireless.c (constructor): Initialize the iw_ext structures
|
||||||
|
with zeroes before passing them to functions - the functions never do that and
|
||||||
|
reading the values back may produce wrong values.
|
||||||
|
(real_bring_up): Store the signal handler id ...
|
||||||
|
(real_bring_down): ... So that it can be removed here.
|
||||||
|
Disconnect the supplicant interface here as well.
|
||||||
|
(nm_device_802_11_wireless_ap_list_get_ap_by_obj_path): Use the dbus object path
|
||||||
|
from the access point instead of old $device/Networks/$essid.
|
||||||
|
|
||||||
|
* src/nm-manager.c (nm_manager_get_state): Return NM_STATE_CONNECTED when the
|
||||||
|
device state is connected (instead of just having link/carrier).
|
||||||
|
|
||||||
|
* src/nm-activation-request.c: Don't store NMData in activation request, it's
|
||||||
|
already easily accessible through the device.
|
||||||
|
|
||||||
|
* src/NetworkManagerAP.c (nm_ap_init): Construct the dbus object path here and
|
||||||
|
store it within the object.
|
||||||
|
(nm_ap_get_dbus_path): Export it to public as well.
|
||||||
|
|
||||||
|
* src/dhcp-manager/nm-dhcp-manager.c (nm_dhcp_manager_get): Keep the ownership
|
||||||
|
of the singleton.
|
||||||
|
|
||||||
2007-03-12 Dan Williams <dcbw@redhat.com>
|
2007-03-12 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
Get rid of 2 second poll of sysfs 'carrier' file for wired devices. Useless
|
Get rid of 2 second poll of sysfs 'carrier' file for wired devices. Useless
|
||||||
|
@@ -46,6 +46,8 @@ static const char * default_essid_list[] =
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
char *dbus_path;
|
||||||
|
|
||||||
/* Scanned or cached values */
|
/* Scanned or cached values */
|
||||||
char * essid;
|
char * essid;
|
||||||
char * orig_essid;
|
char * orig_essid;
|
||||||
@@ -104,6 +106,10 @@ enum {
|
|||||||
static void
|
static void
|
||||||
nm_ap_init (NMAccessPoint *ap)
|
nm_ap_init (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
|
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (ap);
|
||||||
|
static guint32 counter = 0;
|
||||||
|
|
||||||
|
priv->dbus_path = g_strdup_printf (NM_DBUS_PATH_ACCESS_POINT "/%d", counter++);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -111,6 +117,7 @@ finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
|
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
|
||||||
|
|
||||||
|
g_free (priv->dbus_path);
|
||||||
g_free (priv->essid);
|
g_free (priv->essid);
|
||||||
g_free (priv->orig_essid);
|
g_free (priv->orig_essid);
|
||||||
g_slist_foreach (priv->user_addresses, (GFunc)g_free, NULL);
|
g_slist_foreach (priv->user_addresses, (GFunc)g_free, NULL);
|
||||||
@@ -314,19 +321,15 @@ nm_ap_class_init (NMAccessPointClass *ap_class)
|
|||||||
*/
|
*/
|
||||||
NMAccessPoint *nm_ap_new (void)
|
NMAccessPoint *nm_ap_new (void)
|
||||||
{
|
{
|
||||||
NMDBusManager *manager;
|
|
||||||
GObject *object;
|
GObject *object;
|
||||||
char *path;
|
|
||||||
static guint32 counter = 0;
|
|
||||||
|
|
||||||
object = g_object_new (NM_TYPE_AP, NULL);
|
object = g_object_new (NM_TYPE_AP, NULL);
|
||||||
|
if (!object)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
manager = nm_dbus_manager_get ();
|
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (nm_dbus_manager_get ()),
|
||||||
|
nm_ap_get_dbus_path (NM_AP (object)),
|
||||||
path = g_strdup_printf (NM_DBUS_PATH_ACCESS_POINT "/%d", counter++);
|
object);
|
||||||
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (manager),
|
|
||||||
path, object);
|
|
||||||
g_free (path);
|
|
||||||
|
|
||||||
return (NMAccessPoint *) object;
|
return (NMAccessPoint *) object;
|
||||||
}
|
}
|
||||||
@@ -474,6 +477,14 @@ nm_ap_new_from_properties (GHashTable *properties)
|
|||||||
return ap;
|
return ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
nm_ap_get_dbus_path (NMAccessPoint *ap)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
||||||
|
|
||||||
|
return NM_AP_GET_PRIVATE (ap)->dbus_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/set functions for timestamp
|
* Get/set functions for timestamp
|
||||||
|
@@ -62,6 +62,7 @@ NMAccessPoint * nm_ap_new (void);
|
|||||||
NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *ap);
|
NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *ap);
|
||||||
NMAccessPoint * nm_ap_new_from_properties (GHashTable *properties);
|
NMAccessPoint * nm_ap_new_from_properties (GHashTable *properties);
|
||||||
|
|
||||||
|
const char * nm_ap_get_dbus_path (NMAccessPoint *ap);
|
||||||
const GTimeVal * nm_ap_get_timestamp (const NMAccessPoint *ap);
|
const GTimeVal * nm_ap_get_timestamp (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_timestamp (NMAccessPoint *ap, glong sec, glong usec);
|
void nm_ap_set_timestamp (NMAccessPoint *ap, glong sec, glong usec);
|
||||||
void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
||||||
|
@@ -89,10 +89,8 @@ nm_dhcp_manager_get (void)
|
|||||||
|
|
||||||
if (!singleton)
|
if (!singleton)
|
||||||
singleton = nm_dhcp_manager_new ();
|
singleton = nm_dhcp_manager_new ();
|
||||||
else
|
|
||||||
g_object_ref (singleton);
|
|
||||||
|
|
||||||
return singleton;
|
return g_object_ref (singleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -33,7 +33,6 @@
|
|||||||
struct NMActRequest
|
struct NMActRequest
|
||||||
{
|
{
|
||||||
int refcount;
|
int refcount;
|
||||||
NMData * data;
|
|
||||||
NMDevice * dev;
|
NMDevice * dev;
|
||||||
NMAccessPoint * ap;
|
NMAccessPoint * ap;
|
||||||
NMIP4Config * ip4_config;
|
NMIP4Config * ip4_config;
|
||||||
@@ -44,11 +43,10 @@ struct NMActRequest
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *ap, gboolean user_requested)
|
NMActRequest * nm_act_request_new (NMDevice *dev, NMAccessPoint *ap, gboolean user_requested)
|
||||||
{
|
{
|
||||||
NMActRequest * req;
|
NMActRequest * req;
|
||||||
|
|
||||||
g_return_val_if_fail (data != NULL, NULL);
|
|
||||||
g_return_val_if_fail (dev != NULL, NULL);
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
if (NM_IS_DEVICE_802_11_WIRELESS (dev))
|
if (NM_IS_DEVICE_802_11_WIRELESS (dev))
|
||||||
@@ -56,7 +54,6 @@ NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *a
|
|||||||
|
|
||||||
req = g_malloc0 (sizeof (NMActRequest));
|
req = g_malloc0 (sizeof (NMActRequest));
|
||||||
req->refcount = 1;
|
req->refcount = 1;
|
||||||
req->data = data;
|
|
||||||
|
|
||||||
g_object_ref (G_OBJECT (dev));
|
g_object_ref (G_OBJECT (dev));
|
||||||
req->dev = dev;
|
req->dev = dev;
|
||||||
@@ -97,14 +94,6 @@ NMDevice * nm_act_request_get_dev (NMActRequest *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NMData * nm_act_request_get_data (NMActRequest *req)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (req != NULL, NULL);
|
|
||||||
|
|
||||||
return req->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NMAccessPoint * nm_act_request_get_ap (NMActRequest *req)
|
NMAccessPoint * nm_act_request_get_ap (NMActRequest *req)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (req != NULL, NULL);
|
g_return_val_if_fail (req != NULL, NULL);
|
||||||
|
@@ -32,12 +32,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *ap, gboolean user_requested);
|
NMActRequest * nm_act_request_new (NMDevice *dev, NMAccessPoint *ap, gboolean user_requested);
|
||||||
void nm_act_request_ref (NMActRequest *req);
|
void nm_act_request_ref (NMActRequest *req);
|
||||||
void nm_act_request_unref (NMActRequest *req);
|
void nm_act_request_unref (NMActRequest *req);
|
||||||
|
|
||||||
NMDevice * nm_act_request_get_dev (NMActRequest *req);
|
NMDevice * nm_act_request_get_dev (NMActRequest *req);
|
||||||
NMData * nm_act_request_get_data (NMActRequest *req);
|
|
||||||
NMAccessPoint * nm_act_request_get_ap (NMActRequest *req);
|
NMAccessPoint * nm_act_request_get_ap (NMActRequest *req);
|
||||||
gboolean nm_act_request_get_user_requested (NMActRequest *req);
|
gboolean nm_act_request_get_user_requested (NMActRequest *req);
|
||||||
|
|
||||||
|
@@ -52,12 +52,12 @@ nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall,
|
|||||||
g_return_if_fail (pcall != NULL);
|
g_return_if_fail (pcall != NULL);
|
||||||
g_return_if_fail (req != NULL);
|
g_return_if_fail (req != NULL);
|
||||||
|
|
||||||
data = nm_act_request_get_data (req);
|
|
||||||
g_assert (data);
|
|
||||||
|
|
||||||
dev = nm_act_request_get_dev (req);
|
dev = nm_act_request_get_dev (req);
|
||||||
g_assert (dev);
|
g_assert (dev);
|
||||||
|
|
||||||
|
data = nm_device_get_app_data (dev);
|
||||||
|
g_assert (data);
|
||||||
|
|
||||||
ap = nm_act_request_get_ap (req);
|
ap = nm_act_request_get_ap (req);
|
||||||
g_assert (ap);
|
g_assert (ap);
|
||||||
|
|
||||||
|
@@ -98,6 +98,7 @@ typedef struct Supplicant {
|
|||||||
NMSupplicantInterface * iface;
|
NMSupplicantInterface * iface;
|
||||||
|
|
||||||
/* signal handler ids */
|
/* signal handler ids */
|
||||||
|
guint mgr_state_id;
|
||||||
guint iface_error_id;
|
guint iface_error_id;
|
||||||
guint iface_state_id;
|
guint iface_state_id;
|
||||||
guint iface_scanned_ap_id;
|
guint iface_scanned_ap_id;
|
||||||
@@ -426,7 +427,8 @@ constructor (GType type,
|
|||||||
struct iw_range range;
|
struct iw_range range;
|
||||||
struct iwreq wrq;
|
struct iwreq wrq;
|
||||||
|
|
||||||
memset (&wrq, 0, sizeof (wrq));
|
memset (&wrq, 0, sizeof (struct iwreq));
|
||||||
|
memset (&range, 0, sizeof (struct iw_range));
|
||||||
strncpy (wrq.ifr_name, iface, IFNAMSIZ);
|
strncpy (wrq.ifr_name, iface, IFNAMSIZ);
|
||||||
wrq.u.data.pointer = (caddr_t) ⦥
|
wrq.u.data.pointer = (caddr_t) ⦥
|
||||||
wrq.u.data.length = sizeof (struct iw_range);
|
wrq.u.data.length = sizeof (struct iw_range);
|
||||||
@@ -579,10 +581,10 @@ real_bring_up (NMDevice *dev)
|
|||||||
nm_device_802_11_wireless_set_mode (self, IW_MODE_INFRA);
|
nm_device_802_11_wireless_set_mode (self, IW_MODE_INFRA);
|
||||||
|
|
||||||
priv->supplicant.mgr = nm_supplicant_manager_get ();
|
priv->supplicant.mgr = nm_supplicant_manager_get ();
|
||||||
g_signal_connect (priv->supplicant.mgr,
|
priv->supplicant.mgr_state_id = g_signal_connect (priv->supplicant.mgr,
|
||||||
"state",
|
"state",
|
||||||
G_CALLBACK (supplicant_mgr_state_cb),
|
G_CALLBACK (supplicant_mgr_state_cb),
|
||||||
self);
|
self);
|
||||||
if (nm_supplicant_manager_get_state (priv->supplicant.mgr) == NM_SUPPLICANT_MANAGER_STATE_IDLE) {
|
if (nm_supplicant_manager_get_state (priv->supplicant.mgr) == NM_SUPPLICANT_MANAGER_STATE_IDLE) {
|
||||||
init_supplicant_interface (self);
|
init_supplicant_interface (self);
|
||||||
}
|
}
|
||||||
@@ -608,11 +610,20 @@ real_bring_down (NMDevice *dev)
|
|||||||
|
|
||||||
cleanup_supplicant_interface (self);
|
cleanup_supplicant_interface (self);
|
||||||
|
|
||||||
|
if (priv->supplicant.iface) {
|
||||||
|
nm_supplicant_interface_disconnect (priv->supplicant.iface);
|
||||||
|
priv->supplicant.iface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->supplicant.mgr_state_id) {
|
||||||
|
g_signal_handler_disconnect (priv->supplicant.mgr, priv->supplicant.mgr_state_id);
|
||||||
|
priv->supplicant.mgr_state_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->supplicant.mgr) {
|
if (priv->supplicant.mgr) {
|
||||||
g_object_unref (priv->supplicant.mgr);
|
g_object_unref (priv->supplicant.mgr);
|
||||||
priv->supplicant.mgr = NULL;
|
priv->supplicant.mgr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -651,8 +662,7 @@ nm_device_802_11_wireless_activate (NMDevice80211Wireless *self,
|
|||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (ap != NULL);
|
||||||
|
|
||||||
device = NM_DEVICE (self);
|
device = NM_DEVICE (self);
|
||||||
req = nm_act_request_new (nm_device_get_app_data (device),
|
req = nm_act_request_new (device,
|
||||||
device,
|
|
||||||
ap,
|
ap,
|
||||||
user_requested);
|
user_requested);
|
||||||
|
|
||||||
@@ -1117,31 +1127,28 @@ NMAccessPoint *
|
|||||||
nm_device_802_11_wireless_ap_list_get_ap_by_obj_path (NMDevice80211Wireless *self,
|
nm_device_802_11_wireless_ap_list_get_ap_by_obj_path (NMDevice80211Wireless *self,
|
||||||
const char *obj_path)
|
const char *obj_path)
|
||||||
{
|
{
|
||||||
NMAccessPoint * ret_ap = NULL;
|
NMAccessPointList *ap_list;
|
||||||
char * built_path;
|
NMAccessPoint *ap = NULL;
|
||||||
char * dev_path;
|
|
||||||
|
|
||||||
g_return_val_if_fail (self != NULL, NULL);
|
ap_list = nm_device_802_11_wireless_ap_list_get (self);
|
||||||
g_return_val_if_fail (obj_path != NULL, NULL);
|
if (ap_list) {
|
||||||
|
NMAPListIter *list_iter;
|
||||||
|
|
||||||
if (!self->priv->ap_list)
|
if ((list_iter = nm_ap_list_iter_new (ap_list))) {
|
||||||
return NULL;
|
gboolean found = FALSE;
|
||||||
|
|
||||||
dev_path = nm_dbus_get_object_path_for_device (NM_DEVICE (self));
|
while (!found && (ap = nm_ap_list_iter_next (list_iter))) {
|
||||||
dev_path = nm_dbus_unescape_object_path (dev_path);
|
if (!strcmp (obj_path, nm_ap_get_dbus_path (ap)))
|
||||||
built_path = g_strdup_printf ("%s/Networks/", dev_path);
|
found = TRUE;
|
||||||
g_free (dev_path);
|
}
|
||||||
|
nm_ap_list_iter_free (list_iter);
|
||||||
|
|
||||||
if (strncmp (built_path, obj_path, strlen (built_path)) == 0)
|
if (!found)
|
||||||
{
|
ap = NULL;
|
||||||
char *essid = g_strdup (obj_path + strlen (built_path));
|
}
|
||||||
|
|
||||||
ret_ap = nm_ap_list_get_ap_by_essid (self->priv->ap_list, essid);
|
|
||||||
g_free (essid);
|
|
||||||
}
|
}
|
||||||
g_free (built_path);
|
|
||||||
|
|
||||||
return ret_ap;
|
return ap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2957,7 +2964,7 @@ activation_failure_handler (NMDevice *dev)
|
|||||||
NMAccessPoint * ap;
|
NMAccessPoint * ap;
|
||||||
|
|
||||||
req = nm_device_get_act_request (dev);
|
req = nm_device_get_act_request (dev);
|
||||||
app_data = nm_act_request_get_data (req);
|
app_data = nm_device_get_app_data (dev);
|
||||||
g_assert (app_data);
|
g_assert (app_data);
|
||||||
|
|
||||||
if ((ap = nm_act_request_get_ap (req)))
|
if ((ap = nm_act_request_get_ap (req)))
|
||||||
|
@@ -268,8 +268,7 @@ nm_device_802_3_ethernet_activate (NMDevice8023Ethernet *self,
|
|||||||
g_return_if_fail (NM_IS_DEVICE_802_3_ETHERNET (self));
|
g_return_if_fail (NM_IS_DEVICE_802_3_ETHERNET (self));
|
||||||
|
|
||||||
device = NM_DEVICE (self);
|
device = NM_DEVICE (self);
|
||||||
req = nm_act_request_new (nm_device_get_app_data (device),
|
req = nm_act_request_new (device,
|
||||||
device,
|
|
||||||
NULL,
|
NULL,
|
||||||
user_requested);
|
user_requested);
|
||||||
|
|
||||||
|
@@ -78,8 +78,6 @@ struct _NMDeviceClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent;
|
GObjectClass parent;
|
||||||
|
|
||||||
const char * (* has_active_link) (NMDevice *self);
|
|
||||||
void (* set_active_link) (NMDevice *self, gboolean active);
|
|
||||||
void (* update_link) (NMDevice *self);
|
void (* update_link) (NMDevice *self);
|
||||||
|
|
||||||
gboolean (* is_up) (NMDevice *self);
|
gboolean (* is_up) (NMDevice *self);
|
||||||
|
@@ -354,7 +354,7 @@ nm_manager_get_state (NMManager *manager)
|
|||||||
for (iter = priv->devices; iter; iter = iter->next) {
|
for (iter = priv->devices; iter; iter = iter->next) {
|
||||||
NMDevice *dev = NM_DEVICE (iter->data);
|
NMDevice *dev = NM_DEVICE (iter->data);
|
||||||
|
|
||||||
if (nm_device_has_active_link (dev))
|
if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED)
|
||||||
return NM_STATE_CONNECTED;
|
return NM_STATE_CONNECTED;
|
||||||
|
|
||||||
if (nm_device_is_activating (dev))
|
if (nm_device_is_activating (dev))
|
||||||
|
Reference in New Issue
Block a user