Commit 4cbf5947 authored by Beniamino Galvani's avatar Beniamino Galvani

core: add nm_ipX_config_clone()

parent 057744b7
......@@ -581,6 +581,17 @@ sort_captured_addresses (const CList *lst_a, const CList *lst_b, gconstpointer u
NM_FLAGS_HAS (addr_b->n_ifa_flags, IFA_F_SECONDARY);
}
NMIP4Config *
nm_ip4_config_clone (const NMIP4Config *self)
{
NMIP4Config *copy;
copy = nm_ip4_config_new (nm_ip4_config_get_multi_idx (self), -1);
nm_ip4_config_replace (copy, self, NULL);
return copy;
}
NMIP4Config *
nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex, gboolean capture_resolv_conf)
{
......
......@@ -154,6 +154,7 @@ GType nm_ip4_config_get_type (void);
NMIP4Config * nm_ip4_config_new (NMDedupMultiIndex *multi_idx,
int ifindex);
NMIP4Config *nm_ip4_config_clone (const NMIP4Config *self);
int nm_ip4_config_get_ifindex (const NMIP4Config *self);
NMDedupMultiIndex *nm_ip4_config_get_multi_idx (const NMIP4Config *self);
......
......@@ -365,6 +365,17 @@ _nmtst_ip6_config_addresses_sort (NMIP6Config *self)
return FALSE;
}
NMIP6Config *
nm_ip6_config_clone (const NMIP6Config *self)
{
NMIP6Config *copy;
copy = nm_ip6_config_new (nm_ip6_config_get_multi_idx (self), -1);
nm_ip6_config_replace (copy, self, NULL);
return copy;
}
NMIP6Config *
nm_ip6_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary)
{
......
......@@ -101,6 +101,7 @@ GType nm_ip6_config_get_type (void);
NMIP6Config * nm_ip6_config_new (struct _NMDedupMultiIndex *multi_idx, int ifindex);
NMIP6Config * nm_ip6_config_new_cloned (const NMIP6Config *src);
NMIP6Config *nm_ip6_config_clone (const NMIP6Config *self);
int nm_ip6_config_get_ifindex (const NMIP6Config *self);
struct _NMDedupMultiIndex *nm_ip6_config_get_multi_idx (const NMIP6Config *self);
......
......@@ -313,18 +313,6 @@ nmtst_ip4_config_new (int ifindex)
return nm_ip4_config_new (multi_idx, ifindex);
}
static inline NMIP4Config *
nmtst_ip4_config_clone (NMIP4Config *config)
{
NMIP4Config *copy;
g_assert (config);
copy = nm_ip4_config_new (nm_ip4_config_get_multi_idx (config), -1);
g_assert (copy);
nm_ip4_config_replace (copy, config, NULL);
return copy;
}
#endif
......@@ -340,18 +328,6 @@ nmtst_ip6_config_new (int ifindex)
return nm_ip6_config_new (multi_idx, ifindex);
}
static inline NMIP6Config *
nmtst_ip6_config_clone (NMIP6Config *config)
{
NMIP6Config *copy;
g_assert (config);
copy = nm_ip6_config_new (nm_ip6_config_get_multi_idx (config), -1);
g_assert (copy);
nm_ip6_config_replace (copy, config, NULL);
return copy;
}
#endif
#endif /* __NM_TEST_UTILS_CORE_H__ */
......@@ -246,8 +246,10 @@ test_nm_ip6_config_addresses_sort_check (NMIP6Config *config, NMSettingIP6Config
int *idx = g_new (int, addr_count);
nm_ip6_config_set_privacy (config, use_tempaddr);
copy = nmtst_ip6_config_clone (config);
copy2 = nmtst_ip6_config_clone (config);
copy = nm_ip6_config_clone (config);
g_assert (copy);
copy2 = nm_ip6_config_clone (config);
g_assert (copy2);
/* initialize the array of indeces, and keep shuffling them for every @repeat iteration. */
for (i = 0; i < addr_count; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment