NetworkManager/src/ppp-manager/nm-ppp-manager.c

612 lines
14 KiB
C
Raw Normal View History

/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include "nm-ppp-manager.h"
#include "nm-setting-ppp.h"
#include "nm-dbus-manager.h"
#include "nm-utils.h"
#include "nm-marshal.h"
static gboolean impl_ppp_manager_need_secrets (NMPPPManager *manager,
GHashTable *connection,
char **service_name,
GError **err);
static gboolean impl_ppp_manager_set_state (NMPPPManager *manager,
guint32 state,
GError **err);
static gboolean impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
GHashTable *config,
GError **err);
#include "nm-ppp-manager-glue.h"
#define NM_PPPD_PLUGIN PLUGINDIR "/nm-pppd-plugin.so"
#define NM_PPP_WAIT_PPPD 10000 /* 10 seconds */
typedef struct {
GPid pid;
NMDBusManager *dbus_manager;
2007-11-28 Tambet Ingo <tambet@gmail.com> Merge the beginnings of the new GSM card support. * src/ppp-manager/nm-ppp-manager.c (nm_ppp_manager_stop): Remove * the ppp watch source before killing pppd - If this happens from g_object_unref() then the ppp manager is already destroyed by the time the watch callback runs. * src/nm-hal-manager.c: Add a device_type_name string to the * device creators, so that we can print a nice human readable string when a device is added. * src/nm-umts-device.c (automatic_registration_get_network): * Query for the activated network, not much is done with the result thought. * src/nm-serial-device.c (nm_serial_device_get_reply): * Implement. (ppp_ip4_config): Change the device state to activated here for now. (real_check_connection): Make sure the connection includes ppp setting. * libnm-glib/nm-client.c (get_device): Handle umts devices. * libnm-glib/Makefile.am: Add the new files to build. * libnm-glib/nm-umts-device.c: * libnm-glib/nm-umts-device.h: Implement. 2007-11-26 Tambet Ingo <tambet@gmail.com> * src/nm-umts-device.c (automatic_registration_get_network): For * now, dial immediately, nm_serial_device_get_reply() isn't implemented correctly yet. * src/nm-serial-device.c (wait_for_reply_info_destroy): Don't * try to remove the timeout source - this function is only called when the timeout source has been removed. (nm_serial_device_wait_for_reply): Allocate the duplicate responses array to be big enough to contain the terminating zero element as well. The timeout argument is meant to be in seconds now. (real_deactivate_quickly): Implement. * src/NetworkManager.conf: Allow root to own "org.freedesktop.NetworkManager.PPP", deny it for everybody else. * libnm-util/nm-setting-umts.c: Network type and band properties * are ints, (not unsigned ints). * libnm-util/nm-setting-serial.c (nm_setting_serial_class_init): * Fix a small issue with parity bounds - capital letters have lower ascii codes than lower case letters. * libnm-util/nm-connection.c (register_default_settings): * Register serial and umts settings. 2007-11-22 Tambet Ingo <tambet@gmail.com> Remove the "index" property from devices as not all device types have this. * include/NetworkManager.h (NM_DBUS_PATH_DEVICE): Remove. * src/nm-hal-manager.c (nm_get_device_index_from_hal): Remove. (wired_device_creator): Get the device interface from hal to create the device. (wireless_device_creator): Ditto. * src/nm-device.c (nm_device_init): Remove the index member. (constructor): Remove the checks for index property, make interface property a require constructor property. Use the HAL udi for DBus path for devices. (nm_device_get_index): Remove. (set_property): Remove index handling. (get_property): Ditto. (nm_device_get_dbus_path): Remove. * src/nm-device-interface.c (nm_device_interface_init): Remove * the index property. * src/nm-device-802-3-ethernet.c * (nm_device_802_3_ethernet_link_activated): Access the device index through it's interface. (nm_device_802_3_ethernet_link_deactivated): Ditto. (nm_device_802_3_ethernet_new): Remove the useless argument test_dev. Remove index argument. Add interface argument. * src/nm-device-802-11-wireless.c * (nm_device_802_11_wireless_new): Remove the useless test_dev argument. Remove index argument. Add interface arugment. * src/NetworkManagerSystem.c * (nm_system_device_set_from_ip4_config): Get the device index through interface. (nm_system_set_mtu): Ditto. * introspection/nm-device.xml: Remove the "Index" property. 2007-11-21 Tambet Ingo <tambet@gmail.com> * src/nm-serial-device.c: * src/nm-serial-device.c: * src/nm-umts-device.c: * src/nm-umts-device.h: Implement. * src/nm-hal-manager.c (nm_get_device_driver_name): * libhal_free_string the string allocated by libhal. (modem_device_creator): Implement. (register_built_in_creators): Register the modem creator. * src/nm-device-802-11-wireless.c * (nm_device_802_11_wireless_new): Remove the unused test_dev argument. * src/nm-device-802-3-ethernet.c (nm_device_802_3_ethernet_new): * Ditto. * src/Makefile.am: Add new files to build. Link in ppp-manager. * libnm-util/nm-setting-umts.c: * libnm-util/nm-setting-umts.h: * libnm-util/nm-setting-serial.c: * libnm-util/nm-setting-serial.h: Implement. * libnm-util/Makefile.am: Add new files to build. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3116 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-11-29 14:38:07 +00:00
guint32 ppp_watch_id;
guint32 ppp_timeout_handler;
} NMPPPManagerPrivate;
#define NM_PPP_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_PPP_MANAGER, NMPPPManagerPrivate))
G_DEFINE_TYPE (NMPPPManager, nm_ppp_manager, G_TYPE_OBJECT)
enum {
STATE_CHANGED,
IP4_CONFIG,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
GQuark
nm_ppp_manager_error_quark (void)
{
static GQuark quark;
if (!quark)
quark = g_quark_from_static_string ("nm_ppp_manager_error");
return quark;
}
static void
nm_ppp_manager_init (NMPPPManager *manager)
{
}
static GObject *
constructor (GType type,
guint n_construct_params,
GObjectConstructParam *construct_params)
{
GObject *object;
NMPPPManagerPrivate *priv;
DBusGConnection *connection;
DBusGProxy *proxy;
guint request_name_result;
GError *err = NULL;
object = G_OBJECT_CLASS (nm_ppp_manager_parent_class)->constructor (type,
n_construct_params,
construct_params);
if (!object)
return NULL;
priv = NM_PPP_MANAGER_GET_PRIVATE (object);
priv->dbus_manager = nm_dbus_manager_get ();
connection = nm_dbus_manager_get_connection (priv->dbus_manager);
proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus");
if (dbus_g_proxy_call (proxy, "RequestName", &err,
G_TYPE_STRING, NM_DBUS_SERVICE_PPP,
G_TYPE_UINT, 0,
G_TYPE_INVALID,
G_TYPE_UINT, &request_name_result,
G_TYPE_INVALID))
dbus_g_connection_register_g_object (connection, NM_DBUS_PATH_PPP, object);
g_object_unref (proxy);
return object;
}
static void
finalize (GObject *object)
{
//NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (object);
nm_ppp_manager_stop (NM_PPP_MANAGER (object));
//g_object_unref (priv->dbus_manager);
G_OBJECT_CLASS (nm_ppp_manager_parent_class)->finalize (object);
}
static void
nm_ppp_manager_class_init (NMPPPManagerClass *manager_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (manager_class);
g_type_class_add_private (manager_class, sizeof (NMPPPManagerPrivate));
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (manager_class),
&dbus_glib_nm_ppp_manager_object_info);
object_class->constructor = constructor;
object_class->finalize = finalize;
/* signals */
signals[STATE_CHANGED] =
g_signal_new ("state-changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMPPPManagerClass, state_changed),
NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1,
G_TYPE_UINT);
signals[IP4_CONFIG] =
g_signal_new ("ip4-config",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (NMPPPManagerClass, ip4_config),
NULL, NULL,
nm_marshal_VOID__STRING_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_OBJECT);
}
NMPPPManager *
nm_ppp_manager_new (void)
{
return (NMPPPManager *) g_object_new (NM_TYPE_PPP_MANAGER, NULL);
}
/*******************************************/
static void
remove_timeout_handler (NMPPPManager *manager)
{
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
if (priv->ppp_timeout_handler) {
g_source_remove (priv->ppp_timeout_handler);
priv->ppp_timeout_handler = 0;
}
}
static gboolean
impl_ppp_manager_need_secrets (NMPPPManager *manager,
GHashTable *connection,
char **service_name,
GError **err)
{
remove_timeout_handler (manager);
return TRUE;
}
static gboolean impl_ppp_manager_set_state (NMPPPManager *manager,
guint32 state,
GError **err)
{
remove_timeout_handler (manager);
g_signal_emit (manager, signals[STATE_CHANGED], 0, state);
return TRUE;
}
static gboolean
impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
GHashTable *config_hash,
GError **err)
{
NMIP4Config *config;
GValue *val;
const char *iface;
int i;
nm_info ("PPP manager(IP Config Get) reply received.");
remove_timeout_handler (manager);
/* FIXME */
/* g_source_remove (priv->ipconfig_timeout); */
/* priv->ipconfig_timeout = 0; */
config = nm_ip4_config_new ();
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_GATEWAY);
if (val) {
nm_ip4_config_set_gateway (config, g_value_get_uint (val));
nm_ip4_config_set_ptp_address (config, g_value_get_uint (val));
}
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_ADDRESS);
if (val)
nm_ip4_config_set_address (config, g_value_get_uint (val));
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_NETMASK);
if (val)
nm_ip4_config_set_netmask (config, g_value_get_uint (val));
else
/* If no netmask, default to Class C address */
nm_ip4_config_set_netmask (config, 0x00FF);
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_DNS);
if (val) {
GArray *dns = (GArray *) g_value_get_boxed (val);
for (i = 0; i < dns->len; i++)
nm_ip4_config_add_nameserver (config, g_array_index (dns, guint, i));
}
/* FIXME: The plugin helpfully sends WINS servers as well
and we're insensitive clods and ignore them. */
val = (GValue *) g_hash_table_lookup (config_hash, NM_PPP_IP4_CONFIG_INTERFACE);
if (val)
iface = g_value_get_string (val);
else {
nm_warning ("No interface");
goto out;
}
g_signal_emit (manager, signals[IP4_CONFIG], 0, iface, config);
out:
g_object_unref (config);
return TRUE;
}
/*******************************************/
typedef struct {
GPtrArray *array;
GStringChunk *chunk;
} NMCmdLine;
static NMCmdLine *
nm_cmd_line_new (void)
{
NMCmdLine *cmd;
cmd = g_slice_new (NMCmdLine);
cmd->array = g_ptr_array_new ();
cmd->chunk = g_string_chunk_new (1024);
return cmd;
}
static void
nm_cmd_line_destroy (NMCmdLine *cmd)
{
g_ptr_array_free (cmd->array, TRUE);
g_string_chunk_free (cmd->chunk);
g_slice_free (NMCmdLine, cmd);
}
static char *
nm_cmd_line_to_str (NMCmdLine *cmd)
{
char *str;
g_ptr_array_add (cmd->array, NULL);
str = g_strjoinv (" ", (gchar **) cmd->array->pdata);
g_ptr_array_remove_index (cmd->array, cmd->array->len - 1);
return str;
}
static void
nm_cmd_line_add_string (NMCmdLine *cmd, const char *str)
{
g_ptr_array_add (cmd->array, g_string_chunk_insert (cmd->chunk, str));
}
static void
nm_cmd_line_add_int (NMCmdLine *cmd, int i)
{
char *str;
str = g_strdup_printf ("%d", i);
nm_cmd_line_add_string (cmd, str);
g_free (str);
}
/*******************************************/
static inline const char *
nm_find_pppd (void)
{
static const char *pppd_binary_paths[] =
{
"/usr/local/sbin/pppd",
"/usr/sbin/pppd",
"/sbin/pppd",
NULL
};
const char **pppd_binary = pppd_binary_paths;
while (*pppd_binary != NULL) {
if (g_file_test (*pppd_binary, G_FILE_TEST_EXISTS))
break;
pppd_binary++;
}
return *pppd_binary;
}
static void
ppp_exit_code (guint pppd_exit_status)
{
const char *msg;
switch (pppd_exit_status) {
case 1:
msg = "Fatal pppd error";
break;
case 2:
msg = "pppd options error";
break;
case 3:
msg = "No root priv error";
break;
case 4:
msg = "No ppp module error";
break;
case 5:
msg = "pppd received a signal";
break;
case 6:
msg = "Serial port lock failed";
break;
case 7:
msg = "Serial port open failed";
break;
case 8:
msg = "Connect script failed";
break;
case 9:
msg = "Pty program error";
break;
case 10:
msg = "PPP negotiation failed";
break;
case 11:
msg = "Peer didn't authenticatie itself";
break;
case 12:
msg = "Link idle: Idle Seconds reached.";
break;
case 13:
msg = "Connect time limit reached.";
break;
case 14:
msg = "Callback negotiated, call should come back.";
break;
case 15:
msg = "Lack of LCP echo responses";
break;
case 16:
msg = "A modem hung up the phone";
break;
case 17:
msg = "Loopback detected";
break;
case 18:
msg = "The init script failed";
break;
case 19:
msg = "Authentication error.\n"
"We failed to authenticate ourselves to the peer.\n"
"Maybe bad account or password?";
break;
default:
msg = "Unknown error";
}
g_warning ("pppd exited with error: %s", msg);
}
static void
ppp_watch_cb (GPid pid, gint status, gpointer user_data)
{
NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (user_data);
guint err;
if (WIFEXITED (status)) {
err = WEXITSTATUS (status);
if (err != 0)
ppp_exit_code (err);
} else if (WIFSTOPPED (status))
g_warning ("ppp stopped unexpectedly with signal %d", WSTOPSIG (status));
else if (WIFSIGNALED (status))
g_warning ("ppp died with signal %d", WTERMSIG (status));
else
g_warning ("ppp died from an unknown cause");
/* Reap child if needed. */
waitpid (pid, NULL, WNOHANG);
priv->pid = 0;
}
static gboolean
pppd_timed_out (gpointer data)
{
NMPPPManager *manager = NM_PPP_MANAGER (data);
nm_warning ("Looks like pppd didn't initialize our dbus module");
nm_ppp_manager_stop (manager);
return FALSE;
}
static NMCmdLine *
create_pppd_cmd_line (NMSettingPPP *setting, const char *device, GError **err)
{
const char *ppp_binary;
NMCmdLine *cmd;
ppp_binary = nm_find_pppd ();
if (!ppp_binary) {
g_set_error (err, NM_PPP_MANAGER_ERROR, NM_PPP_MANAGER_ERROR,
"Could not find ppp binary.");
return NULL;
}
/* Create pppd command line */
cmd = nm_cmd_line_new ();
nm_cmd_line_add_string (cmd, ppp_binary);
nm_cmd_line_add_string (cmd, "nodetach");
nm_cmd_line_add_string (cmd, "lock");
nm_cmd_line_add_string (cmd, device);
if (setting->baud)
nm_cmd_line_add_int (cmd, setting->baud);
if (setting->noauth)
nm_cmd_line_add_string (cmd, "noauth");
if (setting->noauth)
nm_cmd_line_add_string (cmd, "refuse-eap");
if (setting->refuse_eap)
nm_cmd_line_add_string (cmd, "refuse-chap");
if (setting->refuse_chap)
nm_cmd_line_add_string (cmd, "refuse-mschap");
if (setting->refuse_mschap)
nm_cmd_line_add_string (cmd, "nobsdcomp");
if (setting->nobsdcomp)
nm_cmd_line_add_string (cmd, "nodeflate");
if (setting->nodeflate)
nm_cmd_line_add_string (cmd, "require-mppe");
if (setting->require_mppe)
nm_cmd_line_add_string (cmd, "require-mppe-128");
if (setting->require_mppe_128)
nm_cmd_line_add_string (cmd, "mppe-stateful");
if (setting->mppe_stateful)
nm_cmd_line_add_string (cmd, "require-mppc");
if (setting->crtscts)
nm_cmd_line_add_string (cmd, "crtscts");
if (setting->usepeerdns)
nm_cmd_line_add_string (cmd, "usepeerdns");
if (setting->mru) {
nm_cmd_line_add_string (cmd, "mru");
nm_cmd_line_add_int (cmd, setting->mru);
}
if (setting->mtu) {
nm_cmd_line_add_string (cmd, "mtu");
nm_cmd_line_add_int (cmd, setting->mtu);
}
if (setting->lcp_echo_failure) {
nm_cmd_line_add_string (cmd, "lcp-echo-failure");
nm_cmd_line_add_int (cmd, setting->lcp_echo_failure);
}
if (setting->lcp_echo_interval) {
nm_cmd_line_add_string (cmd, "lcp-echo-interval");
nm_cmd_line_add_int (cmd, setting->lcp_echo_interval);
}
nm_cmd_line_add_string (cmd, "plugin");
nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN);
return cmd;
}
static void
pppd_child_setup (gpointer user_data G_GNUC_UNUSED)
{
/* We are in the child process at this point */
pid_t pid = getpid ();
setpgid (pid, pid);
}
gboolean
nm_ppp_manager_start (NMPPPManager *manager,
const char *device,
NMConnection *connection,
GError **err)
{
NMPPPManagerPrivate *priv;
NMSettingPPP *ppp_setting;
NMCmdLine *ppp_cmd;
char *cmd_str;
GSource *ppp_watch;
g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE);
g_return_val_if_fail (device != NULL, FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
ppp_setting = NM_SETTING_PPP (nm_connection_get_setting (connection, NM_TYPE_SETTING_PPP));
ppp_cmd = create_pppd_cmd_line (ppp_setting, device, err);
if (!ppp_cmd)
return FALSE;
g_ptr_array_add (ppp_cmd->array, NULL);
priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
nm_info ("Starting pppd connection");
cmd_str = nm_cmd_line_to_str (ppp_cmd);
nm_debug ("Command line: %s", cmd_str);
g_free (cmd_str);
priv->pid = 0;
if (!g_spawn_async (NULL, (char **) ppp_cmd->array->pdata, NULL,
G_SPAWN_DO_NOT_REAP_CHILD,
pppd_child_setup,
NULL, &priv->pid, err)) {
goto out;
}
nm_debug ("ppp started with pid %d", priv->pid);
ppp_watch = g_child_watch_source_new (priv->pid);
g_source_set_callback (ppp_watch, (GSourceFunc) ppp_watch_cb, manager, NULL);
g_source_attach (ppp_watch, NULL);
2007-11-28 Tambet Ingo <tambet@gmail.com> Merge the beginnings of the new GSM card support. * src/ppp-manager/nm-ppp-manager.c (nm_ppp_manager_stop): Remove * the ppp watch source before killing pppd - If this happens from g_object_unref() then the ppp manager is already destroyed by the time the watch callback runs. * src/nm-hal-manager.c: Add a device_type_name string to the * device creators, so that we can print a nice human readable string when a device is added. * src/nm-umts-device.c (automatic_registration_get_network): * Query for the activated network, not much is done with the result thought. * src/nm-serial-device.c (nm_serial_device_get_reply): * Implement. (ppp_ip4_config): Change the device state to activated here for now. (real_check_connection): Make sure the connection includes ppp setting. * libnm-glib/nm-client.c (get_device): Handle umts devices. * libnm-glib/Makefile.am: Add the new files to build. * libnm-glib/nm-umts-device.c: * libnm-glib/nm-umts-device.h: Implement. 2007-11-26 Tambet Ingo <tambet@gmail.com> * src/nm-umts-device.c (automatic_registration_get_network): For * now, dial immediately, nm_serial_device_get_reply() isn't implemented correctly yet. * src/nm-serial-device.c (wait_for_reply_info_destroy): Don't * try to remove the timeout source - this function is only called when the timeout source has been removed. (nm_serial_device_wait_for_reply): Allocate the duplicate responses array to be big enough to contain the terminating zero element as well. The timeout argument is meant to be in seconds now. (real_deactivate_quickly): Implement. * src/NetworkManager.conf: Allow root to own "org.freedesktop.NetworkManager.PPP", deny it for everybody else. * libnm-util/nm-setting-umts.c: Network type and band properties * are ints, (not unsigned ints). * libnm-util/nm-setting-serial.c (nm_setting_serial_class_init): * Fix a small issue with parity bounds - capital letters have lower ascii codes than lower case letters. * libnm-util/nm-connection.c (register_default_settings): * Register serial and umts settings. 2007-11-22 Tambet Ingo <tambet@gmail.com> Remove the "index" property from devices as not all device types have this. * include/NetworkManager.h (NM_DBUS_PATH_DEVICE): Remove. * src/nm-hal-manager.c (nm_get_device_index_from_hal): Remove. (wired_device_creator): Get the device interface from hal to create the device. (wireless_device_creator): Ditto. * src/nm-device.c (nm_device_init): Remove the index member. (constructor): Remove the checks for index property, make interface property a require constructor property. Use the HAL udi for DBus path for devices. (nm_device_get_index): Remove. (set_property): Remove index handling. (get_property): Ditto. (nm_device_get_dbus_path): Remove. * src/nm-device-interface.c (nm_device_interface_init): Remove * the index property. * src/nm-device-802-3-ethernet.c * (nm_device_802_3_ethernet_link_activated): Access the device index through it's interface. (nm_device_802_3_ethernet_link_deactivated): Ditto. (nm_device_802_3_ethernet_new): Remove the useless argument test_dev. Remove index argument. Add interface argument. * src/nm-device-802-11-wireless.c * (nm_device_802_11_wireless_new): Remove the useless test_dev argument. Remove index argument. Add interface arugment. * src/NetworkManagerSystem.c * (nm_system_device_set_from_ip4_config): Get the device index through interface. (nm_system_set_mtu): Ditto. * introspection/nm-device.xml: Remove the "Index" property. 2007-11-21 Tambet Ingo <tambet@gmail.com> * src/nm-serial-device.c: * src/nm-serial-device.c: * src/nm-umts-device.c: * src/nm-umts-device.h: Implement. * src/nm-hal-manager.c (nm_get_device_driver_name): * libhal_free_string the string allocated by libhal. (modem_device_creator): Implement. (register_built_in_creators): Register the modem creator. * src/nm-device-802-11-wireless.c * (nm_device_802_11_wireless_new): Remove the unused test_dev argument. * src/nm-device-802-3-ethernet.c (nm_device_802_3_ethernet_new): * Ditto. * src/Makefile.am: Add new files to build. Link in ppp-manager. * libnm-util/nm-setting-umts.c: * libnm-util/nm-setting-umts.h: * libnm-util/nm-setting-serial.c: * libnm-util/nm-setting-serial.h: Implement. * libnm-util/Makefile.am: Add new files to build. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3116 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-11-29 14:38:07 +00:00
priv->ppp_watch_id = g_source_get_id (ppp_watch);
g_source_unref (ppp_watch);
priv->ppp_timeout_handler = g_timeout_add (NM_PPP_WAIT_PPPD, pppd_timed_out, manager);
out:
if (ppp_cmd)
nm_cmd_line_destroy (ppp_cmd);
return priv->pid > 0;
}
void
nm_ppp_manager_stop (NMPPPManager *manager)
{
NMPPPManagerPrivate *priv;
g_return_if_fail (NM_IS_PPP_MANAGER (manager));
priv = NM_PPP_MANAGER_GET_PRIVATE (manager);
if (priv->ppp_timeout_handler) {
g_source_remove (priv->ppp_timeout_handler);
priv->ppp_timeout_handler = 0;
}
2007-11-28 Tambet Ingo <tambet@gmail.com> Merge the beginnings of the new GSM card support. * src/ppp-manager/nm-ppp-manager.c (nm_ppp_manager_stop): Remove * the ppp watch source before killing pppd - If this happens from g_object_unref() then the ppp manager is already destroyed by the time the watch callback runs. * src/nm-hal-manager.c: Add a device_type_name string to the * device creators, so that we can print a nice human readable string when a device is added. * src/nm-umts-device.c (automatic_registration_get_network): * Query for the activated network, not much is done with the result thought. * src/nm-serial-device.c (nm_serial_device_get_reply): * Implement. (ppp_ip4_config): Change the device state to activated here for now. (real_check_connection): Make sure the connection includes ppp setting. * libnm-glib/nm-client.c (get_device): Handle umts devices. * libnm-glib/Makefile.am: Add the new files to build. * libnm-glib/nm-umts-device.c: * libnm-glib/nm-umts-device.h: Implement. 2007-11-26 Tambet Ingo <tambet@gmail.com> * src/nm-umts-device.c (automatic_registration_get_network): For * now, dial immediately, nm_serial_device_get_reply() isn't implemented correctly yet. * src/nm-serial-device.c (wait_for_reply_info_destroy): Don't * try to remove the timeout source - this function is only called when the timeout source has been removed. (nm_serial_device_wait_for_reply): Allocate the duplicate responses array to be big enough to contain the terminating zero element as well. The timeout argument is meant to be in seconds now. (real_deactivate_quickly): Implement. * src/NetworkManager.conf: Allow root to own "org.freedesktop.NetworkManager.PPP", deny it for everybody else. * libnm-util/nm-setting-umts.c: Network type and band properties * are ints, (not unsigned ints). * libnm-util/nm-setting-serial.c (nm_setting_serial_class_init): * Fix a small issue with parity bounds - capital letters have lower ascii codes than lower case letters. * libnm-util/nm-connection.c (register_default_settings): * Register serial and umts settings. 2007-11-22 Tambet Ingo <tambet@gmail.com> Remove the "index" property from devices as not all device types have this. * include/NetworkManager.h (NM_DBUS_PATH_DEVICE): Remove. * src/nm-hal-manager.c (nm_get_device_index_from_hal): Remove. (wired_device_creator): Get the device interface from hal to create the device. (wireless_device_creator): Ditto. * src/nm-device.c (nm_device_init): Remove the index member. (constructor): Remove the checks for index property, make interface property a require constructor property. Use the HAL udi for DBus path for devices. (nm_device_get_index): Remove. (set_property): Remove index handling. (get_property): Ditto. (nm_device_get_dbus_path): Remove. * src/nm-device-interface.c (nm_device_interface_init): Remove * the index property. * src/nm-device-802-3-ethernet.c * (nm_device_802_3_ethernet_link_activated): Access the device index through it's interface. (nm_device_802_3_ethernet_link_deactivated): Ditto. (nm_device_802_3_ethernet_new): Remove the useless argument test_dev. Remove index argument. Add interface argument. * src/nm-device-802-11-wireless.c * (nm_device_802_11_wireless_new): Remove the useless test_dev argument. Remove index argument. Add interface arugment. * src/NetworkManagerSystem.c * (nm_system_device_set_from_ip4_config): Get the device index through interface. (nm_system_set_mtu): Ditto. * introspection/nm-device.xml: Remove the "Index" property. 2007-11-21 Tambet Ingo <tambet@gmail.com> * src/nm-serial-device.c: * src/nm-serial-device.c: * src/nm-umts-device.c: * src/nm-umts-device.h: Implement. * src/nm-hal-manager.c (nm_get_device_driver_name): * libhal_free_string the string allocated by libhal. (modem_device_creator): Implement. (register_built_in_creators): Register the modem creator. * src/nm-device-802-11-wireless.c * (nm_device_802_11_wireless_new): Remove the unused test_dev argument. * src/nm-device-802-3-ethernet.c (nm_device_802_3_ethernet_new): * Ditto. * src/Makefile.am: Add new files to build. Link in ppp-manager. * libnm-util/nm-setting-umts.c: * libnm-util/nm-setting-umts.h: * libnm-util/nm-setting-serial.c: * libnm-util/nm-setting-serial.h: Implement. * libnm-util/Makefile.am: Add new files to build. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3116 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-11-29 14:38:07 +00:00
if (priv->ppp_watch_id) {
g_source_remove (priv->ppp_watch_id);
priv->ppp_watch_id = 0;
}
if (priv->pid) {
kill (priv->pid, SIGTERM);
priv->pid = 0;
}
}