Commit Graph

206 Commits

Author SHA1 Message Date
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
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
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
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
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
Beniamino Galvani
b2146a43e5 cli: fix setting of private key password
We can't pass the password obtained from
nm_setting_802_1x_get_*private_key_password() to
nm_setting_802_1x_set_*private_key() as the latter also frees the old
password.

Fixes: afd2811028
2017-02-13 15:50:21 +01:00
Jiří Klimeš
e29add5f81 cli: move code around to group related functions - no functional change
* all getter/setter/describe, ... functions grouped according to properties
* sort the settings groups alphabetically

(cherry picked from commit 418733f2c1)
2017-01-21 19:56:40 +01:00
Jiří Klimeš
1298a998a1 cli: simplify property functions for allowed values with a macro
DEFINE_ALLOWED_FOR_ENUMS

(cherry picked from commit 5f90f48467)
2017-01-21 19:56:35 +01:00
Jiří Klimeš
49702826b7 cli: TAB-completion for macsec.mode in interactive editor
(cherry picked from commit 6573c2d860)
2017-01-21 19:56:29 +01:00
Jiří Klimeš
344e48da75 cli: TAB-completion for ipv6.addr-gen-mode in interactive editor
(cherry picked from commit 4d8800c876)
2017-01-21 19:56:23 +01:00
Jiří Klimeš
6397ce1fac cli: enable TAB-completion for proxy properties in interactive editor 2017-01-17 14:27:31 +01:00
Beniamino Galvani
d197c0626a cli: macsec support 2017-01-16 17:47:10 +01:00
Lubomir Rintel
b4a31174ea cli: add support for pkcs11: URI scheme on relevant properties 2017-01-06 15:56:11 +01:00
Lubomir Rintel
d5a1a09567 cli: support printing the pkcs11: URI scheme 2017-01-06 15:56:11 +01:00
Lubomir Rintel
afd2811028 cli: do not require a password when setting a PK
It results in a rather confusing behavior:

  # nmcli c modify wifi \
     802-1x.private-key /etc/pki/themostsecret.key \
     802-1x.private-key-password verystrong
  Error: failed to modify 802-1x.private-key: private key
  password not provided.

Moreover, the user might have a good reason for not specifying it on a command
liue and it's not strictly required anyway -- we'll do fine if we don't verify
a private key at addition time.
2017-01-06 15:14:46 +01:00
Lubomir Rintel
260563a7d9 all: use nm_utils_is_valid_iface_name() 2017-01-06 15:11:56 +01:00
Jiří Klimeš
f9648e39dd cli: enable TAB-completion for connection.lldp in interactive editor 2016-12-15 15:05:55 +01:00
Jiří Klimeš
8008770192 cli: enable TAB-completion for connection.metered in interactive editor 2016-12-15 15:05:55 +01:00
Francesco Giudici
16fdef33dd nmcli: add get functions for 802-3.speed and 802-3.duplex properties 2016-11-22 15:24:47 +01:00
Francesco Giudici
e196137f3a nmcli: enable set on 802-3 properties 2016-11-22 15:24:47 +01:00
Thomas Haller
104546cc21 cli: always include "settings-docs.c"
We now require settings-docs.c to be present. Either, configure
with --enable-gtk-doc to have it build, or use the pre-generated file
from the source tarball.
2016-11-21 20:20:14 +01:00
Lubomir Rintel
6499bb893f cli: get rid of client-global connections list
Caching it in the NmCli object is unnecessary, ugly and would be cumbersome in
future when we'll be creating the client object only when needed.
2016-11-11 16:18:03 +01:00
Beniamino Galvani
2a93d44a7a cli: support the autoconnect-retries property 2016-10-16 12:56:09 +02:00
Thomas Haller
29b576bd70 proxy: cleanup handling of proxy-method
The numeric value of NM_SETTING_PROXY_METHOD_NONE should be zero,
as that is the more natural default.

