mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-14 12:05:03 +00:00
adsl: settings and initial "scaffolding"
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, In this version, we hack the nm-device.c:nm_device_get_priority() to get better priority instead of changing the DeviceType enum. Signed-off-by: Pantelis Koukousoulas <pktoss@gmail.com>
This commit is contained in:
parent
6a0f7d655c
commit
0e6f5ce38e
|
@ -107,6 +107,7 @@ typedef enum {
|
|||
* GSM/UMTS, or LTE network access protocols
|
||||
* @NM_DEVICE_TYPE_INFINIBAND: an IP-over-InfiniBand device
|
||||
* @NM_DEVICE_TYPE_BOND: a bond master interface
|
||||
* @NM_DEVICE_TYPE_ADSL: ADSL modem
|
||||
*
|
||||
* #NMDeviceType values indicate the type of hardware represented by
|
||||
* an #NMDevice.
|
||||
|
@ -124,6 +125,7 @@ typedef enum {
|
|||
NM_DEVICE_TYPE_INFINIBAND = 9,
|
||||
NM_DEVICE_TYPE_BOND = 10,
|
||||
NM_DEVICE_TYPE_VLAN = 11,
|
||||
NM_DEVICE_TYPE_ADSL = 12,
|
||||
} NMDeviceType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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-infiniband.xml \
|
||||
|
|
|
@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
|
|||
<xi:include href="nm-device-infiniband.xml"/>
|
||||
<xi:include href="nm-device-bond.xml"/>
|
||||
<xi:include href="nm-device-vlan.xml"/>
|
||||
<xi:include href="nm-device-adsl.xml"/>
|
||||
<xi:include href="nm-wimax-nsp.xml"/>
|
||||
<xi:include href="nm-ip4-config.xml"/>
|
||||
<xi:include href="nm-ip6-config.xml"/>
|
||||
|
|
21
introspection/nm-device-adsl.xml
Normal file
21
introspection/nm-device-adsl.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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>
|
||||
|
||||
<property name="Carrier" type="b" access="read">
|
||||
<tp:docstring>
|
||||
Indicates whether the physical carrier is found.
|
||||
</tp:docstring>
|
||||
</property>
|
||||
|
||||
</interface>
|
||||
</node>
|
|
@ -16,6 +16,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-bond.h \
|
||||
nm-setting-connection.h \
|
||||
|
@ -49,6 +50,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-bond.c \
|
||||
nm-setting-connection.c \
|
||||
|
|
|
@ -32,6 +32,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;
|
||||
|
@ -171,6 +172,17 @@ 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_password_flags;
|
||||
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;
|
||||
|
|
461
libnm-util/nm-setting-adsl.c
Normal file
461
libnm-util/nm-setting-adsl.c
Normal file
|
@ -0,0 +1,461 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
* Hicham HAOUARI <hicham.haouari@gmail.com>
|
||||
* Pantelis Koukousoulas <pktoss@gmail.com>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
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;
|
||||
guint32 vpi;
|
||||
guint32 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
|
||||
**/
|
||||
guint32
|
||||
nm_setting_adsl_get_vpi (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), 0);
|
||||
|
||||
return NM_SETTING_ADSL_GET_PRIVATE (setting)->vpi;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_adsl_get_vci:
|
||||
* @setting: the #NMSettingAdsl
|
||||
*
|
||||
* Returns: the #NMSettingAdsl:vci property of the setting
|
||||
**/
|
||||
guint32
|
||||
nm_setting_adsl_get_vci (NMSettingAdsl *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_ADSL (setting), 0);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (priv->password && !strlen (priv->password)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_ADSL_ERROR,
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
|
||||
NM_SETTING_ADSL_PASSWORD);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) &&
|
||||
strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) &&
|
||||
strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_IPOATM)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_ADSL_ERROR,
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY,
|
||||
NM_SETTING_ADSL_PROTOCOL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (strcmp (priv->encapsulation, NM_SETTING_ADSL_ENCAPSULATION_VCMUX) &&
|
||||
strcmp (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_ascii_strdown (g_value_get_string (value), -1);
|
||||
break;
|
||||
case PROP_ENCAPSULATION:
|
||||
g_free (priv->encapsulation);
|
||||
priv->encapsulation = g_ascii_strdown (g_value_get_string (value), -1);
|
||||
break;
|
||||
case PROP_VPI:
|
||||
priv->vpi = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_VCI:
|
||||
priv->vci = g_value_get_uint (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_uint (value, nm_setting_adsl_get_vpi (setting));
|
||||
break;
|
||||
case PROP_VCI:
|
||||
g_value_set_uint (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_uint (NM_SETTING_ADSL_VPI,
|
||||
"VPI",
|
||||
"VPI of ADSL connection",
|
||||
0, 65536, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
|
||||
/**
|
||||
* NMSettingAdsl:vci:
|
||||
*
|
||||
* ADSL connection vci.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_VCI,
|
||||
g_param_spec_uint (NM_SETTING_ADSL_VCI,
|
||||
"VCI",
|
||||
"VCI of ADSL connection",
|
||||
0, 65536, 0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
|
||||
}
|
100
libnm-util/nm-setting-adsl.h
Normal file
100
libnm-util/nm-setting-adsl.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* -*- mode: c; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* Dan Williams <dcbw@redhat.com>
|
||||
* Hicham HAOUARI <hicham.haouari@gmail.com>
|
||||
* Pantelis Koukousoulas <pantelis@gmail.com>
|
||||
*
|
||||
* 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"
|
||||
|
||||
/**
|
||||
* NMSettingAdslError:
|
||||
* @NM_SETTING_ADSL_ERROR_UNKNOWN: unknown or unclassified error
|
||||
* @NM_SETTING_ADSL_ERROR_INVALID_PROPERTY: the property was invalid
|
||||
* @NM_SETTING_ADSL_ERROR_MISSING_PROPERTY: the property was missing and is
|
||||
* required
|
||||
*/
|
||||
typedef enum {
|
||||
NM_SETTING_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
|
||||
NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
|
||||
NM_SETTING_ADSL_ERROR_MISSING_PROPERTY /*< nick=MissingProperty >*/
|
||||
} NMSettingAdslError;
|
||||
|
||||
#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);
|
||||
guint32 nm_setting_adsl_get_vpi (NMSettingAdsl *setting);
|
||||
guint32 nm_setting_adsl_get_vci (NMSettingAdsl *setting);
|
||||
NMSettingSecretFlags nm_setting_adsl_get_password_flags (NMSettingAdsl *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_ADSL_H */
|
|
@ -120,6 +120,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-wired.c \
|
||||
|
@ -220,6 +222,9 @@ nm-device-ethernet-glue.h: $(top_srcdir)/introspection/nm-device-ethernet.xml
|
|||
nm-device-infiniband-glue.h: $(top_srcdir)/introspection/nm-device-infiniband.xml
|
||||
$(AM_V_GEN) dbus-binding-tool --prefix=nm_device_infiniband --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=$@ $<
|
||||
|
||||
|
@ -261,6 +266,7 @@ BUILT_SOURCES = \
|
|||
nm-device-infiniband-glue.h \
|
||||
nm-device-bond-glue.h \
|
||||
nm-device-vlan-glue.h \
|
||||
nm-device-adsl-glue.h \
|
||||
nm-device-wifi-glue.h \
|
||||
nm-device-olpc-mesh-glue.h \
|
||||
nm-device-bt-glue.h \
|
||||
|
|
82
src/nm-device-adsl.c
Normal file
82
src/nm-device-adsl.c
Normal file
|
@ -0,0 +1,82 @@
|
|||
/* -*- 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 <pktoss@gmail.com>
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-device-adsl.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_UDI, udi,
|
||||
NM_DEVICE_IFACE, iface,
|
||||
NM_DEVICE_DRIVER, driver,
|
||||
NM_DEVICE_TYPE_DESC, "ADSL",
|
||||
NM_DEVICE_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);
|
||||
}
|
57
src/nm-device-adsl.h
Normal file
57
src/nm-device-adsl.h
Normal file
|
@ -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 <pktoss@gmail.com>
|
||||
*/
|
||||
|
||||
#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 */
|
|
@ -48,6 +48,7 @@
|
|||
#include "nm-device-infiniband.h"
|
||||
#include "nm-device-bond.h"
|
||||
#include "nm-device-vlan.h"
|
||||
#include "nm-device-adsl.h"
|
||||
#include "nm-system.h"
|
||||
#include "nm-properties-changed-signal.h"
|
||||
#include "nm-setting-bluetooth.h"
|
||||
|
@ -2025,6 +2026,12 @@ is_vlan (int ifindex)
|
|||
return (nm_system_get_iface_type (ifindex, NULL) == NM_IFACE_TYPE_VLAN);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_adsl (GUdevDevice *device)
|
||||
{
|
||||
return (g_strcmp0 (g_udev_device_get_subsystem (device), "atm") == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
udev_device_added_cb (NMUdevManager *udev_mgr,
|
||||
GUdevDevice *udev_device,
|
||||
|
@ -2044,14 +2051,22 @@ udev_device_added_cb (NMUdevManager *udev_mgr,
|
|||
g_return_if_fail (iface != NULL);
|
||||
g_return_if_fail (sysfs_path != NULL);
|
||||
g_return_if_fail (driver != NULL);
|
||||
g_return_if_fail (ifindex > 0);
|
||||
|
||||
device = find_device_by_ifindex (self, ifindex);
|
||||
if (device) {
|
||||
/* If it's a virtual device we may need to update its UDI */
|
||||
if (nm_system_get_iface_type (ifindex, iface) != NM_IFACE_TYPE_UNSPEC)
|
||||
g_object_set (G_OBJECT (device), NM_DEVICE_UDI, sysfs_path, NULL);
|
||||
return;
|
||||
/* Most devices will have an ifindex here */
|
||||
if (ifindex > 0) {
|
||||
device = find_device_by_ifindex (self, ifindex);
|
||||
if (device) {
|
||||
/* If it's a virtual device we may need to update its UDI */
|
||||
if (nm_system_get_iface_type (ifindex, iface) != NM_IFACE_TYPE_UNSPEC)
|
||||
g_object_set (G_OBJECT (device), NM_DEVICE_UDI, sysfs_path, NULL);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* But ATM/ADSL devices don't */
|
||||
g_return_if_fail (is_adsl (udev_device));
|
||||
device = find_device_by_ip_iface (self, iface);
|
||||
if (device)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Try registered device factories */
|
||||
|
@ -2103,7 +2118,9 @@ udev_device_added_cb (NMUdevManager *udev_mgr,
|
|||
}
|
||||
} else
|
||||
nm_log_err (LOGD_HW, "(%s): failed to get VLAN parent ifindex", iface);
|
||||
} else
|
||||
} else if (is_adsl (udev_device))
|
||||
device = nm_device_adsl_new (sysfs_path, iface, driver);
|
||||
else
|
||||
device = nm_device_ethernet_new (sysfs_path, iface, driver);
|
||||
}
|
||||
|
||||
|
|
|
@ -329,52 +329,34 @@ rfkill_remove (NMUdevManager *self,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
net_add (NMUdevManager *self, GUdevDevice *udev_device)
|
||||
static gboolean
|
||||
dev_get_attrs (GUdevDevice *udev_device,
|
||||
const char **out_ifname,
|
||||
const char **out_path,
|
||||
char **out_driver,
|
||||
int *out_ifindex)
|
||||
{
|
||||
GUdevDevice *parent = NULL, *grandparent = NULL;
|
||||
gint ifindex;
|
||||
gint etype;
|
||||
const char *ifname, *driver, *path, *subsys, *tmp;
|
||||
gboolean is_ctc;
|
||||
const char *ifname, *driver, *path, *subsys;
|
||||
gint ifindex = -1;
|
||||
gboolean success = FALSE;
|
||||
|
||||
g_return_if_fail (udev_device != NULL);
|
||||
g_return_val_if_fail (udev_device != NULL, FALSE);
|
||||
g_return_val_if_fail (out_ifname != NULL, FALSE);
|
||||
g_return_val_if_fail (out_path != NULL, FALSE);
|
||||
g_return_val_if_fail (out_driver != NULL, FALSE);
|
||||
g_return_val_if_fail (out_ifindex != NULL, FALSE);
|
||||
|
||||
ifname = g_udev_device_get_name (udev_device);
|
||||
if (!ifname) {
|
||||
nm_log_dbg (LOGD_HW, "failed to get device's interface");
|
||||
return;
|
||||
}
|
||||
|
||||
etype = g_udev_device_get_sysfs_attr_as_int (udev_device, "type");
|
||||
is_ctc = (strncmp (ifname, "ctc", 3) == 0) && (etype == 256);
|
||||
|
||||
/* Ignore devices that don't report Ethernet encapsulation, except for
|
||||
* s390 CTC-type devices that report 256 for some reason.
|
||||
* FIXME: use something other than interface name to detect CTC here.
|
||||
*/
|
||||
if ((etype != ARPHRD_ETHER) && (etype != ARPHRD_INFINIBAND) && (is_ctc == FALSE)) {
|
||||
nm_log_dbg (LOGD_HW, "(%s): ignoring interface with type %d", ifname, etype);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Not all ethernet devices are immediately usable; newer mobile broadband
|
||||
* devices (Ericsson, Option, Sierra) require setup on the tty before the
|
||||
* ethernet device is usable. 2.6.33 and later kernels set the 'DEVTYPE'
|
||||
* uevent variable which we can use to ignore the interface as a NMDevice
|
||||
* subclass. ModemManager will pick it up though and so we'll handle it
|
||||
* through the mobile broadband stuff.
|
||||
*/
|
||||
tmp = g_udev_device_get_property (udev_device, "DEVTYPE");
|
||||
if (g_strcmp0 (tmp, "wwan") == 0) {
|
||||
nm_log_dbg (LOGD_HW, "(%s): ignoring interface with devtype '%s'", ifname, tmp);
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
path = g_udev_device_get_sysfs_path (udev_device);
|
||||
if (!path) {
|
||||
nm_log_warn (LOGD_HW, "couldn't determine device path; ignoring...");
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
driver = g_udev_device_get_driver (udev_device);
|
||||
|
@ -399,11 +381,8 @@ net_add (NMUdevManager *self, GUdevDevice *udev_device)
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
goto out;
|
||||
}
|
||||
if (g_udev_device_get_sysfs_attr (udev_device, "ifindex"))
|
||||
ifindex = g_udev_device_get_sysfs_attr_as_int (udev_device, "ifindex");
|
||||
|
||||
if (!driver) {
|
||||
switch (nm_system_get_iface_type (ifindex, ifname)) {
|
||||
|
@ -425,13 +404,69 @@ net_add (NMUdevManager *self, GUdevDevice *udev_device)
|
|||
}
|
||||
}
|
||||
|
||||
g_signal_emit (self, signals[DEVICE_ADDED], 0, udev_device, ifname, path, driver, ifindex);
|
||||
*out_ifname = ifname;
|
||||
*out_path = path;
|
||||
*out_driver = g_strdup (driver);
|
||||
*out_ifindex = ifindex;
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
if (grandparent)
|
||||
g_object_unref (grandparent);
|
||||
if (parent)
|
||||
g_object_unref (parent);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static void
|
||||
net_add (NMUdevManager *self, GUdevDevice *udev_device)
|
||||
{
|
||||
gint ifindex = -1;
|
||||
gint etype;
|
||||
const char *ifname = NULL, *path = NULL, *tmp;
|
||||
char *driver = NULL;
|
||||
gboolean is_ctc;
|
||||
|
||||
g_return_if_fail (udev_device != NULL);
|
||||
|
||||
if (!dev_get_attrs (udev_device, &ifname, &path, &driver, &ifindex))
|
||||
return;
|
||||
|
||||
if (ifindex < 0) {
|
||||
nm_log_warn (LOGD_HW, "%s: device had invalid ifindex %d; ignoring...", path, ifindex);
|
||||
goto out;
|
||||
}
|
||||
|
||||
etype = g_udev_device_get_sysfs_attr_as_int (udev_device, "type");
|
||||
is_ctc = (strncmp (ifname, "ctc", 3) == 0) && (etype == 256);
|
||||
|
||||
/* Ignore devices that don't report Ethernet encapsulation, except for
|
||||
* s390 CTC-type devices that report 256 for some reason.
|
||||
* FIXME: use something other than interface name to detect CTC here.
|
||||
*/
|
||||
if ((etype != ARPHRD_ETHER) && (etype != ARPHRD_INFINIBAND) && (is_ctc == FALSE)) {
|
||||
nm_log_dbg (LOGD_HW, "(%s): ignoring interface with type %d", ifname, etype);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Not all ethernet devices are immediately usable; newer mobile broadband
|
||||
* devices (Ericsson, Option, Sierra) require setup on the tty before the
|
||||
* ethernet device is usable. 2.6.33 and later kernels set the 'DEVTYPE'
|
||||
* uevent variable which we can use to ignore the interface as a NMDevice
|
||||
* subclass. ModemManager will pick it up though and so we'll handle it
|
||||
* through the mobile broadband stuff.
|
||||
*/
|
||||
tmp = g_udev_device_get_property (udev_device, "DEVTYPE");
|
||||
if (g_strcmp0 (tmp, "wwan") == 0) {
|
||||
nm_log_dbg (LOGD_HW, "(%s): ignoring interface with devtype '%s'", ifname, tmp);
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_signal_emit (self, signals[DEVICE_ADDED], 0, udev_device, ifname, path, driver, ifindex);
|
||||
|
||||
out:
|
||||
g_free (driver);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -440,6 +475,30 @@ net_remove (NMUdevManager *self, GUdevDevice *device)
|
|||
g_signal_emit (self, signals[DEVICE_REMOVED], 0, device);
|
||||
}
|
||||
|
||||
static void
|
||||
adsl_add (NMUdevManager *self, GUdevDevice *udev_device)
|
||||
{
|
||||
gint ifindex = -1;
|
||||
const char *ifname = NULL, *path = NULL;
|
||||
char *driver = NULL;
|
||||
|
||||
g_return_if_fail (udev_device != NULL);
|
||||
|
||||
nm_log_dbg (LOGD_HW, "adsl_add: ATM Device detected from udev. Adding ..");
|
||||
|
||||
if (dev_get_attrs (udev_device, &ifname, &path, &driver, &ifindex))
|
||||
g_signal_emit (self, signals[DEVICE_ADDED], 0, udev_device, ifname, path, driver, ifindex);
|
||||
g_free (driver);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -455,6 +514,14 @@ 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
|
||||
|
@ -475,18 +542,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);
|
||||
|
@ -496,7 +568,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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue