Commit Graph

528 Commits

Author SHA1 Message Date
Jiří Klimeš
687b651598 libnm/vlan: default to vlan.flags=REORDER_HDR for new connections (rh #1250225)
The kernel defaults REORDER_HDR to 1 when creating a new VLAN, but
NetworkManager's VLAN flags property defaulted to 0. Thus REORDER_HDR was not
set for NM-created VLANs with default values.

We want to match the kernel default, so we change the default value for the
vlan.flags property. However, we do not want to change the flags for existing
connections if the property is missing in connection files. Thus we have to
update plugins for that. We also make sure that vlan.flags is always written
by 'keyfile' when the value is default. That way new connections have flags
property explicitly written and it will be loaded as expected.

https://bugzilla.redhat.com/show_bug.cgi?id=1250225
2015-10-07 13:45:30 +02:00
Lubomir Rintel
3f0d595cc8 libnm,ip4-config: add ipv4.dhcp-timeout property
This is intentionally IPv4 specific since this is used for a quick fallback to
method=link-local -- something that's not needed for IPv6 since the link local
address is always there.

https://bugzilla.redhat.com/show_bug.cgi?id=1262922
2015-10-06 14:16:55 +02:00
Beniamino Galvani
bd27c110a3 glib-compat: add g_hash_table_get_keys_as_array() compat function 2015-10-01 09:05:08 +02:00
Thomas Haller
7bf10a75db build: extract version macros from "nm-version.h" to new header file "nm-version-macros.h"
For libnm library, "nm-dbus-interface.h" contains defines like the D-Bus
paths of NetworkManager. It is desirable to have this header usable without
having a dependency on "glib.h", for example for a QT application. For that,
commit c0852964a8 removed that dependancy.

For libnm-glib library, the analog to "nm-dbus-interface.h" is
"NetworkManager.h", and the same applies there. Commit
159e827a72 removed that include.
However, that broke build on PackageKit [1] which expected to get the
version macros by including "NetworkManager.h". So at least for libnm-glib,
we need to preserve old behavior so that a user including
"NetworkManager.h" gets the version macros, but not "glib.h".

Extract the version macros to a new header file "nm-version-macros.h".
This header doesn't include "glib.h" and can be included from
"NetworkManager.h". This gives as previous behavior and a glib-free
include.

For libnm we still don't include "nm-version-macros.h" to "nm-dbus-interface.h".
Very few users will actually need the version macros, but not using
libnm.
Users that use libnm, should just include (libnm's) "NetworkManager.h" to
get all headers.
As a special case, a user who doesn't want to use glib/libnm, but still
needs both "nm-dbus-interface.h" and "nm-version-macros.h", can include
them both separately.

[1] https://github.com/hughsie/PackageKit/issues/85

Fixes: 4545a7fe96
2015-09-30 23:10:29 +02:00
Thomas Haller
c60ff9e7e0 libnm: add NM_AVAILABLE_IN_1_2 to "nm-dbus-interface.h"
"nm-dbus-interface.h" can be used without glib/libnm, hence we must
workaround a missing NM_AVAILABLE_IN_1_2 macro.
2015-09-25 16:22:47 +02:00
Jiří Klimeš
12e6cf1f20 libnm-core/libnm-util: fix an erroneous error message
ipv6.dns: 'this property is not allowed for '%s=%s'' not allowed for method=ignore
2015-09-25 16:11:24 +02:00
Thomas Haller
0e223d4961 libnm: include "glib.h" in "nm-version.h"
This is a forward port of commit 6f616d4c4b04d5478f60d0311317bc84c5459ea4
which added this patch on nm-1-0 branch.

However, the reason stated there is wrong because we don't need this
to fix Qt examples. Building Qt examples was fixed in that "nm-dbus-interface.h"
no longer drags in "nm-version.h".

On the other hand, we still want "nm-version.h" to be self-contained,
and include "glib.h" as it needs it.
2015-09-25 15:48:09 +02:00
Thomas Haller
c0852964a8 libnm: don't include "nm-version.h" in "nm-dbus-interface.h"
We want "nm-dbus-interface.h" to have no dependancy on libnm and glib.
That way, it is usable for example in the QT examples without dragging
in dependencies to glib.

Also drop all the unneccessary include to "nm-dbus-interface.h", which
we already get by directly or indirectly including "nm-core-types.h".
2015-09-25 15:42:15 +02:00
Jiří Klimeš
ffe16c958f libnm-core: add vpn.timeout property for establishing connections
[1] https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00007.html
2015-09-21 16:59:04 +02:00
Jiří Klimeš
3d64d45d16 libnm-core/libnm-util: fix an assertion in adsl setting
(process:7799): GLib-CRITICAL **: g_ascii_strdown: assertion 'str != NULL' failed
2015-09-21 15:21:50 +02:00
Thomas Haller
c9b3617c35 libnm: mark properties that take effect immediately on active connection (REAPPLY_IMMEDIATELY)
The flag is still unused.
2015-09-18 17:31:51 +02:00
Thomas Haller
b1ebbf4c80 libnm: use NM_FLAGS_HAS() in nm_setting_compare() 2015-09-18 16:37:48 +02:00
Thomas Haller
af180da625 libnm: don't assert in nm_connection_get_*() for verified connection
Those getters are convenience methods to retrieve the id/type from
the NMSettingConnection. If the NMSettingConnection was missing
(and thus the connection invalid) we would raise an assertion.

Don't be so strict and just silently return NULL.
Otherwise, the caller cannot use the functions on unverified
connections.
2015-09-18 16:12:36 +02:00
Jiří Klimeš
4485b4ec2f nmcli: wake-on-lan property set/get fixes
- accept a numeric value (decimal or hex (0x prefix))
- display a numeric value of the property in addition to the strings
- add/accept spaces between string names

to behave similar to other flags' properties.
2015-09-15 11:46:37 +02:00
Lubomir Rintel
874f455d6d test: fix duplicate test names
New glib complains.
2015-09-04 12:08:40 +02:00
Jiří Klimeš
71c8c2e587 libnm-core: fix a crash in priority_strv_to_maplist()
strv can be NULL.

Reproducer:
$ nmcli con mod my-vlan vlan.ingress 1:5
2015-09-01 16:09:08 +02:00
Jiří Klimeš
5e3582c6b1 doc: fix the names of [in|e]gress-priority-map properties in ifcfg-rh man page 2015-08-31 08:44:10 +02:00
Thomas Haller
9cace5b411 libnm/trivial: add code comment to _nm_dbus_error_has_name() 2015-08-25 16:37:43 +02:00
Beniamino Galvani
0bc335cfbe libnm: backport NMSettingWired Wake-on-LAN symbols to 1.0.6
Backport to 1.0.6 the following symbols:

  - nm_setting_wired_get_wake_on_lan
  - nm_setting_wired_get_wake_on_lan_password
  - nm_setting_wired_wake_on_lan_get_type

added to 1.0.6 with commit d449d823046ac02f19d086575a19be7f40278bd0
2015-08-25 10:23:57 +02:00
Beniamino Galvani
0969d16ad8 libnm: backport enum conversion utilities to 1.0.6
Backport to 1.0.6 the following symbols:

  - nm_utils_enum_from_str
  - nm_utils_enum_to_str

added to 1.0.6 with commit f4ce6760e0ebb66aee3df35e9618be656355f318
2015-08-25 10:23:57 +02:00
Thomas Haller
b2a66d59c8 Revert "all: change "Since: 1.2" to "Since: 1.0.4"/"Since: 1.0.6" for backported API"
API should be added with "Since:" of the next release on the same branch.
That means, new API on 1.1 branch (development), should be "Since: 1.2"
and new API on 1.0 branch (stable) will be "Since: 1.0.x". Similarly, new
API on master is NM_AVAILABLE_IN_1_2 and will be added with the linker
version libnl_1_2 -- never the versions of minor releases.

It is also strongly advised that for the 1.0 branch, we only add API
that was previously formerly added on master. IOW, that we only do true
backports of API that already exists on master.

API that gets backported, must also be added to master via NM_BACKPORT_SYMBOL().
That gives ABI compatibility and an application that was build against 1.0.x
will work with 1.y.z version (y > 0) without need for recompiling -- provided
that 1.y.z also contains that API.

There is one important caveat: if a major branch (e.g. current master) has a
linker section of backported APIs (e.g. libnm_1_0_6), we must do the minor release
(1.0.6) before the next major release (1.2). The reason is that after the major
release, the linker section (libnm_1_0_6) must not be extended and thus
the minor release (1.0.6) must be already released at that point.

In general, users should avoid using backported API because it limits
the ability to upgrade to arbitrary later versions. But together with the
previous point (that we only backport API to minor releases), a user that
uses backported API can be sure that a 1.y.z version is ABI compatible with
1.0.x, if the 1.y.z release date was after the release date of 1.0.x.

This reverts commit 02a136682c.
2015-08-25 09:04:35 +02:00
Lubomir Rintel
00b73a9f10 libnm,vpn-editor-plugin: don't assert the plugin name is the same as service name
It's not. It's meant to be human readable (e.g. "IPSec network that sometimes
works").
2015-08-21 16:06:39 +02:00
Lubomir Rintel
4b9f56ecfb Revert "libnm,vpn-editor-plugin: don't assert the plugin name is the same as service name"
This reverts commit 7583f6fc5e.
2015-08-21 16:00:37 +02:00
Lubomir Rintel
7583f6fc5e libnm,vpn-editor-plugin: don't assert the plugin name is the same as service name
It's not. It's meant to be human readable (e.g. "IPSec network that sometimes
works").
2015-08-21 13:37:24 +02:00
Jiří Klimeš
02a136682c all: change "Since: 1.2" to "Since: 1.0.4"/"Since: 1.0.6" for backported API 2015-08-21 10:43:53 +02:00
Jiří Klimeš
3d044b443a libnm: symbols for getting Wi-Fi frequencies have been backported to 1.0.6
Backport to 1.0.6 the following symbols:
  - nm_utils_wifi_2ghz_freqs;
  - nm_utils_wifi_5ghz_freqs;

Backported by commit 77bf69c3dc6ef6c17741cdf0f81af911378596e0
2015-08-21 10:22:31 +02:00
Jiří Klimeš
1a6b631690 libnm: add utility functions for getting 2.4 GHz and 5 GHz Wi-Fi frequencies
nm_utils_wifi_2ghz_freqs()
nm_utils_wifi_5ghz_freqs()
2015-08-21 09:32:09 +02:00
Thomas Haller
1889e9c568 libnm/vpn: set special error code when loading vpn plugin fails due to missing file
VPN plugins are usually split into different packages. It might
be that the plugin file is simply not installed. We want the caller
to be able to recognize that conditation to fail gracefully.
Thus return a certain error code.
2015-08-20 12:42:20 +02:00
Thomas Haller
3dfbbb227e libnm: require exact vpn plugin filename
Originally, nm-applet loaded the vpn plugins by passing the filename
to g_module_open(). Thereby, g_module_open() allowed for missing file
extension and tries to complete the name with a system-dependent suffix.

When porting to libnm, we kept that behavior but did more elaborate
checks on the file, like checking owner and permissions.

Change to no longer trying to append the system suffix, but require
an exact path. That is no usability problem, because the plugin path
is specified in the .name files, and we just require them now to be the
full path (including the .so extension).
Note also, that this only affects new, libnm-based vpn plugins, thus there
is no change in behavior for legacy libnm-glib based plugins.

Fixes: eed0d0c58f
2015-08-18 12:08:11 +02:00
Thomas Haller
96cacc07e8 macros: use short-circuit evaluation in NM_IN_SET()
All current users of NM_IN_SET() would rather use short-circuit evalation
(or don't care). It seems that doing it by default seems favorable.

The only downside is, that this might have somewhat unexpected behavior
to a user who expects a regular function (which would evaluate always
all arguments).

Fixes: 7860ef959a
2015-08-12 16:04:17 +02:00
Thomas Haller
7860ef959a macros: rework NM_IN_SET() macro to expand to a plain logical expression
Let the preprocessor do more work, but generate a simple expression that
the compiler can optimize (presumably) better.
2015-08-12 14:30:18 +02:00
Thomas Haller
97ec44f593 libnm: fix gtkdoc for nm_utils_enum_to_str() and nm_utils_enum_from_str()
Fixes: 8be9814793
2015-08-05 16:35:26 +02:00
Thomas Haller
1766ab6e21 libnm: fix gtkdoc for _nm_utils_dns_option_*()
Fixes: 019943bb5d
2015-08-05 16:33:44 +02:00
Thomas Haller
d81e8b96d2 libnm: fix gtkdoc for nm_setting_ip_config_next_valid_dns_option()
Fixes: 019943bb5d
2015-08-05 16:32:00 +02:00
Thomas Haller
eef0342bcc libnm/test: use (void) for empty parentheses in function prototype
Fixes: ec92ecedae
2015-08-05 16:24:12 +02:00
Dan Winship
22e1a97e12 all: drop includes to <glib/gi18n.h> for "nm-default.h"
The localization headers are now included via "nm-default.h".

Also fixes several places, where we wrongly included <glib/gi18n-lib.h>
instead of <glib/gi18n.h>. For example under "clients/" directory.
2015-08-05 15:35:51 +02:00
Thomas Haller
7363dc94c6 nm-default: include i18n headers via "nm-default.h" 2015-08-05 15:32:40 +02:00
Thomas Haller
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Thomas Haller
780e9a3f43 libnm: include header in public header file with angle brackets 2015-08-05 15:25:30 +02:00
Thomas Haller
e0bded93f3 libnm: avoid deprecated warning for NMVpnPluginInfo
When merely including "nm-vpn-plugin-info.h" (or "NetworkManager.h")
gcc raises warnings like:
  "Not available before 1.2 [-Werror=deprecated-declarations]"

The problem is that the NMVpnPluginInfo typedef itself is marked as
deprecated but also used by other functions like nm_vpn_plugin_info_get_name().

    typedef struct {
        int field;
    } Foo G_UNAVAILABLE(1,2);

    G_UNAVAILABLE(1,2)
    void deprecated_function (Foo *foo);

    warning: ‘Foo’ is deprecated: Not available before 1.2 [-Wdeprecated-declarations]

I think that when a function is itself deprecated, gcc should not warn about
the use of a deprecated typedef.
Gcc's documentation states: "Note that the warnings only occur for
uses and then only if the type is being applied to an identifier
that itself is not being declared as deprecated.".
Apparently, this only works for structs, but not for typedef of structs.

Anyway. Remove the deprecation from NMVpnPluginInfo to avoid the compiler
warning.

https://bugzilla.gnome.org/show_bug.cgi?id=753098

Fixes: d6226bd987
2015-08-04 15:59:32 +02:00
Beniamino Galvani
f8ae5f1671 libnm-core: trivial: fix glib-mkenums parse warning
Avoid a new line in the definition of enum value to fix the following
glib-mkenums warning:

  glib-mkenums: nm-setting-wired.h:71:
  Failed to parse ` - 1 - NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) '

Fixes: 5622461c04
2015-08-04 14:50:30 +02:00
Beniamino Galvani
d49fcd07d1 libnm-core: add _nm_utils_strv_equal() 2015-08-04 08:46:11 +02:00
Dan Williams
3a7db0dd9e introspection: fix some annotations
Fixes: eafa6c3584
Fixes: eed0d0c58f
Fixes: b5cc017ba4
Fixes: bce040daa2
2015-07-31 14:19:14 -05:00
Beniamino Galvani
e65854f609 libnm-core: strip nm_utils_enum_from_str() input string 2015-07-30 16:56:27 +02:00
Thomas Haller
eafa6c3584 libnm: add load method to NMVpnPluginInfo
https://bugzilla.gnome.org/show_bug.cgi?id=749877
2015-07-29 22:34:35 +02:00
Thomas Haller
eed0d0c58f libnm: add nm_vpn_editor_plugin_load_from_file() function 2015-07-29 22:34:35 +02:00
Thomas Haller
b5cc017ba4 libnm: add _nm_utils_check_module_file() 2015-07-29 22:34:35 +02:00
Thomas Haller
bce040daa2 libnm: move NMVpnEditorPlugin to libnm-core/
Split the content of libnm/nm-vpn-editor-plugin.h and
move NMVpnEditorPlugin to libnm-core/nm-vpn-editor-plugin.h.

VPN plugins allow us to extend functionality about VPNs.
This can be also useful for NetworkManager core, hence
move that part to libnm-core.

The name NMVpnEditorPlugin is slightly misleading but not completely
wrong. The "editor" part stands no longer for bringing nm-applet
functionality (alone), but enable general VPN functionality in
the client.

Especially because we already have NMVpnPluginOld with a different
meaning (i.e. a base class of the plugin server implementation).
2015-07-29 22:34:35 +02:00
Thomas Haller
d6226bd987 libnm: add NMVpnPluginInfo class
NMVpnPluginInfo is little more then a wrapper around
the GKeyFile that describes the VPN plugin settings,
i.e. the name files under "/etc/NetworkManager/VPN/".

Add this class to make the VPN API more explicit. Clients
now can use NMVpnPluginInfo instead of concerning themselves
with loading the keyfile and the meaning of its properties.

Also add support for a new VPN plugins directory
"/usr/lib/NetworkManager/VPN", which should replace
"/etc/NetworkManager/VPN" in the future. But we have to
consider both locations for backward compatibility.

The content of the VPN directory is not user configuration,
hence it should not be under "/etc". See related bug 738853.
2015-07-29 22:34:35 +02:00
Thomas Haller
ed381cb1e2 libnm: add _nm_utils_check_file() util 2015-07-29 22:34:35 +02:00