core: merge branch 'th/nm-dhcp-config-merge'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/423
This commit is contained in:
Thomas Haller 2020-02-21 16:01:20 +01:00
commit cfa2981271
17 changed files with 368 additions and 472 deletions

View file

@ -2277,10 +2277,8 @@ src_libNetworkManager_la_SOURCES = \
src/nm-dcb.h \ src/nm-dcb.h \
src/nm-netns.c \ src/nm-netns.c \
src/nm-netns.h \ src/nm-netns.h \
src/nm-dhcp4-config.c \ src/nm-dhcp-config.c \
src/nm-dhcp4-config.h \ src/nm-dhcp-config.h \
src/nm-dhcp6-config.c \
src/nm-dhcp6-config.h \
src/nm-dispatcher.c \ src/nm-dispatcher.c \
src/nm-dispatcher.h \ src/nm-dispatcher.h \
src/nm-firewall-manager.c \ src/nm-firewall-manager.c \

View file

@ -1043,17 +1043,17 @@ nm_str_realloc (char *str)
/*****************************************************************************/ /*****************************************************************************/
#define NM_GOBJECT_PROPERTIES_DEFINE_BASE(...) \ #define NM_GOBJECT_PROPERTIES_DEFINE_BASE_FULL(suffix, ...) \
typedef enum { \ typedef enum { \
PROP_0, \ PROP_0##suffix, \
__VA_ARGS__ \ __VA_ARGS__ \
_PROPERTY_ENUMS_LAST, \ _PROPERTY_ENUMS_LAST##suffix, \
} _PropertyEnums; \ } _PropertyEnums##suffix; \
static GParamSpec *obj_properties[_PROPERTY_ENUMS_LAST] = { NULL, } static GParamSpec *obj_properties##suffix[_PROPERTY_ENUMS_LAST##suffix] = { NULL, }
#define NM_GOBJECT_PROPERTIES_DEFINE_NOTIFY(obj_type, obj_properties, property_enums_type, prop_0) \ #define NM_GOBJECT_PROPERTIES_DEFINE_NOTIFY(suffix, obj_type) \
static inline void \ static inline void \
_nm_gobject_notify_together_impl (obj_type *obj, guint n, const property_enums_type *props) \ _nm_gobject_notify_together_impl (obj_type *obj, guint n, const _PropertyEnums##suffix *props) \
{ \ { \
const gboolean freeze_thaw = (n > 1); \ const gboolean freeze_thaw = (n > 1); \
\ \
@ -1063,12 +1063,12 @@ _nm_gobject_notify_together_impl (obj_type *obj, guint n, const property_enums_t
if (freeze_thaw) \ if (freeze_thaw) \
g_object_freeze_notify ((GObject *) obj); \ g_object_freeze_notify ((GObject *) obj); \
while (n-- > 0) { \ while (n-- > 0) { \
const property_enums_type prop = *props++; \ const _PropertyEnums##suffix prop = *props++; \
\ \
if (prop != prop_0) { \ if (prop != PROP_0##suffix) { \
nm_assert ((gsize) prop < G_N_ELEMENTS (obj_properties)); \ nm_assert ((gsize) prop < G_N_ELEMENTS (obj_properties##suffix)); \
nm_assert (obj_properties[prop]); \ nm_assert (obj_properties##suffix[prop]); \
g_object_notify_by_pspec ((GObject *) obj, obj_properties[prop]); \ g_object_notify_by_pspec ((GObject *) obj, obj_properties##suffix[prop]); \
} \ } \
} \ } \
if (freeze_thaw) \ if (freeze_thaw) \
@ -1076,20 +1076,26 @@ _nm_gobject_notify_together_impl (obj_type *obj, guint n, const property_enums_t
} \ } \
\ \
_nm_unused static inline void \ _nm_unused static inline void \
_notify (obj_type *obj, property_enums_type prop) \ _notify (obj_type *obj, _PropertyEnums##suffix prop) \
{ \ { \
_nm_gobject_notify_together_impl (obj, 1, &prop); \ _nm_gobject_notify_together_impl (obj, 1, &prop); \
} \ } \
#define NM_GOBJECT_PROPERTIES_DEFINE_BASE(...) \
NM_GOBJECT_PROPERTIES_DEFINE_BASE_FULL (, __VA_ARGS__); \
#define NM_GOBJECT_PROPERTIES_DEFINE(obj_type, ...) \ #define NM_GOBJECT_PROPERTIES_DEFINE(obj_type, ...) \
NM_GOBJECT_PROPERTIES_DEFINE_BASE (__VA_ARGS__); \ NM_GOBJECT_PROPERTIES_DEFINE_BASE_FULL (, __VA_ARGS__); \
NM_GOBJECT_PROPERTIES_DEFINE_NOTIFY (obj_type, obj_properties, _PropertyEnums, PROP_0) NM_GOBJECT_PROPERTIES_DEFINE_NOTIFY (, obj_type)
/* invokes _notify() for all arguments (of type _PropertyEnums). Note, that if /* invokes _notify() for all arguments (of type _PropertyEnums). Note, that if
* there are more than one prop arguments, this will involve a freeze/thaw * there are more than one prop arguments, this will involve a freeze/thaw
* of GObject property notifications. */ * of GObject property notifications. */
#define nm_gobject_notify_together_full(suffix, obj, ...) \
_nm_gobject_notify_together_impl (obj, NM_NARG (__VA_ARGS__), (const _PropertyEnums##suffix[]) { __VA_ARGS__ })
#define nm_gobject_notify_together(obj, ...) \ #define nm_gobject_notify_together(obj, ...) \
_nm_gobject_notify_together_impl (obj, NM_NARG (__VA_ARGS__), (const _PropertyEnums[]) { __VA_ARGS__ }) nm_gobject_notify_together_full (, obj, __VA_ARGS__)
/*****************************************************************************/ /*****************************************************************************/

View file

@ -43,8 +43,7 @@
#include "nm-ip6-config.h" #include "nm-ip6-config.h"
#include "nm-pacrunner-manager.h" #include "nm-pacrunner-manager.h"
#include "dnsmasq/nm-dnsmasq-manager.h" #include "dnsmasq/nm-dnsmasq-manager.h"
#include "nm-dhcp4-config.h" #include "nm-dhcp-config.h"
#include "nm-dhcp6-config.h"
#include "nm-rfkill-manager.h" #include "nm-rfkill-manager.h"
#include "nm-firewall-manager.h" #include "nm-firewall-manager.h"
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
@ -161,11 +160,7 @@ typedef struct {
typedef struct { typedef struct {
NMDhcpClient *client; NMDhcpClient *client;
union { NMDhcpConfig *config;
NMDhcp4Config *config_4;
NMDhcp6Config *config_6;
gpointer config;
};
gulong state_sigid; gulong state_sigid;
guint grace_id; guint grace_id;
bool grace_pending:1; bool grace_pending:1;
@ -7628,8 +7623,8 @@ dhcp4_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
g_clear_object (&priv->dhcp_data_4.client); g_clear_object (&priv->dhcp_data_4.client);
} }
if (priv->dhcp_data_4.config_4) { if (priv->dhcp_data_4.config) {
nm_dbus_object_clear_and_unexport (&priv->dhcp_data_4.config_4); nm_dbus_object_clear_and_unexport (&priv->dhcp_data_4.config);
_notify (self, PROP_DHCP4_CONFIG); _notify (self, PROP_DHCP4_CONFIG);
} }
} }
@ -8002,9 +7997,9 @@ dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
clear_config: clear_config:
/* The previous configuration is no longer valid */ /* The previous configuration is no longer valid */
if (priv->dhcp_data_4.config_4) { if (priv->dhcp_data_4.config) {
nm_dbus_object_clear_and_unexport (&priv->dhcp_data_4.config_4); nm_dbus_object_clear_and_unexport (&priv->dhcp_data_4.config);
priv->dhcp_data_4.config_4 = nm_dhcp4_config_new (); priv->dhcp_data_4.config = nm_dhcp_config_new (AF_INET);
_notify (self, PROP_DHCP4_CONFIG); _notify (self, PROP_DHCP4_CONFIG);
} }
} }
@ -8067,7 +8062,7 @@ dhcp4_state_changed (NMDhcpClient *client,
g_free (priv->dhcp4.root_path); g_free (priv->dhcp4.root_path);
priv->dhcp4.root_path = g_strdup (g_hash_table_lookup (options, "root_path")); priv->dhcp4.root_path = g_strdup (g_hash_table_lookup (options, "root_path"));
nm_dhcp4_config_set_options (priv->dhcp_data_4.config_4, options); nm_dhcp_config_set_options (priv->dhcp_data_4.config, options);
_notify (self, PROP_DHCP4_CONFIG); _notify (self, PROP_DHCP4_CONFIG);
if (priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF) { if (priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF) {
@ -8446,8 +8441,8 @@ dhcp4_start (NMDevice *self)
s_ip4 = nm_connection_get_setting_ip4_config (connection); s_ip4 = nm_connection_get_setting_ip4_config (connection);
/* Clear old exported DHCP options */ /* Clear old exported DHCP options */
nm_dbus_object_clear_and_unexport (&priv->dhcp_data_4.config_4); nm_dbus_object_clear_and_unexport (&priv->dhcp_data_4.config);
priv->dhcp_data_4.config_4 = nm_dhcp4_config_new (); priv->dhcp_data_4.config = nm_dhcp_config_new (AF_INET);
pllink = nm_platform_link_get (nm_device_get_platform (self), nm_device_get_ip_ifindex (self)); pllink = nm_platform_link_get (nm_device_get_platform (self), nm_device_get_ip_ifindex (self));
if (pllink) { if (pllink) {
@ -8692,8 +8687,8 @@ dhcp6_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
g_clear_object (&priv->dhcp_data_6.client); g_clear_object (&priv->dhcp_data_6.client);
} }
if (priv->dhcp_data_6.config_6) { if (priv->dhcp_data_6.config) {
nm_dbus_object_clear_and_unexport (&priv->dhcp_data_6.config_6); nm_dbus_object_clear_and_unexport (&priv->dhcp_data_6.config);
_notify (self, PROP_DHCP6_CONFIG); _notify (self, PROP_DHCP6_CONFIG);
} }
} }
@ -8779,9 +8774,9 @@ dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
clear_config: clear_config:
/* The previous configuration is no longer valid */ /* The previous configuration is no longer valid */
if (priv->dhcp_data_6.config_6) { if (priv->dhcp_data_6.config) {
nm_dbus_object_clear_and_unexport (&priv->dhcp_data_6.config_6); nm_dbus_object_clear_and_unexport (&priv->dhcp_data_6.config);
priv->dhcp_data_6.config_6 = nm_dhcp6_config_new (); priv->dhcp_data_6.config = nm_dhcp_config_new (AF_INET6);
_notify (self, PROP_DHCP6_CONFIG); _notify (self, PROP_DHCP6_CONFIG);
} }
} }
@ -8825,7 +8820,7 @@ dhcp6_state_changed (NMDhcpClient *client,
if (ip6_config) { if (ip6_config) {
applied_config_init (&priv->dhcp6.ip6_config, ip6_config); applied_config_init (&priv->dhcp6.ip6_config, ip6_config);
priv->dhcp6.event_id = g_strdup (event_id); priv->dhcp6.event_id = g_strdup (event_id);
nm_dhcp6_config_set_options (priv->dhcp_data_6.config_6, options); nm_dhcp_config_set_options (priv->dhcp_data_6.config, options);
_notify (self, PROP_DHCP6_CONFIG); _notify (self, PROP_DHCP6_CONFIG);
} else } else
applied_config_clear (&priv->dhcp6.ip6_config); applied_config_clear (&priv->dhcp6.ip6_config);
@ -9300,8 +9295,8 @@ dhcp6_start (NMDevice *self, gboolean wait_for_ll)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMConnection *connection; NMConnection *connection;
nm_dbus_object_clear_and_unexport (&priv->dhcp_data_6.config_6); nm_dbus_object_clear_and_unexport (&priv->dhcp_data_6.config);
priv->dhcp_data_6.config_6 = nm_dhcp6_config_new (); priv->dhcp_data_6.config = nm_dhcp_config_new (AF_INET6);
nm_assert (!applied_config_get_current (&priv->dhcp6.ip6_config)); nm_assert (!applied_config_get_current (&priv->dhcp6.ip6_config));
applied_config_clear (&priv->dhcp6.ip6_config); applied_config_clear (&priv->dhcp6.ip6_config);
@ -12828,12 +12823,16 @@ nm_device_set_proxy_config (NMDevice *self, const char *pac_url)
} }
/* IP Configuration stuff */ /* IP Configuration stuff */
NMDhcp4Config * NMDhcpConfig *
nm_device_get_dhcp4_config (NMDevice *self) nm_device_get_dhcp_config (NMDevice *self, int addr_family)
{ {
const gboolean IS_IPv4 = (addr_family == AF_INET);
g_return_val_if_fail (NM_IS_DEVICE (self), NULL); g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
return NM_DEVICE_GET_PRIVATE (self)->dhcp_data_4.config_4; nm_assert_addr_family (addr_family);
return NM_DEVICE_GET_PRIVATE (self)->dhcp_data_x[IS_IPv4].config;
} }
NMIP4Config * NMIP4Config *
@ -13087,14 +13086,6 @@ nm_device_replace_vpn6_config (NMDevice *self, NMIP6Config *old, NMIP6Config *co
_LOGW (LOGD_IP6, "failed to set VPN routes for device"); _LOGW (LOGD_IP6, "failed to set VPN routes for device");
} }
NMDhcp6Config *
nm_device_get_dhcp6_config (NMDevice *self)
{
g_return_val_if_fail (NM_IS_DEVICE (self), NULL);
return NM_DEVICE_GET_PRIVATE (self)->dhcp_data_6.config_6;
}
NMIP6Config * NMIP6Config *
nm_device_get_ip6_config (NMDevice *self) nm_device_get_ip6_config (NMDevice *self)
{ {
@ -17434,13 +17425,13 @@ get_property (GObject *object, guint prop_id,
nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip_config_4 : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip_config_4 : NULL);
break; break;
case PROP_DHCP4_CONFIG: case PROP_DHCP4_CONFIG:
nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp_data_4.config_4 : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp_data_4.config : NULL);
break; break;
case PROP_IP6_CONFIG: case PROP_IP6_CONFIG:
nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip_config_6 : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->ip_config_6 : NULL);
break; break;
case PROP_DHCP6_CONFIG: case PROP_DHCP6_CONFIG:
nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp_data_6.config_6 : NULL); nm_dbus_utils_g_value_set_object_path (value, ip_config_valid (priv->state) ? priv->dhcp_data_6.config : NULL);
break; break;
case PROP_STATE: case PROP_STATE:
g_value_set_uint (value, priv->state); g_value_set_uint (value, priv->state);

View file

@ -504,8 +504,7 @@ const char * nm_device_get_initial_hw_address (NMDevice *dev);
NMProxyConfig * nm_device_get_proxy_config (NMDevice *dev); NMProxyConfig * nm_device_get_proxy_config (NMDevice *dev);
NMDhcp4Config * nm_device_get_dhcp4_config (NMDevice *dev); NMDhcpConfig * nm_device_get_dhcp_config (NMDevice *dev, int addr_family);
NMDhcp6Config * nm_device_get_dhcp6_config (NMDevice *dev);
NMIP4Config * nm_device_get_ip4_config (NMDevice *dev); NMIP4Config * nm_device_get_ip4_config (NMDevice *dev);
void nm_device_replace_vpn4_config (NMDevice *dev, void nm_device_replace_vpn4_config (NMDevice *dev,
NMIP4Config *old, NMIP4Config *old,

View file

@ -9,7 +9,7 @@
#include "nm-dhcp-client.h" #include "nm-dhcp-client.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-dhcp4-config.h" #include "nm-dhcp-config.h"
#define NM_TYPE_DHCP_MANAGER (nm_dhcp_manager_get_type ()) #define NM_TYPE_DHCP_MANAGER (nm_dhcp_manager_get_type ())
#define NM_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_MANAGER, NMDhcpManager)) #define NM_DHCP_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_MANAGER, NMDhcpManager))

View file

@ -135,8 +135,7 @@ sources = files(
'nm-config-data.c', 'nm-config-data.c',
'nm-connectivity.c', 'nm-connectivity.c',
'nm-dcb.c', 'nm-dcb.c',
'nm-dhcp4-config.c', 'nm-dhcp-config.c',
'nm-dhcp6-config.c',
'nm-dispatcher.c', 'nm-dispatcher.c',
'nm-firewall-manager.c', 'nm-firewall-manager.c',
'nm-hostname-manager.c', 'nm-hostname-manager.c',

View file

@ -4055,18 +4055,18 @@ GVariant *
nm_utils_strdict_to_variant (GHashTable *options) nm_utils_strdict_to_variant (GHashTable *options)
{ {
GVariantBuilder builder; GVariantBuilder builder;
gs_free const char **keys = NULL; gs_free NMUtilsNamedValue *values = NULL;
guint i; guint i;
guint nkeys; guint n;
keys = nm_utils_strdict_get_keys (options, TRUE, &nkeys); values = nm_utils_named_values_from_str_dict (options, &n);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
for (i = 0; i < nkeys; i++) { for (i = 0; i < n; i++) {
g_variant_builder_add (&builder, g_variant_builder_add (&builder,
"{sv}", "{sv}",
keys[i], values[i].name,
g_variant_new_string (g_hash_table_lookup (options, keys[i]))); g_variant_new_string (values[i].value_str));
} }
return g_variant_builder_end (&builder); return g_variant_builder_end (&builder);
} }

251
src/nm-dhcp-config.c Normal file
View file

@ -0,0 +1,251 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2008 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-dhcp-config.h"
#include "nm-dbus-interface.h"
#include "nm-utils.h"
#include "nm-dbus-object.h"
#include "nm-core-utils.h"
/*****************************************************************************/
#define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ())
#define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4Config))
#define NM_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass))
#define NM_IS_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP4_CONFIG))
#define NM_IS_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP4_CONFIG))
#define NM_DHCP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass))
typedef struct _NMDhcp4Config NMDhcp4Config;
typedef struct _NMDhcp4ConfigClass NMDhcp4ConfigClass;
static GType nm_dhcp4_config_get_type (void);
#define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ())
#define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6Config))
#define NM_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass))
#define NM_IS_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP6_CONFIG))
#define NM_IS_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP6_CONFIG))
#define NM_DHCP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass))
typedef struct _NMDhcp6Config NMDhcp6Config;
typedef struct _NMDhcp6ConfigClass NMDhcp6ConfigClass;
static GType nm_dhcp6_config_get_type (void);
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMDhcpConfig,
PROP_OPTIONS,
);
typedef struct {
GVariant *options;
} NMDhcpConfigPrivate;
struct _NMDhcpConfig {
NMDBusObject parent;
NMDhcpConfigPrivate _priv;
};
struct _NMDhcpConfigClass {
NMDBusObjectClass parent;
};
G_DEFINE_ABSTRACT_TYPE (NMDhcpConfig, nm_dhcp_config, NM_TYPE_DBUS_OBJECT)
#define NM_DHCP_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcpConfig, NM_IS_DHCP_CONFIG)
/*****************************************************************************/
void
nm_dhcp_config_set_options (NMDhcpConfig *self,
GHashTable *options)
{
NMDhcpConfigPrivate *priv;
g_return_if_fail (NM_IS_DHCP_CONFIG (self));
g_return_if_fail (options);
priv = NM_DHCP_CONFIG_GET_PRIVATE (self);
nm_g_variant_unref (priv->options);
priv->options = g_variant_ref_sink (nm_utils_strdict_to_variant (options));
_notify (self, PROP_OPTIONS);
}
const char *
nm_dhcp_config_get_option (NMDhcpConfig *self, const char *key)
{
NMDhcpConfigPrivate *priv;
const char *value;
g_return_val_if_fail (NM_IS_DHCP_CONFIG (self), NULL);
g_return_val_if_fail (key, NULL);
priv = NM_DHCP_CONFIG_GET_PRIVATE (self);
if ( priv->options
&& g_variant_lookup (priv->options, key, "&s", &value))
return value;
else
return NULL;
}
GVariant *
nm_dhcp_config_get_options (NMDhcpConfig *self)
{
g_return_val_if_fail (NM_IS_DHCP_CONFIG (self), NULL);
return NM_DHCP_CONFIG_GET_PRIVATE (self)->options;
}
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (object);
switch (prop_id) {
case PROP_OPTIONS:
g_value_set_variant (value, priv->options
?: g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/*****************************************************************************/
static void
nm_dhcp_config_init (NMDhcpConfig *self)
{
}
NMDhcpConfig *
nm_dhcp_config_new (int addr_family)
{
nm_assert_addr_family (addr_family);
return g_object_new ( addr_family != AF_INET
? NM_TYPE_DHCP6_CONFIG
: NM_TYPE_DHCP4_CONFIG,
NULL);
}
static void
finalize (GObject *object)
{
NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (object);
nm_g_variant_unref (priv->options);
G_OBJECT_CLASS (nm_dhcp_config_parent_class)->finalize (object);
}
static void
nm_dhcp_config_class_init (NMDhcpConfigClass *config_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
object_class->get_property = get_property;
object_class->finalize = finalize;
obj_properties[PROP_OPTIONS] =
g_param_spec_variant (NM_DHCP_CONFIG_OPTIONS, "", "",
G_VARIANT_TYPE ("a{sv}"),
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
}
/*****************************************************************************/
struct _NMDhcp4Config {
NMDhcpConfig parent;
};
struct _NMDhcp4ConfigClass {
NMDhcpConfigClass parent;
};
G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_DHCP_CONFIG)
static void
nm_dhcp4_config_init (NMDhcp4Config *self)
{
}
static const NMDBusInterfaceInfoExtended interface_info_dhcp4_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DHCP4_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Options", "a{sv}", NM_DHCP_CONFIG_OPTIONS),
),
),
.legacy_property_changed = TRUE,
};
static void
nm_dhcp4_config_class_init (NMDhcp4ConfigClass *klass)
{
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP4Config");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_dhcp4_config);
dbus_object_class->export_on_construction = TRUE;
}
/*****************************************************************************/
struct _NMDhcp6Config {
NMDhcpConfig parent;
};
struct _NMDhcp6ConfigClass {
NMDhcpConfigClass parent;
};
G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_DHCP_CONFIG)
static void
nm_dhcp6_config_init (NMDhcp6Config *self)
{
}
static const NMDBusInterfaceInfoExtended interface_info_dhcp6_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DHCP6_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Options", "a{sv}", NM_DHCP_CONFIG_OPTIONS),
),
),
.legacy_property_changed = TRUE,
};
static void
nm_dhcp6_config_class_init (NMDhcp6ConfigClass *klass)
{
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP6Config");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_dhcp6_config);
dbus_object_class->export_on_construction = TRUE;
}

