Commit 8039dd30 authored by Pantelis Koukousoulas's avatar Pantelis Koukousoulas Committed by Dan Williams

adsl: add libnm-glib and nmcli code

For the finale, this is the libnm-glib and nmcli part of the support,
with this you can now make a full pppoatm connection from NetworkManager
by configuring it in system scope in a keyfile.

As an example, here is mine:
(password and username snipped for obvious reasons)

[connection]
id=MYISP
uuid=34d04e69-fdd9-4231-af2c-25ed1f34dc1e
type=adsl
timestamp=1304621332

[adsl]
username=user@myisp.com
password=mypassword
vpi=8
vci=35
encapsulation=vcmux
protocol=pppoa

[ipv6]
method=ignore

[ipv4]
method=auto

Extract from logs:
NetworkManager[29155]: <info> Activation (ueagle-atm0) starting connection 'MYISP'
NetworkManager[29155]: <info> (ueagle-atm0): device state change: disconnected -> prepare (reason 'none') [30 40 0]
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 1 of 5 (Device Prepare) scheduled...
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 1 of 5 (Device Prepare) started...
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 2 of 5 (Device Configure) scheduled...
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 1 of 5 (Device Prepare) complete.
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 2 of 5 (Device Configure) starting...
NetworkManager[29155]: <info> (ueagle-atm0): device state change: prepare -> config (reason 'none') [40 50 0]
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 2 of 5 (Device Configure) successful.
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 3 of 5 (IP Configure Start) scheduled.
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 2 of 5 (Device Configure) complete.
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 3 of 5 (IP Configure Start) started...
NetworkManager[29155]: <info> (ueagle-atm0): device state change: config -> ip-config (reason 'none') [50 70 0]
NetworkManager[29155]: <info> starting PPP connection
NetworkManager[29155]: <debug> [1304671146.590156] [nm-ppp-manager.c:1047] nm_ppp_manager_start(): command line: /usr/sbin/pppd nodetach lock nodefaultroute user user@myisp.com plugin pppoatm.so 8.35 noipdefault noauth usepeerdns lcp-echo-failure 0 lcp-echo-interval 0 ipparam /org/freedesktop/NetworkManager/PPP/0 plugin /opt/nmadsl/lib/pppd/2.4.5/nm-pppd-plugin.so
NetworkManager[29155]: <info> pppd started with pid 29175
NetworkManager[29155]: <debug> [1304671146.591235] [NetworkManagerUtils.c:816] nm_utils_get_proc_sys_net_value(): (ueagle-atm0): error reading /proc/sys/net/ipv6/conf/ueagle-atm0/accept_ra: (4) Failed to open file '/proc/sys/net/ipv6/conf/ueagle-atm0/accept_ra': No such file or directory
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 3 of 5 (IP Configure Start) complete.
Plugin pppoatm.so loaded.
Plugin /opt/nmadsl/lib/pppd/2.4.5/nm-pppd-plugin.so loaded.
** Message: nm-ppp-plugin: (plugin_init): initializing
** Message: nm-ppp-plugin: (nm_phasechange): status 3 / phase 'serial connection'
NetworkManager[29155]: <debug> [1304671146.612937] [nm-udev-manager.c:621] handle_uevent(): UDEV event: action 'add' subsys 'net' device 'ppp0'
NetworkManager[29155]: <debug> [1304671146.613134] [nm-udev-manager.c:525] net_add(): ignoring interface with type 512
NetworkManager[29155]: <debug> [1304671146.617308] [nm-netlink-monitor.c:117] link_msg_handler(): netlink link message: iface idx 35 flags 0x1090
Using interface ppp0
Connect: ppp0 <--> 8.35
** Message: nm-ppp-plugin: (nm_phasechange): status 5 / phase 'establish'
** Message: nm-ppp-plugin: (nm_phasechange): status 6 / phase 'authenticate'
** Message: nm-ppp-plugin: (get_credentials): passwd-hook, requesting credentials...
NetworkManager[29155]: <debug> [1304671149.639511] [nm-agent-manager.c:1044] nm_agent_manager_get_secrets(): Secrets requested for connection /org/freedesktop/NetworkManager/Settings/0 (adsl)
NetworkManager[29155]: <debug> [1304671149.639684] [nm-settings-connection.c:717] nm_settings_connection_get_secrets(): (34d04e69-fdd9-4231-af2c-25ed1f34dc1e/adsl:1) secrets requested flags 0x1 hint 'password'
NetworkManager[29155]: <debug> [1304671149.640950] [nm-agent-manager.c:959] get_start(): (0x9b4ad10/adsl) system settings secrets sufficient
NetworkManager[29155]: <debug> [1304671149.641332] [nm-settings-connection.c:573] agent_secrets_done_cb(): (34d04e69-fdd9-4231-af2c-25ed1f34dc1e/adsl:1) existing secrets returned
NetworkManager[29155]: <debug> [1304671149.641541] [nm-settings-connection.c:579] agent_secrets_done_cb(): (34d04e69-fdd9-4231-af2c-25ed1f34dc1e/adsl:1) secrets request completed
NetworkManager[29155]: <debug> [1304671149.643074] [nm-settings-connection.c:618] agent_secrets_done_cb(): (34d04e69-fdd9-4231-af2c-25ed1f34dc1e/adsl:1) new agent secrets processed
** Message: nm-ppp-plugin: (get_credentials): got credentials from NetworkManager
PAP authentication succeeded
** Message: nm-ppp-plugin: (nm_phasechange): status 8 / phase 'network'
local  IP address 94.70.90.201
remote IP address 80.106.108.12
primary   DNS address 195.170.0.1
secondary DNS address 195.170.2.2
** Message: nm-ppp-plugin: (nm_phasechange): status 9 / phase 'running'
** Message: nm-ppp-plugin: (nm_ip_up): ip-up event
** Message: nm-ppp-plugin: (nm_ip_up): sending Ip4Config to NetworkManager...
NetworkManager[29155]: <debug> [1304671150.607440] [nm-netlink-monitor.c:117] link_msg_handler(): netlink link message: iface idx 35 flags 0x110D1
NetworkManager[29155]: <info> PPP manager(IP Config Get) reply received.
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 4 of 5 (IP4 Configure Get) scheduled...
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 4 of 5 (IP4 Configure Get) started...
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 5 of 5 (IP Configure Commit) scheduled...
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 4 of 5 (IP4 Configure Get) complete.
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 5 of 5 (IP Configure Commit) started...
NetworkManager[29155]: <debug> [1304671150.608918] [nm-system.c:222] sync_addresses(): (ppp0): syncing addresses (family 2)
NetworkManager[29155]: <info> (ueagle-atm0): device state change: ip-config -> activated (reason 'none') [70 100 0]
NetworkManager[29155]: <info> Policy set 'MYISP' (ppp0) as default for IPv4 routing and DNS.
NetworkManager[29155]: <info> Activation (ueagle-atm0) successful, device activated.
NetworkManager[29155]: <info> Activation (ueagle-atm0) Stage 5 of 5 (IP Configure Commit) complete.
Signed-off-by: default avatarPantelis Koukousoulas <pktoss@gmail.com>
parent 9039c24b
......@@ -33,6 +33,7 @@
#include <nm-client.h>
#include <nm-device-ethernet.h>
#include <nm-device-adsl.h>
#include <nm-device-wifi.h>
#if WITH_WIMAX
#include <nm-device-wimax.h>
......@@ -92,6 +93,7 @@ static NmcOutputField nmc_fields_settings_names[] = {
SETTING_FIELD (NM_SETTING_INFINIBAND_SETTING_NAME, 0), /* 16 */
SETTING_FIELD (NM_SETTING_BOND_SETTING_NAME, 0), /* 17 */
SETTING_FIELD (NM_SETTING_VLAN_SETTING_NAME, 0), /* 18 */
SETTING_FIELD (NM_SETTING_ADSL_SETTING_NAME, 0), /* 19 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTINGS_NAMES_ALL_X NM_SETTING_CONNECTION_SETTING_NAME","\
......@@ -104,6 +106,7 @@ static NmcOutputField nmc_fields_settings_names[] = {
NM_SETTING_SERIAL_SETTING_NAME","\
NM_SETTING_PPP_SETTING_NAME","\
NM_SETTING_PPPOE_SETTING_NAME","\
NM_SETTING_ADSL_SETTING_NAME","\
NM_SETTING_GSM_SETTING_NAME","\
NM_SETTING_CDMA_SETTING_NAME","\
NM_SETTING_BLUETOOTH_SETTING_NAME","\
......@@ -438,6 +441,15 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
continue;
}
}
if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[19].name)) {
NMSettingAdsl *s_adsl = nm_connection_get_setting_adsl (connection);
if (s_adsl) {
setting_adsl_details (s_adsl, nmc);
was_output = TRUE;
continue;
}
}
}
if (print_settings_array)
......
......@@ -31,6 +31,7 @@
#include <nm-client.h>
#include <nm-device.h>
#include <nm-device-ethernet.h>
#include <nm-device-adsl.h>
#include <nm-device-wifi.h>
#include <nm-device-modem.h>
#include <nm-device-bt.h>
......@@ -47,6 +48,7 @@
#include <nm-vpn-connection.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-adsl.h>
#include <nm-setting-pppoe.h>
#include <nm-setting-wireless.h>
#include <nm-setting-gsm.h>
......@@ -256,6 +258,8 @@ device_type_to_string (NMDevice *device)
switch (nm_device_get_device_type (device)) {
case NM_DEVICE_TYPE_ETHERNET:
return NM_SETTING_WIRED_SETTING_NAME;
case NM_DEVICE_TYPE_ADSL:
return NM_SETTING_ADSL_SETTING_NAME;
case NM_DEVICE_TYPE_WIFI:
return NM_SETTING_WIRELESS_SETTING_NAME;
case NM_DEVICE_TYPE_MODEM:
......
......@@ -348,6 +348,26 @@ static NmcOutputField nmc_fields_setting_pppoe[] = {
NM_SETTING_PPPOE_PASSWORD
#define NMC_FIELDS_SETTING_PPPOE_COMMON NMC_FIELDS_SETTING_PPP_ALL
/* Available fields for NM_SETTING_ADSL_SETTING_NAME */
static NmcOutputField nmc_fields_setting_adsl[] = {
SETTING_FIELD ("name", 10), /* 0 */
SETTING_FIELD (NM_SETTING_ADSL_USERNAME, 15), /* 1 */
SETTING_FIELD (NM_SETTING_ADSL_PASSWORD, 15), /* 2 */
SETTING_FIELD (NM_SETTING_ADSL_VPI, 10), /* 3 */
SETTING_FIELD (NM_SETTING_ADSL_VCI, 10), /* 4 */
SETTING_FIELD (NM_SETTING_ADSL_ENCAPSULATION, 10), /* 5 */
SETTING_FIELD (NM_SETTING_ADSL_PROTOCOL, 10), /* 6 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTING_ADSL_ALL "name"","\
NM_SETTING_ADSL_USERNAME","\
NM_SETTING_ADSL_PASSWORD","\
NM_SETTING_ADSL_VPI","\
NM_SETTING_ADSL_VCI","\
NM_SETTING_ADSL_ENCAPSULATION","\
NM_SETTING_ADSL_PROTOCOL
#define NMC_FIELDS_SETTING_ADSL_COMMON NMC_FIELDS_SETTING_ADSL_ALL
/* Available fields for NM_SETTING_GSM_SETTING_NAME */
static NmcOutputField nmc_fields_setting_gsm[] = {
SETTING_FIELD ("name", 10), /* 0 */
......@@ -1716,3 +1736,31 @@ setting_vlan_details (NMSettingVlan *s_vlan, NmCli *nmc)
return TRUE;
}
gboolean
setting_adsl_details (NMSettingAdsl *s_adsl, NmCli *nmc)
{
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
g_return_val_if_fail (NM_IS_SETTING_ADSL (s_adsl), FALSE);
nmc->allowed_fields = nmc_fields_setting_adsl;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_SETTING_ADSL_ALL, nmc->allowed_fields, NULL);
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print field names */
nmc->allowed_fields[0].value = NM_SETTING_ADSL_SETTING_NAME;
nmc->allowed_fields[1].value = nm_setting_adsl_get_username (s_adsl);
nmc->allowed_fields[2].value = nm_setting_adsl_get_password (s_adsl);
nmc->allowed_fields[3].value = g_strdup_printf ("%d", nm_setting_adsl_get_vpi (s_adsl));
nmc->allowed_fields[4].value = g_strdup_printf ("%d", nm_setting_adsl_get_vci (s_adsl));
nmc->allowed_fields[5].value = nm_setting_adsl_get_encapsulation (s_adsl);
nmc->allowed_fields[6].value = nm_setting_adsl_get_protocol (s_adsl);
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
return TRUE;
}
......@@ -22,6 +22,7 @@
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-adsl.h>
#include <nm-setting-8021x.h>
#include <nm-setting-wireless.h>
#include <nm-setting-wireless-security.h>
......@@ -63,5 +64,6 @@ gboolean setting_wimax_details (NMSettingWimax *s_wimax, NmCli *nmc);
gboolean setting_infiniband_details (NMSettingInfiniband *s_infiniband, NmCli *nmc);
gboolean setting_bond_details (NMSettingBond *s_bond, NmCli *nmc);
gboolean setting_vlan_details (NMSettingVlan *s_vlan, NmCli *nmc);
gboolean setting_adsl_details (NMSettingAdsl *s_adsl, NmCli *nmc);
#endif /* NMC_SETTINGS_H */
......@@ -59,6 +59,7 @@ libnminclude_HEADERS = \
nm-device.h \
nm-device-ethernet.h \
nm-device-infiniband.h \
nm-device-adsl.h \
nm-device-wifi.h \
nm-device-bt.h \
nm-device-olpc-mesh.h \
......@@ -92,6 +93,7 @@ libnm_glib_la_csources = \
nm-device.c \
nm-device-ethernet.c \
nm-device-infiniband.c \
nm-device-adsl.c \
nm-device-wifi.c \
nm-device-bt.c \
nm-device-olpc-mesh.c \
......
......@@ -58,6 +58,11 @@ global:
nm_client_wwan_get_enabled;
nm_client_wwan_hardware_get_enabled;
nm_client_wwan_set_enabled;
nm_device_adsl_error_get_type;
nm_device_adsl_error_quark;
nm_device_adsl_get_carrier;
nm_device_adsl_get_type;
nm_device_adsl_new;
nm_device_bond_error_get_type;
nm_device_bond_error_quark;
nm_device_bond_get_carrier;
......
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* 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.
*
* author: Pantelis Koukousoulas <pktoss@gmail.com>
* Copyright 2009 - 2011 Red Hat, Inc.
*/
#include "nm-device-adsl.h"
#include "nm-device-private.h"
#include "nm-object-private.h"
#include "nm-setting-adsl.h"
#include <string.h>
G_DEFINE_TYPE (NMDeviceAdsl, nm_device_adsl, NM_TYPE_DEVICE)
#define NM_DEVICE_ADSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_ADSL, NMDeviceAdslPrivate))
typedef struct {
DBusGProxy *proxy;
gboolean carrier;
gboolean disposed;
} NMDeviceAdslPrivate;
enum {
PROP_0,
PROP_CARRIER,
LAST_PROP
};
#define DBUS_PROP_CARRIER "Carrier"
/**
* nm_device_adsl_error_quark:
*
* Registers an error quark for #NMDeviceAdsl if necessary.
*
* Returns: the error quark used for #NMDeviceAdsl errors.
**/
GQuark
nm_device_adsl_error_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("nm-device-adsl-error-quark");
return quark;
}
/**
* nm_device_adsl_new:
* @connection: the #DBusGConnection
* @path: the DBus object path of the device
*
* Creates a new #NMDeviceAdsl.
*
* Returns: a new device
**/
GObject *
nm_device_adsl_new (DBusGConnection *connection, const char *path)
{
GObject *device;
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);
device = g_object_new (NM_TYPE_DEVICE_ADSL,
NM_OBJECT_DBUS_CONNECTION, connection,
NM_OBJECT_DBUS_PATH, path,
NULL);
_nm_object_ensure_inited (NM_OBJECT (device));
return device;
}
/**
* nm_device_adsl_get_carrier:
* @device: a #NMDeviceAdsl
*
* Whether the device has carrier.
*
* Returns: %TRUE if the device has carrier
**/
gboolean
nm_device_adsl_get_carrier (NMDeviceAdsl *device)
{
g_return_val_if_fail (NM_IS_DEVICE_ADSL (device), FALSE);
_nm_object_ensure_inited (NM_OBJECT (device));
return NM_DEVICE_ADSL_GET_PRIVATE (device)->carrier;
}
static gboolean
connection_compatible (NMDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
NMSettingAdsl *s_adsl;
const char *ctype;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
ctype = nm_setting_connection_get_connection_type (s_con);
if (strcmp (ctype, NM_SETTING_ADSL_SETTING_NAME) != 0) {
g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION,
"The connection was not an ADSL connection.");
return FALSE;
}
s_adsl = nm_connection_get_setting_adsl (connection);
if (!s_adsl) {
g_set_error (error, NM_DEVICE_ADSL_ERROR, NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION,
"The connection was not a valid ADSL connection.");
return FALSE;
}
return TRUE;
}
/******************************************************************/
static void
nm_device_adsl_init (NMDeviceAdsl *device)
{
_nm_device_set_device_type (NM_DEVICE (device), NM_DEVICE_TYPE_ADSL);
}
static void
register_properties (NMDeviceAdsl *device)
{
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (device);
const NMPropertiesInfo property_info[] = {
{ NM_DEVICE_ADSL_CARRIER, &priv->carrier },
{ NULL },
};
_nm_object_register_properties (NM_OBJECT (device),
priv->proxy,
property_info);
}
static void
constructed (GObject *object)
{
NMDeviceAdslPrivate *priv;
G_OBJECT_CLASS (nm_device_adsl_parent_class)->constructed (object);
priv = NM_DEVICE_ADSL_GET_PRIVATE (object);
priv->proxy = dbus_g_proxy_new_for_name (nm_object_get_connection (NM_OBJECT (object)),
NM_DBUS_SERVICE,
nm_object_get_path (NM_OBJECT (object)),
NM_DBUS_INTERFACE_DEVICE_ADSL);
register_properties (NM_DEVICE_ADSL (object));
}
static void
dispose (GObject *object)
{
NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (object);
if (priv->disposed) {
G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object);
return;
}
priv->disposed = TRUE;
g_object_unref (priv->proxy);
G_OBJECT_CLASS (nm_device_adsl_parent_class)->dispose (object);
}
static void
finalize (GObject *object)
{
G_OBJECT_CLASS (nm_device_adsl_parent_class)->finalize (object);
}
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
NMDeviceAdsl *device = NM_DEVICE_ADSL (object);
switch (prop_id) {
case PROP_CARRIER:
g_value_set_boolean (value, nm_device_adsl_get_carrier (device));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_device_adsl_class_init (NMDeviceAdslClass *adsl_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (adsl_class);
NMDeviceClass *device_class = NM_DEVICE_CLASS (adsl_class);
g_type_class_add_private (object_class, sizeof (NMDeviceAdslPrivate));
/* virtual methods */
object_class->constructed = constructed;
object_class->dispose = dispose;
object_class->finalize = finalize;
object_class->get_property = get_property;
device_class->connection_compatible = connection_compatible;
/* properties */
/**
* NMDeviceAdsl:carrier:
*
* Whether the device has carrier.
**/
g_object_class_install_property
(object_class, PROP_CARRIER,
g_param_spec_boolean (NM_DEVICE_ADSL_CARRIER,
"Carrier",
"Carrier",
FALSE,
G_PARAM_READABLE));
}
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* libnm_glib -- Access network status & information from glib applications
*
* 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.
*
* Copyright (C) 2011 Pantelis Koukousoulas <pktoss@gmail.com>
*/
#ifndef NM_DEVICE_ADSL_H
#define NM_DEVICE_ADSL_H
#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 ((obj), NM_TYPE_DEVICE_ADSL))
#define NM_DEVICE_ADSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_ADSL, NMDeviceAdslClass))
/**
* NMDeviceAdslError:
* @NM_DEVICE_ADSL_ERROR_UNKNOWN: unknown or unclassified error
* @NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION: the connection was not of ADSL type
* @NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION: the ADSL connection was invalid
*/
typedef enum {
NM_DEVICE_ADSL_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
NM_DEVICE_ADSL_ERROR_NOT_ADSL_CONNECTION, /*< nick=NotAdslConnection >*/
NM_DEVICE_ADSL_ERROR_INVALID_ADSL_CONNECTION, /*< nick=InvalidAdslConnection >*/
} NMDeviceAdslError;
#define NM_DEVICE_ADSL_ERROR nm_device_adsl_error_quark ()
GQuark nm_device_adsl_error_quark (void);
#define NM_DEVICE_ADSL_CARRIER "carrier"
typedef struct {
NMDevice parent;
} NMDeviceAdsl;
typedef struct {
NMDeviceClass parent;
/* Padding for future expansion */
void (*_reserved1) (void);
void (*_reserved2) (void);
void (*_reserved3) (void);
void (*_reserved4) (void);
void (*_reserved5) (void);
void (*_reserved6) (void);
} NMDeviceAdslClass;
GType nm_device_adsl_get_type (void);
GObject *nm_device_adsl_new (DBusGConnection *connection, const char *path);
gboolean nm_device_adsl_get_carrier (NMDeviceAdsl *device);
G_END_DECLS
#endif /* NM_DEVICE_ADSL_H */
......@@ -27,6 +27,7 @@
#include "NetworkManager.h"
#include "nm-device-ethernet.h"
#include "nm-device-adsl.h"
#include "nm-device-wifi.h"
#include "nm-device-modem.h"
#include "nm-device-bt.h"
......@@ -207,6 +208,8 @@ _nm_device_gtype_from_dtype (NMDeviceType dtype)
return NM_TYPE_DEVICE_MODEM;
case NM_DEVICE_TYPE_BT:
return NM_TYPE_DEVICE_BT;
case NM_DEVICE_TYPE_ADSL:
return NM_TYPE_DEVICE_ADSL;
case NM_DEVICE_TYPE_OLPC_MESH:
return NM_TYPE_DEVICE_OLPC_MESH;
case NM_DEVICE_TYPE_WIMAX:
......
......@@ -15,6 +15,7 @@ global:
nm_connection_get_path;
nm_connection_get_setting;
nm_connection_get_setting_802_1x;
nm_connection_get_setting_adsl;
nm_connection_get_setting_bluetooth;
nm_connection_get_setting_bond;
nm_connection_get_setting_by_name;
......@@ -32,7 +33,6 @@ 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;
......@@ -174,14 +174,14 @@ global:
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_encapsulation;
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_get_username;
nm_setting_adsl_get_vci;
nm_setting_adsl_get_vpi;
nm_setting_adsl_new;
nm_setting_bluetooth_error_get_type;
nm_setting_bluetooth_error_quark;
......
......@@ -41,6 +41,7 @@
#include "nm-setting-pppoe.h"
#include "nm-setting-wimax.h"
#include "nm-setting-wired.h"
#include "nm-setting-adsl.h"
#include "nm-setting-wireless.h"
#include "nm-setting-wireless-security.h"
#include "nm-setting-serial.h"
......@@ -117,7 +118,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
static GHashTable *registered_settings = NULL;
#define DEFAULT_MAP_SIZE 19
#define DEFAULT_MAP_SIZE 20
static struct SettingInfo {
const char *name;
......@@ -259,6 +260,11 @@ register_default_settings (void)
NM_SETTING_PPPOE_ERROR,
3, TRUE);
register_one_setting (NM_SETTING_ADSL_SETTING_NAME,
NM_TYPE_SETTING_ADSL,
NM_SETTING_ADSL_ERROR,
3, TRUE);
register_one_setting (NM_SETTING_802_1X_SETTING_NAME,
NM_TYPE_SETTING_802_1X,
NM_SETTING_802_1X_ERROR,
......@@ -1624,6 +1630,23 @@ nm_connection_get_setting_wired (NMConnection *connection)
return (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
}
/**
* nm_connection_get_setting_adsl:
* @connection: the #NMConnection
*
* A shortcut to return any #NMSettingAdsl the connection might contain.
*
* Returns: (transfer none): an #NMSettingAdsl if the connection contains one, otherwise NULL
**/
NMSettingAdsl *
nm_connection_get_setting_adsl (NMConnection *connection)
{
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
return (NMSettingAdsl *) nm_connection_get_setting (connection, NM_TYPE_SETTING_ADSL);
}
/**
* nm_connection_get_setting_wireless:
* @connection: the #NMConnection
......
......@@ -46,6 +46,7 @@
#include <nm-setting-vpn.h>
#include <nm-setting-wimax.h>
#include <nm-setting-wired.h>
#include <nm-setting-adsl.h>
#include <nm-setting-wireless.h>
#include <nm-setting-wireless-security.h>
#include <nm-setting-vlan.h>
......@@ -199,6 +200,7 @@ NMSettingPPPOE * nm_connection_get_setting_pppoe (NMConnec
NMSettingSerial * nm_connection_get_setting_serial (NMConnection *connection);
NMSettingVPN * nm_connection_get_setting_vpn (NMConnection *connection);
NMSettingWimax * nm_connection_get_setting_wimax (NMConnection *connection);
NMSettingAdsl * nm_connection_get_setting_adsl (NMConnection *connection);
NMSettingWired * nm_connection_get_setting_wired (NMConnection *connection);
NMSettingWireless * nm_connection_get_setting_wireless (NMConnection *connection);
NMSettingWirelessSecurity *nm_connection_get_setting_wireless_security (NMConnection *connection);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment