Commit graph

110 commits

Author SHA1 Message Date
Thomas Haller ee86069601 shared: add test for NM_SET_OUT() 2016-09-26 17:00:38 +02:00
Thomas Haller c3ecca225c core: add _nm_utils_array_find_binary_search()
Also add nm_cmp_uint32_p_with_data(). Will be used later.
2016-09-23 15:49:29 +02:00
Thomas Haller b1fd5a06c4 macros: simplify NM_IN_SET() and NM_IN_STRSET() macros
and support up to 16 arguments.
2016-09-22 16:34:22 +02:00
Thomas Haller 1206fd066b shared: add nm_utils_syslog_coerce_from_nm() util
When a VPN plugin logs to syslog(), it should not use the syslog
levels that were passed in by NetworkManager directly. Instead,
it must map LOG_NOTICE to LOG_INFO and LOG_INFO to LOG_DEBUG.

Add a utility function does gets that right.
2016-09-19 15:35:33 +02:00
Thomas Haller eb8da4c282 build: disable type checks in G_TYPE_CHECK_INSTANCE_CAST() macros (bgo#771120)
Avoid the pointless overhead. Even glib disables them unless you build
with --enable-debug.

https://bugzilla.gnome.org/show_bug.cgi?id=771120
2016-09-12 13:53:34 +02:00
Thomas Haller 2cae9ba348 shared: add _NM_GET_PRIVATE() macro 2016-09-08 00:21:21 +02:00
Thomas Haller b2016fd2a5 shared: add NM_MIN()/NM_MAX() macros to replace glib's MIN()/MAX() 2016-09-08 00:21:21 +02:00
Thomas Haller 3227b9017b shared: add helper macros nm_str_not_empty() and nm_strdup_not_empty() 2016-09-06 16:07:02 +02:00
Lubomir Rintel b2eb64a439 release: bump version to 1.5.0 (development) 2016-08-17 16:20:42 +02:00
Alfonso Sanchez-Beato 6fb0de0a8b auth: check when setting statistics refresh rate 2016-08-17 16:08:20 +02:00
Beniamino Galvani a52d4654ec checkpoint: use polkit to check permission 2016-08-17 14:55:34 +02:00
Thomas Haller 6d2680acf1 nm-glib.h: fix compatibility wrapper for g_variant_new_take_string()
g_variant_new_from_bytes() is itself only available since 2.36, thus
using it triggers a deprecation warning itself.
2016-08-11 19:21:55 +02:00
Thomas Haller 80d52e3230 nm-glib: add compatibility wrapper for g_variant_new_take_string() 2016-08-11 11:54:18 +02:00
Thomas Haller 3d30004710 build: cleanup src/Makefile.am
- reorder entries in src/Makefile.am so that general names
  are all at the beginning (AM_CPPFLAGS, sbin_PROGRAMS)
  and the names for a certain library/binary are grouped
  together
- have libNetworkManager.la reuse libNetworkManagerBase.la.
- let all components in src/Makefile.am use the same AM_CPPFLAGS,
  except libsystem-nm.la.
- move callouts/nm-dispatcher-api.h to shared/ directory. It
  is obviously not internal API to callouts, and callouts is
  not a library. Thus, the right place is shared/.
2016-08-11 11:54:18 +02:00
Thomas Haller de2ce68a9f shared: add NM_VPN_PLUGIN_CONFIG_PROXY_PAC to "nm-vpn-plugin-macros.h" for VPN plugins
Soon we will add proxy support where VPN plugins set a property
NM_VPN_PLUGIN_CONFIG_PROXY_PAC.

All a VPN plugin needs to make use of this new setting is the
NM_VPN_PLUGIN_CONFIG_PROXY_PAC define.

We don't want that older plugins (still compatible with libnm 1.2 API)
require a new API only for this define. Define it instead in
"shared/nm-utils/nm-vpn-plugin-macros.h" as fallback.

https://mail.gnome.org/archives/networkmanager-list/2016-June/msg00154.html
2016-07-06 13:54:35 +02:00
Thomas Haller 4041bf966f shared: add nm_strquote_a() helper 2016-07-05 23:08:22 +02:00
Thomas Haller 42940fd66b shared: drop function name from g_return_val_if_reached()
When using g_return_val_if_reached(), the default macro would include
the function name. This name is increasing the binary size. Replace
it in non-debug builds.
2016-07-05 20:46:49 +02:00
Thomas Haller 375d3e1cb8 vpn: support option to preserve previous routing information on VPN config update
On openvpn restart, the VPN helper script is invoked without full routing information.
Thus, the routes will be dropped because the helper script cannot provide them
on update.

Add an option "preserve-route" which tells NetworkManager to preserve
and reuse the previous configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1231338
https://bugzilla.gnome.org/show_bug.cgi?id=750873
2016-07-04 10:31:05 +02:00
Thomas Haller 8eed67122c device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.

"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.

"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a6.

"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".

On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.

There is some overlap with the "wifi.mac-address-randomization" setting.

https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-06-30 08:29:56 +02:00
Beniamino Galvani a5d1db08f8 dns: log DNS servers at TRACE level
Be more verbose at TRACE level and log the DNS servers associated to
configurations. This will help to debug issues like [0].

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1348887
2016-06-28 16:24:28 +02:00
Thomas Haller caeaa78918 nm-glib: implement compatibility macro for g_strv_contains() differently
Otherwise, deprecation warnings are not properly suppressed for

  g_return_if_fail (g_strv_contains (strv, str));
2016-06-17 12:25:33 +02:00
Thomas Haller 1b9d60f985 nm-glib: remove G_GNUC_EXTENSION
We use statement expressions all over the place without explicitly
marking them. If that would be a problem, we'd have to change a
*lot* of code. We simply require that as a mandatory feature from
our compiler.
2016-06-17 12:25:15 +02:00
Lubomir Rintel 45d6baac4d shared: backport g_strv_contains() 2016-06-17 12:22:37 +02:00
Thomas Haller af507cd089 shared: add also "shared/nm-utils/nm-vpn-plugin-macros.h"
It has the very similar purpose as "nm-utils/nm-vpn-plugin-utils.[ch]", except
that is is header-only.
2016-06-16 18:06:16 +02:00
Thomas Haller 89d32944af tests: fix checking NM_ASSERT_NO_MSG define in "nm-test-utils.h"
"nm-test-utils.h" may also be used by the VPN plugins, there
we have no NM_ASSERT_NO_MSG define.
2016-06-16 11:04:51 +02:00
Thomas Haller 3bcec4067f shared: include "nm-glib.h" from "nm-macros-internal.h"
"nm-glib.h" is our most basic header. "nm-macros-internal.h" extends
on that. Thus, let "nm-macros-internal.h" include "nm-glib.h".
2016-06-16 10:45:54 +02:00
Thomas Haller 037462e902 shared: include "gsystem-local-alloc.h" from "nm-glib.h"
"nm-glib.h" is the most basic header, the one we cannot do without.
("nm-default.h", is already more generic, the one which every common
source file in NetworkManager repository should include).

Let "gsystem-local-alloc.h" be included by "nm-glib.h" and nowhere
else.
2016-06-16 10:45:54 +02:00
Thomas Haller 5d55492bac shared: add "nm-utils/nm-vpn-plugin-utils.h"
This file is only used by plugins and copied between them.

It's purpose is to contain general utility functions that are
only relevant for implementing NetworkManager's VPN plugins.

In principle the utility functions could be part of libnm, however,
there are a few problems with that:
  - if they are part of libnm, adding and using a new utility function
    requires the plugin to bump the required libnm version. Since you
    usally can work around/reimplement utility functions, this results
    in not using the API from libnm, not adding the API to libnm,
    and reimplementing it over and over in the plugin.
  - plugins compile both against libnm and libnm-glib. Thus, either
    the utility function would also be needed in libnm-glib, or again,
    it is not usable by the plugin.

We must avoid that the utility functions diverge and no local
modifications to these files should be made in the plugin.
Instead, one special location of the utility functions shall be
extended and re-imported (copied) to the plugin as needed.

Add the files to NetworkManager's repository. Although they are not
needed for NetworkManager itself, they are a different API provided
by NetworkManager. An API that is reused and shared by copying the files
around.
2016-06-16 10:45:54 +02:00
Thomas Haller 4b288136e1 shared: move shared files to subdirectory "shared/nm-utils/"
The "shared" directory contains files that are possibly used by all components
of NetworkManager repository.

Some of these files are even copied as-is to other projects (VPN plugins, nm-applet)
and used there without modification. Move those files to a separate directory.
By moving them to a common directory, it is clearer that they belong
together. Also, you can easier compare the copied versions to their
original via

  $ diff -r ./shared/nm-utils/ /path/to/nm-vpn-plugin/shared/nm-utils/
2016-06-16 10:45:53 +02:00
Thomas Haller cf34211c90 libnm/vpn: add nm_vpn_editor_plugin_load_vt()
Let VPN plugins return a virtual function table to extend
the API while bypassing libnm. This allows to add and use
new functionality to VPN plugins without updating libnm.

The actual definitions are in a header-only file
"nm-vpn-editor-plugin-call.h", which can be copied to the
caller/plugin.
2016-06-15 15:01:12 +02:00
Thomas Haller e108f1cfaf shared: add nm_strcmp_p() utils macro 2016-06-15 10:32:31 +02:00
Thomas Haller 00f58adb16 build: remove assertion messages in non-debug build
Assertions like g_assert*() and g_return_*() contain the stringified
test expression. This string ends up in the binary and increases its
size.

We usually don't have failing assertions. These string are a waste,
instead the file and line number shall suffice.

It reduces the striped size of the NetworkManager binary from 2500k
to 2392k, that is -108k, -4.3%.

This changes

 - "g_assert (1 == 2);"
   from: NetworkManager:ERROR:source.c:347:some_function: assertion failed: (1 == 2)
   to:   NetworkManager:ERROR:source.c:347:<unknown-fcn>: assertion failed: (<dropped>)

 - "g_return_if_fail (1 == 2);"
   from: (process:21024): NetworkManager-CRITICAL **: some_function: assertion '1 == 2' failed
   to:   (process:21024): NetworkManager-CRITICAL **: ((source.c:347)): assertion '<dropped>' failed

When doing a non-debug build, those string are now removed. Debug-builds
can be enabled by setting --with-more-assert=$LEVEL to larger then zero.

https://bugzilla.gnome.org/show_bug.cgi?id=767296
2016-06-09 12:03:39 +02:00
Thomas Haller fa973afa19 tests: add macro NMTST_G_RETURN_MSG for expecting g_return*() failures
A failure to g_return*() by default prints a g_critical() with stringifing the
condition. Add a macro NMTST_G_RETURN_MSG() that reproduces that line to more
accurately match the failure message.
2016-06-09 12:03:39 +02:00
Thomas Haller 348e505b3a macros: add macro _nm_printf() for function attribute 2016-06-05 12:22:01 +02:00
Thomas Haller 8e54cfdb27 all: move NM_AUTH_PERMISSION_* defines to "nm-common-macros.h" header 2016-06-01 19:06:35 +02:00
Thomas Haller ed551a4633 shared: add "nm-common-macros.h" header
Shared headers are all project-wide and internal API.
Currently we have the following:

General purpose:

  - shared/gsystem-local-alloc.h: header-only, allocation macros
  - shared/nm-dbus-compat.h: header-only, D-Bus related defines
  - shared/nm-glib.h: header-only, glib compatibility defines
  - shared/nm-macros-internal.h: header-only, utils
  - shared/nm-shared-utils.[hc]: source and header, utils
  - shared/nm-test*.[hc]: source and header, libnm testing utils

Special to NetworkManager repository:

  - shared/nm-version-macros.h.in: header-only, version macros
  - shared/nm-default.h: header-only, default-include

Now we add "shared/nm-common-macros.h" which is header-only, but non
general purpose.

I am running low on good names, considering all the shared/core/macros
utils headers. Still, I think "nm-common-macros.h" is appropriate.
2016-06-01 19:06:35 +02:00
Thomas Haller a2c843499c all/tests: split core part out of "nm-test-utils.h"
A large part of "nm-test-utils.h" is only relevant for tests inside "src/"
directory, as they are helpers related to NetworkManager core part.

Split this part out of "nm-test-utils.h" header.
2016-05-17 16:48:52 +02:00
Thomas Haller 5847e70fd6 shared: add _nm_pure/_nm_const define for __attribute__ ((pure))/((const)) 2016-05-16 13:09:02 +02:00
Thomas Haller b871106e25 macros: define NM_MORE_ASSERTS is not defined
In NetworkManager's configure script we have --with-more-asserts
option which always defines NM_MORE_ASSERTS in config.h.

When reusing the header file outside of NetworkManager, the
NM_MORE_ASSERTS define might be unset. Define it in that case
to avoid compiler warnings about undefined preprocessor define.
2016-05-14 23:11:59 +02:00
Thomas Haller ba90c9601c all: replace nm_unauto() by g_steal_pointer()
They do essentially the same.
2016-05-12 14:28:44 +02:00
Thomas Haller 5d1c4ca6c4 nm-glib: backport g_steal_pointer() from glib-2.44 2016-05-12 14:25:36 +02:00
Thomas Haller ee29228277 shared: add define _nm_unused for __attribute__((unused))
This is both supported by clang and gcc. Using it is nicer then
casting the (void), which requires an additional line of code.
2016-05-12 09:59:09 +02:00
Thomas Haller fbf4904ae0 nmtst: allow non-boolean argument to nmtst_assert_success()
Reimplement nmtst_assert_success() as a macro which allows non-boolean @success
arguments.
2016-05-09 11:04:51 +02:00
Thomas Haller 05478e4f4c utils: refactor _nm_utils_ascii_str_to_int64()
To allow for trailing whitespace, we don't need to copy and trunacate
the input string. g_ascii_strtoll() conveniently returns the location via
the endptr argument.
2016-05-03 11:52:39 +02:00
Thomas Haller 6bf022359f core/trivial: rename "source" field of addresses and routes
The "source" field of NMPlatformIPRoute (now "rt_source") maps to the
protocol field of the route. The source of NMPlatformIPAddress (now
"addr_source") has no direct equivalent in the kernel.

As their use is different, they should have different names. Also,
the name "source" is used all over the place. Hence give the fields
a more distinct name.
2016-04-28 12:53:21 +02:00
Thomas Haller 186787744c shared: move nm_utils_ascii_str_to_bool() to shared/nm-shared-utils.h 2016-04-19 13:47:41 +02:00
Thomas Haller 9a1e0b97da shared: add _nm_packed macro for __attribute__((packed)) 2016-04-11 11:26:36 +02:00
Thomas Haller 2e6ec6d8ac nmtst: add nmtst_platform_ip4_address() util 2016-04-11 11:26:32 +02:00
Thomas Haller 0e78ce5ed6 nmtst: add nmtst_rand_buf() util 2016-04-11 11:22:50 +02:00
Lubomir Rintel 350d96a9ee release: bump version to 1.3.0 (development) 2016-04-05 22:22:58 +02:00