diff options
Diffstat (limited to 'libnm-core')
-rw-r--r-- | libnm-core/meson.build | 2 | ||||
-rw-r--r-- | libnm-core/nm-connection.c | 21 | ||||
-rw-r--r-- | libnm-core/nm-connection.h | 2 | ||||
-rw-r--r-- | libnm-core/nm-core-enum-types.c.template | 1 | ||||
-rw-r--r-- | libnm-core/nm-core-internal.h | 1 | ||||
-rw-r--r-- | libnm-core/nm-core-types.h | 1 | ||||
-rw-r--r-- | libnm-core/nm-dbus-interface.h | 5 | ||||
-rw-r--r-- | libnm-core/nm-setting-contrail-vrouter.c | 182 | ||||
-rw-r--r-- | libnm-core/nm-setting-contrail-vrouter.h | 41 |
9 files changed, 255 insertions, 1 deletions
diff --git a/libnm-core/meson.build b/libnm-core/meson.build index 4c72590e7b..ce93b00914 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -25,6 +25,7 @@ libnm_core_headers = files( 'nm-setting-bridge.h', 'nm-setting-cdma.h', 'nm-setting-connection.h', + 'nm-setting-contrail-vrouter.h', 'nm-setting-dcb.h', 'nm-setting-dummy.h', 'nm-setting-ethtool.h', @@ -119,6 +120,7 @@ libnm_core_settings_sources = files( 'nm-setting-bridge.c', 'nm-setting-cdma.c', 'nm-setting-connection.c', + 'nm-setting-contrail-vrouter.c', 'nm-setting-dcb.c', 'nm-setting-dummy.c', 'nm-setting-ethtool.c', diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 307b9d6234..2d9974b476 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -891,6 +891,8 @@ _supports_addr_family (NMConnection *self, int family) g_return_val_if_fail (connection_type, TRUE); if (strcmp (connection_type, NM_SETTING_OVS_INTERFACE_SETTING_NAME) == 0) return TRUE; + if (strcmp (connection_type, NM_SETTING_CONTRAIL_VROUTER_SETTING_NAME) == 0) + return TRUE; if (strcmp (connection_type, NM_SETTING_WPAN_SETTING_NAME) == 0) return FALSE; if (strcmp (connection_type, NM_SETTING_6LOWPAN_SETTING_NAME) == 0) @@ -2694,7 +2696,8 @@ nm_connection_is_virtual (NMConnection *connection) NM_SETTING_TUN_SETTING_NAME, NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VXLAN_SETTING_NAME, - NM_SETTING_WIREGUARD_SETTING_NAME)) + NM_SETTING_WIREGUARD_SETTING_NAME, + NM_SETTING_CONTRAIL_VROUTER_SETTING_NAME)) return TRUE; if (nm_streq (type, NM_SETTING_INFINIBAND_SETTING_NAME)) { @@ -3339,6 +3342,22 @@ _nm_connection_get_setting_bluetooth_for_nap (NMConnection *connection) return NULL; } +/** + * nm_connection_get_setting_contrail_vrouter: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingContrailVrouter the connection might contain. + * + * Returns: (transfer none): an #NMSettingContrailVrouter if the connection contains one, otherwise %NULL + * + * Since: 1.14 + **/ +NMSettingContrailVrouter * +nm_connection_get_setting_contrail_vrouter (NMConnection *connection) +{ + return _connection_get_setting_check (connection, NM_TYPE_SETTING_CONTRAIL_VROUTER); +} + /*****************************************************************************/ static void diff --git a/libnm-core/nm-connection.h b/libnm-core/nm-connection.h index 86041f3601..d619c8d023 100644 --- a/libnm-core/nm-connection.h +++ b/libnm-core/nm-connection.h @@ -190,6 +190,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_14 +NMSettingContrailVrouter * nm_connection_get_setting_contrail_vrouter (NMConnection *connection); NM_AVAILABLE_IN_1_8 NMSettingDummy * nm_connection_get_setting_dummy (NMConnection *connection); NMSettingGeneric * nm_connection_get_setting_generic (NMConnection *connection); diff --git a/libnm-core/nm-core-enum-types.c.template b/libnm-core/nm-core-enum-types.c.template index b6cb38eecc..8f68995f92 100644 --- a/libnm-core/nm-core-enum-types.c.template +++ b/libnm-core/nm-core-enum-types.c.template @@ -16,6 +16,7 @@ #include "nm-setting-bridge.h" #include "nm-setting-cdma.h" #include "nm-setting-connection.h" +#include "nm-setting-contrail-vrouter.h" #include "nm-setting-dcb.h" #include "nm-setting-dummy.h" #include "nm-setting-generic.h" diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index cdd9be88fd..403432c877 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -33,6 +33,7 @@ #include "nm-setting-bridge.h" #include "nm-setting-cdma.h" #include "nm-setting-connection.h" +#include "nm-setting-contrail-vrouter.h" #include "nm-setting-dcb.h" #include "nm-setting-dummy.h" #include "nm-setting-generic.h" diff --git a/libnm-core/nm-core-types.h b/libnm-core/nm-core-types.h index d7c1b5b5b7..951a4bd53f 100644 --- a/libnm-core/nm-core-types.h +++ b/libnm-core/nm-core-types.h @@ -23,6 +23,7 @@ typedef struct _NMSettingBridge NMSettingBridge; typedef struct _NMSettingBridgePort NMSettingBridgePort; typedef struct _NMSettingCdma NMSettingCdma; typedef struct _NMSettingConnection NMSettingConnection; +typedef struct _NMSettingContrailVrouter NMSettingContrailVrouter; typedef struct _NMSettingDcb NMSettingDcb; typedef struct _NMSettingDummy NMSettingDummy; typedef struct _NMSettingEthtool NMSettingEthtool; diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index ae3c41a7a4..f914dab185 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -34,6 +34,7 @@ #define NM_DBUS_INTERFACE_DEVICE_BLUETOOTH NM_DBUS_INTERFACE_DEVICE ".Bluetooth" #define NM_DBUS_INTERFACE_DEVICE_BOND NM_DBUS_INTERFACE_DEVICE ".Bond" #define NM_DBUS_INTERFACE_DEVICE_BRIDGE NM_DBUS_INTERFACE_DEVICE ".Bridge" +#define NM_DBUS_INTERFACE_DEVICE_CONTRAIL_VROUTER NM_DBUS_INTERFACE_DEVICE ".ContrailVrouter" #define NM_DBUS_INTERFACE_DEVICE_DUMMY NM_DBUS_INTERFACE_DEVICE ".Dummy" #define NM_DBUS_INTERFACE_DEVICE_GENERIC NM_DBUS_INTERFACE_DEVICE ".Generic" #define NM_DBUS_INTERFACE_DEVICE_GRE NM_DBUS_INTERFACE_DEVICE ".Gre" @@ -209,6 +210,7 @@ typedef enum { * @NM_DEVICE_TYPE_6LOWPAN: 6LoWPAN interface * @NM_DEVICE_TYPE_WIREGUARD: a WireGuard interface * @NM_DEVICE_TYPE_WIFI_P2P: an 802.11 Wi-Fi P2P device (Since: 1.16) + * @NM_DEVICE_TYPE_CONTRAIL_VROUTER: a Contrail Vrouter * * #NMDeviceType values indicate the type of hardware represented by a * device object. @@ -245,6 +247,7 @@ typedef enum { NM_DEVICE_TYPE_6LOWPAN = 28, NM_DEVICE_TYPE_WIREGUARD = 29, NM_DEVICE_TYPE_WIFI_P2P = 30, + NM_DEVICE_TYPE_CONTRAIL_VROUTER = 31, } NMDeviceType; /** @@ -565,6 +568,7 @@ typedef enum { * @NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED: The selected IP method is not supported * @NM_DEVICE_STATE_REASON_SRIOV_CONFIGURATION_FAILED: configuration of SR-IOV parameters failed * @NM_DEVICE_STATE_REASON_PEER_NOT_FOUND: The Wi-Fi P2P peer could not be found + * @NM_DEVICE_STATE_REASON_CONTRAIL_VROUTER_FAILED: Contrail Vrouter kernel module failed * * Device state change reason codes */ @@ -637,6 +641,7 @@ typedef enum { NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED = 65, NM_DEVICE_STATE_REASON_SRIOV_CONFIGURATION_FAILED = 66, NM_DEVICE_STATE_REASON_PEER_NOT_FOUND = 67, + NM_DEVICE_STATE_REASON_CONTRAIL_VROUTER_FAILED = 68, } NMDeviceStateReason; /** diff --git a/libnm-core/nm-setting-contrail-vrouter.c b/libnm-core/nm-setting-contrail-vrouter.c new file mode 100644 index 0000000000..5cef5e07ce --- /dev/null +++ b/libnm-core/nm-setting-contrail-vrouter.c @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: LGPL-2.1+ +/* + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#include "nm-default.h" + +#include "nm-setting-contrail-vrouter.h" + +#include "nm-connection-private.h" +#include "nm-setting-connection.h" +#include "nm-setting-private.h" + +/** + * SECTION:nm-setting-contrail-vrouter + * @short_description: Describes connection properties for Contrail vrouter. + * + * The #NMSettingContrailVrouter object is a #NMSetting subclass that describes properties + * necessary for Contrail vrouter. + **/ + +enum { + PROP_0, + PROP_PHYSDEV, + LAST_PROP +}; + +/** + * NMSettingContrailVrouter: + * + * Contrail vrouter Settings + */ +struct _NMSettingContrailVrouter { + NMSetting parent; + + char *physdev; +}; + +struct _NMSettingContrailVrouterClass { + NMSettingClass parent; +}; + +G_DEFINE_TYPE (NMSettingContrailVrouter, nm_setting_contrail_vrouter, NM_TYPE_SETTING) + +/*****************************************************************************/ + +/** + * nm_setting_ovs_interface_get_physdev: + * @self: the #NMSettingContrailVrouter + * + * Returns: the #NMSettingContrailVrouter:physdev property of the setting + * + * Since: 1.14 + **/ +const char * +nm_setting_contrail_vrouter_get_physdev (NMSettingContrailVrouter *self) +{ + g_return_val_if_fail (NM_IS_SETTING_CONTRAIL_VROUTER (self), NULL); + + return self->physdev; +} + +/*****************************************************************************/ + +static int +verify (NMSetting *setting, NMConnection *connection, GError **error) +{ + + if (connection) { + NMSettingConnection *s_con; + + s_con = nm_connection_get_setting_connection (connection); + if (!s_con) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_SETTING, + _("missing setting")); + g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME); + return FALSE; + } + } + return TRUE; +} + +/*****************************************************************************/ + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMSettingContrailVrouter *self = NM_SETTING_CONTRAIL_VROUTER (object); + + switch (prop_id) { + case PROP_PHYSDEV: + g_value_set_string (value, self->physdev); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMSettingContrailVrouter *self = NM_SETTING_CONTRAIL_VROUTER (object); + + switch (prop_id) { + case PROP_PHYSDEV: + g_free (self->physdev); + self->physdev = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/*****************************************************************************/ + +static void +nm_setting_contrail_vrouter_init (NMSettingContrailVrouter *self) +{ +} + +/** + * nm_setting_contrail_vrouter_new: + * + * Creates a new #NMSettingContrailVrouter object with default values. + * + * Returns: (transfer full): the new empty #NMSettingContrailVrouter object + * + * Since: 1.14 + **/ +NMSetting * +nm_setting_contrail_vrouter_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_CONTRAIL_VROUTER, NULL); +} + +static void +finalize (GObject *object) +{ + NMSettingContrailVrouter *self = NM_SETTING_CONTRAIL_VROUTER (object); + + g_free (self->physdev); + + G_OBJECT_CLASS (nm_setting_contrail_vrouter_parent_class)->finalize (object); +} + +static void +nm_setting_contrail_vrouter_class_init (NMSettingContrailVrouterClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + NMSettingClass *setting_class = NM_SETTING_CLASS (klass); + + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->finalize = finalize; + + setting_class->verify = verify; + + /** + * NMSettingContrailVrouter:physdev: + * + * The physical device name. + * + * Since: 1.14 + **/ + g_object_class_install_property + (object_class, PROP_PHYSDEV, + g_param_spec_string (NM_SETTING_CONTRAIL_VROUTER_PHYSDEV, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS)); + + _nm_setting_class_commit (setting_class, NM_META_SETTING_TYPE_CONTRAIL_VROUTER); +} diff --git a/libnm-core/nm-setting-contrail-vrouter.h b/libnm-core/nm-setting-contrail-vrouter.h new file mode 100644 index 0000000000..82ebb9b769 --- /dev/null +++ b/libnm-core/nm-setting-contrail-vrouter.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: LGPL-2.1+ +/* + * Copyright (C) 2007 - 2013 Red Hat, Inc. + * Copyright (C) 2007 - 2008 Novell, Inc. + */ + +#ifndef __NM_SETTING_CONTRAIL_VROUTER_H__ +#define __NM_SETTING_CONTRAIL_VROUTER_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_CONTRAIL_VROUTER (nm_setting_contrail_vrouter_get_type ()) +#define NM_SETTING_CONTRAIL_VROUTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_CONTRAIL_VROUTER, NMSettingContrailVrouter)) +#define NM_SETTING_CONTRAIL_VROUTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_CONTRAIL_VROUTERCONFIG, NMSettingContrailVrouterClass)) +#define NM_IS_SETTING_CONTRAIL_VROUTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_CONTRAIL_VROUTER)) +#define NM_IS_SETTING_CONTRAIL_VROUTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_CONTRAIL_VROUTER)) +#define NM_SETTING_CONTRAIL_VROUTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_CONTRAIL_VROUTER, NMSettingContrailVrouterClass)) + +#define NM_SETTING_CONTRAIL_VROUTER_SETTING_NAME "contrail-vrouter" + +#define NM_SETTING_CONTRAIL_VROUTER_PHYSDEV "physdev" + +typedef struct _NMSettingContrailVrouterClass NMSettingContrailVrouterClass; + +NM_AVAILABLE_IN_1_14 +GType nm_setting_contrail_vrouter_get_type (void); +NM_AVAILABLE_IN_1_14 +NMSetting *nm_setting_contrail_vrouter_new (void); + +NM_AVAILABLE_IN_1_14 +const char *nm_setting_contrail_vrouter_get_physdev (NMSettingContrailVrouter *self); + +G_END_DECLS + +#endif /* __NM_SETTING_CONTRAIL_VROUTER_H__ */ |