summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2011-01-02 17:24:23 -0600
committerDan Williams <dcbw@redhat.com>2011-01-02 17:24:23 -0600
commit0587ef1179c7abb1c83ff5d12ce8e1b587ed0625 (patch)
tree7e66edf56183e99552e17044433e6eb234359d0b /test
parentb2f9747dba513fd34dac2b427ad1e0ac6ccb31e9 (diff)
parent15a9f29a14783fcd1b8e936a8338452737825726 (diff)
downloadNetworkManager-0587ef1179c7abb1c83ff5d12ce8e1b587ed0625.tar.gz
Merge remote branch 'origin/master' into wimax
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am4
-rwxr-xr-xtest/NMLoadModules61
-rw-r--r--test/nm-online.c4
-rw-r--r--test/nm-tool.c107
4 files changed, 84 insertions, 92 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 8e235e4322..7bdaf0db96 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,9 +10,9 @@ AM_CPPFLAGS = \
-DNM_RUN_DIR=\"$(rundir)\" \
-DDATADIR=\"$(datadir)\"
-bin_PROGRAMS = nm-tool
+bin_PROGRAMS = nm-tool nm-online
-noinst_PROGRAMS = nm-online libnm-glib-test
+noinst_PROGRAMS = libnm-glib-test
nm_tool_SOURCES = nm-tool.c
nm_tool_LDADD = \
diff --git a/test/NMLoadModules b/test/NMLoadModules
deleted file mode 100755
index 0dc6a486cc..0000000000
--- a/test/NMLoadModules
+++ /dev/null
@@ -1,61 +0,0 @@
-#! /bin/bash
-# Load kernel modules for all network devices
-
-CWD=`pwd`
-cd /etc/sysconfig/network-scripts
-
-# find all the interfaces besides loopback.
-# ignore aliases, alternative configurations, and editor backup files
-interfaces=`ls ifcfg* | LANG=C egrep -v '(ifcfg-lo|:|rpmsave|rpmorig|rpmnew)' | \
- LANG=C egrep -v '(~|\.bak)$' | \
- LANG=C egrep 'ifcfg-[A-Za-z0-9\._-]+$' | \
- sed 's/^ifcfg-//g' |
- sed 's/[0-9]/ &/' | LANG=C sort -k 1,1 -k 2n | sed 's/ //'`
-
-# bring up all other interfaces configured to come up at boot time
-for i in $interfaces; do
- eval $(LANG=C fgrep "DEVICE=" ifcfg-$i)
- eval $(LANG=C fgrep "TYPE=" ifcfg-$i)
- eval $(LANG=C fgrep "SLAVE=" ifcfg-$i)
- eval $(LANG=C fgrep "BRIDGE=" ifcfg-$i)
-
- if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi
-
- if [ "${DEVICE##cipcb}" != "$DEVICE" ] ; then
- unset DEVICE TYPE SLAVE BRIDGE
- continue
- fi
-
- if [ "$TYPE" = "xDSL" ]; then
- unset DEVICE TYPE SLAVE BRIDGE
- continue
- fi
-
- if [ -n "$BRIDGE" ]; then
- unset DEVICE TYPE SLAVE BRIDGE
- continue
- fi
-
- if [ "${DEVICE%%.*}" != "$DEVICE" ] ; then
- unset DEVICE TYPE SLAVE BRIDGE
- continue
- fi
-
- if [ "$SLAVE" = "yes" ]; then
- unset DEVICE TYPE SLAVE BRIDGE
- continue
- fi
- unset DEVICE TYPE SLAVE BRIDGE
-
- # Load the module
- LC_ALL= LANG= /sbin/ip -o link | grep -q $i
- if [ "$?" = "1" ]; then
- alias=`modprobe -c | awk "/^(alias|install)[[:space:]]+$i[[:space:]]/ { print \\$3 }"`
- if [ -n "$alias" -a "$alias" != "off" -a "$alias" != "/bin/true" ]; then
- modprobe $alias > /dev/null 2>&1
- fi
- fi
- continue
-done
-
-exit 0
diff --git a/test/nm-online.c b/test/nm-online.c
index 3827c74690..27bf1789fb 100644
--- a/test/nm-online.c
+++ b/test/nm-online.c
@@ -153,7 +153,7 @@ int main (int argc, char *argv[])
g_option_context_free (opt_ctx);
if (!success) {
- g_error ("Invalid option. Please use --help to see a list of valid options.");
+ g_warning ("Invalid option. Please use --help to see a list of valid options.");
return 2;
}
@@ -162,7 +162,7 @@ int main (int argc, char *argv[])
else
timeout.value = 30;
if (timeout.value < 0 || timeout.value > 3600) {
- g_error ("Invalid option. Please use --help to see a list of valid options.");
+ g_warning ("Invalid option. Please use --help to see a list of valid options.");
return 2;
}
diff --git a/test/nm-tool.c b/test/nm-tool.c
index dc4efb8c9d..54b7fcbbe9 100644
--- a/test/nm-tool.c
+++ b/test/nm-tool.c
@@ -16,7 +16,7 @@
* 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 - 2009 Red Hat, Inc.
+ * (C) Copyright 2005 - 2010 Red Hat, Inc.
* (C) Copyright 2007 Novell, Inc.
*/
@@ -41,6 +41,7 @@
#include <nm-wimax-device.h>
#include <nm-utils.h>
#include <nm-setting-ip4-config.h>
+#include <nm-setting-ip6-config.h>
#include <nm-vpn-connection.h>
#include <nm-setting-connection.h>
@@ -251,6 +252,28 @@ ip4_address_as_string (guint32 ip)
}
}
+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;
+ }
+}
+
static const char *
get_dev_state_string (NMDeviceState state)
{
@@ -459,38 +482,69 @@ detail_device (gpointer data, gpointer user_data)
/* IP Setup info */
if (state == NM_DEVICE_STATE_ACTIVATED) {
- NMIP4Config *cfg = nm_device_get_ip4_config (device);
+ NMIP4Config *cfg4 = nm_device_get_ip4_config (device);
+ NMIP6Config *cfg6 = nm_device_get_ip6_config (device);
GSList *iter;
- printf ("\n IPv4 Settings:\n");
+ if (cfg4) {
+ printf ("\n IPv4 Settings:\n");
- for (iter = (GSList *) nm_ip4_config_get_addresses (cfg); iter; iter = g_slist_next (iter)) {
- NMIP4Address *addr = (NMIP4Address *) iter->data;
- guint32 prefix = nm_ip4_address_get_prefix (addr);
- char *tmp2;
+ 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);
+ 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);
+ 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);
- tmp = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
- print_string (" Gateway", tmp);
- g_free (tmp);
- printf ("\n");
+ tmp = ip4_address_as_string (nm_ip4_address_get_gateway (addr));
+ print_string (" Gateway", tmp);
+ g_free (tmp);
+ printf ("\n");
+ }
+
+ 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);
+ }
+ }
}
- array = nm_ip4_config_get_nameservers (cfg);
- if (array) {
- int i;
+ 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);
- for (i = 0; i < array->len; i++) {
- tmp = ip4_address_as_string (g_array_index (array, guint32, i));
+ 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);
}
@@ -541,7 +595,7 @@ detail_vpn (gpointer data, gpointer user_data)
g_return_if_fail (connection != NULL);
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
- g_return_if_fail (connection != NULL);
+ g_return_if_fail (s_con != NULL);
print_header ("VPN", NULL, nm_setting_connection_get_id (s_con));
@@ -649,8 +703,7 @@ get_connections_for_service (DBusGConnection *bus,
G_TYPE_INVALID,
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &paths,
G_TYPE_INVALID)) {
- g_warning ("error: failed to read connections from %s:\n %s",
- service, error ? error->message : "(unknown)");
+ /* No connections or settings service may not be running */
g_clear_error (&error);
goto out;
}