Commit Graph

222 Commits

Author SHA1 Message Date
Jiří Klimeš
e8ee5bdb0b cli: 'dev wifi list': change default displayed columns
Now they are
 #define NMC_FIELDS_DEV_WIFI_LIST_COMMON
         "IN-USE,SSID,MODE,CHAN,RATE,SIGNAL,BARS,SECURITY"
2013-05-31 09:38:04 +02:00
Jiří Klimeš
dca3584b26 cli: 'dev wifi list': change SECURITY values
* remove "Encrypted" tag
 The "Encrypted: " stuff was initially copied from nm-tool, but it doesn't help
 here much. See also http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=a734c836a56f3170202f0555f1a03c9b2835775c
 for APs with WPA & RSN IEs, but no privacy flag.

* remove a space from "WPA ", etc. strings. Translators often leave it out
  and thus break output.

* change "WPA" to "WPA1" to make it clearer

* use "802.1X" instead of "Enterprise" to save some characters
2013-05-31 09:38:04 +02:00
Jiří Klimeš
5f93c4314d cli: 'dev wifi list': add IN-USE (*) field 2013-05-31 09:38:04 +02:00
Jiří Klimeš
e949365db4 cli: 'dev wifi list': 'Infrastructure' -> 'Infra', 'Unknown' -> 'N/A' in MODE 2013-05-31 09:38:03 +02:00
Jiří Klimeš
e339a259b1 cli: 'dev wifi list': add BARS column displaying signal semi-graphically
using unicode characters:
'_'   '▂'     '▄'     '▆'     '█'
0x5f  0x2582  0x2584  0x2586  0x2588
2013-05-31 09:38:03 +02:00
Jiří Klimeš
ac4c3f395d cli: 'dev wifi list': add CHAN column 2013-05-31 09:38:03 +02:00
Jiří Klimeš
28704d1f42 cli: 'dev wifi list' use nm_utils_ssid_to_utf8() to display SSID; add SSID-HEX
This commit removes enclosing '' from SSID.
SSID-HEX is printed as a string of hex characters (each 2 chars represent one
byte).
2013-05-31 09:38:03 +02:00
Jiří Klimeš
66098fa607 cli: trivial update of NmcOutputField initializers
no actual change
2013-05-31 09:38:03 +02:00
Jiří Klimeš
1d1cfd77d3 cli: adapt the code for the new flags and printing facilities
The data are added to output_data at first, and then they are printed all at
once using print_data(), that takes care of proper alignment and display.

The static 'width' values defined in NmcOutputField columns are not used now,
but dynamically computed maximal widths override them.
2013-05-31 09:38:03 +02:00
Jiří Klimeš
7fe4345d0d cli: print_required_fields() - fix non-ASCII strings alignment in multiline 2013-05-31 09:38:03 +02:00
Jiří Klimeš
e6870789b5 cli: enhance printing to align tabular output properly and not to waste space
Until now we have used a static width defined for each column for tabular
output. Even if this worked in most cases, it was not optimal, because by
using too wide columns we wasted space, and in case of a too narrow column the
alignment broke. So, we need to know the longest string in a column to be able
to align columns in the tabular output. Thus, the printing has to be postponed
till we have all data available, and can find the widest column. This value is
then used for aligning while printing the data.

Arrays of NmcOutputField (rows) are inserted into output_data array. When all
data have been added, print_data() can be used to print the whole output_data
array with proper alignment.

A single row can be printed using print_required_fields().

Also, output flags are redone to better match the new output_data array.
The flags are needed for every row (in tabular output); they are stored in
the first field (NmcOutputField) for the whole row.

Addapted set_val_str() and set_val_arr() to set value type (char * x char **).
Added set_val_strc(), set_val_arrc() for const values that should not be freed.

output_data takes ownership of the data added to it and takes care of freeing
the memory.

See e.g.
https://bugzilla.gnome.org/show_bug.cgi?id=699503
2013-05-31 09:38:03 +02:00
Jiří Klimeš
0376f0be16 cli: make prompts asking for user input translatable in 'nmcli device' 2013-05-16 14:03:49 +02:00
Jiří Klimeš
d0b74b7d8d cli: 'connection add': allow numeric bonding modes 2013-05-16 10:44:17 +02:00
Jiří Klimeš
2b843dac50 cli: change '--private' to 'private yes|no' in 'nmcli dev wifi connect'
Missing 'private' argument default to private=no, the same way as before.
2013-05-16 10:28:40 +02:00
Jiří Klimeš
fa6ecaed32 cli: remove '--nowait' and '--timeout' options and use global '--wait' instead
'--wait 0' corresponds to '--nowait'
'--wait n' for n > 0 corresponds to '--timeout n'
2013-05-16 10:28:40 +02:00
Jiří Klimeš
7d55426992 cli: add global '--wait <seconds>' option - timeout waiting for operations
--wait <0-maxint>

