summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmo Puustinen <ismo.puustinen@intel.com>2017-11-10 14:49:27 +0200
committerThomas Haller <thaller@redhat.com>2018-01-09 14:24:53 +0100
commit2e2ff6f27aa1bfa7a27d49980b319873240ec84b (patch)
tree4f7e8a6dbe08390df71db4626a1491965128c8f0
parent6dd69990c04b8a4e1bc439f6f717de48f4f8d9be (diff)
mdns: add new connection property.
Add support for mDNS as a connection-level property. Update ifcfg-rh and keyfile plugins to support it.
-rw-r--r--clients/common/nm-meta-setting-desc.c8
-rw-r--r--clients/common/settings-docs.c.in1
-rw-r--r--libnm-core/nm-setting-connection.c59
-rw-r--r--libnm-core/nm-setting-connection.h21
-rw-r--r--libnm-core/tests/test-general.c1
-rw-r--r--libnm/libnm.ver2
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c9
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c11
8 files changed, 109 insertions, 3 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index 4aa135a925..9943b35eff 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -5577,6 +5577,14 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
| NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PRETTY_TEXT,
),
),
+ PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_MDNS,
+ .property_type = &_pt_gobject_enum,
+ .property_typ_data = DEFINE_PROPERTY_TYP_DATA (
+ PROPERTY_TYP_DATA_SUBTYPE (gobject_enum,
+ .get_gtype = nm_setting_connection_mdns_get_type,
+ ),
+ ),
+ ),
NULL
};
diff --git a/clients/common/settings-docs.c.in b/clients/common/settings-docs.c.in
index 8f3a95763f..1f3a1a62be 100644
--- a/clients/common/settings-docs.c.in
+++ b/clients/common/settings-docs.c.in
@@ -144,6 +144,7 @@
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_INTERFACE_NAME N_("The name of the network interface this connection is bound to. If not set, then the connection can be attached to any interface of the appropriate type (subject to restrictions imposed by other settings). For software devices this specifies the name of the created device. For connection types where interface names cannot easily be made persistent (e.g. mobile broadband or USB Ethernet), this property should not be used. Setting this property restricts the interfaces a connection can be used with, and if interface names change or are reordered the connection may be applied to the wrong interface.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_LLDP N_("Whether LLDP is enabled for the connection.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MASTER N_("Interface name of the master device or UUID of the master connection.")
+#define DESCRIBE_DOC_NM_SETTING_CONNECTION_MDNS N_("Whether mDNS is enabled for the connection. The permitted values are: yes: register hostname and resolving for the connection, no: disable mDNS for the interface, resolve: do not register hostname but allow resolving of mDNS host names. When updating this property on a currently activated connection, the change takes effect immediately. This feature requires a plugin which supports mDNS. One such plugin is dns-systemd-resolved.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_METERED N_("Whether the connection is metered. When updating this property on a currently activated connection, the change takes effect immediately.")
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_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_CONNECTION_PERMISSIONS N_("An array of strings defining what access a given user has to this connection. If this is NULL or empty, all users are allowed to access this connection; otherwise users are allowed if and only if they are in this list. When this is not empty, the connection can be active only when one of the specified users is logged into an active session. Each entry is of the form \"[type]:[id]:[reserved]\"; for example, \"user:dcbw:blah\". At this time only the \"user\" [type] is allowed. Any other values are ignored and reserved for future use. [id] is the username that this permission refers to, which may not contain the \":\" character. Any [reserved] information present must be ignored and is reserved for future use. All of [type], [id], and [reserved] must be valid UTF-8.")
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c
index 24c65e7c5e..ba5bf8bf55 100644
--- a/libnm-core/nm-setting-connection.c
+++ b/libnm-core/nm-setting-connection.c
@@ -81,6 +81,7 @@ typedef struct {
NMMetered metered;
NMSettingConnectionLldp lldp;
gint auth_retries;
+ NMSettingConnectionMdns mdns;
} NMSettingConnectionPrivate;
enum {
@@ -103,6 +104,7 @@ enum {
PROP_GATEWAY_PING_TIMEOUT,
PROP_METERED,
PROP_LLDP,
+ PROP_MDNS,
PROP_STABLE_ID,
PROP_AUTH_RETRIES,
@@ -862,6 +864,23 @@ nm_setting_connection_get_lldp (NMSettingConnection *setting)
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->lldp;
}
+/**
+ * nm_setting_connection_get_mdns:
+ * @setting: the #NMSettingConnection
+ *
+ * Returns: the #NMSettingConnection:mdns property of the setting.
+ *
+ * Since: 1.12
+ **/
+NMSettingConnectionMdns
+nm_setting_connection_get_mdns (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting),
+ NM_SETTING_CONNECTION_MDNS_UNKNOWN);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->mdns;
+}
+
static void
_set_error_missing_base_setting (GError **error, const char *type)
{
@@ -1332,6 +1351,9 @@ set_property (GObject *object, guint prop_id,
case PROP_AUTH_RETRIES:
priv->auth_retries = g_value_get_int (value);
break;
+ case PROP_MDNS:
+ priv->mdns = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1420,6 +1442,9 @@ get_property (GObject *object, guint prop_id,
case PROP_AUTH_RETRIES:
g_value_set_int (value, priv->auth_retries);
break;
+ case PROP_MDNS:
+ g_value_set_int (value, priv->mdns);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1982,4 +2007,38 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
G_PARAM_CONSTRUCT |
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_STATIC_STRINGS));
+
+ /**
+ * NMSettingConnection:mdns:
+ *
+ * Whether mDNS is enabled for the connection.
+ *
+ * The permitted values are: yes: register hostname and resolving
+ * for the connection, no: disable mDNS for the interface, resolve:
+ * do not register hostname but allow resolving of mDNS host names.
+ * When updating this property on a currently activated connection,
+ * the change takes effect immediately.
+ *
+ * This feature requires a plugin which supports mDNS. One such
+ * plugin is dns-systemd-resolved.
+ *
+ * Since: 1.12
+ **/
+ /* ---ifcfg-rh---
+ * property: mdns
+ * variable: CONNECTION_MDNS(+)
+ * values: yes,no,resolve
+ * default: missing variable means global default
+ * description: Whether or not mDNS is enabled for the connection
+ * example: CONNECTION_MDNS=yes
+ * ---end---
+ */
+ g_object_class_install_property
+ (object_class, PROP_MDNS,
+ g_param_spec_int (NM_SETTING_CONNECTION_MDNS, "", "",
+ G_MININT32, G_MAXINT32,
+ NM_SETTING_CONNECTION_MDNS_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
}
diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h
index 02a7f5b10a..6fd88a906d 100644
--- a/libnm-core/nm-setting-connection.h
+++ b/libnm-core/nm-setting-connection.h
@@ -64,6 +64,7 @@ G_BEGIN_DECLS
#define NM_SETTING_CONNECTION_METERED "metered"
#define NM_SETTING_CONNECTION_LLDP "lldp"
#define NM_SETTING_CONNECTION_AUTH_RETRIES "auth-retries"
+#define NM_SETTING_CONNECTION_MDNS "mdns"
/* Types for property values */
/**
@@ -98,6 +99,24 @@ typedef enum {
} NMSettingConnectionLldp;
/**
+ * NMSettingConnectionMdns:
+ * @NM_SETTING_CONNECTION_MDNS_UNKNOWN: default value
+ * @NM_SETTING_CONNECTION_MDNS_YES: disable mDNS
+ * @NM_SETTING_CONNECTION_MDNS_NO: enable mDNS
+ * @NM_SETTING_CONNECTION_MDNS_RESOLVE: support only resolving, do not register hostname
+ *
+ * #NMSettingConnectionMdns values indicate whether mDNS should be enabled.
+ *
+ * Since: 1.12
+ */
+typedef enum {
+ NM_SETTING_CONNECTION_MDNS_UNKNOWN = 0,
+ NM_SETTING_CONNECTION_MDNS_YES = 1,
+ NM_SETTING_CONNECTION_MDNS_NO = 2,
+ NM_SETTING_CONNECTION_MDNS_RESOLVE = 3,
+} NMSettingConnectionMdns;
+
+/**
* NMSettingConnection:
*
* General Connection Profile Settings
@@ -170,6 +189,8 @@ NMSettingConnectionLldp nm_setting_connection_get_lldp (NMSettingConnection *set
NM_AVAILABLE_IN_1_10
gint nm_setting_connection_get_auth_retries (NMSettingConnection *setting);
+NM_AVAILABLE_IN_1_12
+NMSettingConnectionMdns nm_setting_connection_get_mdns (NMSettingConnection *setting);
G_END_DECLS
#endif /* __NM_SETTING_CONNECTION_H__ */
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index e4a5aa5a13..9cf08c5d8c 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -2604,6 +2604,7 @@ test_connection_diff_a_only (void)
{ NM_SETTING_CONNECTION_METERED, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_LLDP, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_AUTH_RETRIES, NM_SETTING_DIFF_RESULT_IN_A },
+ { NM_SETTING_CONNECTION_MDNS, NM_SETTING_DIFF_RESULT_IN_A },
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }
} },
{ NM_SETTING_WIRED_SETTING_NAME, {
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index e5ded29ac1..29dfba7b58 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -1347,6 +1347,8 @@ global:
nm_client_get_checkpoints;
nm_device_ip_tunnel_get_flags;
nm_ip_tunnel_flags_get_type;
+ nm_setting_connection_get_mdns;
+ nm_setting_connection_mdns_get_type;
nm_setting_ip_tunnel_get_flags;
nm_setting_vpn_get_data_keys;
nm_setting_vpn_get_secret_keys;
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index d6be2f3a14..04fbc38772 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -181,7 +181,7 @@ make_connection_setting (const char *file,
const char *v;
gs_free char *stable_id = NULL;
const char *const *iter;
- int vint64;
+ int vint64, i_val;
ifcfg_name = utils_get_ifcfg_name (file, TRUE);
if (!ifcfg_name)
@@ -321,6 +321,13 @@ make_connection_setting (const char *file,
vint64 = svGetValueInt64 (ifcfg, "AUTH_RETRIES", 10, -1, G_MAXINT32, -1);
g_object_set (s_con, NM_SETTING_CONNECTION_AUTH_RETRIES, (gint) vint64, NULL);
+ i_val = NM_SETTING_CONNECTION_MDNS_UNKNOWN;
+ if (!svGetValueEnum (ifcfg, "MDNS",
+ nm_setting_connection_mdns_get_type (),
+ &i_val, NULL)) {
+ }
+ g_object_set (s_con, NM_SETTING_CONNECTION_MDNS, i_val, NULL);
+
return NM_SETTING (s_con);
}
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index 9c49c97483..55eab7bfa8 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -1727,7 +1727,7 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg)
guint32 n, i;
GString *str;
const char *master, *master_iface = NULL, *type;
- gint vint;
+ gint vint, i_val;
guint32 vuint32;
const char *tmp;
@@ -1882,6 +1882,14 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg)
vint = nm_setting_connection_get_auth_retries (s_con);
svSetValueInt64_cond (ifcfg, "AUTH_RETRIES", vint >= 0, vint);
+
+ i_val = nm_setting_connection_get_mdns (s_con);
+ if (i_val != NM_SETTING_CONNECTION_MDNS_UNKNOWN) {
+ svSetValueEnum (ifcfg, "MDNS", nm_setting_connection_mdns_get_type (),
+ i_val);
+ } else {
+ svUnsetValue (ifcfg, "MDNS");
+ }
}
static char *
@@ -3182,4 +3190,3 @@ nms_ifcfg_rh_writer_can_write_connection (NMConnection *connection, GError **err
NM_PRINT_FMT_QUOTE_STRING (type));
return FALSE;
}
-