summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-02-02 14:30:15 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2016-02-11 21:57:09 +0100
commit8682bb7f5f59824a46f36f9ea6ab36fd5e02ca74 (patch)
tree9d666ef56bf0186c47d4acd691bb3e7a8c08fc2d
parente2637760f160f8d790438f3ca26df1b888de7909 (diff)
downloadNetworkManager-8682bb7f5f59824a46f36f9ea6ab36fd5e02ca74.tar.gz
nmtst: introduce nmtst_setting_ip_config_add_{address,route} helpers
-rw-r--r--shared/nm-test-utils.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/shared/nm-test-utils.h b/shared/nm-test-utils.h
index 89d32ccf8c..fcae761228 100644
--- a/shared/nm-test-utils.h
+++ b/shared/nm-test-utils.h
@@ -1325,6 +1325,56 @@ nmtst_ip6_config_clone (NMIP6Config *config)
#endif
+#ifdef NM_SETTING_IP_CONFIG_H
+inline static void
+nmtst_setting_ip_config_add_address (NMSettingIPConfig *s_ip,
+ const char *address,
+ guint prefix)
+{
+ NMIPAddress *addr;
+ int family;
+
+ g_assert (s_ip);
+
+ if (nm_utils_ipaddr_valid (AF_INET, address))
+ family = AF_INET;
+ else if (nm_utils_ipaddr_valid (AF_INET6, address))
+ family = AF_INET6;
+ else
+ g_assert (FALSE);
+
+ addr = nm_ip_address_new (family, address, prefix, NULL);
+ g_assert (addr);
+ g_assert (nm_setting_ip_config_add_address (s_ip, addr));
+ nm_ip_address_unref (addr);
+}
+
+inline static void
+nmtst_setting_ip_config_add_route (NMSettingIPConfig *s_ip,
+ const char *dest,
+ guint prefix,
+ const char *next_hop,
+ gint64 metric)
+{
+ NMIPRoute *route;
+ int family;
+
+ g_assert (s_ip);
+
+ if (nm_utils_ipaddr_valid (AF_INET, dest))
+ family = AF_INET;
+ else if (nm_utils_ipaddr_valid (AF_INET6, dest))
+ family = AF_INET6;
+ else
+ g_assert (FALSE);
+
+ route = nm_ip_route_new (family, dest, prefix, next_hop, metric, NULL);
+ g_assert (route);
+ g_assert (nm_setting_ip_config_add_route (s_ip, route));
+ nm_ip_route_unref (route);
+}
+#endif /* NM_SETTING_IP_CONFIG_H */
+
#if (defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__)) || (defined(NM_CONNECTION_H))
inline static NMConnection *