Also, cast all uses of the enum values in g_object_set() to
(int).
2016-10-05 14:46:18 +02:00
Atul Anand
20098591d9 proxy: change semantics of pac-script
libnm-core: pac-script property in NMSettingProxy now represents the
script itself not the location. It ensures that the connection is
self contained.

nmcli: Supports loading of PAC Script via file path or written explicitly.
2016-10-04 11:44:44 +02:00
Atul Anand
812b8774f6 proxy: remove unnecessary APIs
Unnecessary APIs have been removed from nm-setting-proxy, client like
nm-connection-editor are expected to create a PAC script snippet the load
the location of file in NM.
2016-10-04 11:44:44 +02:00
Atul Anand
2cb75e08d6 nmcli: Add Proxy support to nmcli
nmcli fixed to allow users edit proxy properties.
2016-10-04 11:44:44 +02:00
Lubomir Rintel
afab2b8112 cli: only connect handlers for property changes in interactive edit
Fixes: c5324ed285
(cherry picked from commit 79c81bbb8c)
2016-08-24 17:27:55 +02:00
Lubomir Rintel
2895261c91 cli/connections: do connection completion in get_connection()
Start completing by the id if the filter type is not specified
2016-08-01 13:52:36 +02:00
Thomas Haller
96cabbcbb8 all: make MAC address randomization algorithm configurable
For the per-connection settings "ethernet.cloned-mac-address"
and "wifi.cloned-mac-address", and for the per-device setting
"wifi.scan-rand-mac-address", we may generate MAC addresses using
either the "random" or "stable" algorithm.

Add new properties "generate-mac-address-mask" that allow to configure
which bits of the MAC address will be scrambled.

By default, the "random" and "stable" algorithms scamble all bits
of the MAC address, including the OUI part and generate a locally-
administered, unicast address.

By specifying a MAC address mask, we can now configure to perserve
parts of the current MAC address of the device. For example, setting
"FF:FF:FF:00:00:00" will preserve the first 3 octects of the current
MAC address.

One can also explicitly specify a MAC address to use instead of the
current MAC address. For example, "FF:FF:FF:00:00:00 68:F7:28:00:00:00"
sets the OUI part of the MAC address to "68:F7:28" while scrambling
the last 3 octects.
Similarly, "02:00:00:00:00:00 00:00:00:00:00:00" will scamble
all bits of the MAC address, except clearing the second-least
significant bit. Thus, creating a burned-in address, globally
administered.

One can also supply a list of MAC addresses like
"FF:FF:FF:00:00:00 68:F7:28:00:00:00 00:0C:29:00:00:00 ..." in which
case a MAC address is choosen randomly.

To fully scamble the MAC address one can configure
"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00".
which also randomly creates either a locally or globally administered
address.

With this, the following macchanger options can be implemented:

  `macchanger --random`
   This is the default if no mask is configured.
   -> ""
   while is the same as:
   -> "00:00:00:00:00:00"
   -> "02:00:00:00:00:00 02:00:00:00:00:00"

  `macchanger --random --bia`
   -> "02:00:00:00:00:00 00:00:00:00:00:00"

  `macchanger --ending`
   This option cannot be fully implemented, because macchanger
   uses the current MAC address but also implies --bia.
   -> "FF:FF:FF:00:00:00"
      This would yields the same result only if the current MAC address
      is already a burned-in address too. Otherwise, it has not the same
      effect as --ending.
   -> "FF:FF:FF:00:00:00 <MAC_ADDR>"
      Alternatively, instead of using the current MAC address,
      spell the OUI part out. But again, that is not really the
      same as macchanger does because you explictly have to name
      the OUI part to use.

  `machanger --another`
  `machanger --another_any`
  -> "FF:FF:FF:00:00:00 <MAC_ADDR> <MAC_ADDR> ..."
     "$(printf "FF:FF:FF:00:00:00 %s\n" "$(sed -n 's/^\([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) .*/\1:\2:\3:00:00:00/p' /usr/share/macchanger/wireless.list | xargs)")"
2016-06-30 08:32:50 +02:00