summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-05-22 15:41:29 +0200
committerLubomir Rintel <lkundrak@v3.sk>2018-06-26 16:21:55 +0200
commit7c1f3650a14cd565533475515e0e3ed1c26c8fce (patch)
treea14d2aa4483c7ea7c3c851ed2f5e36b318372065
parent2af11440f905eef8c515ff0e4ae11963b95c26c5 (diff)
downloadNetworkManager-7c1f3650a14cd565533475515e0e3ed1c26c8fce.tar.gz
core: add NMSetting6Lowpan
-rw-r--r--Makefile.am2
-rw-r--r--clients/common/settings-docs.h.in2
-rw-r--r--libnm-core/meson.build2
-rw-r--r--libnm-core/nm-connection.c21
-rw-r--r--libnm-core/nm-connection.h2
-rw-r--r--libnm-core/nm-core-internal.h1
-rw-r--r--libnm-core/nm-core-types.h1
-rw-r--r--libnm-core/nm-setting-6lowpan.c229
-rw-r--r--libnm-core/nm-setting-6lowpan.h52
-rw-r--r--libnm/NetworkManager.h1
-rw-r--r--libnm/libnm.ver1
-rw-r--r--po/POTFILES.in1
12 files changed, 314 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 905a12827a..1f25c8387e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -394,6 +394,7 @@ libnm_core_lib_h_pub_real = \
libnm-core/nm-core-types.h \
libnm-core/nm-dbus-interface.h \
libnm-core/nm-errors.h \
+ libnm-core/nm-setting-6lowpan.h \
libnm-core/nm-setting-8021x.h \
libnm-core/nm-setting-adsl.h \
libnm-core/nm-setting-bluetooth.h \
@@ -463,6 +464,7 @@ libnm_core_lib_h_priv = \
libnm-core/nm-setting-private.h \
libnm-core/nm-utils-private.h
libnm_core_lib_c_settings_real = \
+ libnm-core/nm-setting-6lowpan.c \
libnm-core/nm-setting-8021x.c \
libnm-core/nm-setting-adsl.c \
libnm-core/nm-setting-bluetooth.c \
diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in
index e82d492f83..e6a2f6f30a 100644
--- a/clients/common/settings-docs.h.in
+++ b/clients/common/settings-docs.h.in
@@ -1,5 +1,7 @@
/* Generated file. Do not edit. */
+#define DESCRIBE_DOC_NM_SETTING_6LOWPAN_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
+#define DESCRIBE_DOC_NM_SETTING_6LOWPAN_PARENT N_("If given, specifies the parent interface name or parent connection UUID from which this 6LowPAN interface should be created.")
#define DESCRIBE_DOC_NM_SETTING_OLPC_MESH_CHANNEL N_("Channel on which the mesh network to join is located.")
#define DESCRIBE_DOC_NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS N_("Anycast DHCP MAC address used when requesting an IP address via DHCP. The specific anycast address used determines which DHCP server class answers the request.")
#define DESCRIBE_DOC_NM_SETTING_OLPC_MESH_NAME N_("The setting's name, which uniquely identifies the setting within the connection. Each setting type has a name unique to that type, for example \"ppp\" or \"wireless\" or \"wired\".")
diff --git a/libnm-core/meson.build b/libnm-core/meson.build
index 15d68bdb6c..39ea608c44 100644
--- a/libnm-core/meson.build
+++ b/libnm-core/meson.build
@@ -5,6 +5,7 @@ libnm_core_headers = files(
'nm-core-types.h',
'nm-dbus-interface.h',
'nm-errors.h',
+ 'nm-setting-6lowpan.h',
'nm-setting-8021x.h',
'nm-setting-adsl.h',
'nm-setting-bluetooth.h',
@@ -56,6 +57,7 @@ libnm_core_headers = files(
)
libnm_core_settings_sources = files(
+ 'nm-setting-6lowpan.c',
'nm-setting-8021x.c',
'nm-setting-adsl.c',
'nm-setting-bluetooth.c',
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 421c8ce667..8a66afc61a 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -833,6 +833,8 @@ _supports_addr_family (NMConnection *self, int family)
return TRUE;
if (strcmp (connection_type, NM_SETTING_WPAN_SETTING_NAME) == 0)
return FALSE;
+ if (strcmp (connection_type, NM_SETTING_6LOWPAN_SETTING_NAME) == 0)
+ return family == AF_INET6 || family == AF_UNSPEC;
return !nm_setting_connection_get_master (nm_connection_get_setting_connection (self));
}
@@ -2100,7 +2102,8 @@ nm_connection_is_virtual (NMConnection *connection)
if (!type)
return FALSE;
- if ( !strcmp (type, NM_SETTING_BOND_SETTING_NAME)
+ if ( !strcmp (type, NM_SETTING_6LOWPAN_SETTING_NAME)
+ || !strcmp (type, NM_SETTING_BOND_SETTING_NAME)
|| !strcmp (type, NM_SETTING_DUMMY_SETTING_NAME)
|| !strcmp (type, NM_SETTING_TEAM_SETTING_NAME)
|| !strcmp (type, NM_SETTING_BRIDGE_SETTING_NAME)
@@ -2181,6 +2184,22 @@ nm_connection_get_virtual_device_description (NMConnection *connection)
/*****************************************************************************/
/**
+ * nm_connection_get_setting_6lowpan:
+ * @connection: the #NMConnection
+ *
+ * A shortcut to return any #NMSetting6Lowpan the connection might contain.
+ *
+ * Returns: (transfer none): an #NMSetting6Lowpan if the connection contains one, otherwise %NULL
+ *
+ * Since: 1.14
+ **/
+NMSetting6Lowpan *
+nm_connection_get_setting_6lowpan (NMConnection *connection)
+{
+ return _connection_get_setting_check (connection, NM_TYPE_SETTING_6LOWPAN);
+}
+
+/**
* nm_connection_get_setting_802_1x:
* @connection: the #NMConnection
*
diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h
index 97fd8844ae..8f65e9fce9 100644
--- a/libnm-core/nm-connection.h
+++ b/libnm-core/nm-connection.h
@@ -193,6 +193,8 @@ const char * nm_connection_get_connection_type (NMConnection *connection);
gboolean nm_connection_is_virtual (NMConnection *connection);
char * nm_connection_get_virtual_device_description (NMConnection *connection);
+NM_AVAILABLE_IN_1_14
+NMSetting6Lowpan * nm_connection_get_setting_6lowpan (NMConnection *connection);
NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection);
NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection);
NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection);
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index 17fe8923e7..8413bf99fa 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -37,6 +37,7 @@
#include "nm-connection.h"
#include "nm-core-enum-types.h"
+#include "nm-setting-6lowpan.h"
#include "nm-setting-8021x.h"
#include "nm-setting-adsl.h"
#include "nm-setting-bluetooth.h"
diff --git a/libnm-core/nm-core-types.h b/libnm-core/nm-core-types.h
index f127b9fde5..73ba579489 100644
--- a/libnm-core/nm-core-types.h
+++ b/libnm-core/nm-core-types.h
@@ -29,6 +29,7 @@
typedef struct _NMConnection NMConnection;
typedef struct _NMSetting NMSetting;
+typedef struct _NMSetting6Lowpan NMSetting6Lowpan;
typedef struct _NMSetting8021x NMSetting8021x;
typedef struct _NMSettingAdsl NMSettingAdsl;
typedef struct _NMSettingBluetooth NMSettingBluetooth;
diff --git a/libnm-core/nm-setting-6lowpan.c b/libnm-core/nm-setting-6lowpan.c
new file mode 100644
index 0000000000..3ea1c69b4b
--- /dev/null
+++ b/libnm-core/nm-setting-6lowpan.c
@@ -0,0 +1,229 @@
+/*
+ * 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 2018 Red Hat, Inc.
+ */
+
+#include "nm-default.h"
+
+#include "nm-setting-private.h"
+#include "nm-setting-6lowpan.h"
+
+NM_GOBJECT_PROPERTIES_DEFINE_BASE (
+ PROP_PARENT,
+);
+
+typedef struct {
+ char *parent;
+} NMSetting6LowpanPrivate;
+
+/**
+ * NMSetting6Lowpan:
+ *
+ * 6LoWPAN Settings
+ */
+struct _NMSetting6Lowpan {
+ NMSetting parent;
+};
+
+typedef struct {
+ NMSettingClass parent;
+} NMSetting6LowpanClass;
+
+/**
+ * SECTION:nm-setting-6lowpan
+ * @short_description: Describes connection properties for 6LoWPAN interfaces
+ *
+ * The #NMSetting6Lowpan object is a #NMSetting subclass that describes properties
+ * necessary for connection to 6LoWPAN interfaces.
+ **/
+
+G_DEFINE_TYPE_WITH_CODE (NMSetting6Lowpan, nm_setting_6lowpan, NM_TYPE_SETTING,
+ _nm_register_setting (6LOWPAN, NM_SETTING_PRIORITY_HW_BASE))
+NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_6LOWPAN)
+
+#define NM_SETTING_6LOWPAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_6LOWPAN, NMSetting6LowpanPrivate))
+
+
+/**
+ * nm_setting_6lowpan_new:
+ *
+ * Creates a new #NMSetting6Lowpan object with default values.
+ *
+ * Returns: (transfer full): the new empty #NMSetting6Lowpan object
+ *
+ * Since: 1.14
+ **/
+NMSetting *
+nm_setting_6lowpan_new (void)
+{
+ return (NMSetting *) g_object_new (NM_TYPE_SETTING_6LOWPAN, NULL);
+}
+
+/**
+ * nm_setting_6lowpan_get_parent:
+ * @setting: the #NMSetting6Lowpan
+ *
+ * Returns: the #NMSetting6Lowpan:parent property of the setting
+ *
+ * Since: 1.14
+ **/
+const char *
+nm_setting_6lowpan_get_parent (NMSetting6Lowpan *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_6LOWPAN (setting), NULL);
+ return NM_SETTING_6LOWPAN_GET_PRIVATE (setting)->parent;
+}
+
+/*********************************************************************/
+
+static gboolean
+verify (NMSetting *setting, NMConnection *connection, GError **error)
+{
+ NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
+ NMSettingConnection *s_con = NULL;
+
+ if (connection)
+ s_con = nm_connection_get_setting_connection (connection);
+
+ if (!priv->parent) {
+ g_set_error (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_MISSING_PROPERTY,
+ _("property is not specified"));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_6LOWPAN_SETTING_NAME, NM_SETTING_6LOWPAN_PARENT);
+ return FALSE;
+ }
+
+
+
+ if (nm_utils_is_uuid (priv->parent)) {
+ /* If we have an NMSettingConnection:master with slave-type="6lowpan",
+ * then it must be the same UUID.
+ */
+ if (s_con) {
+ const char *master = NULL, *slave_type = NULL;
+
+ slave_type = nm_setting_connection_get_slave_type (s_con);
+ if (!g_strcmp0 (slave_type, NM_SETTING_6LOWPAN_SETTING_NAME))
+ master = nm_setting_connection_get_master (s_con);
+
+ if (master && g_strcmp0 (priv->parent, master) != 0) {
+ g_set_error (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("'%s' value doesn't match '%s=%s'"),
+ priv->parent, NM_SETTING_CONNECTION_MASTER, master);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_6LOWPAN_SETTING_NAME, NM_SETTING_6LOWPAN_PARENT);
+ return FALSE;
+ }
+ }
+ } else if (!nm_utils_iface_valid_name (priv->parent)) {
+ /* parent must be either a UUID or an interface name */
+ g_set_error (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("'%s' is neither an UUID nor an interface name"),
+ priv->parent);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_6LOWPAN_SETTING_NAME, NM_SETTING_6LOWPAN_PARENT);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+nm_setting_6lowpan_init (NMSetting6Lowpan *setting)
+{
+}
+
+static void
+set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
+ NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
+
+ switch (prop_id) {
+ case PROP_PARENT:
+ g_free (priv->parent);
+ priv->parent = 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)
+{
+ NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
+ NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
+
+ switch (prop_id) {
+ case PROP_PARENT:
+ g_value_set_string (value, priv->parent);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+finalize (GObject *object)
+{
+ NMSetting6Lowpan *setting = NM_SETTING_6LOWPAN (object);
+ NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE (setting);
+
+ g_free (priv->parent);
+
+ G_OBJECT_CLASS (nm_setting_6lowpan_parent_class)->finalize (object);
+}
+
+static void
+nm_setting_6lowpan_class_init (NMSetting6LowpanClass *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 (NMSetting6LowpanPrivate));
+
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
+ object_class->finalize = finalize;
+ parent_class->verify = verify;
+
+ /**
+ * NMSetting6Lowpan:parent:
+ *
+ * If given, specifies the parent interface name or parent connection UUID
+ * from which this 6LowPAN interface should be created.
+ *
+ * Since: 1.14
+ **/
+ obj_properties[PROP_PARENT] =
+ g_param_spec_string (NM_SETTING_6LOWPAN_PARENT, "", "",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ NM_SETTING_PARAM_INFERRABLE |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
+}
diff --git a/libnm-core/nm-setting-6lowpan.h b/libnm-core/nm-setting-6lowpan.h
new file mode 100644
index 0000000000..5663bdde33
--- /dev/null
+++ b/libnm-core/nm-setting-6lowpan.h
@@ -0,0 +1,52 @@
+/*
+ * 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 2018 Red Hat, Inc.
+ */
+
+#ifndef __NM_SETTING_6LOWPAN_H__
+#define __NM_SETTING_6LOWPAN_H__
+
+#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
+#error "Only <NetworkManager.h> can be included directly."
+#endif
+
+#include "nm-setting.h"
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_SETTING_6LOWPAN (nm_setting_6lowpan_get_type ())
+#define NM_SETTING_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_6LOWPAN, NMSetting6Lowpan))
+#define NM_SETTING_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_6LOWPANCONFIG, NMSetting6LowpanClass))
+#define NM_IS_SETTING_6LOWPAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_6LOWPAN))
+#define NM_IS_SETTING_6LOWPAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_6LOWPAN))
+#define NM_SETTING_6LOWPAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_6LOWPAN, NMSetting6LowpanClass))
+
+#define NM_SETTING_6LOWPAN_SETTING_NAME "6lowpan"
+
+#define NM_SETTING_6LOWPAN_PARENT "parent"
+
+NM_AVAILABLE_IN_1_14
+GType nm_setting_6lowpan_get_type (void);
+NM_AVAILABLE_IN_1_14
+NMSetting *nm_setting_6lowpan_new (void);
+
+NM_AVAILABLE_IN_1_14
+const char *nm_setting_6lowpan_get_parent (NMSetting6Lowpan *setting);
+
+G_END_DECLS
+
+#endif /* __NM_SETTING_6LOWPAN_H__ */
diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h
index 05557ec6f3..9b62d969dc 100644
--- a/libnm/NetworkManager.h
+++ b/libnm/NetworkManager.h
@@ -59,6 +59,7 @@
#include "nm-ip-config.h"
#include "nm-object.h"
#include "nm-remote-connection.h"
+#include "nm-setting-6lowpan.h"
#include "nm-setting-8021x.h"
#include "nm-setting-adsl.h"
#include "nm-setting-bluetooth.h"
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index a0e4d4385e..f8423d789d 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1355,6 +1355,7 @@ global:
nm_ip_tunnel_flags_get_type;
nm_remote_connection_get_filename;
nm_remote_connection_get_flags;
+ nm_setting_6lowpan_get_type;
nm_setting_connection_get_mdns;
nm_setting_connection_mdns_get_type;
nm_setting_ip_tunnel_get_flags;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c414f828e9..f9b99f3430 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -57,6 +57,7 @@ libnm-core/crypto_nss.c
libnm-core/nm-connection.c
libnm-core/nm-dbus-utils.c
libnm-core/nm-keyfile.c
+libnm-core/nm-setting-6lowpan.c
libnm-core/nm-setting-8021x.c
libnm-core/nm-setting-adsl.c
libnm-core/nm-setting-bluetooth.c