libnm-core: add connection.llmnr property

This commit is contained in:
Beniamino Galvani 2018-08-31 10:48:18 +02:00
parent 8e6ad2853c
commit e83c31bbe0
5 changed files with 91 additions and 3 deletions

View file

@ -135,6 +135,7 @@
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_ID N_("A human readable unique identifier for the connection, like \"Work Wi-Fi\" or \"T-Mobile 3G\".")
#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_LLMNR N_("Whether Link-Local Multicast Name Resolution (LLMNR) is enabled for the connection. LLMNR is a protocol based on the Domain Name System (DNS) packet format that allows both IPv4 and IPv6 hosts to perform name resolution for hosts on the same local link. The permitted values are: yes: register hostname and resolving for the connection, no: disable LLMNR for the interface, resolve: do not register hostname but allow resolving of LLMNR host names. This feature requires a plugin which supports LLMNR. One such plugin is dns-systemd-resolved.")
#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. 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.")

View file

@ -81,6 +81,7 @@ typedef struct {
NMSettingConnectionLldp lldp;
int auth_retries;
int mdns;
int llmnr;
} NMSettingConnectionPrivate;
enum {
@ -105,6 +106,7 @@ enum {
PROP_METERED,
PROP_LLDP,
PROP_MDNS,
PROP_LLMNR,
PROP_STABLE_ID,
PROP_AUTH_RETRIES,
@ -896,6 +898,23 @@ nm_setting_connection_get_mdns (NMSettingConnection *setting)
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->mdns;
}
/**
* nm_setting_connection_get_llmnr:
* @setting: the #NMSettingConnection
*
* Returns: the #NMSettingConnection:llmnr property of the setting.
*
* Since: 1.14
**/
NMSettingConnectionLlmnr
nm_setting_connection_get_llmnr (NMSettingConnection *setting)
{
g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting),
NM_SETTING_CONNECTION_LLMNR_DEFAULT);
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->llmnr;
}
static void
_set_error_missing_base_setting (GError **error, const char *type)
{
@ -1093,17 +1112,28 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
if ( priv->mdns < NM_SETTING_CONNECTION_MDNS_DEFAULT
|| priv->mdns > NM_SETTING_CONNECTION_MDNS_YES) {
if ( priv->mdns < (int) NM_SETTING_CONNECTION_MDNS_DEFAULT
|| priv->mdns > (int) NM_SETTING_CONNECTION_MDNS_YES) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("mdns value %d is not valid"), priv->mdns);
_("value %d is not valid"), priv->mdns);
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_MDNS);
return FALSE;
}
if ( priv->llmnr < (int) NM_SETTING_CONNECTION_LLMNR_DEFAULT
|| priv->llmnr > (int) NM_SETTING_CONNECTION_LLMNR_YES) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("value %d is not valid"), priv->llmnr);
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME,
NM_SETTING_CONNECTION_LLMNR);
return FALSE;
}
if (!NM_IN_SET (priv->multi_connect, (int) NM_CONNECTION_MULTI_CONNECT_DEFAULT,
(int) NM_CONNECTION_MULTI_CONNECT_SINGLE,
(int) NM_CONNECTION_MULTI_CONNECT_MANUAL_MULTIPLE,
@ -1276,6 +1306,7 @@ nm_setting_connection_init (NMSettingConnection *setting)
NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting);
priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT;
priv->llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT;
}
static void
@ -1400,6 +1431,9 @@ set_property (GObject *object, guint prop_id,
case PROP_MDNS:
priv->mdns = g_value_get_int (value);
break;
case PROP_LLMNR:
priv->llmnr = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -1494,6 +1528,9 @@ get_property (GObject *object, guint prop_id,
case PROP_MDNS:
g_value_set_int (value, priv->mdns);
break;
case PROP_LLMNR:
g_value_set_int (value, priv->llmnr);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -2127,6 +2164,31 @@ nm_setting_connection_class_init (NMSettingConnectionClass *klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
/**
* NMSettingConnection:llmnr:
*
* Whether Link-Local Multicast Name Resolution (LLMNR) is enabled
* for the connection. LLMNR is a protocol based on the Domain Name
* System (DNS) packet format that allows both IPv4 and IPv6 hosts
* to perform name resolution for hosts on the same local link.
*
* The permitted values are: yes: register hostname and resolving
* for the connection, no: disable LLMNR for the interface, resolve:
* do not register hostname but allow resolving of LLMNR host names.
*
* This feature requires a plugin which supports LLMNR. One such
* plugin is dns-systemd-resolved.
*
* Since: 1.14
**/
g_object_class_install_property
(object_class, PROP_LLMNR,
g_param_spec_int (NM_SETTING_CONNECTION_LLMNR, "", "",
G_MININT32, G_MAXINT32,
NM_SETTING_CONNECTION_LLMNR_DEFAULT,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_CONNECTION,
NULL, properties_override);
}

View file

@ -66,6 +66,7 @@ G_BEGIN_DECLS
#define NM_SETTING_CONNECTION_LLDP "lldp"
#define NM_SETTING_CONNECTION_AUTH_RETRIES "auth-retries"
#define NM_SETTING_CONNECTION_MDNS "mdns"
#define NM_SETTING_CONNECTION_LLMNR "llmnr"
/* Types for property values */
/**
@ -117,6 +118,24 @@ typedef enum {
NM_SETTING_CONNECTION_MDNS_YES = 2,
} NMSettingConnectionMdns;
/**
* NMSettingConnectionLlmnr:
* @NM_SETTING_CONNECTION_LLMNR_DEFAULT: default value
* @NM_SETTING_CONNECTION_LLMNR_NO: disable LLMNR
* @NM_SETTING_CONNECTION_LLMNR_RESOLVE: support only resolving, do not register hostname
* @NM_SETTING_CONNECTION_LLMNR_YES: enable LLMNR
*
* #NMSettingConnectionLlmnr values indicate whether LLMNR should be enabled.
*
* Since: 1.14
*/
typedef enum {
NM_SETTING_CONNECTION_LLMNR_DEFAULT = -1,
NM_SETTING_CONNECTION_LLMNR_NO = 0,
NM_SETTING_CONNECTION_LLMNR_RESOLVE = 1,
NM_SETTING_CONNECTION_LLMNR_YES = 2,
} NMSettingConnectionLlmnr;
/**
* NMSettingConnection:
*
@ -194,6 +213,9 @@ int nm_setting_connection_get_auth_retries (NMSettingConnection *set
NM_AVAILABLE_IN_1_12
NMSettingConnectionMdns nm_setting_connection_get_mdns (NMSettingConnection *setting);
NM_AVAILABLE_IN_1_14
NMSettingConnectionLlmnr nm_setting_connection_get_llmnr (NMSettingConnection *setting);
G_END_DECLS
#endif /* __NM_SETTING_CONNECTION_H__ */

View file

@ -2618,6 +2618,7 @@ test_connection_diff_a_only (void)
{ 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 },
{ NM_SETTING_CONNECTION_LLMNR, NM_SETTING_DIFF_RESULT_IN_A },
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }
} },
{ NM_SETTING_WIRED_SETTING_NAME, {

View file

@ -1393,7 +1393,9 @@ global:
nm_device_wireguard_get_type;
nm_device_wpan_get_type;
nm_setting_6lowpan_get_type;
nm_setting_connection_get_llmnr;
nm_setting_connection_get_multi_connect;
nm_setting_connection_llmnr_get_type;
nm_setting_ethtool_clear_features;
nm_setting_ethtool_get_feature;
nm_setting_ethtool_get_type;