35
src/nm-dhcp-config.h Normal file
View file

@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2008 Red Hat, Inc.
*/
#ifndef __NM_DHCP_CONFIG_H__
#define __NM_DHCP_CONFIG_H__
/*****************************************************************************/
#define NM_TYPE_DHCP_CONFIG (nm_dhcp_config_get_type ())
#define NM_DHCP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_CONFIG, NMDhcpConfig))
#define NM_DHCP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_CONFIG, NMDhcpConfigClass))
#define NM_IS_DHCP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP_CONFIG))
#define NM_IS_DHCP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP_CONFIG))
#define NM_DHCP_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_CONFIG, NMDhcpConfigClass))
#define NM_DHCP_CONFIG_OPTIONS "options"
typedef struct _NMDhcpConfigClass NMDhcpConfigClass;
GType nm_dhcp_config_get_type (void);
NMDhcpConfig *nm_dhcp_config_new (int addr_family);
int nm_dhcp_config_get_addr_family (NMDhcpConfig *self);
void nm_dhcp_config_set_options (NMDhcpConfig *self,
GHashTable *options);
const char *nm_dhcp_config_get_option (NMDhcpConfig *self, const char *option);
GVariant *nm_dhcp_config_get_options (NMDhcpConfig *self);
#endif /* __NM_DHCP_CONFIG_H__ */

