diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2015-09-28 19:19:13 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-10-06 14:16:55 +0200 |
commit | 3f0d595cc827d9e1117bc5c796aa11185ba8c5d7 (patch) | |
tree | 3e5181451ff9a04570857c0bedde909f93e8801f | |
parent | 8c9b791768e0dc90c0f019cbd15a6653689f6619 (diff) | |
download | NetworkManager-3f0d595cc827d9e1117bc5c796aa11185ba8c5d7.tar.gz |
libnm,ip4-config: add ipv4.dhcp-timeout property
This is intentionally IPv4 specific since this is used for a quick fallback to
method=link-local -- something that's not needed for IPv6 since the link local
address is always there.
https://bugzilla.redhat.com/show_bug.cgi?id=1262922
-rw-r--r-- | libnm-core/nm-setting-ip4-config.c | 48 | ||||
-rw-r--r-- | libnm-core/nm-setting-ip4-config.h | 4 | ||||
-rw-r--r-- | libnm-core/tests/test-general.c | 1 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 |
4 files changed, 54 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c index 562b760151..1fb4677ac5 100644 --- a/libnm-core/nm-setting-ip4-config.c +++ b/libnm-core/nm-setting-ip4-config.c @@ -58,11 +58,13 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP4_CONFIG) typedef struct { char *dhcp_client_id; + int dhcp_timeout; } NMSettingIP4ConfigPrivate; enum { PROP_0, PROP_DHCP_CLIENT_ID, + PROP_DHCP_TIMEOUT, LAST_PROP }; @@ -98,6 +100,26 @@ nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting) return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_client_id; } +/** + * nm_setting_ip4_config_get_dhcp_timeout: + * @setting: the #NMSettingIP4Config + * + * Returns the value contained in the #NMSettingIP4Config:dhcp-timeout + * property. + * + * Returns: the configured DHCP timeout in seconds. 0 = default for + * the particular kind of device. + * + * Since: 1.2 + **/ +int +nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0); + + return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_timeout; +} + static gboolean verify (NMSetting *setting, NMConnection *connection, GError **error) { @@ -208,6 +230,9 @@ set_property (GObject *object, guint prop_id, g_free (priv->dhcp_client_id); priv->dhcp_client_id = g_value_dup_string (value); break; + case PROP_DHCP_TIMEOUT: + priv->dhcp_timeout = g_value_get_uint (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -224,6 +249,9 @@ get_property (GObject *object, guint prop_id, case PROP_DHCP_CLIENT_ID: g_value_set_string (value, nm_setting_ip4_config_get_dhcp_client_id (s_ip4)); break; + case PROP_DHCP_TIMEOUT: + g_value_set_uint (value, nm_setting_ip4_config_get_dhcp_timeout (s_ip4)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -599,6 +627,26 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * NMSettingIP4Config:dhcp-timeout: + * + * A timeout for a DHCP transaction in seconds. + **/ + /* ---ifcfg-rh--- + * property: dhcp-client-id + * variable: DHCP_TIMEOUT(+) + * description: A timeout after which the DHCP transaction fails in case of no response. + * example: DHCP_TIMEOUT=10 + * ---end--- + */ + g_object_class_install_property + (object_class, PROP_DHCP_TIMEOUT, + g_param_spec_uint (NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, "", "", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | + NM_SETTING_PARAM_FUZZY_IGNORE | + G_PARAM_STATIC_STRINGS)); + /* IP4-specific property overrides */ /* ---dbus--- diff --git a/libnm-core/nm-setting-ip4-config.h b/libnm-core/nm-setting-ip4-config.h index e944dfe391..23e9e99d44 100644 --- a/libnm-core/nm-setting-ip4-config.h +++ b/libnm-core/nm-setting-ip4-config.h @@ -42,6 +42,8 @@ G_BEGIN_DECLS #define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id" +#define NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT "dhcp-timeout" + /** * NM_SETTING_IP4_CONFIG_METHOD_AUTO: * @@ -102,6 +104,8 @@ GType nm_setting_ip4_config_get_type (void); NMSetting *nm_setting_ip4_config_new (void); const char *nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *setting); +NM_AVAILABLE_IN_1_2 +int nm_setting_ip4_config_get_dhcp_timeout (NMSettingIP4Config *setting); G_END_DECLS diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 4eb739e994..bb2d6cb66d 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -2002,6 +2002,7 @@ test_connection_diff_a_only (void) { NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A }, + { NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A }, { NM_SETTING_IP_CONFIG_NEVER_DEFAULT, NM_SETTING_DIFF_RESULT_IN_A }, diff --git a/libnm/libnm.ver b/libnm/libnm.ver index c04bfacf8d..2e58887d06 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -870,6 +870,7 @@ global: nm_setting_connection_autoconnect_slaves_get_type; nm_setting_connection_get_autoconnect_slaves; nm_setting_connection_get_metered; + nm_setting_ip4_config_get_dhcp_timeout; nm_setting_ip_config_add_dns_option; nm_setting_ip_config_clear_dns_options; nm_setting_ip_config_get_dns_option; |