diff options
-rw-r--r-- | libnm-util/Makefile.am | 2 | ||||
-rw-r--r-- | libnm-util/libnm-util.ver | 1 | ||||
-rw-r--r-- | libnm-util/nm-util-private.c | 44 | ||||
-rw-r--r-- | libnm-util/nm-util-private.h | 60 | ||||
-rw-r--r-- | libnm-util/nm-utils-private.h | 30 | ||||
-rw-r--r-- | libnm-util/nm-utils.c | 42 | ||||
-rw-r--r-- | libnm-util/tests/test-general.c | 24 | ||||
-rw-r--r-- | src/nm-ip4-config.c | 6 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/reader.c | 4 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 10 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/writer.c | 6 |
11 files changed, 98 insertions, 131 deletions
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am index c48f806492..90dec54b2a 100644 --- a/libnm-util/Makefile.am +++ b/libnm-util/Makefile.am @@ -57,7 +57,6 @@ libnm_util_include_HEADERS = \ libnm_util_la_private_headers = \ crypto.h \ nm-param-spec-specialized.h \ - nm-util-private.h \ nm-utils-private.h \ nm-setting-private.h @@ -92,7 +91,6 @@ libnm_util_la_csources = \ nm-setting-wireless.c \ nm-setting-wireless-security.c \ nm-setting-vpn.c \ - nm-util-private.c \ nm-utils-enum-types.c \ nm-utils.c \ nm-value-transforms.c diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index ff7a7697f6..c6fc0d7f69 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -610,6 +610,7 @@ global: nm_utils_deinit; nm_utils_escape_ssid; nm_utils_file_is_pkcs12; + nm_utils_get_private; nm_utils_gvalue_hash_dup; nm_utils_hex2byte; nm_utils_hexstr2bin; diff --git a/libnm-util/nm-util-private.c b/libnm-util/nm-util-private.c deleted file mode 100644 index 545113e619..0000000000 --- a/libnm-util/nm-util-private.c +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2014 Red Hat, Inc. - */ - -#include "nm-util-private.h" - -static const NMUtilPrivateData data = { - .nm_setting_ip4_config_get_address_label = nm_setting_ip4_config_get_address_label, - .nm_setting_ip4_config_add_address_with_label = nm_setting_ip4_config_add_address_with_label, -}; - -/** - * nm_util_get_private: - * - * Entry point for NetworkManager-internal API. Although this symbol is exported, - * it is only useful if you have access to "nm-util-private.h", which is only - * available inside the NetworkManager tree. - * - * Return value: Who knows? It's a mystery. - * - * Since: 0.9.10 - */ -const NMUtilPrivateData * -nm_util_get_private (void) -{ - return &data; -} diff --git a/libnm-util/nm-util-private.h b/libnm-util/nm-util-private.h deleted file mode 100644 index f59fc887ab..0000000000 --- a/libnm-util/nm-util-private.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA. - * - * (C) Copyright 2014 Red Hat, Inc. - */ - -#ifndef __NM_UTIL_PRIVATE_H__ -#define __NM_UTIL_PRIVATE_H__ - -#include <glib.h> - -#include "nm-setting-private.h" - -G_BEGIN_DECLS - -typedef struct NMUtilPrivateData { - const char * (*nm_setting_ip4_config_get_address_label) (NMSettingIP4Config *setting, - guint32 i); - gboolean (*nm_setting_ip4_config_add_address_with_label) (NMSettingIP4Config *setting, - NMIP4Address *address, - const char *label); -} NMUtilPrivateData; - -const NMUtilPrivateData *nm_util_get_private (void); - - -/** - * NM_UTIL_PRIVATE_CALL: - * @call: a call to a private libnm-util function - * - * Used to call private libnm-util functions. Eg, if there was a - * private function called nm_foo_get_bar(), you could call it like: - * - * bar = NM_UTIL_PRIVATE_CALL (nm_foo_get_bar (foo, x, y, z)); - * - * This macro only exists inside the NetworkManager source tree and - * is not part of the public API. - * - * Since: 0.9.10 - */ -#define NM_UTIL_PRIVATE_CALL(call) (nm_util_get_private ()->call) - -G_END_DECLS - -#endif diff --git a/libnm-util/nm-utils-private.h b/libnm-util/nm-utils-private.h index 2d179cf4d4..9d73a939fd 100644 --- a/libnm-util/nm-utils-private.h +++ b/libnm-util/nm-utils-private.h @@ -26,6 +26,8 @@ #ifndef __NM_UTILS_PRIVATE_H__ #define __NM_UTILS_PRIVATE_H__ +#include "nm-setting-private.h" + gboolean _nm_utils_string_in_list (const char *str, const char **valid_strings); @@ -37,4 +39,32 @@ gboolean _nm_utils_gvalue_array_validate (GValueArray *elements, void _nm_value_transforms_register (void); +/***********************************************************/ + +typedef struct NMUtilsPrivateData { + const char * (*nm_setting_ip4_config_get_address_label) (NMSettingIP4Config *setting, + guint32 i); + gboolean (*nm_setting_ip4_config_add_address_with_label) (NMSettingIP4Config *setting, + NMIP4Address *address, + const char *label); +} NMUtilsPrivateData; + +const NMUtilsPrivateData *nm_utils_get_private (void); + +/** + * NM_UTILS_PRIVATE_CALL: + * @call: a call to a private libnm-util function + * + * Used to call private libnm-util functions. Eg, if there was a + * private function called nm_foo_get_bar(), you could call it like: + * + * bar = NM_UTILS_PRIVATE_CALL (nm_foo_get_bar (foo, x, y, z)); + * + * This macro only exists inside the NetworkManager source tree and + * is not part of the public API. + * + * Since: 0.9.10 + */ +#define NM_UTILS_PRIVATE_CALL(call) (nm_utils_get_private ()->call) + #endif diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index f5803cba6b..0176d9c3c9 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -2495,3 +2495,45 @@ nm_utils_check_virtual_device_compatibility (GType virtual_type, GType other_typ return FALSE; } } + +/***********************************************************/ + +/* Unused prototype to make the compiler happy */ +const NMUtilsPrivateData *nm_util_get_private (void); + +static const NMUtilsPrivateData data = { + .nm_setting_ip4_config_get_address_label = nm_setting_ip4_config_get_address_label, + .nm_setting_ip4_config_add_address_with_label = nm_setting_ip4_config_add_address_with_label, +}; + +/** + * nm_utils_get_private: + * + * Entry point for NetworkManager-internal API. You should not use this + * function for any reason. + * + * Returns: Who knows? It's a mystery. + * + * Since: 0.9.10 + */ +const NMUtilsPrivateData * +nm_utils_get_private (void) +{ + return &data; +} + +/** + * nm_util_get_private: + * + * You should not use this function for any reason. + * + * Returns: Who knows? It's a mystery. + * + * Since: 0.9.10 + */ +const NMUtilsPrivateData * +nm_util_get_private (void) +{ + /* Compat function to preserve ABI */ + return nm_utils_get_private (); +} diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c index 02a2a00d94..df0a1ecbfb 100644 --- a/libnm-util/tests/test-general.c +++ b/libnm-util/tests/test-general.c @@ -41,7 +41,7 @@ #include "nm-setting-vlan.h" #include "nm-setting-bond.h" #include "nm-utils.h" -#include "nm-util-private.h" +#include "nm-utils-private.h" #include "nm-dbus-glib-types.h" #include "nm-test-utils.h" @@ -332,7 +332,7 @@ test_setting_ip4_config_labels (void) nm_setting_verify (NM_SETTING (s_ip4), NULL, &error); g_assert_no_error (error); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); g_assert_cmpstr (label, ==, NULL); /* addr 2 */ @@ -340,12 +340,12 @@ test_setting_ip4_config_labels (void) nm_ip4_address_set_address (addr, 0x02020202); nm_ip4_address_set_prefix (addr, 24); - NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, "eth0:1")); + NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, "eth0:1")); nm_ip4_address_unref (addr); nm_setting_verify (NM_SETTING (s_ip4), NULL, &error); g_assert_no_error (error); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); g_assert_cmpstr (label, ==, "eth0:1"); /* addr 3 */ @@ -353,12 +353,12 @@ test_setting_ip4_config_labels (void) nm_ip4_address_set_address (addr, 0x03030303); nm_ip4_address_set_prefix (addr, 24); - NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, NULL)); + NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, NULL)); nm_ip4_address_unref (addr); nm_setting_verify (NM_SETTING (s_ip4), NULL, &error); g_assert_no_error (error); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 2)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 2)); g_assert_cmpstr (label, ==, NULL); /* Remove addr 1 and re-verify remaining addresses */ @@ -368,12 +368,12 @@ test_setting_ip4_config_labels (void) addr = nm_setting_ip4_config_get_address (s_ip4, 0); g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x02020202); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); g_assert_cmpstr (label, ==, "eth0:1"); addr = nm_setting_ip4_config_get_address (s_ip4, 1); g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); g_assert_cmpstr (label, ==, NULL); @@ -397,12 +397,12 @@ test_setting_ip4_config_labels (void) addr = nm_setting_ip4_config_get_address (s_ip4, 0); g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x02020202); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); g_assert_cmpstr (label, ==, NULL); addr = nm_setting_ip4_config_get_address (s_ip4, 1); g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); g_assert_cmpstr (label, ==, NULL); /* Setting labels now will leave addresses untouched */ @@ -416,12 +416,12 @@ test_setting_ip4_config_labels (void) addr = nm_setting_ip4_config_get_address (s_ip4, 0); g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x02020202); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)); g_assert_cmpstr (label, ==, "eth0:1"); addr = nm_setting_ip4_config_get_address (s_ip4, 1); g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303); - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 1)); g_assert_cmpstr (label, ==, NULL); /* Setting labels to a value that's too short or too long will result in diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index b39ec9f20c..aea5119940 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -30,7 +30,7 @@ #include "nm-dbus-glib-types.h" #include "nm-ip4-config-glue.h" #include "NetworkManagerUtils.h" -#include "nm-util-private.h" +#include "nm-utils-private.h" G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, G_TYPE_OBJECT) @@ -328,7 +328,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, i /* Addresses */ for (i = 0; i < naddresses; i++) { NMIP4Address *s_addr = nm_setting_ip4_config_get_address (setting, i); - const char *label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (setting, i)); + const char *label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (setting, i)); NMPlatformIP4Address address; memset (&address, 0, sizeof (address)); @@ -426,7 +426,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config) nm_ip4_address_set_gateway (s_addr, gateway); if (*address->label) - NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, s_addr, address->label)); + NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, s_addr, address->label)); else nm_setting_ip4_config_add_address (s_ip4, s_addr); nm_ip4_address_unref (s_addr); diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index f96387e34b..d4537de808 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -50,7 +50,7 @@ #include <nm-setting-bridge-port.h> #include <nm-setting-dcb.h> #include <nm-setting-generic.h> -#include <nm-util-private.h> +#include <nm-utils-private.h> #include <nm-utils.h> #include "nm-platform.h" @@ -1577,7 +1577,7 @@ read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *netwo ok = read_full_ip4_address (parsed, network_file, -1, addr, &err); svCloseFile (parsed); if (ok) { - if (!NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, device))) + if (!NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, device))) PARSE_WARNING ("duplicate IP4 address in alias file %s", item); } else { PARSE_WARNING ("error reading IP4 address from alias file '%s': %s", diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index de042da309..b8a16c3c52 100644 --- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -46,7 +46,7 @@ #include <nm-setting-serial.h> #include <nm-setting-vlan.h> #include <nm-setting-dcb.h> -#include <nm-util-private.h> +#include <nm-utils-private.h> #include "NetworkManagerUtils.h" @@ -2953,7 +2953,7 @@ test_read_wired_aliases_good (void) TEST_IFCFG_ALIASES_GOOD, i); - ASSERT (g_strcmp0 (NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)), expected_label[j]) == 0, + ASSERT (g_strcmp0 (NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)), expected_label[j]) == 0, "aliases-good-verify-ip4", "failed to verify %s: unexpected IP4 address label #%d", TEST_IFCFG_ALIASES_GOOD, i); @@ -3080,7 +3080,7 @@ test_read_wired_aliases_bad (const char *base, const char *expected_id) "aliases-bad-verify-ip4", "failed to verify %s: unexpected IP4 address gateway", base); - ASSERT (g_strcmp0 (NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)), expected_label) == 0, + ASSERT (g_strcmp0 (NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, 0)), expected_label) == 0, "aliases-bad-verify-ip4", "failed to verify %s: unexpected IP4 address label", base); @@ -8152,7 +8152,7 @@ test_write_wired_aliases (void) nm_ip4_address_set_address (addr, ip[i]); nm_ip4_address_set_prefix (addr, prefix); nm_ip4_address_set_gateway (addr, gw); - NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, label[i])); + NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_add_address_with_label (s_ip4, addr, label[i])); nm_ip4_address_unref (addr); } @@ -8260,7 +8260,7 @@ test_write_wired_aliases (void) testfile, i); - ASSERT (g_strcmp0 (NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)), label[j]) == 0, + ASSERT (g_strcmp0 (NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)), label[j]) == 0, "wired-aliases-write-verify-ip4", "failed to verify %s: unexpected IP4 address label #%d", testfile, i); diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index b9c108cc1a..60af599bf1 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -39,7 +39,7 @@ #include <nm-setting-vlan.h> #include <nm-setting-team.h> #include <nm-setting-team-port.h> -#include <nm-util-private.h> +#include <nm-utils-private.h> #include <nm-utils.h> #include "nm-logging.h" @@ -1928,7 +1928,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) NMIP4Address *addr; guint32 ip; - if (i > 0 && NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i))) + if (i > 0 && NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i))) continue; if (n == 0) { @@ -2203,7 +2203,7 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) guint32 ip; shvarFile *ifcfg; - label = NM_UTIL_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)); + label = NM_UTILS_PRIVATE_CALL (nm_setting_ip4_config_get_address_label (s_ip4, i)); if (!label) continue; if ( strncmp (label, base_name, base_name_len) != 0 |