nm_utils_enum_to_str() may also output numeric values if there is no
corresponding "nick" for the enum/flag value.
For enums the value is in decimal and for flags the value is hexadecimal
(with a "0x" prefix).
The same was already supported by nm_utils_enum_from_str() when reading
the value. However, previously, reading a flag would only support hex
numbers and reading a enum would only support decimal numbers.
Extend that, to allow passing numbers in any base. For nm_utils_enum_to_str()
also make sure to never output nicks that may be misinterpreted as
numbers.
It is not uncommon that a flags type has also the value 0 mapped,
for example to "unknown" or "none".
In that case, we should not return an empty string, but instead
that zero value.
Also, flags actually have an unsigned type. That isn't a real
problem to cast it to a signed int. But be more careful about
it and use unsigned while handling unsigned values and only
cast to int once.
Commit 029a0a21ea ("device: split out cloned MAC decision from
nm_device_hw_addr_set_cloned()") accidentally removed the assignment
of the new device @hw_addr_type, which then was left to
HW_ADDR_TYPE_UNSET. As a consequence, we never restored the initial
MAC address when the connection was deactivated. Fix this.
Fixes: 029a0a21ea
(cherry picked from commit 166988264f)
Commit 029a0a21ea ("device: split out cloned MAC decision from
nm_device_hw_addr_set_cloned()") accidentally removed the assignment
of the new device @hw_addr_type, which then was left to
HW_ADDR_TYPE_UNSET. As a consequence, we never restored the initial
MAC address when the connection was deactivated. Fix this.
Fixes: 029a0a21ea
Fixes the parsing for correct and incorrect commands.
e.g.:
nmcli connection down id <conn>
nmcli -t
...
Fixes: 16902a2be6
(cherry picked from commit ef0d0d08eb)
Shift argc and argc manually between argument ant its value and use
next_arg() between arguments everywhere. Whill be useful to parse global
arguments.
This makes it possible to retain Internet connectivity when multiple devices
have a default route, but one with the link type of a higher priority can not
reach the Internet.
This moves tracking of connectivity to NMDevice and makes the NMManager
negotiate the best of known connectivity states of devices. The NMConnectivity
singleton handles its own configuration and scheduling of the permission
checks, but otherwise greatly simplifies it.
This will be useful to determine correct metrics for multiple default routes
depending on actual internet connectivity.
The per-device connection checks is not yet exposed on the D-Bus, since they
probably should be per-address-family as well.
These functions return static information, and don't require
a @setting argument. The list of options is interesting even
when having now setting instance at hand.
Document this to promise the user that passing %NULL is allowed.
It was allowed since when those functions were added.
moved from: char *colorize_string (..., gboolean &dealloc)
to: const char *colorize_string (..., char **out_to_free)
No more needed to cast (char *) on a (const char *).
Fixed also get_value_to_print() which relies on colorize_string()
When a full section is specified as the field parameter in terse tabular
mode, the section name should be printed followed by all the field values
belonging to that section separated by ':'. The NAME of section CONNECTIONS
was missing.
sample command:
$ nmcli -m tab -t -f CONNECTIONS device show ens3
previous output was:
/org/freedesktop/NetworkManager/Settings/{1}:5059XXX-XXXX.. | ens3-dhcp
now:
CONNECTIONS:/org/freedesktop/NetworkManager/Settings/{1}:5059XXX-XXXX.. | ens3-dhcp
When only the main header should be printed and output mode
is 'pretty' skip the construction of the string containing
field values as it will not be used.
Don't print value output in the "PRETTY" format when the --terse option
has been specified.
This should allow to feed back the output from "nmcli show" to "nmcli
modify" without changes.
It turns out that some routers return responses to DHCP6
Information-request messages that do not contain any of the options
that we insert in the "options" table. When that happened and the
info-only flag for DHCP6 was set, the assertion was triggered and
NetworkManager crashed. We remove the assertion as having empty options
is a possibility and is harmless anyway. This happened while using the
internal dhclient.