[patch NetworkManager v3 2/6] add setting for team port
- From: Jiri Pirko <jiri resnulli us>
- To: networkmanager-list gnome org
- Cc: fbl redhat com
- Subject: [patch NetworkManager v3 2/6] add setting for team port
- Date: Thu, 25 Jul 2013 15:36:46 +0200
Signed-off-by: Jiri Pirko <jiri resnulli us>
---
libnm-util/Makefile.am | 2 +
libnm-util/libnm-util.ver | 5 ++
libnm-util/nm-connection.c | 17 ++++
libnm-util/nm-connection.h | 2 +
libnm-util/nm-setting-team-port.c | 174 ++++++++++++++++++++++++++++++++++++++
libnm-util/nm-setting-team-port.h | 76 +++++++++++++++++
6 files changed, 276 insertions(+)
create mode 100644 libnm-util/nm-setting-team-port.c
create mode 100644 libnm-util/nm-setting-team-port.h
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am
index 495a42d..554b4a4 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 f946fb3..512e5bc 100644
--- a/libnm-util/libnm-util.ver
+++ b/libnm-util/libnm-util.ver
@@ -19,6 +19,7 @@ global:
nm_connection_get_setting_bluetooth;
nm_connection_get_setting_bond;
nm_connection_get_setting_team;
+ nm_connection_get_setting_team_port;
nm_connection_get_setting_bridge;
nm_connection_get_setting_bridge_port;
nm_connection_get_setting_by_name;
@@ -211,6 +212,10 @@ global:
nm_setting_team_get_type;
nm_setting_team_new;
nm_setting_team_get_config;
+ nm_setting_team_port_error_quark;
+ nm_setting_team_port_get_type;
+ nm_setting_team_port_new;
+ nm_setting_team_port_get_config;
nm_setting_bridge_error_get_type;
nm_setting_bridge_error_quark;
nm_setting_bridge_get_ageing_time;
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 631fdae..dac66c4 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 7897628..f310319 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 0000000..0d650ec
--- /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 0000000..cd74b6b
--- /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 */
--
1.8.1.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]