summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-09-11 11:30:48 +0200
committerThomas Haller <thaller@redhat.com>2017-09-11 15:05:57 +0200
commit3c84dd15e066e2a7e309c408563456c2396dfc15 (patch)
treed49b68ff87ca54289bdefcad959669218820e7d8
parent1aa36dde94dfb32a7172815ecb918b662aa9253b (diff)
downloadNetworkManager-3c84dd15e066e2a7e309c408563456c2396dfc15.tar.gz
core/dhcp: use addr-family parameter for instead of boolean
In many cases we want to treat IPv4 and IPv6 generically. That looks nicer if we distingish by an @addr_family integer, instead of a boolean. Replace the @is_ipv6 boolean with an @addr_family paramter. The @is_ipv6 boolean is inconsistent with other places where we use @is_ipv4 to indicate the opposite. Eventually, we should use @addr_family everywhere. Also, at the call site it's not immediately clear what TRUE/FALSE means, here AF_INET/AF_INET6 is better.
-rw-r--r--src/devices/nm-device.c6
-rw-r--r--src/dhcp/nm-dhcp-client-logging.h21
-rw-r--r--src/dhcp/nm-dhcp-client.c70
-rw-r--r--src/dhcp/nm-dhcp-client.h8
-rw-r--r--src/dhcp/nm-dhcp-dhclient-utils.c26
-rw-r--r--src/dhcp/nm-dhcp-dhclient-utils.h4
-rw-r--r--src/dhcp/nm-dhcp-dhclient.c80
-rw-r--r--src/dhcp/nm-dhcp-manager.c25
-rw-r--r--src/dhcp/nm-dhcp-manager.h2
-rw-r--r--src/dhcp/nm-dhcp-systemd.c14
-rw-r--r--src/dhcp/tests/test-dhcp-dhclient.c46
11 files changed, 166 insertions, 136 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index aff5184d21..6158cc917a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -5805,7 +5805,7 @@ dhcp4_state_changed (NMDhcpClient *client,
NMIP4Config *manual, **configs;
NMConnection *connection;
- g_return_if_fail (nm_dhcp_client_get_ipv6 (client) == FALSE);
+ g_return_if_fail (nm_dhcp_client_get_addr_family (client) == AF_INET);
g_return_if_fail (!ip4_config || NM_IS_IP4_CONFIG (ip4_config));
_LOGD (LOGD_DHCP4, "new DHCPv4 client state %d", state);
@@ -6570,7 +6570,7 @@ dhcp6_state_changed (NMDhcpClient *client,
NMDevice *self = NM_DEVICE (user_data);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- g_return_if_fail (nm_dhcp_client_get_ipv6 (client) == TRUE);
+ g_return_if_fail (nm_dhcp_client_get_addr_family (client) == AF_INET6);
g_return_if_fail (!ip6_config || NM_IS_IP6_CONFIG (ip6_config));
_LOGD (LOGD_DHCP6, "new DHCPv6 client state %d", state);
@@ -10500,10 +10500,10 @@ find_ip4_lease_config (NMDevice *self,
leases = nm_dhcp_manager_get_lease_ip_configs (nm_dhcp_manager_get (),
nm_device_get_multi_index (self),
+ AF_INET,
ip_iface,
ip_ifindex,
nm_connection_get_uuid (connection),
- FALSE,
nm_device_get_ip4_route_metric (self));
for (liter = leases; liter && !found; liter = liter->next) {
NMIP4Config *lease_config = liter->data;
diff --git a/src/dhcp/nm-dhcp-client-logging.h b/src/dhcp/nm-dhcp-client-logging.h
index 1047a7d7bd..1ed47170d4 100644
--- a/src/dhcp/nm-dhcp-client-logging.h
+++ b/src/dhcp/nm-dhcp-client-logging.h
@@ -23,6 +23,23 @@
#include "nm-dhcp-client.h"
+static inline NMLogDomain
+_nm_dhcp_client_get_domain (NMDhcpClient *self)
+{
+ if (self) {
+ switch (nm_dhcp_client_get_addr_family (self)) {
+ case AF_INET:
+ return LOGD_DHCP4;
+ case AF_INET6:
+ return LOGD_DHCP6;
+ default:
+ nm_assert_not_reached ();
+ break;
+ }
+ }
+ return LOGD_DHCP;
+}
+
#define _NMLOG_PREFIX_NAME "dhcp"
#define _NMLOG_DOMAIN LOGD_DHCP
#define _NMLOG(level, ...) \
@@ -38,9 +55,7 @@
if (nm_logging_enabled (_level, _NMLOG_DOMAIN)) { \
NMDhcpClient *_self = (NMDhcpClient *) (self); \
const char *__ifname = _self ? nm_dhcp_client_get_iface (_self) : NULL; \
- const NMLogDomain _domain = !_self \
- ? LOGD_DHCP \
- : (nm_dhcp_client_get_ipv6 (_self) ? LOGD_DHCP6 : LOGD_DHCP4); \
+ const NMLogDomain _domain = _nm_dhcp_client_get_domain (_self); \
\
nm_log (_level, _domain, __ifname, NULL, \
"%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c
index e409fb4f3f..e9e67565d4 100644
--- a/src/dhcp/nm-dhcp-client.c
+++ b/src/dhcp/nm-dhcp-client.c
@@ -51,10 +51,10 @@ static guint signals[LAST_SIGNAL] = { 0 };
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_MULTI_IDX,
+ PROP_ADDR_FAMILY,
PROP_IFACE,
PROP_IFINDEX,
PROP_HWADDR,
- PROP_IPV6,
PROP_UUID,
PROP_PRIORITY,
PROP_TIMEOUT,
@@ -63,22 +63,21 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
typedef struct _NMDhcpClientPrivate {
NMDedupMultiIndex *multi_idx;
char * iface;
- int ifindex;
GByteArray * hwaddr;
- gboolean ipv6;
char * uuid;
- guint32 priority;
- guint32 timeout;
GByteArray * duid;
GBytes * client_id;
char * hostname;
- gboolean use_fqdn;
-
- NMDhcpState state;
pid_t pid;
guint timeout_id;
guint watch_id;
- gboolean info_only;
+ int addr_family;
+ int ifindex;
+ guint32 priority;
+ guint32 timeout;
+ NMDhcpState state;
+ bool info_only:1;
+ bool use_fqdn:1;
} NMDhcpClientPrivate;
G_DEFINE_TYPE_EXTENDED (NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, {})
@@ -119,12 +118,12 @@ nm_dhcp_client_get_ifindex (NMDhcpClient *self)
return NM_DHCP_CLIENT_GET_PRIVATE (self)->ifindex;
}
-gboolean
-nm_dhcp_client_get_ipv6 (NMDhcpClient *self)
+int
+nm_dhcp_client_get_addr_family (NMDhcpClient *self)
{
- g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
+ g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), AF_UNSPEC);
- return NM_DHCP_CLIENT_GET_PRIVATE (self)->ipv6;
+ return NM_DHCP_CLIENT_GET_PRIVATE (self)->addr_family;
}
const char *
@@ -315,8 +314,8 @@ nm_dhcp_client_set_state (NMDhcpClient *self,
watch_cleanup (self);
if (new_state == NM_DHCP_STATE_BOUND) {
- g_assert ( (priv->ipv6 && NM_IS_IP6_CONFIG (ip_config))
- || (!priv->ipv6 && NM_IS_IP4_CONFIG (ip_config)));
+ g_assert ( (priv->addr_family == AF_INET && NM_IS_IP4_CONFIG (ip_config))
+ || (priv->addr_family == AF_INET6 && NM_IS_IP6_CONFIG (ip_config)));
g_assert (options);
} else {
g_assert (ip_config == NULL);
@@ -331,7 +330,8 @@ nm_dhcp_client_set_state (NMDhcpClient *self,
if ((priv->state == new_state) && (new_state != NM_DHCP_STATE_BOUND))
return;
- if (priv->ipv6 && new_state == NM_DHCP_STATE_BOUND) {
+ if ( priv->addr_family == AF_INET6
+ && new_state == NM_DHCP_STATE_BOUND) {
char *start, *iaid;
iaid = g_hash_table_lookup (options, "iaid");
@@ -438,7 +438,7 @@ nm_dhcp_client_start_ip4 (NMDhcpClient *self,
priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
g_return_val_if_fail (priv->pid == -1, FALSE);
- g_return_val_if_fail (priv->ipv6 == FALSE, FALSE);
+ g_return_val_if_fail (priv->addr_family == AF_INET, FALSE);
g_return_val_if_fail (priv->uuid != NULL, FALSE);
_LOGI ("activation: beginning transaction (timeout in %u seconds)", (guint) priv->timeout);
@@ -540,7 +540,7 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
g_return_val_if_fail (priv->pid == -1, FALSE);
- g_return_val_if_fail (priv->ipv6 == TRUE, FALSE);
+ g_return_val_if_fail (priv->addr_family == AF_INET6, FALSE);
g_return_val_if_fail (priv->uuid != NULL, FALSE);
/* If we don't have one yet, read the default DUID for this DHCPv6 client
@@ -775,20 +775,20 @@ nm_dhcp_client_handle_event (gpointer unused,
/* Create the IP config */
g_warn_if_fail (g_hash_table_size (str_options));
if (g_hash_table_size (str_options)) {
- if (priv->ipv6) {
- prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options);
- ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
+ if (priv->addr_family == AF_INET) {
+ ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (nm_dhcp_client_get_multi_idx (self),
priv->ifindex,
priv->iface,
str_options,
- priv->priority,
- priv->info_only);
+ priv->priority);
} else {
- ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (nm_dhcp_client_get_multi_idx (self),
+ prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options);
+ ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self),
priv->ifindex,
priv->iface,
str_options,
- priv->priority);
+ priv->priority,
+ priv->info_only);
}
}
}
@@ -836,8 +836,8 @@ get_property (GObject *object, guint prop_id,
case PROP_HWADDR:
g_value_set_boxed (value, priv->hwaddr);
break;
- case PROP_IPV6:
- g_value_set_boolean (value, priv->ipv6);
+ case PROP_ADDR_FAMILY:
+ g_value_set_int (value, priv->addr_family);
break;
case PROP_UUID:
g_value_set_string (value, priv->uuid);
@@ -881,9 +881,11 @@ set_property (GObject *object, guint prop_id,
/* construct-only */
priv->hwaddr = g_value_dup_boxed (value);
break;
- case PROP_IPV6:
+ case PROP_ADDR_FAMILY:
/* construct-only */
- priv->ipv6 = g_value_get_boolean (value);
+ priv->addr_family = g_value_get_int (value);
+ if (!NM_IN_SET (priv->addr_family, AF_INET, AF_INET6))
+ g_return_if_reached ();
break;
case PROP_UUID:
/* construct-only */
@@ -988,11 +990,11 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
- obj_properties[PROP_IPV6] =
- g_param_spec_boolean (NM_DHCP_CLIENT_IPV6, "", "",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
+ obj_properties[PROP_ADDR_FAMILY] =
+ g_param_spec_int (NM_DHCP_CLIENT_ADDR_FAMILY, "", "",
+ 0, G_MAXINT, AF_UNSPEC,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
obj_properties[PROP_UUID] =
g_param_spec_string (NM_DHCP_CLIENT_UUID, "", "",
diff --git a/src/dhcp/nm-dhcp-client.h b/src/dhcp/nm-dhcp-client.h
index 9e71b1c0e8..38f9c6de12 100644
--- a/src/dhcp/nm-dhcp-client.h
+++ b/src/dhcp/nm-dhcp-client.h
@@ -34,9 +34,9 @@
#define NM_DHCP_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClientClass))
#define NM_DHCP_CLIENT_INTERFACE "iface"
+#define NM_DHCP_CLIENT_ADDR_FAMILY "addr-family"
#define NM_DHCP_CLIENT_IFINDEX "ifindex"
#define NM_DHCP_CLIENT_HWADDR "hwaddr"
-#define NM_DHCP_CLIENT_IPV6 "ipv6"
#define NM_DHCP_CLIENT_UUID "uuid"
#define NM_DHCP_CLIENT_PRIORITY "priority"
#define NM_DHCP_CLIENT_TIMEOUT "timeout"
@@ -108,12 +108,12 @@ struct _NMDedupMultiIndex *nm_dhcp_client_get_multi_idx (NMDhcpClient *self);
pid_t nm_dhcp_client_get_pid (NMDhcpClient *self);
+int nm_dhcp_client_get_addr_family (NMDhcpClient *self);
+
const char *nm_dhcp_client_get_iface (NMDhcpClient *self);
int nm_dhcp_client_get_ifindex (NMDhcpClient *self);
-gboolean nm_dhcp_client_get_ipv6 (NMDhcpClient *self);
-
const char *nm_dhcp_client_get_uuid (NMDhcpClient *self);
const GByteArray *nm_dhcp_client_get_duid (NMDhcpClient *self);
@@ -179,10 +179,10 @@ typedef struct {
const char *name;
const char *(*get_path) (void);
GSList *(*get_lease_ip_configs) (struct _NMDedupMultiIndex *multi_idx,
+ int addr_family,
const char *iface,
int ifindex,
const char *uuid,
- gboolean ipv6,
guint32 default_route_metric);
} NMDhcpClientFactory;
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c
index f66c5880e4..9ae355ece1 100644
--- a/src/dhcp/nm-dhcp-dhclient-utils.c
+++ b/src/dhcp/nm-dhcp-dhclient-utils.c
@@ -257,7 +257,7 @@ read_interface (const char *line, char *interface, guint size)
char *
nm_dhcp_dhclient_create_config (const char *interface,
- gboolean is_ip6,
+ int addr_family,
GBytes *client_id,
const char *anycast_addr,
const char *hostname,
@@ -272,6 +272,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
int i;
g_return_val_if_fail (!anycast_addr || nm_utils_hwaddr_valid (anycast_addr, ETH_ALEN), NULL);
+ g_return_val_if_fail (NM_IN_SET (addr_family, AF_INET, AF_INET6), NULL);
new_contents = g_string_new (_("# Created by NetworkManager\n"));
fqdn_opts = g_ptr_array_sized_new (5);
@@ -373,18 +374,18 @@ nm_dhcp_dhclient_create_config (const char *interface,
} else
g_string_append_c (new_contents, '\n');
- if (is_ip6) {
- add_hostname6 (new_contents, hostname);
- add_request (reqs, "dhcp6.name-servers");
- add_request (reqs, "dhcp6.domain-search");
- add_request (reqs, "dhcp6.client-id");
- } else {
+ if (addr_family == AF_INET) {
add_ip4_config (new_contents, client_id, hostname, use_fqdn);
add_request (reqs, "rfc3442-classless-static-routes");
add_request (reqs, "ms-classless-static-routes");
add_request (reqs, "static-routes");
add_request (reqs, "wpad");
add_request (reqs, "ntp-servers");
+ } else {
+ add_hostname6 (new_contents, hostname);
+ add_request (reqs, "dhcp6.name-servers");
+ add_request (reqs, "dhcp6.domain-search");
+ add_request (reqs, "dhcp6.client-id");
}
if (reset_reqlist)
@@ -663,25 +664,25 @@ lease_validity_span (const char *str_expire, GDateTime *now)
/**
* nm_dhcp_dhclient_read_lease_ip_configs:
* @multi_idx: the multi index instance for the ip config object
+ * @addr_family: whether to read IPv4 or IPv6 leases
* @iface: the interface name to match leases with
* @ifindex: interface index of @iface
* @contents: the contents of a dhclient leasefile
- * @ipv6: whether to read IPv4 or IPv6 leases
* @now: the current UTC date/time; pass %NULL to automatically use current
* UTC time. Testcases may need a different value for 'now'
*
* Reads dhclient leases from @contents and parses them into either
- * #NMIP4Config or #NMIP6Config objects depending on the value of @ipv6.
+ * #NMIP4Config or #NMIP6Config objects depending on the value of @addr_family.
*
- * Returns: a #GSList of #NMIP4Config objects (if @ipv6 is %FALSE) or a list of
- * #NMIP6Config objects (if @ipv6 is %TRUE) containing the lease data.
+ * Returns: a #GSList of #NMIP4Config objects (if @addr_family is %AF_INET) or a list of
+ * #NMIP6Config objects (if @addr_family is %AF_INET6) containing the lease data.
*/
GSList *
nm_dhcp_dhclient_read_lease_ip_configs (NMDedupMultiIndex *multi_idx,
+ int addr_family,
const char *iface,
int ifindex,
const char *contents,
- gboolean ipv6,
GDateTime *now)
{
GSList *parsed = NULL, *iter, *leases = NULL;
@@ -690,6 +691,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (NMDedupMultiIndex *multi_idx,
gint32 now_monotonic_ts;
g_return_val_if_fail (contents != NULL, NULL);
+ nm_assert (NM_IN_SET (addr_family, AF_INET, AF_INET6));
split = g_strsplit_set (contents, "\n\r", -1);
if (!split)
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.h b/src/dhcp/nm-dhcp-dhclient-utils.h
index dd276bea45..de69fb297c 100644
--- a/src/dhcp/nm-dhcp-dhclient-utils.h
+++ b/src/dhcp/nm-dhcp-dhclient-utils.h
@@ -23,7 +23,7 @@
#include "nm-setting-ip6-config.h"
char *nm_dhcp_dhclient_create_config (const char *interface,
- gboolean is_ip6,
+ int addr_family,
GBytes *client_id,
const char *anycast_addr,
const char *hostname,
@@ -43,10 +43,10 @@ gboolean nm_dhcp_dhclient_save_duid (const char *leasefile,
GError **error);
GSList *nm_dhcp_dhclient_read_lease_ip_configs (struct _NMDedupMultiIndex *multi_idx,
+ int addr_family,
const char *iface,
int ifindex,
const char *contents,
- gboolean ipv6,
GDateTime *now);
GBytes *nm_dhcp_dhclient_get_client_id_from_config_file (const char *path);
diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c
index 73d53a4f47..39aaaabfc9 100644
--- a/src/dhcp/nm-dhcp-dhclient.c
+++ b/src/dhcp/nm-dhcp-dhclient.c
@@ -49,6 +49,15 @@
/*****************************************************************************/
+static const char *
+_addr_family_to_path_part (int addr_family)
+{
+ nm_assert (NM_IN_SET (addr_family, AF_INET, AF_INET6));
+ return (addr_family == AF_INET6) ? "6" : "";
+}
+
+/*****************************************************************************/
+
#define NM_TYPE_DHCP_DHCLIENT (nm_dhcp_dhclient_get_type ())
#define NM_DHCP_DHCLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclient))
#define NM_DHCP_DHCLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DHCP_DHCLIENT, NMDhcpDhclientClass))
@@ -94,9 +103,9 @@ nm_dhcp_dhclient_get_path (void)
/**
* get_dhclient_leasefile():
+ * @addr_family: AF_INET or AF_INET6
* @iface: the interface name of the device on which DHCP will be done
* @uuid: the connection UUID to which the returned lease should belong
- * @ipv6: %TRUE for IPv6, %FALSE for IPv4
* @out_preferred_path: on return, the "most preferred" leasefile path
*
* Returns the path of an existing leasefile (if any) for this interface and
@@ -106,16 +115,16 @@ nm_dhcp_dhclient_get_path (void)
* Returns: an existing leasefile, or %NULL if no matching leasefile could be found
*/
static char *
-get_dhclient_leasefile (const char *iface,
+get_dhclient_leasefile (int addr_family,
+ const char *iface,
const char *uuid,
- gboolean ipv6,
char **out_preferred_path)
{
char *path;
/* /var/lib/NetworkManager is the preferred leasefile path */
path = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s-%s.lease",
- ipv6 ? "6" : "",
+ _addr_family_to_path_part (addr_family),
uuid,
iface);
if (out_preferred_path)
@@ -133,14 +142,14 @@ get_dhclient_leasefile (const char *iface,
/* Old Debian, SUSE, and Mandriva location */
g_free (path);
path = g_strdup_printf (LOCALSTATEDIR "/lib/dhcp/dhclient%s-%s-%s.lease",
- ipv6 ? "6" : "", uuid, iface);
+ _addr_family_to_path_part (addr_family), uuid, iface);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
/* Old Red Hat and Fedora location */
g_free (path);
path = g_strdup_printf (LOCALSTATEDIR "/lib/dhclient/dhclient%s-%s-%s.lease",
- ipv6 ? "6" : "", uuid, iface);
+ _addr_family_to_path_part (addr_family), uuid, iface);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
@@ -151,17 +160,17 @@ get_dhclient_leasefile (const char *iface,
static GSList *
nm_dhcp_dhclient_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
+ int addr_family,
const char *iface,
int ifindex,
const char *uuid,
- gboolean ipv6,
guint32 default_route_metric)
{
char *contents = NULL;
char *leasefile;
GSList *leases = NULL;
- leasefile = get_dhclient_leasefile (iface, uuid, FALSE, NULL);
+ leasefile = get_dhclient_leasefile (addr_family, iface, uuid, NULL);
if (!leasefile)
return NULL;
@@ -169,7 +178,7 @@ nm_dhcp_dhclient_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
&& g_file_get_contents (leasefile, &contents, NULL, NULL)
&& contents
&& contents[0])
- leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, iface, ifindex, contents, ipv6, NULL);
+ leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, addr_family, iface, ifindex, contents, NULL);
g_free (leasefile);
g_free (contents);
@@ -179,9 +188,9 @@ nm_dhcp_dhclient_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
static gboolean
merge_dhclient_config (NMDhcpDhclient *self,
+ int addr_family,
const char *iface,
const char *conf_file,
- gboolean is_ip6,
GBytes *client_id,
const char *anycast_addr,
const char *hostname,
@@ -206,7 +215,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
}
}
- new = nm_dhcp_dhclient_create_config (iface, is_ip6, client_id, anycast_addr, hostname, use_fqdn, orig_path, orig, out_new_client_id);
+ new = nm_dhcp_dhclient_create_config (iface, addr_family, client_id, anycast_addr, hostname, use_fqdn, orig_path, orig, out_new_client_id);
g_assert (new);
success = g_file_set_contents (conf_file, new, -1, error);
g_free (new);
@@ -216,7 +225,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
}
static char *
-find_existing_config (NMDhcpDhclient *self, const char *iface, const char *uuid, gboolean ipv6)
+find_existing_config (NMDhcpDhclient *self, int addr_family, const char *iface, const char *uuid)
{
char *path;
@@ -225,20 +234,20 @@ find_existing_config (NMDhcpDhclient *self, const char *iface, const char *uuid,
* or generic.
*/
if (uuid) {
- path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", uuid);
+ path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", _addr_family_to_path_part (addr_family), uuid);
_LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
}
- path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface);
+ path = g_strdup_printf (NMCONFDIR "/dhclient%s-%s.conf", _addr_family_to_path_part (addr_family), iface);
_LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
- path = g_strdup_printf (NMCONFDIR "/dhclient%s.conf", ipv6 ? "6" : "");
+ path = g_strdup_printf (NMCONFDIR "/dhclient%s.conf", _addr_family_to_path_part (addr_family));
_LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
@@ -252,25 +261,25 @@ find_existing_config (NMDhcpDhclient *self, const char *iface, const char *uuid,
* which is then used by many other distributions. Some distributions
* (including Fedora) don't even provide a default configuration file.
*/
- path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s-%s.conf", ipv6 ? "6" : "", iface);
+ path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s-%s.conf", _addr_family_to_path_part (addr_family), iface);
_LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
- path = g_strdup_printf (SYSCONFDIR "/dhclient%s-%s.conf", ipv6 ? "6" : "", iface);
+ path = g_strdup_printf (SYSCONFDIR "/dhclient%s-%s.conf", _addr_family_to_path_part (addr_family), iface);
_LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
- path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s.conf", ipv6 ? "6" : "");
+ path = g_strdup_printf (SYSCONFDIR "/dhcp/dhclient%s.conf", _addr_family_to_path_part (addr_family));
_LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
- path = g_strdup_printf (SYSCONFDIR "/dhclient%s.conf", ipv6 ? "6" : "");
+ path = g_strdup_printf (SYSCONFDIR "/dhclient%s.conf", _addr_family_to_path_part (addr_family));
_LOGD ("looking for existing config %s", path);
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
@@ -288,8 +297,8 @@ find_existing_config (NMDhcpDhclient *self, const char *iface, const char *uuid,
*/
static char *
create_dhclient_config (NMDhcpDhclient *self,
+ int addr_family,
const char *iface,
- gboolean is_ip6,
const char *uuid,
GBytes *client_id,
const char *dhcp_anycast_addr,
@@ -303,18 +312,18 @@ create_dhclient_config (NMDhcpDhclient *self,
g_return_val_if_fail (iface != NULL, NULL);
- new = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s.conf", is_ip6 ? "6" : "", iface);
+ new = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s.conf", _addr_family_to_path_part (addr_family), iface);
_LOGD ("creating composite dhclient config %s", new);
- orig = find_existing_config (self, iface, uuid, is_ip6);
+ orig = find_existing_config (self, addr_family, iface, uuid);
if (orig)
_LOGD ("merging existing dhclient config %s", orig);
else
_LOGD ("no existing dhclient configuration to merge");
error = NULL;
- success = merge_dhclient_config (self, iface, new, is_ip6, client_id, dhcp_anycast_addr,
- hostname, use_fqdn, orig, out_new_client_id, &error);
+ success = merge_dhclient_config (self, addr_family, iface, new, client_id, dhcp_anycast_addr,
+ hostname, use_fqdn, orig, out_new_client_id, &error);
if (!success) {
_LOGW ("error creating dhclient configuration: %s", error->message);
g_error_free (error);
@@ -340,7 +349,8 @@ dhclient_start (NMDhcpClient *client,
GError *error = NULL;
const char *iface, *uuid, *system_bus_address, *dhclient_path = NULL;
char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL;
- gboolean ipv6, success;
+ int addr_family;
+ gboolean success;
char *escaped, *preferred_leasefile_path = NULL;
guint32 timeout;
char timeout_str[64];
@@ -349,7 +359,7 @@ dhclient_start (NMDhcpClient *client,
iface = nm_dhcp_client_get_iface (client);
uuid = nm_dhcp_client_get_uuid (client);
- ipv6 = nm_dhcp_client_get_ipv6 (client);
+ addr_family = nm_dhcp_client_get_addr_family (client);
dhclient_path = nm_dhcp_dhclient_get_path ();
if (!dhclient_path) {
@@ -358,8 +368,8 @@ dhclient_start (NMDhcpClient *client,
}
pid_file = g_strdup_printf (RUNSTATEDIR "/dhclient%s-%s.pid",
- ipv6 ? "6" : "",
- iface);
+ _addr_family_to_path_part (addr_family),
+ iface);
/* Kill any existing dhclient from the pidfile */
binary_name = g_path_get_basename (dhclient_path);
@@ -373,7 +383,7 @@ dhclient_start (NMDhcpClient *client,
}
g_free (priv->lease_file);
- priv->lease_file = get_dhclient_leasefile (iface, uuid, ipv6, &preferred_leasefile_path);
+ priv->lease_file = get_dhclient_leasefile (addr_family, iface, uuid, &preferred_leasefile_path);
if (!priv->lease_file) {
/* No existing leasefile, dhclient will create one at the preferred path */
priv->lease_file = g_strdup (preferred_leasefile_path);
@@ -399,7 +409,7 @@ dhclient_start (NMDhcpClient *client,
g_free (preferred_leasefile_path);
/* Save the DUID to the leasefile dhclient will actually use */
- if (ipv6) {
+ if (addr_family == AF_INET6) {
escaped = nm_dhcp_dhclient_escape_duid (duid);
success = nm_dhcp_dhclient_save_duid (priv->lease_file, escaped, &error);
g_free (escaped);
@@ -423,7 +433,7 @@ dhclient_start (NMDhcpClient *client,
if (release)
g_ptr_array_add (argv, (gpointer) "-r");
- if (ipv6) {
+ if (addr_family == AF_INET6) {
g_ptr_array_add (argv, (gpointer) "-6");
if (mode_opt)
g_ptr_array_add (argv, (gpointer) mode_opt);
@@ -515,7 +525,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
hostname = nm_dhcp_client_get_hostname (client);
use_fqdn = nm_dhcp_client_get_use_fqdn (client);
- priv->conf_file = create_dhclient_config (self, iface, FALSE, uuid, client_id, dhcp_anycast_addr,
+ priv->conf_file = create_dhclient_config (self, AF_INET, iface, uuid, client_id, dhcp_anycast_addr,
hostname, use_fqdn, &new_client_id);
if (priv->conf_file) {
if (new_client_id)
@@ -544,7 +554,7 @@ ip6_start (NMDhcpClient *client,
uuid = nm_dhcp_client_get_uuid (client);
hostname = nm_dhcp_client_get_hostname (client);
- priv->conf_file = create_dhclient_config (self, iface, TRUE, uuid, NULL, dhcp_anycast_addr, hostname, TRUE, NULL);
+ priv->conf_file = create_dhclient_config (self, AF_INET6, iface, uuid, NULL, dhcp_anycast_addr, hostname, TRUE, NULL);
if (!priv->conf_file) {
_LOGW ("error creating dhclient configuration file");
return FALSE;
@@ -610,9 +620,9 @@ get_duid (NMDhcpClient *client)
GError *error = NULL;
/* Look in interface-specific leasefile first for backwards compat */
- leasefile = get_dhclient_leasefile (nm_dhcp_client_get_iface (client),
+ leasefile = get_dhclient_leasefile (AF_INET6,
+ nm_dhcp_client_get_iface (client),
nm_dhcp_client_get_uuid (client),
- TRUE,
NULL);
if (leasefile) {
_LOGD ("looking for DUID in '%s'", leasefile);
diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c
index ae4c3f97e9..0ee064285f 100644
--- a/src/dhcp/nm-dhcp-manager.c
+++ b/src/dhcp/nm-dhcp-manager.c
@@ -95,7 +95,7 @@ _client_factory_available (const NMDhcpClientFactory *client_factory)
/*****************************************************************************/
static NMDhcpClient *
-get_client_for_ifindex (NMDhcpManager *manager, int ifindex, gboolean ip6)
+get_client_for_ifindex (NMDhcpManager *manager, int addr_family, int ifindex)
{
NMDhcpManagerPrivate *priv;
GHashTableIter iter;
@@ -111,7 +111,7 @@ get_client_for_ifindex (NMDhcpManager *manager, int ifindex, gboolean ip6)
NMDhcpClient *candidate = NM_DHCP_CLIENT (value);
if ( nm_dhcp_client_get_ifindex (candidate) == ifindex
- && nm_dhcp_client_get_ipv6 (candidate) == ip6)
+ && nm_dhcp_client_get_addr_family (candidate) == addr_family)
return candidate;
}
@@ -152,13 +152,13 @@ client_state_changed (NMDhcpClient *client,
static NMDhcpClient *
client_start (NMDhcpManager *self,
+ int addr_family,
NMDedupMultiIndex *multi_idx,
const char *iface,
int ifindex,
const GByteArray *hwaddr,
const char *uuid,
guint32 priority,
- gboolean ipv6,
const struct in6_addr *ipv6_ll_addr,
const char *dhcp_client_id,
guint32 timeout,
@@ -186,7 +186,7 @@ client_start (NMDhcpManager *self,
return NULL;
/* Kill any old client instance */
- client = get_client_for_ifindex (self, ifindex, ipv6);
+ client = get_client_for_ifindex (self, addr_family, ifindex);
if (client) {
g_object_ref (client);
remove_client (self, client);
@@ -197,10 +197,10 @@ client_start (NMDhcpManager *self,
/* And make a new one */
client = g_object_new (priv->client_factory->get_type (),
NM_DHCP_CLIENT_MULTI_IDX, multi_idx,
+ NM_DHCP_CLIENT_ADDR_FAMILY, addr_family,
NM_DHCP_CLIENT_INTERFACE, iface,
NM_DHCP_CLIENT_IFINDEX, ifindex,
NM_DHCP_CLIENT_HWADDR, hwaddr,
- NM_DHCP_CLIENT_IPV6, ipv6,
NM_DHCP_CLIENT_UUID, uuid,
NM_DHCP_CLIENT_PRIORITY, priority,
NM_DHCP_CLIENT_TIMEOUT, (guint) timeout,
@@ -208,10 +208,10 @@ client_start (NMDhcpManager *self,
g_hash_table_insert (NM_DHCP_MANAGER_GET_PRIVATE (self)->clients, client, g_object_ref (client));
g_signal_connect (client, NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED, G_CALLBACK (client_state_changed), self);
- if (ipv6)
- success = nm_dhcp_client_start_ip6 (client, dhcp_anycast_addr, ipv6_ll_addr, hostname, info_only, privacy, needed_prefixes);
- else
+ if (addr_family == AF_INET)
success = nm_dhcp_client_start_ip4 (client, dhcp_client_id, dhcp_anycast_addr, hostname, hostname_use_fqdn, last_ip4_address);
+ else
+ success = nm_dhcp_client_start_ip6 (client, dhcp_anycast_addr, ipv6_ll_addr, hostname, info_only, privacy, needed_prefixes);
if (!success) {
remove_client (self, client);
@@ -270,7 +270,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
}
}
- return client_start (self, multi_idx, iface, ifindex, hwaddr, uuid, priority, FALSE, NULL,
+ return client_start (self, AF_INET, multi_idx, iface, ifindex, hwaddr, uuid, priority, NULL,
dhcp_client_id, timeout, dhcp_anycast_addr, hostname,
use_fqdn, FALSE, 0, last_ip_address, 0);
}
@@ -303,7 +303,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
/* Always prefer the explicit dhcp-hostname if given */
hostname = dhcp_hostname ? dhcp_hostname : priv->default_hostname;
}
- return client_start (self, multi_idx, iface, ifindex, hwaddr, uuid, priority, TRUE,
+ return client_start (self, AF_INET6, multi_idx, iface, ifindex, hwaddr, uuid, priority,
ll_addr, NULL, timeout, dhcp_anycast_addr, hostname, TRUE, info_only,
privacy, NULL, needed_prefixes);
}
@@ -325,10 +325,10 @@ nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostna
GSList *
nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
NMDedupMultiIndex *multi_idx,
+ int addr_family,
const char *iface,
int ifindex,
const char *uuid,
- gboolean ipv6,
guint32 default_route_metric)
{
NMDhcpManagerPrivate *priv;
@@ -337,11 +337,12 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
g_return_val_if_fail (iface != NULL, NULL);
g_return_val_if_fail (ifindex >= -1, NULL);
g_return_val_if_fail (uuid != NULL, NULL);
+ g_return_val_if_fail (NM_IN_SET (addr_family, AF_INET, AF_INET6), NULL);
priv = NM_DHCP_MANAGER_GET_PRIVATE (self);
if ( priv->client_factory
&& priv->client_factory->get_lease_ip_configs)
- return priv->client_factory->get_lease_ip_configs (multi_idx, iface, ifindex, uuid, ipv6, default_route_metric);
+ return priv->client_factory->get_lease_ip_configs (multi_idx, addr_family, iface, ifindex, uuid, default_route_metric);
return NULL;
}
diff --git a/src/dhcp/nm-dhcp-manager.h b/src/dhcp/nm-dhcp-manager.h
index 2376ea8921..f73ca6892f 100644
--- a/src/dhcp/nm-dhcp-manager.h
+++ b/src/dhcp/nm-dhcp-manager.h
@@ -78,10 +78,10 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self,
struct _NMDedupMultiIndex *multi_idx,
+ int addr_family,
const char *iface,
int ifindex,
const char *uuid,
- gboolean ipv6,
guint32 default_route_metric);
/* For testing only */
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
index 61e2f69b39..c3c986d0c7 100644
--- a/src/dhcp/nm-dhcp-systemd.c
+++ b/src/dhcp/nm-dhcp-systemd.c
@@ -428,20 +428,20 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
/*****************************************************************************/
static char *
-get_leasefile_path (const char *iface, const char *uuid, gboolean ipv6)
+get_leasefile_path (int addr_family, const char *iface, const char *uuid)
{
return g_strdup_printf (NMSTATEDIR "/internal%s-%s-%s.lease",
- ipv6 ? "6" : "",
+ addr_family == AF_INET6 ? "6" : "",
uuid,
iface);
}
static GSList *
nm_dhcp_systemd_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
+ int addr_family,
const char *iface,
int ifindex,
const char *uuid,
- gboolean ipv6,
guint32 default_route_metric)
{
GSList *leases = NULL;
@@ -450,10 +450,10 @@ nm_dhcp_systemd_get_lease_ip_configs (NMDedupMultiIndex *multi_idx,
NMIP4Config *ip4_config;
int r;
- if (ipv6)
+ if (addr_family != AF_INET)
return NULL;
- path = get_leasefile_path (iface, uuid, FALSE);
+ path = get_leasefile_path (addr_family, iface, uuid);
r = dhcp_lease_load (&lease, path);
if (r == 0 && lease) {
ip4_config = lease_to_ip4_config (multi_idx, iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL);
@@ -604,7 +604,7 @@ ip4_start (NMDhcpClient *client, const char *dhcp_anycast_addr, const char *last
g_assert (priv->client6 == NULL);
g_free (priv->lease_file);
- priv->lease_file = get_leasefile_path (iface, nm_dhcp_client_get_uuid (client), FALSE);
+ priv->lease_file = get_leasefile_path (AF_INET, iface, nm_dhcp_client_get_uuid (client));
r = sd_dhcp_client_new (&priv->client4);
if (r < 0) {
@@ -905,7 +905,7 @@ ip6_start (NMDhcpClient *client,
g_return_val_if_fail (duid != NULL, FALSE);
g_free (priv->lease_file);
- priv->lease_file = get_leasefile_path (iface, nm_dhcp_client_get_uuid (client), TRUE);
+ priv->lease_file = get_leasefile_path (AF_INET6, iface, nm_dhcp_client_get_uuid (client));
priv->info_only = info_only;
r = sd_dhcp6_client_new (&priv->client6);
diff --git a/src/dhcp/tests/test-dhcp-dhclient.c b/src/dhcp/tests/test-dhcp-dhclient.c
index 7a6bcb5426..879aa317e7 100644
--- a/src/dhcp/tests/test-dhcp-dhclient.c
+++ b/src/dhcp/tests/test-dhcp-dhclient.c
@@ -42,7 +42,7 @@ static const int IFINDEX = 5;
static void
test_config (const char *orig,
const char *expected,
- gboolean ipv6,
+ int addr_family,
const char *hostname,
gboolean use_fqdn,
const char *dhcp_client_id,
@@ -60,7 +60,7 @@ test_config (const char *orig,
}
new = nm_dhcp_dhclient_create_config (iface,
- ipv6,
+ addr_family,
client_id,
anycast_addr,
hostname,
@@ -108,7 +108,7 @@ static const char *orig_missing_expected = \
static void
test_orig_missing (void)
{
- test_config (NULL, orig_missing_expected, FALSE, NULL, FALSE, NULL, NULL, "eth0", NULL);
+ test_config (NULL, orig_missing_expected, AF_INET, NULL, FALSE, NULL, NULL, "eth0", NULL);
}
/*****************************************************************************/
@@ -137,7 +137,7 @@ static void
test_override_client_id (void)
{
test_config (override_client_id_orig, override_client_id_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
"11:22:33:44:55:66",
NULL,
"eth0",
@@ -166,7 +166,7 @@ static void
test_quote_client_id (void)
{
test_config (NULL, quote_client_id_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
"1234",
NULL,
"eth0",
@@ -195,7 +195,7 @@ static void
test_ascii_client_id (void)
{
test_config (NULL, ascii_client_id_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
"qb:cd:ef:12:34:56",
NULL,
"eth0",
@@ -224,7 +224,7 @@ static void
test_hex_single_client_id (void)
{
test_config (NULL, hex_single_client_id_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
"ab:cd:e:12:34:56",
NULL,
"eth0",
@@ -261,7 +261,7 @@ test_existing_hex_client_id (void)
new_client_id = g_bytes_new (bytes, sizeof (bytes));
test_config (existing_hex_client_id_orig, existing_hex_client_id_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
NULL,
new_client_id,
"eth0",
@@ -301,7 +301,7 @@ test_existing_ascii_client_id (void)
memcpy (buf + 1, EACID, NM_STRLEN (EACID));
new_client_id = g_bytes_new (buf, sizeof (buf));
test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
NULL,
new_client_id,
"eth0",
@@ -330,7 +330,7 @@ static void
test_fqdn (void)
{
test_config (NULL, fqdn_expected,
- FALSE, "foo.bar.com",
+ AF_INET, "foo.bar.com",
TRUE, NULL,
NULL,
"eth0",
@@ -370,7 +370,7 @@ test_fqdn_options_override (void)
{
test_config (fqdn_options_override_orig,
fqdn_options_override_expected,
- FALSE, "example2.com",
+ AF_INET, "example2.com",
TRUE, NULL,
NULL,
"eth0",
@@ -403,7 +403,7 @@ static void
test_override_hostname (void)
{
test_config (override_hostname_orig, override_hostname_expected,
- FALSE, "blahblah", FALSE,
+ AF_INET, "blahblah", FALSE,
NULL,
NULL,
"eth0",
@@ -431,7 +431,7 @@ static void
test_override_hostname6 (void)
{
test_config (override_hostname6_orig, override_hostname6_expected,
- TRUE, "blahblah.local", TRUE,
+ AF_INET6, "blahblah.local", TRUE,
NULL,
NULL,
"eth0",
@@ -456,7 +456,7 @@ test_nonfqdn_hostname6 (void)
{
/* Non-FQDN hostname can now be used with dhclient */
test_config (NULL, nonfqdn_hostname6_expected,
- TRUE, "blahblah",
+ AF_INET6, "blahblah",
TRUE, NULL,
NULL,
"eth0",
@@ -491,7 +491,7 @@ static void
test_existing_alsoreq (void)
{
test_config (existing_alsoreq_orig, existing_alsoreq_expected,
- FALSE, NULL,
+ AF_INET, NULL,
FALSE,
NULL,
NULL,
@@ -530,7 +530,7 @@ static void
test_existing_req (void)
{
test_config (existing_req_orig, existing_req_expected,
- FALSE, NULL,
+ AF_INET, NULL,
FALSE,
NULL,
NULL,
@@ -570,7 +570,7 @@ static void
test_existing_multiline_alsoreq (void)
{
test_config (existing_multiline_alsoreq_orig, existing_multiline_alsoreq_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
NULL,
NULL,
"eth0",
@@ -784,7 +784,7 @@ static void
test_interface1 (void)
{
test_config (interface1_orig, interface1_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
NULL,
NULL,
"eth0",
@@ -829,7 +829,7 @@ static void
test_interface2 (void)
{
test_config (interface2_orig, interface2_expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
NULL,
NULL,
"eth1",
@@ -883,7 +883,7 @@ test_config_req_intf (void)
"\n";
test_config (orig, expected,
- FALSE, NULL, FALSE,
+ AF_INET, NULL, FALSE,
NULL,
NULL,
"eth0",
@@ -912,7 +912,7 @@ test_read_lease_ip4_config_basic (void)
/* Date from before the least expiration */
now = g_date_time_new_utc (2013, 11, 1, 19, 55, 32);
- leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, "wlan0", IFINDEX, contents, FALSE, now);
+ leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, AF_INET, "wlan0", IFINDEX, contents, now);
g_assert_cmpint (g_slist_length (leases), ==, 2);
/* IP4Config #1 */
@@ -987,7 +987,7 @@ test_read_lease_ip4_config_expired (void)
/* Date from *after* the lease expiration */
now = g_date_time_new_utc (2013, 12, 1, 19, 55, 32);
- leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, "wlan0", IFINDEX, contents, FALSE, now);
+ leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, AF_INET, "wlan0", IFINDEX, contents, now);
g_assert (leases == NULL);
g_date_time_unref (now);
@@ -1010,7 +1010,7 @@ test_read_lease_ip4_config_expect_failure (gconstpointer user_data)
/* Date from before the least expiration */
now = g_date_time_new_utc (2013, 11, 1, 1, 1, 1);
- leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, "wlan0", IFINDEX, contents, FALSE, now);
+ leases = nm_dhcp_dhclient_read_lease_ip_configs (multi_idx, AF_INET, "wlan0", IFINDEX, contents, now);
g_assert (leases == NULL);
g_date_time_unref (now);