2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2019-09-25 13:13:40 +02:00
|
|
|
/*
|
2018-03-29 12:31:33 +02:00
|
|
|
* (C) Copyright 2010 - 2018 Red Hat, Inc.
|
2010-02-25 09:52:30 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef NMC_CONNECTIONS_H
|
|
|
|
|
#define NMC_CONNECTIONS_H
|
|
|
|
|
|
|
|
|
|
#include "nmcli.h"
|
|
|
|
|
|
|
|
|
|
NMCResultCode do_connections (NmCli *nmc, int argc, char **argv);
|
|
|
|
|
|
2015-03-27 13:07:43 +01:00
|
|
|
void monitor_connections (NmCli *nmc);
|
|
|
|
|
|
2016-06-22 17:35:16 +02:00
|
|
|
gboolean
|
|
|
|
|
nmc_read_connection_properties (NmCli *nmc,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
int *argc,
|
|
|
|
|
char ***argv,
|
|
|
|
|
GError **error);
|
|
|
|
|
|
2018-03-29 12:31:33 +02:00
|
|
|
NMMetaColor nmc_active_connection_state_to_color (NMActiveConnectionState state);
|
2016-06-22 17:35:16 +02:00
|
|
|
|
2018-11-09 16:45:21 +01:00
|
|
|
int nmc_active_connection_cmp (NMActiveConnection *ac_a, NMActiveConnection *ac_b);
|
|
|
|
|
|
cli: rework printing of `nmcli connection` for multiple active connections
The output of `nmcli connection show` contains also information about
whether the profile is currently active, for example the device and
the current (activation) state.
Even when a profile can be activated only once (without supporting
mutiple activations at the same time), there are moments when a
connection is activating and still deactivating on another device.
NetworkManager ensures in the case with single activations that
a profile cannot be in state "activated" multiple times. But that
doesn't mean, that one profile cannot have multiple active connection
which reference it. That was already handled wrongly before, because
`nmcli connection show` would only search the first matching
active-connection. That is, it would arbitrarily pick an active
connection in case there were multiple and only show activation
state about one.
Furthermore, we will soon also add the possibility, that a profile can be
active multiple times (at the same time). Especially then, we need to
extend the output format to show all the devices on which the profile is
currently active.
Rework printing the connection list to use nmc_print(), and fix various
issues.
- as discussed, a profile may have multiple active connections at each time.
There are only two possibilities: if a profile is active multiple
times, show a line for each activation, or otherwise, show the
information about multiple activations combined in one line, e.g. by
printing "DEVICE eth0,eth1". This patch, does the former.
We will now print a line for each active connection, to show
all the devices and activation states in multiple lines.
Yes, this may result in the same profile being printed multiple times.
That is a change in behavior, and inconvenient if you do something
like
for UUID in $(nmcli connection show | awk '{print$2}'); do ...
However, above is anyway wrong because it assumes that there are no
spaces in the connection name. The proper way to do this is like
for UUID in $(nmcli -g UUID connection show); do ...
In the latter case, whenever a user selects a subset of fields
(--fields, --get) which don't print information about active connections,
these multiple lines are combined. So, above still works as expected,
never returning duplicate UUIDs.
- if a user has no permissions to see a connection, we previously
would print "<invisible> $NAME". No longer do this but just print
the ID was it is reported by the active-connection. If the goal
of this was to prevent users from accidentally access the non-existing
connection by $NAME, then this was a bad solution, because a script
would instead try to access "<invisible> $NAME". This is now solved
better by hiding the active connection if the user selects "-g NAME".
- the --order option now sorts according to how the fields are shown.
For example, with --terse mode, it will evaluate type "802-11-wireless"
but with pretty mode it will consider "wifi". This may change the
ordering in which connections are shown. Also, for sorting the name,
we use g_utf8_collate() because it's unicode.
2018-04-25 10:00:40 +02:00
|
|
|
extern const NmcMetaGenericInfo *const metagen_con_show[];
|
2018-04-26 13:19:20 +02:00
|
|
|
extern const NmcMetaGenericInfo *const metagen_con_active_general[];
|
2018-04-26 14:41:13 +02:00
|
|
|
extern const NmcMetaGenericInfo *const metagen_con_active_vpn[];
|
cli: split tracking of meta data out of NmcOutputField
When generating output data, nmcli iterates over a list of
property-descriptors (nmc_fields_ip4_config), creates an intermediate
array (output_data) and finally prints it.
However, previously both the meta data (nmc_fields_ip4_config) and
the intermediate format use the same type NmcOutputField. This means,
certain fields are relevant to describe a property, and other fields
are output/formatting fields.
Split this up. Now, the meta data is tracked in form of an NMMetaAbstractInfo
lists. This separates the information about properties from intermediate steps
during creation of the output.
Note that currently functions like print_ip4_config() still have all the
knowledge about how to generate the output. That is wrong, instead, the
meta data (NMMetaAbstractInfo) should describe how to create the output
and then all those functions could be replaced. This means, later we want
to add more knowledge to the NMMetaAbstractInfo, so it is important to
keep them separate from NmcOutputField.
2017-03-31 19:18:16 +02:00
|
|
|
extern const NmcMetaGenericInfo *const nmc_fields_con_active_details_groups[];
|
2016-07-27 16:24:30 +02:00
|
|
|
|
2010-02-25 09:52:30 -08:00
|
|
|
#endif /* NMC_CONNECTIONS_H */
|