Commit Graph

692 Commits

Author SHA1 Message Date
Thomas Haller
09d127b473 cli: add property-info for NMSettingPppoe 2017-03-30 13:09:56 +02:00
Thomas Haller
a89e9a0a6f cli: add property-info for NMSettingDcb 2017-03-30 13:09:56 +02:00
Thomas Haller
89b5685695 cli: add property-info for NMSettingProxy 2017-03-30 13:09:56 +02:00
Thomas Haller
b9029a798e cli: add NmcPropertyType structure
We shall not only have a PropertyInfo. Most properties share common
behavior, that is, they have a type. Move the function pointers to
a NmcPropertyType structure, so that it can be reused for multiple
properties.

This promotes the idea that properties have a (limited) set of types
with some type specific behaviors. Contrary, to having each property
re-implement fully it's type. E.g. instead of having various property
re-define their full behavior as an "bool", have one property type
"bool" which can be attached to a property.
2017-03-30 13:09:56 +02:00
Thomas Haller
40f47dbb06 cli: add property-info for NMSettingIP4Config and NMSettingIP6Config 2017-03-30 13:09:56 +02:00
Thomas Haller
c023edc3bb cli: remove GLUE macros that hide names
It's useful to see the entire name not having a macro construct it.
Otherwise, the usage is not grepable.
2017-03-30 13:09:55 +02:00
Thomas Haller
f7937c8f4a cli: generate all-properties list from NmcSettingInfo
It's redundant information that requires us to declare it
in the static meta data. Generate it instead as needed.
2017-03-30 13:09:55 +02:00
Thomas Haller
cb66cf96d7 cli: add values_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
10119aa3a3 cli: add remove_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
850d652cdb cli: add remove_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
2de82f11c9 cli: add set_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
8b96cee124 cli: implement property getter for "connection" setting via nmc_setting_info 2017-03-30 13:09:55 +02:00
Thomas Haller
4e91492b76 cli: rework property handling via NmcPropertyInfo for NMSettingConnection
Add an improved way of tracking meta data about settings.

E.g. it is wrong to generate for each property a nmc_property_*_get_*()
function. Instead, there should be a meta data about the property
itself, and a mechanism to retrieve the property.

For now, only do this for NMSettingConnection and keep all the existing
infrastructure in place. Later on all settings shall be moved.

Especially to accomodate NmcOutputField mangles the concept of
setting-meta data, formatting options, and collecting output results.
It's a total hack, that will be need fixing later.
2017-03-30 13:09:55 +02:00
Thomas Haller
d3ad7920de cli: add setting-info structure to settings.c
Will get more use soon.
2017-03-30 13:09:55 +02:00
Thomas Haller
2b0c00a3e3 Revert "nmcli: output property values in "parsable" mode when the "--terse" option is specified"
This will be solved differently by th/setting-user-data-bgo776276
branch. Revert the change for now, the same functionality will be
restored later.

This reverts commit 623d888801.
2017-03-30 13:09:55 +02:00
Francesco Giudici
ef0d0d08eb nmcli: fix nmcli parsing
Fixes the parsing for correct and incorrect commands.
e.g.:
nmcli connection down id <conn>
nmcli -t
...

Fixes: 16902a2be6
2017-03-29 13:02:39 +02:00
Francesco Giudici
0e73a06646 nmcli: fix nmcli connection edit
fix extra parameters check in nmc_parse_args()
e.g.: nmcli connection edit type ethernet

Fixes: 16902a2be6
2017-03-29 11:34:13 +02:00
Lubomir Rintel
cd2a5c5800 cli/connections: drop the redundant parsing of --show-secrets
This is no longer needed now that --show-secrets is a global option.
2017-03-28 15:32:06 +02:00
Lubomir Rintel
f909ef421b cli: check for global options before each agument
Turn --ask and --show-secrets into global options. This is for user
comfort, see: rh #1351263.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
5a71bc8022 cli: add NmCli argument to next_arg()
Will be useful in next commit.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
16902a2be6 cli: use next_arg() on argument boundary
Shift argc and argc manually between argument ant its value and use
next_arg() between arguments everywhere. Whill be useful to parse global
arguments.
2017-03-28 15:32:05 +02:00
Thomas Haller
618dd28950 cli: fix completion of setting names for --fields (2) 2017-03-28 13:42:40 +02:00
Francesco Giudici
8bfb9989cd nmcli: fix colorize_string() signature in order to return static char *
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()
2017-03-28 10:55:00 +02:00
Francesco Giudici
f4d0417c8d nmcli: add -g[et-values] option as a '-m tab -t -f <arg>' shortcut
Quick and easy way to get clean and parsable field values.
2017-03-28 10:55:00 +02:00
Francesco Giudici
a62b72272f nmcli: fix missing CONNECTIONS section name from nmcli -f all -m tab dev show <dev>
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
2017-03-28 10:55:00 +02:00
Francesco Giudici
7d96f1f17d nmcli: don't enforce anymore the -f(ields) option in -t(erse) mode 2017-03-28 10:55:00 +02:00
Francesco Giudici
4fa2e1422d nmcli: (trivial) add comment 2017-03-28 10:55:00 +02:00
Francesco Giudici
7b589a0aef nmcli: refactor print_required_fields
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.
2017-03-28 10:55:00 +02:00
Francesco Giudici
cf39ef52da nmcli: remove redundant check 2017-03-28 10:55:00 +02:00
Francesco Giudici
6520cf1171 nmcli: always print "--" for empty or unset values in normal/pretty output
This was already true for tabular ouput mode.
Align to this behavior when printing in multiline mode.
2017-03-28 10:55:00 +02:00
Francesco Giudici
39f1d44ec8 nmcli: output just the raw value of vlan.flags when in terse mode 2017-03-28 10:55:00 +02:00
Francesco Giudici
3e3d36450c nmcli: don't substitute empty strings with "--" in terse mode 2017-03-28 10:55:00 +02:00
Francesco Giudici
623d888801 nmcli: output property values in "parsable" mode when the "--terse" option is specified
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.
2017-03-28 10:55:00 +02:00
Thomas Haller
6e1616ba69 cli: fix completion of setting names for --fields 2017-03-26 19:48:29 +02:00
Lubomir Rintel
57a26fd2aa cli/connections: decide about activation success and failure in single place
Track both device and active connections at the same time and decide
whether activation finished (either successfully or not) in a single
place, check_activated().