View file

@ -1,158 +0,0 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2008 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-dhcp4-config.h"
#include "nm-dbus-interface.h"
#include "nm-utils.h"
#include "nm-dbus-object.h"
#include "nm-core-utils.h"
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMDhcp4Config,
PROP_OPTIONS,
);
typedef struct {
GVariant *options;
} NMDhcp4ConfigPrivate;
struct _NMDhcp4Config {
NMDBusObject parent;
NMDhcp4ConfigPrivate _priv;
};
struct _NMDhcp4ConfigClass {
NMDBusObjectClass parent;
};
G_DEFINE_TYPE (NMDhcp4Config, nm_dhcp4_config, NM_TYPE_DBUS_OBJECT)
#define NM_DHCP4_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp4Config, NM_IS_DHCP4_CONFIG)
/*****************************************************************************/
void
nm_dhcp4_config_set_options (NMDhcp4Config *self,
GHashTable *options)
{
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (self);
GVariant *val;
g_return_if_fail (NM_IS_DHCP4_CONFIG (self));
g_return_if_fail (options);
val = nm_utils_strdict_to_variant (options);
g_variant_unref (priv->options);
priv->options = g_variant_ref_sink (val);
_notify (self, PROP_OPTIONS);
}
const char *
nm_dhcp4_config_get_option (NMDhcp4Config *self, const char *key)
{
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (self);
const char *value;
g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);
g_return_val_if_fail (key != NULL, NULL);
if (g_variant_lookup (priv->options, key, "&s", &value))
return value;
else
return NULL;
}
GVariant *
nm_dhcp4_config_get_options (NMDhcp4Config *self)
{
g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);
return g_variant_ref (NM_DHCP4_CONFIG_GET_PRIVATE (self)->options);
}
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object);
switch (prop_id) {
case PROP_OPTIONS:
g_value_set_variant (value, priv->options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/*****************************************************************************/
static void
nm_dhcp4_config_init (NMDhcp4Config *self)
{
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (self);
priv->options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0);
g_variant_ref_sink (priv->options);
}
NMDhcp4Config *
nm_dhcp4_config_new (void)
{
return NM_DHCP4_CONFIG (g_object_new (NM_TYPE_DHCP4_CONFIG, NULL));
}
static void
finalize (GObject *object)
{
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (object);
g_variant_unref (priv->options);
G_OBJECT_CLASS (nm_dhcp4_config_parent_class)->finalize (object);
}
static const NMDBusInterfaceInfoExtended interface_info_dhcp4_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DHCP4_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Options", "a{sv}", NM_DHCP4_CONFIG_OPTIONS),
),
),
.legacy_property_changed = TRUE,
};
static void
nm_dhcp4_config_class_init (NMDhcp4ConfigClass *config_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (config_class);
object_class->get_property = get_property;
object_class->finalize = finalize;
dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP4Config");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_dhcp4_config);
dbus_object_class->export_on_construction = TRUE;
obj_properties[PROP_OPTIONS] =
g_param_spec_variant (NM_DHCP4_CONFIG_OPTIONS, "", "",
G_VARIANT_TYPE ("a{sv}"),
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
}

View file

@ -1,31 +0,0 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2008 Red Hat, Inc.
*/
#ifndef __NETWORKMANAGER_DHCP4_CONFIG_H__
#define __NETWORKMANAGER_DHCP4_CONFIG_H__
#define NM_TYPE_DHCP4_CONFIG (nm_dhcp4_config_get_type ())
#define NM_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4Config))
#define NM_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass))
#define NM_IS_DHCP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP4_CONFIG))
#define NM_IS_DHCP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP4_CONFIG))
#define NM_DHCP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP4_CONFIG, NMDhcp4ConfigClass))
#define NM_DHCP4_CONFIG_OPTIONS "options"
typedef struct _NMDhcp4ConfigClass NMDhcp4ConfigClass;
GType nm_dhcp4_config_get_type (void);
NMDhcp4Config *nm_dhcp4_config_new (void);
void nm_dhcp4_config_set_options (NMDhcp4Config *config,
GHashTable *options);
const char *nm_dhcp4_config_get_option (NMDhcp4Config *config, const char *option);
GVariant *nm_dhcp4_config_get_options (NMDhcp4Config *config);
#endif /* __NETWORKMANAGER_DHCP4_CONFIG_H__ */

View file

@ -1,156 +0,0 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2008 Red Hat, Inc.
*/
#include "nm-default.h"
#include "nm-dhcp6-config.h"
#include "nm-dbus-interface.h"
#include "nm-utils.h"
#include "nm-dbus-object.h"
#include "nm-core-utils.h"
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMDhcp6Config,
PROP_OPTIONS,
);
typedef struct {
GVariant *options;
} NMDhcp6ConfigPrivate;
struct _NMDhcp6Config {
NMDBusObject parent;
NMDhcp6ConfigPrivate _priv;
};
struct _NMDhcp6ConfigClass {
NMDBusObjectClass parent;
};
G_DEFINE_TYPE (NMDhcp6Config, nm_dhcp6_config, NM_TYPE_DBUS_OBJECT)
#define NM_DHCP6_CONFIG_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDhcp6Config, NM_IS_DHCP6_CONFIG)
/*****************************************************************************/
void
nm_dhcp6_config_set_options (NMDhcp6Config *self,
GHashTable *options)
{
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (self);
GVariant *val;
g_return_if_fail (NM_IS_DHCP6_CONFIG (self));
g_return_if_fail (options);
val = nm_utils_strdict_to_variant (options);
g_variant_unref (priv->options);
priv->options = g_variant_ref_sink (val);
_notify (self, PROP_OPTIONS);
}
const char *
nm_dhcp6_config_get_option (NMDhcp6Config *self, const char *key)
{
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (self);
const char *value;
g_return_val_if_fail (NM_IS_DHCP6_CONFIG (self), NULL);
g_return_val_if_fail (key != NULL, NULL);
if (g_variant_lookup (priv->options, key, "&s", &value))
return value;
else
return NULL;
}
GVariant *
nm_dhcp6_config_get_options (NMDhcp6Config *self)
{
g_return_val_if_fail (NM_IS_DHCP6_CONFIG (self), NULL);
return g_variant_ref (NM_DHCP6_CONFIG_GET_PRIVATE (self)->options);
}
/*****************************************************************************/
static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
switch (prop_id) {
case PROP_OPTIONS:
g_value_set_variant (value, priv->options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
nm_dhcp6_config_init (NMDhcp6Config *self)
{
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (self);
priv->options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0);
g_variant_ref_sink (priv->options);
}
NMDhcp6Config *
nm_dhcp6_config_new (void)
{
return NM_DHCP6_CONFIG (g_object_new (NM_TYPE_DHCP6_CONFIG, NULL));
}
static void
finalize (GObject *object)
{
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (object);
g_variant_unref (priv->options);
G_OBJECT_CLASS (nm_dhcp6_config_parent_class)->finalize (object);
}
static const NMDBusInterfaceInfoExtended interface_info_dhcp6_config = {
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
NM_DBUS_INTERFACE_DHCP6_CONFIG,
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS (
&nm_signal_info_property_changed_legacy,
),
.properties = NM_DEFINE_GDBUS_PROPERTY_INFOS (
NM_DEFINE_DBUS_PROPERTY_INFO_EXTENDED_READABLE_L ("Options", "a{sv}", NM_DHCP6_CONFIG_OPTIONS),
),
),
.legacy_property_changed = TRUE,
};
static void
nm_dhcp6_config_class_init (NMDhcp6ConfigClass *config_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (config_class);
object_class->get_property = get_property;
object_class->finalize = finalize;
dbus_object_class->export_path = NM_DBUS_EXPORT_PATH_NUMBERED (NM_DBUS_PATH"/DHCP6Config");
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_dhcp6_config);
dbus_object_class->export_on_construction = TRUE;
obj_properties[PROP_OPTIONS] =
g_param_spec_variant (NM_DHCP6_CONFIG_OPTIONS, "", "",
G_VARIANT_TYPE ("a{sv}"),
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
}

