Commit 0587ef11 authored by Dan Williams's avatar Dan Williams

Merge remote branch 'origin/master' into wimax

parents b2f9747d 15a9f29a
......@@ -93,12 +93,14 @@ libnm-util/tests/test-need-secrets
libnm-util/tests/test-setting-8021x
src/tests/test-dhcp-options
src/tests/test-policy-hosts
src/dhcp-manager/tests/test-dhcp-dhclient
system-settings/plugins/keyfile/tests/test-keyfile
system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh
system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh-utils
system-settings/plugins/ifcfg-rh/tests/network-scripts/Test_Write_*
system-settings/plugins/ifcfg-rh/tests/network-scripts/*-Test_Write_*
system-settings/plugins/ifupdown/tests/test-ifupdown
m4/gtk-doc.m4
m4/intltool.m4
......@@ -106,5 +108,9 @@ m4/libtool.m4
m4/lt*.m4
policy/org.freedesktop.network-manager-settings.system.policy
policy/org.freedesktop.NetworkManager.policy
data/NetworkManager.service
data/org.freedesktop.NetworkManager.service
cli/src/nmcli
......@@ -1317,7 +1317,7 @@
2008-09-30 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerPolicy.c
- (lookup_thread_worker): don't store the idle handler ID becuase the
- (lookup_thread_worker): don't store the idle handler ID because the
idle handler could have already run and freed the LookupThread
structure
......@@ -8391,7 +8391,7 @@
internally; clients should provide a setting that applies to
the device with 'autoconnect: True'. Problem was that these
internally auto-created connections don't have a proxy or service
name becuase they weren't created by a settings daemon, and therefore
name because they weren't created by a settings daemon, and therefore
clients have no idea what to do with them.
2007-10-03 Dan Williams <dcbw@redhat.com>
......@@ -9794,7 +9794,7 @@
* libnm-glib/nm-settings.c
libnm-glib/nm-settings.h
- make the dbus path a property of the object, and autogenerate it.
It can't be composed of the 'id' field becuase that's not available
It can't be composed of the 'id' field because that's not available
yet during the GObject creation in nm_connection_settings_init()
2007-08-29 Dan Williams <dcbw@redhat.com>
......
......@@ -10,6 +10,7 @@ SUBDIRS = \
cli \
tools \
policy \
data \
initscript \
test \
po \
......@@ -24,7 +25,11 @@ EXTRA_DIST = \
intltool-merge.in \
intltool-update.in
DISTCHECK_CONFIGURE_FLAGS = --with-tests=yes --with-docs=yes --with-udev-dir=$$dc_install_base/lib/udev
DISTCHECK_CONFIGURE_FLAGS = \
--with-tests=yes \
--with-docs=yes \
--with-udev-dir=$$dc_install_base/lib/udev \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
DISTCLEANFILES = intltool-extract intltool-merge intltool-update
......
......@@ -66,11 +66,11 @@ those drivers that are shipped with the upstream Linux kernel, because only
those drivers can be easily fixed and debugged. ndiswrapper, vendor binary
drivers, or other out-of-tree drivers may or may not work well with
NetworkManager, precisely because they have not been vetted and improved by the
open-source community, and becuase problems in these drivers usually cannot
open-source community, and because problems in these drivers usually cannot
be fixed.
Sometimes, command-line tools like 'iwconfig' will work, but NetworkManager will
fail. This is again often due to buggy drivers, becuase these drivers simply
fail. This is again often due to buggy drivers, because these drivers simply
aren't expecting the dynamic requests that NetworkManager and wpa_supplicant
make. Driver bugs should be filed in the bug tracker of the distribution being
run, since often distributions customize their kernel and drivers.
......
......@@ -60,7 +60,7 @@ nm_dispatcher_action_LDADD = \
$(GLIB_LIBS)
nm-dispatcher-glue.h: nm-dispatcher.xml
dbus-binding-tool --prefix=nm_dispatcher --mode=glib-server --output=$@ $<
$(AM_V_GEN) dbus-binding-tool --prefix=nm_dispatcher --mode=glib-server --output=$@ $<
udevrulesdir = $(UDEV_BASE_DIR)/rules.d
udevrules_DATA = 77-nm-olpc-mesh.rules
......
......@@ -489,6 +489,10 @@ nm_dispatcher_action (Handler *h,
if (!d->persist)
d->quit_timeout = g_timeout_add_seconds (10, quit_timeout_cb, NULL);
/* Hostname changes don't require a device nor contain a connection */
if (!strcmp (action, "hostname"))
goto dispatch;
connection = nm_connection_new_from_hash (connection_hash, error);
if (connection) {
NMSettingConnection *s_con;
......@@ -506,10 +510,6 @@ nm_dispatcher_action (Handler *h,
*error = NULL;
}
/* Hostname changes don't require a device */
if (!strcmp (action, "hostname"))
goto dispatch;
/* interface name */
value = g_hash_table_lookup (device_props, NMD_DEVICE_PROPS_INTERFACE);
if (!value || !G_VALUE_HOLDS_STRING (value)) {
......
......@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <netinet/ether.h>
......@@ -64,9 +65,10 @@ static NmcOutputField nmc_fields_con_status[] = {
{"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,SCOPE,DEFAULT,VPN,DBUS-SERVICE,SPEC-OBJECT"
#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' */
......@@ -79,9 +81,10 @@ static NmcOutputField nmc_fields_con_list[] = {
{"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,SCOPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,READONLY"
#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"
......@@ -375,6 +378,7 @@ show_connection (NMConnection *data, gpointer user_data)
timestamp = nm_setting_connection_get_timestamp (s_con);
timestamp_str = g_strdup_printf ("%" G_GUINT64_FORMAT, timestamp);
strftime (timestamp_real_str, sizeof (timestamp_real_str), "%c", localtime ((time_t *) &timestamp));
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);
......@@ -383,6 +387,7 @@ show_connection (NMConnection *data, gpointer user_data)
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);
......@@ -603,6 +608,7 @@ show_active_connection (gpointer data, gpointer user_data)
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);
......@@ -711,10 +717,11 @@ check_ethernet_compatible (NMDeviceEthernet *device, NMConnection *connection, G
if (s_wired) {
const GByteArray *mac;
const char *device_mac_str;
struct ether_addr *device_mac;
struct ether_addr *device_mac = NULL;
device_mac_str = nm_device_ethernet_get_hw_address (device);
device_mac = ether_aton (device_mac_str);
device_mac_str = nm_device_ethernet_get_permanent_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.");
return FALSE;
......@@ -760,10 +767,11 @@ check_wifi_compatible (NMDeviceWifi *device, NMConnection *connection, GError **
if (s_wireless) {
const GByteArray *mac;
const char *device_mac_str;
struct ether_addr *device_mac;
struct ether_addr *device_mac = NULL;
device_mac_str = nm_device_wifi_get_hw_address (device);
device_mac = ether_aton (device_mac_str);
device_mac_str = nm_device_wifi_get_permanent_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.");
return FALSE;
......@@ -1288,7 +1296,7 @@ activate_connection_cb (gpointer user_data, const char *path, GError *error)
printf (_("Active connection state: %s\n"), active_connection_state_to_string (state));
printf (_("Active connection path: %s\n"), orig_path);
if (!orig_nmc->should_wait || 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 {
......@@ -1415,7 +1423,10 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
goto error;
}
nmc->should_wait = wait;
/* 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,
is_system ? NM_DBUS_SERVICE_SYSTEM_SETTINGS : NM_DBUS_SERVICE_USER_SETTINGS,
con_path,
......@@ -1504,6 +1515,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
else {
fprintf (stderr, _("Warning: Connection not active\n"));
}
sleep (1); /* Don't quit immediatelly and give NM time to check our permissions */
error:
nmc->should_wait = FALSE;
......
This diff is collapsed.
......@@ -34,14 +34,16 @@
static NmcOutputField nmc_fields_nm_status[] = {
{"RUNNING", N_("RUNNING"), 15, NULL, 0}, /* 0 */
{"STATE", N_("STATE"), 15, NULL, 0}, /* 1 */
{"WIFI-HARDWARE", N_("WIFI-HARDWARE"), 15, NULL, 0}, /* 2 */
{"WIFI", N_("WIFI"), 10, NULL, 0}, /* 3 */
{"WWAN-HARDWARE", N_("WWAN-HARDWARE"), 15, NULL, 0}, /* 4 */
{"WWAN", N_("WWAN"), 10, NULL, 0}, /* 5 */
{"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}
};
#define NMC_FIELDS_NM_STATUS_ALL "RUNNING,STATE,WIFI-HARDWARE,WIFI,WWAN-HARDWARE,WWAN"
#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"
......@@ -60,10 +62,10 @@ usage (void)
{
fprintf (stderr,
_("Usage: nmcli nm { COMMAND | help }\n\n"
" COMMAND := { status | sleep | wakeup | wifi | wwan }\n\n"
" COMMAND := { status | enable | sleep | wifi | wwan }\n\n"
" status\n"
" sleep\n"
" wakeup\n"
" enable [true|false]\n"
" sleep [true|false]\n"
" wifi [on|off]\n"
" wwan [on|off]\n\n"));
}
......@@ -97,6 +99,7 @@ static NMCResultCode
show_nm_status (NmCli *nmc)
{
gboolean nm_running;
gboolean net_enabled;
NMState state;
const char *wireless_hw_enabled_str, *wireless_enabled_str;
const char *wwan_hw_enabled_str, *wwan_enabled_str;
......@@ -136,6 +139,7 @@ show_nm_status (NmCli *nmc)
nm_running = nm_client_get_manager_running (nmc->client);
state = nm_client_get_state (nmc->client);
net_enabled = nm_client_networking_get_enabled (nmc->client);
if (nm_running) {
wireless_hw_enabled_str = nm_client_wireless_hardware_get_enabled (nmc->client) ? _("enabled") : _("disabled");
wireless_enabled_str = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
......@@ -147,10 +151,11 @@ show_nm_status (NmCli *nmc)
nmc->allowed_fields[0].value = nm_running ? _("running") : _("not running");
nmc->allowed_fields[1].value = nm_state_to_string (state);
nmc->allowed_fields[2].value = wireless_hw_enabled_str;
nmc->allowed_fields[3].value = wireless_enabled_str;
nmc->allowed_fields[4].value = wwan_hw_enabled_str;
nmc->allowed_fields[5].value = wwan_enabled_str;
nmc->allowed_fields[2].value = net_enabled ? _("enabled") : _("disabled");
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 */
......@@ -158,12 +163,49 @@ show_nm_status (NmCli *nmc)
return NMC_RESULT_SUCCESS;
}
/* libnm-glib doesn't provide API fro Sleep method - implement D-Bus call ourselves */
static void networking_set_sleep (NmCli *nmc, gboolean in_sleep)
{
DBusGConnection *connection = NULL;
DBusGProxy *proxy = NULL;
GError *err = NULL;
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
if (!connection) {
g_string_printf (nmc->return_text, _("Error: Couldn't connect to system bus: %s"), err->message);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
g_error_free (err);
goto gone;
}
proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager");
if (!proxy) {
g_string_printf (nmc->return_text, _("Error: Couldn't create D-Bus object proxy."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
goto gone;
}
if (!dbus_g_proxy_call (proxy, "Sleep", &err, G_TYPE_BOOLEAN, in_sleep, G_TYPE_INVALID, G_TYPE_INVALID)) {
g_string_printf (nmc->return_text, _("Error in sleep: %s"), err->message);
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
g_error_free (err);
}
gone:
if (connection) dbus_g_connection_unref (connection);
if (proxy) g_object_unref (proxy);
}
/* entry point function for global network manager related commands 'nmcli nm' */
NMCResultCode
do_network_manager (NmCli *nmc, int argc, char **argv)
{
GError *error = NULL;
gboolean sleep_flag;
gboolean enable_net;
gboolean enable_wifi;
gboolean enable_wwan;
guint32 mode_flag = (nmc->print_output == NMC_PRINT_PRETTY) ? NMC_PF_FLAG_PRETTY : (nmc->print_output == NMC_PRINT_TERSE) ? NMC_PF_FLAG_TERSE : 0;
......@@ -186,11 +228,54 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
goto opt_error;
nmc->return_value = show_nm_status (nmc);
}
else if (matches (*argv, "sleep") == 0) {
nm_client_sleep (nmc->client, TRUE);
else if (matches (*argv, "enable") == 0) {
if (next_arg (&argc, &argv) != 0) {
/* no argument, show current state of networking */
if (!nmc_terse_option_check (nmc->print_output, nmc->required_fields, &error))
goto opt_error;
if (nmc->required_fields && strcasecmp (nmc->required_fields, "NET-ENABLED")) {
g_string_printf (nmc->return_text, _("Error: '--fields' value '%s' is not valid here; allowed fields: %s"),
nmc->required_fields, NMC_FIELDS_NM_NET_ENABLED);
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_NET_ENABLED, 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 = _("Networking enabled");
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
nmc->allowed_fields[2].value = nm_client_networking_get_enabled (nmc->client) ? _("enabled") : _("disabled");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
} else {
if (!strcmp (*argv, "true"))
enable_net = TRUE;
else if (!strcmp (*argv, "false"))
enable_net = FALSE;
else {
g_string_printf (nmc->return_text, _("Error: invalid 'enable' parameter: '%s'; use 'true' or 'false'."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
nm_client_networking_set_enabled (nmc->client, enable_net);
}
}
else if (matches (*argv, "wakeup") == 0) {
nm_client_sleep (nmc->client, FALSE);
else if (matches (*argv, "sleep") == 0) {
if (next_arg (&argc, &argv) != 0) {
g_string_printf (nmc->return_text, _("Error: Sleeping status is not exported by NetworkManager."));
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
} else {
if (!strcmp (*argv, "true"))
sleep_flag = TRUE;
else if (!strcmp (*argv, "false"))
sleep_flag = FALSE;
else {
g_string_printf (nmc->return_text, _("Error: invalid 'sleep' parameter: '%s'; use 'true' or 'false'."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
goto end;
}
networking_set_sleep (nmc, sleep_flag);
}
}
else if (matches (*argv, "wifi") == 0) {
if (next_arg (&argc, &argv) != 0) {
......@@ -208,7 +293,7 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
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 enabled");
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
nmc->allowed_fields[3].value = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
nmc->allowed_fields[4].value = nm_client_wireless_get_enabled (nmc->client) ? _("enabled") : _("disabled");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
} else {
......@@ -240,7 +325,7 @@ do_network_manager (NmCli *nmc, int argc, char **argv)
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 = _("WWAN enabled");
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
nmc->allowed_fields[5].value = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
nmc->allowed_fields[6].value = nm_client_wwan_get_enabled (nmc->client) ? _("enabled") : _("disabled");
nmc->print_fields.flags = multiline_flag | mode_flag | escape_flag;
print_fields (nmc->print_fields, nmc->allowed_fields); /* Print header */
} else {
......
......@@ -286,6 +286,7 @@ nmc_init (NmCli *nmc)
nmc->user_connections = NULL;
nmc->should_wait = FALSE;
nmc->nowait_flag = TRUE;
nmc->print_output = NMC_PRINT_NORMAL;
nmc->multiline_output = FALSE;
nmc->mode_specified = FALSE;
......
......@@ -102,6 +102,7 @@ typedef struct _NmCli {
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 */
NMCPrintOutput print_output; /* Output mode */
gboolean multiline_output; /* Multiline output instead of default tabular */
gboolean mode_specified; /* Whether tabular/multiline mode was specified via '--mode' option */
......
......@@ -50,13 +50,14 @@ static NmcOutputField nmc_fields_setting_connection[] = {
/* Available fields for NM_SETTING_WIRED_SETTING_NAME */
static NmcOutputField nmc_fields_setting_wired[] = {
SETTING_FIELD ("name", 17), /* 0 */
SETTING_FIELD (NM_SETTING_WIRED_PORT, 8), /* 1 */
SETTING_FIELD (NM_SETTING_WIRED_SPEED, 10), /* 2 */
SETTING_FIELD (NM_SETTING_WIRED_DUPLEX, 10), /* 3 */
SETTING_FIELD (NM_SETTING_WIRED_AUTO_NEGOTIATE, 15), /* 4 */
SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS, 19), /* 5 */
SETTING_FIELD (NM_SETTING_WIRED_MTU, 6), /* 6 */
SETTING_FIELD ("name", 17), /* 0 */
SETTING_FIELD (NM_SETTING_WIRED_PORT, 8), /* 1 */
SETTING_FIELD (NM_SETTING_WIRED_SPEED, 10), /* 2 */
SETTING_FIELD (NM_SETTING_WIRED_DUPLEX, 10), /* 3 */
SETTING_FIELD (NM_SETTING_WIRED_AUTO_NEGOTIATE, 15), /* 4 */
SETTING_FIELD (NM_SETTING_WIRED_MAC_ADDRESS, 19), /* 5 */
SETTING_FIELD (NM_SETTING_WIRED_CLONED_MAC_ADDRESS, 19), /* 6 */
SETTING_FIELD (NM_SETTING_WIRED_MTU, 6), /* 7 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTING_WIRED_ALL "name"","\
......@@ -65,6 +66,7 @@ static NmcOutputField nmc_fields_setting_wired[] = {
NM_SETTING_WIRED_DUPLEX","\
NM_SETTING_WIRED_AUTO_NEGOTIATE","\
NM_SETTING_WIRED_MAC_ADDRESS","\
NM_SETTING_WIRED_CLONED_MAC_ADDRESS","\
NM_SETTING_WIRED_MTU
#define NMC_FIELDS_SETTING_WIRED_COMMON NMC_FIELDS_SETTING_WIRED_ALL
......@@ -131,9 +133,10 @@ static NmcOutputField nmc_fields_setting_wireless[] = {
SETTING_FIELD (NM_SETTING_WIRELESS_RATE, 10), /* 6 */
SETTING_FIELD (NM_SETTING_WIRELESS_TX_POWER, 10), /* 7 */
SETTING_FIELD (NM_SETTING_WIRELESS_MAC_ADDRESS, 19), /* 8 */
SETTING_FIELD (NM_SETTING_WIRELESS_MTU, 6), /* 9 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEEN_BSSIDS, 35), /* 10 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEC, 10), /* 11 */
SETTING_FIELD (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, 19), /* 9 */
SETTING_FIELD (NM_SETTING_WIRELESS_MTU, 6), /* 10 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEEN_BSSIDS, 35), /* 11 */
SETTING_FIELD (NM_SETTING_WIRELESS_SEC, 10), /* 12 */
{NULL, NULL, 0, NULL, 0}
};
#define NMC_FIELDS_SETTING_WIRELESS_ALL "name"","\
......@@ -145,6 +148,7 @@ static NmcOutputField nmc_fields_setting_wireless[] = {
NM_SETTING_WIRELESS_RATE","\
NM_SETTING_WIRELESS_TX_POWER","\
NM_SETTING_WIRELESS_MAC_ADDRESS","\
NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS","\
NM_SETTING_WIRELESS_MTU","\
NM_SETTING_WIRELESS_SEEN_BSSIDS","\
NM_SETTING_WIRELESS_SEC
......@@ -518,7 +522,7 @@ setting_wired_details (NMSetting *setting, NmCli *nmc)
{
NMSettingWired *s_wired;
const GByteArray *mac;
char *speed_str, *mtu_str, *mac_str = NULL;
char *speed_str, *mtu_str, *device_mac_str = NULL, *cloned_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;
......@@ -535,21 +539,26 @@ setting_wired_details (NMSetting *setting, NmCli *nmc)
mtu_str = g_strdup_printf ("%d", nm_setting_wired_get_mtu (s_wired));
mac = nm_setting_wired_get_mac_address (s_wired);
if (mac)
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]);
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]);
mac = nm_setting_wired_get_cloned_mac_address (s_wired);
if (mac)
cloned_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_WIRED_SETTING_NAME;
nmc->allowed_fields[1].value = nm_setting_wired_get_port (s_wired);
nmc->allowed_fields[2].value = speed_str;
nmc->allowed_fields[3].value = nm_setting_wired_get_duplex (s_wired);
nmc->allowed_fields[4].value = nm_setting_wired_get_auto_negotiate (s_wired) ? _("yes") : _("no");
nmc->allowed_fields[5].value = mac_str;
nmc->allowed_fields[6].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
nmc->allowed_fields[5].value = device_mac_str;
nmc->allowed_fields[6].value = cloned_mac_str;
nmc->allowed_fields[7].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
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 (speed_str);
g_free (mac_str);
g_free (device_mac_str);
g_free (cloned_mac_str);
g_free (mtu_str);
return TRUE;
......@@ -663,7 +672,7 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
int i;
const GByteArray *ssid, *bssid, *mac;
char *ssid_str, *channel_str, *rate_str, *tx_power_str, *mtu_str;
char *mac_str = NULL, *bssid_str = NULL;
char *device_mac_str = NULL, *cloned_mac_str = NULL, *bssid_str = NULL;
GString *seen_bssids;
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;
......@@ -688,7 +697,10 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
mtu_str = g_strdup_printf ("%d", nm_setting_wireless_get_mtu (s_wireless));
mac = nm_setting_wireless_get_mac_address (s_wireless);
if (mac)
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]);
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]);
mac = nm_setting_wireless_get_cloned_mac_address (s_wireless);
if (mac)
cloned_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]);
seen_bssids = g_string_new (NULL);
for (i = 0; i < nm_setting_wireless_get_num_seen_bssids (s_wireless); i++) {
if (i > 0)
......@@ -704,10 +716,11 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
nmc->allowed_fields[5].value = bssid_str ? bssid_str : _("not set");
nmc->allowed_fields[6].value = rate_str;
nmc->allowed_fields[7].value = tx_power_str;
nmc->allowed_fields[8].value = mac_str ? mac_str : _("not set");
nmc->allowed_fields[9].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
nmc->allowed_fields[10].value = seen_bssids->str;
nmc->allowed_fields[11].value = nm_setting_wireless_get_security (s_wireless);
nmc->allowed_fields[8].value = device_mac_str ? device_mac_str : _("not set");
nmc->allowed_fields[9].value = cloned_mac_str ? cloned_mac_str : _("not set");
nmc->allowed_fields[10].value = strcmp (mtu_str, "0") ? mtu_str : _("auto");
nmc->allowed_fields[11].value = seen_bssids->str;
nmc->allowed_fields[12].value = nm_setting_wireless_get_security (s_wireless);
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 */
......@@ -717,7 +730,8 @@ setting_wireless_details (NMSetting *setting, NmCli *nmc)
g_free (bssid_str);
g_free (rate_str);
g_free (tx_power_str);
g_free (mac_str);
g_free (device_mac_str);
g_free (cloned_mac_str);
g_free (mtu_str);
g_string_free (seen_bssids, TRUE);
......
This diff is collapsed.