netspeed r123 - trunk/src
- From: bdejean svn gnome org
- To: svn-commits-list gnome org
- Subject: netspeed r123 - trunk/src
- Date: Wed, 2 Jul 2008 19:32:30 +0000 (UTC)
Author: bdejean
Date: Wed Jul 2 19:32:30 2008
New Revision: 123
URL: http://svn.gnome.org/viewvc/netspeed?rev=123&view=rev
Log:
Turned is_no_dummy_device into is_dummy_device (sorry think about not
not something is hard) and improved it so that the following are dummy
devices:
- loopback
- interfaces without any IPv4 address and without any non-scope-link
IPv6 address.
Modified:
trunk/src/backend.c
trunk/src/backend.h
trunk/src/netspeed.c
Modified: trunk/src/backend.c
==============================================================================
--- trunk/src/backend.c (original)
+++ trunk/src/backend.c Wed Jul 2 19:32:30 2008
@@ -27,9 +27,27 @@
#include "backend.h"
gboolean
-is_no_dummy_device(const char* device)
+is_dummy_device(const char* device)
{
- return !g_str_has_prefix(device, "lo") && !g_str_has_prefix(device, "dummy");
+ glibtop_netload netload;
+ glibtop_get_netload(&netload, device);
+
+ if (netload.if_flags & (1 << GLIBTOP_IF_FLAGS_LOOPBACK))
+ return TRUE;
+
+ /* Skip interfaces without any IPv4/IPv6 address (or
+ those with only a LINK ipv6 addr) However we need to
+ be able to exclude these while still keeping the
+ value so when they get online (with NetworkManager
+ for example) we don't get a suddent peak. Once we're
+ able to get this, ignoring down interfaces will be
+ possible too. */
+ if (!(netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS6)
+ && netload.scope6 != GLIBTOP_IF_IN6_SCOPE_LINK)
+ && !(netload.flags & (1 << GLIBTOP_NETLOAD_ADDRESS)))
+ return TRUE;
+
+ return FALSE;
}
@@ -77,7 +95,7 @@
if (retval != 11) continue;
- if (gw == 0 && is_no_dummy_device(device)) {
+ if (gw == 0 && !is_dummy_device(device)) {
fclose(fp);
return device;
}
Modified: trunk/src/backend.h
==============================================================================
--- trunk/src/backend.h (original)
+++ trunk/src/backend.h Wed Jul 2 19:32:30 2008
@@ -76,7 +76,7 @@
get_default_route(void);
gboolean
-is_no_dummy_device(const char* device);
+is_dummy_device(const char* device);
void
free_devices_list(GList *list);
Modified: trunk/src/netspeed.c
==============================================================================
--- trunk/src/netspeed.c (original)
+++ trunk/src/netspeed.c Wed Jul 2 19:32:30 2008
@@ -556,7 +556,7 @@
devices = get_available_devices();
for (tmp = devices; tmp; tmp = g_list_next(tmp)) {
- if (is_no_dummy_device(tmp->data) == FALSE)
+ if (is_dummy_device(tmp->data))
continue;
if (set_applet_devinfo(applet, tmp->data))
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]