summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2013-07-25 15:36:46 +0200
committerDan Williams <dcbw@redhat.com>2013-08-15 10:54:14 -0500
commit64cdb1a7f03c59f869b5a68bb2ac6355f89ef079 (patch)
tree2ff16112adf20ab51569f0cf5236c8a39b2cdcb3
parent3dcb7935a536d27911c081d70f093333282eda91 (diff)
libnm-util: add setting for team port
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
-rw-r--r--libnm-util/Makefile.am2
-rw-r--r--libnm-util/libnm-util.ver6
-rw-r--r--libnm-util/nm-connection.c17
-rw-r--r--libnm-util/nm-connection.h2
-rw-r--r--libnm-util/nm-setting-team-port.c174
-rw-r--r--libnm-util/nm-setting-team-port.h76
6 files changed, 277 insertions, 0 deletions
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am
index 495a42dcd5..554b4a4b1b 100644
--- a/libnm-util/Makefile.am
+++ b/libnm-util/Makefile.am
@@ -19,6 +19,7 @@ libnm_util_include_HEADERS = \
nm-setting-bluetooth.h \
nm-setting-bond.h \
nm-setting-team.h \
+ nm-setting-team-port.h \
nm-setting-bridge.h \
nm-setting-bridge-port.h \
nm-setting-connection.h \
@@ -57,6 +58,7 @@ libnm_util_la_csources = \
nm-setting-bluetooth.c \
nm-setting-bond.c \
nm-setting-team.c \
+ nm-setting-team-port.c \
nm-setting-bridge.c \
nm-setting-bridge-port.c \
nm-setting-connection.c \
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver
index be342adfbe..d3e430cc34 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -33,6 +33,7 @@ global:
nm_connection_get_setting_pppoe;
nm_connection_get_setting_serial;
nm_connection_get_setting_team;
+ nm_connection_get_setting_team_port;
nm_connection_get_setting_vlan;
nm_connection_get_setting_vpn;
nm_connection_get_setting_wimax;
@@ -421,6 +422,11 @@ global:
nm_setting_team_get_interface_name;
nm_setting_team_get_type;
nm_setting_team_new;
+ nm_setting_team_port_error_get_type;
+ nm_setting_team_port_error_quark;
+ nm_setting_team_port_get_config;
+ nm_setting_team_port_get_type;
+ nm_setting_team_port_new;
nm_setting_to_hash;
nm_setting_to_string;
nm_setting_update_secrets;
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 631fdae787..dac66c4767 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -49,6 +49,7 @@
#include "nm-setting-olpc-mesh.h"
#include "nm-setting-bond.h"
#include "nm-setting-team.h"
+#include "nm-setting-team-port.h"
#include "nm-setting-bridge.h"
#include "nm-setting-bridge-port.h"
#include "nm-setting-vlan.h"
@@ -1259,6 +1260,22 @@ nm_connection_get_setting_team (NMConnection *connection)
}
/**
+ * nm_connection_get_setting_team_port:
+ * @connection: the #NMConnection
+ *
+ * A shortcut to return any #NMSettingTeamPort the connection might contain.
+ *
+ * Returns: (transfer none): an #NMSettingTeamPort if the connection contains one, otherwise %NULL
+ **/
+NMSettingTeamPort *
+nm_connection_get_setting_team_port (NMConnection *connection)
+{
+ g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
+
+ return (NMSettingTeamPort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM_PORT);
+}
+
+/**
* nm_connection_get_setting_bridge:
* @connection: the #NMConnection
*
diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h
index 78976284e4..f310319969 100644
--- a/libnm-util/nm-connection.h
+++ b/libnm-util/nm-connection.h
@@ -34,6 +34,7 @@
#include <nm-setting-bluetooth.h>
#include <nm-setting-bond.h>
#include <nm-setting-team.h>
+#include <nm-setting-team-port.h>
#include <nm-setting-bridge.h>
#include <nm-setting-bridge-port.h>
#include <nm-setting-cdma.h>
@@ -202,6 +203,7 @@ NMSetting8021x * nm_connection_get_setting_802_1x (NMConnec
NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection);
NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection);
NMSettingTeam * nm_connection_get_setting_team (NMConnection *connection);
+NMSettingTeamPort * nm_connection_get_setting_team_port (NMConnection *connection);
NMSettingBridge * nm_connection_get_setting_bridge (NMConnection *connection);
NMSettingBridgePort * nm_connection_get_setting_bridge_port (NMConnection *connection);
NMSettingCdma * nm_connection_get_setting_cdma (NMConnection *connection);
diff --git a/libnm-util/nm-setting-team-port.c b/libnm-util/nm-setting-team-port.c
new file mode 100644
index 0000000000..0d650ecefd
--- /dev/null
+++ b/libnm-util/nm-setting-team-port.c
@@ -0,0 +1,174 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
+ *
+ * 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.
+ */
+
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <dbus/dbus-glib.h>
+#include <glib/gi18n.h>
+
+#include "nm-setting-team-port.h"
+#include "nm-utils.h"
+#include "nm-utils-private.h"
+#include "nm-setting-private.h"
+
+/**
+ * SECTION:nm-setting-team-port
+ * @short_description: Describes connection properties for team ports
+ * @include: nm-setting-team-port.h
+ *
+ * The #NMSettingTeamPort object is a #NMSetting subclass that describes
+ * optional properties that apply to team ports.
+ **/
+
+/**
+ * nm_setting_team_port_error_quark:
+ *
+ * Registers an error quark for #NMSettingTeamPort if necessary.
+ *
+ * Returns: the error quark used for #NMSettingTeamPort errors.
+ **/
+GQuark
+nm_setting_team_port_error_quark (void)
+{
+ static GQuark quark;
+
+ if (G_UNLIKELY (!quark))
+ quark = g_quark_from_static_string ("nm-setting-team-port-error-quark");
+ return quark;
+}
+
+G_DEFINE_TYPE_WITH_CODE (NMSettingTeamPort, nm_setting_team_port, NM_TYPE_SETTING,
+ _nm_register_setting (NM_SETTING_TEAM_PORT_SETTING_NAME,
+ g_define_type_id,
+ 3,
+ NM_SETTING_TEAM_PORT_ERROR))
+NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_TEAM_PORT)
+
+#define NM_SETTING_TEAM_PORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortPrivate))
+
+typedef struct {
+ char *config;
+} NMSettingTeamPortPrivate;
+
+enum {
+ PROP_0,
+ PROP_CONFIG,
+ LAST_PROP
+};
+
+/**
+ * nm_setting_team_port_new:
+ *
+ * Creates a new #NMSettingTeamPort object with default values.
+ *
+ * Returns: (transfer full): the new empty #NMSettingTeamPort object
+ **/
+NMSetting *
+nm_setting_team_port_new (void)
+{
+ return (NMSetting *) g_object_new (NM_TYPE_SETTING_TEAM_PORT, NULL);
+}
+
+/**
+ * nm_setting_team_port_get_config:
+ * @setting: the #NMSettingTeamPort
+ *
+ * Returns: the #NMSettingTeamPort:config property of the setting
+ **/
+const char *
+nm_setting_team_port_get_config (NMSettingTeamPort *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_TEAM_PORT (setting), NULL);
+
+ return NM_SETTING_TEAM_PORT_GET_PRIVATE (setting)->config;
+}
+
+static gboolean
+verify (NMSetting *setting, GSList *all_settings, GError **error)
+{
+ return TRUE;
+}
+
+static void
+nm_setting_team_port_init (NMSettingTeamPort *setting)
+{
+ g_object_set (setting, NM_SETTING_NAME, NM_SETTING_TEAM_PORT_SETTING_NAME, NULL);
+}
+
+static void
+set_property (GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (object);
+
+ switch (prop_id) {
+ case PROP_CONFIG:
+ priv->config = 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)
+{
+ NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT (object);
+
+ switch (prop_id) {
+ case PROP_CONFIG:
+ g_value_set_string (value, nm_setting_team_port_get_config (setting));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+nm_setting_team_port_class_init (NMSettingTeamPortClass *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 (NMSettingTeamPortPrivate));
+
+ /* virtual methods */
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
+ parent_class->verify = verify;
+
+ /* Properties */
+ /**
+ * NMSettingTeamPort:config:
+ *
+ * The config of team port
+ **/
+ g_object_class_install_property
+ (object_class, PROP_CONFIG,
+ g_param_spec_string (NM_SETTING_TEAM_PORT_CONFIG,
+ "Config",
+ "The config of team port",
+ NULL,
+ G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
+}
diff --git a/libnm-util/nm-setting-team-port.h b/libnm-util/nm-setting-team-port.h
new file mode 100644
index 0000000000..cd74b6b0ed
--- /dev/null
+++ b/libnm-util/nm-setting-team-port.h
@@ -0,0 +1,76 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2013 Jiri Pirko <jiri@resnulli.us>
+ *
+ * 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.
+ */
+
+#ifndef NM_SETTING_TEAM_PORT_H
+#define NM_SETTING_TEAM_PORT_H
+
+#include <nm-setting.h>
+
+G_BEGIN_DECLS
+
+#define NM_TYPE_SETTING_TEAM_PORT (nm_setting_team_port_get_type ())
+#define NM_SETTING_TEAM_PORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPort))
+#define NM_SETTING_TEAM_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortClass))
+#define NM_IS_SETTING_TEAM_PORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_TEAM_PORT))
+#define NM_IS_SETTING_TEAM_PORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_TEAM_PORT))
+#define NM_SETTING_TEAM_PORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_TEAM_PORT, NMSettingTeamPortClass))
+
+#define NM_SETTING_TEAM_PORT_SETTING_NAME "team-port"
+
+/**
+ * NMSettingTeamPortError:
+ * @NM_SETTING_TEAM_PORT_ERROR_UNKNOWN: unknown or unclassified error
+ * @NM_SETTING_TEAM_PORT_ERROR_INVALID_PROPERTY: the property was invalid
+ * @NM_SETTING_TEAM_PORT_ERROR_MISSING_PROPERTY: the property was missing and
+ * is required
+ */
+typedef enum {
+ NM_SETTING_TEAM_PORT_ERROR_UNKNOWN = 0, /*< nick=UnknownError >*/
+ NM_SETTING_TEAM_PORT_ERROR_INVALID_PROPERTY, /*< nick=InvalidProperty >*/
+ NM_SETTING_TEAM_PORT_ERROR_MISSING_PROPERTY, /*< nick=MissingProperty >*/
+} NMSettingTeamPortError;
+
+#define NM_SETTING_TEAM_PORT_ERROR nm_setting_team_port_error_quark ()
+GQuark nm_setting_team_port_error_quark (void);
+
+#define NM_SETTING_TEAM_PORT_CONFIG "config"
+
+typedef struct {
+ NMSetting parent;
+} NMSettingTeamPort;
+
+typedef struct {
+ NMSettingClass parent;
+
+ /* Padding for future expansion */
+ void (*_reserved1) (void);
+ void (*_reserved2) (void);
+ void (*_reserved3) (void);
+ void (*_reserved4) (void);
+} NMSettingTeamPortClass;
+
+GType nm_setting_team_port_get_type (void);
+
+NMSetting * nm_setting_team_port_new (void);
+const char * nm_setting_team_port_get_config (NMSettingTeamPort *setting);
+
+G_END_DECLS
+
+#endif /* NM_SETTING_TEAM_PORT_H */