On Fri, 2011-05-06 at 14:23 +0300, Pantelis Koukousoulas wrote: > This patch adds the settings code (NMSettingAdsl) and the initial > "scaffolding" i.e., a tiny stub version of NMDeviceAdsl and the > udev handler code to get the device detected. > > With this patch you should be able to see an atm device being detected > by networkmanager in the logs, although of course it doesn't > do anything useful yet. > > Extract from the logs: > > [1304668252.341354] [nm-udev-manager.c:562] adsl_add(): adsl_add: ATM Device > detected from udev. Adding .. > (ueagle-atm0): failed to look up interface index > (ueagle-atm0): new ADSL device (driver: 'ueagle-atm' ifindex: -1) > (ueagle-atm0): exported as /org/freedesktop/NetworkManager/Devices/2 > (ueagle-atm0): now managed > (ueagle-atm0): device state change: unmanaged -> unavailable (reason > 'managed') [10 20 2] > (ueagle-atm0): deactivating device (reason: 2). > [1304668252.345102] [nm-system.c:1349] flush_routes(): (ueagle-atm0) failed > to lookup interface index > [1304668252.347821] [nm-device.c:3912] nm_device_state_changed(): > (ueagle-atm0): device is available, > > Note: > nm-device.c:nm_device_get_priority() > essentially returns the index of the Device Type in the NMDeviceType enum. > So, since ADSL typically should have the best priority, it was placed above > the ethernet device.
One more thing I forgot about: make sure to add the setting to register_default_settings() in nm-connection.c too, and pass TRUE as the last parameter since this setting is a "base type" which describes hardware that can be used to connect to a network, as opposed to IPv4 for example which doesn't. And I see what you were trying to do with the nm_device_get_priority(), but we'll need to hack that function up since we can't change the device numbers at all since they are exposed API. Dan > Signed-off-by: Pantelis Koukousoulas <[email protected]> > --- > include/NetworkManager.h | 18 +- > introspection/Makefile.am | 1 + > introspection/nm-device-adsl.xml | 15 ++ > libnm-util/Makefile.am | 2 + > libnm-util/libnm-util.ver | 12 +- > libnm-util/nm-setting-adsl.c | 476 > ++++++++++++++++++++++++++++++++++++++ > libnm-util/nm-setting-adsl.h | 97 ++++++++ > src/Makefile.am | 6 + > src/nm-device-adsl.c | 83 +++++++ > src/nm-device-adsl.h | 57 +++++ > src/nm-udev-manager.c | 48 ++++- > 11 files changed, 804 insertions(+), 11 deletions(-) > create mode 100644 introspection/nm-device-adsl.xml > create mode 100644 libnm-util/nm-setting-adsl.c > create mode 100644 libnm-util/nm-setting-adsl.h > create mode 100644 src/nm-device-adsl.c > create mode 100644 src/nm-device-adsl.h > > diff --git a/include/NetworkManager.h b/include/NetworkManager.h > index 17c3a11..b007e1c 100644 > --- a/include/NetworkManager.h > +++ b/include/NetworkManager.h > @@ -92,6 +92,7 @@ typedef enum { > /** > * NMDeviceType: > * @NM_DEVICE_TYPE_UNKNOWN: unknown device > + * @NM_DEVICE_TYPE_ADSL: ADSL WAN device > * @NM_DEVICE_TYPE_ETHERNET: a wired ethernet device > * @NM_DEVICE_TYPE_WIFI: an 802.11 WiFi device > * @NM_DEVICE_TYPE_UNUSED1: not used > @@ -106,14 +107,15 @@ typedef enum { > */ > typedef enum { > NM_DEVICE_TYPE_UNKNOWN = 0, > - NM_DEVICE_TYPE_ETHERNET = 1, > - NM_DEVICE_TYPE_WIFI = 2, > - NM_DEVICE_TYPE_UNUSED1 = 3, > - NM_DEVICE_TYPE_UNUSED2 = 4, > - NM_DEVICE_TYPE_BT = 5, /* Bluetooth */ > - NM_DEVICE_TYPE_OLPC_MESH = 6, > - NM_DEVICE_TYPE_WIMAX = 7, > - NM_DEVICE_TYPE_MODEM = 8, > + NM_DEVICE_TYPE_ADSL = 1, > + NM_DEVICE_TYPE_ETHERNET = 2, > + NM_DEVICE_TYPE_WIFI = 3, > + NM_DEVICE_TYPE_UNUSED1 = 4, > + NM_DEVICE_TYPE_UNUSED2 = 5, > + NM_DEVICE_TYPE_BT = 6, /* Bluetooth */ > + NM_DEVICE_TYPE_OLPC_MESH = 7, > + NM_DEVICE_TYPE_WIMAX = 8, > + NM_DEVICE_TYPE_MODEM = 9, > } NMDeviceType; > > /* General device capability flags */ > diff --git a/introspection/Makefile.am b/introspection/Makefile.am > index 320245e..4950e7d 100644 > --- a/introspection/Makefile.am > +++ b/introspection/Makefile.am > @@ -8,6 +8,7 @@ EXTRA_DIST = \ > nm-device-wifi.xml \ > nm-device-olpc-mesh.xml \ > nm-device-ethernet.xml \ > + nm-device-adsl.xml \ > nm-device-modem.xml \ > nm-device-wimax.xml \ > nm-device.xml \ > diff --git a/introspection/nm-device-adsl.xml > b/introspection/nm-device-adsl.xml > new file mode 100644 > index 0000000..9610f98 > --- /dev/null > +++ b/introspection/nm-device-adsl.xml > @@ -0,0 +1,15 @@ > +<?xml version="1.0" encoding="UTF-8" ?> > + > +<node name="/" > xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> > + <interface name="org.freedesktop.NetworkManager.Device.Adsl"> > + > + <signal name="PropertiesChanged"> > + <arg name="properties" type="a{sv}" tp:type="String_Variant_Map"> > + <tp:docstring> > + A dictionary mapping property names to variant boxed values > + </tp:docstring> > + </arg> > + </signal> > + > + </interface> > +</node> > diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am > index 0a29e9c..9f452a4 100644 > --- a/libnm-util/Makefile.am > +++ b/libnm-util/Makefile.am > @@ -14,6 +14,7 @@ libnm_util_include_HEADERS = \ > nm-connection.h \ > nm-setting.h \ > nm-setting-8021x.h \ > + nm-setting-adsl.h \ > nm-setting-bluetooth.h \ > nm-setting-connection.h \ > nm-setting-ip4-config.h \ > @@ -43,6 +44,7 @@ libnm_util_la_csources = \ > nm-param-spec-specialized.c \ > nm-setting.c \ > nm-setting-8021x.c \ > + nm-setting-adsl.c \ > nm-setting-bluetooth.c \ > nm-setting-connection.c \ > nm-setting-ip4-config.c \ > diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver > index 4ff0838..d3b9f47 100644 > --- a/libnm-util/libnm-util.ver > +++ b/libnm-util/libnm-util.ver > @@ -27,6 +27,7 @@ global: > nm_connection_get_setting_vpn; > nm_connection_get_setting_wimax; > nm_connection_get_setting_wired; > + nm_connection_get_setting_adsl; > nm_connection_get_setting_wireless; > nm_connection_get_setting_wireless_security; > nm_connection_get_type; > @@ -130,7 +131,6 @@ global: > nm_setting_802_1x_get_phase2_private_key_path; > nm_setting_802_1x_get_phase2_private_key_scheme; > nm_setting_802_1x_get_pin; > - nm_setting_802_1x_get_pin_flags; > nm_setting_802_1x_get_private_key_blob; > nm_setting_802_1x_get_private_key_format; > nm_setting_802_1x_get_private_key_password; > @@ -147,6 +147,16 @@ global: > nm_setting_802_1x_set_phase2_client_cert; > nm_setting_802_1x_set_phase2_private_key; > nm_setting_802_1x_set_private_key; > + nm_setting_adsl_error_get_type; > + nm_setting_adsl_error_quark; > + nm_setting_adsl_get_username; > + nm_setting_adsl_get_password; > + nm_setting_adsl_get_protocol; > + nm_setting_adsl_get_encapsulation; > + nm_setting_adsl_get_vpi; > + nm_setting_adsl_get_vci; > + nm_setting_adsl_get_type; > + nm_setting_adsl_new; > nm_setting_bluetooth_error_get_type; > nm_setting_bluetooth_error_quark; > nm_setting_bluetooth_get_bdaddr; > diff --git a/libnm-util/nm-setting-adsl.c b/libnm-util/nm-setting-adsl.c > new file mode 100644 > index 0000000..f0db252 > --- /dev/null > +++ b/libnm-util/nm-setting-adsl.c > @@ -0,0 +1,476 @@ > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ > + > +/* > + * Dan Williams <[email protected]> > + * Hicham HAOUARI <[email protected]> > + * Pantelis Koukousoulas <[email protected]> > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the > + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > + * Boston, MA 02110-1301 USA. > + * > + * (C) Copyright 2007 - 2008 Red Hat, Inc. > + */ > + > +#include "nm-setting-adsl.h" > +#include "nm-setting-ppp.h" > +#include "nm-setting-private.h" > +#include "nm-utils.h" > +#include <string.h> > + > +/** > + * SECTION:nm-setting-adsl > + * @short_description: Describes ADSL-based properties > + * @include: nm-setting-adsl.h > + * > + * The #NMSettingAdsl object is a #NMSetting subclass that describes > + * properties of ADSL connections. > + */ > + > +/** > + * nm_setting_adsl_error_quark: > + * > + * Registers an error quark for #NMSettingAdsl if necessary. > + * > + * Returns: the error quark used for #NMSettingAdsl errors. > + **/ > +GQuark > +nm_setting_adsl_error_quark (void) > +{ > + static GQuark quark; > + > + if (G_UNLIKELY (!quark)) > + quark = g_quark_from_static_string > ("nm-setting-adsl-error-quark"); > + return quark; > +} > + > +/* This should really be standard. */ > +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } > + > +GType > +nm_setting_adsl_error_get_type (void) > +{ > + static GType etype = 0; > + > + if (etype == 0) { > + static const GEnumValue values[] = { > + /* Unknown error. */ > + ENUM_ENTRY (NM_SETTING_ADSL_ERROR_UNKNOWN, > "UnknownError"), > + /* The specified property was invalid. */ > + ENUM_ENTRY (NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, > "InvalidProperty"), > + /* The specified property was missing and is required. > */ > + ENUM_ENTRY (NM_SETTING_ADSL_ERROR_MISSING_PROPERTY, > "MissingProperty"), > + { 0, 0, 0 } > + }; > + etype = g_enum_register_static ("NMSettingAdslError", values); > + } > + return etype; > +} > + > +G_DEFINE_TYPE (NMSettingAdsl, nm_setting_adsl, NM_TYPE_SETTING) > + > +#define NM_SETTING_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), > NM_TYPE_SETTING_ADSL, NMSettingAdslPrivate)) > + > +typedef struct { > + char *username; > + char *password; > + NMSettingSecretFlags password_flags; > + char *protocol; > + char *encapsulation; > + char *vpi; > + char *vci; > +} NMSettingAdslPrivate; > + > +enum { > + PROP_0, > + PROP_USERNAME, > + PROP_PASSWORD, > + PROP_PASSWORD_FLAGS, > + PROP_PROTOCOL, > + PROP_ENCAPSULATION, > + PROP_VPI, > + PROP_VCI, > + > + LAST_PROP > +}; > + > +/** > + * nm_setting_adsl_new: > + * > + * Creates a new #NMSettingAdsl object with default values. > + * > + * Returns: the new empty #NMSettingAdsl object > + **/ > +NMSetting * > +nm_setting_adsl_new (void) > +{ > + return (NMSetting *) g_object_new (NM_TYPE_SETTING_ADSL, NULL); > +} > + > +/** > + * nm_setting_adsl_get_username: > + * @setting: the #NMSettingAdsl > + * > + * Returns: the #NMSettingAdsl:username property of the setting > + **/ > +const char * > +nm_setting_adsl_get_username (NMSettingAdsl *setting) > +{ > + g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL); > + > + return NM_SETTING_ADSL_GET_PRIVATE (setting)->username; > +} > + > +/** > + * nm_setting_adsl_get_password: > + * @setting: the #NMSettingAdsl > + * > + * Returns: the #NMSettingAdsl:password property of the setting > + **/ > +const char * > +nm_setting_adsl_get_password (NMSettingAdsl *setting) > +{ > + g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL); > + > + return NM_SETTING_ADSL_GET_PRIVATE (setting)->password; > +} > + > +/** > + * nm_setting_adsl_get_password_flags: > + * @setting: the #NMSettingAdsl > + * > + * Returns: the #NMSettingSecretFlags pertaining to the > #NMSettingAdsl:password > + **/ > +NMSettingSecretFlags > +nm_setting_adsl_get_password_flags (NMSettingAdsl *setting) > +{ > + g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), > NM_SETTING_SECRET_FLAG_NONE); > + > + return NM_SETTING_ADSL_GET_PRIVATE (setting)->password_flags; > +} > + > +/** > + * nm_setting_adsl_get_protocol: > + * @setting: the #NMSettingAdsl > + * > + * Returns: the #NMSettingAdsl:protocol property of the setting > + **/ > +const char * > +nm_setting_adsl_get_protocol (NMSettingAdsl *setting) > +{ > + g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL); > + > + return NM_SETTING_ADSL_GET_PRIVATE (setting)->protocol; > +} > + > +/** > + * nm_setting_adsl_get_encapsulation: > + * @setting: the #NMSettingAdsl > + * > + * Returns: the #NMSettingAdsl:encapsulation property of the setting > + **/ > +const char * > +nm_setting_adsl_get_encapsulation (NMSettingAdsl *setting) > +{ > + g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL); > + > + return NM_SETTING_ADSL_GET_PRIVATE (setting)->encapsulation; > +} > + > +/** > + * nm_setting_adsl_get_vpi: > + * @setting: the #NMSettingAdsl > + * > + * Returns: the #NMSettingAdsl:vpi property of the setting > + **/ > +const char * > +nm_setting_adsl_get_vpi (NMSettingAdsl *setting) > +{ > + g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL); > + > + return NM_SETTING_ADSL_GET_PRIVATE (setting)->vpi; > +} > + > +/** > + * nm_setting_adsl_get_vci: > + * @setting: the #NMSettingAdsl > + * > + * Returns: the #NMSettingAdsl:vci property of the setting > + **/ > +const char * > +nm_setting_adsl_get_vci (NMSettingAdsl *setting) > +{ > + g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), NULL); > + > + return NM_SETTING_ADSL_GET_PRIVATE (setting)->vci; > +} > + > +static gboolean > +verify (NMSetting *setting, GSList *all_settings, GError **error) > +{ > + NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting); > + > + if (!priv->username) { > + g_set_error (error, > + NM_SETTING_ADSL_ERROR, > + NM_SETTING_ADSL_ERROR_MISSING_PROPERTY, > + NM_SETTING_ADSL_USERNAME); > + return FALSE; > + } else if (!strlen (priv->username)) { > + g_set_error (error, > + NM_SETTING_ADSL_ERROR, > + NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, > + NM_SETTING_ADSL_USERNAME); > + return FALSE; > + } > + > + /* FIXME: Only PPPoA supported for now */ > + if (g_ascii_strcasecmp(priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA)) > { > + g_set_error (error, > + NM_SETTING_ADSL_ERROR, > + NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, > + NM_SETTING_ADSL_PROTOCOL); > + return FALSE; > + } > + > + if (!g_ascii_strcasecmp(priv->encapsulation, > NM_SETTING_ADSL_ENCAPSULATION_VCMUX) && > + !g_ascii_strcasecmp(priv->encapsulation, > NM_SETTING_ADSL_ENCAPSULATION_LLC) ) { > + g_set_error (error, > + NM_SETTING_ADSL_ERROR, > + NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, > + NM_SETTING_ADSL_ENCAPSULATION); > + return FALSE; > + } > + > + return TRUE; > +} > + > +static GPtrArray * > +need_secrets (NMSetting *setting) > +{ > + NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting); > + GPtrArray *secrets = NULL; > + > + if (priv->password) > + return NULL; > + > + if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) { > + secrets = g_ptr_array_sized_new (1); > + g_ptr_array_add (secrets, NM_SETTING_ADSL_PASSWORD); > + } > + > + return secrets; > +} > + > +static void > +nm_setting_adsl_init (NMSettingAdsl *setting) > +{ > + g_object_set (setting, NM_SETTING_NAME, NM_SETTING_ADSL_SETTING_NAME, > NULL); > +} > + > +static void > +finalize (GObject *object) > +{ > + NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object); > + > + g_free (priv->username); > + g_free (priv->password); > + g_free (priv->protocol); > + g_free (priv->encapsulation); > + > + G_OBJECT_CLASS (nm_setting_adsl_parent_class)->finalize (object); > +} > + > +static void > +set_property (GObject *object, guint prop_id, > + const GValue *value, GParamSpec *pspec) > +{ > + NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (object); > + > + switch (prop_id) { > + case PROP_USERNAME: > + g_free (priv->username); > + priv->username = g_value_dup_string (value); > + break; > + case PROP_PASSWORD: > + g_free (priv->password); > + priv->password = g_value_dup_string (value); > + break; > + case PROP_PASSWORD_FLAGS: > + priv->password_flags = g_value_get_uint (value); > + break; > + case PROP_PROTOCOL: > + g_free (priv->protocol); > + priv->protocol = g_value_dup_string (value); > + break; > + case PROP_ENCAPSULATION: > + g_free (priv->encapsulation); > + priv->encapsulation = g_value_dup_string (value); > + break; > + case PROP_VPI: > + > + priv->vpi = g_value_dup_string (value); > + break; > + case PROP_VCI: > + priv->vci = g_value_dup_string (value); > + break; > + default: > + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > + break; > + } > +} > + > +static void > +get_property (GObject *object, guint prop_id, > + GValue *value, GParamSpec *pspec) > +{ > + NMSettingAdsl *setting = NM_SETTING_ADSL (object); > + > + switch (prop_id) { > + case PROP_USERNAME: > + g_value_set_string (value, nm_setting_adsl_get_username > (setting)); > + break; > + case PROP_PASSWORD: > + g_value_set_string (value, nm_setting_adsl_get_password > (setting)); > + break; > + case PROP_PASSWORD_FLAGS: > + g_value_set_uint (value, nm_setting_adsl_get_password_flags > (setting)); > + break; > + case PROP_PROTOCOL: > + g_value_set_string (value, nm_setting_adsl_get_protocol > (setting)); > + break; > + case PROP_ENCAPSULATION: > + g_value_set_string (value, nm_setting_adsl_get_encapsulation > (setting)); > + break; > + case PROP_VPI: > + g_value_set_string (value, nm_setting_adsl_get_vpi (setting)); > + break; > + case PROP_VCI: > + g_value_set_string (value, nm_setting_adsl_get_vci (setting)); > + break; > + default: > + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); > + break; > + } > +} > + > +static void > +nm_setting_adsl_class_init (NMSettingAdslClass *setting_class) > +{ > + GObjectClass *object_class = G_OBJECT_CLASS (setting_class); > + NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class); > + > + g_type_class_add_private (setting_class, sizeof (NMSettingAdslPrivate)); > + > + /* virtual methods */ > + object_class->set_property = set_property; > + object_class->get_property = get_property; > + object_class->finalize = finalize; > + parent_class->verify = verify; > + parent_class->need_secrets = need_secrets; > + > + /* Properties */ > + > + /** > + * NMSettingAdsl:username: > + * > + * Username used to authenticate with the ADSL service. > + **/ > + g_object_class_install_property > + (object_class, PROP_USERNAME, > + g_param_spec_string (NM_SETTING_ADSL_USERNAME, > + "Username", > + "Username used to > authenticate with the PPPoA service.", > + NULL, > + G_PARAM_READWRITE | > NM_SETTING_PARAM_SERIALIZE)); > + > + /** > + * NMSettingADSL:password: > + * > + * Password used to authenticate with the ADSL service. > + **/ > + g_object_class_install_property > + (object_class, PROP_PASSWORD, > + g_param_spec_string (NM_SETTING_ADSL_PASSWORD, > + "Password", > + "Password used to > authenticate with the PPPoA service.", > + NULL, > + G_PARAM_READWRITE | > NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET)); > + > + /** > + * NMSettingAdsl:password-flags: > + * > + * Flags indicating how to handle #NMSettingAdsl:password:. > + **/ > + g_object_class_install_property (object_class, PROP_PASSWORD_FLAGS, > + g_param_spec_uint (NM_SETTING_ADSL_PASSWORD_FLAGS, > + "Password Flags", > + "Flags indicating how to handle the ADSL > password.", > + NM_SETTING_SECRET_FLAG_NONE, > + NM_SETTING_SECRET_FLAGS_ALL, > + NM_SETTING_SECRET_FLAG_NONE, > + G_PARAM_READWRITE | > NM_SETTING_PARAM_SERIALIZE)); > + > + /** > + * NMSettingAdsl:protocol: > + * > + * ADSL connection protocol, can be PPPoA, PPPoE, or IPoATM. > + **/ > + g_object_class_install_property > + (object_class, PROP_PROTOCOL, > + g_param_spec_string (NM_SETTING_ADSL_PROTOCOL, > + "Protocol", > + "ADSL connection protocol.", > + NULL, > + G_PARAM_READWRITE | > NM_SETTING_PARAM_SERIALIZE)); > + > + /** > + * NMSettingAdsl:encapsulation: > + * > + * ADSL connection encapsulation, can be VCMux or LLC. > + **/ > + g_object_class_install_property > + (object_class, PROP_ENCAPSULATION, > + g_param_spec_string (NM_SETTING_ADSL_ENCAPSULATION, > + "Encapsulation", > + "Encapsulation of ADSL > connection", > + NULL, > + G_PARAM_READWRITE | > NM_SETTING_PARAM_SERIALIZE)); > + > + /** > + * NMSettingAdsl:vpi: > + * > + * ADSL connection vpi. > + **/ > + g_object_class_install_property > + (object_class, PROP_VPI, > + g_param_spec_string (NM_SETTING_ADSL_VPI, > + "VPI", > + "VPI of ADSL connection", > + NULL, > + G_PARAM_READWRITE | > NM_SETTING_PARAM_SERIALIZE)); > + > + /** > + * NMSettingAdsl:vci: > + * > + * ADSL connection vci. > + **/ > + g_object_class_install_property > + (object_class, PROP_VCI, > + g_param_spec_string (NM_SETTING_ADSL_VCI, > + "VCI", > + "VCI of ADSL connection", > + NULL, > + G_PARAM_READWRITE | > NM_SETTING_PARAM_SERIALIZE)); > +} > diff --git a/libnm-util/nm-setting-adsl.h b/libnm-util/nm-setting-adsl.h > new file mode 100644 > index 0000000..fd7408b > --- /dev/null > +++ b/libnm-util/nm-setting-adsl.h > @@ -0,0 +1,97 @@ > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ > + > +/* > + * Dan Williams <[email protected]> > + * Hicham HAOUARI <[email protected]> > + * Pantelis Koukousoulas <[email protected]> > + * > + * This library is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2 of the License, or (at your option) any later version. > + * > + * This library is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with this library; if not, write to the > + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, > + * Boston, MA 02110-1301 USA. > + * > + * (C) Copyright 2007 - 2008 Red Hat, Inc. > + */ > + > +#ifndef NM_SETTING_ADSL_H > +#define NM_SETTING_ADSL_H > + > +#include <nm-setting.h> > + > +G_BEGIN_DECLS > + > +#define NM_TYPE_SETTING_ADSL (nm_setting_adsl_get_type ()) > +#define NM_SETTING_ADSL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), > NM_TYPE_SETTING_ADSL, NMSettingAdsl)) > +#define NM_SETTING_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), > NM_TYPE_SETTING_ADSL, NMSettingAdslClass)) > +#define NM_IS_SETTING_ADSL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), > NM_TYPE_SETTING_ADSL)) > +#define NM_IS_SETTING_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), > NM_TYPE_SETTING_ADSL)) > +#define NM_SETTING_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), > NM_TYPE_SETTING_ADSL, NMSettingAdslClass)) > + > +#define NM_SETTING_ADSL_SETTING_NAME "adsl" > + > +typedef enum > +{ > + NM_SETTING_ADSL_ERROR_UNKNOWN = 0, > + NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, > + NM_SETTING_ADSL_ERROR_MISSING_PROPERTY > +} NMSettingAdslError; > + > +#define NM_TYPE_SETTING_ADSL_ERROR (nm_setting_adsl_error_get_type ()) > +GType nm_setting_adsl_error_get_type (void); > + > +#define NM_SETTING_ADSL_ERROR nm_setting_adsl_error_quark () > +GQuark nm_setting_adsl_error_quark (void); > + > +#define NM_SETTING_ADSL_USERNAME "username" > +#define NM_SETTING_ADSL_PASSWORD "password" > +#define NM_SETTING_ADSL_PASSWORD_FLAGS "password-flags" > +#define NM_SETTING_ADSL_PROTOCOL "protocol" > +#define NM_SETTING_ADSL_ENCAPSULATION "encapsulation" > +#define NM_SETTING_ADSL_VPI "vpi" > +#define NM_SETTING_ADSL_VCI "vci" > + > + > +#define NM_SETTING_ADSL_PROTOCOL_PPPOA "pppoa" > +#define NM_SETTING_ADSL_PROTOCOL_PPPOE "pppoe" > +#define NM_SETTING_ADSL_PROTOCOL_IPOATM "ipoatm" > +#define NM_SETTING_ADSL_ENCAPSULATION_VCMUX "vcmux" > +#define NM_SETTING_ADSL_ENCAPSULATION_LLC "llc" > + > +typedef struct { > + NMSetting parent; > +} NMSettingAdsl; > + > +typedef struct { > + NMSettingClass parent; > + > + /* Padding for future expansion */ > + void (*_reserved1) (void); > + void (*_reserved2) (void); > + void (*_reserved3) (void); > + void (*_reserved4) (void); > +} NMSettingAdslClass; > + > +GType nm_setting_adsl_get_type (void); > + > +NMSetting *nm_setting_adsl_new (void); > +const char *nm_setting_adsl_get_username (NMSettingAdsl *setting); > +const char *nm_setting_adsl_get_password (NMSettingAdsl *setting); > +const char *nm_setting_adsl_get_protocol (NMSettingAdsl *setting); > +const char *nm_setting_adsl_get_encapsulation (NMSettingAdsl *setting); > +const char *nm_setting_adsl_get_vpi (NMSettingAdsl *setting); > +const char *nm_setting_adsl_get_vci (NMSettingAdsl *setting); > +NMSettingSecretFlags nm_setting_adsl_get_password_flags (NMSettingAdsl > *setting); > + > +G_END_DECLS > + > +#endif /* NM_SETTING_ADSL_H */ > diff --git a/src/Makefile.am b/src/Makefile.am > index 94e1a8c..50b52d6 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -118,6 +118,8 @@ NetworkManager_SOURCES = \ > nm-device-private.h \ > nm-device-ethernet.c \ > nm-device-ethernet.h \ > + nm-device-adsl.c \ > + nm-device-adsl.h \ > nm-device-wifi.c \ > nm-device-wifi.h \ > nm-device-olpc-mesh.c \ > @@ -185,6 +187,9 @@ nm-device-interface-glue.h: > $(top_srcdir)/introspection/nm-device.xml > nm-device-ethernet-glue.h: $(top_srcdir)/introspection/nm-device-ethernet.xml > $(AM_V_GEN) dbus-binding-tool --prefix=nm_device_ethernet > --mode=glib-server --output=$@ $< > > +nm-device-adsl-glue.h: $(top_srcdir)/introspection/nm-device-adsl.xml > + $(AM_V_GEN) dbus-binding-tool --prefix=nm_device_adsl > --mode=glib-server --output=$@ $< > + > nm-device-wifi-glue.h: $(top_srcdir)/introspection/nm-device-wifi.xml > $(AM_V_GEN) dbus-binding-tool --prefix=nm_device_wifi > --mode=glib-server --output=$@ $< > > @@ -217,6 +222,7 @@ BUILT_SOURCES = \ > nm-manager-glue.h \ > nm-device-interface-glue.h \ > nm-device-ethernet-glue.h \ > + nm-device-adsl-glue.h \ > nm-device-wifi-glue.h \ > nm-device-olpc-mesh-glue.h \ > nm-device-bt-glue.h \ > diff --git a/src/nm-device-adsl.c b/src/nm-device-adsl.c > new file mode 100644 > index 0000000..212fec1 > --- /dev/null > +++ b/src/nm-device-adsl.c > @@ -0,0 +1,83 @@ > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ > +/* NetworkManager -- Network link manager > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License along > + * with this program; if not, write to the Free Software Foundation, Inc., > + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + * > + * Pantelis Koukousoulas <[email protected]> > + */ > + > +#include <glib.h> > + > +#include "nm-glib-compat.h" > +#include "nm-device-adsl.h" > +#include "nm-device-interface.h" > +#include "nm-properties-changed-signal.h" > + > +#include "nm-device-adsl-glue.h" > + > +G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE) > + > +enum { > + PROPERTIES_CHANGED, > + LAST_SIGNAL > +}; > +static guint signals[LAST_SIGNAL] = { 0 }; > + > + > +NMDevice * > +nm_device_adsl_new (const char *udi, > + const char *iface, > + const char *driver) > +{ > + g_return_val_if_fail (udi != NULL, NULL); > + > + return (NMDevice *) g_object_new (NM_TYPE_DEVICE_ADSL, > + NM_DEVICE_INTERFACE_UDI, udi, > + NM_DEVICE_INTERFACE_IFACE, iface, > + NM_DEVICE_INTERFACE_DRIVER, driver, > + NM_DEVICE_INTERFACE_TYPE_DESC, "ADSL", > + NM_DEVICE_INTERFACE_DEVICE_TYPE, > NM_DEVICE_TYPE_ADSL, > + NULL); > +} > + > + > +static void > +nm_device_adsl_init (NMDeviceAdsl * self) > +{ > +} > + > + > +static guint32 > +real_get_generic_capabilities (NMDevice *dev) > +{ > + return NM_DEVICE_CAP_NM_SUPPORTED; > +} > + > +static void > +nm_device_adsl_class_init (NMDeviceAdslClass *klass) > +{ > + GObjectClass *object_class = G_OBJECT_CLASS (klass); > + NMDeviceClass *parent_class = NM_DEVICE_CLASS (klass); > + > + parent_class->get_generic_capabilities = real_get_generic_capabilities; > + > + /* Signals */ > + signals[PROPERTIES_CHANGED] = > + nm_properties_changed_signal_new (object_class, > + G_STRUCT_OFFSET > (NMDeviceAdslClass, properties_changed)); > + > + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), > + &dbus_glib_nm_device_adsl_object_info); > +} > diff --git a/src/nm-device-adsl.h b/src/nm-device-adsl.h > new file mode 100644 > index 0000000..42c5bc9 > --- /dev/null > +++ b/src/nm-device-adsl.h > @@ -0,0 +1,57 @@ > +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ > +/* NetworkManager -- Network link manager > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License along > + * with this program; if not, write to the Free Software Foundation, Inc., > + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + * > + * Pantelis Koukousoulas <[email protected]> > + */ > + > +#ifndef NM_DEVICE_ADSL_H > +#define NM_DEVICE_ADSL_H > + > +#include <glib-object.h> > + > +// Parent class > +#include "nm-device.h" > + > +G_BEGIN_DECLS > + > +#define NM_TYPE_DEVICE_ADSL (nm_device_adsl_get_type ()) > +#define NM_DEVICE_ADSL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), > NM_TYPE_DEVICE_ADSL, NMDeviceAdsl)) > +#define NM_DEVICE_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), > NM_TYPE_DEVICE_ADSL, NMDeviceAdslClass)) > +#define NM_IS_DEVICE_ADSL(obj) (G_TYPE_CHECK_INSTANCE_TYPE > ((obj), NM_TYPE_DEVICE_ADSL)) > +#define NM_IS_DEVICE_ADSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE > ((klass), NM_TYPE_DEVICE_ADSL)) > +#define NM_DEVICE_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS > ((obj), NM_TYPE_DEVICE_ADSL, NMDeviceAdslClass)) > + > +typedef struct { > + NMDevice parent; > +} NMDeviceAdsl; > + > +typedef struct { > + NMDeviceClass parent; > + > + /* Signals */ > + void (*properties_changed) (NMDeviceAdsl *device, GHashTable > *properties); > +} NMDeviceAdslClass; > + > +GType nm_device_adsl_get_type (void); > + > +NMDevice *nm_device_adsl_new (const char *udi, > + const char *iface, > + const char *driver); > + > +G_END_DECLS > + > +#endif /* NM_DEVICE_ADSL_H */ > diff --git a/src/nm-udev-manager.c b/src/nm-udev-manager.c > index 41a4e15..82b016a 100644 > --- a/src/nm-udev-manager.c > +++ b/src/nm-udev-manager.c > @@ -38,6 +38,7 @@ > #include "nm-device-wifi.h" > #include "nm-device-olpc-mesh.h" > #include "nm-device-ethernet.h" > +#include "nm-device-adsl.h" > #if WITH_WIMAX > #include "nm-device-wimax.h" > #endif > @@ -413,6 +414,13 @@ is_wimax (const char *driver) > return g_strcmp0 (driver, "i2400m_usb") == 0; > } > > +static gboolean > +is_atm (GUdevDevice *device) > +{ > + const gchar *subsys = g_udev_device_get_subsystem(device); > + return (!strcmp (subsys,"atm")); > +} > + > static GObject * > device_creator (NMUdevManager *manager, > GUdevDevice *udev_device, > @@ -459,6 +467,12 @@ device_creator (NMUdevManager *manager, > } > } > > + /* If the device is atm it doesn't have an interface index */ > + if (is_atm (udev_device)) { > + device = (GObject *) nm_device_adsl_new (path, ifname, driver); > + goto out; > + } > + > ifindex = g_udev_device_get_sysfs_attr_as_int (udev_device, "ifindex"); > if (ifindex <= 0) { > nm_log_warn (LOGD_HW, "%s: device had invalid ifindex %d; > ignoring...", path, (guint32) ifindex); > @@ -541,11 +555,29 @@ net_add (NMUdevManager *self, GUdevDevice *device) > } > > static void > +adsl_add (NMUdevManager *self, GUdevDevice *device) > +{ > + g_return_if_fail (device != NULL); > + > + nm_log_dbg (LOGD_HW, "adsl_add: ATM Device detected from udev. Adding > .."); > + > + g_signal_emit (self, signals[DEVICE_ADDED], 0, device, device_creator); > +} > + > +static void > net_remove (NMUdevManager *self, GUdevDevice *device) > { > g_signal_emit (self, signals[DEVICE_REMOVED], 0, device); > } > > +static void > +adsl_remove (NMUdevManager *self, GUdevDevice *device) > +{ > + nm_log_dbg (LOGD_HW, "adsl_remove: Removing ATM Device"); > + > + g_signal_emit (self, signals[DEVICE_REMOVED], 0, device); > +} > + > void > nm_udev_manager_query_devices (NMUdevManager *self) > { > @@ -561,6 +593,13 @@ nm_udev_manager_query_devices (NMUdevManager *self) > g_object_unref (G_UDEV_DEVICE (iter->data)); > } > g_list_free (devices); > + > + devices = g_udev_client_query_by_subsystem(priv->client, "atm"); > + for (iter = devices; iter; iter = g_list_next (iter)) { > + adsl_add (self, G_UDEV_DEVICE (iter->data)); > + g_object_unref (G_UDEV_DEVICE(iter->data)); > + } > + g_list_free (devices); > } > > static void > @@ -581,18 +620,23 @@ handle_uevent (GUdevClient *client, > nm_log_dbg (LOGD_HW, "UDEV event: action '%s' subsys '%s' device '%s'", > action, subsys, g_udev_device_get_name (device)); > > - g_return_if_fail (!strcmp (subsys, "rfkill") || !strcmp (subsys, > "net")); > + g_return_if_fail (!strcmp (subsys, "rfkill") || !strcmp (subsys, "net") > || > + !strcmp (subsys, "atm")); > > if (!strcmp (action, "add")) { > if (!strcmp (subsys, "rfkill")) > rfkill_add (self, device); > else if (!strcmp (subsys, "net")) > net_add (self, device); > + else if (!strcmp (subsys, "atm")) > + adsl_add (self, device); > } else if (!strcmp (action, "remove")) { > if (!strcmp (subsys, "rfkill")) > rfkill_remove (self, device); > else if (!strcmp (subsys, "net")) > net_remove (self, device); > + else if (!strcmp (subsys, "atm")) > + adsl_remove (self, device); > } > > recheck_killswitches (self); > @@ -602,7 +646,7 @@ static void > nm_udev_manager_init (NMUdevManager *self) > { > NMUdevManagerPrivate *priv = NM_UDEV_MANAGER_GET_PRIVATE (self); > - const char *subsys[3] = { "rfkill", "net", NULL }; > + const char *subsys[4] = { "rfkill", "net", "atm", NULL }; > GList *switches, *iter; > guint32 i; > _______________________________________________ networkmanager-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/networkmanager-list
