From 1bf2d3b0495ce56132e601f6d68f403c99889739 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 31 Jan 2017 14:13:35 +0100 Subject: [PATCH] libnm-core: add dummy connection setting The setting must be present in connections with type=dummy. It does not contain any property. --- Makefile.am | 2 ++ libnm-core/nm-connection.c | 19 +++++++++++ libnm-core/nm-connection.h | 2 ++ libnm-core/nm-core-internal.h | 1 + libnm-core/nm-core-types.h | 1 + libnm-core/nm-setting-dummy.c | 62 ++++++++++++++++++++++++++++++++++ libnm-core/nm-setting-dummy.h | 63 +++++++++++++++++++++++++++++++++++ libnm/NetworkManager.h | 1 + libnm/libnm.ver | 3 ++ 9 files changed, 154 insertions(+) create mode 100644 libnm-core/nm-setting-dummy.c create mode 100644 libnm-core/nm-setting-dummy.h diff --git a/Makefile.am b/Makefile.am index e88277f221..f153af990c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -374,6 +374,7 @@ libnm_core_lib_h_pub_real = \ libnm-core/nm-setting-cdma.h \ libnm-core/nm-setting-connection.h \ libnm-core/nm-setting-dcb.h \ + libnm-core/nm-setting-dummy.h \ libnm-core/nm-setting-generic.h \ libnm-core/nm-setting-gsm.h \ libnm-core/nm-setting-infiniband.h \ @@ -439,6 +440,7 @@ libnm_core_lib_c_real = \ libnm-core/nm-setting-cdma.c \ libnm-core/nm-setting-connection.c \ libnm-core/nm-setting-dcb.c \ + libnm-core/nm-setting-dummy.c \ libnm-core/nm-setting-generic.c \ libnm-core/nm-setting-gsm.c \ libnm-core/nm-setting-infiniband.c \ diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 98899ef7b7..ce6f405c35 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -1845,6 +1845,7 @@ nm_connection_is_virtual (NMConnection *connection) g_return_val_if_fail (type != NULL, FALSE); if ( !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) || !strcmp (type, NM_SETTING_VLAN_SETTING_NAME) @@ -2054,6 +2055,24 @@ nm_connection_get_setting_dcb (NMConnection *connection) return (NMSettingDcb *) nm_connection_get_setting (connection, NM_TYPE_SETTING_DCB); } +/** + * nm_connection_get_setting_dummy: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingDummy the connection might contain. + * + * Returns: (transfer none): an #NMSettingDummy if the connection contains one, otherwise %NULL + * + * Since: 1.8 + **/ +NMSettingDummy * +nm_connection_get_setting_dummy (NMConnection *connection) +{ + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + return (NMSettingDummy *) nm_connection_get_setting (connection, NM_TYPE_SETTING_DUMMY); +} + /** * nm_connection_get_setting_generic: * @connection: the #NMConnection diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h index 36ef7b6f34..032d9d7eb0 100644 --- a/libnm-core/nm-connection.h +++ b/libnm-core/nm-connection.h @@ -199,6 +199,8 @@ NMSettingBridgePort * nm_connection_get_setting_bridge_port (NMConnec NMSettingCdma * nm_connection_get_setting_cdma (NMConnection *connection); NMSettingConnection * nm_connection_get_setting_connection (NMConnection *connection); NMSettingDcb * nm_connection_get_setting_dcb (NMConnection *connection); +NM_AVAILABLE_IN_1_8 +NMSettingDummy * nm_connection_get_setting_dummy (NMConnection *connection); NMSettingGeneric * nm_connection_get_setting_generic (NMConnection *connection); NMSettingGsm * nm_connection_get_setting_gsm (NMConnection *connection); NMSettingInfiniband * nm_connection_get_setting_infiniband (NMConnection *connection); diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index f5b4184234..71e0ff893b 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -45,6 +45,7 @@ #include "nm-setting-cdma.h" #include "nm-setting-connection.h" #include "nm-setting-dcb.h" +#include "nm-setting-dummy.h" #include "nm-setting-generic.h" #include "nm-setting-gsm.h" #include "nm-setting-infiniband.h" diff --git a/libnm-core/nm-core-types.h b/libnm-core/nm-core-types.h index 2948b5f596..dc13cf0779 100644 --- a/libnm-core/nm-core-types.h +++ b/libnm-core/nm-core-types.h @@ -38,6 +38,7 @@ typedef struct _NMSettingBridgePort NMSettingBridgePort; typedef struct _NMSettingCdma NMSettingCdma; typedef struct _NMSettingConnection NMSettingConnection; typedef struct _NMSettingDcb NMSettingDcb; +typedef struct _NMSettingDummy NMSettingDummy; typedef struct _NMSettingGeneric NMSettingGeneric; typedef struct _NMSettingGsm NMSettingGsm; typedef struct _NMSettingInfiniband NMSettingInfiniband; diff --git a/libnm-core/nm-setting-dummy.c b/libnm-core/nm-setting-dummy.c new file mode 100644 index 0000000000..0934e963ba --- /dev/null +++ b/libnm-core/nm-setting-dummy.c @@ -0,0 +1,62 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * 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 2017 Red Hat, Inc. + */ + +#include "nm-default.h" + +#include "nm-setting-dummy.h" +#include "nm-setting-connection.h" +#include "nm-setting-private.h" + +/** + * SECTION:nm-setting-dummy + * @short_description: Describes connection properties for dummy interfaces + * + * The #NMSettingDummy object is a #NMSetting subclass that describes properties + * necessary for connection to dummy devices + **/ + +G_DEFINE_TYPE_WITH_CODE (NMSettingDummy, nm_setting_dummy, NM_TYPE_SETTING, + _nm_register_setting (DUMMY, 1)) +NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DUMMY) + +/** + * nm_setting_dummy_new: + * + * Creates a new #NMSettingDummy object with default values. + * + * Returns: (transfer full): the new empty #NMSettingDummy object + * + * Since: 1.8 + **/ +NMSetting * +nm_setting_dummy_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_DUMMY, NULL); +} + +static void +nm_setting_dummy_init (NMSettingDummy *setting) +{ +} + +static void +nm_setting_dummy_class_init (NMSettingDummyClass *setting_class) +{ +} diff --git a/libnm-core/nm-setting-dummy.h b/libnm-core/nm-setting-dummy.h new file mode 100644 index 0000000000..fdeb76059f --- /dev/null +++ b/libnm-core/nm-setting-dummy.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * 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 2017 Red Hat, Inc. + */ + +#ifndef __NM_SETTING_DUMMY_H__ +#define __NM_SETTING_DUMMY_H__ + +#if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-setting.h" + +G_BEGIN_DECLS + +#define NM_TYPE_SETTING_DUMMY (nm_setting_dummy_get_type ()) +#define NM_SETTING_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_DUMMY, NMSettingDummy)) +#define NM_SETTING_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_DUMMYCONFIG, NMSettingDummyClass)) +#define NM_IS_SETTING_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_DUMMY)) +#define NM_IS_SETTING_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_DUMMY)) +#define NM_SETTING_DUMMY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_DUMMY, NMSettingDummyClass)) + +#define NM_SETTING_DUMMY_SETTING_NAME "dummy" + +/** + * NMSettingDummy: + */ +struct _NMSettingDummy { + NMSetting parent; +}; + +typedef struct { + NMSettingClass parent; + + /*< private >*/ + gpointer padding[4]; +} NMSettingDummyClass; + +NM_AVAILABLE_IN_1_8 +GType nm_setting_dummy_get_type (void); +NM_AVAILABLE_IN_1_8 +NMSetting *nm_setting_dummy_new (void); + +G_END_DECLS + +#endif /* __NM_SETTING_DUMMY_H__ */ diff --git a/libnm/NetworkManager.h b/libnm/NetworkManager.h index d0dec1a019..747510a268 100644 --- a/libnm/NetworkManager.h +++ b/libnm/NetworkManager.h @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 5473ffaa2f..bfcec2639d 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1146,6 +1146,7 @@ global: libnm_1_8_0 { global: + nm_connection_get_setting_dummy; nm_setting_802_1x_auth_flags_get_type; nm_setting_802_1x_get_auth_timeout; nm_setting_802_1x_get_ca_cert_password; @@ -1158,5 +1159,7 @@ global: nm_setting_802_1x_get_phase2_client_cert_password; nm_setting_802_1x_get_phase2_client_cert_password_flags; nm_setting_cdma_get_mtu; + nm_setting_dummy_get_type; + nm_setting_dummy_new; nm_setting_gsm_get_mtu; } libnm_1_6_0;