mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 11:19:16 +02:00
2007-02-05 Tambet Ingo <tambet@ximian.com>
* src/NetworkManagerMain.h: Remove all references to DHCP manager. * src/NetworkManager.c: Don't initialize the DHCP manager, it's a singleton now. * src/nm-device.c: Use the new DHCP manager API. * src/nm-activation-request.c: * src/nm-activation-request.h: - Remove all dhcp related properties and methods. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2284 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
1bbdd977e3
commit
58b53400a5
6 changed files with 123 additions and 79 deletions
30
ChangeLog
30
ChangeLog
|
|
@ -1,3 +1,33 @@
|
||||||
|
2007-02-05 Tambet Ingo <tambet@ximian.com>
|
||||||
|
|
||||||
|
* src/NetworkManagerMain.h: Remove all references to DHCP manager.
|
||||||
|
|
||||||
|
* src/NetworkManager.c: Don't initialize the DHCP manager, it's a
|
||||||
|
singleton now.
|
||||||
|
|
||||||
|
* src/nm-device.c: Use the new DHCP manager API.
|
||||||
|
|
||||||
|
* src/nm-activation-request.c:
|
||||||
|
* src/nm-activation-request.h:
|
||||||
|
- Remove all dhcp related properties and methods.
|
||||||
|
|
||||||
|
* src/dhcp-manager/nm-dhcp-marshal-main.c: Add.
|
||||||
|
|
||||||
|
* src/dhcp-manager/nm-dhcp-marshal.list: Add.
|
||||||
|
|
||||||
|
* src/dhcp-manager/nm-dhcp-manager.c:
|
||||||
|
* src/dhcp-manager/nm-dhcp-manager.h:
|
||||||
|
- Convert it to GObject since we need to signal state changes.
|
||||||
|
- Remove all references to other NM classes, this class is one
|
||||||
|
of the lowest classes in our hierarchy.
|
||||||
|
- One less class to use NMActRequest.
|
||||||
|
- Make it singleton, one less user of NMData.
|
||||||
|
- Remove a couple of sleep() calls.
|
||||||
|
- Convert a bunch of low-level dbus API calls to dbus-glib calls.
|
||||||
|
One less class to use the NM's custom tailored signal handlig.
|
||||||
|
|
||||||
|
* Makefile.am: Generate marshallers, add them to build.
|
||||||
|
|
||||||
2007-02-02 Dan Williams <dcbw@redhat.com>
|
2007-02-02 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* configure.in
|
* configure.in
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@
|
||||||
#include "nm-supplicant-manager.h"
|
#include "nm-supplicant-manager.h"
|
||||||
#include "nm-dbus-net.h"
|
#include "nm-dbus-net.h"
|
||||||
#include "nm-netlink-monitor.h"
|
#include "nm-netlink-monitor.h"
|
||||||
#include "nm-dhcp-manager.h"
|
|
||||||
#include "nm-logging.h"
|
#include "nm-logging.h"
|
||||||
|
|
||||||
#define NM_WIRELESS_LINK_STATE_POLL_INTERVAL (5 * 1000)
|
#define NM_WIRELESS_LINK_STATE_POLL_INTERVAL (5 * 1000)
|
||||||
|
|
@ -567,7 +566,6 @@ static void nm_data_free (NMData *data)
|
||||||
nm_dbus_method_list_unref (data->device_methods);
|
nm_dbus_method_list_unref (data->device_methods);
|
||||||
|
|
||||||
nm_vpn_manager_dispose (data->vpn_manager);
|
nm_vpn_manager_dispose (data->vpn_manager);
|
||||||
nm_dhcp_manager_dispose (data->dhcp_manager);
|
|
||||||
g_object_unref (data->named_manager);
|
g_object_unref (data->named_manager);
|
||||||
|
|
||||||
g_main_loop_unref (data->main_loop);
|
g_main_loop_unref (data->main_loop);
|
||||||
|
|
@ -818,12 +816,6 @@ main (int argc, char *argv[])
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_data->dhcp_manager = nm_dhcp_manager_new (nm_data);
|
|
||||||
if (!nm_data->dhcp_manager) {
|
|
||||||
nm_warning ("Failed to start the DHCP manager.");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
nm_data->named_manager = nm_named_manager_new ();
|
nm_data->named_manager = nm_named_manager_new ();
|
||||||
if (!nm_data->named_manager) {
|
if (!nm_data->named_manager) {
|
||||||
nm_warning ("Failed to start the named manager.");
|
nm_warning ("Failed to start the named manager.");
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,6 @@ typedef enum NMIntState
|
||||||
typedef struct NMActRequest NMActRequest;
|
typedef struct NMActRequest NMActRequest;
|
||||||
typedef struct NMVPNActRequest NMVPNActRequest;
|
typedef struct NMVPNActRequest NMVPNActRequest;
|
||||||
typedef struct NMVPNManager NMVPNManager;
|
typedef struct NMVPNManager NMVPNManager;
|
||||||
typedef struct NMDHCPManager NMDHCPManager;
|
|
||||||
|
|
||||||
#define DHCP_SERVICE_NAME "com.redhat.dhcp"
|
|
||||||
#define DHCP_OBJECT_PATH "/com/redhat/dhcp"
|
|
||||||
|
|
||||||
typedef struct NMData
|
typedef struct NMData
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +61,6 @@ typedef struct NMData
|
||||||
|
|
||||||
NMNamedManager * named_manager;
|
NMNamedManager * named_manager;
|
||||||
NMVPNManager * vpn_manager;
|
NMVPNManager * vpn_manager;
|
||||||
NMDHCPManager * dhcp_manager;
|
|
||||||
guint32 nmi_sig_handler_id;
|
guint32 nmi_sig_handler_id;
|
||||||
|
|
||||||
NMDbusMethodList * nm_methods;
|
NMDbusMethodList * nm_methods;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#include "nm-activation-request.h"
|
#include "nm-activation-request.h"
|
||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
#include "NetworkManagerDbus.h"
|
#include "NetworkManagerDbus.h"
|
||||||
#include "nm-dhcp-manager.h"
|
|
||||||
#include "nm-dbus-manager.h"
|
#include "nm-dbus-manager.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
|
@ -43,9 +42,6 @@ struct NMActRequest
|
||||||
|
|
||||||
NMActStage stage;
|
NMActStage stage;
|
||||||
DBusPendingCall * user_key_pcall;
|
DBusPendingCall * user_key_pcall;
|
||||||
|
|
||||||
guint32 dhcp_state;
|
|
||||||
guint dhcp_timeout;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -71,7 +67,6 @@ NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *a
|
||||||
req->ap = ap;
|
req->ap = ap;
|
||||||
|
|
||||||
req->user_requested = user_requested;
|
req->user_requested = user_requested;
|
||||||
req->dhcp_state = nm_dhcp_manager_get_state_for_device (data->dhcp_manager, dev);
|
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
@ -94,9 +89,6 @@ void nm_act_request_unref (NMActRequest *req)
|
||||||
if (req->ap)
|
if (req->ap)
|
||||||
nm_ap_unref (req->ap);
|
nm_ap_unref (req->ap);
|
||||||
|
|
||||||
if (req->dhcp_timeout > 0)
|
|
||||||
g_source_remove (req->dhcp_timeout);
|
|
||||||
|
|
||||||
memset (req, 0, sizeof (NMActRequest));
|
memset (req, 0, sizeof (NMActRequest));
|
||||||
g_free (req);
|
g_free (req);
|
||||||
}
|
}
|
||||||
|
|
@ -225,32 +217,3 @@ void nm_act_request_set_user_key_pending_call (NMActRequest *req, DBusPendingCal
|
||||||
if (req->user_key_pcall)
|
if (req->user_key_pcall)
|
||||||
dbus_pending_call_ref (req->user_key_pcall);
|
dbus_pending_call_ref (req->user_key_pcall);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint8 nm_act_request_get_dhcp_state (NMActRequest *req)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (req != NULL, 0);
|
|
||||||
|
|
||||||
return req->dhcp_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nm_act_request_set_dhcp_state (NMActRequest *req, guint8 dhcp_state)
|
|
||||||
{
|
|
||||||
g_return_if_fail (req != NULL);
|
|
||||||
|
|
||||||
req->dhcp_state = dhcp_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
guint nm_act_request_get_dhcp_timeout (NMActRequest *req)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (req != NULL, 0);
|
|
||||||
|
|
||||||
return req->dhcp_timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nm_act_request_set_dhcp_timeout (NMActRequest *req, guint dhcp_timeout)
|
|
||||||
{
|
|
||||||
g_return_if_fail (req != NULL);
|
|
||||||
|
|
||||||
req->dhcp_timeout = dhcp_timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,4 @@ void nm_act_request_set_stage (NMActRequest *req, NMActStage stage);
|
||||||
DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req);
|
DBusPendingCall * nm_act_request_get_user_key_pending_call (NMActRequest *req);
|
||||||
void nm_act_request_set_user_key_pending_call (NMActRequest *req, DBusPendingCall *pcall);
|
void nm_act_request_set_user_key_pending_call (NMActRequest *req, DBusPendingCall *pcall);
|
||||||
|
|
||||||
guint8 nm_act_request_get_dhcp_state (NMActRequest *req);
|
|
||||||
void nm_act_request_set_dhcp_state (NMActRequest *req, guint8 dhcp_state);
|
|
||||||
|
|
||||||
guint nm_act_request_get_dhcp_timeout (NMActRequest *req);
|
|
||||||
void nm_act_request_set_dhcp_timeout (NMActRequest *req, guint dhcp_timeout);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
114
src/nm-device.c
114
src/nm-device.c
|
|
@ -62,8 +62,9 @@ struct _NMDevicePrivate
|
||||||
|
|
||||||
/* IP configuration info */
|
/* IP configuration info */
|
||||||
void * system_config_data; /* Distro-specific config data (parsed config file, etc) */
|
void * system_config_data; /* Distro-specific config data (parsed config file, etc) */
|
||||||
gboolean use_dhcp;
|
|
||||||
NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */
|
NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */
|
||||||
|
NMDHCPManager * dhcp_manager;
|
||||||
|
gulong dhcp_signal_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req);
|
static void nm_device_activate_schedule_stage5_ip_config_commit (NMActRequest *req);
|
||||||
|
|
@ -175,7 +176,7 @@ nm_device_new (const char *iface,
|
||||||
|
|
||||||
/* Grab IP config data for this device from the system configuration files */
|
/* Grab IP config data for this device from the system configuration files */
|
||||||
dev->priv->system_config_data = nm_system_device_get_system_config (dev, app_data);
|
dev->priv->system_config_data = nm_system_device_get_system_config (dev, app_data);
|
||||||
dev->priv->use_dhcp = nm_system_device_get_use_dhcp (dev);
|
nm_device_set_use_dhcp (dev, nm_system_device_get_use_dhcp (dev));
|
||||||
|
|
||||||
/* Allow distributions to flag devices as disabled */
|
/* Allow distributions to flag devices as disabled */
|
||||||
if (nm_system_device_get_disabled (dev))
|
if (nm_system_device_get_disabled (dev))
|
||||||
|
|
@ -217,7 +218,6 @@ nm_device_init (NMDevice * self)
|
||||||
self->priv->act_source_id = 0;
|
self->priv->act_source_id = 0;
|
||||||
|
|
||||||
self->priv->system_config_data = NULL;
|
self->priv->system_config_data = NULL;
|
||||||
self->priv->use_dhcp = TRUE;
|
|
||||||
self->priv->ip4_config = NULL;
|
self->priv->ip4_config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -724,19 +724,27 @@ real_act_stage3_ip_config_start (NMDevice *self,
|
||||||
if (nm_device_get_use_dhcp (self))
|
if (nm_device_get_use_dhcp (self))
|
||||||
{
|
{
|
||||||
/* Begin a DHCP transaction on the interface */
|
/* Begin a DHCP transaction on the interface */
|
||||||
if (!nm_dhcp_manager_begin_transaction (data->dhcp_manager, req))
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
{
|
gboolean success;
|
||||||
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DHCP devices will be notified by the DHCP manager when
|
/* DHCP manager will cancel any transaction already in progress and we do not
|
||||||
* stuff happens.
|
want to cancel this activation if we get "down" state from that. */
|
||||||
*/
|
g_signal_handler_block (priv->dhcp_manager, priv->dhcp_signal_id);
|
||||||
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
||||||
|
success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager,
|
||||||
|
nm_device_get_iface (self));
|
||||||
|
|
||||||
|
g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_signal_id);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
/* DHCP devices will be notified by the DHCP manager when
|
||||||
|
* stuff happens.
|
||||||
|
*/
|
||||||
|
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
||||||
|
} else
|
||||||
|
ret = NM_ACT_STAGE_RETURN_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -859,9 +867,14 @@ real_act_stage4_get_ip4_config (NMDevice *self,
|
||||||
data = nm_act_request_get_data (req);
|
data = nm_act_request_get_data (req);
|
||||||
g_assert (data);
|
g_assert (data);
|
||||||
|
|
||||||
if (nm_device_get_use_dhcp (self))
|
if (nm_device_get_use_dhcp (self)) {
|
||||||
real_config = nm_dhcp_manager_get_ip4_config (data->dhcp_manager, req);
|
real_config = nm_dhcp_manager_get_ip4_config (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
||||||
else
|
nm_device_get_iface (self));
|
||||||
|
|
||||||
|
if (real_config && nm_ip4_config_get_mtu (real_config) == 0)
|
||||||
|
/* If the DHCP server doesn't set the MTU, get it from backend. */
|
||||||
|
nm_ip4_config_set_mtu (real_config, nm_system_get_mtu (self));
|
||||||
|
} else
|
||||||
real_config = nm_system_device_new_ip4_system_config (self);
|
real_config = nm_system_device_new_ip4_system_config (self);
|
||||||
|
|
||||||
if (real_config)
|
if (real_config)
|
||||||
|
|
@ -1138,7 +1151,9 @@ real_activation_cancel_handler (NMDevice *self,
|
||||||
g_return_if_fail (req != NULL);
|
g_return_if_fail (req != NULL);
|
||||||
|
|
||||||
if (nm_act_request_get_stage (req) == NM_ACT_STAGE_IP_CONFIG_START)
|
if (nm_act_request_get_stage (req) == NM_ACT_STAGE_IP_CONFIG_START)
|
||||||
nm_dhcp_manager_cancel_transaction (self->priv->app_data->dhcp_manager, req);
|
nm_dhcp_manager_cancel_transaction (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
||||||
|
nm_device_get_iface (self),
|
||||||
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1212,7 +1227,9 @@ nm_device_deactivate_quickly (NMDevice *self)
|
||||||
*/
|
*/
|
||||||
if ((act_request = nm_device_get_act_request (self)))
|
if ((act_request = nm_device_get_act_request (self)))
|
||||||
{
|
{
|
||||||
nm_dhcp_manager_cancel_transaction (app_data->dhcp_manager, act_request);
|
nm_dhcp_manager_cancel_transaction (NM_DEVICE_GET_PRIVATE (self)->dhcp_manager,
|
||||||
|
nm_device_get_iface (self),
|
||||||
|
FALSE);
|
||||||
nm_act_request_unref (act_request);
|
nm_act_request_unref (act_request);
|
||||||
self->priv->act_request = NULL;
|
self->priv->act_request = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -1385,21 +1402,72 @@ nm_device_can_interrupt_activation (NMDevice *self)
|
||||||
|
|
||||||
/* IP Configuration stuff */
|
/* IP Configuration stuff */
|
||||||
|
|
||||||
|
static void
|
||||||
|
dhcp_state_changed (NMDHCPManager *dhcp_manager,
|
||||||
|
const char *iface,
|
||||||
|
NMDHCPState state,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
NMDevice *device = NM_DEVICE (user_data);
|
||||||
|
NMActRequest *req;
|
||||||
|
|
||||||
|
req = nm_device_get_act_request (device);
|
||||||
|
if (!req)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!strcmp (nm_device_get_iface (device), iface) &&
|
||||||
|
nm_act_request_get_stage (req) == NM_ACT_STAGE_IP_CONFIG_START) {
|
||||||
|
switch (state) {
|
||||||
|
case DHCDBD_BOUND: /* lease obtained */
|
||||||
|
case DHCDBD_RENEW: /* lease renewed */
|
||||||
|
case DHCDBD_REBOOT: /* have valid lease, but now obtained a different one */
|
||||||
|
case DHCDBD_REBIND: /* new, different lease */
|
||||||
|
nm_device_activate_schedule_stage4_ip_config_get (req);
|
||||||
|
break;
|
||||||
|
case DHCDBD_TIMEOUT: /* timed out contacting DHCP server */
|
||||||
|
nm_device_activate_schedule_stage4_ip_config_timeout (req);
|
||||||
|
break;
|
||||||
|
case DHCDBD_FAIL: /* all attempts to contact server timed out, sleeping */
|
||||||
|
case DHCDBD_ABEND: /* dhclient exited abnormally */
|
||||||
|
case DHCDBD_END: /* dhclient exited normally */
|
||||||
|
nm_policy_schedule_activation_failed (req);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_device_get_use_dhcp (NMDevice *self)
|
nm_device_get_use_dhcp (NMDevice *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (self != NULL, FALSE);
|
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
|
||||||
|
|
||||||
return self->priv->use_dhcp;
|
return NM_DEVICE_GET_PRIVATE (self)->dhcp_manager ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_device_set_use_dhcp (NMDevice *self,
|
nm_device_set_use_dhcp (NMDevice *self,
|
||||||
gboolean use_dhcp)
|
gboolean use_dhcp)
|
||||||
{
|
{
|
||||||
g_return_if_fail (self != NULL);
|
NMDevicePrivate *priv;
|
||||||
|
|
||||||
self->priv->use_dhcp = use_dhcp;
|
g_return_if_fail (NM_IS_DEVICE (self));
|
||||||
|
|
||||||
|
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
|
||||||
|
if (use_dhcp) {
|
||||||
|
if (!priv->dhcp_manager) {
|
||||||
|
priv->dhcp_manager = nm_dhcp_manager_get ();
|
||||||
|
priv->dhcp_signal_id = g_signal_connect (priv->dhcp_manager, "state-changed",
|
||||||
|
G_CALLBACK (dhcp_state_changed),
|
||||||
|
self);
|
||||||
|
}
|
||||||
|
} else if (priv->dhcp_manager) {
|
||||||
|
g_signal_handler_disconnect (priv->dhcp_manager, priv->dhcp_signal_id);
|
||||||
|
g_object_unref (priv->dhcp_manager);
|
||||||
|
priv->dhcp_manager = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1652,6 +1720,8 @@ nm_device_dispose (GObject *object)
|
||||||
self->priv->act_source_id = 0;
|
self->priv->act_source_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nm_device_set_use_dhcp (self, FALSE);
|
||||||
|
|
||||||
/* Chain up to the parent class */
|
/* Chain up to the parent class */
|
||||||
klass = NM_DEVICE_CLASS (g_type_class_peek (NM_TYPE_DEVICE));
|
klass = NM_DEVICE_CLASS (g_type_class_peek (NM_TYPE_DEVICE));
|
||||||
parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
|
parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue