summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/Makefile.in48
-rw-r--r--cli/src/Makefile.in50
-rw-r--r--cli/src/connections.c667
-rw-r--r--cli/src/devices.c506
-rw-r--r--cli/src/network-manager.c157
-rw-r--r--cli/src/nmcli.c15
-rw-r--r--cli/src/nmcli.h14
-rw-r--r--cli/src/settings.c55
-rw-r--r--cli/src/settings.h2
-rw-r--r--cli/src/utils.c49
-rw-r--r--cli/src/utils.h1
11 files changed, 475 insertions, 1089 deletions
diff --git a/cli/Makefile.in b/cli/Makefile.in
index a8d972d47..06dee842a 100644
--- a/cli/Makefile.in
+++ b/cli/Makefile.in
@@ -37,16 +37,11 @@ subdir = cli
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \
- $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
- $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/introspection.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnl-check.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/intltool.m4 \
+ $(top_srcdir)/m4/libnl-check.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -103,6 +98,7 @@ am__relativize = \
done; \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
ALL_LINGUAS = @ALL_LINGUAS@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
@@ -111,6 +107,8 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
@@ -127,7 +125,6 @@ DHCLIENT_PATH = @DHCLIENT_PATH@
DHCLIENT_VERSION = @DHCLIENT_VERSION@
DHCPCD_PATH = @DHCPCD_PATH@
DISABLE_DEPRECATED = @DISABLE_DEPRECATED@
-DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -136,7 +133,6 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
-GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
GIO_CFLAGS = @GIO_CFLAGS@
GIO_LIBS = @GIO_LIBS@
@@ -145,8 +141,8 @@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GMODULE_CFLAGS = @GMODULE_CFLAGS@
GMODULE_LIBS = @GMODULE_LIBS@
+GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
-GMSGFMT_015 = @GMSGFMT_015@
GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
GNUTLS_LIBS = @GNUTLS_LIBS@
GREP = @GREP@
@@ -161,23 +157,13 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
INTLLIBS = @INTLLIBS@
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
INTLTOOL_MERGE = @INTLTOOL_MERGE@
INTLTOOL_PERL = @INTLTOOL_PERL@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
-INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
-INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@
-INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@
-INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@
-INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@
-INTROSPECTION_LIBS = @INTROSPECTION_LIBS@
-INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
-INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
-INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
IPTABLES_PATH = @IPTABLES_PATH@
-IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@
-IWMX_SDK_LIBS = @IWMX_SDK_LIBS@
KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
LD = @LD@
LDFLAGS = @LDFLAGS@
@@ -185,8 +171,6 @@ LIBDL = @LIBDL@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
-LIBICONV = @LIBICONV@
-LIBINTL = @LIBINTL@
LIBM = @LIBM@
LIBNL_CFLAGS = @LIBNL_CFLAGS@
LIBNL_LIBS = @LIBNL_LIBS@
@@ -195,15 +179,13 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
-LTLIBICONV = @LTLIBICONV@
-LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
-MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
-MSGFMT_015 = @MSGFMT_015@
+MSGFMT_OPTS = @MSGFMT_OPTS@
MSGMERGE = @MSGMERGE@
NM = @NM@
NMEDIT = @NMEDIT@
@@ -229,9 +211,12 @@ PKGCONFIG_PATH = @PKGCONFIG_PATH@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POFILES = @POFILES@
POLKIT_CFLAGS = @POLKIT_CFLAGS@
POLKIT_LIBS = @POLKIT_LIBS@
POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@
RANLIB = @RANLIB@
RESOLVCONF_PATH = @RESOLVCONF_PATH@
@@ -246,13 +231,10 @@ UUID_CFLAGS = @UUID_CFLAGS@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
-XGETTEXT_015 = @XGETTEXT_015@
-XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
-ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
diff --git a/cli/src/Makefile.in b/cli/src/Makefile.in
index f5a9e00bf..51ec648a0 100644
--- a/cli/src/Makefile.in
+++ b/cli/src/Makefile.in
@@ -39,16 +39,11 @@ subdir = cli/src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/compiler_warnings.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/gtk-doc.m4 \
- $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
- $(top_srcdir)/m4/intltool.m4 $(top_srcdir)/m4/introspection.m4 \
- $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
- $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libnl-check.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/intltool.m4 \
+ $(top_srcdir)/m4/libnl-check.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -70,7 +65,7 @@ AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -101,6 +96,7 @@ ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
ALL_LINGUAS = @ALL_LINGUAS@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
@@ -109,6 +105,8 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
@@ -125,7 +123,6 @@ DHCLIENT_PATH = @DHCLIENT_PATH@
DHCLIENT_VERSION = @DHCLIENT_VERSION@
DHCPCD_PATH = @DHCPCD_PATH@
DISABLE_DEPRECATED = @DISABLE_DEPRECATED@
-DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -134,7 +131,6 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
-GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
GIO_CFLAGS = @GIO_CFLAGS@
GIO_LIBS = @GIO_LIBS@
@@ -143,8 +139,8 @@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GMODULE_CFLAGS = @GMODULE_CFLAGS@
GMODULE_LIBS = @GMODULE_LIBS@
+GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
-GMSGFMT_015 = @GMSGFMT_015@
GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
GNUTLS_LIBS = @GNUTLS_LIBS@
GREP = @GREP@
@@ -159,23 +155,13 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INSTOBJEXT = @INSTOBJEXT@
INTLLIBS = @INTLLIBS@
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
INTLTOOL_MERGE = @INTLTOOL_MERGE@
INTLTOOL_PERL = @INTLTOOL_PERL@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
-INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
-INTROSPECTION_CFLAGS = @INTROSPECTION_CFLAGS@
-INTROSPECTION_COMPILER = @INTROSPECTION_COMPILER@
-INTROSPECTION_GENERATE = @INTROSPECTION_GENERATE@
-INTROSPECTION_GIRDIR = @INTROSPECTION_GIRDIR@
-INTROSPECTION_LIBS = @INTROSPECTION_LIBS@
-INTROSPECTION_MAKEFILE = @INTROSPECTION_MAKEFILE@
-INTROSPECTION_SCANNER = @INTROSPECTION_SCANNER@
-INTROSPECTION_TYPELIBDIR = @INTROSPECTION_TYPELIBDIR@
IPTABLES_PATH = @IPTABLES_PATH@
-IWMX_SDK_CFLAGS = @IWMX_SDK_CFLAGS@
-IWMX_SDK_LIBS = @IWMX_SDK_LIBS@
KERNEL_FIRMWARE_DIR = @KERNEL_FIRMWARE_DIR@
LD = @LD@
LDFLAGS = @LDFLAGS@
@@ -183,8 +169,6 @@ LIBDL = @LIBDL@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
-LIBICONV = @LIBICONV@
-LIBINTL = @LIBINTL@
LIBM = @LIBM@
LIBNL_CFLAGS = @LIBNL_CFLAGS@
LIBNL_LIBS = @LIBNL_LIBS@
@@ -193,15 +177,13 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
-LTLIBICONV = @LTLIBICONV@
-LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
-MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
+MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
-MSGFMT_015 = @MSGFMT_015@
+MSGFMT_OPTS = @MSGFMT_OPTS@
MSGMERGE = @MSGMERGE@
NM = @NM@
NMEDIT = @NMEDIT@
@@ -227,9 +209,12 @@ PKGCONFIG_PATH = @PKGCONFIG_PATH@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+POFILES = @POFILES@
POLKIT_CFLAGS = @POLKIT_CFLAGS@
POLKIT_LIBS = @POLKIT_LIBS@
POSUB = @POSUB@
+PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
+PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@
PPPD_PLUGIN_DIR = @PPPD_PLUGIN_DIR@
RANLIB = @RANLIB@
RESOLVCONF_PATH = @RESOLVCONF_PATH@
@@ -244,13 +229,10 @@ UUID_CFLAGS = @UUID_CFLAGS@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
-XGETTEXT_015 = @XGETTEXT_015@
-XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
-ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
diff --git a/cli/src/connections.c b/cli/src/connections.c
index 2646aa9e9..88a5df49c 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -17,8 +17,6 @@
* (C) Copyright 2010 - 2011 Red Hat, Inc.
*/
-#include "config.h"
-
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
@@ -40,18 +38,16 @@
#include <nm-setting-cdma.h>
#include <nm-setting-bluetooth.h>
#include <nm-setting-olpc-mesh.h>
-#if WITH_WIMAX
-#include <nm-setting-wimax.h>
-#endif
#include <nm-device-ethernet.h>
#include <nm-device-wifi.h>
-#if WITH_WIMAX
-#include <nm-device-wimax.h>
-#endif
-#include <nm-device-modem.h>
+#include <nm-gsm-device.h>
+#include <nm-cdma-device.h>
#include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h>
#include <nm-remote-settings.h>
+#include <nm-remote-settings-system.h>
+#include <nm-settings-interface.h>
+#include <nm-settings-connection-interface.h>
#include <nm-vpn-connection.h>
#include "utils.h"
@@ -64,29 +60,32 @@ static NmcOutputField nmc_fields_con_status[] = {
{"NAME", N_("NAME"), 25, NULL, 0}, /* 0 */
{"UUID", N_("UUID"), 38, NULL, 0}, /* 1 */
{"DEVICES", N_("DEVICES"), 10, NULL, 0}, /* 2 */
- {"DEFAULT", N_("DEFAULT"), 8, NULL, 0}, /* 3 */
- {"SPEC-OBJECT", N_("SPEC-OBJECT"), 10, NULL, 0}, /* 4 */
- {"VPN", N_("VPN"), 5, NULL, 0}, /* 5 */
- {"DBUS-PATH", N_("DBUS-PATH"), 51, NULL, 0}, /* 6 */
+ {"SCOPE", N_("SCOPE"), 8, NULL, 0}, /* 3 */
+ {"DEFAULT", N_("DEFAULT"), 8, NULL, 0}, /* 4 */
+ {"DBUS-SERVICE", N_("DBUS-SERVICE"), 45, NULL, 0}, /* 5 */
+ {"SPEC-OBJECT", N_("SPEC-OBJECT"), 10, NULL, 0}, /* 6 */
+ {"VPN", N_("VPN"), 5, NULL, 0}, /* 7 */
+ {"DBUS-PATH", N_("DBUS-PATH"), 51, NULL, 0}, /* 8 */
{NULL, NULL, 0, NULL, 0}
};
-#define NMC_FIELDS_CON_STATUS_ALL "NAME,UUID,DEVICES,DEFAULT,VPN,DBUS-PATH,SPEC-OBJECT"
-#define NMC_FIELDS_CON_STATUS_COMMON "NAME,UUID,DEVICES,DEFAULT,VPN"
+#define NMC_FIELDS_CON_STATUS_ALL "NAME,UUID,DEVICES,SCOPE,DEFAULT,VPN,DBUS-SERVICE,DBUS-PATH,SPEC-OBJECT"
+#define NMC_FIELDS_CON_STATUS_COMMON "NAME,UUID,DEVICES,SCOPE,DEFAULT,VPN"
/* Available fields for 'con list' */
static NmcOutputField nmc_fields_con_list[] = {
{"NAME", N_("NAME"), 25, NULL, 0}, /* 0 */
{"UUID", N_("UUID"), 38, NULL, 0}, /* 1 */
{"TYPE", N_("TYPE"), 17, NULL, 0}, /* 2 */
- {"TIMESTAMP", N_("TIMESTAMP"), 12, NULL, 0}, /* 3 */
- {"TIMESTAMP-REAL", N_("TIMESTAMP-REAL"), 34, NULL, 0}, /* 4 */
- {"AUTOCONNECT", N_("AUTOCONNECT"), 13, NULL, 0}, /* 5 */
- {"READONLY", N_("READONLY"), 10, NULL, 0}, /* 6 */
- {"DBUS-PATH", N_("DBUS-PATH"), 42, NULL, 0}, /* 7 */
+ {"SCOPE", N_("SCOPE"), 8, NULL, 0}, /* 3 */
+ {"TIMESTAMP", N_("TIMESTAMP"), 12, NULL, 0}, /* 4 */
+ {"TIMESTAMP-REAL", N_("TIMESTAMP-REAL"), 34, NULL, 0}, /* 5 */
+ {"AUTOCONNECT", N_("AUTOCONNECT"), 13, NULL, 0}, /* 6 */
+ {"READONLY", N_("READONLY"), 10, NULL, 0}, /* 7 */
+ {"DBUS-PATH", N_("DBUS-PATH"), 42, NULL, 0}, /* 8 */
{NULL, NULL, 0, NULL, 0}
};
-#define NMC_FIELDS_CON_LIST_ALL "NAME,UUID,TYPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,READONLY,DBUS-PATH"
-#define NMC_FIELDS_CON_LIST_COMMON "NAME,UUID,TYPE,TIMESTAMP-REAL"
+#define NMC_FIELDS_CON_LIST_ALL "NAME,UUID,TYPE,SCOPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,READONLY,DBUS-PATH"
+#define NMC_FIELDS_CON_LIST_COMMON "NAME,UUID,TYPE,SCOPE,TIMESTAMP-REAL"
/* Helper macro to define fields */
@@ -109,10 +108,9 @@ static NmcOutputField nmc_fields_settings_names[] = {
SETTING_FIELD (NM_SETTING_BLUETOOTH_SETTING_NAME, 0), /* 12 */
SETTING_FIELD (NM_SETTING_OLPC_MESH_SETTING_NAME, 0), /* 13 */
SETTING_FIELD (NM_SETTING_VPN_SETTING_NAME, 0), /* 14 */
- SETTING_FIELD (NM_SETTING_WIMAX_SETTING_NAME, 0), /* 15 */
{NULL, NULL, 0, NULL, 0}
};
-#define NMC_FIELDS_SETTINGS_NAMES_ALL_X NM_SETTING_CONNECTION_SETTING_NAME","\
+#define NMC_FIELDS_SETTINGS_NAMES_ALL NM_SETTING_CONNECTION_SETTING_NAME","\
NM_SETTING_WIRED_SETTING_NAME","\
NM_SETTING_802_1X_SETTING_NAME","\
NM_SETTING_WIRELESS_SETTING_NAME","\
@@ -127,12 +125,6 @@ static NmcOutputField nmc_fields_settings_names[] = {
NM_SETTING_BLUETOOTH_SETTING_NAME","\
NM_SETTING_OLPC_MESH_SETTING_NAME","\
NM_SETTING_VPN_SETTING_NAME
-#if WITH_WIMAX
-#define NMC_FIELDS_SETTINGS_NAMES_ALL NMC_FIELDS_SETTINGS_NAMES_ALL_X","\
- NM_SETTING_WIMAX_SETTING_NAME
-#else
-#define NMC_FIELDS_SETTINGS_NAMES_ALL NMC_FIELDS_SETTINGS_NAMES_ALL_X
-#endif
typedef struct {
@@ -151,10 +143,11 @@ static void quit (void);
static void show_connection (NMConnection *data, gpointer user_data);
static NMConnection *find_connection (GSList *list, const char *filter_type, const char *filter_val);
static gboolean find_device_for_connection (NmCli *nmc, NMConnection *connection, const char *iface, const char *ap,
- const char *nsp, NMDevice **device, const char **spec_object, GError **error);
+ NMDevice **device, const char **spec_object, GError **error);
static const char *active_connection_state_to_string (NMActiveConnectionState state);
static void active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpointer user_data);
-static void get_connections_cb (NMRemoteSettings *settings, gpointer user_data);
+static void activate_connection_cb (gpointer user_data, const char *path, GError *error);
+static void get_connections_cb (NMSettingsInterface *settings, gpointer user_data);
static NMCResultCode do_connections_list (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_connections_status (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_connection_up (NmCli *nmc, int argc, char **argv);
@@ -164,27 +157,14 @@ static void
usage (void)
{
fprintf (stderr,
- _("Usage: nmcli con { COMMAND | help }\n"
- " COMMAND := { list | status | up | down }\n\n"
- " list [id <id> | uuid <id>]\n"
- " status\n"
-#if WITH_WIMAX
- " up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [nsp <name>] [--nowait] [--timeout <timeout>]\n"
-#else
- " up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [--nowait] [--timeout <timeout>]\n"
-#endif
- " down id <id> | uuid <id>\n"));
+ _("Usage: nmcli con { COMMAND | help }\n"
+ " COMMAND := { list | status | up | down }\n\n"
+ " list [id <id> | uuid <id> | system | user]\n"
+ " status\n"
+ " up id <id> | uuid <id> [iface <iface>] [ap <hwaddr>] [--nowait] [--timeout <timeout>]\n"
+ " down id <id> | uuid <id>\n"));
}
-/* The real commands that do something - i.e. not 'help', etc. */
-static const char *real_con_commands[] = {
- "list",
- "status",
- "up",
- "down",
- NULL
-};
-
/* quit main loop */
static void
quit (void)
@@ -374,17 +354,6 @@ nmc_connection_detail (NMConnection *connection, NmCli *nmc)
continue;
}
}
-
-#if WITH_WIMAX
- if (!strcasecmp (nmc_fields_settings_names[section_idx].name, nmc_fields_settings_names[15].name)) {
- setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_WIMAX);
- if (setting) {
- setting_wimax_details (setting, nmc);
- was_output = TRUE;
- continue;
- }
- }
-#endif
}
if (print_settings_array)
@@ -403,7 +372,7 @@ show_connection (NMConnection *data, gpointer user_data)
char *timestamp_str;
char timestamp_real_str[64];
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
if (s_con) {
/* Obtain field values */
timestamp = nm_setting_connection_get_timestamp (s_con);
@@ -413,11 +382,12 @@ show_connection (NMConnection *data, gpointer user_data)
nmc->allowed_fields[0].value = nm_setting_connection_get_id (s_con);
nmc->allowed_fields[1].value = nm_setting_connection_get_uuid (s_con);
nmc->allowed_fields[2].value = nm_setting_connection_get_connection_type (s_con);
- nmc->allowed_fields[3].value = timestamp_str;
- nmc->allowed_fields[4].value = timestamp ? timestamp_real_str : _("never");
- nmc->allowed_fields[5].value = nm_setting_connection_get_autoconnect (s_con) ? _("yes") : _("no");
- nmc->allowed_fields[6].value = nm_setting_connection_get_read_only (s_con) ? _("yes") : _("no");
- nmc->allowed_fields[7].value = nm_connection_get_path (connection);
+ nmc->allowed_fields[3].value = nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM ? _("system") : _("user");
+ nmc->allowed_fields[4].value = timestamp_str;
+ nmc->allowed_fields[5].value = timestamp ? timestamp_real_str : _("never");
+ nmc->allowed_fields[6].value = nm_setting_connection_get_autoconnect (s_con) ? _("yes") : _("no");
+ nmc->allowed_fields[7].value = nm_setting_connection_get_read_only (s_con) ? _("yes") : _("no");
+ nmc->allowed_fields[8].value = nm_connection_get_path (connection);
nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
print_fields (nmc->print_fields, nmc->allowed_fields);
@@ -438,7 +408,7 @@ find_connection (GSList *list, const char *filter_type, const char *filter_val)
iterator = list;
while (iterator) {
connection = NM_CONNECTION (iterator->data);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
if (s_con) {
id = nm_setting_connection_get_id (s_con);
uuid = nm_setting_connection_get_uuid (s_con);
@@ -488,19 +458,22 @@ do_connections_list (NmCli *nmc, int argc, char **argv)
goto error;
valid_param_specified = TRUE;
- /* Print headers */
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("Connection list");
+ nmc->print_fields.header_name = _("System connections");
print_fields (nmc->print_fields, nmc->allowed_fields);
-
- /* Print values */
g_slist_foreach (nmc->system_connections, (GFunc) show_connection, nmc);
+
+ nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
+ nmc->print_fields.header_name = _("User connections");
+ print_fields (nmc->print_fields, nmc->allowed_fields);
+ g_slist_foreach (nmc->user_connections, (GFunc) show_connection, nmc);
}
else {
while (argc > 0) {
if (strcmp (*argv, "id") == 0 || strcmp (*argv, "uuid") == 0) {
const char *selector = *argv;
- NMConnection *con;
+ NMConnection *con1;
+ NMConnection *con2;
if (next_arg (&argc, &argv) != 0) {
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *argv);
@@ -511,16 +484,42 @@ do_connections_list (NmCli *nmc, int argc, char **argv)
if (!nmc->mode_specified)
nmc->multiline_output = TRUE; /* multiline mode is default for 'con list id|uuid' */
- con = find_connection (nmc->system_connections, selector, *argv);
- if (con) {
- nmc_connection_detail (con, nmc);
- }
- else {
+ con1 = find_connection (nmc->system_connections, selector, *argv);
+ con2 = find_connection (nmc->user_connections, selector, *argv);
+ if (con1) nmc_connection_detail (con1, nmc);
+ if (con2) nmc_connection_detail (con2, nmc);
+ if (!con1 && !con2) {
g_string_printf (nmc->return_text, _("Error: %s - no such connection."), *argv);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
}
break;
}
+ else if (strcmp (*argv, "system") == 0) {
+ if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error2))
+ goto error;
+ if (error1)
+ goto error;
+ valid_param_specified = TRUE;
+
+ nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
+ nmc->print_fields.header_name = _("System connections");
+ print_fields (nmc->print_fields, nmc->allowed_fields);
+ g_slist_foreach (nmc->system_connections, (GFunc) show_connection, nmc);
+ break;
+ }
+ else if (strcmp (*argv, "user") == 0) {
+ if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error2))
+ goto error;
+ if (error1)
+ goto error;
+ valid_param_specified = TRUE;
+
+ nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
+ nmc->print_fields.header_name = _("User connections");
+ print_fields (nmc->print_fields, nmc->allowed_fields);
+ g_slist_foreach (nmc->user_connections, (GFunc) show_connection, nmc);
+ break;
+ }
else {
fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
}
@@ -554,19 +553,29 @@ error:
return nmc->return_value;
}
+typedef struct {
+ NmCli *nmc;
+ NMConnectionScope scope;
+} StatusInfo;
+
static void
show_active_connection (gpointer data, gpointer user_data)
{
NMActiveConnection *active = NM_ACTIVE_CONNECTION (data);
- NmCli *nmc = (NmCli *) user_data;
+ StatusInfo *info = (StatusInfo *) user_data;
GSList *con_list, *iter;
const char *active_path;
+ NMConnectionScope active_service_scope;
NMSettingConnection *s_con;
const GPtrArray *devices;
GString *dev_str;
int i;
active_path = nm_active_connection_get_connection (active);
+ active_service_scope = nm_active_connection_get_scope (active);
+
+ if (active_service_scope != info->scope)
+ return;
/* Get devices of the active connection */
dev_str = g_string_new (NULL);
@@ -580,27 +589,29 @@ show_active_connection (gpointer data, gpointer user_data)
if (dev_str->len > 0)
g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */
- con_list = nmc->system_connections;
+ con_list = (info->scope == NM_CONNECTION_SCOPE_SYSTEM) ? info->nmc->system_connections : info->nmc->user_connections;
for (iter = con_list; iter; iter = g_slist_next (iter)) {
NMConnection *connection = (NMConnection *) iter->data;
const char *con_path = nm_connection_get_path (connection);
if (!strcmp (active_path, con_path)) {
/* This connection is active */
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con != NULL);
/* Obtain field values */
- nmc->allowed_fields[0].value = nm_setting_connection_get_id (s_con);
- nmc->allowed_fields[1].value = nm_setting_connection_get_uuid (s_con);
- nmc->allowed_fields[2].value = dev_str->str;
- nmc->allowed_fields[3].value = nm_active_connection_get_default (active) ? _("yes") : _("no");
- nmc->allowed_fields[4].value = nm_active_connection_get_specific_object (active);
- nmc->allowed_fields[5].value = NM_IS_VPN_CONNECTION (active) ? _("yes") : _("no");
- nmc->allowed_fields[6].value = nm_object_get_path (NM_OBJECT (active));
-
- nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
- print_fields (nmc->print_fields, nmc->allowed_fields);
+ info->nmc->allowed_fields[0].value = nm_setting_connection_get_id (s_con);
+ info->nmc->allowed_fields[1].value = nm_setting_connection_get_uuid (s_con);
+ info->nmc->allowed_fields[2].value = dev_str->str;
+ info->nmc->allowed_fields[3].value = active_service_scope == NM_CONNECTION_SCOPE_SYSTEM ? _("system") : _("user");
+ info->nmc->allowed_fields[4].value = nm_active_connection_get_default (active) ? _("yes") : _("no");
+ info->nmc->allowed_fields[5].value = nm_active_connection_get_service_name (active);
+ info->nmc->allowed_fields[6].value = nm_active_connection_get_specific_object (active);
+ info->nmc->allowed_fields[7].value = NM_IS_VPN_CONNECTION (active) ? _("yes") : _("no");
+ info->nmc->allowed_fields[8].value = nm_object_get_path (NM_OBJECT (active));
+
+ info->nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
+ print_fields (info->nmc->print_fields, info->nmc->allowed_fields);
break;
}
}
@@ -613,6 +624,7 @@ do_connections_status (NmCli *nmc, int argc, char **argv)
{
const GPtrArray *active_cons;
GError *error = NULL;
+ StatusInfo *info;
char *fields_str;
char *fields_all = NMC_FIELDS_CON_STATUS_ALL;
char *fields_common = NMC_FIELDS_CON_STATUS_COMMON;
@@ -661,8 +673,15 @@ do_connections_status (NmCli *nmc, int argc, char **argv)
nmc->get_client (nmc);
active_cons = nm_client_get_active_connections (nmc->client);
- if (active_cons && active_cons->len)
- g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) nmc);
+ if (active_cons && active_cons->len) {
+ info = g_malloc0 (sizeof (StatusInfo));
+ info->nmc = nmc;
+ info->scope = NM_CONNECTION_SCOPE_SYSTEM;
+ g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) info);
+ info->scope = NM_CONNECTION_SCOPE_USER;
+ g_ptr_array_foreach ((GPtrArray *) active_cons, show_active_connection, (gpointer) info);
+ g_free (info);
+ }
error:
return nmc->return_value;
@@ -681,7 +700,7 @@ check_ethernet_compatible (NMDeviceEthernet *device, NMConnection *connection, G
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
connection_type = nm_setting_connection_get_connection_type (s_con);
@@ -695,7 +714,7 @@ check_ethernet_compatible (NMDeviceEthernet *device, NMConnection *connection, G
if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME))
is_pppoe = TRUE;
- s_wired = nm_connection_get_setting_wired (connection);
+ s_wired = (NMSettingWired *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRED);
/* Wired setting is optional for PPPoE */
if (!is_pppoe && !s_wired) {
g_set_error (error, 0, 0,
@@ -737,7 +756,7 @@ check_wifi_compatible (NMDeviceWifi *device, NMConnection *connection, GError **
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME)) {
@@ -746,7 +765,7 @@ check_wifi_compatible (NMDeviceWifi *device, NMConnection *connection, GError **
return FALSE;
}
- s_wireless = nm_connection_get_setting_wireless (connection);
+ s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
if (!s_wireless) {
g_set_error (error, 0, 0,
"The connection was not a valid WiFi connection.");
@@ -795,7 +814,7 @@ check_bt_compatible (NMDeviceBt *device, NMConnection *connection, GError **erro
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_BLUETOOTH_SETTING_NAME)) {
@@ -804,7 +823,7 @@ check_bt_compatible (NMDeviceBt *device, NMConnection *connection, GError **erro
return FALSE;
}
- s_bt = nm_connection_get_setting_bluetooth (connection);
+ s_bt = NM_SETTING_BLUETOOTH (nm_connection_get_setting (connection, NM_TYPE_SETTING_BLUETOOTH));
if (!s_bt) {
g_set_error (error, 0, 0,
"The connection was not a valid Bluetooth connection.");
@@ -854,7 +873,7 @@ check_olpc_mesh_compatible (NMDeviceOlpcMesh *device, NMConnection *connection,
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_OLPC_MESH_SETTING_NAME)) {
@@ -863,7 +882,7 @@ check_olpc_mesh_compatible (NMDeviceOlpcMesh *device, NMConnection *connection,
return FALSE;
}
- s_mesh = nm_connection_get_setting_olpc_mesh (connection);
+ s_mesh = NM_SETTING_OLPC_MESH (nm_connection_get_setting (connection, NM_TYPE_SETTING_OLPC_MESH));
if (!s_mesh) {
g_set_error (error, 0, 0,
"The connection was not a valid Mesh connection.");
@@ -874,94 +893,55 @@ check_olpc_mesh_compatible (NMDeviceOlpcMesh *device, NMConnection *connection,
}
#endif
-#if WITH_WIMAX
static gboolean
-check_wimax_compatible (NMDeviceWimax *device, NMConnection *connection, GError **error)
+check_gsm_compatible (NMGsmDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
- NMSettingWimax *s_wimax;
- const GByteArray *mac;
- const char *device_mac_str;
- struct ether_addr *device_mac = NULL;
+ NMSettingGsm *s_gsm;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIMAX_SETTING_NAME)) {
- g_set_error (error, 0, 0,
- "The connection was not a WiMAX connection.");
- return FALSE;
- }
-
- s_wimax = nm_connection_get_setting_wimax (connection);
- if (!s_wimax) {
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME)) {
g_set_error (error, 0, 0,
- "The connection was not a valid WiMAX connection.");
- return FALSE;
- }
-
- device_mac_str = nm_device_wimax_get_hw_address (device);
- if (device_mac_str)
- device_mac = ether_aton (device_mac_str);
- if (!device_mac) {
- g_set_error (error, 0, 0, "Invalid device MAC address.");
+ "The connection was not a GSM connection.");
return FALSE;
}
- mac = nm_setting_wimax_get_mac_address (s_wimax);
- if (mac && memcmp (mac->data, device_mac->ether_addr_octet, ETH_ALEN)) {
+ s_gsm = NM_SETTING_GSM (nm_connection_get_setting (connection, NM_TYPE_SETTING_GSM));
+ if (!s_gsm) {
g_set_error (error, 0, 0,
- "The connection's MAC address did not match this device.");
+ "The connection was not a valid GSM connection.");
return FALSE;
}
return TRUE;
}
-#endif
static gboolean
-check_modem_compatible (NMDeviceModem *device, NMConnection *connection, GError **error)
+check_cdma_compatible (NMCdmaDevice *device, NMConnection *connection, GError **error)
{
NMSettingConnection *s_con;
- NMSettingGsm *s_gsm;
NMSettingCdma *s_cdma;
- NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- /* Figure out what the modem supports */
- caps = nm_device_modem_get_current_capabilities (device);
- if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
- if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_GSM_SETTING_NAME)) {
- g_set_error (error, 0, 0,
- "The connection was not a GSM connection.");
- return FALSE;
- }
-
- s_gsm = nm_connection_get_setting_gsm (connection);
- if (!s_gsm) {
- g_set_error (error, 0, 0,
- "The connection was not a valid GSM connection.");
- return FALSE;
- }
- } else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) {
- if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME)) {
- g_set_error (error, 0, 0,
- "The connection was not a CDMA connection.");
- return FALSE;
- }
+ if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_CDMA_SETTING_NAME)) {
+ g_set_error (error, 0, 0,
+ "The connection was not a CDMA connection.");
+ return FALSE;
+ }
- s_cdma = nm_connection_get_setting_cdma (connection);
- if (!s_cdma) {
- g_set_error (error, 0, 0,
- "The connection was not a valid CDMA connection.");
- return FALSE;
- }
+ s_cdma = NM_SETTING_CDMA (nm_connection_get_setting (connection, NM_TYPE_SETTING_CDMA));
+ if (!s_cdma) {
+ g_set_error (error, 0, 0,
+ "The connection was not a valid CDMA connection.");
+ return FALSE;
}
return TRUE;
@@ -981,17 +961,49 @@ nm_device_is_connection_compatible (NMDevice *device, NMConnection *connection,
return check_bt_compatible (NM_DEVICE_BT (device), connection, error);
// else if (NM_IS_DEVICE_OLPC_MESH (device))
// return check_olpc_mesh_compatible (NM_DEVICE_OLPC_MESH (device), connection, error);
-#if WITH_WIMAX
- else if (NM_IS_DEVICE_WIMAX (device))
- return check_wimax_compatible (NM_DEVICE_WIMAX (device), connection, error);
-#endif
- else if (NM_IS_DEVICE_MODEM (device))
- return check_modem_compatible (NM_DEVICE_MODEM (device), connection, error);
+ else if (NM_IS_GSM_DEVICE (device))
+ return check_gsm_compatible (NM_GSM_DEVICE (device), connection, error);
+ else if (NM_IS_CDMA_DEVICE (device))
+ return check_cdma_compatible (NM_CDMA_DEVICE (device), connection, error);
g_set_error (error, 0, 0, "unhandled device type '%s'", G_OBJECT_TYPE_NAME (device));
return FALSE;
}
+
+/**
+ * nm_client_get_active_connection_by_path:
+ * @client: a #NMClient
+ * @object_path: the object path to search for
+ *
+ * Gets a #NMActiveConnection from a #NMClient.
+ *
+ * Returns: the #NMActiveConnection for the given @object_path or %NULL if none is found.
+ **/
+static NMActiveConnection *
+nm_client_get_active_connection_by_path (NMClient *client, const char *object_path)
+{
+ const GPtrArray *actives;
+ int i;
+ NMActiveConnection *active = NULL;
+
+ g_return_val_if_fail (NM_IS_CLIENT (client), NULL);
+ g_return_val_if_fail (object_path, NULL);
+
+ actives = nm_client_get_active_connections (client);
+ if (!actives)
+ return NULL;
+
+ for (i = 0; i < actives->len; i++) {
+ NMActiveConnection *candidate = g_ptr_array_index (actives, i);
+ if (!strcmp (nm_object_get_path (NM_OBJECT (candidate)), object_path)) {
+ active = candidate;
+ break;
+ }
+ }
+
+ return active;
+}
/* -------------------- */
static NMActiveConnection *
@@ -1043,20 +1055,13 @@ get_default_active_connection (NmCli *nmc, NMDevice **device)
* IN: connection: connection to activate
* iface: device interface name to use (optional)
* ap: access point to use (optional; valid just for 802-11-wireless)
- * nsp: Network Service Provider to use (option; valid only for wimax)
* OUT: device: found device
* spec_object: specific_object path of NMAccessPoint
* RETURNS: TRUE when a device is found, FALSE otherwise.
*/
static gboolean
-find_device_for_connection (NmCli *nmc,
- NMConnection *connection,
- const char *iface,
- const char *ap,
- const char *nsp,
- NMDevice **device,
- const char **spec_object,
- GError **error)
+find_device_for_connection (NmCli *nmc, NMConnection *connection, const char *iface, const char *ap,
+ NMDevice **device, const char **spec_object, GError **error)
{
NMSettingConnection *s_con;
const char *con_type;
@@ -1067,7 +1072,7 @@ find_device_for_connection (NmCli *nmc,
g_return_val_if_fail (spec_object != NULL && *spec_object == NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- s_con = nm_connection_get_setting_connection (connection);
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
con_type = nm_setting_connection_get_connection_type (s_con);
@@ -1143,27 +1148,6 @@ find_device_for_connection (NmCli *nmc,
}
g_free (hwaddr_up);
}
-
-#if WITH_WIMAX
- if ( found_device
- && nsp
- && !strcmp (con_type, NM_SETTING_WIMAX_SETTING_NAME)
- && NM_IS_DEVICE_WIMAX (dev)) {
- const GPtrArray *nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev));
- found_device = NULL; /* Mark as not found; set to the device again later, only if NSP matches */
-
- for (j = 0; nsps && (j < nsps->len); j++) {
- NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
- const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp);
-
- if (!strcmp (nsp, candidate_name)) {
- found_device = dev;
- *spec_object = nm_object_get_path (NM_OBJECT (candidate_nsp));
- break;
- }
- }
- }
-#endif
}
if (found_device) {
@@ -1187,8 +1171,6 @@ active_connection_state_to_string (NMActiveConnectionState state)
return _("activating");
case NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
return _("activated");
- case NM_ACTIVE_CONNECTION_STATE_DEACTIVATING:
- return _("deactivating");
case NM_ACTIVE_CONNECTION_STATE_UNKNOWN:
default:
return _("unknown");
@@ -1318,32 +1300,79 @@ timeout_cb (gpointer user_data)
}
static void
-activate_connection_cb (NMClient *client, NMActiveConnection *active, GError *error, gpointer user_data)
+foo_active_connections_changed_cb (NMClient *client,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ /* Call again activate_connection_cb with dummy arguments;
+ * the correct ones are taken from its first call.
+ */
+ activate_connection_cb (NULL, NULL, NULL);
+}
+
+static void
+activate_connection_cb (gpointer user_data, const char *path, GError *error)
{
NmCli *nmc = (NmCli *) user_data;
+ NMActiveConnection *active;
NMActiveConnectionState state;
+ static gulong handler_id = 0;
+ static NmCli *orig_nmc;
+ static const char *orig_path;
+ static GError *orig_error;
+
+ if (nmc)
+ {
+ /* Called first time; store actual arguments */
+ orig_nmc = nmc;
+ orig_path = path;
+ orig_error = error;
+ }
- if (error) {
- g_string_printf (nmc->return_text, _("Error: Connection activation failed: %s"), error->message);
- nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
+ /* Disconnect the handler not to be run any more */
+ if (handler_id != 0) {
+ g_signal_handler_disconnect (orig_nmc->client, handler_id);
+ handler_id = 0;
+ }
+
+ if (orig_error) {
+ g_string_printf (orig_nmc->return_text, _("Error: Connection activation failed: %s"), orig_error->message);
+ orig_nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
quit ();
} else {
+ active = nm_client_get_active_connection_by_path (orig_nmc->client, orig_path);
+ if (!active) {
+ /* The active connection path is not in active connections list yet; wait for active-connections signal. */
+ /* This is basically the case for VPN connections. */
+ if (nmc) {
+ /* Called first time, i.e. by nm_client_activate_connection() */
+ handler_id = g_signal_connect (orig_nmc->client, "notify::active-connections",
+ G_CALLBACK (foo_active_connections_changed_cb), NULL);
+ return;
+ } else {
+ g_string_printf (orig_nmc->return_text, _("Error: Obtaining active connection for '%s' failed."), orig_path);
+ orig_nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
+ quit ();
+ return;
+ }
+ }
+
state = nm_active_connection_get_state (active);
printf (_("Active connection state: %s\n"), active_connection_state_to_string (state));
- printf (_("Active connection path: %s\n"), nm_object_get_path (NM_OBJECT (active)));
+ printf (_("Active connection path: %s\n"), orig_path);
- if (nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
+ if (orig_nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
/* don't want to wait or already activated */
quit ();
} else {
if (NM_IS_VPN_CONNECTION (active))
- g_signal_connect (NM_VPN_CONNECTION (active), "vpn-state-changed", G_CALLBACK (vpn_connection_state_cb), nmc);
+ g_signal_connect (NM_VPN_CONNECTION (active), "vpn-state-changed", G_CALLBACK (vpn_connection_state_cb), orig_nmc);
else
- g_signal_connect (active, "notify::state", G_CALLBACK (active_connection_state_cb), nmc);
+ g_signal_connect (active, "notify::state", G_CALLBACK (active_connection_state_cb), orig_nmc);
/* Start timer not to loop forever when signals are not emitted */
- g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc);
+ g_timeout_add_seconds (orig_nmc->timeout, timeout_cb, orig_nmc);
}
}
}
@@ -1356,10 +1385,11 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
gboolean device_found;
NMConnection *connection = NULL;
NMSettingConnection *s_con;
+ gboolean is_system;
+ const char *con_path;
const char *con_type;
const char *iface = NULL;
const char *ap = NULL;
- const char *nsp = NULL;
gboolean id_specified = FALSE;
gboolean wait = TRUE;
GError *error = NULL;
@@ -1380,7 +1410,8 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
goto error;
}
- connection = find_connection (nmc->system_connections, selector, *argv);
+ if ((connection = find_connection (nmc->system_connections, selector, *argv)) == NULL)
+ connection = find_connection (nmc->user_connections, selector, *argv);
if (!connection) {
g_string_printf (nmc->return_text, _("Error: Unknown connection: %s."), *argv);
@@ -1406,17 +1437,6 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
ap = *argv;
}
-#if WITH_WIMAX
- else if (strcmp (*argv, "nsp") == 0) {
- if (next_arg (&argc, &argv) != 0) {
- g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *argv);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- goto error;
- }
-
- nsp = *argv;
- }
-#endif
else if (strcmp (*argv, "--nowait") == 0) {
wait = FALSE;
} else if (strcmp (*argv, "--timeout") == 0) {
@@ -1462,11 +1482,14 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
/* create NMClient */
nmc->get_client (nmc);
- s_con = nm_connection_get_setting_connection (connection);
+ is_system = (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) ? TRUE : FALSE;
+ con_path = nm_connection_get_path (connection);
+
+ s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
con_type = nm_setting_connection_get_connection_type (s_con);
- device_found = find_device_for_connection (nmc, connection, iface, ap, nsp, &device, &spec_object, &error);
+ device_found = find_device_for_connection (nmc, connection, iface, ap, &device, &spec_object, &error);
if (!device_found) {
if (error)
@@ -1478,14 +1501,13 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
goto error;
}
- /* Use nowait_flag instead of should_wait because exiting has to be postponed till
- * active_connection_state_cb() is called. That gives NM time to check our permissions
- * and we can follow activation progress.
- */
+ /* Use nowait_flag instead of should_wait because exitting has to be postponed till active_connection_state_cb()
+ * is called, giving NM time to check our permissions */
nmc->nowait_flag = !wait;
nmc->should_wait = TRUE;
nm_client_activate_connection (nmc->client,
- connection,
+ is_system ? NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS,
+ con_path,
device,
spec_object,
activate_connection_cb,
@@ -1506,6 +1528,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
const GPtrArray *active_cons;
const char *con_path;
const char *active_path;
+ NMConnectionScope active_service_scope, con_scope;
gboolean id_specified = FALSE;
gboolean wait = TRUE;
int i;
@@ -1521,7 +1544,8 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
goto error;
}
- connection = find_connection (nmc->system_connections, selector, *argv);
+ if ((connection = find_connection (nmc->system_connections, selector, *argv)) == NULL)
+ connection = find_connection (nmc->user_connections, selector, *argv);
if (!connection) {
g_string_printf (nmc->return_text, _("Error: Unknown connection: %s."), *argv);
@@ -1562,13 +1586,15 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
nmc->get_client (nmc);
con_path = nm_connection_get_path (connection);
+ con_scope = nm_connection_get_scope (connection);
active_cons = nm_client_get_active_connections (nmc->client);
for (i = 0; active_cons && (i < active_cons->len); i++) {
NMActiveConnection *candidate = g_ptr_array_index (active_cons, i);
active_path = nm_active_connection_get_connection (candidate);
- if (!strcmp (active_path, con_path)) {
+ active_service_scope = nm_active_connection_get_scope (candidate);
+ if (!strcmp (active_path, con_path) && active_service_scope == con_scope) {
active = candidate;
break;
}
@@ -1576,8 +1602,9 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
if (active)
nm_client_deactivate_connection (nmc->client, active);
- else
+ else {
fprintf (stderr, _("Warning: Connection not active\n"));
+ }
sleep (1); /* Don't quit immediatelly and give NM time to check our permissions */
error:
@@ -1585,66 +1612,73 @@ error:
return nmc->return_value;
}
-static NMCResultCode
-parse_cmd (NmCli *nmc, int argc, char **argv)
+/* callback called when connections are obtained from the settings service */
+static void
+get_connections_cb (NMSettingsInterface *settings, gpointer user_data)
{
+ ArgsInfo *args = (ArgsInfo *) user_data;
+ static gboolean system_cb_called = FALSE;
+ static gboolean user_cb_called = FALSE;
GError *error = NULL;
- if (argc == 0) {
- if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
+ if (NM_IS_REMOTE_SETTINGS_SYSTEM (settings)) {
+ system_cb_called = TRUE;
+ args->nmc->system_connections = nm_settings_interface_list_connections (settings);
+ }
+ else {
+ user_cb_called = TRUE;
+ args->nmc->user_connections = nm_settings_interface_list_connections (settings);
+ }
+
+ /* return and wait for the callback of the second settings is called */
+ if ( (args->nmc->system_settings_running && !system_cb_called)
+ || (args->nmc->user_settings_running && !user_cb_called))
+ return;
+
+ if (args->argc == 0) {
+ if (!nmc_terse_option_check (args->nmc->print_output, args->nmc->required_fields, &error))
goto opt_error;
- nmc->return_value = do_connections_list (nmc, argc, argv);
+ args->nmc->return_value = do_connections_list (args->nmc, args->argc, args->argv);
} else {
- if (matches (*argv, "list") == 0) {
- nmc->return_value = do_connections_list (nmc, argc-1, argv+1);
+ if (matches (*args->argv, "list") == 0) {
+ args->nmc->return_value = do_connections_list (args->nmc, args->argc-1, args->argv+1);
}
- else if (matches(*argv, "status") == 0) {
- if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
+ else if (matches(*args->argv, "status") == 0) {
+ if (!nmc_terse_option_check (args->nmc->print_output, args->nmc->required_fields, &error))
goto opt_error;
- nmc->return_value = do_connections_status (nmc, argc-1, argv+1);
+ args->nmc->return_value = do_connections_status (args->nmc, args->argc-1, args->argv+1);
}
- else if (matches(*argv, "up") == 0) {
- nmc->return_value = do_connection_up (nmc, argc-1, argv+1);
+ else if (matches(*args->argv, "up") == 0) {
+ args->nmc->return_value = do_connection_up (args->nmc, args->argc-1, args->argv+1);
}
- else if (matches(*argv, "down") == 0) {
- nmc->return_value = do_connection_down (nmc, argc-1, argv+1);
+ else if (matches(*args->argv, "down") == 0) {
+ args->nmc->return_value = do_connection_down (args->nmc, args->argc-1, args->argv+1);
}
- else if (matches (*argv, "help") == 0) {
+ else if (matches (*args->argv, "help") == 0) {
usage ();
- nmc->should_wait = FALSE;
+ args->nmc->should_wait = FALSE;
} else {
usage ();
- g_string_printf (nmc->return_text, _("Error: 'con' command '%s' is not valid."), *argv);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- nmc->should_wait = FALSE;
+ g_string_printf (args->nmc->return_text, _("Error: 'con' command '%s' is not valid."), *args->argv);
+ args->nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ args->nmc->should_wait = FALSE;
}
}
- return nmc->return_value;
+ if (!args->nmc->should_wait)
+ quit ();
+ return;
opt_error:
- g_string_printf (nmc->return_text, _("Error: %s."), error->message);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- nmc->should_wait = FALSE;
+ g_string_printf (args->nmc->return_text, _("Error: %s."), error->message);
+ args->nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
+ args->nmc->should_wait = FALSE;
g_error_free (error);
- return nmc->return_value;
+ quit ();
+ return;
}
-/* callback called when connections are obtained from the settings service */
-static void
-get_connections_cb (NMRemoteSettings *settings, gpointer user_data)
-{
- ArgsInfo *args = (ArgsInfo *) user_data;
-
- /* Get the connection list */
- args->nmc->system_connections = nm_remote_settings_list_connections (settings);
-
- parse_cmd (args->nmc, args->argc, args->argv);
-
- if (!args->nmc->should_wait)
- quit ();
-}
/* Entry point function for connections-related commands: 'nmcli con' */
NMCResultCode
@@ -1652,66 +1686,59 @@ do_connections (NmCli *nmc, int argc, char **argv)
{
DBusGConnection *bus;
GError *error = NULL;
- int i = 0;
- gboolean real_cmd = FALSE;
-
- if (argc == 0)
- real_cmd = TRUE;
- else {
- while (real_con_commands[i] && matches (*argv, real_con_commands[i]) != 0)
- i++;
- if (real_con_commands[i] != NULL)
- real_cmd = TRUE;
- }
- if (!real_cmd) {
- /* no real execution command - no need to get connections */
- return parse_cmd (nmc, argc, argv);
- } else {
- if (!nmc_versions_match (nmc))
- return nmc->return_value;
+ nmc->should_wait = TRUE;
- nmc->should_wait = TRUE;
+ args_info.nmc = nmc;
+ args_info.argc = argc;
+ args_info.argv = argv;
- args_info.nmc = nmc;
- args_info.argc = argc;
- args_info.argv = argv;
+ /* connect to DBus' system bus */
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (error || !bus) {
+ g_string_printf (nmc->return_text, _("Error: could not connect to D-Bus."));
+ nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
+ return nmc->return_value;
+ }
- /* connect to DBus' system bus */
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (error || !bus) {
- g_string_printf (nmc->return_text, _("Error: could not connect to D-Bus."));
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- return nmc->return_value;
- }
+ /* get system settings */
+ if (!(nmc->system_settings = nm_remote_settings_system_new (bus))) {
+ g_string_printf (nmc->return_text, _("Error: Could not get system settings."));
+ nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
+ return nmc->return_value;
- /* get system settings */
- if (!(nmc->system_settings = nm_remote_settings_new (bus))) {
- g_string_printf (nmc->return_text, _("Error: Could not get system settings."));
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- return nmc->return_value;
+ }
- }
+ /* get user settings */
+ if (!(nmc->user_settings = nm_remote_settings_new (bus, NM_CONNECTION_SCOPE_USER))) {
+ g_string_printf (nmc->return_text, _("Error: Could not get user settings."));
+ nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
+ return nmc->return_value;
+ }
- /* find out whether settings service is running */
- g_object_get (nmc->system_settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &nmc->system_settings_running, NULL);
+ /* find out whether setting services are running */
+ g_object_get (nmc->system_settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &nmc->system_settings_running, NULL);
+ g_object_get (nmc->user_settings, NM_REMOTE_SETTINGS_SERVICE_RUNNING, &nmc->user_settings_running, NULL);
- if (!nmc->system_settings_running) {
- g_string_printf (nmc->return_text, _("Error: Can't obtain connections: settings service is not running."));
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- return nmc->return_value;
- }
+ if (!nmc->system_settings_running && !nmc->user_settings_running) {
+ g_string_printf (nmc->return_text, _("Error: Can't obtain connections: settings services are not running."));
+ nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
+ return nmc->return_value;
+ }
- /* connect to signal "connections-read" - emitted when connections are fetched and ready */
- g_signal_connect (nmc->system_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
- G_CALLBACK (get_connections_cb), &args_info);
+ /* connect to signal "connections-read" - emitted when connections are fetched and ready */
+ if (nmc->system_settings_running)
+ g_signal_connect (nmc->system_settings, NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
+ G_CALLBACK (get_connections_cb), &args_info);
+ if (nmc->user_settings_running)
+ g_signal_connect (nmc->user_settings, NM_SETTINGS_INTERFACE_CONNECTIONS_READ,
+ G_CALLBACK (get_connections_cb), &args_info);
- dbus_g_connection_unref (bus);
+ dbus_g_connection_unref (bus);
- /* The rest will be done in get_connection_cb() callback.
- * We need to wait for signals that connections are read.
- */
- return NMC_RESULT_SUCCESS;
- }
+ /* The rest will be done in get_connection_cb() callback.
+ * We need to wait for signals that connections are read.
+ */
+ return NMC_RESULT_SUCCESS;
}
diff --git a/cli/src/devices.c b/cli/src/devices.c
index c6228ba1a..d314928a8 100644
--- a/cli/src/devices.c
+++ b/cli/src/devices.c
@@ -17,8 +17,6 @@
* (C) Copyright 2010 - 2011 Red Hat, Inc.
*/
-#include "config.h"
-
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -35,12 +33,10 @@
#include <nm-device.h>
#include <nm-device-ethernet.h>
#include <nm-device-wifi.h>
-#include <nm-device-modem.h>
+#include <nm-gsm-device.h>
+#include <nm-cdma-device.h>
#include <nm-device-bt.h>
//#include <nm-device-olpc-mesh.h>
-#if WITH_WIMAX
-#include <nm-device-wimax.h>
-#endif
#include <nm-utils.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
@@ -53,9 +49,6 @@
#include <nm-setting-cdma.h>
#include <nm-setting-bluetooth.h>
#include <nm-setting-olpc-mesh.h>
-#if WITH_WIMAX
-#include <nm-setting-wimax.h>
-#endif
#include "utils.h"
#include "devices.h"
@@ -80,21 +73,14 @@ static NmcOutputField nmc_fields_dev_list_sections[] = {
{"WIFI-PROPERTIES", N_("WIFI-PROPERTIES"), 0, NULL, 0}, /* 2 */
{"AP", N_("AP"), 0, NULL, 0}, /* 3 */
{"WIRED-PROPERTIES", N_("WIRED-PROPERTIES"), 0, NULL, 0}, /* 4 */
- {"WIMAX-PROPERTIES", N_("WIMAX-PROPERTIES"), 0, NULL, 0}, /* 5 */
- {"NSP", N_("NSP"), 0, NULL, 0}, /* 6 */
- {"IP4-SETTINGS", N_("IP4-SETTINGS"), 0, NULL, 0}, /* 7 */
- {"IP4-DNS", N_("IP4-DNS"), 0, NULL, 0}, /* 8 */
- {"IP6-SETTINGS", N_("IP6-SETTINGS"), 0, NULL, 0}, /* 9 */
- {"IP6-DNS", N_("IP6-DNS"), 0, NULL, 0}, /* 10 */
+ {"IP4-SETTINGS", N_("IP4-SETTINGS"), 0, NULL, 0}, /* 5 */
+ {"IP4-DNS", N_("IP4-DNS"), 0, NULL, 0}, /* 6 */
+ {"IP6-SETTINGS", N_("IP6-SETTINGS"), 0, NULL, 0}, /* 7 */
+ {"IP6-DNS", N_("IP6-DNS"), 0, NULL, 0}, /* 8 */
{NULL, NULL, 0, NULL, 0}
};
-#if WITH_WIMAX
-#define NMC_FIELDS_DEV_LIST_SECTIONS_ALL "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
-#define NMC_FIELDS_DEV_LIST_SECTIONS_COMMON "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,WIMAX-PROPERTIES,NSP,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
-#else
#define NMC_FIELDS_DEV_LIST_SECTIONS_ALL "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
#define NMC_FIELDS_DEV_LIST_SECTIONS_COMMON "GENERAL,CAPABILITIES,WIFI-PROPERTIES,AP,WIRED-PROPERTIES,IP4-SETTINGS,IP4-DNS,IP6-SETTINGS,IP6-DNS"
-#endif
/* Available fields for 'dev list' - GENERAL part */
static NmcOutputField nmc_fields_dev_list_general[] = {
@@ -142,21 +128,6 @@ static NmcOutputField nmc_fields_dev_list_wifi_prop[] = {
#define NMC_FIELDS_DEV_LIST_WIFI_PROP_ALL "NAME,WEP,WPA,WPA2,TKIP,CCMP"
#define NMC_FIELDS_DEV_LIST_WIFI_PROP_COMMON "NAME,WEP,WPA,WPA2,TKIP,CCMP"
-#if WITH_WIMAX
-/* Available fields for 'dev list' - wimax properties part */
-static NmcOutputField nmc_fields_dev_list_wimax_prop[] = {
- {"NAME", N_("NAME"), 18, NULL, 0}, /* 0 */
- {"CTR-FREQ", N_("CTR-FREQ"), 7, NULL, 0}, /* 1 */
- {"RSSI", N_("RSSI"), 5, NULL, 0}, /* 2 */
- {"CINR", N_("CINR"), 5, NULL, 0}, /* 3 */
- {"TX-POW", N_("TX-POW"), 5, NULL, 0}, /* 4 */
- {"BSID", N_("BSID"), 18, NULL, 0}, /* 5 */
- {NULL, NULL, 0, NULL, 0}
-};
-#define NMC_FIELDS_DEV_LIST_WIMAX_PROP_ALL "NAME,CTR-FREQ,RSSI,CINR,TX-POW,BSID"
-#define NMC_FIELDS_DEV_LIST_WIMAX_PROP_COMMON "NAME,CTR-FREQ,RSSI,CINR,TX-POW,BSID"
-#endif
-
/* Available fields for 'dev list' - IPv4 settings part */
static NmcOutputField nmc_fields_dev_list_ip4_settings[] = {
{"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
@@ -218,23 +189,6 @@ static NmcOutputField nmc_fields_dev_wifi_list[] = {
#define NMC_FIELDS_DEV_WIFI_LIST_COMMON "SSID,BSSID,MODE,FREQ,RATE,SIGNAL,SECURITY,ACTIVE"
#define NMC_FIELDS_DEV_WIFI_LIST_FOR_DEV_LIST "NAME,"NMC_FIELDS_DEV_WIFI_LIST_COMMON
-#if WITH_WIMAX
-/* Available fields for 'dev wimax list' */
-static NmcOutputField nmc_fields_dev_wimax_list[] = {
- {"NAME", N_("NAME"), 15, NULL, 0}, /* 0 */
- {"NSP", N_("NSP"), 33, NULL, 0}, /* 1 */
- {"SIGNAL", N_("SIGNAL"), 8, NULL, 0}, /* 2 */
- {"TYPE", N_("TYPE"), 16, NULL, 0}, /* 3 */
- {"DEVICE", N_("DEVICE"), 10, NULL, 0}, /* 4 */
- {"ACTIVE", N_("ACTIVE"), 8, NULL, 0}, /* 5 */
- {"DBUS-PATH", N_("DBUS-PATH"), 46, NULL, 0}, /* 6 */
- {NULL, NULL, 0, NULL, 0}
-};
-#define NMC_FIELDS_DEV_WIMAX_LIST_ALL "NSP,SIGNAL,TYPE,DEVICE,ACTIVE,DBUS-PATH"
-#define NMC_FIELDS_DEV_WIMAX_LIST_COMMON "NSP,SIGNAL,TYPE,DEVICE,ACTIVE"
-#define NMC_FIELDS_DEV_WIMAX_LIST_FOR_DEV_LIST "NAME,"NMC_FIELDS_DEV_WIMAX_LIST_COMMON
-#endif
-
/* static function prototypes */
static void usage (void);
@@ -243,9 +197,7 @@ static NMCResultCode do_devices_status (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_devices_list (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_device_disconnect (NmCli *nmc, int argc, char **argv);
static NMCResultCode do_device_wifi (NmCli *nmc, int argc, char **argv);
-#if WITH_WIMAX
-static NMCResultCode do_device_wimax (NmCli *nmc, int argc, char **argv);
-#endif
+
extern GMainLoop *loop; /* glib main loop variable */
@@ -253,20 +205,12 @@ static void
usage (void)
{
fprintf (stderr,
- _("Usage: nmcli dev { COMMAND | help }\n\n"
-#if WITH_WIMAX
- " COMMAND := { status | list | disconnect | wifi | wimax }\n\n"
-#else
- " COMMAND := { status | list | disconnect | wifi }\n\n"
-#endif
- " status\n"
- " list [iface <iface>]\n"
- " disconnect iface <iface> [--nowait] [--timeout <timeout>]\n"
- " wifi [list [iface <iface>] [hwaddr <hwaddr>]]\n"
-#if WITH_WIMAX
- " wimax [list [iface <iface>] [nsp <name>]]\n\n"
-#endif
- ));
+ _("Usage: nmcli dev { COMMAND | help }\n\n"
+ " COMMAND := { status | list | disconnect | wifi }\n\n"
+ " status\n"
+ " list [iface <iface>]\n"
+ " disconnect iface <iface> [--nowait] [--timeout <timeout>]\n"
+ " wifi [list [iface <iface>] [hwaddr <hwaddr>]]\n\n"));
}
/* quit main loop */
@@ -294,14 +238,8 @@ device_state_to_string (NMDeviceState state)
return _("connecting (need authentication)");
case NM_DEVICE_STATE_IP_CONFIG:
return _("connecting (getting IP configuration)");
- case NM_DEVICE_STATE_IP_CHECK:
- return _("connecting (checking IP connectivity)");
- case NM_DEVICE_STATE_SECONDARIES:
- return _("connecting (starting secondary connections)");
case NM_DEVICE_STATE_ACTIVATED:
return _("connected");
- case NM_DEVICE_STATE_DEACTIVATING:
- return _("deactivating");
case NM_DEVICE_STATE_FAILED:
return _("connection failed");
default:
@@ -309,41 +247,28 @@ device_state_to_string (NMDeviceState state)
}
}
-/* Convert device type to string. Use setting names strings to match with
- * connection type names.
- */
+/* Return device type - use setting names to match with connection types */
static const char *
-device_type_to_string (NMDevice *device)
+get_device_type (NMDevice * device)
{
- NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
-
- switch (nm_device_get_device_type (device)) {
- case NM_DEVICE_TYPE_ETHERNET:
+ if (NM_IS_DEVICE_ETHERNET (device))
return NM_SETTING_WIRED_SETTING_NAME;
- case NM_DEVICE_TYPE_WIFI:
+ else if (NM_IS_DEVICE_WIFI (device))
return NM_SETTING_WIRELESS_SETTING_NAME;
- case NM_DEVICE_TYPE_MODEM:
- caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
- if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
- return NM_SETTING_GSM_SETTING_NAME;
- else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
- return NM_SETTING_CDMA_SETTING_NAME;
- return _("Unknown");
- case NM_DEVICE_TYPE_BT:
+ else if (NM_IS_GSM_DEVICE (device))
+ return NM_SETTING_GSM_SETTING_NAME;
+ else if (NM_IS_CDMA_DEVICE (device))
+ return NM_SETTING_CDMA_SETTING_NAME;
+ else if (NM_IS_DEVICE_BT (device))
return NM_SETTING_BLUETOOTH_SETTING_NAME;
-// case NM_DEVICE_TYPE_OLPC_MESH:
+// else if (NM_IS_DEVICE_OLPC_MESH (device))
// return NM_SETTING_OLPC_MESH_SETTING_NAME;
-#if WITH_WIMAX
- case NM_DEVICE_TYPE_WIMAX:
- return NM_SETTING_WIMAX_SETTING_NAME;
-#endif
- default:
+ else
return _("Unknown");
- }
}
static char *
-ap_wpa_rsn_flags_to_string (NM80211ApSecurityFlags flags)
+ap_wpa_rsn_flags_to_string (guint32 flags)
{
char *flags_str[16]; /* Enough space for flags and terminating NULL */
char *ret_str;
@@ -417,8 +342,8 @@ ip6_address_as_string (const struct in6_addr *ip)
g_string_append_printf (ip6_str, "%02X", ip->s6_addr[0]);
for (j = 1; j < 16; j++)
g_string_append_printf (ip6_str, " %02X", ip->s6_addr[j]);
- g_warning ("%s: error converting IP6 address %s",
- __func__, ip6_str->str);
+ nm_warning ("%s: error converting IP6 address %s",
+ __func__, ip6_str->str);
g_string_free (ip6_str, TRUE);
return NULL;
}
@@ -437,9 +362,7 @@ detail_access_point (gpointer data, gpointer user_data)
NMAccessPoint *ap = NM_ACCESS_POINT (data);
APInfo *info = (APInfo *) user_data;
gboolean active = FALSE;
- NM80211ApFlags flags;
- NM80211ApSecurityFlags wpa_flags, rsn_flags;
- guint32 freq, bitrate;
+ guint32 flags, wpa_flags, rsn_flags, freq, bitrate;
guint8 strength;
const GByteArray *ssid;
const char *hwaddr;
@@ -522,54 +445,6 @@ detail_access_point (gpointer data, gpointer user_data)
g_string_free (security_str, TRUE);
}
-#if WITH_WIMAX
-static void
-detail_wimax_nsp (NMWimaxNsp *nsp, NmCli *nmc, NMDevice *dev, int idx)
-{
- NMDeviceWimax *wimax = NM_DEVICE_WIMAX (dev);
- char *nsp_name, *quality_str;
- const char *ntype;
- gboolean active = FALSE;
-
- switch (nm_wimax_nsp_get_network_type (nsp)) {
- case NM_WIMAX_NSP_NETWORK_TYPE_HOME:
- ntype = _("Home");
- break;
- case NM_WIMAX_NSP_NETWORK_TYPE_PARTNER:
- ntype = _("Partner");
- break;
- case NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER:
- ntype = _("Roaming");
- break;
- default:
- ntype = _("Unknown");
- break;
- }
-
- if (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED) {
- if (nsp == nm_device_wimax_get_active_nsp (wimax))
- active = TRUE;
- }
-
- quality_str = g_strdup_printf ("%u", nm_wimax_nsp_get_signal_quality (nsp));
- nsp_name = g_strdup_printf ("NSP%d", idx); /* NSP */
-
- nmc->allowed_fields[0].value = nsp_name;
- nmc->allowed_fields[1].value = nm_wimax_nsp_get_name (nsp);
- nmc->allowed_fields[2].value = quality_str;
- nmc->allowed_fields[3].value = ntype;
- nmc->allowed_fields[4].value = nm_device_get_iface (dev);
- nmc->allowed_fields[5].value = active ? _("yes") : _("no");
- nmc->allowed_fields[6].value = nm_object_get_path (NM_OBJECT (nsp));
-
- nmc->print_fields.flags &= ~NMC_PF_FLAG_MAIN_HEADER_ADD & ~NMC_PF_FLAG_MAIN_HEADER_ONLY & ~NMC_PF_FLAG_FIELD_NAMES; /* Clear header flags */
- print_fields (nmc->print_fields, nmc->allowed_fields);
-
- g_free (nsp_name);
- g_free (quality_str);
-}
-#endif
-
struct cb_info {
NMClient *client;
const GPtrArray *active;
@@ -585,7 +460,7 @@ show_device_info (gpointer data, gpointer user_data)
char *tmp;
const char *hwaddr = NULL;
NMDeviceState state = NM_DEVICE_STATE_UNKNOWN;
- NMDeviceCapabilities caps;
+ guint32 caps;
guint32 speed;
char *speed_str = NULL;
const GArray *array;
@@ -646,14 +521,10 @@ show_device_info (gpointer data, gpointer user_data)
hwaddr = nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device));
else if (NM_IS_DEVICE_WIFI (device))
hwaddr = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device));
-#if WITH_WIMAX
- else if (NM_IS_DEVICE_WIMAX (device))
- hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
-#endif
nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[0].name; /* "GENERAL"*/
nmc->allowed_fields[1].value = nm_device_get_iface (device);
- nmc->allowed_fields[2].value = device_type_to_string (device);
+ nmc->allowed_fields[2].value = get_device_type (device);
nmc->allowed_fields[3].value = nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)");
nmc->allowed_fields[4].value = hwaddr ? hwaddr : _("unknown)");
nmc->allowed_fields[5].value = device_state_to_string (state);
@@ -695,7 +566,7 @@ show_device_info (gpointer data, gpointer user_data)
/* Wireless specific information */
if ((NM_IS_DEVICE_WIFI (device))) {
- NMDeviceWifiCapabilities wcaps;
+ guint32 wcaps;
NMAccessPoint *active_ap = NULL;
const char *active_bssid = NULL;
const GPtrArray *aps;
@@ -761,77 +632,6 @@ show_device_info (gpointer data, gpointer user_data)
was_output = TRUE;
}
}
-#if WITH_WIMAX
- else if (NM_IS_DEVICE_WIMAX (device)) {
- /* WIMAX-PROPERTIES */
- if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[5].name)) {
- char *cfreq = NULL, *rssi = NULL, *cinr = NULL, *txpow = NULL;
- guint tmp_uint;
- gint tmp_int;
- const char *bsid;
-
- nmc->allowed_fields = nmc_fields_dev_list_wimax_prop;
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_WIMAX_PROP_ALL, nmc->allowed_fields, NULL);
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
-
- nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[5].name; /* "WIMAX-PROPERTIES" */
-
- /* Center frequency */
- tmp_uint = nm_device_wimax_get_center_frequency (NM_DEVICE_WIMAX (device));
- if (tmp_uint)
- cfreq = g_strdup_printf ("%'.1f MHz", (double) tmp_uint / 1000.0);
- nmc->allowed_fields[1].value = cfreq ? cfreq : "";
-
- /* RSSI */
- tmp_int = nm_device_wimax_get_rssi (NM_DEVICE_WIMAX (device));
- if (tmp_int)
- rssi = g_strdup_printf ("%d dBm", tmp_int);
- nmc->allowed_fields[2].value = rssi ? rssi : "";
-
- /* CINR */
- tmp_int = nm_device_wimax_get_cinr (NM_DEVICE_WIMAX (device));
- if (tmp_int)
- cinr = g_strdup_printf ("%d dB", tmp_int);
- nmc->allowed_fields[3].value = cinr ? cinr : "";
-
- /* TX Power */
- tmp_int = nm_device_wimax_get_tx_power (NM_DEVICE_WIMAX (device));
- if (tmp_int)
- txpow = g_strdup_printf ("%'.2f dBm", (float) tmp_int / 2.0);
- nmc->allowed_fields[4].value = txpow ? txpow : "";
-
- /* BSID */
- bsid = nm_device_wimax_get_bsid (NM_DEVICE_WIMAX (device));
- nmc->allowed_fields[5].value = bsid ? bsid : "";
-
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
- was_output = TRUE;
- }
-
- /* section NSP */
- if (!strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[6].name)) {
- const GPtrArray *nsps;
- int g, idx = 1;
-
- nmc->allowed_fields = nmc_fields_dev_wimax_list;
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_WIMAX_LIST_FOR_DEV_LIST, nmc->allowed_fields, NULL);
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
-
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
-
- nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
- for (g = 0; nsps && g < nsps->len; g++) {
- NMWimaxNsp *nsp = g_ptr_array_index (nsps, g);
-
- detail_wimax_nsp (nsp, nmc, device, idx++);
- }
- was_output = TRUE;
- }
- }
-#endif
/* IP Setup info */
if (state == NM_DEVICE_STATE_ACTIVATED) {
@@ -840,7 +640,7 @@ show_device_info (gpointer data, gpointer user_data)
GSList *iter;
/* IP4-SETTINGS */
- if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[7].name)) {
+ if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[5].name)) {
nmc->allowed_fields = nmc_fields_dev_list_ip4_settings;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP4_SETTINGS_ALL, nmc->allowed_fields, NULL);
@@ -860,7 +660,7 @@ show_device_info (gpointer data, gpointer user_data)
gateway_str = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
- nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[7].name; /* "IP4-SETTINGS" */
+ nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[5].name; /* "IP4-SETTINGS" */
nmc->allowed_fields[1].value = addr_str;
nmc->allowed_fields[2].value = prefix_str;
nmc->allowed_fields[3].value = gateway_str;
@@ -874,7 +674,7 @@ show_device_info (gpointer data, gpointer user_data)
was_output = TRUE;
}
/* IP4-DNS */
- if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[8].name)) {
+ if (cfg4 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[6].name)) {
array = nm_ip4_config_get_nameservers (cfg4);
if (array) {
int i;
@@ -885,7 +685,7 @@ show_device_info (gpointer data, gpointer user_data)
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
for (i = 0; i < array->len; i++) {
- char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[8].name, i+1);
+ char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[6].name, i+1);
tmp = ip4_address_as_string (g_array_index (array, guint32, i));
nmc->allowed_fields[0].value = dns_name; /* "IP4-DNS<num>" */
nmc->allowed_fields[1].value = tmp;
@@ -900,7 +700,7 @@ show_device_info (gpointer data, gpointer user_data)
}
/* IP6-SETTINGS */
- if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[9].name)) {
+ if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[7].name)) {
nmc->allowed_fields = nmc_fields_dev_list_ip6_settings;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_DEV_LIST_IP6_SETTINGS_ALL, nmc->allowed_fields, NULL);
@@ -916,7 +716,7 @@ show_device_info (gpointer data, gpointer user_data)
prefix_str = g_strdup_printf ("%d", prefix);
gateway_str = ip6_address_as_string (nm_ip6_address_get_gateway (addr));
- nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[9].name; /* "IP6-SETTINGS" */
+ nmc->allowed_fields[0].value = nmc_fields_dev_list_sections[7].name; /* "IP6-SETTINGS" */
nmc->allowed_fields[1].value = addr_str;
nmc->allowed_fields[2].value = prefix_str;
nmc->allowed_fields[3].value = gateway_str;
@@ -930,7 +730,7 @@ show_device_info (gpointer data, gpointer user_data)
was_output = TRUE;
}
/* IP6-DNS */
- if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[10].name)) {
+ if (cfg6 && !strcasecmp (nmc_fields_dev_list_sections[section_idx].name, nmc_fields_dev_list_sections[8].name)) {
int i = 1;
nmc->allowed_fields = nmc_fields_dev_list_ip6_dns;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
@@ -938,7 +738,7 @@ show_device_info (gpointer data, gpointer user_data)
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
for (iter = (GSList *) nm_ip6_config_get_nameservers (cfg6); iter; iter = g_slist_next (iter)) {
- char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[10].name, i++);
+ char *dns_name = g_strdup_printf ("%s%d", nmc_fields_dev_list_sections[8].name, i++);
tmp = ip6_address_as_string (iter->data);
nmc->allowed_fields[0].value = dns_name; /* "IP6-DNS<num>" */
@@ -962,7 +762,7 @@ static void
show_device_status (NMDevice *device, NmCli *nmc)
{
nmc->allowed_fields[0].value = nm_device_get_iface (device);
- nmc->allowed_fields[1].value = device_type_to_string (device);
+ nmc->allowed_fields[1].value = get_device_type (device);
nmc->allowed_fields[2].value = device_state_to_string (nm_device_get_state (device));
nmc->allowed_fields[3].value = nm_object_get_path (NM_OBJECT (device));
@@ -1021,9 +821,6 @@ do_devices_status (NmCli *nmc, int argc, char **argv)
goto error;
}
- if (!nmc_versions_match (nmc))
- goto error;
-
/* Print headers */
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.header_name = _("Status of devices");
@@ -1083,9 +880,6 @@ do_devices_list (NmCli *nmc, int argc, char **argv)
goto error;
}
- if (!nmc_versions_match (nmc))
- goto error;
-
nmc->get_client (nmc);
devices = nm_client_get_devices (nmc->client);
@@ -1236,9 +1030,6 @@ do_device_disconnect (NmCli *nmc, int argc, char **argv)
goto error;
}
- if (!nmc_versions_match (nmc))
- goto error;
-
nmc->get_client (nmc);
devices = nm_client_get_devices (nmc->client);
for (i = 0; devices && (i < devices->len); i++) {
@@ -1364,9 +1155,6 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
goto error;
}
- if (!nmc_versions_match (nmc))
- goto error;
-
/* Print headers */
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
nmc->print_fields.header_name = _("WiFi scan list");
@@ -1495,213 +1283,6 @@ do_device_wifi (NmCli *nmc, int argc, char **argv)
return nmc->return_value;
}
-#if WITH_WIMAX
-static void
-show_nsp_info (NMDevice *device, NmCli *nmc)
-{
- const GPtrArray *nsps;
- int i, idx = 1;
-
- nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
- for (i = 0; nsps && i < nsps->len; i++) {
- NMWimaxNsp *nsp = g_ptr_array_index (nsps, i);
-
- detail_wimax_nsp (nsp, nmc, device, idx++);
- }
-}
-
-static NMCResultCode
-do_device_wimax_list (NmCli *nmc, int argc, char **argv)
-{
- GError *error = NULL;
- NMDevice *device = NULL;
- NMWimaxNsp *nsp = NULL;
- const char *iface = NULL;
- const char *nsp_user = NULL;
- const GPtrArray *devices;
- const GPtrArray *nsps;
- int i, j;
- char *fields_str;
- char *fields_all = NMC_FIELDS_DEV_WIMAX_LIST_ALL;
- char *fields_common = NMC_FIELDS_DEV_WIMAX_LIST_COMMON;
- guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
- guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
- guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
-
- while (argc > 0) {
- if (strcmp (*argv, "iface") == 0) {
- if (next_arg (&argc, &argv) != 0) {
- g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *argv);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- goto error;
- }
- iface = *argv;
- } else if (strcmp (*argv, "nsp") == 0) {
- if (next_arg (&argc, &argv) != 0) {
- g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *argv);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- goto error;
- }
- nsp_user = *argv;
- } else {
- fprintf (stderr, _("Unknown parameter: %s\n"), *argv);
- }
-
- argc--;
- argv++;
- }
-
- if (!nmc->required_fields || strcasecmp (nmc->required_fields, "common") == 0)
- fields_str = fields_common;
- else if (!nmc->required_fields || strcasecmp (nmc->required_fields, "all") == 0)
- fields_str = fields_all;
- else
- fields_str = nmc->required_fields;
-
- nmc->allowed_fields = nmc_fields_dev_wimax_list;
- nmc->print_fields.indices = parse_output_fields (fields_str, nmc->allowed_fields, &error);
-
- if (error) {
- if (error->code == 0)
- g_string_printf (nmc->return_text, _("Error: 'dev wimax': %s"), error->message);
- else
- g_string_printf (nmc->return_text, _("Error: 'dev wimax': %s; allowed fields: %s"), error->message, NMC_FIELDS_DEV_WIMAX_LIST_ALL);
- g_error_free (error);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- goto error;
- }
-
- if (!nmc_is_nm_running (nmc, &error)) {
- if (error) {
- g_string_printf (nmc->return_text, _("Error: Can't find out if NetworkManager is running: %s."), error->message);
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- g_error_free (error);
- } else {
- g_string_printf (nmc->return_text, _("Error: NetworkManager is not running."));
- nmc->return_value = NMC_RESULT_ERROR_NM_NOT_RUNNING;
- }
- goto error;
- }
-
- if (!nmc_versions_match (nmc))
- goto error;
-
- /* Print headers */
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("WiMAX NSP list");
-
- nmc->get_client (nmc);
- devices = nm_client_get_devices (nmc->client);
- if (iface) {
- /* Device specified - list only NSPs of this interface */
- for (i = 0; devices && (i < devices->len); i++) {
- NMDevice *candidate = g_ptr_array_index (devices, i);
- const char *dev_iface = nm_device_get_iface (candidate);
-
- if (!strcmp (dev_iface, iface)) {
- device = candidate;
- break;
- }
- }
-
- if (!device) {
- g_string_printf (nmc->return_text, _("Error: Device '%s' not found."), iface);
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- goto error;
- }
-
- if (NM_IS_DEVICE_WIMAX (device)) {
- if (nsp_user) {
- /* Specific NSP requested - list only that */
- nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
- for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) {
- NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
- const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp);
- char *nsp_up;
-
- nsp_up = g_ascii_strup (nsp_user, -1);
- if (!strcmp (nsp_up, candidate_name))
- nsp = candidate_nsp;
- g_free (nsp_up);
- }
- if (!nsp) {
- g_string_printf (nmc->return_text, _("Error: NSP with name '%s' not found."), nsp_user);
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- goto error;
- }
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
- detail_wimax_nsp (nsp, nmc, device, 1);
- } else {
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
- show_nsp_info (device, nmc);
- }
- } else {
- g_string_printf (nmc->return_text, _("Error: Device '%s' is not a WiMAX device."), iface);
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- goto error;
- }
- } else {
- /* List NSPs for all devices */
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
- if (nsp_user) {
- /* Specific NSP requested - list only that */
- for (i = 0; devices && (i < devices->len); i++) {
- NMDevice *dev = g_ptr_array_index (devices, i);
- int idx = 1;
-
- if (!NM_IS_DEVICE_WIMAX (dev))
- continue;
-
- nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (dev));
- for (j = 0, nsp = NULL; nsps && (j < nsps->len); j++) {
- NMWimaxNsp *candidate_nsp = g_ptr_array_index (nsps, j);
- const char *candidate_name = nm_wimax_nsp_get_name (candidate_nsp);
- char *nsp_up;
-
- nsp_up = g_ascii_strup (nsp_user, -1);
- if (!strcmp (nsp_up, candidate_name)) {
- nsp = candidate_nsp;
- detail_wimax_nsp (nsp, nmc, dev, idx);
- }
- g_free (nsp_up);
- }
- }
- if (!nsp) {
- g_string_printf (nmc->return_text, _("Error: Access point with hwaddr '%s' not found."), nsp_user);
- nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
- goto error;
- }
- } else {
- for (i = 0; devices && (i < devices->len); i++) {
- NMDevice *dev = g_ptr_array_index (devices, i);
- if (NM_IS_DEVICE_WIMAX (dev))
- show_nsp_info (dev, nmc);
- }
- }
- }
-
-error:
- return nmc->return_value;
-}
-
-static NMCResultCode
-do_device_wimax (NmCli *nmc, int argc, char **argv)
-{
- if (argc == 0)
- nmc->return_value = do_device_wimax_list (nmc, argc-1, argv+1);
- else if (argc > 0) {
- if (matches (*argv, "list") == 0) {
- nmc->return_value = do_device_wimax_list (nmc, argc-1, argv+1);
- }
- else {
- g_string_printf (nmc->return_text, _("Error: 'dev wimax' command '%s' is not valid."), *argv);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- }
- }
-
- return nmc->return_value;
-}
-#endif
NMCResultCode
do_devices (NmCli *nmc, int argc, char **argv)
@@ -1733,13 +1314,6 @@ do_devices (NmCli *nmc, int argc, char **argv)
goto opt_error;
nmc->return_value = do_device_wifi (nmc, argc-1, argv+1);
}
-#if WITH_WIMAX
- else if (matches (*argv, "wimax") == 0) {
- if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
- goto opt_error;
- nmc->return_value = do_device_wimax (nmc, argc-1, argv+1);
- }
-#endif
else if (strcmp (*argv, "help") == 0) {
usage ();
}
diff --git a/cli/src/network-manager.c b/cli/src/network-manager.c
index 5ecfde3a1..e695c0e42 100644
--- a/cli/src/network-manager.c
+++ b/cli/src/network-manager.c
@@ -17,8 +17,6 @@
* (C) Copyright 2010 - 2011 Red Hat, Inc.
*/
-#include "config.h"
-
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -35,27 +33,19 @@
/* Available fields for 'nm status' */
static NmcOutputField nmc_fields_nm_status[] = {
{"RUNNING", N_("RUNNING"), 15, NULL, 0}, /* 0 */
- {"VERSION", N_("VERSION"), 10, NULL, 0}, /* 1 */
- {"STATE", N_("STATE"), 15, NULL, 0}, /* 2 */
- {"NET-ENABLED", N_("NET-ENABLED"), 13, NULL, 0}, /* 3 */
- {"WIFI-HARDWARE", N_("WIFI-HARDWARE"), 15, NULL, 0}, /* 4 */
- {"WIFI", N_("WIFI"), 10, NULL, 0}, /* 5 */
- {"WWAN-HARDWARE", N_("WWAN-HARDWARE"), 15, NULL, 0}, /* 6 */
- {"WWAN", N_("WWAN"), 10, NULL, 0}, /* 7 */
- {"WIMAX-HARDWARE", N_("WIMAX-HARDWARE"), 15, NULL, 0}, /* 8 */
- {"WIMAX", N_("WIMAX"), 10, NULL, 0}, /* 9 */
- {NULL, NULL, 0, NULL, 0}
+ {"STATE", N_("STATE"), 15, NULL, 0}, /* 1 */
+ {"NET-ENABLED", N_("NET-ENABLED"), 13, NULL, 0}, /* 2 */
+ {"WIFI-HARDWARE", N_("WIFI-HARDWARE"), 15, NULL, 0}, /* 3 */
+ {"WIFI", N_("WIFI"), 10, NULL, 0}, /* 4 */
+ {"WWAN-HARDWARE", N_("WWAN-HARDWARE"), 15, NULL, 0}, /* 5 */
+ {"WWAN", N_("WWAN"), 10, NULL, 0}, /* 6 */
+ {NULL, NULL, 0, NULL, 0}
};
-#if WITH_WIMAX
-#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,VERSION,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN,WIMAX-HARDWARE,WIMAX"
-#else
-#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,VERSION,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
-#endif
+#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,NET-ENABLED,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#define NMC_FIELDS_NM_STATUS_COMMON "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#define NMC_FIELDS_NM_NET_ENABLED "NET-ENABLED"
#define NMC_FIELDS_NM_WIFI "WIFI"
#define NMC_FIELDS_NM_WWAN "WWAN"
-#define NMC_FIELDS_NM_WIMAX "WIMAX"
extern GMainLoop *loop;
@@ -71,21 +61,13 @@ static void
usage (void)
{
fprintf (stderr,
- _("Usage: nmcli nm { COMMAND | help }\n\n"
-#if WITH_WIMAX
- " COMMAND := { status | enable | sleep | wifi | wwan | wimax }\n\n"
-#else
- " COMMAND := { status | enable | sleep | wifi | wwan }\n\n"
-#endif
- " status\n"
- " enable [true|false]\n"
- " sleep [true|false]\n"
- " wifi [on|off]\n"
- " wwan [on|off]\n"
-#if WITH_WIMAX
- " wimax [on|off]\n\n"
-#endif
- ));
+ _("Usage: nmcli nm { COMMAND | help }\n\n"
+ " COMMAND := { status | enable | sleep | wifi | wwan }\n\n"
+ " status\n"
+ " enable [true|false]\n"
+ " sleep [true|false]\n"
+ " wifi [on|off]\n"
+ " wwan [on|off]\n\n"));
}
/* quit main loop */
@@ -103,14 +85,8 @@ nm_state_to_string (NMState state)
return _("asleep");
case NM_STATE_CONNECTING:
return _("connecting");
- case NM_STATE_CONNECTED_LOCAL:
- return _("connected (local only)");
- case NM_STATE_CONNECTED_SITE:
- return _("connected (site only)");
- case NM_STATE_CONNECTED_GLOBAL:
+ case NM_STATE_CONNECTED:
return _("connected");
- case NM_STATE_DISCONNECTING:
- return _("disconnecting");
case NM_STATE_DISCONNECTED:
return _("disconnected");
case NM_STATE_UNKNOWN:
@@ -127,9 +103,6 @@ show_nm_status (NmCli *nmc)
const char *net_enabled_str;
const char *wireless_hw_enabled_str, *wireless_enabled_str;
const char *wwan_hw_enabled_str, *wwan_enabled_str;
-#if WITH_WIMAX
- const char *wimax_hw_enabled_str, *wimax_enabled_str;
-#endif
GError *error = NULL;
const char *fields_str;
const char *fields_all = NMC_FIELDS_NM_STATUS_ALL;
@@ -158,11 +131,12 @@ show_nm_status (NmCli *nmc)
return nmc->return_value;
}
+ nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
+ nmc->print_fields.header_name = _("NetworkManager status");
+ print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
+
nm_running = nmc_is_nm_running (nmc, NULL);
if (nm_running) {
- if (!nmc_versions_match (nmc))
- goto error;
-
nmc->get_client (nmc); /* create NMClient */
state = nm_client_get_state (nmc->client);
net_enabled_str = nm_client_networking_get_enabled (nmc->client) ? _("enabled") : _("disabled");
@@ -170,44 +144,22 @@ show_nm_status (NmCli *nmc)
wireless_enabled_str = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
wwan_hw_enabled_str = nm_client_wwan_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
wwan_enabled_str = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
-#if WITH_WIMAX
- wimax_hw_enabled_str = nm_client_wimax_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
- wimax_enabled_str = nm_client_wimax_get_enabled (nmc->client) ? _("enabled") : _("disabled");
-#endif
} else {
-#if WITH_WIMAX
- net_enabled_str = wireless_hw_enabled_str = wireless_enabled_str =
- wwan_hw_enabled_str = wwan_enabled_str = wimax_hw_enabled_str = wimax_enabled_str = _("unknown");
-#else
- net_enabled_str = wireless_hw_enabled_str = wireless_enabled_str =
- wwan_hw_enabled_str = wwan_enabled_str = _("unknown");
-#endif
+ net_enabled_str = wireless_hw_enabled_str = wireless_enabled_str = wwan_hw_enabled_str = wwan_enabled_str = _("unknown");
}
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("NetworkManager status");
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
-
nmc->allowed_fields[0].value = nm_running ? _("running") : _("not running");
- nmc->allowed_fields[1].value = nm_client_get_version (nmc->client);
- nmc->allowed_fields[2].value = nm_state_to_string (state);
- nmc->allowed_fields[3].value = net_enabled_str;
- nmc->allowed_fields[4].value = wireless_hw_enabled_str;
- nmc->allowed_fields[5].value = wireless_enabled_str;
- nmc->allowed_fields[6].value = wwan_hw_enabled_str;
- nmc->allowed_fields[7].value = wwan_enabled_str;
-#if WITH_WIMAX
- nmc->allowed_fields[8].value = wimax_hw_enabled_str;
- nmc->allowed_fields[9].value = wimax_enabled_str;
-#endif
+ nmc->allowed_fields[1].value = nm_state_to_string (state);
+ nmc->allowed_fields[2].value = net_enabled_str;
+ nmc->allowed_fields[3].value = wireless_hw_enabled_str;
+ nmc->allowed_fields[4].value = wireless_enabled_str;
+ nmc->allowed_fields[5].value = wwan_hw_enabled_str;
+ nmc->allowed_fields[6].value = wwan_enabled_str;
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
return NMC_RESULT_SUCCESS;
-
-error:
- return nmc->return_value;
}
/* libnm-glib doesn't provide API fro Sleep method - implement D-Bus call ourselves */
@@ -255,9 +207,6 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
gboolean enable_net;
gboolean enable_wifi;
gboolean enable_wwan;
-#if WITH_WIMAX
- gboolean enable_wimax;
-#endif
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
@@ -293,9 +242,9 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
if (nmc_is_nm_running (nmc, NULL)) {
nmc->get_client (nmc); /* create NMClient */
- nmc->allowed_fields[3].value = nm_client_networking_get_enabled (nmc->client) ? _("enabled") : _("disabled");
+ nmc->allowed_fields[2].value = nm_client_networking_get_enabled (nmc->client) ? _("enabled") : _("disabled");
} else
- nmc->allowed_fields[3].value = _("unknown");
+ nmc->allowed_fields[2].value = _("unknown");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
} else {
@@ -348,9 +297,9 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
if (nmc_is_nm_running (nmc, NULL)) {
nmc->get_client (nmc); /* create NMClient */
- nmc->allowed_fields[5].value = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
+ nmc->allowed_fields[4].value = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
} else
- nmc->allowed_fields[5].value = _("unknown");
+ nmc->allowed_fields[4].value = _("unknown");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
} else {
@@ -386,9 +335,9 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
if (nmc_is_nm_running (nmc, NULL)) {
nmc->get_client (nmc); /* create NMClient */
- nmc->allowed_fields[7].value = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
+ nmc->allowed_fields[6].value = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
} else
- nmc->allowed_fields[7].value = _("unknown");
+ nmc->allowed_fields[6].value = _("unknown");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
} else {
@@ -405,46 +354,6 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
nm_client_wwan_set_enabled (nmc->client, enable_wwan);
}
}
-#if WITH_WIMAX
- else if (matches (*argv, "wimax") == 0) {
- if (next_arg (&argc, &argv) != 0) {
- if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
- goto opt_error;
- /* no argument, show current WiMAX state */
- if (nmc->required_fields && strcasecmp (nmc->required_fields, "WIMAX")) {
- g_string_printf (nmc->return_text, _("Error: '--fields' value '%s' is not valid here; allowed fields: %s"),
- nmc->required_fields, NMC_FIELDS_NM_WIMAX);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- goto end;
- }
- nmc->allowed_fields = nmc_fields_nm_status;
- nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_NM_WIMAX, nmc->allowed_fields, NULL);
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_MAIN_HEADER_ADD | NMC_PF_FLAG_FIELD_NAMES;
- nmc->print_fields.header_name = _("WiMAX enabled");
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
-
- if (nmc_is_nm_running (nmc, NULL)) {
- nmc->get_client (nmc); /* create NMClient */
- nmc->allowed_fields[9].value = nm_client_wimax_get_enabled (nmc->client) ? _("enabled") : _("disabled");
- } else
- nmc->allowed_fields[9].value = _("unknown");
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
- } else {
- if (!strcmp (*argv, "on"))
- enable_wimax = TRUE;
- else if (!strcmp (*argv, "off"))
- enable_wimax = FALSE;
- else {
- g_string_printf (nmc->return_text, _("Error: invalid 'wimax' parameter: '%s'."), *argv);
- nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
- goto end;
- }
- nmc->get_client (nmc); /* create NMClient */
- nm_client_wimax_set_enabled (nmc->client, enable_wimax);
- }
- }
-#endif
else if (strcmp (*argv, "help") == 0) {
usage ();
}
diff --git a/cli/src/nmcli.c b/cli/src/nmcli.c
index f51779e6b..4a5480244 100644
--- a/cli/src/nmcli.c
+++ b/cli/src/nmcli.c
@@ -33,6 +33,9 @@
#include <nm-client.h>
#include <nm-setting-connection.h>
#include <nm-remote-settings.h>
+#include <nm-remote-settings-system.h>
+#include <nm-settings-interface.h>
+#include <nm-settings-connection-interface.h>
#include "nmcli.h"
#include "utils.h"
@@ -68,7 +71,6 @@ usage (const char *prog_name)
" -m[ode] tabular|multiline output mode\n"
" -f[ields] <field1,field2,...>|all|common specify fields to output\n"
" -e[scape] yes|no escape columns separators in values\n"
- " -n[ocheck] don't check nmcli and NetworkManager versions\n"
" -v[ersion] show program version\n"
" -h[elp] print this help\n\n"
"OBJECT\n"
@@ -201,8 +203,6 @@ parse_command_line (NmCli *nmc, int argc, char **argv)
return nmc->return_value;
}
nmc->required_fields = g_strdup (argv[1]);
- } else if (matches (opt, "-nocheck") == 0) {
- nmc->nocheck_ver = TRUE;
} else if (matches (opt, "-version") == 0) {
printf (_("nmcli tool, version %s\n"), NMCLI_VERSION);
return NMC_RESULT_SUCCESS;
@@ -275,8 +275,13 @@ nmc_init (NmCli *nmc)
nmc->timeout = 10;
nmc->system_settings = NULL;
+ nmc->user_settings = NULL;
+
nmc->system_settings_running = FALSE;
+ nmc->user_settings_running = FALSE;
+
nmc->system_connections = NULL;
+ nmc->user_connections = NULL;
nmc->should_wait = FALSE;
nmc->nowait_flag = TRUE;
@@ -287,7 +292,6 @@ nmc_init (NmCli *nmc)
nmc->required_fields = NULL;
nmc->allowed_fields = NULL;
memset (&nmc->print_fields, '\0', sizeof (NmcPrintFields));
- nmc->nocheck_ver = FALSE;
}
static void
@@ -298,7 +302,10 @@ nmc_cleanup (NmCli *nmc)
g_string_free (nmc->return_text, TRUE);
if (nmc->system_settings) g_object_unref (nmc->system_settings);
+ if (nmc->user_settings) g_object_unref (nmc->user_settings);
+
g_slist_free (nmc->system_connections);
+ g_slist_free (nmc->user_connections);
g_free (nmc->required_fields);
if (nmc->print_fields.indices)
diff --git a/cli/src/nmcli.h b/cli/src/nmcli.h
index 90091b365..a208e79e7 100644
--- a/cli/src/nmcli.h
+++ b/cli/src/nmcli.h
@@ -24,6 +24,7 @@
#include <nm-client.h>
#include <nm-remote-settings.h>
+#include <nm-remote-settings-system.h>
/* nmcli exit codes */
typedef enum {
@@ -49,10 +50,7 @@ typedef enum {
NMC_RESULT_ERROR_DEV_DISCONNECT = 6,
/* NetworkManager is not running */
- NMC_RESULT_ERROR_NM_NOT_RUNNING = 7,
-
- /* nmcli and NetworkManager versions mismatch */
- NMC_RESULT_ERROR_VERSIONS_MISMATCH = 8
+ NMC_RESULT_ERROR_NM_NOT_RUNNING = 7
} NMCResultCode;
typedef enum {
@@ -97,9 +95,14 @@ typedef struct _NmCli {
int timeout; /* Operation timeout */
- NMRemoteSettings *system_settings; /* System settings */
+ NMRemoteSettingsSystem *system_settings; /* System settings */
+ NMRemoteSettings *user_settings; /* User settings */
+
gboolean system_settings_running; /* Is system settings service running? */
+ gboolean user_settings_running; /* Is user settings service running? */
+
GSList *system_connections; /* List of system connections */
+ GSList *user_connections; /* List of user connections */
gboolean should_wait; /* Indication that nmcli should not end yet */
gboolean nowait_flag; /* '--nowait' option; used for passing to callbacks */
@@ -110,7 +113,6 @@ typedef struct _NmCli {
char *required_fields; /* Required fields in output: '--fields' option */
NmcOutputField *allowed_fields; /* Array of allowed fields for particular commands */
NmcPrintFields print_fields; /* Structure with field indices to print */
- gboolean nocheck_ver; /* Don't check nmcli and NM versions: option '--nocheck' */
} NmCli;
#endif /* NMC_NMCLI_H */
diff --git a/cli/src/settings.c b/cli/src/settings.c
index c23853702..8b6287647 100644
--- a/cli/src/settings.c
+++ b/cli/src/settings.c
@@ -17,8 +17,6 @@
* (C) Copyright 2010 Red Hat, Inc.
*/
-#include "config.h"
-
#include <glib.h>
#include <glib/gi18n.h>
#include <libnm-util/nm-utils.h>
@@ -95,7 +93,8 @@ static NmcOutputField nmc_fields_setting_8021X[] = {
SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, 20), /* 18 */
SETTING_FIELD (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD, 20), /* 19 */
SETTING_FIELD (NM_SETTING_802_1X_PIN, 8), /* 20 */
- SETTING_FIELD (NM_SETTING_802_1X_SYSTEM_CA_CERTS, 17), /* 21 */
+ SETTING_FIELD (NM_SETTING_802_1X_PSK, 8), /* 21 */
+ SETTING_FIELD (NM_SETTING_802_1X_SYSTEM_CA_CERTS, 17), /* 22 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTING_802_1X_ALL "name"","\
@@ -119,6 +118,7 @@ static NmcOutputField nmc_fields_setting_8021X[] = {
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY","\
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD","\
NM_SETTING_802_1X_PIN","\
+ NM_SETTING_802_1X_PSK","\
NM_SETTING_802_1X_SYSTEM_CA_CERTS
#define NMC_FIELDS_SETTING_802_1X_COMMON NMC_FIELDS_SETTING_802_1X_ALL
@@ -402,18 +402,6 @@ static NmcOutputField nmc_fields_setting_vpn[] = {
NM_SETTING_VPN_SECRETS
#define NMC_FIELDS_SETTING_VPN_COMMON NMC_FIELDS_SETTING_VPN_ALL
-/* Available fields for NM_SETTING_WIMAX_SETTING_NAME */
-static NmcOutputField nmc_fields_setting_wimax[] = {
- SETTING_FIELD ("name", 6), /* 0 */
- SETTING_FIELD (NM_SETTING_WIMAX_MAC_ADDRESS, 19), /* 1 */
- SETTING_FIELD (NM_SETTING_WIMAX_NETWORK_NAME, 40), /* 2 */
- {NULL, NULL, 0, NULL, 0}
-};
-#define NMC_FIELDS_SETTING_WIMAX_ALL "name"","\
- NM_SETTING_WIMAX_MAC_ADDRESS","\
- NM_SETTING_WIMAX_NETWORK_NAME
-#define NMC_FIELDS_SETTING_WIMAX_COMMON NMC_FIELDS_SETTING_WIMAX_ALL
-
static char *
wep_key_type_to_string (NMWepKeyType type)
@@ -660,7 +648,8 @@ setting_802_1X_details (NMSetting *setting, NmCli *nmc)
nmc->allowed_fields[18].value = phase2_private_key_str;
nmc->allowed_fields[19].value = nm_setting_802_1x_get_phase2_private_key_password (s_8021X);
nmc->allowed_fields[20].value = nm_setting_802_1x_get_pin (s_8021X);
- nmc->allowed_fields[21].value = nm_setting_802_1x_get_system_ca_certs (s_8021X) ? _("yes") : _("no");
+ nmc->allowed_fields[21].value = nm_setting_802_1x_get_psk (s_8021X);
+ nmc->allowed_fields[22].value = nm_setting_802_1x_get_system_ca_certs (s_8021X) ? _("yes") : _("no");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
@@ -1392,37 +1381,3 @@ setting_vpn_details (NMSetting *setting, NmCli *nmc)
return TRUE;
}
-gboolean
-setting_wimax_details (NMSetting *setting, NmCli *nmc)
-{
- NMSettingWimax *s_wimax;
- const GByteArray *mac;
- char *device_mac_str = NULL;
- guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
- guint32 multiline_flag = nmc->multiline_output ? NMC_PF_FLAG_MULTILINE : 0;
- guint32 escape_flag = nmc->escape_values ? NMC_PF_FLAG_ESCAPE : 0;
-
- g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), FALSE);
- s_wimax = (NMSettingWimax *) setting;
-
- nmc->allowed_fields = nmc_fields_setting_wimax;
- nmc->print_fields.indices = parse_output_fields (NMC_FIELDS_SETTING_WIMAX_ALL, nmc->allowed_fields, NULL);
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_FIELD_NAMES;
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print field names */
-
- mac = nm_setting_wimax_get_mac_address (s_wimax);
- if (mac)
- device_mac_str = g_strdup_printf ("%02X:%02X:%02X:%02X:%02X:%02X", mac->data[0], mac->data[1], mac->data[2], mac->data[3], mac->data[4], mac->data[5]);
-
- nmc->allowed_fields[0].value = NM_SETTING_WIMAX_SETTING_NAME;
- nmc->allowed_fields[1].value = device_mac_str;
- nmc->allowed_fields[2].value = nm_setting_wimax_get_network_name (s_wimax);
-
- nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag | NMC_PF_FLAG_SECTION_PREFIX;
- print_fields (nmc->print_fields, nmc->allowed_fields); /* Print values */
-
- g_free (device_mac_str);
-
- return TRUE;
-}
-
diff --git a/cli/src/settings.h b/cli/src/settings.h
index 4901bf272..aec71551d 100644
--- a/cli/src/settings.h
+++ b/cli/src/settings.h
@@ -35,7 +35,6 @@
#include <nm-setting-bluetooth.h>
#include <nm-setting-olpc-mesh.h>
#include <nm-setting-vpn.h>
-#include <nm-setting-wimax.h>
#include "nmcli.h"
#include "utils.h"
@@ -56,6 +55,5 @@ gboolean setting_cdma_details (NMSetting *setting, NmCli *nmc);
gboolean setting_bluetooth_details (NMSetting *setting, NmCli *nmc);
gboolean setting_olpc_mesh_details (NMSetting *setting, NmCli *nmc);
gboolean setting_vpn_details (NMSetting *setting, NmCli *nmc);
-gboolean setting_wimax_details (NMSetting *setting, NmCli *nmc);
#endif /* NMC_SETTINGS_H */
diff --git a/cli/src/utils.c b/cli/src/utils.c
index 3c4e4f369..bcc51bbd8 100644
--- a/cli/src/utils.c
+++ b/cli/src/utils.c
@@ -17,9 +17,6 @@
* (C) Copyright 2010 - 2011 Red Hat, Inc.
*/
-/* Generated configuration file */
-#include "config.h"
-
#include <stdio.h>
#include <string.h>
@@ -354,49 +351,3 @@ done:
return has_owner;
}
-/*
-* Compare versions of nmcli and NM daemon.
-* Return: TRUE - the versions match (when only major and minor match, print a warning)
-* FALSE - versions mismatch
-*/
-gboolean
-nmc_versions_match (NmCli *nmc)
-{
- const char *nm_ver = NULL;
- const char *dot;
- gboolean match = FALSE;
-
- g_return_val_if_fail (nmc != NULL, FALSE);
-
- /* --nocheck option - don't compare the versions */
- if (nmc->nocheck_ver)
- return TRUE;
-
- nmc->get_client (nmc);
- nm_ver = nm_client_get_version (nmc->client);
- if (nm_ver) {
- if (!strcmp (nm_ver, VERSION))
- match = TRUE;
- else {
- dot = strchr (nm_ver, '.');
- if (dot) {
- dot = strchr (dot + 1, '.');
- if (dot && !strncmp (nm_ver, VERSION, dot-nm_ver)) {
- fprintf(stderr,
- _("Warning: nmcli (%s) and NetworkManager (%s) versions don't match. Use --nocheck to suppress the warning.\n"),
- VERSION, nm_ver);
- match = TRUE;
- }
- }
- }
- }
-
- if (!match) {
- g_string_printf (nmc->return_text, _("Error: nmcli (%s) and NetworkManager (%s) versions don't match. Force execution using --nocheck, but the results are unpredictable."),
- VERSION, nm_ver ? nm_ver : _("unknown"));
- nmc->return_value = NMC_RESULT_ERROR_VERSIONS_MISMATCH;
- }
-
- return match;
-}
-
diff --git a/cli/src/utils.h b/cli/src/utils.h
index 467054a28..da058f279 100644
--- a/cli/src/utils.h
+++ b/cli/src/utils.h
@@ -33,6 +33,5 @@ GArray *parse_output_fields (const char *fields_str, const NmcOutputField fields
gboolean nmc_terse_option_check (NMCPrintOutput print_output, const char *fields, GError **error);
void print_fields (const NmcPrintFields fields, const NmcOutputField field_values[]);
gboolean nmc_is_nm_running (NmCli *nmc, GError **error);
-gboolean nmc_versions_match (NmCli *nmc);
#endif /* NMC_UTILS_H */