0    : means "do not wait". nmcli exits immediatelly with success.
1... : if operation doesn't finish within the timeout, nmcli exits with an error
2013-05-16 10:28:40 +02:00
Jiří Klimeš
a453563bee cli: remove RUNNING field from default 'common' fields
That way it is not displayed by default:
$ nmcli general status

But can be explicitly requested:
$ nmcli -t -f running,version general status
$ nmcli -f all general status

E.g. Fedora initscripts do this in
/etc/sysconfig/network-scripts/network-functions

is_nm_running ()
{
    [ "$(LANG=C nmcli -t --fields running nm status 2>/dev/null)" = "running" ]
}
2013-05-10 12:28:01 +02:00
Jiří Klimeš
24f05292da cli: update bash-completion file for 'connection add'
* _nmcli_list vs. _nmcli_list_nl - space vs. new-line separated list
* connection add
  - various types, modes, mac, ifname, ...
2013-05-07 19:41:37 +02:00
Jiří Klimeš
6c2e7706af cli: 'connection add': accept multiple IP addresses 2013-05-07 19:41:37 +02:00
Jiří Klimeš
3901281077 cli: 'connection add' command for adding NM connections non-interactively
A few examples:
nmcli --ask connection add
nmcli connection add type ethernet
nmcli -p connection add type ethernet con-name "my ethernet connection 1"
nmcli connection add type ethernet ip4 192.168.100.5/24
nmcli connection add type ethernet ip4 192.168.100.100/24 gw4 192.168.100.1 ip4 1.2.3.4 ip6 abbe::cafe
nmcli connection add type ethernet ifname eth0
nmcli connection add type ethernet autoconnect no ifname eth0
nmcli connection add type wifi con-name Rakosnicek ssid Brcalnik
nmcli --ask connection add type wifi con-name My_WiFi
nmcli c a type infiniband con-name Infi1 transport-mode connected
nmcli c a type bluetooth addr 12:54:00:fd:db:26
nmcli c a type bluetooth addr 12:54:00:fd:db:26 bt-type dun-cdma
nmcli c a type gsm apn internet
nmcli c a type cdma
nmcli c a type bond
nmcli c a type bond ifname mybond0 mode active-backup
nmcli c a ifname maxipes-fik type vlan dev eth0 id 55
nmcli c a con-name VLAN1 type vlan dev eth0 id 44 ingress "2:4,3:55" egress "1:3" flags 6
nmcli c a type bridge ifname br0 stp on ip4 10.0.0.25
nmcli c a ifname eth0 type bridge-slave master 30fc816a-e7dd-4ae7-a86e-ab0c9cee51c2 hairpin no path-cost 333 priority 20
nmcli c a type bridge-slave master br2
2013-05-07 19:41:36 +02:00
Jiří Klimeš
5761a46da0 cli: add functions for creating NM address and route structures to common.c
nmc_parse_and_build_ip[4|6]_address() creating NMIP[4|6]Address
nmc_parse_and_build_ip[4|6]_route() creating NMIP[4|6]Route
2013-05-07 19:41:36 +02:00
Jiří Klimeš
04d590a923 cli: nmc_string_to_bool() - util function for converting string to boolean
["true", "yes", "on"] -> TRUE
["false", "no", "off"] -> FALSE
2013-05-07 19:41:36 +02:00
Jiří Klimeš
ddd3ea2cd4 cli: util functions for converting string to int
nmc_string_to_int()  - converts string to signed long int (decimal)
nmc_string_to_uint() - converts string to unsigned long int (decimal)
nmc_string_to_int_base()  - converts string to signed long int with given base
nmc_string_to_uint_base() - converts string to unsigned long int with given base
2013-05-07 19:41:36 +02:00
Jiří Klimeš
8598ee1139 cli: nmc_string_is_valid() utility function
This function checks whether a string is contained among allowed strings. It
performs case-insensitive comparison and supports shortcuts if they are unique.
It returns a pointer to the found string in allowed array, or NULL.
2013-05-07 19:41:36 +02:00
Dan Winship
440223fa3c cli: sort the output of "nmcli dev"
Sort the output of "nmcli dev", first by state (with connected devices
first and unmanaged ones last), then by type and interface name.
2013-05-07 12:46:56 -04:00
Dan Winship
ae9a389f83 libnm-glib, cli: add nm_device_get_type_description
Add a new libnm-glib method to get the type description for a device,
and use it in nmcli. For most types, the type description is based on
the class name, but for NMDeviceGeneric, it comes from the
:type-description property.
2013-05-07 12:46:56 -04:00
Dan Winship
ab7ebead2c core: add IP configuration for unmanaged devices
Use NMPlatform to read the IP address/route configuration of unmanaged
devices, and export that via D-Bus like we do with NM-generated IP
configs.
2013-05-07 12:46:55 -04:00
Jiří Klimeš
4d048cc2d8 cli: fix displaying unknown flags/bands 2013-05-06 14:00:10 +02:00
Dan Williams
e09550ec62 cli: clarify generic getter alloc/free behavior 2013-05-03 10:31:50 -05:00
Jiří Klimeš
47710f8211 cli: 'con up' - give bond/bridge slaves 10s to appear while activating master
If there are no slaves after the timeout, exit nmcli with an error, assuming
that NM is waiting for slaves to finish activation:
"(bondx) "IPv4 config waiting until slaves are ready"
"(bondx) "IPv6 config waiting until slaves are ready"
2013-04-30 09:28:13 +02:00
Jiří Klimeš
8215fd92fc cli: rename 'nmcli dev wifi scan' to 'nmcli dev wifi rescan' (bgo #698241) 2013-04-24 10:22:57 +02:00
Jiří Klimeš
3560024de9 cli: remove obsolete 'nmcli nm'
The functionality is present in 'general', 'networking' and 'radio'.
We changed syntax anyway, so it doesn't make much sense to keep 'nm'.
2013-04-24 10:04:43 +02:00
Jiří Klimeš
3bf97fafe7 cli: rename 'iface' --> 'ifname' in all commands 2013-04-24 10:04:37 +02:00
Jiří Klimeš
5f523d8f4d cli: accept shortcuts for --mode and --escape arguments
--mode tabular | multiline  -->  --mode t | m
--escape yes | no           -->  --escape y | n
2013-04-24 10:04:33 +02:00
Jiří Klimeš
d3ea9ee472 cli: handle NULL gracefully in nmc_arg_is_help() 2013-04-18 12:42:54 +02:00
Jiří Klimeš
7d5df73d76 cli: add nmc_arg_is_help() and use it to save some code lines 2013-04-18 11:25:49 +02:00
Pavel Šimerda
b292af8e1d trivial: avoid -Wshadow
jklimes: read vs. read(3), use 'num' instead
2013-04-15 13:43:34 +02:00
Jiří Klimeš
654a79ba88 cli: update bash completion file for the new syntax 2013-04-09 10:31:13 +02:00
Jiří Klimeš
c84315fd12 cli: 'connection delete' - do not stop on invalid connection arguments
Rather report it and continue with the next one. This is the behaviour
e.g. 'rm' command uses.
2013-04-08 16:14:56 -05:00
Jiří Klimeš
7dddead250 trivial: format nmcli usage help 2013-04-08 16:14:11 -05:00
Jiří Klimeš
15398f6fc3 trivial: fix some comments and error messages in devices.c 2013-04-08 16:14:11 -05:00
Jiří Klimeš
9ebe727d83 cli: add 'nmcli general logging'
nmcli general logging [level <log level>] [domains <log domains>]

Examples:
nmcli general logging    - print current level and domains values
nmcli general logging level ERR  - change logging level to ERR
nmcli general logging level DEBUG domains DNS  - change logging level to DEBUG and domains to DNS
nmcli g l domains DEFAULT  - set default log domains (the ones active when NM)
2013-04-08 16:14:11 -05:00
Jiří Klimeš
e2d8ca7924 cli: util function to parse command-line arguments
nmc_parse_args() - parse command-line arguments
2013-04-08 16:14:11 -05:00
Jiří Klimeš
9ddd7bc2dc cli: split 'nmcli switch' --> 'nmcli networking' and 'nmcli radio' 2013-04-08 16:14:11 -05:00
Jiří Klimeš
7e7335471c cli: rename HARDWARE -> HW in status/switch fields 2013-04-08 16:14:11 -05:00
Jiří Klimeš
2bafd7a707 cli: split 'general' into 'nmcli switch' and 'nmcli general' commands
They basically contain operations previously available via 'nmcli nm'.
'nmcli nm' is still kept for backward compatibility.

Usage:
nmcli switch  [all|networking|wifi|wwan|wimax [on/off]]
nmcli general [status|permissions]

Examples:
nmcli switch all         - show all switches
nmcli switch wifi off    - switch Wi-Fi off

nmcli g s    - show NM status
nmcli g p    - show NM permissions
2013-04-08 16:14:10 -05:00
Jiří Klimeš
7a8d654691 cli: rename 'device list' -> 'device show' and remove 'iface' keyword
Examples:
nmcli device show         - shows details for all available devices
nmcli device show eth0    - shows details for eth0
nmcli device show em1.25  - shows details for em1.25 VLAN device
2013-04-08 16:12:34 -05:00
Jiří Klimeš
51f055f74c cli: remove iface keyword for 'nmcli device disconnect'
'nmcli disconnect' allows specifying only one interface at a time.
2013-04-08 16:12:34 -05:00
Jiří Klimeš
60f54cd65d cli: 'device disconnect' - ask for interface when missing and '--ask' is present 2013-04-08 16:12:34 -05:00
Jiří Klimeš
0db4b4db90 cli: 'device wifi connect' - ask for SSID/BSSID and password if not provided
when '--ask' parameter is specified
2013-04-08 16:12:34 -05:00