View file

@ -1,31 +0,0 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2008 Red Hat, Inc.
*/
#ifndef __NETWORKMANAGER_DHCP6_CONFIG_H__
#define __NETWORKMANAGER_DHCP6_CONFIG_H__
#define NM_TYPE_DHCP6_CONFIG (nm_dhcp6_config_get_type ())
#define NM_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6Config))
#define NM_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass))
#define NM_IS_DHCP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DHCP6_CONFIG))
#define NM_IS_DHCP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DHCP6_CONFIG))
#define NM_DHCP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP6_CONFIG, NMDhcp6ConfigClass))
#define NM_DHCP6_CONFIG_OPTIONS "options"
typedef struct _NMDhcp6ConfigClass NMDhcp6ConfigClass;
GType nm_dhcp6_config_get_type (void);
NMDhcp6Config *nm_dhcp6_config_new (void);
void nm_dhcp6_config_set_options (NMDhcp6Config *config,
GHashTable *options);
const char *nm_dhcp6_config_get_option (NMDhcp6Config *config, const char *option);
GVariant *nm_dhcp6_config_get_options (NMDhcp6Config *self);
#endif /* __NETWORKMANAGER_DHCP6_CONFIG_H__ */

View file

@ -14,8 +14,7 @@
#include "nm-connectivity.h" #include "nm-connectivity.h"
#include "nm-act-request.h" #include "nm-act-request.h"
#include "devices/nm-device.h" #include "devices/nm-device.h"
#include "nm-dhcp4-config.h" #include "nm-dhcp-config.h"
#include "nm-dhcp6-config.h"
#include "nm-proxy-config.h" #include "nm-proxy-config.h"
#include "nm-ip4-config.h" #include "nm-ip4-config.h"
#include "nm-ip6-config.h" #include "nm-ip6-config.h"
@ -331,8 +330,7 @@ fill_device_props (NMDevice *device,
NMProxyConfig *proxy_config; NMProxyConfig *proxy_config;
NMIP4Config *ip4_config; NMIP4Config *ip4_config;
NMIP6Config *ip6_config; NMIP6Config *ip6_config;
NMDhcp4Config *dhcp4_config; NMDhcpConfig *dhcp_config;
NMDhcp6Config *dhcp6_config;
/* If the action is for a VPN, send the VPN's IP interface instead of the device's */ /* If the action is for a VPN, send the VPN's IP interface instead of the device's */
g_variant_builder_add (dev_builder, "{sv}", NMD_DEVICE_PROPS_IP_INTERFACE, g_variant_builder_add (dev_builder, "{sv}", NMD_DEVICE_PROPS_IP_INTERFACE,
@ -360,13 +358,13 @@ fill_device_props (NMDevice *device,
if (ip6_config) if (ip6_config)
dump_ip6_to_props (ip6_config, ip6_builder); dump_ip6_to_props (ip6_config, ip6_builder);
dhcp4_config = nm_device_get_dhcp4_config (device); dhcp_config = nm_device_get_dhcp_config (device, AF_INET);
if (dhcp4_config) if (dhcp_config)
*dhcp4_props = nm_dhcp4_config_get_options (dhcp4_config); *dhcp4_props = nm_g_variant_ref (nm_dhcp_config_get_options (dhcp_config));
dhcp6_config = nm_device_get_dhcp6_config (device); dhcp_config = nm_device_get_dhcp_config (device, AF_INET6);
if (dhcp6_config) if (dhcp_config)
*dhcp6_props = nm_dhcp6_config_get_options (dhcp6_config); *dhcp6_props = nm_g_variant_ref (nm_dhcp_config_get_options (dhcp_config));
} }
static void static void

View file

@ -6496,7 +6496,7 @@ nm_manager_write_device_state (NMManager *self, NMDevice *device)
guint32 route_metric_default_aspired; guint32 route_metric_default_aspired;
guint32 route_metric_default_effective; guint32 route_metric_default_effective;
int nm_owned; int nm_owned;
NMDhcp4Config *dhcp4_config; NMDhcpConfig *dhcp_config;
const char *next_server = NULL; const char *next_server = NULL;
const char *root_path = NULL; const char *root_path = NULL;
@ -6534,10 +6534,10 @@ nm_manager_write_device_state (NMManager *self, NMDevice *device)
route_metric_default_effective = _device_route_metric_get (self, ifindex, NM_DEVICE_TYPE_UNKNOWN, route_metric_default_effective = _device_route_metric_get (self, ifindex, NM_DEVICE_TYPE_UNKNOWN,
TRUE, &route_metric_default_aspired); TRUE, &route_metric_default_aspired);
dhcp4_config = nm_device_get_dhcp4_config (device); dhcp_config = nm_device_get_dhcp_config (device, AF_INET);
if (dhcp4_config) { if (dhcp_config) {
root_path = nm_dhcp4_config_get_option (dhcp4_config, "root_path"); root_path = nm_dhcp_config_get_option (dhcp_config, "root_path");
next_server = nm_dhcp4_config_get_option (dhcp4_config, "next_server"); next_server = nm_dhcp_config_get_option (dhcp_config, "next_server");
} }
return nm_config_device_state_write (ifindex, return nm_config_device_state_write (ifindex,

View file

@ -29,8 +29,7 @@
#include "settings/nm-settings.h" #include "settings/nm-settings.h"
#include "settings/nm-settings-connection.h" #include "settings/nm-settings-connection.h"
#include "settings/nm-agent-manager.h" #include "settings/nm-agent-manager.h"
#include "nm-dhcp4-config.h" #include "nm-dhcp-config.h"
#include "nm-dhcp6-config.h"
#include "nm-config.h" #include "nm-config.h"
#include "nm-netns.h" #include "nm-netns.h"
#include "nm-hostname-manager.h" #include "nm-hostname-manager.h"
@ -692,6 +691,7 @@ update_system_hostname (NMPolicy *self, const char *msg)
const NMPlatformIP4Address *addr4; const NMPlatformIP4Address *addr4;
const NMPlatformIP6Address *addr6; const NMPlatformIP6Address *addr6;
NMDevice *device; NMDevice *device;
NMDhcpConfig *dhcp_config;
g_return_if_fail (self != NULL); g_return_if_fail (self != NULL);
@ -745,12 +745,10 @@ update_system_hostname (NMPolicy *self, const char *msg)
} }
if (priv->default_ac4) { if (priv->default_ac4) {
NMDhcp4Config *dhcp4_config;
/* Grab a hostname out of the device's DHCP4 config */ /* Grab a hostname out of the device's DHCP4 config */
dhcp4_config = nm_device_get_dhcp4_config (get_default_device (self, AF_INET)); dhcp_config = nm_device_get_dhcp_config (get_default_device (self, AF_INET), AF_INET);
if (dhcp4_config) { if (dhcp_config) {
dhcp_hostname = nm_dhcp4_config_get_option (dhcp4_config, "host_name"); dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "host_name");
if (dhcp_hostname && dhcp_hostname[0]) { if (dhcp_hostname && dhcp_hostname[0]) {
p = nm_str_skip_leading_spaces (dhcp_hostname); p = nm_str_skip_leading_spaces (dhcp_hostname);
if (p[0]) { if (p[0]) {
@ -765,12 +763,10 @@ update_system_hostname (NMPolicy *self, const char *msg)
} }
if (priv->default_ac6) { if (priv->default_ac6) {
NMDhcp6Config *dhcp6_config;
/* Grab a hostname out of the device's DHCP6 config */ /* Grab a hostname out of the device's DHCP6 config */
dhcp6_config = nm_device_get_dhcp6_config (get_default_device (self, AF_INET6)); dhcp_config = nm_device_get_dhcp_config (get_default_device (self, AF_INET6), AF_INET6);
if (dhcp6_config) { if (dhcp_config) {
dhcp_hostname = nm_dhcp6_config_get_option (dhcp6_config, "host_name"); dhcp_hostname = nm_dhcp_config_get_option (dhcp_config, "host_name");
if (dhcp_hostname && dhcp_hostname[0]) { if (dhcp_hostname && dhcp_hostname[0]) {
p = nm_str_skip_leading_spaces (dhcp_hostname); p = nm_str_skip_leading_spaces (dhcp_hostname);
if (p[0]) { if (p[0]) {

View file

@ -24,8 +24,7 @@ typedef struct _NMConfig NMConfig;
typedef struct _NMConfigData NMConfigData; typedef struct _NMConfigData NMConfigData;
typedef struct _NMConnectivity NMConnectivity; typedef struct _NMConnectivity NMConnectivity;
typedef struct _NMDevice NMDevice; typedef struct _NMDevice NMDevice;
typedef struct _NMDhcp4Config NMDhcp4Config; typedef struct _NMDhcpConfig NMDhcpConfig;
typedef struct _NMDhcp6Config NMDhcp6Config;
typedef struct _NMProxyConfig NMProxyConfig; typedef struct _NMProxyConfig NMProxyConfig;
typedef struct _NMIPConfig NMIPConfig; typedef struct _NMIPConfig NMIPConfig;
typedef struct _NMIP4Config NMIP4Config; typedef struct _NMIP4Config NMIP4Config;