2007-12-05 Tambet Ingo <tambet@gmail.com>

* src/nm-umts-device.c (dial_done): Fix the typoes in warnings.
        (get_network_done): Remove newline, nm_info() does it already.
        (real_act_stage1_prepare): Turn the modem echo off.

        * src/NetworkManagerSystem.c
        * (nm_system_device_set_from_ip4_config): In case of serial
        device, set the route to the device interface. This is a hack.

        * src/nm-serial-device.c (nm_serial_device_send_command_string):
        * Only append carriage 
        return, no need for a new-line.
        (ppp_ip4_config): Store the ip4 config to be set in the next
stage.
        Change the device iface here (ugh).
        (real_act_stage4_get_ip4_config): Implement.
        (real_deactivate_quickly): Free the pending ip4 config if it's
still pending.
        Restore the device iface.

        * src/NetworkManagerPolicy.c (nm_policy_device_change_check): Do
        * nothing if the active
        device is not wired or wireless (eg, automatically upped)
device.

        * src/ppp-manager/nm-ppp-manager.c (ip4_config_get): Don't make
        * the config secondary,
        it isn't.
        (nm_ppp_manager_start): Don't let pppd to set the default route,
we want to do it.

        * src/nm-hal-manager.c (get_creator): Make sure the device has
        * required capability
        before calling it's is_device_fn().



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3137 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Tambet Ingo 2007-12-05 17:33:55 +00:00
parent 5ec181c20e
commit cb1277c955
7 changed files with 103 additions and 15 deletions

View file

@ -1,3 +1,30 @@
2007-12-05 Tambet Ingo <tambet@gmail.com>
* src/nm-umts-device.c (dial_done): Fix the typoes in warnings.
(get_network_done): Remove newline, nm_info() does it already.
(real_act_stage1_prepare): Turn the modem echo off.
* src/NetworkManagerSystem.c (nm_system_device_set_from_ip4_config): In case of serial
device, set the route to the device interface. This is a hack.
* src/nm-serial-device.c (nm_serial_device_send_command_string): Only append carriage
return, no need for a new-line.
(ppp_ip4_config): Store the ip4 config to be set in the next stage.
Change the device iface here (ugh).
(real_act_stage4_get_ip4_config): Implement.
(real_deactivate_quickly): Free the pending ip4 config if it's still pending.
Restore the device iface.
* src/NetworkManagerPolicy.c (nm_policy_device_change_check): Do nothing if the active
device is not wired or wireless (eg, automatically upped) device.
* src/ppp-manager/nm-ppp-manager.c (ip4_config_get): Don't make the config secondary,
it isn't.
(nm_ppp_manager_start): Don't let pppd to set the default route, we want to do it.
* src/nm-hal-manager.c (get_creator): Make sure the device has required capability
before calling it's is_device_fn().
2007-12-05 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-utils.c

View file

