Commit Graph

153 Commits

Author SHA1 Message Date
Jiří Klimeš
bccc1af51b cli: fix an bug when reporting an error
$ nmcli dev wifi rescan ifname eteee

(process:21211): libnm-CRITICAL **: nm_device_get_device_type: assertion 'NM_IS_DEVICE (self)' failed
Error: Device 'eteee' is not a Wi-Fi device.

Fixes: 823df334ed
2015-08-13 09:48: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
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship
3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00
Beniamino Galvani
f208e7030f cli: add 'metered' property to device 2015-06-09 18:11:25 +02:00
Lubomir Rintel
29fe1abf0d cli: stop waiting for deactivation if device reaches unmanaged state
default-unmanaged devices enter unmanaged state right after they're
disconnected.
2015-04-23 10:22:26 -04:00
Jiří Klimeš
1b9c1ed6d3 cli: add NM-PLUGIN-MISSING to devices 2015-04-20 10:04:26 +02:00
Jiří Klimeš
823df334ed cli: better indicate when a Wi-Fi plugin might not be available (rh #1168573)
* print an error message indicating NM Wi-Fi plugin may be missing, for
  nmcli device wifi ifname <dev-name>
  nmcli device wifi connect ifname <dev-name>

* add NM-TYPE to 'nmcli device show' command displaying internal NM device type
  (like NMDeviceWifi, NMDeviceGeneric, ...)

https://bugzilla.redhat.com/show_bug.cgi?id=1168573
2015-04-20 09:52:31 +02:00
Dan Winship
721e917cb6 wimax: drop WiMAX support (bgo #747846)
Even Fedora is no longer shipping the WiMAX SDK, so it's likely we'll
eventually accidentally break some of the code in src/devices/wimax/
(if we haven't already). Discussion on the list showed a consensus for
dropping support for WiMAX.

So, remove the SDK checks from configure.ac, remove the WiMAX device
plugin and associated manager support, and deprecate all the APIs.

For compatibility reasons, it is still possible to create and save
WiMAX connections, to toggle the software WiMAX rfkill state, and to
change the "WIMAX" log level, although none of these have any effect,
since no NMDeviceWimax will ever be created.

nmcli was only compiling in support for most WiMAX operations when NM
as a whole was built with WiMAX support, so that code has been removed
now as well. (It is still possible to use nmcli to create and edit
WiMAX connections, but those connections will never be activatable.)
2015-04-17 12:42:23 -04:00
Jiří Klimeš
8252553615 cli: add PHYS_PORT_ID property to devices
The physical-port-id property was added to libnm (libnm-glib) in commit
47cc8b25f2.
2015-04-14 12:18:00 +02:00
Beniamino Galvani
aabc6fc57b wifi: indicate 2ghz and 5ghz wifi device capabilities
Add new capabilities CAP_FREQ_2GHZ and CAP_FREQ_5GHZ to indicate the
frequency bands supported by a Wifi device.

Add also CAP_FREQ_VALID, which is set when the values of the other 2
capabilities are available.

Original patch by Dan Williams <dcbw@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=723295
2015-04-08 10:48:38 +02:00
Jiří Klimeš
b8a2f42a38 cli: allow multiple devices for 'nmcli device disconnect/delete' (bgo #746097)
Allow disconnecting and deleting multiple interfaces at a time. It is much
more user friendly. TAB and bash completions are supported as well.

https://bugzilla.gnome.org/show_bug.cgi?id=746097
2015-03-20 11:03:44 +01:00
Jiří Klimeš
643291bea5 cli: sort access point list
According to signal strength, frequency and rate.
2015-02-26 11:54:45 +01:00
Jiří Klimeš
fad26c286c cli: color output of 'nmcli device wifi list' 2015-02-24 15:14:13 +01:00
Jiří Klimeš
4668f2038e nmcli: show devices list in colors 2015-02-23 09:24:21 +01:00
Jiří Klimeš
fda5a4703d cli: add parent device information for VLAN devices 2014-11-24 10:33:22 +01:00
Dan Williams
88c9c6a6ac clients: merge nm_secret_agent_simple_set_connection_path() into nm_secret_agent_simple_enable()
set_connection_path() is almost always called right before enable(),
and it's unclear why it would be called anywhere else.  So just
merge the two methods.
2014-11-21 12:14:48 -05:00
Dan Winship
a1f746351a clients: NMSecretAgentSimple API fixups
nm_secret_agent_simple_*() functions should take an
NMSecretAgentSimple, not an NMSecretAgent.

The type macros were incorrectly validating against
NM_TYPE_SECRET_AGENT rather than NM_TYPE_SECRET_AGENT_SIMPLE.
2014-11-21 12:08:35 -05:00
Jiří Klimeš
4b799db1d3 cli: add support for secret agent to 'nmcli dev connect' too
And move secrets getting code to common.c (without changes).
2014-11-20 16:36:29 +01:00
Lubomir Rintel
653b7e4805 cli: Watch for device as well as AC state changes when activating
The signals might be delivered in no particular order and we need to wait for
the device to reach stable state (whether it's successfully conntected or not)
as well as the active connection to leave ACTIVATING state.

https://bugzilla.gnome.org/show_bug.cgi?id=740320
2014-11-19 17:06:33 +01:00
Lubomir Rintel
7d80a17631 cli: Finish waiting for the device activation when it disconnects
The device status alone is uninteresting as its changes can be due to
deactivation of previously active connection. We should monitor the
active connection changes instead of device state changes.

However the device state changes is still interesting, as it contains the
reason for the change, let's just ignore them while the connection is
activating.

Lastly, we need to handle failures as well. It should be noted that it's
not sufficient to deal with NM_DEVICE_STATE_FAILED as the device will
quickly draverse to NM_DEVICE_STATE_DISCONNECTED. This happens in case of
a failure due to NM_DEVICE_STATE_REASON_NO_SECRETS as soon as the server
makes sure it won't reconnect automatically.
2014-11-14 16:46:40 -06:00
Lubomir Rintel
529092f035 Revert "cli: Finish waiting for device activation when they disconnect"
In case there's already a connection on the device, it traverses to
DISCONNECTED. We shouldn't cease waiting then.

This reverts commit 94a57d5e07.
2014-11-14 13:54:13 +01:00
Lubomir Rintel
94a57d5e07 cli: Finish waiting for device activation when they disconnect
When wifi secrets are missing, NM_DEVICE_STATE_FAILED due to
NM_DEVICE_STATE_REASON_NO_SECRETS is immediately followed by traversal to
NM_DEVICE_STATE_DISCONNECTED as soon as the server makes sure it won't
reconnect automatically. We sometimes aren't quick to handle the first signal
and only get the latter one.

Let's treat all states that aren't ordinarily reached upon activation as bad.
2014-11-13 18:55:37 +01:00
Jiří Klimeš
b75dfc62e8 cli: fix nmcli timeout when disconnecting a device
$ nmcli dev disconnect nm-bond
Error: Timeout 10 sec expired.

When a software device is disconnected, it will be removed. And it may not go
to NM_DEVICE_STATE_DISCONNECTED state before that. So we need to listen to
"device-removed" signal.

Fixes:Beaker:test_log-NetworkManager_Test189_bond_activate
2014-11-10 17:22:52 +01:00
Dan Winship
ca18b2d442 libnm: create NMDhcpConfig as parent of NMDhcp4Config and NMDhcp6Config
As with NMIP4Config and NMIP6Config, merge the two DHCP config classes
into one in the public API.
2014-11-07 07:49:40 -05:00
Dan Winship
d34910b128 libnm: create NMIPConfig as parent of NMIP4Config and NMIP6Config
Create NMIPConfig as the parent of NMIP4Config and NMIP6Config, and
remove the two subclasses from the public API; while it's convenient
to still have both internally, they are now identical to the outside
world.
2014-11-07 07:49:40 -05:00
Jiří Klimeš
3a551664df cli: add 'nmcli agent' command (bgo #739568)
Synopsis:
nmcli agent { secret | polkit | all }

The command runs separate NetworkManager secret agent or session polkit agent, or both.
It is useful when
- no other secret agent is available (such as GUI nm-applet, gnome-shell, KDE applet)
- no other polkit agent is available (such as polkit-gnome-authentication-agent-1,
  polkit-kde-authentication-agent-1 or lxpolkit)

https://bugzilla.gnome.org/show_bug.cgi?id=739568
2014-11-07 11:58:25 +01:00
Jiří Klimeš
afde052445 trivial: fix a typo in comments 2014-10-30 08:25:11 +01:00
Dan Winship
2ff4a7d4b0 libnm: strip GDBus gunk from GErrors
Call g_dbus_error_strip_remote_error() on all errors returned from
gdbus calls. (Blah!)
2014-10-22 08:29:10 -04:00
Dan Winship
862d4efeac libnm-core, core: move NMManagerError to nm-errors
Move the definition of NMManagerError to nm-errors, register it with
D-Bus, and verify in the tests that it maps correctly.

NM_MANAGER_ERROR_INTERNAL gets renamed to NM_MANAGER_ERROR_FAILED for
consistency. NM_MANAGER_ERROR_UNMANAGED_DEVICE is dropped since that
name doesn't really describe the one place it was previously used in.
NM_MANAGER_ERROR_SYSTEM_CONNECTION is dropped because it was't being
used. NM_MANAGER_ERROR_UNSUPPORTED_CONNECTION_TYPE is dropped because
it can be replaced with an NM_CONNECTION_ERROR.
NM_MANAGER_ERROR_AUTOCONNECT_NOT_ALLOWED is turned into the more
generic NM_MANAGER_ERROR_CONNECTION_NOT_AVAILABLE.

Also, remove the <tp:possible-errors> sections from nm-manager.xml,
since they were completely out of date.
2014-10-22 08:29:09 -04:00
Jiří Klimeš
e0c8848f2e cli: get connection ID straight from the active connection
Static connection profile may not be available and using active conection
is easier anyway.
2014-10-20 09:11:57 +02:00
Jiří Klimeš
8919a8572a cli: strip errors from D-Bus before presenting to a user 2014-10-01 11:53:07 +02:00
Dan Winship
e684f36365 libnm-core: add nm_utils_wifi_strength_bars(), use it in nmcli and nmtui
Add nm_utils_wifi_strength_bars(), which figures out whether the
terminal can display graphical wifi strength bars, and converts a
numerical value to the appropriate Unicode or ASCII characters.

This also now takes into consideration the fact that the console font
doesn't contain all of the necessary characters, so we can't display
the graphical bars there. (rh #1131491)
2014-09-27 11:49:15 -04:00
Dan Winship
1b74e77f9f cli: use g_print/g_printerr rather than printf/fprintf
Use g_print() and g_printerr(), which wrap printf() and
fprintf(stderr,...), but handle conversion from UTF-8 if the locale is
using a different character set.
2014-09-27 11:45:53 -04:00
Jiří Klimeš
9eabe9c5f6 cli: move "CONNECTIONS" group lower in the output 2014-09-25 19:09:06 +02:00
Jiří Klimeš
6c27af6385 cli: show capabilities for Bluetooth devices 2014-09-25 19:09:05 +02:00
Jiří Klimeš
0b6bd87848 cli: also show team and bridge specific details for devices
Now it is only SLAVES field, common for bond, team and bridge devices.
2014-09-25 19:09:05 +02:00
Dan Winship
2237ea3ddb libnm: make sync/async APIs more GLib-like
Make synchronous APIs take GCancellables, and make asynchronous APIs
use GAsyncReadyCallbacks and have names ending in "_async", with
"_finish" functions to retrieve the results.

Also, make nm_client_activate_connection_finish(),
nm_client_add_and_activate_finish(), and
nm_remote_settings_add_connection_finish() be (transfer full) rather
than (transfer none), because the refcounting semantics become
slightly confusing in some edge cases otherwise.
2014-09-25 09:29:20 -04:00
Jiří Klimeš
3784678177 cli: create a connection if none exist in 'nmcli dev connect' (rh #1113941)
https://bugzilla.redhat.com/show_bug.cgi?id=1113941
2014-09-22 13:10:43 +02:00
Jiří Klimeš
dc1c17fd30 cli: get NMClient early and remove duplicated code 2014-09-22 12:53:46 +02:00
Dan Winship
3e5b3833aa libnm: change empty-GPtrArray-return semantics
libnm functions that return GPtrArrays of objects had a rule that if
the array was empty, they would return NULL rather than a 0-length
array. As it turns out, this is just a nuisance to clients, since in
most places the code for the non-empty case would end up doing the
right thing for the empty case as well (and where it doesn't, we can
check "array->len == 0" just as easily as "array == NULL"). So just
return the 0-length array instead.
2014-09-04 09:21:05 -04:00
Dan Winship
20dc44bda9 libnm: drop NM_TYPE_SSID, use G_TYPE_BYTES
Make NMAccessPoint:ssid be G_TYPE_BYTES and update the corresponding
APIs accordingly.
2014-09-04 09:21:04 -04:00
Dan Winship
f71218d70a libnm: simplify NMDevice:state-reason
The NMDevice:state-reason property was awkward to work with since it
was a tuple of two values (state and reason), and likewise, although
we had nm_device_get_state() to return just the state, there was no
corresponding function to get just the reason.

Fix this; make the state-reason property contain just the
NMDeviceStateReason, and make nm_device_get_state_reason() return just
that.
2014-09-04 09:21:04 -04:00
Dan Winship
3fbabde4c3 libnm-core: replace GByteArray with pointer + length in some APIs
APIs that take arbitrary data should take it in the form of a pointer
and length, not a GByteArray, so that you can use them regardless of
what format you have the data in (GByteArray, GBytes, plain array,
etc).
2014-09-04 09:20:11 -04:00
Jiří Klimeš
26eafd3420 trivial: fix a typo in show_access_point_info() function name 2014-08-18 13:58:43 +02:00
Jiří Klimeš
45358f51fc cli: fix crash in nmcli device wifi with multiple wifi devices (bgo #734466)
And separate details for particular devices with an empty line.

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

Reported-by: Martin Pitt <martinpitt@gnome.org>
2014-08-18 13:58:43 +02:00
Dan Winship
e1ba13a426 libnm-core, libnm, core: make NMConnection an interface
The fact that NMRemoteConnection has to be an NMConnection and
therefore can't be an NMObject means that it needs to reimplement bits
of NMObject functionality (and likewise NMObject needs some special
magic to deal with it). Likewise, we will need a daemon-side
equivalent of NMObject as part of the gdbus port, and we would want
NMSettingsConnection to be able to inherit from this as well.

Solve this problem by making NMConnection into an interface, and
having NMRemoteConnection and NMSettingsConnection implement it. (We
use some hacks to keep the GHashTable of NMSettings objects inside
nm-connection.c rather than having to be implemented by the
implementations.)

Since NMConnection is no longer an instantiable type, this adds
NMSimpleConnection to replace the various non-D-Bus-based uses of
NMConnection throughout the code. nm_connection_new() becomes
nm_simple_connection_new(), nm_connection_new_from_hash() becomes
nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
becomes nm_simple_connection_new_clone().
2014-08-16 10:17:53 -04:00
Dan Winship
8ce06b814c libnm: synchronize NMClient and NMRemoteSettings "is NM running" properties
Rename NMClient:manager-running and NMRemoteSettings:service-running
to both be :nm-running.
2014-08-07 15:43:43 -04:00
Dan Winship
357efd26e4 libnm-core: include ETH_ALEN/INFINIBAND_ALEN defines in nm-utils.h
Include <linux/if_ether.h> and <linux/if_infiniband.h> from
nm-utils.h, to get ETH_ALEN and INFINIBAND_ALEN, and remove those
includes (as well as <net/ethernet.h> and <netinet/ether.h>, and
various headers that had been included to get the ARPHRD_* constants)
from other files where they're not needed now.
2014-08-07 14:04:14 -04:00
Dan Winship
35f36ba4c3 libnm-core, etc: drop type-based hwaddr funcs, port to length-based ones
Drop the arptype-based nm_utils_hwaddr funcs, and rename the
length-based ones to no longer have _len in their names. This also
switches nm_utils_hwaddr_atoba() to using a length rather than an
arptype, and adds a length argument to nm_utils_hwaddr_valid() (making
nm_utils_hwaddr_valid() now a replacement for nm_utils_hwaddr_aton()
in some places, where we were only using aton() to do validity
checking).
2014-08-07 12:08:16 -04:00