diff options
| author | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-01-22 00:29:39 +0100 |
| commit | 2c032d8f1c6292c1338a615e6ec40252889ba85c (patch) | |
| tree | 1f77182220b2b0264288ba4a476ab47e5bc48716 /src/settings/plugins/ifupdown | |
| parent | 33491bc4279481db8ae47213e34a6d695a0e8830 (diff) | |
Imported Upstream version 1.0.0 upstream/1.0.0
Diffstat (limited to 'src/settings/plugins/ifupdown')
| -rw-r--r-- | src/settings/plugins/ifupdown/Makefile.am | 21 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/Makefile.in | 36 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/interface_parser.c | 1 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/nm-ifupdown-connection.c | 12 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/nm-ifupdown-connection.h | 6 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/parser.c | 157 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/plugin.c | 24 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/plugin.h | 2 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/tests/Makefile.am | 19 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/tests/Makefile.in | 39 | ||||
| -rw-r--r-- | src/settings/plugins/ifupdown/tests/test-ifupdown.c | 215 |
11 files changed, 187 insertions, 345 deletions
diff --git a/src/settings/plugins/ifupdown/Makefile.am b/src/settings/plugins/ifupdown/Makefile.am index fd98f8fe..0ca543e3 100644 --- a/src/settings/plugins/ifupdown/Makefile.am +++ b/src/settings/plugins/ifupdown/Makefile.am @@ -4,19 +4,14 @@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/logging \ - -I$(top_srcdir)/src/config \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-glib \ - -I$(top_srcdir)/libnm-util \ - -I$(top_builddir)/libnm-util \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ + -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ - $(POLKIT_CFLAGS) \ $(GUDEV_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" @@ -28,10 +23,6 @@ libifupdown_io_la_SOURCES = \ parser.c \ parser.h -libifupdown_io_la_LIBADD = \ - $(top_builddir)/libnm-util/libnm-util.la \ - $(GLIB_LIBS) - pkglib_LTLIBRARIES = libnm-settings-plugin-ifupdown.la libnm_settings_plugin_ifupdown_la_SOURCES = \ @@ -41,9 +32,5 @@ libnm_settings_plugin_ifupdown_la_SOURCES = \ plugin.h libnm_settings_plugin_ifupdown_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifupdown_la_LIBADD = \ - $(top_builddir)/libnm-util/libnm-util.la \ - libifupdown-io.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) +libnm_settings_plugin_ifupdown_la_LIBADD = libifupdown-io.la diff --git a/src/settings/plugins/ifupdown/Makefile.in b/src/settings/plugins/ifupdown/Makefile.in index 50d4ca08..44596e48 100644 --- a/src/settings/plugins/ifupdown/Makefile.in +++ b/src/settings/plugins/ifupdown/Makefile.in @@ -130,18 +130,14 @@ am__uninstall_files_from_dir = { \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkglib_LTLIBRARIES) -am__DEPENDENCIES_1 = -libifupdown_io_la_DEPENDENCIES = \ - $(top_builddir)/libnm-util/libnm-util.la $(am__DEPENDENCIES_1) +libifupdown_io_la_LIBADD = am_libifupdown_io_la_OBJECTS = interface_parser.lo parser.lo libifupdown_io_la_OBJECTS = $(am_libifupdown_io_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -libnm_settings_plugin_ifupdown_la_DEPENDENCIES = \ - $(top_builddir)/libnm-util/libnm-util.la libifupdown-io.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +libnm_settings_plugin_ifupdown_la_DEPENDENCIES = libifupdown-io.la am_libnm_settings_plugin_ifupdown_la_OBJECTS = \ nm-ifupdown-connection.lo plugin.lo libnm_settings_plugin_ifupdown_la_OBJECTS = \ @@ -264,6 +260,8 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ +BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -387,6 +385,7 @@ NEWT_CFLAGS = @NEWT_CFLAGS@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ +NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -406,6 +405,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ @@ -432,7 +432,7 @@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_BASE_DIR = @UDEV_BASE_DIR@ +UDEV_DIR = @UDEV_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ @@ -514,19 +514,14 @@ with_valgrind = @with_valgrind@ SUBDIRS = . tests AM_CPPFLAGS = \ -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/logging \ - -I$(top_srcdir)/src/config \ -I$(top_srcdir)/src/settings \ -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-glib \ - -I$(top_srcdir)/libnm-util \ - -I$(top_builddir)/libnm-util \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ + -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ - $(POLKIT_CFLAGS) \ $(GUDEV_CFLAGS) \ -DSYSCONFDIR=\"$(sysconfdir)\" @@ -537,10 +532,6 @@ libifupdown_io_la_SOURCES = \ parser.c \ parser.h -libifupdown_io_la_LIBADD = \ - $(top_builddir)/libnm-util/libnm-util.la \ - $(GLIB_LIBS) - pkglib_LTLIBRARIES = libnm-settings-plugin-ifupdown.la libnm_settings_plugin_ifupdown_la_SOURCES = \ nm-ifupdown-connection.c \ @@ -549,12 +540,7 @@ libnm_settings_plugin_ifupdown_la_SOURCES = \ plugin.h libnm_settings_plugin_ifupdown_la_LDFLAGS = -module -avoid-version -libnm_settings_plugin_ifupdown_la_LIBADD = \ - $(top_builddir)/libnm-util/libnm-util.la \ - libifupdown-io.la \ - $(GLIB_LIBS) \ - $(GUDEV_LIBS) - +libnm_settings_plugin_ifupdown_la_LIBADD = libifupdown-io.la all: all-recursive .SUFFIXES: diff --git a/src/settings/plugins/ifupdown/interface_parser.c b/src/settings/plugins/ifupdown/interface_parser.c index ee233c93..32d27c57 100644 --- a/src/settings/plugins/ifupdown/interface_parser.c +++ b/src/settings/plugins/ifupdown/interface_parser.c @@ -21,6 +21,7 @@ */ #include "config.h" + #include "interface_parser.h" #include <stdio.h> #include <stdlib.h> diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c index 4e13a2b8..c6073bd7 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -21,14 +21,15 @@ * (C) Copyright 2007,2008 Canonical Ltd. */ +#include "config.h" + #include <string.h> #include <glib/gstdio.h> -#include <NetworkManager.h> +#include <nm-dbus-interface.h> #include <nm-utils.h> #include <nm-setting-wireless-security.h> #include <nm-settings-connection.h> #include <nm-system-config-interface.h> -#include <nm-settings-error.h> #include <nm-logging.h> #include "nm-ifupdown-connection.h" #include "parser.h" @@ -161,9 +162,8 @@ nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connectio /* Properties */ g_object_class_install_property (object_class, PROP_IFBLOCK, - g_param_spec_pointer (NM_IFUPDOWN_CONNECTION_IFBLOCK, - "ifblock", - "", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_param_spec_pointer (NM_IFUPDOWN_CONNECTION_IFBLOCK, "", "", + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); } diff --git a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h index 447af78a..be2ebc0a 100644 --- a/src/settings/plugins/ifupdown/nm-ifupdown-connection.h +++ b/src/settings/plugins/ifupdown/nm-ifupdown-connection.h @@ -21,8 +21,8 @@ * (C) Copyright 2008 Canonical Ltd. */ -#ifndef NM_IFUPDOWN_CONNECTION_H -#define NM_IFUPDOWN_CONNECTION_H +#ifndef __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ +#define __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ #include <nm-settings-connection.h> #include "interface_parser.h" @@ -52,4 +52,4 @@ NMIfupdownConnection *nm_ifupdown_connection_new (if_block *block); G_END_DECLS -#endif /* NM_IFUPDOWN_CONNECTION_H */ +#endif /* __NETWORKMANAGER_IFUPDOWN_CONNECTION_H__ */ diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c index 91ed3e21..15081a4c 100644 --- a/src/settings/plugins/ifupdown/parser.c +++ b/src/settings/plugins/ifupdown/parser.c @@ -21,24 +21,18 @@ * (C) Copyright 2008 Canonical Ltd. */ +#include "config.h" + #include <string.h> #include <arpa/inet.h> #include <stdlib.h> #include <errno.h> - -#include <nm-connection.h> -#include <NetworkManager.h> -#include <nm-setting-connection.h> -#include <nm-setting-ip4-config.h> -#include <nm-setting-ppp.h> -#include <nm-setting-wired.h> -#include <nm-setting-wireless.h> -#include <nm-setting-8021x.h> -#include <nm-system-config-interface.h> -#include <nm-utils.h> -#include <nm-logging.h> #include <ctype.h> +#include "nm-core-internal.h" +#include "nm-system-config-interface.h" +#include "nm-logging.h" + #include "parser.h" #include "plugin.h" @@ -417,19 +411,8 @@ update_wired_setting_from_if_block(NMConnection *connection, nm_connection_add_setting(connection, NM_SETTING(s_wired)); } -static GQuark -eni_plugin_error_quark() { - static GQuark error_quark = 0; - - if(!error_quark) { - error_quark = g_quark_from_static_string ("eni-plugin-error-quark"); - } - - return error_quark; -} - static void -ifupdown_ip4_add_dns (NMSettingIP4Config *s_ip4, const char *dns) +ifupdown_ip4_add_dns (NMSettingIPConfig *s_ip4, const char *dns) { guint32 addr; char **list, **iter; @@ -447,7 +430,7 @@ ifupdown_ip4_add_dns (NMSettingIP4Config *s_ip4, const char *dns) continue; } - if (!nm_setting_ip4_config_add_dns (s_ip4, addr)) + if (!nm_setting_ip_config_add_dns (s_ip4, *iter)) nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); } g_strfreev (list); @@ -459,15 +442,15 @@ update_ip4_setting_from_if_block(NMConnection *connection, GError **error) { - NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new()); + NMSettingIPConfig *s_ip4 = NM_SETTING_IP_CONFIG (nm_setting_ip4_config_new()); const char *type = ifparser_getkey(block, "inet"); gboolean is_static = type && !strcmp("static", type); if (!is_static) { - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); } else { - guint32 tmp_addr, tmp_mask, tmp_gw; - NMIP4Address *addr; + guint32 tmp_mask; + NMIPAddress *addr; const char *address_v; const char *netmask_v; const char *gateway_v; @@ -479,10 +462,9 @@ update_ip4_setting_from_if_block(NMConnection *connection, /* Address */ address_v = ifparser_getkey (block, "address"); - if (!address_v || !inet_pton (AF_INET, address_v, &tmp_addr)) { - g_set_error (error, eni_plugin_error_quark (), 0, - "Missing IPv4 address '%s'", - address_v ? address_v : "(none)"); + if (!address_v) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IPv4 address"); goto error; } @@ -491,13 +473,8 @@ update_ip4_setting_from_if_block(NMConnection *connection, if (netmask_v) { if (strlen (netmask_v) < 7) { netmask_int = atoi (netmask_v); - if (netmask_int > 32) { - g_set_error (error, eni_plugin_error_quark (), 0, - "Invalid IPv4 netmask '%s'", netmask_v); - goto error; - } } else if (!inet_pton (AF_INET, netmask_v, &tmp_mask)) { - g_set_error (error, eni_plugin_error_quark (), 0, + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, "Invalid IPv4 netmask '%s'", netmask_v); goto error; } else { @@ -505,29 +482,30 @@ update_ip4_setting_from_if_block(NMConnection *connection, } } - /* gateway */ - gateway_v = ifparser_getkey (block, "gateway"); - if (!gateway_v) - gateway_v = address_v; /* dcbw: whaaa?? */ - if (!inet_pton (AF_INET, gateway_v, &tmp_gw)) { - g_set_error (error, eni_plugin_error_quark (), 0, - "Invalid IPv4 gateway '%s'", gateway_v); - goto error; - } - /* Add the new address to the setting */ - addr = nm_ip4_address_new (); - nm_ip4_address_set_address (addr, tmp_addr); - nm_ip4_address_set_prefix (addr, netmask_int); - nm_ip4_address_set_gateway (addr, tmp_gw); + addr = nm_ip_address_new (AF_INET, address_v, netmask_int, error); + if (!addr) + goto error; - if (nm_setting_ip4_config_add_address (s_ip4, addr)) { + if (nm_setting_ip_config_add_address (s_ip4, addr)) { nm_log_info (LOGD_SETTINGS, "addresses count: %d", - nm_setting_ip4_config_get_num_addresses (s_ip4)); + nm_setting_ip_config_get_num_addresses (s_ip4)); } else { nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP4 address"); } - nm_ip4_address_unref (addr); + nm_ip_address_unref (addr); + + /* gateway */ + gateway_v = ifparser_getkey (block, "gateway"); + if (gateway_v) { + if (!nm_utils_ipaddr_valid (AF_INET, gateway_v)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IPv4 gateway '%s'", gateway_v); + goto error; + } + if (!nm_setting_ip_config_get_gateway (s_ip4)) + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL); + } nameserver_v = ifparser_getkey (block, "dns-nameserver"); ifupdown_ip4_add_dns (s_ip4, nameserver_v); @@ -535,7 +513,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, nameservers_v = ifparser_getkey (block, "dns-nameservers"); ifupdown_ip4_add_dns (s_ip4, nameservers_v); - if (!nm_setting_ip4_config_get_num_dns (s_ip4)) + if (!nm_setting_ip_config_get_num_dns (s_ip4)) nm_log_info (LOGD_SETTINGS, "No dns-nameserver configured in /etc/network/interfaces"); /* DNS searches */ @@ -546,13 +524,13 @@ update_ip4_setting_from_if_block(NMConnection *connection, g_strstrip (*iter); if (g_ascii_isspace (*iter[0])) continue; - if (!nm_setting_ip4_config_add_dns_search (s_ip4, *iter)) + if (!nm_setting_ip_config_add_dns_search (s_ip4, *iter)) nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); } g_strfreev (list); } - g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL); + g_object_set (s_ip4, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_MANUAL, NULL); } nm_connection_add_setting (connection, NM_SETTING (s_ip4)); @@ -564,7 +542,7 @@ error: } static void -ifupdown_ip6_add_dns (NMSettingIP6Config *s_ip6, const char *dns) +ifupdown_ip6_add_dns (NMSettingIPConfig *s_ip6, const char *dns) { struct in6_addr addr; char **list, **iter; @@ -582,7 +560,7 @@ ifupdown_ip6_add_dns (NMSettingIP6Config *s_ip6, const char *dns) continue; } - if (!nm_setting_ip6_config_add_dns (s_ip6, &addr)) + if (!nm_setting_ip_config_add_dns (s_ip6, *iter)) nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); } g_strfreev (list); @@ -593,16 +571,15 @@ update_ip6_setting_from_if_block(NMConnection *connection, if_block *block, GError **error) { - NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new()); + NMSettingIPConfig *s_ip6 = NM_SETTING_IP_CONFIG (nm_setting_ip6_config_new()); const char *type = ifparser_getkey(block, "inet6"); gboolean is_static = type && (!strcmp("static", type) || !strcmp("v4tunnel", type)); if (!is_static) { - g_object_set(s_ip6, NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); + g_object_set(s_ip6, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); } else { - struct in6_addr tmp_addr, tmp_gw; - NMIP6Address *addr; + NMIPAddress *addr; const char *address_v; const char *prefix_v; const char *gateway_v; @@ -614,10 +591,9 @@ update_ip6_setting_from_if_block(NMConnection *connection, /* Address */ address_v = ifparser_getkey(block, "address"); - if (!address_v || !inet_pton (AF_INET6, address_v, &tmp_addr)) { - g_set_error (error, eni_plugin_error_quark (), 0, - "Missing IPv6 address '%s'", - address_v ? address_v : "(none)"); + if (!address_v) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Missing IPv6 address"); goto error; } @@ -626,29 +602,30 @@ update_ip6_setting_from_if_block(NMConnection *connection, if (prefix_v) prefix_int = g_ascii_strtoll (prefix_v, NULL, 10); - /* Gateway */ - gateway_v = ifparser_getkey (block, "gateway"); - if (!gateway_v) - gateway_v = address_v; /* dcbw: whaaa?? */ - if (!inet_pton (AF_INET6, gateway_v, &tmp_gw)) { - g_set_error (error, eni_plugin_error_quark (), 0, - "Invalid IPv6 gateway '%s'", gateway_v); - goto error; - } - /* Add the new address to the setting */ - addr = nm_ip6_address_new (); - nm_ip6_address_set_address (addr, &tmp_addr); - nm_ip6_address_set_prefix (addr, prefix_int); - nm_ip6_address_set_gateway (addr, &tmp_gw); + addr = nm_ip_address_new (AF_INET6, address_v, prefix_int, error); + if (!addr) + goto error; - if (nm_setting_ip6_config_add_address (s_ip6, addr)) { + if (nm_setting_ip_config_add_address (s_ip6, addr)) { nm_log_info (LOGD_SETTINGS, "addresses count: %d", - nm_setting_ip6_config_get_num_addresses (s_ip6)); + nm_setting_ip_config_get_num_addresses (s_ip6)); } else { nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP6 address"); } - nm_ip6_address_unref (addr); + nm_ip_address_unref (addr); + + /* gateway */ + gateway_v = ifparser_getkey (block, "gateway"); + if (gateway_v) { + if (!nm_utils_ipaddr_valid (AF_INET6, gateway_v)) { + g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, + "Invalid IPv6 gateway '%s'", gateway_v); + goto error; + } + if (!nm_setting_ip_config_get_gateway (s_ip6)) + g_object_set (s_ip6, NM_SETTING_IP_CONFIG_GATEWAY, gateway_v, NULL); + } nameserver_v = ifparser_getkey(block, "dns-nameserver"); ifupdown_ip6_add_dns (s_ip6, nameserver_v); @@ -656,7 +633,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, nameservers_v = ifparser_getkey(block, "dns-nameservers"); ifupdown_ip6_add_dns (s_ip6, nameservers_v); - if (!nm_setting_ip6_config_get_num_dns (s_ip6)) + if (!nm_setting_ip_config_get_num_dns (s_ip6)) nm_log_info (LOGD_SETTINGS, "No dns-nameserver configured in /etc/network/interfaces"); /* DNS searches */ @@ -667,14 +644,14 @@ update_ip6_setting_from_if_block(NMConnection *connection, g_strstrip (*iter); if (isblank (*iter[0])) continue; - if (!nm_setting_ip6_config_add_dns_search (s_ip6, *iter)) + if (!nm_setting_ip_config_add_dns_search (s_ip6, *iter)) nm_log_warn (LOGD_SETTINGS, " duplicate DNS domain '%s'", *iter); } g_strfreev (list); } g_object_set (s_ip6, - NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, + NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL, NULL); } @@ -709,7 +686,7 @@ ifupdown_update_connection_from_if_block (NMConnection *connection, idstr = g_strconcat ("Ifupdown (", block->name, ")", NULL); uuid_base = idstr; - uuid = nm_utils_uuid_generate_from_string (uuid_base); + uuid = nm_utils_uuid_generate_from_string (uuid_base, -1, NM_UTILS_UUID_TYPE_LEGACY, NULL); g_object_set (s_con, NM_SETTING_CONNECTION_TYPE, type, NM_SETTING_CONNECTION_INTERFACE_NAME, block->name, diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c index dcae211c..1b5642af 100644 --- a/src/settings/plugins/ifupdown/plugin.c +++ b/src/settings/plugins/ifupdown/plugin.c @@ -22,11 +22,11 @@ * (C) Copyright 2009 - 2011 Red Hat, Inc. */ +#include "config.h" + #include <string.h> #include <sys/inotify.h> -#include <net/ethernet.h> -#include <netinet/ether.h> #include <gmodule.h> #include <glib-object.h> @@ -36,13 +36,14 @@ #include "interface_parser.h" -#include "NetworkManager.h" +#include "nm-dbus-interface.h" #include "nm-system-config-interface.h" #include "nm-setting-ip4-config.h" #include "nm-setting-wireless.h" #include "nm-setting-wired.h" #include "nm-setting-ppp.h" #include "nm-utils.h" +#include "nm-core-internal.h" #include "nm-ifupdown-connection.h" #include "plugin.h" @@ -186,7 +187,6 @@ bind_device_to_connection (SCPluginIfupdown *self, GUdevDevice *device, NMIfupdownConnection *exported) { - GByteArray *mac_address; NMSettingWired *s_wired; NMSettingWireless *s_wifi; const char *iface, *address; @@ -203,8 +203,7 @@ bind_device_to_connection (SCPluginIfupdown *self, return; } - mac_address = nm_utils_hwaddr_atoba (address, ARPHRD_ETHER); - if (!mac_address) { + if (!nm_utils_hwaddr_valid (address, ETH_ALEN)) { nm_log_warn (LOGD_SETTINGS, "failed to parse MAC address '%s' for %s", address, iface); return; @@ -214,12 +213,11 @@ bind_device_to_connection (SCPluginIfupdown *self, s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (exported)); if (s_wired) { nm_log_info (LOGD_SETTINGS, "locking wired connection setting"); - g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac_address, NULL); + g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, address, NULL); } else if (s_wifi) { nm_log_info (LOGD_SETTINGS, "locking wireless connection setting"); - g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, mac_address, NULL); + g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, address, NULL); } - g_byte_array_free (mac_address, TRUE); nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), NULL, NULL); } @@ -507,9 +505,7 @@ static GSList* SCPluginIfupdown_get_connections (NMSystemConfigInterface *config) { SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config); - GSList *connections = NULL; - GHashTableIter iter; - gpointer value; + GSList *connections; nm_log_info (LOGD_SETTINGS, "(%d) ... get_connections.", GPOINTER_TO_UINT(config)); @@ -518,9 +514,7 @@ SCPluginIfupdown_get_connections (NMSystemConfigInterface *config) return NULL; } - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, &value)) - connections = g_slist_prepend (connections, value); + connections = _nm_utils_hash_values_to_slist (priv->connections); nm_log_info (LOGD_SETTINGS, "(%d) connections count: %d", GPOINTER_TO_UINT(config), g_slist_length(connections)); return connections; diff --git a/src/settings/plugins/ifupdown/plugin.h b/src/settings/plugins/ifupdown/plugin.h index ed7732b8..943b8b9f 100644 --- a/src/settings/plugins/ifupdown/plugin.h +++ b/src/settings/plugins/ifupdown/plugin.h @@ -48,6 +48,4 @@ struct _SCPluginIfupdownClass { GType sc_plugin_ifupdown_get_type (void); -GQuark ifupdown_plugin_error_quark (void); - #endif /* _PLUGIN_H_ */ diff --git a/src/settings/plugins/ifupdown/tests/Makefile.am b/src/settings/plugins/ifupdown/tests/Makefile.am index 160b3327..24cdd955 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.am +++ b/src/settings/plugins/ifupdown/tests/Makefile.am @@ -2,19 +2,15 @@ if ENABLE_TESTS AM_CPPFLAGS = \ -I$(top_srcdir)/include \ - -I$(top_builddir)/include \ - -I$(top_srcdir)/libnm-util \ - -I$(top_builddir)/libnm-util \ - -I$(top_srcdir)/libnm-glib \ + -I$(top_srcdir)/libnm-core \ + -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/logging \ -I$(top_srcdir)/src/settings \ -I$(srcdir)/../ \ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ + -DNETWORKMANAGER_COMPILATION \ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ $(GLIB_CFLAGS) \ - $(DBUS_CFLAGS) \ - $(POLKIT_CFLAGS) \ -DTEST_ENI_DIR=\"$(abs_srcdir)\" noinst_PROGRAMS = test-ifupdown @@ -25,17 +21,14 @@ test_ifupdown_SOURCES = \ ../parser.c test_ifupdown_LDADD = \ - $(top_builddir)/src/libNetworkManager.la \ - $(top_builddir)/libnm-glib/libnm-glib.la \ - $(top_builddir)/libnm-util/libnm-util.la \ - $(DBUS_LIBS) + $(top_builddir)/src/libNetworkManager.la TESTS = test-ifupdown +endif + EXTRA_DIST = \ test1 test2 test3 test4 test5 test6 test7 test8 test9 test11 test12 \ test13 test14 test15 test16 test17-wired-static-verify-ip4 \ test18-wired-static-verify-ip6 test19-wired-static-verify-ip4-plen \ test20-source-stanza test20-source-stanza.eth0 test20-source-stanza.eth1 - -endif diff --git a/src/settings/plugins/ifupdown/tests/Makefile.in b/src/settings/plugins/ifupdown/tests/Makefile.in index 86afefe6..6dedec00 100644 --- a/src/settings/plugins/ifupdown/tests/Makefile.in +++ b/src/settings/plugins/ifupdown/tests/Makefile.in @@ -109,12 +109,8 @@ am__test_ifupdown_SOURCES_DIST = test-ifupdown.c ../interface_parser.c \ @ENABLE_TESTS_TRUE@am_test_ifupdown_OBJECTS = test-ifupdown.$(OBJEXT) \ @ENABLE_TESTS_TRUE@ interface_parser.$(OBJEXT) parser.$(OBJEXT) test_ifupdown_OBJECTS = $(am_test_ifupdown_OBJECTS) -am__DEPENDENCIES_1 = @ENABLE_TESTS_TRUE@test_ifupdown_DEPENDENCIES = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-glib/libnm-glib.la \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-util/libnm-util.la \ -@ENABLE_TESTS_TRUE@ $(am__DEPENDENCIES_1) +@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent @@ -211,6 +207,8 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BLUEZ5_CFLAGS = @BLUEZ5_CFLAGS@ +BLUEZ5_LIBS = @BLUEZ5_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -334,6 +332,7 @@ NEWT_CFLAGS = @NEWT_CFLAGS@ NEWT_LIBS = @NEWT_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ +NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT = @NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT@ NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ NM_MICRO_VERSION = @NM_MICRO_VERSION@ NM_MINOR_VERSION = @NM_MINOR_VERSION@ @@ -353,6 +352,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ @@ -379,7 +379,7 @@ SYSTEMD_INHIBIT_LIBS = @SYSTEMD_INHIBIT_LIBS@ SYSTEMD_LOGIN_CFLAGS = @SYSTEMD_LOGIN_CFLAGS@ SYSTEMD_LOGIN_LIBS = @SYSTEMD_LOGIN_LIBS@ SYSTEM_CA_PATH = @SYSTEM_CA_PATH@ -UDEV_BASE_DIR = @UDEV_BASE_DIR@ +UDEV_DIR = @UDEV_DIR@ USE_NLS = @USE_NLS@ UUID_CFLAGS = @UUID_CFLAGS@ UUID_LIBS = @UUID_LIBS@ @@ -460,19 +460,15 @@ with_resolvconf = @with_resolvconf@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@AM_CPPFLAGS = \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/include \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-util \ -@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-util \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-glib \ +@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/libnm-core \ +@ENABLE_TESTS_TRUE@ -I$(top_builddir)/libnm-core \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src \ -@ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/logging \ @ENABLE_TESTS_TRUE@ -I$(top_srcdir)/src/settings \ @ENABLE_TESTS_TRUE@ -I$(srcdir)/../ \ @ENABLE_TESTS_TRUE@ -DG_LOG_DOMAIN=\""NetworkManager-ifupdown"\" \ +@ENABLE_TESTS_TRUE@ -DNETWORKMANAGER_COMPILATION \ @ENABLE_TESTS_TRUE@ -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ @ENABLE_TESTS_TRUE@ $(GLIB_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(DBUS_CFLAGS) \ -@ENABLE_TESTS_TRUE@ $(POLKIT_CFLAGS) \ @ENABLE_TESTS_TRUE@ -DTEST_ENI_DIR=\"$(abs_srcdir)\" @ENABLE_TESTS_TRUE@test_ifupdown_SOURCES = \ @@ -481,16 +477,13 @@ with_valgrind = @with_valgrind@ @ENABLE_TESTS_TRUE@ ../parser.c @ENABLE_TESTS_TRUE@test_ifupdown_LDADD = \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-glib/libnm-glib.la \ -@ENABLE_TESTS_TRUE@ $(top_builddir)/libnm-util/libnm-util.la \ -@ENABLE_TESTS_TRUE@ $(DBUS_LIBS) - -@ENABLE_TESTS_TRUE@EXTRA_DIST = \ -@ENABLE_TESTS_TRUE@ test1 test2 test3 test4 test5 test6 test7 test8 test9 test11 test12 \ -@ENABLE_TESTS_TRUE@ test13 test14 test15 test16 test17-wired-static-verify-ip4 \ -@ENABLE_TESTS_TRUE@ test18-wired-static-verify-ip6 test19-wired-static-verify-ip4-plen \ -@ENABLE_TESTS_TRUE@ test20-source-stanza test20-source-stanza.eth0 test20-source-stanza.eth1 +@ENABLE_TESTS_TRUE@ $(top_builddir)/src/libNetworkManager.la + +EXTRA_DIST = \ + test1 test2 test3 test4 test5 test6 test7 test8 test9 test11 test12 \ + test13 test14 test15 test16 test17-wired-static-verify-ip4 \ + test18-wired-static-verify-ip6 test19-wired-static-verify-ip4-plen \ + test20-source-stanza test20-source-stanza.eth0 test20-source-stanza.eth1 all: all-am diff --git a/src/settings/plugins/ifupdown/tests/test-ifupdown.c b/src/settings/plugins/ifupdown/tests/test-ifupdown.c index 83864287..1c100ac2 100644 --- a/src/settings/plugins/ifupdown/tests/test-ifupdown.c +++ b/src/settings/plugins/ifupdown/tests/test-ifupdown.c @@ -18,11 +18,12 @@ * */ +#include "config.h" + #include <glib.h> #include <string.h> -#include <nm-utils.h> - +#include "nm-core-internal.h" #include "nm-logging.h" #include "interface_parser.h" #include "parser.h" @@ -460,20 +461,15 @@ test17_read_static_ipv4 (const char *path) { NMConnection *connection; NMSettingConnection *s_con; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; NMSettingWired *s_wired; char *unmanaged = NULL; GError *error = NULL; const char* tmp; - const char *expected_address = "10.0.0.3"; const char *expected_id = "Ifupdown (eth0)"; - const char *expected_dns1 = "10.0.0.1"; - const char *expected_dns2 = "10.0.0.2"; const char *expected_search1 = "example.com"; const char *expected_search2 = "foo.example.com"; - guint32 expected_prefix = 8; - NMIP4Address *ip4_addr; - guint32 addr; + NMIPAddress *ip4_addr; #define TEST17_NAME "wired-static-verify-ip4" if_block *block = NULL; @@ -481,7 +477,7 @@ test17_read_static_ipv4 (const char *path) init_ifparser_with_file (path, file); block = ifparser_getfirst (); - connection = nm_connection_new(); + connection = nm_simple_connection_new(); ifupdown_update_connection_from_if_block(connection, block, &error); ASSERT (connection != NULL, @@ -524,10 +520,6 @@ test17_read_static_ipv4 (const char *path) /* ===== IPv4 SETTING ===== */ - ASSERT (inet_pton (AF_INET, expected_address, &addr) > 0, - TEST17_NAME, "failed to verify %s: couldn't convert IP address #1", - file); - s_ip4 = nm_connection_get_setting_ip4_config (connection); ASSERT (s_ip4 != NULL, TEST17_NAME, "failed to verify %s: missing %s setting", @@ -535,101 +527,81 @@ test17_read_static_ipv4 (const char *path) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip4_config_get_method (s_ip4); + tmp = nm_setting_ip_config_get_method (s_ip4); ASSERT (strcmp (tmp, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0, TEST17_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* IP addresses */ - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 1, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip4) == 1, TEST17_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); - - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); - ASSERT (ip4_addr, - TEST17_NAME, "failed to verify %s: missing IP4 address #1", - file); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix, - TEST17_NAME, "failed to verify %s: unexpected IP4 address prefix", - file); + NM_SETTING_IP_CONFIG_ADDRESSES); - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr, - TEST17_NAME, "failed to verify %s: unexpected IP4 address: %s", - file, addr); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); + g_assert (ip4_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "10.0.0.3"); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 8); /* DNS Addresses */ - ASSERT (nm_setting_ip4_config_get_num_dns (s_ip4) == 2, + ASSERT (nm_setting_ip_config_get_num_dns (s_ip4) == 2, TEST17_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET, expected_dns1, &addr) > 0, - TEST17_NAME, "failed to verify %s: couldn't convert DNS IP address #1", - file, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 0) == addr, + ASSERT (!strcmp (nm_setting_ip_config_get_dns (s_ip4, 0), "10.0.0.1"), TEST17_NAME, "failed to verify %s: unexpected %s / %s key value #1", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET, expected_dns2, &addr) > 0, - TEST17_NAME, "failed to verify %s: couldn't convert DNS IP address #2", - file, - NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); - - ASSERT (nm_setting_ip4_config_get_dns (s_ip4, 1) == addr, + ASSERT (!strcmp (nm_setting_ip_config_get_dns (s_ip4, 1), "10.0.0.2"), TEST17_NAME, "failed to verify %s: unexpected %s / %s key value #2", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 1, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip4) == 1, TEST17_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); /* DNS search domains */ - ASSERT (nm_setting_ip4_config_get_num_dns_searches (s_ip4) == 2, + ASSERT (nm_setting_ip_config_get_num_dns_searches (s_ip4) == 2, TEST17_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - tmp = nm_setting_ip4_config_get_dns_search (s_ip4, 0); + tmp = nm_setting_ip_config_get_dns_search (s_ip4, 0); ASSERT (tmp != NULL, TEST17_NAME, "failed to verify %s: missing %s / %s key", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); ASSERT (strcmp (tmp, expected_search1) == 0, TEST17_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); - tmp = nm_setting_ip4_config_get_dns_search (s_ip4, 1); + tmp = nm_setting_ip_config_get_dns_search (s_ip4, 1); ASSERT (tmp != NULL, TEST17_NAME, "failed to verify %s: missing %s / %s key", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); ASSERT (strcmp (tmp, expected_search2) == 0, TEST17_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); g_object_unref (connection); } @@ -639,27 +611,22 @@ test18_read_static_ipv6 (const char *path) { NMConnection *connection; NMSettingConnection *s_con; - NMSettingIP6Config *s_ip6; + NMSettingIPConfig *s_ip6; NMSettingWired *s_wired; char *unmanaged = NULL; GError *error = NULL; const char* tmp; - const char *expected_address = "fc00::1"; const char *expected_id = "Ifupdown (myip6tunnel)"; - const char *expected_dns1 = "fc00::2"; - const char *expected_dns2 = "fc00::3"; const char *expected_search1 = "example.com"; const char *expected_search2 = "foo.example.com"; - guint32 expected_prefix = 64; - NMIP6Address *ip6_addr; - struct in6_addr addr; + NMIPAddress *ip6_addr; if_block *block = NULL; #define TEST18_NAME "wired-static-verify-ip6" const char* file = "test18-" TEST18_NAME; init_ifparser_with_file (path, file); block = ifparser_getfirst (); - connection = nm_connection_new(); + connection = nm_simple_connection_new(); ifupdown_update_connection_from_if_block(connection, block, &error); ASSERT (connection != NULL, @@ -708,11 +675,6 @@ test18_read_static_ipv6 (const char *path) /* ===== IPv6 SETTING ===== */ - ASSERT (inet_pton (AF_INET6, expected_address, &addr) > 0, - TEST18_NAME, - "failed to verify %s: couldn't convert IP address #1", - file); - s_ip6 = nm_connection_get_setting_ip6_config (connection); ASSERT (s_ip6 != NULL, TEST18_NAME, @@ -721,115 +683,85 @@ test18_read_static_ipv6 (const char *path) NM_SETTING_IP6_CONFIG_SETTING_NAME); /* Method */ - tmp = nm_setting_ip6_config_get_method (s_ip6); + tmp = nm_setting_ip_config_get_method (s_ip6); ASSERT (strcmp (tmp, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0, TEST18_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_METHOD); + NM_SETTING_IP_CONFIG_METHOD); /* IP addresses */ - ASSERT (nm_setting_ip6_config_get_num_addresses (s_ip6) == 1, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip6) == 1, TEST18_NAME, "failed to verify %s: unexpected number of %s / %s", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_ADDRESSES); - - ip6_addr = nm_setting_ip6_config_get_address (s_ip6, 0); - ASSERT (ip6_addr, - TEST18_NAME, - "failed to verify %s: missing %s / %s #1", - file, - NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); - ASSERT (nm_ip6_address_get_prefix (ip6_addr) == expected_prefix, - TEST18_NAME - "failed to verify %s: unexpected %s / %s prefix", - file, - NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_ADDRESSES); - - ASSERT (IN6_ARE_ADDR_EQUAL (nm_ip6_address_get_address (ip6_addr), - &addr), - TEST18_NAME, - "failed to verify %s: unexpected %s / %s", - file, - NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_ADDRESSES); + ip6_addr = nm_setting_ip_config_get_address (s_ip6, 0); + g_assert (ip6_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "fc00::1"); + g_assert_cmpint (nm_ip_address_get_prefix (ip6_addr), ==, 64); /* DNS Addresses */ - ASSERT (nm_setting_ip6_config_get_num_dns (s_ip6) == 2, + ASSERT (nm_setting_ip_config_get_num_dns (s_ip6) == 2, TEST18_NAME, "failed to verify %s: unexpected number of %s / %s values", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (inet_pton (AF_INET6, expected_dns1, &addr) > 0, - TEST18_NAME, - "failed to verify %s: couldn't convert DNS IP address #1", - file); - - ASSERT (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 0), - &addr), + ASSERT (!strcmp (nm_setting_ip_config_get_dns (s_ip6, 0), "fc00::2"), TEST18_NAME, "failed to verify %s: unexpected %s / %s #1", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); - - ASSERT (inet_pton (AF_INET6, expected_dns2, &addr) > 0, - TEST18_NAME, - "failed to verify %s: couldn't convert DNS IP address #2", - file); + NM_SETTING_IP_CONFIG_DNS); - ASSERT (IN6_ARE_ADDR_EQUAL (nm_setting_ip6_config_get_dns (s_ip6, 1), - &addr), + ASSERT (!strcmp (nm_setting_ip_config_get_dns (s_ip6, 1), "fc00::3"), TEST18_NAME, "failed to verify %s: unexpected %s / %s #2", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS); + NM_SETTING_IP_CONFIG_DNS); /* DNS search domains */ - ASSERT (nm_setting_ip6_config_get_num_dns_searches (s_ip6) == 2, + ASSERT (nm_setting_ip_config_get_num_dns_searches (s_ip6) == 2, TEST18_NAME, "failed to verify %s: unexpected number of %s / %s values", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); - tmp = nm_setting_ip6_config_get_dns_search (s_ip6, 0); + tmp = nm_setting_ip_config_get_dns_search (s_ip6, 0); ASSERT (tmp != NULL, "wired-ipv6-manual-verify-ip6", "failed to verify %s: missing %s / %s #1", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); ASSERT (strcmp (tmp, expected_search1) == 0, "wired-ipv6-manual-verify-ip6", "failed to verify %s: unexpected %s / %s #1", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); - tmp = nm_setting_ip6_config_get_dns_search (s_ip6, 1); + tmp = nm_setting_ip_config_get_dns_search (s_ip6, 1); ASSERT (tmp != NULL, TEST18_NAME, "failed to verify %s: missing %s / %s #2", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); ASSERT (strcmp (tmp, expected_search2) == 0, TEST18_NAME, "failed to verify %s: unexpected %s / %s #2", file, NM_SETTING_IP6_CONFIG_SETTING_NAME, - NM_SETTING_IP6_CONFIG_DNS_SEARCH); + NM_SETTING_IP_CONFIG_DNS_SEARCH); g_free (unmanaged); g_object_unref (connection); @@ -839,13 +771,10 @@ static void test19_read_static_ipv4_plen (const char *path) { NMConnection *connection; - NMSettingIP4Config *s_ip4; + NMSettingIPConfig *s_ip4; char *unmanaged = NULL; GError *error = NULL; - const char *expected_address = "10.0.0.3"; - guint32 expected_prefix = 8; - NMIP4Address *ip4_addr; - guint32 addr; + NMIPAddress *ip4_addr; #define TEST19_NAME "wired-static-verify-ip4-plen" if_block *block = NULL; @@ -853,7 +782,7 @@ test19_read_static_ipv4_plen (const char *path) init_ifparser_with_file (path, file); block = ifparser_getfirst (); - connection = nm_connection_new(); + connection = nm_simple_connection_new(); ifupdown_update_connection_from_if_block(connection, block, &error); ASSERT (connection != NULL, @@ -867,10 +796,6 @@ test19_read_static_ipv4_plen (const char *path) /* ===== IPv4 SETTING ===== */ - ASSERT (inet_pton (AF_INET, expected_address, &addr) > 0, - TEST19_NAME, "failed to verify %s: couldn't convert IP address #1", - file); - s_ip4 = nm_connection_get_setting_ip4_config (connection); ASSERT (s_ip4 != NULL, TEST19_NAME, "failed to verify %s: missing %s setting", @@ -878,24 +803,16 @@ test19_read_static_ipv4_plen (const char *path) NM_SETTING_IP4_CONFIG_SETTING_NAME); /* IP addresses */ - ASSERT (nm_setting_ip4_config_get_num_addresses (s_ip4) == 1, + ASSERT (nm_setting_ip_config_get_num_addresses (s_ip4) == 1, TEST19_NAME, "failed to verify %s: unexpected %s / %s key value", file, NM_SETTING_IP4_CONFIG_SETTING_NAME, - NM_SETTING_IP4_CONFIG_ADDRESSES); + NM_SETTING_IP_CONFIG_ADDRESSES); - ip4_addr = nm_setting_ip4_config_get_address (s_ip4, 0); - ASSERT (ip4_addr, - TEST19_NAME, "failed to verify %s: missing IP4 address #1", - file); - - ASSERT (nm_ip4_address_get_prefix (ip4_addr) == expected_prefix, - TEST19_NAME, "failed to verify %s: unexpected IP4 address prefix", - file); - - ASSERT (nm_ip4_address_get_address (ip4_addr) == addr, - TEST19_NAME, "failed to verify %s: unexpected IP4 address: %s", - file, addr); + ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0); + g_assert (ip4_addr != NULL); + g_assert_cmpstr (nm_ip_address_get_address (ip4_addr), ==, "10.0.0.3"); + g_assert_cmpint (nm_ip_address_get_prefix (ip4_addr), ==, 8); g_object_unref (connection); } @@ -930,14 +847,10 @@ test20_source_stanza (const char *path) int main (int argc, char **argv) { - GError *error = NULL; - #if !GLIB_CHECK_VERSION (2, 35, 0) g_type_init (); #endif - if (!nm_utils_init (&error)) - FAIL ("nm-utils-init", "failed to initialize libnm-util: %s", error->message); nm_logging_setup ("WARN", "DEFAULT", NULL, NULL); g_test_init (&argc, &argv, NULL); |