@ -236,6 +236,11 @@ nm_policy_device_change_check (gpointer user_data)
switch (nm_manager_get_state (policy->manager)) {
case NM_STATE_CONNECTED:
old_dev = nm_manager_get_active_device (policy->manager);
/* Don't touch devices that are not upped/downed automatically */
if (!NM_IS_DEVICE_802_3_ETHERNET (old_dev) && !NM_IS_DEVICE_802_11_WIRELESS (old_dev))
goto out;
caps = nm_device_get_capabilities (old_dev);
/* Don't interrupt semi-supported devices. If the user chose

View file

@ -1,3 +1,5 @@
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
@ -48,6 +50,9 @@
#include "nm-utils.h"
#include "nm-netlink.h"
/* FIXME: Remove this */
#include "nm-serial-device.h"
#include <netlink/route/addr.h>
#include <netlink/netlink.h>
#include <netlink/utils.h>
@ -223,7 +228,13 @@ gboolean nm_system_device_set_from_ip4_config (NMDevice *dev)
nm_warning ("couldn't create rtnl address!\n");
sleep (1);
nm_system_device_set_ip4_route (dev, nm_ip4_config_get_gateway (config), 0, 0, nm_ip4_config_get_mss (config));
/* FIXME: This is wrong wrong wrong. But I don't know how to fix it. A virtual function to NMDevice class? */
if (NM_IS_SERIAL_DEVICE (dev))
nm_system_device_add_default_route_via_device_with_iface (nm_device_get_iface (dev));
else
nm_system_device_set_ip4_route (dev, nm_ip4_config_get_gateway (config), 0, 0,
nm_ip4_config_get_mss (config));
len = nm_ip4_config_get_num_static_routes (config);
for (i = 0; i < len; i++) {

View file

@ -52,7 +52,8 @@ get_creator (NMHalManager *manager, const char *udi)
for (iter = manager->device_creators; iter; iter = iter->next) {
creator = (DeviceCreator *) iter->data;
if (creator->is_device_fn (manager, udi))
if (libhal_device_query_capability (manager->hal_ctx, udi, creator->capability_str, NULL) &&
creator->is_device_fn (manager, udi))
return creator;
}

View file

@ -13,6 +13,7 @@
#include <glib.h>
#include "nm-serial-device.h"
#include "nm-device-interface.h"
#include "nm-device-private.h"
#include "ppp-manager/nm-ppp-manager.h"
#include "nm-setting-serial.h"
@ -24,9 +25,11 @@ G_DEFINE_TYPE (NMSerialDevice, nm_serial_device, NM_TYPE_DEVICE)
#define NM_SERIAL_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SERIAL_DEVICE, NMSerialDevicePrivate))
typedef struct {
char *serial_iface;
int fd;
GIOChannel *channel;
NMPPPManager *ppp_manager;
NMIP4Config *pending_ip4_config;
struct termios old_t;
} NMSerialDevicePrivate;
@ -326,7 +329,7 @@ nm_serial_device_send_command_string (NMSerialDevice *device, const char *str)
command = g_byte_array_new ();
g_byte_array_append (command, (guint8 *) str, strlen (str));
g_byte_array_append (command, (guint8 *) "\r\n", 2);
g_byte_array_append (command, (guint8 *) "\r", 1);
ret = nm_serial_device_send_command (device, command);
g_byte_array_free (command, TRUE);
@ -760,10 +763,12 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
NMIP4Config *config,
gpointer user_data)
{
nm_debug ("got ipconfig from pppd: %s", iface);
/* FIXME */
NMDevice *device = NM_DEVICE (user_data);
nm_device_state_changed (NM_DEVICE (user_data), NM_DEVICE_STATE_ACTIVATED);
g_object_set (device, NM_DEVICE_INTERFACE_IFACE, iface, NULL);
NM_SERIAL_DEVICE_GET_PRIVATE (device)->pending_ip4_config = g_object_ref (config);
nm_device_activate_schedule_stage4_ip_config_get (device);
}
static NMActStageReturn
@ -802,12 +807,32 @@ real_act_stage2_config (NMDevice *device)
return ret;
}
static NMActStageReturn
real_act_stage4_get_ip4_config (NMDevice *device, NMIP4Config **config)
{
NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (device);
*config = priv->pending_ip4_config;
priv->pending_ip4_config = NULL;
return NM_ACT_STAGE_RETURN_SUCCESS;
}
static void
real_deactivate_quickly (NMDevice *device)
{
NMSerialDevice *self = NM_SERIAL_DEVICE (device);
NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (device);
/* Restore the iface (ttyUSB0 vs ppp0) */
if (!strcmp (nm_device_get_iface (device), priv->serial_iface))
g_object_set (device, NM_DEVICE_INTERFACE_IFACE, priv->serial_iface, NULL);
if (priv->pending_ip4_config) {
g_object_unref (priv->pending_ip4_config);
priv->pending_ip4_config = NULL;
}
if (priv->ppp_manager) {
g_object_unref (priv->ppp_manager);
priv->ppp_manager = NULL;
@ -844,12 +869,32 @@ nm_serial_device_init (NMSerialDevice *self)
{
}
static GObject*
constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
GObject *object;
object = G_OBJECT_CLASS (nm_serial_device_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
NM_SERIAL_DEVICE_GET_PRIVATE (object)->serial_iface = g_strdup (nm_device_get_iface (NM_DEVICE (object)));
return object;
}
static void
finalize (GObject *object)
{
NMSerialDevice *self = NM_SERIAL_DEVICE (object);
NMSerialDevicePrivate *priv = NM_SERIAL_DEVICE_GET_PRIVATE (self);
nm_serial_device_close (self);
g_free (priv->serial_iface);
G_OBJECT_CLASS (nm_serial_device_parent_class)->finalize (object);
}
@ -863,9 +908,11 @@ nm_serial_device_class_init (NMSerialDeviceClass *klass)
g_type_class_add_private (object_class, sizeof (NMSerialDevicePrivate));
/* Virtual methods */
object_class->constructor = constructor;
object_class->finalize = finalize;
parent_class->check_connection = real_check_connection;
parent_class->act_stage2_config = real_act_stage2_config;
parent_class->act_stage4_get_ip4_config = real_act_stage4_get_ip4_config;
parent_class->deactivate_quickly = real_deactivate_quickly;
}

View file

@ -80,10 +80,10 @@ dial_done (NMSerialDevice *device,
nm_warning ("No carrier");
break;
case -1:
nm_warning ("Manual registration timed out");
nm_warning ("Dialing timed out");
break;
default:
nm_warning ("Manual registration failed");
nm_warning ("Dialing failed");
break;
}
@ -151,7 +151,7 @@ get_network_done (NMSerialDevice *device,
gpointer user_data)
{
if (response)
nm_info ("Associated with network: %s\n", response);
nm_info ("Associated with network: %s", response);
else
nm_warning ("Couldn't read active network name");
@ -161,7 +161,7 @@ get_network_done (NMSerialDevice *device,
static void
automatic_registration_get_network (NMSerialDevice *device)
{
char terminators[] = { '\r', '\n', '\0' };
const char terminators[] = { '\r', '\n', '\0' };
nm_serial_device_send_command_string (device, "AT+COPS?");
nm_serial_device_get_reply (device, 10, terminators, get_network_done, NULL);
@ -368,8 +368,8 @@ real_act_stage1_prepare (NMDevice *device)
if (!nm_serial_device_open (NM_SERIAL_DEVICE (device)))
return NM_ACT_STAGE_RETURN_FAILURE;
nm_serial_device_send_command_string (serial_device, "ATZ");
nm_serial_device_wait_for_reply (serial_device, 3, responses, init_done, NULL);
nm_serial_device_send_command_string (serial_device, "ATZ E0");
nm_serial_device_wait_for_reply (serial_device, 10, responses, init_done, NULL);
return NM_ACT_STAGE_RETURN_POSTPONE;
}

View file

@ -312,7 +312,6 @@ ip4_config_get (DBusGProxy *proxy,
/* priv->ipconfig_timeout = 0; */
config = nm_ip4_config_new ();
nm_ip4_config_set_secondary (config, TRUE);
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_GATEWAY);
if (val)
@ -516,8 +515,6 @@ nm_ppp_manager_start (NMPPPManager *manager,
if (!ppp_cmd)
return FALSE;
/* FIXME: This should come from NMSettingIP4Config */
nm_cmd_line_add_string (ppp_cmd, "defaultroute");
g_ptr_array_add (ppp_cmd->array, NULL);
priv = NM_PPP_MANAGER_GET_PRIVATE (manager);