NetworkManager/test/nm-tool.c

812 lines
22 KiB
C
Raw Normal View History

/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2005 - 2011 Red Hat, Inc.
* (C) Copyright 2007 Novell, Inc.
*/
#include <config.h>
#include <glib.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <nm-client.h>
#include <nm-device.h>
#include <nm-device-ethernet.h>
#include <nm-device-wifi.h>
#include <nm-gsm-device.h>
#include <nm-cdma-device.h>
#include <nm-device-bt.h>
2011-01-05 18:23:08 -06:00
#if WITH_WIMAX
#include <nm-device-wimax.h>
2011-01-05 18:23:08 -06:00
#endif
2007-10-09 Tambet Ingo <tambet@gmail.com> * src/NetworkManagerUtils.c (nm_utils_is_empty_ssid): (nm_utils_escape_ssid): (nm_utils_same_ssid): Remove. These functions are copied and pasted in a lot of places, so they belong to libnm-utils instead. Now with 100% less compiler warnings: * libnm-util/nm-utils.c (nm_dbus_escape_object_path): Remove, * unused. (nm_dbus_unescape_object_path): Ditto. (nm_utils_ssid_to_utf8): Ditto. (nm_utils_is_empty_ssid): Move here from src/NetworkManagerUtils.c (nm_utils_escape_ssid): Ditto. (nm_utils_same_ssid): Ditto. * src/nm-manager.c: Include 'netinet/ether.h' for ether_aton_r. (add_one_connection_element): Remove an unused variable. (impl_manager_get_active_connections): Ditto. * src/NetworkManagerPolicy.c (get_device_connection): Remove an * unused variable. * src/nm-dbus-manager.c (nm_dbus_manager_start_service): Remove * a leftover from the previous commit. * src/nm-device-802-11-wireless.c (set_current_ap): Remove * unused variable. (real_act_stage1_prepare): Ditto. (activation_success_handler): Ditto. (get_property): Ditto. * src/nm-device-802-3-ethernet.c (real_get_best_connection): * Remove unused variable. * src/ppp-manager/nm-pppd-plugin.c (nm_ip_up): Remove the check * for 'ifname', it's always set. * src/supplicant-manager/nm-supplicant-config.c (nm_supplicant_config_add_setting_wireless): Cast the GByteArray's 'guint8 *' to expected "char *". (nm_supplicant_config_add_setting_wireless): Ditto. (nm_supplicant_config_remove_option): Remove, not used. * libnm-glib/libnm-glib-test.c (dump_access_point): Frequency is * a guint32, not double. (test_wireless_enabled): Ifdef out unused function. (device_deactivate): Ditto. (device_state_changed): Ditto. (nm_utils_is_empty_ssid): Remove, it's now in libnm-utils. (nm_utils_escape_ssid): Ditto. * test/nm-tool.c (nm_utils_escape_ssid): Remove, it's now in * libnm-utils. (nm_utils_is_empty_ssid): Ditto. * libnm-glib/nm-client.c * (nm_client_free_active_connection_element): Remove unused variable. * libnm-util/nm-setting.c (setting_wireless_destroy): Remove * unused variable. (setting_vpn_properties_update_secrets): Ditto. (int_to_gvalue): Ifdef out for now, not used. (byte_to_gvalue): Ditto. * libnm-util/dbus-dict-helpers.c * (_nmu_dbus_add_dict_entry_string_array): Unused, remove. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2960 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-10-09 08:57:35 +00:00
#include <nm-utils.h>
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
#include <nm-setting-ip4-config.h>
#include <nm-setting-ip6-config.h>
#include <nm-vpn-connection.h>
#include <nm-setting-connection.h>
/* Don't use nm-dbus-glib-types.h so that we can keep nm-tool
* building standalone outside of the NM tree.
*/
#define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
#define DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH))
2010-07-16 20:37:27 -04:00
static GHashTable *connections = NULL;
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;
}
printf ("State: %s\n\n", state_string);
return success;
}
static void
print_header (const char *label, const char *iface, const char *connection)
{
GString *string;
string = g_string_sized_new (79);
g_string_append_printf (string, "- %s: ", label);
if (iface)
g_string_append_printf (string, "%s ", iface);
if (connection)
g_string_append_printf (string, " [%s] ", connection);
while (string->len < 80)
g_string_append_c (string, '-');
printf ("%s\n", string->str);
g_string_free (string, TRUE);
}
static void
print_string (const char *label, const char *data)
{
#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;
printf (" %s:%s%s\n", label, &spaces[0], data);
}
static void
detail_access_point (gpointer data, gpointer user_data)
{
NMAccessPoint *ap = NM_ACCESS_POINT (data);
const char *active_bssid = (const char *) user_data;
GString *str;
gboolean active = FALSE;
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-28 14:47:31 +00:00
guint32 flags, wpa_flags, rsn_flags;
const GByteArray * ssid;
char *tmp;
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
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);
if (active_bssid) {
const char *current_bssid = nm_access_point_get_hw_address (ap);
if (current_bssid && !strcmp (current_bssid, active_bssid))
active = TRUE;
}
str = g_string_new (NULL);
g_string_append_printf (str,
"%s, %s, Freq %d MHz, Rate %d Mb/s, Strength %d",
(nm_access_point_get_mode (ap) == NM_802_11_MODE_INFRA) ? "Infra" : "Ad-Hoc",
nm_access_point_get_hw_address (ap),
nm_access_point_get_frequency (ap),
nm_access_point_get_max_bitrate (ap) / 1000,
nm_access_point_get_strength (ap));
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
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))
g_string_append (str, ", Encrypted: ");
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
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))
g_string_append (str, " WEP");
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-28 14:47:31 +00:00
if (wpa_flags != NM_802_11_AP_SEC_NONE)
g_string_append (str, " WPA");
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-28 14:47:31 +00:00
if (rsn_flags != NM_802_11_AP_SEC_NONE)
g_string_append (str, " WPA2");
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
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))
g_string_append (str, " Enterprise");
/* FIXME: broadcast/hidden */
ssid = nm_access_point_get_ssid (ap);
tmp = g_strdup_printf (" %s%s", active ? "*" : "",
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
print_string (tmp, str->str);
g_string_free (str, TRUE);
g_free (tmp);
}
2011-01-05 18:23:08 -06:00
#if WITH_WIMAX
2009-12-14 13:51:50 +02:00
static const char *
wimax_network_type_to_str (NMWimaxNspNetworkType type)
{
switch (type) {
case NM_WIMAX_NSP_NETWORK_TYPE_HOME:
return "Home";
2009-12-14 13:51:50 +02:00
case NM_WIMAX_NSP_NETWORK_TYPE_PARTNER:
return "Partner";
2009-12-14 13:51:50 +02:00
case NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER:
return "Roaming";
2009-12-14 13:51:50 +02:00
default:
return "Unknown";
2009-12-14 13:51:50 +02:00
}
}
static void
detail_nsp (gpointer data, gpointer user_data)
{
NMWimaxNsp *nsp = NM_WIMAX_NSP (data);
const char *active_name = (const char *) user_data;
const char *name;
char *label;
char *data_str;
gboolean active = FALSE;
name = nm_wimax_nsp_get_name (nsp);
if (active_name)
active = g_strcmp0 (active_name, name) == 0;
label = g_strdup_printf (" %s%s", active ? "*" : "", name);
data_str = g_strdup_printf ("%d%% (%s)",
nm_wimax_nsp_get_signal_quality (nsp),
wimax_network_type_to_str (nm_wimax_nsp_get_network_type (nsp)));
2009-12-14 13:51:50 +02:00
print_string (label, data_str);
2009-12-14 13:51:50 +02:00
g_free (label);
g_free (data_str);
}
2011-01-05 18:23:08 -06:00
#endif
2009-12-14 13:51:50 +02:00
static gchar *
ip4_address_as_string (guint32 ip)
{
struct in_addr tmp_addr;
char buf[INET_ADDRSTRLEN+1];
memset (&buf, '\0', sizeof (buf));
tmp_addr.s_addr = ip;
if (inet_ntop (AF_INET, &tmp_addr, buf, INET_ADDRSTRLEN)) {
return g_strdup (buf);
} else {
nm_warning ("%s: error converting IP4 address 0x%X",
__func__, ntohl (tmp_addr.s_addr));
return NULL;
}
}
static gchar *
ip6_address_as_string (const struct in6_addr *ip)
{
char buf[INET6_ADDRSTRLEN];
memset (&buf, '\0', sizeof (buf));
if (inet_ntop (AF_INET6, ip, buf, INET6_ADDRSTRLEN)) {
return g_strdup (buf);
} else {
int j;
GString *ip6_str = g_string_new (NULL);
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]);
nm_warning ("%s: error converting IP6 address %s",
__func__, ip6_str->str);
g_string_free (ip6_str, TRUE);
return NULL;
}
}
2008-04-07 Dan Williams <dcbw@redhat.com> * include/NetworkManager.h - Remove the DOWN and CANCELLED device states - Add UNMANAGED and UNAVAILABLE device states - Document the device states * introspection/nm-device.xml src/nm-device-interface.c src/nm-device-interface.h - Add the 'managed' property * test/nm-tool.c - (detail_device): print out device state * src/NetworkManagerSystem.h src/backends/NetworkManagerArch.c src/backends/NetworkManagerDebian.c src/backends/NetworkManagerFrugalware.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerMandriva.c src/backends/NetworkManagerPaldo.c src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSlackware.c src/backends/NetworkManagerSuSE.c - (nm_system_device_get_system_config, nm_system_device_get_disabled nm_system_device_free_system_config): remove; they were unused and their functionality should be re-implemented in each distro's system settings service plugin * src/nm-gsm-device.c src/nm-gsm-device.h src/nm-cdma-device.c src/nm-cdma-device.h - (*_new): take the 'managed' argument * src/nm-device.c - (nm_device_set_address): remove, fold into nm_device_bring_up() - (nm_device_init): start in unmanaged state, not disconnected - (constructor): don't start device until the system settings service has had a chance to figure out if the device is managed or not - (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down): don't set device state here, let callers handle that as appropriate - (nm_device_dispose): don't touch the device if it's not managed - (set_property, get_property, nm_device_class_init): implement the 'managed' property - (nm_device_state_changed): bring the device up if its now managed, and deactivate it if it used to be active - (nm_device_get_managed, nm_device_set_managed): do the right thing with the managed state * src/nm-hal-manager.c - (wired_device_creator, wireless_device_creator, modem_device_creator): take initial managed state and pass it along to device constructors - (create_device_and_add_to_list): get managed state and pass to type creators * src/nm-device-802-11-wireless.c - (real_can_activate): fold in most of nm_device_802_11_wireless_can_activate() - (can_scan): can't scan in UNAVAILABLE or UNMANAGED - (link_timeout_cb): instead of deactivating, change device state and let the device state handler to it - (real_update_hw_address): clean up - (state_changed_cb): when entering UNAVAILABLE state, schedule an idle handler to transition to DISCONNECTED if the device isn't rfkilled * src/nm-device-802-3-ethernet.c - (set_carrier): move above callers and get rid of prototype - (device_state_changed): when entering UNAVAILABLE state, schedule an idle handler to transition to DISCONNECTED if the device has a carrier - (real_update_hw_address): clean up - (link_timeout_cb, ppp_state_changed): change state instead of calling deactivation directly as deactivation doesn't change state anymore * src/NetworkManagerPolicy.c - (schedule_activate_check): yay, remove wireless_enabled hack since the NMManager and wireless devices work that out themselves now - (device_state_changed): change to a switch and update for new device states - (device_carrier_changed): remove; device handles this now through state changes - (device_added): don't care about carrier any more; the initial activation check will happen when the device transitions to DISCONNECTED * src/nm-manager.c - (dispose): clear unmanaged devices - (handle_unmanaged_devices): update unmanaged device list and toggle the managed property on each device when needed - (system_settings_properties_changed_cb): handle signals from the system settings service - (system_settings_get_unmanaged_devices_cb): handle callback from getting the unmanaged device list method call - (query_unmanaged_devices): ask the system settings service for its list of unmanaged devices - (nm_manager_name_owner_changed, initial_get_connections): get unmanaged devices - (manager_set_wireless_enabled): push rfkill state down to wireless devices directly and let them handle the necessary state transitions - (manager_device_state_changed): update for new device states - (nm_manager_add_device): set initial rfkill state on wireless devices - (nm_manager_remove_device): don't touch the device if it's unmanaged - (nm_manager_activate_connection): return error if the device is unmanaged - (nm_manager_sleep): handle new device states correctly; don't change the state of unavailable/unmanaged devices * libnm-glib/nm-device-802-11-wireless.c - (state_changed_cb): update for new device states git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
static const char *
get_dev_state_string (NMDeviceState state)
{
if (state == NM_DEVICE_STATE_UNMANAGED)
return "unmanaged";
else if (state == NM_DEVICE_STATE_UNAVAILABLE)
return "unavailable";
else if (state == NM_DEVICE_STATE_DISCONNECTED)
return "disconnected";
else if (state == NM_DEVICE_STATE_PREPARE)
return "connecting (prepare)";
else if (state == NM_DEVICE_STATE_CONFIG)
return "connecting (configuring)";
else if (state == NM_DEVICE_STATE_NEED_AUTH)
return "connecting (need authentication)";
else if (state == NM_DEVICE_STATE_IP_CONFIG)
return "connecting (getting IP configuration)";
else if (state == NM_DEVICE_STATE_ACTIVATED)
return "connected";
else if (state == NM_DEVICE_STATE_FAILED)
return "connection failed";
return "unknown";
}
static NMConnection *
get_connection_for_active (NMActiveConnection *active)
{
const char *path;
g_return_val_if_fail (active != NULL, NULL);
path = nm_active_connection_get_connection (active);
g_return_val_if_fail (path != NULL, NULL);
2010-07-16 20:37:27 -04:00
return (NMConnection *) g_hash_table_lookup (connections, path);
}
struct cb_info {
NMClient *client;
const GPtrArray *active;
};
static void
detail_device (gpointer data, gpointer user_data)
{
NMDevice *device = NM_DEVICE (data);
struct cb_info *info = user_data;
char *tmp;
NMDeviceState state;
guint32 caps;
guint32 speed;
const GArray *array;
int j;
gboolean is_default = FALSE;
const char *id = NULL;
state = nm_device_get_state (device);
for (j = 0; info->active && (j < info->active->len); j++) {
NMActiveConnection *candidate = g_ptr_array_index (info->active, j);
const GPtrArray *devices = nm_active_connection_get_devices (candidate);
NMDevice *candidate_dev;
NMConnection *connection;
NMSettingConnection *s_con;
if (!devices || !devices->len)
continue;
candidate_dev = g_ptr_array_index (devices, 0);
if (candidate_dev == device) {
if (nm_active_connection_get_default (candidate))
is_default = TRUE;
connection = get_connection_for_active (candidate);
if (!connection)
break;
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
if (s_con)
id = nm_setting_connection_get_id (s_con);
break;
}
}
print_header ("Device", nm_device_get_iface (device), id);
/* General information */
if (NM_IS_DEVICE_ETHERNET (device))
print_string ("Type", "Wired");
else if (NM_IS_DEVICE_WIFI (device))
print_string ("Type", "802.11 WiFi");
else if (NM_IS_GSM_DEVICE (device))
print_string ("Type", "Mobile Broadband (GSM)");
else if (NM_IS_CDMA_DEVICE (device))
print_string ("Type", "Mobile Broadband (CDMA)");
else if (NM_IS_DEVICE_BT (device))
print_string ("Type", "Bluetooth");
2011-01-05 18:23:08 -06:00
#if WITH_WIMAX
else if (NM_IS_DEVICE_WIMAX (device))
2009-12-14 13:51:50 +02:00
print_string ("Type", "WiMAX");
2011-01-05 18:23:08 -06:00
#endif
print_string ("Driver", nm_device_get_driver (device) ? nm_device_get_driver (device) : "(unknown)");
2008-04-07 Dan Williams <dcbw@redhat.com> * include/NetworkManager.h - Remove the DOWN and CANCELLED device states - Add UNMANAGED and UNAVAILABLE device states - Document the device states * introspection/nm-device.xml src/nm-device-interface.c src/nm-device-interface.h - Add the 'managed' property * test/nm-tool.c - (detail_device): print out device state * src/NetworkManagerSystem.h src/backends/NetworkManagerArch.c src/backends/NetworkManagerDebian.c src/backends/NetworkManagerFrugalware.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerMandriva.c src/backends/NetworkManagerPaldo.c src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSlackware.c src/backends/NetworkManagerSuSE.c - (nm_system_device_get_system_config, nm_system_device_get_disabled nm_system_device_free_system_config): remove; they were unused and their functionality should be re-implemented in each distro's system settings service plugin * src/nm-gsm-device.c src/nm-gsm-device.h src/nm-cdma-device.c src/nm-cdma-device.h - (*_new): take the 'managed' argument * src/nm-device.c - (nm_device_set_address): remove, fold into nm_device_bring_up() - (nm_device_init): start in unmanaged state, not disconnected - (constructor): don't start device until the system settings service has had a chance to figure out if the device is managed or not - (nm_device_deactivate, nm_device_bring_up, nm_device_bring_down): don't set device state here, let callers handle that as appropriate - (nm_device_dispose): don't touch the device if it's not managed - (set_property, get_property, nm_device_class_init): implement the 'managed' property - (nm_device_state_changed): bring the device up if its now managed, and deactivate it if it used to be active - (nm_device_get_managed, nm_device_set_managed): do the right thing with the managed state * src/nm-hal-manager.c - (wired_device_creator, wireless_device_creator, modem_device_creator): take initial managed state and pass it along to device constructors - (create_device_and_add_to_list): get managed state and pass to type creators * src/nm-device-802-11-wireless.c - (real_can_activate): fold in most of nm_device_802_11_wireless_can_activate() - (can_scan): can't scan in UNAVAILABLE or UNMANAGED - (link_timeout_cb): instead of deactivating, change device state and let the device state handler to it - (real_update_hw_address): clean up - (state_changed_cb): when entering UNAVAILABLE state, schedule an idle handler to transition to DISCONNECTED if the device isn't rfkilled * src/nm-device-802-3-ethernet.c - (set_carrier): move above callers and get rid of prototype - (device_state_changed): when entering UNAVAILABLE state, schedule an idle handler to transition to DISCONNECTED if the device has a carrier - (real_update_hw_address): clean up - (link_timeout_cb, ppp_state_changed): change state instead of calling deactivation directly as deactivation doesn't change state anymore * src/NetworkManagerPolicy.c - (schedule_activate_check): yay, remove wireless_enabled hack since the NMManager and wireless devices work that out themselves now - (device_state_changed): change to a switch and update for new device states - (device_carrier_changed): remove; device handles this now through state changes - (device_added): don't care about carrier any more; the initial activation check will happen when the device transitions to DISCONNECTED * src/nm-manager.c - (dispose): clear unmanaged devices - (handle_unmanaged_devices): update unmanaged device list and toggle the managed property on each device when needed - (system_settings_properties_changed_cb): handle signals from the system settings service - (system_settings_get_unmanaged_devices_cb): handle callback from getting the unmanaged device list method call - (query_unmanaged_devices): ask the system settings service for its list of unmanaged devices - (nm_manager_name_owner_changed, initial_get_connections): get unmanaged devices - (manager_set_wireless_enabled): push rfkill state down to wireless devices directly and let them handle the necessary state transitions - (manager_device_state_changed): update for new device states - (nm_manager_add_device): set initial rfkill state on wireless devices - (nm_manager_remove_device): don't touch the device if it's unmanaged - (nm_manager_activate_connection): return error if the device is unmanaged - (nm_manager_sleep): handle new device states correctly; don't change the state of unavailable/unmanaged devices * libnm-glib/nm-device-802-11-wireless.c - (state_changed_cb): update for new device states git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3540 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-04-08 02:58:02 +00:00
print_string ("State", get_dev_state_string (state));
if (is_default)
print_string ("Default", "yes");
else
print_string ("Default", "no");
tmp = NULL;
if (NM_IS_DEVICE_ETHERNET (device))
tmp = g_strdup (nm_device_ethernet_get_hw_address (NM_DEVICE_ETHERNET (device)));
else if (NM_IS_DEVICE_WIFI (device))
tmp = g_strdup (nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (device)));
2011-01-05 18:23:08 -06:00
#if WITH_WIMAX
else if (NM_IS_DEVICE_WIMAX (device))
tmp = g_strdup (nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device)));
2011-01-05 18:23:08 -06:00
#endif
if (tmp) {
print_string ("HW Address", tmp);
g_free (tmp);
}
/* Capabilities */
caps = nm_device_get_capabilities (device);
printf ("\n Capabilities:\n");
if (caps & NM_DEVICE_CAP_CARRIER_DETECT)
print_string (" Carrier Detect", "yes");
speed = 0;
if (NM_IS_DEVICE_ETHERNET (device)) {
/* Speed in Mb/s */
speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (device));
} else if (NM_IS_DEVICE_WIFI (device)) {
/* Speed in b/s */
speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (device));
speed /= 1000;
}
if (speed) {
char *speed_string;
speed_string = g_strdup_printf ("%u Mb/s", speed);
print_string (" Speed", speed_string);
g_free (speed_string);
}
/* Wireless specific information */
if ((NM_IS_DEVICE_WIFI (device))) {
2007-08-28 Dan Williams <dcbw@redhat.com> Remove NMAPSecurity objects, they are replaced with flags on the APs for each AP's capabilities, and by NMConnection/NMSettings objects for user defined connections. * include/NetworkManager.h - Redefine 802.11 security properties. There are now device capabilities and AP flags and AP security flags. It was way to unclear before. * src/Makefile.am src/nm-ap-security-leap.h src/nm-ap-security-leap.c src/nm-ap-security-wpa-eap.c src/nm-ap-security-wpa-eap.h src/nm-ap-security-private.h src/nm-ap-security-wpa-psk.c src/nm-ap-security-wpa-psk.h src/nm-ap-security-wep.c src/nm-ap-security-wep.h src/nm-ap-security.c src/nm-ap-security.h - Removed, to be replaced with NMConnection/NMSettings objects * src/nm-dbus-nmi.c src/nm-dbus-nmi.h - Removed, to be replaced by code that talks to the new info daemon interface and gets NMConnection/NMSettings objects * src/backends/NetworkManagerSuSE.c - Remove usage of NMAPSecurity; should be replaced by a system-level info-daemon that does the same thing but talks the new info-daemon D-Bus interface * src/NetworkManagerAP.h src/NetworkManagerAP.c src/NetworkManagerAPList.c libnm-glib/libnm-glib-test.c - Remove usage of NMAPSecurity objects and adjust to new flags for WPA/RSN * libnm-glib/nm-access-point.c libnm-glib/nm-access-point.h introspection/nm-access-point.xml test/nm-tool.c - Adjust to new flags for AP security * utils/nm-utils.c utils/nm-utils.h src/vpn-manager/nm-dbus-vpn.c - Remove D-Bus pending call stuff from nm-utils and put it in the VPN stuff which is the only place it's used * src/nm-device-interface.c src/nm-device-interface.h introspection/nm-device.xml src/nm-activation-request.c src/nm-activation-request.h src/nm-device.c - Add a new 'specific_object' argument that hints to NM what actual AP or other device-specific thing the connection should apply to. NMConnection objects can apply to more than one actual device/AP. * libnm-util/nm-connection.c * libnm-util/nm-connection.h - Add 'have_secrets" call stubs * libnm-util/cipher.h - Move NM_AUTH_TYPE_* defines here for now * src/nm-device-802-11-wireless.c - Remove usage of NMAPSecurity, to be replaced with NMConnection/ NMSettings objects * src/NetworkManagerDbus.c * src/NetworkManagerPolicy.c - Remove usage of update_allowed_networks, should be pushing data in a different manner git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2738 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-08-28 14:47:31 +00:00
guint32 wcaps;
2007-06-21 Tambet Ingo <tambet@ximian.com> * libnm-glib/Makefile.am: Add NMObject to build, remove nm-utils.[ch]. * nm-utils.[ch]: Remove. * libnm-glib/nm-object.c: Implement a base class for all libnm-glib dbus-aware objects for easy property access and dbus connection handling. * libnm-glib/nm-client.c: Derive from NMObject. * libnm-glib/nm-device.c: Ditto. * libnm-glib/nm-device-802-3-ethernet.c: Changes for being based on NMObject. * libnm-glib/nm-device-802-11-wireless.c: Ditto. * libnm-glib/nm-ip4-config.c: Ditto. * libnm-glib/nm-access-point.c: Ditto. * libnm-util/nm-connection.c (nm_connection_compare): Add a stub for connection comparision. Currently used by the device activation code to determine if the new activation is the same as the old one. * src/nm-dbus-nmi.c (nm_dbus_get_user_key_for_network): Don't use the obsolete and wrong way of getting the dbus path for AP. Fixes the issue where the applet isn't able to ask password for the AP. * src/nm-device.c (nm_device_activate): Change the logic here - instead of giving up if the device is already connected, tear down it's connection (if it isn't the same as new one) and start the activation. * src/nm-manager.c: Add the beginnings of NMConnection storage and signals. * src/NetworkManagerAP.c (nm_ap_init): Set the default values to AP memebers, fixes the issue where all APs are always listed as encrypted. * src/NetworkManagerDbus.c (nm_dbus_get_object_path_for_network): Remove. APs have their own registered paths. * test/nm-tool.c (detail_device): Don't try to get active network from wireless device if it's not connected - dbus-glib will happily crash trying to marshal NULL. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2615 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-06-22 15:09:02 +00:00
NMAccessPoint *active_ap = NULL;
const char *active_bssid = NULL;
const GPtrArray *aps;
printf ("\n Wireless Properties\n");
wcaps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (device));
if (wcaps & (NM_WIFI_DEVICE_CAP_CIPHER_WEP40 | NM_WIFI_DEVICE_CAP_CIPHER_WEP104))
print_string (" WEP Encryption", "yes");
if (wcaps & NM_WIFI_DEVICE_CAP_WPA)
print_string (" WPA Encryption", "yes");
if (wcaps & NM_WIFI_DEVICE_CAP_RSN)
print_string (" WPA2 Encryption", "yes");
2007-06-21 Tambet Ingo <tambet@ximian.com> * libnm-glib/Makefile.am: Add NMObject to build, remove nm-utils.[ch]. * nm-utils.[ch]: Remove. * libnm-glib/nm-object.c: Implement a base class for all libnm-glib dbus-aware objects for easy property access and dbus connection handling. * libnm-glib/nm-client.c: Derive from NMObject. * libnm-glib/nm-device.c: Ditto. * libnm-glib/nm-device-802-3-ethernet.c: Changes for being based on NMObject. * libnm-glib/nm-device-802-11-wireless.c: Ditto. * libnm-glib/nm-ip4-config.c: Ditto. * libnm-glib/nm-access-point.c: Ditto. * libnm-util/nm-connection.c (nm_connection_compare): Add a stub for connection comparision. Currently used by the device activation code to determine if the new activation is the same as the old one. * src/nm-dbus-nmi.c (nm_dbus_get_user_key_for_network): Don't use the obsolete and wrong way of getting the dbus path for AP. Fixes the issue where the applet isn't able to ask password for the AP. * src/nm-device.c (nm_device_activate): Change the logic here - instead of giving up if the device is already connected, tear down it's connection (if it isn't the same as new one) and start the activation. * src/nm-manager.c: Add the beginnings of NMConnection storage and signals. * src/NetworkManagerAP.c (nm_ap_init): Set the default values to AP memebers, fixes the issue where all APs are always listed as encrypted. * src/NetworkManagerDbus.c (nm_dbus_get_object_path_for_network): Remove. APs have their own registered paths. * test/nm-tool.c (detail_device): Don't try to get active network from wireless device if it's not connected - dbus-glib will happily crash trying to marshal NULL. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2615 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-06-22 15:09:02 +00:00
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device));
2007-06-21 Tambet Ingo <tambet@ximian.com> * libnm-glib/Makefile.am: Add NMObject to build, remove nm-utils.[ch]. * nm-utils.[ch]: Remove. * libnm-glib/nm-object.c: Implement a base class for all libnm-glib dbus-aware objects for easy property access and dbus connection handling. * libnm-glib/nm-client.c: Derive from NMObject. * libnm-glib/nm-device.c: Ditto. * libnm-glib/nm-device-802-3-ethernet.c: Changes for being based on NMObject. * libnm-glib/nm-device-802-11-wireless.c: Ditto. * libnm-glib/nm-ip4-config.c: Ditto. * libnm-glib/nm-access-point.c: Ditto. * libnm-util/nm-connection.c (nm_connection_compare): Add a stub for connection comparision. Currently used by the device activation code to determine if the new activation is the same as the old one. * src/nm-dbus-nmi.c (nm_dbus_get_user_key_for_network): Don't use the obsolete and wrong way of getting the dbus path for AP. Fixes the issue where the applet isn't able to ask password for the AP. * src/nm-device.c (nm_device_activate): Change the logic here - instead of giving up if the device is already connected, tear down it's connection (if it isn't the same as new one) and start the activation. * src/nm-manager.c: Add the beginnings of NMConnection storage and signals. * src/NetworkManagerAP.c (nm_ap_init): Set the default values to AP memebers, fixes the issue where all APs are always listed as encrypted. * src/NetworkManagerDbus.c (nm_dbus_get_object_path_for_network): Remove. APs have their own registered paths. * test/nm-tool.c (detail_device): Don't try to get active network from wireless device if it's not connected - dbus-glib will happily crash trying to marshal NULL. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2615 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2007-06-22 15:09:02 +00:00
active_bssid = active_ap ? nm_access_point_get_hw_address (active_ap) : NULL;
}
printf ("\n Wireless Access Points %s\n", active_ap ? "(* = current AP)" : "");
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (device));
if (aps && aps->len)
g_ptr_array_foreach ((GPtrArray *) aps, detail_access_point, (gpointer) active_bssid);
} else if (NM_IS_DEVICE_ETHERNET (device)) {
printf ("\n Wired Properties\n");
if (nm_device_ethernet_get_carrier (NM_DEVICE_ETHERNET (device)))
print_string (" Carrier", "on");
else
print_string (" Carrier", "off");
2011-01-05 18:23:08 -06:00
#if WITH_WIMAX
} else if (NM_IS_DEVICE_WIMAX (device)) {
NMDeviceWimax *wimax = NM_DEVICE_WIMAX (device);
2009-12-14 13:51:50 +02:00
NMWimaxNsp *active_nsp = NULL;
const char *active_name = NULL;
const GPtrArray *nsps;
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
guint tmp_uint;
gint tmp_int;
const char *tmp_str;
active_nsp = nm_device_wimax_get_active_nsp (wimax);
2009-12-14 13:51:50 +02:00
active_name = active_nsp ? nm_wimax_nsp_get_name (active_nsp) : NULL;
printf ("\n Link Status\n");
tmp_uint = nm_device_wimax_get_center_frequency (wimax);
if (tmp_uint)
tmp = g_strdup_printf ("%'.1f MHz", (double) tmp_uint / 1000.0);
else
tmp = g_strdup ("(unknown)");
print_string (" Center Freq.", tmp);
g_free (tmp);
tmp_int = nm_device_wimax_get_rssi (wimax);
if (tmp_int)
tmp = g_strdup_printf ("%d dBm", tmp_int);
else
tmp = g_strdup ("(unknown)");
print_string (" RSSI", tmp);
g_free (tmp);
tmp_int = nm_device_wimax_get_cinr (wimax);
if (tmp_int)
tmp = g_strdup_printf ("%d dB", tmp_int);
else
tmp = g_strdup ("(unknown)");
print_string (" CINR", tmp);
g_free (tmp);
tmp_int = nm_device_wimax_get_tx_power (wimax);
if (tmp_int)
tmp = g_strdup_printf ("%'.2f dBm", (float) tmp_int / 2.0);
else
tmp = g_strdup ("(unknown)");
print_string (" TX Power", tmp);
g_free (tmp);
tmp_str = nm_device_wimax_get_bsid (wimax);
if (tmp_str)
print_string (" BSID", tmp_str);
else
print_string (" BSID", "(unknown)");
2009-12-14 13:51:50 +02:00
}
printf ("\n WiMAX NSPs %s\n", active_nsp ? "(* current NSP)" : "");
nsps = nm_device_wimax_get_nsps (NM_DEVICE_WIMAX (device));
2009-12-14 13:51:50 +02:00
if (nsps && nsps->len)
g_ptr_array_foreach ((GPtrArray *) nsps, detail_nsp, (gpointer) active_name);
2011-01-05 18:23:08 -06:00
#endif
}
/* IP Setup info */
if (state == NM_DEVICE_STATE_ACTIVATED) {
NMIP4Config *cfg4 = nm_device_get_ip4_config (device);
NMIP6Config *cfg6 = nm_device_get_ip6_config (device);
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
GSList *iter;
if (cfg4) {
printf ("\n IPv4 Settings:\n");
for (iter = (GSList *) nm_ip4_config_get_addresses (cfg4); iter; iter = g_slist_next (iter)) {
NMIP4Address *addr = (NMIP4Address *) iter->data;
guint32 prefix = nm_ip4_address_get_prefix (addr);
char *tmp2;
tmp = ip4_address_as_string (nm_ip4_address_get_address (addr));
print_string (" Address", tmp);
g_free (tmp);
tmp2 = ip4_address_as_string (nm_utils_ip4_prefix_to_netmask (prefix));
tmp = g_strdup_printf ("%d (%s)", prefix, tmp2);
g_free (tmp2);
print_string (" Prefix", 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
tmp = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
print_string (" Gateway", tmp);
g_free (tmp);
printf ("\n");
}
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
array = nm_ip4_config_get_nameservers (cfg4);
if (array) {
int i;
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);
}
}
2008-05-06 Dan Williams <dcbw@redhat.com> * src/dhcp-manager/nm-dhcp-manager.c - (nm_dhcp_manager_get_ip4_config): clean up; update for changes to NMIP4Config to support multiple IP addresses * src/NetworkManagerUtils.c - (nm_utils_merge_ip4_config): update for multiple IP addresses * src/nm-ip4-config.c src/nm-ip4-config.h - Store a list of IPv4 address/netmask/gateway tuples - (nm_ip4_config_get_gateway, nm_ip4_config_set_gateway, nm_ip4_config_get_netmask, nm_ip4_config_set_netmask, nm_ip4_config_get_broadcast, nm_ip4_config_set_broadcast, nm_ip4_config_set_address): remove - (nm_ip4_config_take_address, nm_ip4_config_add_address, nm_ip4_config_replace_address, nm_ip4_config_get_num_addresses): new functions; handle multiple IPv4 addresses * src/nm-device.c src/ppp-manager/nm-ppp-manager.c src/vpn-manager/nm-vpn-connection.c src/NetworkManagerPolicy.c test/nm-tool.c libnm-glib/libnm-glib-test.c - update for changes to NMIP4Config for multiple IPv4 addresses * src/NetworkManagerSystem.c - (nm_system_device_set_ip4_route): don't add the route if any address is on the same subnet as the destination - (check_one_address): ignore the exact match, just match family and interface index - (add_ip4_addresses): add all IPv4 addresses in an NMIP4Config to an interface - (nm_system_device_set_from_ip4_config): use add_ip4_addresses() - (nm_system_vpn_device_set_from_ip4_config): use add_ip4_addresses() * introspection/nm-ip4-config.xml - Remove 'address', 'gateway', 'netmask', and 'broadcast' properties - Add 'addresses' property which is an array of (uuu) tuples of address/netmask/gateway * libnm-util/nm-setting-ip4-config.c - (set_property): use ip-address <-> GValue converters from nm-utils.c * libnm-glib/nm-ip4-config.c libnm-glib/nm-ip4-config.h - Handle D-Bus interface changes to support multiple IP addresses git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3637 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-05-06 21:53:22 +00:00
}
if (cfg6) {
printf ("\n IPv6 Settings:\n");
for (iter = (GSList *) nm_ip6_config_get_addresses (cfg6); iter; iter = g_slist_next (iter)) {
NMIP6Address *addr = (NMIP6Address *) iter->data;
guint32 prefix = nm_ip6_address_get_prefix (addr);
tmp = ip6_address_as_string (nm_ip6_address_get_address (addr));
print_string (" Address", tmp);
g_free (tmp);
tmp = g_strdup_printf ("%d", prefix);
print_string (" Prefix", tmp);
g_free (tmp);
tmp = ip6_address_as_string (nm_ip6_address_get_gateway (addr));
print_string (" Gateway", tmp);
g_free (tmp);
printf ("\n");
}
for (iter = (GSList *) nm_ip6_config_get_nameservers (cfg6); iter; iter = g_slist_next (iter)) {
tmp = ip6_address_as_string (iter->data);
print_string (" DNS", tmp);
g_free (tmp);
}
}
}
printf ("\n\n");
}
static const char *
get_vpn_state_string (NMVPNConnectionState state)
{
switch (state) {
case NM_VPN_CONNECTION_STATE_PREPARE:
return "connecting (prepare)";
case NM_VPN_CONNECTION_STATE_NEED_AUTH:
return "connecting (need authentication)";
case NM_VPN_CONNECTION_STATE_CONNECT:
return "connecting";
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
return "connecting (getting IP configuration)";
case NM_VPN_CONNECTION_STATE_ACTIVATED:
return "connected";
case NM_VPN_CONNECTION_STATE_FAILED:
return "connection failed";
case NM_VPN_CONNECTION_STATE_DISCONNECTED:
return "disconnected";
default:
break;
}
return "unknown";
}
static void
detail_vpn (gpointer data, gpointer user_data)
{
NMActiveConnection *active = NM_ACTIVE_CONNECTION (data);
NMConnection *connection;
NMSettingConnection *s_con;
NMVPNConnectionState state;
const char *banner;
if (!NM_IS_VPN_CONNECTION (active))
return;
connection = get_connection_for_active (active);
g_return_if_fail (connection != NULL);
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
2010-06-23 10:53:44 +02:00
g_return_if_fail (s_con != NULL);
print_header ("VPN", NULL, nm_setting_connection_get_id (s_con));
state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (active));
print_string ("State", get_vpn_state_string (state));
if (nm_active_connection_get_default (active))
print_string ("Default", "yes");
else
print_string ("Default", "no");
banner = nm_vpn_connection_get_banner (NM_VPN_CONNECTION (active));
if (banner) {
char **lines, **iter;
printf ("\n Message:\n");
lines = g_strsplit_set (banner, "\n\r", -1);
for (iter = lines; *iter; iter++) {
if (*iter && strlen (*iter))
printf (" %s\n", *iter);
}
g_strfreev (lines);
}
printf ("\n\n");
}
static void
get_one_connection (DBusGConnection *bus,
const char *path,
GHashTable *table)
{
DBusGProxy *proxy;
NMConnection *connection = NULL;
GError *error = NULL;
GHashTable *settings = NULL;
g_return_if_fail (bus != NULL);
g_return_if_fail (path != NULL);
g_return_if_fail (table != NULL);
proxy = dbus_g_proxy_new_for_name (bus, NM_DBUS_SERVICE,
2010-07-16 20:37:27 -04:00
path, NM_DBUS_IFACE_SETTINGS_CONNECTION);
if (!proxy)
return;
if (!dbus_g_proxy_call (proxy, "GetSettings", &error,
G_TYPE_INVALID,
DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
G_TYPE_INVALID)) {
nm_warning ("error: cannot retrieve connection: %s", error ? error->message : "(unknown)");
goto out;
}
connection = nm_connection_new_from_hash (settings, &error);
g_hash_table_destroy (settings);
if (!connection) {
nm_warning ("error: invalid connection: '%s' / '%s' invalid: %d",
error ? g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)) : "(unknown)",
error ? error->message : "(unknown)",
error ? error->code : -1);
goto out;
}
nm_connection_set_path (connection, path);
g_hash_table_insert (table, g_strdup (path), g_object_ref (connection));
out:
g_clear_error (&error);
if (connection)
g_object_unref (connection);
g_object_unref (proxy);
}
2010-07-16 20:37:27 -04:00
static gboolean
get_all_connections (void)
{
GError *error = NULL;
2010-07-16 20:37:27 -04:00
DBusGConnection *bus;
DBusGProxy *proxy = NULL;
GPtrArray *paths = NULL;
int i;
2010-07-16 20:37:27 -04:00
gboolean sucess = FALSE;
2010-07-16 20:37:27 -04:00
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error || !bus) {
g_warning ("error: could not connect to dbus");
goto out;
}
proxy = dbus_g_proxy_new_for_name (bus,
NM_DBUS_SERVICE,
NM_DBUS_PATH_SETTINGS,
NM_DBUS_IFACE_SETTINGS);
if (!proxy) {
2010-07-16 20:37:27 -04:00
g_warning ("error: failed to create DBus proxy for settings service");
goto out;
}
if (!dbus_g_proxy_call (proxy, "ListConnections", &error,
G_TYPE_INVALID,
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &paths,
G_TYPE_INVALID)) {
/* No connections or settings service may not be running */
g_clear_error (&error);
goto out;
}
2010-07-16 20:37:27 -04:00
connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
2010-07-16 20:37:27 -04:00
for (i = 0; paths && (i < paths->len); i++)
get_one_connection (bus, g_ptr_array_index (paths, i), connections);
2010-07-16 20:37:27 -04:00
sucess = TRUE;
2010-07-16 20:37:27 -04:00
out:
if (bus)
dbus_g_connection_unref (bus);
if (proxy)
g_object_unref (proxy);
2010-07-16 20:37:27 -04:00
return sucess;
}
int
main (int argc, char *argv[])
{
NMClient *client;
const GPtrArray *devices;
struct cb_info info;
g_type_init ();
client = nm_client_new ();
if (!client) {
exit (1);
}
printf ("\nNetworkManager Tool\n\n");
if (!get_nm_state (client)) {
g_warning ("error: could not connect to NetworkManager");
exit (1);
}
if (!get_all_connections ())
exit (1);
info.client = client;
info.active = nm_client_get_active_connections (client);
devices = nm_client_get_devices (client);
if (devices)
g_ptr_array_foreach ((GPtrArray *) devices, detail_device, &info);
if (info.active)
g_ptr_array_foreach ((GPtrArray *) info.active, detail_vpn, &info);
g_object_unref (client);
2010-07-16 20:37:27 -04:00
g_hash_table_unref (connections);
return 0;
}