diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-06-30 13:58:23 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-08-05 08:03:15 +0200 |
commit | f83e56ec6dbe2b03a2ce19767ff992d2637d8de6 (patch) | |
tree | 8b34ae8e85100a4686beae0a41b62a22a169ee04 | |
parent | c521cffd7bb395e35befd3c9766fab8655cd27f1 (diff) | |
download | NetworkManager-f83e56ec6dbe2b03a2ce19767ff992d2637d8de6.tar.gz |
libnm,clients: add 'parent' property to PPPoE setting
When the property is set, it specifies the device on which PPPoE is to
be started. The ppp interface will be named as the
connection.interface-name property.
When the property is not set the previous behavior will be retained,
i.e. the PPPoE connection will be started on connection.interface-name
and the PPP interface will have a random name.
-rw-r--r-- | clients/common/nm-meta-setting-desc.c | 6 | ||||
-rw-r--r-- | clients/common/settings-docs.c.in | 1 | ||||
-rw-r--r-- | libnm-core/nm-setting-pppoe.c | 55 | ||||
-rw-r--r-- | libnm-core/nm-setting-pppoe.h | 3 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 |
5 files changed, 66 insertions, 0 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index 0928374eb2..9d68b23334 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -5789,6 +5789,12 @@ static const NMMetaPropertyInfo *const property_infos_OLPC_MESH[] = { #undef _CURRENT_NM_META_SETTING_TYPE #define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_PPPOE static const NMMetaPropertyInfo *const property_infos_PPPOE[] = { + PROPERTY_INFO_WITH_DESC (NM_SETTING_PPPOE_PARENT, + .is_cli_option = TRUE, + .property_alias = "parent", + .prompt = N_("PPPoE parent device"), + .property_type = &_pt_gobject_string, + ), PROPERTY_INFO_WITH_DESC (NM_SETTING_PPPOE_SERVICE, .is_cli_option = TRUE, .property_alias = "service", diff --git a/clients/common/settings-docs.c.in b/clients/common/settings-docs.c.in index a8afff5c0a..a4412270ac 100644 --- a/clients/common/settings-docs.c.in +++ b/clients/common/settings-docs.c.in @@ -280,6 +280,7 @@ #define DESCRIBE_DOC_NM_SETTING_PPP_REQUIRE_MPPE N_("If TRUE, MPPE (Microsoft Point-to-Point Encryption) will be required for the PPP session. If either 64-bit or 128-bit MPPE is not available the session will fail. Note that MPPE is not used on mobile broadband connections.") #define DESCRIBE_DOC_NM_SETTING_PPP_REQUIRE_MPPE_128 N_("If TRUE, 128-bit MPPE (Microsoft Point-to-Point Encryption) will be required for the PPP session, and the \"require-mppe\" property must also be set to TRUE. If 128-bit MPPE is not available the session will fail.") #define DESCRIBE_DOC_NM_SETTING_PPPOE_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_PPPOE_PARENT N_("If given, specifies the parent interface name on which this PPPoE connection should be created. If this property is not specified, the connection is activated on the interface specified in \"interface-name\" of NMSettingConnection.") #define DESCRIBE_DOC_NM_SETTING_PPPOE_PASSWORD N_("Password used to authenticate with the PPPoE service.") #define DESCRIBE_DOC_NM_SETTING_PPPOE_PASSWORD_FLAGS N_("Flags indicating how to handle the \"password\" property.") #define DESCRIBE_DOC_NM_SETTING_PPPOE_SERVICE N_("If specified, instruct PPPoE to only initiate sessions with access concentrators that provide the specified service. For most providers, this should be left blank. It is only required if there are multiple access concentrators or a specific service is known to be required.") diff --git a/libnm-core/nm-setting-pppoe.c b/libnm-core/nm-setting-pppoe.c index f72ee27385..3f9c2a9d6d 100644 --- a/libnm-core/nm-setting-pppoe.c +++ b/libnm-core/nm-setting-pppoe.c @@ -45,6 +45,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_PPPOE) #define NM_SETTING_PPPOE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_PPPOE, NMSettingPppoePrivate)) typedef struct { + char *parent; char *service; char *username; char *password; @@ -53,6 +54,7 @@ typedef struct { enum { PROP_0, + PROP_PARENT, PROP_SERVICE, PROP_USERNAME, PROP_PASSWORD, @@ -75,6 +77,22 @@ nm_setting_pppoe_new (void) } /** + * nm_setting_pppoe_get_parent: + * @setting: the #NMSettingPppoe + * + * Returns: the #NMSettingPppoe:parent property of the setting + * + * Since: 1.10 + **/ +const char * +nm_setting_pppoe_get_parent (NMSettingPppoe *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NULL); + + return NM_SETTING_PPPOE_GET_PRIVATE (setting)->parent; +} + +/** * nm_setting_pppoe_get_service: * @setting: the #NMSettingPppoe * @@ -134,6 +152,7 @@ static gboolean verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (setting); + gs_free_error GError *local_error = NULL; if (!priv->username) { g_set_error_literal (error, @@ -160,6 +179,16 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + if ( priv->parent + && !nm_utils_is_valid_iface_name (priv->parent, &local_error)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + "'%s': %s", priv->parent, local_error->message); + g_prefix_error (error, "%s.%s: ", NM_SETTING_PPPOE_SETTING_NAME, NM_SETTING_PPPOE_PARENT); + return FALSE; + } + return TRUE; } @@ -192,6 +221,10 @@ set_property (GObject *object, guint prop_id, NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE (object); switch (prop_id) { + case PROP_PARENT: + g_free (priv->parent); + priv->parent = g_value_dup_string (value); + break; case PROP_SERVICE: g_free (priv->service); priv->service = g_value_dup_string (value); @@ -220,6 +253,9 @@ get_property (GObject *object, guint prop_id, NMSettingPppoe *setting = NM_SETTING_PPPOE (object); switch (prop_id) { + case PROP_PARENT: + g_value_set_string (value, nm_setting_pppoe_get_parent (setting)); + break; case PROP_SERVICE: g_value_set_string (value, nm_setting_pppoe_get_service (setting)); break; @@ -267,6 +303,25 @@ nm_setting_pppoe_class_init (NMSettingPppoeClass *setting_class) /* Properties */ /** + * NMSettingPppoe:parent: + * + * If given, specifies the parent interface name on which this PPPoE + * connection should be created. If this property is not specified, + * the connection is activated on the interface specified in + * #NMSettingConnection:interface-name of #NMSettingConnection. + * + * Since: 1.10 + **/ + g_object_class_install_property + (object_class, PROP_PARENT, + g_param_spec_string (NM_SETTING_PPPOE_PARENT, "", "", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS)); + + /** * NMSettingPppoe:service: * * If specified, instruct PPPoE to only initiate sessions with access diff --git a/libnm-core/nm-setting-pppoe.h b/libnm-core/nm-setting-pppoe.h index b6717cde81..cab96e3b98 100644 --- a/libnm-core/nm-setting-pppoe.h +++ b/libnm-core/nm-setting-pppoe.h @@ -40,6 +40,7 @@ G_BEGIN_DECLS #define NM_SETTING_PPPOE_SETTING_NAME "pppoe" +#define NM_SETTING_PPPOE_PARENT "parent" #define NM_SETTING_PPPOE_SERVICE "service" #define NM_SETTING_PPPOE_USERNAME "username" #define NM_SETTING_PPPOE_PASSWORD "password" @@ -64,6 +65,8 @@ typedef struct { GType nm_setting_pppoe_get_type (void); NMSetting *nm_setting_pppoe_new (void); +NM_AVAILABLE_IN_1_10 +const char *nm_setting_pppoe_get_parent (NMSettingPppoe *setting); const char *nm_setting_pppoe_get_service (NMSettingPppoe *setting); const char *nm_setting_pppoe_get_username (NMSettingPppoe *setting); const char *nm_setting_pppoe_get_password (NMSettingPppoe *setting); diff --git a/libnm/libnm.ver b/libnm/libnm.ver index f1fb863d93..f22a0f1064 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1182,6 +1182,7 @@ libnm_1_10_0 { global: nm_device_dummy_get_hw_address; nm_setting_bridge_get_group_forward_mask; + nm_setting_pppoe_get_parent; nm_setting_wireless_security_get_pmf; nm_setting_wireless_security_get_wps_method; nm_setting_wireless_security_pmf_get_type; |