This makes the already too complex code path a bit more straightforward
and also makes it possible to be more reasonable about the diagnostics.

Now that the active connection signals the reason, we include it; but if
the failure is due to the device disconnection while we're activating,
include a device reason instead, since it's often more useful. Like:

Before:
  Error: Connection activation failed.

Without considering the device:
  Error: Connection activation failed: the base network connection was interrupted

After:
  Error: Connection activation failed: The Wi-Fi network could not be found
2017-03-17 10:21:19 +01:00
Lubomir Rintel
81cd300108 cli/general: avoid chopping off the last letter of master device name
...when "nmcli" is called without argument and the master device is the last
entry printed.
2017-03-16 17:11:58 +01:00
Thomas Haller
22b7282d84 all: use "unsigned" instead of "unsigned int" 2017-03-14 11:26:29 +01:00
Thomas Haller
831286df30 include: use double-quotes to include our own headers
In practice, this should only matter when there are multiple
header files with the same name. That is something we try
to avoid already, by giving headers a distinct name.

When building NetworkManager itself, we clearly want to use
double-quotes for including our own headers.
But we also want to do that in our public headers. For example:

  ./a.c
    #include <stdio.h>
    #include <nm-1.h>
    void main() {
        printf ("INCLUDED %s/nm-2.h\n", SYMB);
    }

  ./1/nm-1.h
    #include <nm-2.h>

  ./1/nm-2.h
    #define SYMB "1"

  ./2/nm-2.h
    #define SYMB "2"

$ cc -I./2 -I./1 ./a.c
$ ./a.out
INCLUDED 2/nm-2.h

Exceptions to this are
  - headers in "shared/nm-utils" that include <NetworkManager.h>. These
    headers are copied into projects and hence used like headers owned by
    those projects.
  - examples/C
2017-03-09 14:12:35 +01:00
Beniamino Galvani
d094914120 cli: support route options 2017-03-06 15:20:25 +01:00
Beniamino Galvani
4db7890fae cli: support dummy connections 2017-02-22 21:05:04 +01:00
Beniamino Galvani
9a215d332b cli: add support for 802-1x.auth-timeout property 2017-02-21 09:18:53 +01:00
Beniamino Galvani
bb72409e9f cli: support 802-1x.phase1-auth-flags 2017-02-20 14:06:14 +01:00
Beniamino Galvani
27a52989e3 cli: support the cdma.mtu property 2017-02-20 09:18:25 +01:00
Beniamino Galvani
c51232f940 cli: support the gsm.mtu property 2017-02-20 09:18:25 +01:00
Lubomir Rintel
4121e57c50 cli: add support for 802.1x certificate passwords 2017-02-17 14:24:34 +01:00
Lubomir Rintel
bc6a383dd7 cli: fix match()
Fixes: 84c484ed5b
2017-02-16 10:39:08 +01:00
Lubomir Rintel
84c484ed5b cli: make match() return boolean
Coccinelle semantic patch:

  @@
  @@
  -int
  +gboolean
          matches (...);

  @@
  expression pattern, cmd, len;
  @@
  -int
  +gboolean
          matches (...)
          {
                  ...
  -               return memcmp (pattern, cmd, len);
  +               return memcmp (pattern, cmd, len) == 0;
          }

  @@
  expression prefix, str;
  @@
  (
  -matches (prefix, str) != 0
  +!matches (prefix, str)
  |
  -matches (prefix, str) == 0
  +matches (prefix, str)
  )

  @@
  expression prefix, str;
  @@
  -(matches (prefix, str))
  +matches (prefix, str)

  @@
  expression prefix, str;
  @@
  -(!matches (prefix, str))
  +!matches (prefix, str)

spatch --smpl-spacing --sp-file match.cocci --dir clients/cli/ \
  --include-headers --macro-file shared/nm-utils/gsystem-local-alloc.h
2017-02-15 13:04:07 +01:00
Lubomir Rintel
1d40c5f476 cli: add nmcli g logging completion
This is sort of ugly, because it includes the domain and log levels
verbatim. They're just plain strings on the API, there's no way the
client would know which ones are valid.

On the other hand this kills one of two uses of nmc_parse_args(), which
probably means it's not a very good abstraction and maybe we should get
rid of it altogether. It is in particular unfriendly to argument
completion.
2017-02-15 11:16:19 +01:00
Lubomir Rintel
8bd7bbba02 cli: add completion for "nmcli c edit" 2017-02-15 11:16:19 +01:00
Lubomir Rintel
29bb6ae4fe cli: complete the [-][-]help arguments 2017-02-15 11:16:19 +01:00