2005-10-09 04:28:16 +00:00
|
|
|
/* nm-tool - information tool for NetworkManager
|
|
|
|
|
*
|
|
|
|
|
* Dan Williams <dcbw@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* (C) Copyright 2005 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
#include <dbus/dbus-glib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2008-03-14 Dan Williams <dcbw@redhat.com>
* include/wireless-helper.h
include/Makefile.am
- One place for all the junk needed for #including wireless.h
* test/nm-tool.c
src/NetworkManagerAP.c
src/wpa.c
src/Makefile.am
libnm-util/nm-utils.c
libnm-util/nm-setting-wireless.c
libnm-glib/nm-device-802-11-wireless.c
libnm-glib/nm-access-point.c
libnm-glib/libnm-glib-test.c
- include wireless-helper.h, not iwlib.h
* configure.in
- Don't need libiw really, just need to check for wireless.h
* src/kernel-types.h
- Remove; used types moved into wpa.c
* src/nm-device-802-11-wireless.c
- (nm_device_802_11_wireless_update_signal_strength,
real_get_generic_capabilities, nm_device_802_11_wireless_get_mode,
nm_device_802_11_wireless_set_mode,
nm_device_802_11_wireless_get_frequency,
nm_device_802_11_wireless_get_ssid,
nm_device_802_11_wireless_set_ssid,
nm_device_802_11_wireless_get_bitrate,
nm_device_802_11_wireless_get_bssid,
nm_device_802_11_wireless_disable_encryption): use ioctl() directly
instead of iwlib functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3462 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-14 21:12:03 +00:00
|
|
|
#include "wireless-helper.h"
|
2005-12-07 17:40:37 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <arpa/inet.h>
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
#include <nm-client.h>
|
|
|
|
|
#include <nm-device.h>
|
|
|
|
|
#include <nm-device-802-3-ethernet.h>
|
|
|
|
|
#include <nm-device-802-11-wireless.h>
|
2007-10-09 08:57:35 +00:00
|
|
|
#include <nm-utils.h>
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
static gboolean
|
|
|
|
|
get_nm_state (NMClient *client)
|
|
|
|
|
{
|
|
|
|
|
NMState state;
|
|
|
|
|
char *state_string;
|
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
|
|
state = nm_client_get_state (client);
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
|
case NM_STATE_ASLEEP:
|
|
|
|
|
state_string = "asleep";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NM_STATE_CONNECTING:
|
|
|
|
|
state_string = "connecting";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NM_STATE_CONNECTED:
|
|
|
|
|
state_string = "connected";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NM_STATE_DISCONNECTED:
|
|
|
|
|
state_string = "disconnected";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case NM_STATE_UNKNOWN:
|
|
|
|
|
default:
|
|
|
|
|
state_string = "unknown";
|
|
|
|
|
success = FALSE;
|
|
|
|
|
break;
|
2005-10-09 04:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2006-03-27 18:00:12 +00:00
|
|
|
printf ("State: %s\n\n", state_string);
|
2005-10-09 04:28:16 +00:00
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
static void
|
|
|
|
|
print_string (const char *label, const char *data)
|
2005-10-09 04:28:16 +00:00
|
|
|
{
|
|
|
|
|
#define SPACING 18
|
|
|
|
|
int label_len = 0;
|
|
|
|
|
char spaces[50];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (label != NULL);
|
|
|
|
|
g_return_if_fail (data != NULL);
|
|
|
|
|
|
|
|
|
|
label_len = strlen (label);
|
|
|
|
|
if (label_len > SPACING)
|
|
|
|
|
label_len = SPACING - 1;
|
|
|
|
|
for (i = 0; i < (SPACING - label_len); i++)
|
|
|
|
|
spaces[i] = 0x20;
|
|
|
|
|
spaces[i] = 0x00;
|
|
|
|
|
|
2006-01-11 20:07:56 +00:00
|
|
|
printf (" %s:%s%s\n", label, &spaces[0], data);
|
2005-10-09 04:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
static void
|
2007-10-03 18:20:35 +00:00
|
|
|
detail_access_point (gpointer data, gpointer user_data)
|
2005-10-09 04:28:16 +00:00
|
|
|
{
|
2007-03-05 08:49:30 +00:00
|
|
|
NMAccessPoint *ap = NM_ACCESS_POINT (data);
|
|
|
|
|
const char *active_bssid = (const char *) user_data;
|
|
|
|
|
GString *str;
|
|
|
|
|
gboolean active = FALSE;
|
2007-08-28 14:47:31 +00:00
|
|
|
guint32 flags, wpa_flags, rsn_flags;
|
2007-09-24 14:58:52 +00:00
|
|
|
const GByteArray * ssid;
|
2007-03-05 08:49:30 +00:00
|
|
|
char *tmp;
|
|
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
flags = nm_access_point_get_flags (ap);
|
|
|
|
|
wpa_flags = nm_access_point_get_wpa_flags (ap);
|
|
|
|
|
rsn_flags = nm_access_point_get_rsn_flags (ap);
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
if (active_bssid) {
|
2007-10-05 16:00:06 +00:00
|
|
|
const char *current_bssid = nm_access_point_get_hw_address (ap);
|
2007-03-05 08:49:30 +00:00
|
|
|
if (current_bssid && !strcmp (current_bssid, active_bssid))
|
|
|
|
|
active = TRUE;
|
2005-10-09 04:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
str = g_string_new (NULL);
|
|
|
|
|
g_string_append_printf (str,
|
2007-10-16 14:16:51 +00:00
|
|
|
"%s, %s, Freq %d MHz, Rate %d Mb/s, Strength %d",
|
|
|
|
|
(nm_access_point_get_mode (ap) == IW_MODE_INFRA) ? "Infra" : "Ad-Hoc",
|
|
|
|
|
nm_access_point_get_hw_address (ap),
|
2007-09-25 18:56:02 +00:00
|
|
|
nm_access_point_get_frequency (ap),
|
2008-03-12 17:44:39 +00:00
|
|
|
nm_access_point_get_max_bitrate (ap) / 1000,
|
2007-03-05 08:49:30 +00:00
|
|
|
nm_access_point_get_strength (ap));
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
if ( !(flags & NM_802_11_AP_FLAGS_PRIVACY)
|
|
|
|
|
&& (wpa_flags != NM_802_11_AP_SEC_NONE)
|
|
|
|
|
&& (rsn_flags != NM_802_11_AP_SEC_NONE))
|
2007-03-05 08:49:30 +00:00
|
|
|
g_string_append (str, ", Encrypted: ");
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
if ( (flags & NM_802_11_AP_FLAGS_PRIVACY)
|
|
|
|
|
&& (wpa_flags == NM_802_11_AP_SEC_NONE)
|
|
|
|
|
&& (rsn_flags == NM_802_11_AP_SEC_NONE))
|
2007-03-05 08:49:30 +00:00
|
|
|
g_string_append (str, " WEP");
|
2007-08-28 14:47:31 +00:00
|
|
|
if (wpa_flags != NM_802_11_AP_SEC_NONE)
|
2007-03-05 08:49:30 +00:00
|
|
|
g_string_append (str, " WPA");
|
2007-08-28 14:47:31 +00:00
|
|
|
if (rsn_flags != NM_802_11_AP_SEC_NONE)
|
2007-03-05 08:49:30 +00:00
|
|
|
g_string_append (str, " WPA2");
|
2007-08-28 14:47:31 +00:00
|
|
|
if ( (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
|
|
|
|
|
|| (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X))
|
2007-03-05 08:49:30 +00:00
|
|
|
g_string_append (str, " Enterprise");
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
/* FIXME: broadcast/hidden */
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-06-27 16:18:52 +00:00
|
|
|
ssid = nm_access_point_get_ssid (ap);
|
|
|
|
|
tmp = g_strdup_printf (" %s%s", active ? "*" : "",
|
|
|
|
|
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
print_string (tmp, str->str);
|
2006-01-30 18:45:17 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
g_string_free (str, TRUE);
|
|
|
|
|
g_free (tmp);
|
|
|
|
|
}
|
2006-01-30 18:45:17 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
static gchar *
|
|
|
|
|
ip4_address_as_string (guint32 ip)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr tmp_addr;
|
|
|
|
|
gchar *ip_string;
|
2006-01-30 18:45:17 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
tmp_addr.s_addr = ip;
|
|
|
|
|
ip_string = inet_ntoa (tmp_addr);
|
2006-01-30 18:45:17 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
return g_strdup (ip_string);
|
2006-01-30 18:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
static void
|
|
|
|
|
detail_device (gpointer data, gpointer user_data)
|
2005-10-09 04:28:16 +00:00
|
|
|
{
|
2007-03-05 08:49:30 +00:00
|
|
|
NMDevice *device = NM_DEVICE (data);
|
|
|
|
|
char *tmp;
|
|
|
|
|
NMDeviceState state;
|
2007-10-27 02:58:32 +00:00
|
|
|
guint32 caps;
|
|
|
|
|
guint32 speed;
|
2008-03-24 15:17:30 +00:00
|
|
|
const GArray *array;
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
state = nm_device_get_state (device);
|
|
|
|
|
|
2008-03-24 15:17:30 +00:00
|
|
|
printf ("- Device: %s ----------------------------------------------------------------\n",
|
|
|
|
|
nm_device_get_iface (device));
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
/* General information */
|
|
|
|
|
if (NM_IS_DEVICE_802_3_ETHERNET (device))
|
|
|
|
|
print_string ("Type", "Wired");
|
|
|
|
|
else if (NM_IS_DEVICE_802_11_WIRELESS (device))
|
|
|
|
|
print_string ("Type", "802.11 Wireless");
|
|
|
|
|
|
2008-03-24 15:17:30 +00:00
|
|
|
print_string ("Driver", nm_device_get_driver (device) ? nm_device_get_driver (device) : "(unknown)");
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
if (state == NM_DEVICE_STATE_ACTIVATED)
|
|
|
|
|
print_string ("Active", "yes");
|
|
|
|
|
else
|
|
|
|
|
print_string ("Active", "no");
|
|
|
|
|
|
|
|
|
|
tmp = NULL;
|
|
|
|
|
if (NM_IS_DEVICE_802_3_ETHERNET (device))
|
2008-03-12 Dan Williams <dcbw@redhat.com>
Move the 'carrier' property from NMDevice to NMDevice8023Ethernet;
convert the libnm-glib NMDevice8023Ethernet to cached properties
* introspection/nm-device-802-3-ethernet.xml
- New 'Carrier' property
- New 'PropertiesChanged' signal
* introspection/nm-device.xml
- Remove 'Carrier' property
- Remove 'CarrierChanged' signal
* src/nm-device-interface.c
src/nm-device-interface.h
- (nm_device_interface_init): remove 'carrier' property and
'carrier-changed' signal
* src/nm-device.c
src/nm-device.h
- (nm_device_get_carrier, nm_device_set_carrier): remove
- (nm_device_activate_stage5_ip_config_commit): don't bother updating
the link here; wired device will handle that
- (handle_dhcp_lease_change): don't bother updating link here
- (get_property, nm_device_class_init): remove carrier property
* src/nm-device-802-11-wireless.c
- (real_update_link, nm_device_802_11_wireless_class_init): remove
real_update_link(); wireless devices don't use carrier at all
- (link_timeout_cb, supplicant_iface_state_cb_handler,
supplicant_iface_connection_state_cb_handler,
supplicant_mgr_state_cb_handler): remove anything to do with carrier
* src/nm-device-802-3-ethernet.c
src/nm-device-802-3-ethernet.h
- (nm_device_802_3_ethernet_carrier_on,
nm_device_802_3_ethernet_carrier_off, constructor): use set_carrier()
instead of nm_device_set_carrier()
- (device_state_changed): update link from sysfs on activation;
replaces real_update_link()
- (real_update_link): remove, replaced by device_state_changed()
- (nm_device_802_3_ethernet_get_carrier, set_carrier): new functions
- (nm_device_802_3_ethernet_get_speed): move up with other getters/setters
- (real_get_generic_capabilities, real_can_interrupt_activation): use
new get_carrier function
- (get_property): add 'carrier' property
- (nm_device_802_3_ethernet_class_init): add 'carrier' property and
hook into property-changed signal helper
* src/NetworkManagerPolicy.c
- (device_carrier_changed): will only ever be called with a wired device
- (device_added): only hook up to carrier-changed for wired devices
* libnm-glib/nm-device.c
libnm-glib/nm-device.h
- (constructor, nm_device_class_init): remove carrier-changed signal
- (device_carrier_changed_proxy): remove; unused
- (nm_device_get_carrier): remove; carrier a property of wired devices
* libnm-glib/nm-device-802-3-ethernet.c
libnm-glib/nm-device-802-3-ethernet.h
- Convert to cached properties like AP and Wireless objects
- (nm_device_802_3_ethernet_get_hw_address): now returns a 'const char *'
instead of a 'char *', return value should not be freed
- (nm_device_802_3_ethernet_get_carrier): return current carrier status
- (constructor): hook into properties-changed helper
- (set_property, get_property): new functions
- (nm_device_802_3_ethernet_class_init): export GObject properties
* test/nm-tool.c
- (detail_device): strdup the wired hardware address too since it's
cached now
* libnm-glib/libnm-glib-test.c
- (dump_wired): strdup the wired hardware address too since it's
cached now
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3428 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-03-12 16:12:39 +00:00
|
|
|
tmp = g_strdup (nm_device_802_3_ethernet_get_hw_address (NM_DEVICE_802_3_ETHERNET (device)));
|
2007-03-05 08:49:30 +00:00
|
|
|
else if (NM_IS_DEVICE_802_11_WIRELESS (device))
|
2007-11-13 20:03:31 +00:00
|
|
|
tmp = g_strdup (nm_device_802_11_wireless_get_hw_address (NM_DEVICE_802_11_WIRELESS (device)));
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
if (tmp) {
|
|
|
|
|
print_string ("HW Address", tmp);
|
|
|
|
|
g_free (tmp);
|
2005-10-09 04:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
/* Capabilities */
|
|
|
|
|
caps = nm_device_get_capabilities (device);
|
|
|
|
|
printf ("\n Capabilities:\n");
|
|
|
|
|
if (caps & NM_DEVICE_CAP_NM_SUPPORTED)
|
|
|
|
|
print_string (" Supported", "yes");
|
|
|
|
|
else
|
|
|
|
|
print_string (" Supported", "no");
|
|
|
|
|
if (caps & NM_DEVICE_CAP_CARRIER_DETECT)
|
|
|
|
|
print_string (" Carrier Detect", "yes");
|
|
|
|
|
|
|
|
|
|
speed = 0;
|
2007-10-27 02:58:32 +00:00
|
|
|
if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
|
|
|
|
|
/* Speed in Mb/s */
|
2007-03-05 08:49:30 +00:00
|
|
|
speed = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (device));
|
2007-10-27 02:58:32 +00:00
|
|
|
} else if (NM_IS_DEVICE_802_11_WIRELESS (device)) {
|
|
|
|
|
/* Speed in b/s */
|
2007-03-05 08:49:30 +00:00
|
|
|
speed = nm_device_802_11_wireless_get_bitrate (NM_DEVICE_802_11_WIRELESS (device));
|
2007-10-27 02:58:32 +00:00
|
|
|
speed /= 1000000;
|
|
|
|
|
}
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
if (speed) {
|
|
|
|
|
char *speed_string;
|
|
|
|
|
|
2007-10-27 02:58:32 +00:00
|
|
|
speed_string = g_strdup_printf ("%u Mb/s", speed);
|
2007-03-05 08:49:30 +00:00
|
|
|
print_string (" Speed", speed_string);
|
|
|
|
|
g_free (speed_string);
|
2005-10-09 04:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
/* Wireless specific information */
|
|
|
|
|
if ((NM_IS_DEVICE_802_11_WIRELESS (device))) {
|
2007-08-28 14:47:31 +00:00
|
|
|
guint32 wcaps;
|
2007-06-22 15:09:02 +00:00
|
|
|
NMAccessPoint *active_ap = NULL;
|
2007-10-05 16:00:06 +00:00
|
|
|
const char *active_bssid = NULL;
|
2008-03-27 14:13:47 +00:00
|
|
|
const GPtrArray *aps;
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
printf ("\n Wireless Settings\n");
|
|
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
wcaps = nm_device_802_11_wireless_get_capabilities (NM_DEVICE_802_11_WIRELESS (device));
|
2007-03-05 08:49:30 +00:00
|
|
|
|
2007-08-28 14:47:31 +00:00
|
|
|
if (wcaps & (NM_802_11_DEVICE_CAP_CIPHER_WEP40 | NM_802_11_DEVICE_CAP_CIPHER_WEP104))
|
2007-03-05 08:49:30 +00:00
|
|
|
print_string (" WEP Encryption", "yes");
|
2007-08-28 14:47:31 +00:00
|
|
|
if (wcaps & NM_802_11_DEVICE_CAP_WPA)
|
2007-03-05 08:49:30 +00:00
|
|
|
print_string (" WPA Encryption", "yes");
|
2007-08-28 14:47:31 +00:00
|
|
|
if (wcaps & NM_802_11_DEVICE_CAP_RSN)
|
2007-03-05 08:49:30 +00:00
|
|
|
print_string (" WPA2 Encryption", "yes");
|
|
|
|
|
|
2007-06-22 15:09:02 +00:00
|
|
|
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
|
2007-10-03 18:20:35 +00:00
|
|
|
active_ap = nm_device_802_11_wireless_get_active_access_point (NM_DEVICE_802_11_WIRELESS (device));
|
2007-06-22 15:09:02 +00:00
|
|
|
active_bssid = active_ap ? nm_access_point_get_hw_address (active_ap) : NULL;
|
|
|
|
|
}
|
2007-03-05 08:49:30 +00:00
|
|
|
|
2007-10-03 18:20:35 +00:00
|
|
|
printf ("\n Wireless Access Points%s\n", active_ap ? "(* = Current AP)" : "");
|
2007-03-05 08:49:30 +00:00
|
|
|
|
2007-10-03 18:20:35 +00:00
|
|
|
aps = nm_device_802_11_wireless_get_access_points (NM_DEVICE_802_11_WIRELESS (device));
|
2008-03-27 14:13:47 +00:00
|
|
|
g_ptr_array_foreach ((GPtrArray *) aps, detail_access_point, (gpointer) active_bssid);
|
2007-03-05 08:49:30 +00:00
|
|
|
} else if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
|
|
|
|
|
printf ("\n Wired Settings\n");
|
|
|
|
|
/* FIXME */
|
|
|
|
|
#if 0
|
|
|
|
|
if (link_active)
|
|
|
|
|
print_string (" Hardware Link", "yes");
|
2005-10-09 04:28:16 +00:00
|
|
|
else
|
2007-03-05 08:49:30 +00:00
|
|
|
print_string (" Hardware Link", "no");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
/* IP Setup info */
|
|
|
|
|
if (state == NM_DEVICE_STATE_ACTIVATED) {
|
|
|
|
|
NMIP4Config *cfg = nm_device_get_ip4_config (device);
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
printf ("\n IP Settings:\n");
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
tmp = ip4_address_as_string (nm_ip4_config_get_address (cfg));
|
|
|
|
|
print_string (" IP Address", tmp);
|
|
|
|
|
g_free (tmp);
|
2006-03-02 Robert Love <rml@novell.com>
Add support for retrieving both the per-device speed and the
per-network maximum supported rate. Then change the getProperties
DBUS API for both networks and devices to report this informaiton.
Finally, display the information via both nm-applet and nm-tool:
* gnome/applet/applet-dbus-devices.c: Grab the speed from getProperties
and set it.
* gnome/applet/applet.c: Display the device's speed in the 'Connection
Information' dialog.
* gnome/applet/applet.glade: Update the UI to show per-device speed.
* gnome/applet/nm-device.c, gnome/applet/nm-device.h: Add interfaces
network_device_get_speed() and network_device_set_speed() for
retrieving and setting, respectively, a network device's current
speed.
* src/nm-dbus-device.c: Send the device's speed on getProperties.
* src/nm-device-802-11-wireless.c: Return the rate in Mb/s, not Kb/s,
in the function nm_device_802_11_wireless_get_bitrate() -- it does
not matter (yet) what the units are, because we only feed it its own
output. Implement SIOCGIRATE and set the per-network maximum
supported rate during scanning.
* src/nm-device-802-11-wireless.h: Export the function
nm_device_802_11_wireless_get_bitrate().
* src/nm-device-802-3-ethernet.c, src/nm-device-802-3-ethernet.h: Add
function nm_device_802_3_ethernet_get_speed() for returning an
802.3's current speed, in Mb/s.
* test/nm-tool.c: Display the per-device current speed, if available,
and the per-network maximum rate.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-02 23:01:33 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
tmp = ip4_address_as_string (nm_ip4_config_get_netmask (cfg));
|
|
|
|
|
print_string (" Subnet Mask", tmp);
|
|
|
|
|
g_free (tmp);
|
2006-03-02 Robert Love <rml@novell.com>
Add support for retrieving both the per-device speed and the
per-network maximum supported rate. Then change the getProperties
DBUS API for both networks and devices to report this informaiton.
Finally, display the information via both nm-applet and nm-tool:
* gnome/applet/applet-dbus-devices.c: Grab the speed from getProperties
and set it.
* gnome/applet/applet.c: Display the device's speed in the 'Connection
Information' dialog.
* gnome/applet/applet.glade: Update the UI to show per-device speed.
* gnome/applet/nm-device.c, gnome/applet/nm-device.h: Add interfaces
network_device_get_speed() and network_device_set_speed() for
retrieving and setting, respectively, a network device's current
speed.
* src/nm-dbus-device.c: Send the device's speed on getProperties.
* src/nm-device-802-11-wireless.c: Return the rate in Mb/s, not Kb/s,
in the function nm_device_802_11_wireless_get_bitrate() -- it does
not matter (yet) what the units are, because we only feed it its own
output. Implement SIOCGIRATE and set the per-network maximum
supported rate during scanning.
* src/nm-device-802-11-wireless.h: Export the function
nm_device_802_11_wireless_get_bitrate().
* src/nm-device-802-3-ethernet.c, src/nm-device-802-3-ethernet.h: Add
function nm_device_802_3_ethernet_get_speed() for returning an
802.3's current speed, in Mb/s.
* test/nm-tool.c: Display the per-device current speed, if available,
and the per-network maximum rate.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-02 23:01:33 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
tmp = ip4_address_as_string (nm_ip4_config_get_broadcast (cfg));
|
|
|
|
|
print_string (" Broadcast", tmp);
|
|
|
|
|
g_free (tmp);
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
tmp = ip4_address_as_string (nm_ip4_config_get_gateway (cfg));
|
|
|
|
|
print_string (" Gateway", tmp);
|
|
|
|
|
g_free (tmp);
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
array = nm_ip4_config_get_nameservers (cfg);
|
|
|
|
|
if (array) {
|
|
|
|
|
int i;
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
for (i = 0; i < array->len; i++) {
|
|
|
|
|
tmp = ip4_address_as_string (g_array_index (array, guint32, i));
|
|
|
|
|
print_string (" DNS", tmp);
|
|
|
|
|
g_free (tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-10-09 04:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
printf ("\n\n");
|
|
|
|
|
}
|
2005-10-09 04:28:16 +00:00
|
|
|
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
int
|
|
|
|
|
main (int argc, char *argv[])
|
2005-10-09 04:28:16 +00:00
|
|
|
{
|
2007-03-05 08:49:30 +00:00
|
|
|
NMClient *client;
|
2008-03-27 14:13:47 +00:00
|
|
|
const GPtrArray *devices;
|
2005-10-09 04:28:16 +00:00
|
|
|
|
|
|
|
|
g_type_init ();
|
|
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
client = nm_client_new ();
|
|
|
|
|
if (!client) {
|
|
|
|
|
exit (1);
|
2005-10-09 04:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-11 20:07:56 +00:00
|
|
|
printf ("\nNetworkManager Tool\n\n");
|
2005-10-09 04:28:16 +00:00
|
|
|
|
2007-03-05 08:49:30 +00:00
|
|
|
if (!get_nm_state (client)) {
|
2006-01-11 20:07:56 +00:00
|
|
|
fprintf (stderr, "\n\nNetworkManager appears not to be running (could not get its state).\n");
|
2005-10-09 04:28:16 +00:00
|
|
|
exit (1);
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-27 14:13:47 +00:00
|
|
|
devices = nm_client_get_devices (client);
|
|
|
|
|
g_ptr_array_foreach ((GPtrArray *) devices, detail_device, NULL);
|
2007-03-05 08:49:30 +00:00
|
|
|
|
|
|
|
|
g_object_unref (client);
|
2005-10-09 04:28:16 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|