summaryrefslogtreecommitdiff
path: root/netspeed
diff options
context:
space:
mode:
Diffstat (limited to 'netspeed')
-rw-r--r--netspeed/src/backend.c36
-rw-r--r--netspeed/src/backend.h4
-rw-r--r--netspeed/src/netspeed.c89
3 files changed, 74 insertions, 55 deletions
diff --git a/netspeed/src/backend.c b/netspeed/src/backend.c
index f013c170..baff8f8d 100644
--- a/netspeed/src/backend.c
+++ b/netspeed/src/backend.c
@@ -207,6 +207,41 @@ get_ip_address_list (const char *iface_name,
return list;
}
+GSList*
+get_ip6_address_list (const char *iface_name)
+{
+ GSList *list = NULL;
+ struct ifaddrs *ifaces;
+
+ if (getifaddrs (&ifaces) != -1) {
+ char ip6[INET6_ADDRSTRLEN];
+
+ for (struct ifaddrs *iface = ifaces; iface != NULL; iface = iface->ifa_next) {
+ if ((iface->ifa_addr == NULL) || (iface->ifa_addr->sa_family != AF_INET6))
+ continue;
+
+ if (!g_strcmp0 (iface->ifa_name, iface_name)) {
+ void *sinx_addr = NULL;
+
+ struct sockaddr_in6 ip6_addr;
+
+ memcpy (&ip6_addr, iface->ifa_addr, sizeof (struct sockaddr_in6));
+
+ /* get network ip */
+ sinx_addr = &ip6_addr.sin6_addr;
+ inet_ntop (iface->ifa_addr->sa_family, sinx_addr, ip6, sizeof (ip6));
+
+ list = g_slist_prepend (list, g_strdup (ip6));
+ }
+ }
+
+ if (list != NULL)
+ list = g_slist_sort (list, (GCompareFunc) g_strcmp0);
+ freeifaddrs (ifaces);
+ }
+ return list;
+}
+
const gchar*
get_default_route (void)
{
@@ -350,7 +385,6 @@ get_device_info (const char *device,
if (devinfo->running) {
devinfo->ip = netload.address;
devinfo->netmask = netload.subnet;
- memcpy (devinfo->ipv6, netload.address6, 16);
#if defined (HAVE_NL)
if (devinfo->type != DEV_WIRELESS) {
devinfo->tx = netload.bytes_out;
diff --git a/netspeed/src/backend.h b/netspeed/src/backend.h
index cd98c66c..74344836 100644
--- a/netspeed/src/backend.h
+++ b/netspeed/src/backend.h
@@ -61,7 +61,6 @@ typedef struct {
guint32 netmask;
guint32 ptpip;
guint8 hwaddr [8]; /* EUI-48 or EUI-64 */
- guint8 ipv6 [16];
char *essid;
gboolean up;
gboolean running;
@@ -108,4 +107,7 @@ get_wireless_info (DevInfo *devinfo);
GSList*
get_ip_address_list (const char *ifa_name, gboolean ipv4);
+GSList*
+get_ip6_address_list (const char *ifa_name);
+
#endif /* _BACKEND_H */
diff --git a/netspeed/src/netspeed.c b/netspeed/src/netspeed.c
index eeb2dce4..59c016b8 100644
--- a/netspeed/src/netspeed.c
+++ b/netspeed/src/netspeed.c
@@ -518,7 +518,7 @@ redraw_graph (NetspeedApplet *netspeed,
w = gdk_window_get_width (real_window);
h = gdk_window_get_height (real_window);
- /* the graph hight should be: hight/2 <= applet->max_graph < hight */
+ /* the graph hight should be: hight/2 <= netspeed->max_graph < hight */
for (max_val = 1; max_val < netspeed->max_graph; max_val *= 2) ;
/* calculate the polygons (GdkPoint[]) for the graphs */
@@ -687,13 +687,6 @@ format_ipv4 (guint32 ip,
}
static void
-format_ipv6 (const guint8 ip[16],
- char *dest)
-{
- inet_ntop (AF_INET6, ip, dest, INET6_ADDRSTRLEN);
-}
-
-static void
fill_details_dialog (NetspeedApplet *netspeed)
{
char *text;
@@ -1371,54 +1364,44 @@ update_tooltip (NetspeedApplet *netspeed)
if (!netspeed->devinfo->running)
g_string_printf (tooltip, _("%s is down"), netspeed->devinfo->name);
else {
+ GSList *iterator;
+ GString *string = NULL;
char ipv4_text [INET_ADDRSTRLEN];
- char ipv6_text [INET6_ADDRSTRLEN];
- char *ip;
-
- if (netspeed->show_all_addresses) {
- format_ipv6 (netspeed->devinfo->ipv6, ipv6_text);
- if (netspeed->devinfo->ip) {
- format_ipv4 (netspeed->devinfo->ip, ipv4_text);
- if (strlen (ipv6_text) > 2) {
- g_string_printf (tooltip,
- _("%s: %s and %s"),
- netspeed->devinfo->name,
- ipv4_text,
- ipv6_text);
- } else {
- g_string_printf (tooltip,
- _("%s: %s"),
- netspeed->devinfo->name,
- ipv4_text);
- }
- } else {
- if (strlen (ipv6_text) > 2) {
- g_string_printf (tooltip,
- _("%s: %s"),
- netspeed->devinfo->name,
- ipv6_text);
- } else {
- g_string_printf (tooltip,
- _("%s: has no ip"),
- netspeed->devinfo->name);
- }
- }
- } else {
- if (netspeed->devinfo->ip) {
- format_ipv4 (netspeed->devinfo->ip, ipv4_text);
- ip = ipv4_text;
- } else {
- format_ipv6 (netspeed->devinfo->ipv6, ipv6_text);
- if (strlen (ipv6_text) > 2) {
- ip = ipv6_text;
- } else {
- ip = _("has no ip");
+
+ g_string_printf (tooltip, "%s: ", netspeed->devinfo->name);
+
+ if (netspeed->show_all_addresses || !netspeed->devinfo->ip) {
+ GSList *ip6_address_list = get_ip6_address_list (netspeed->devinfo->name);
+
+ /* check if we got IPv6 addresses */
+ if (ip6_address_list != NULL) {
+ for (iterator = ip6_address_list; iterator; iterator = iterator->next) {
+ if (string == NULL)
+ string = g_string_new ((char*) iterator->data);
+ else
+ g_string_append_printf (string,
+ _("\n%s"),
+ (char*) iterator->data);
}
}
- g_string_printf (tooltip,
- _("%s: %s"),
- netspeed->devinfo->name,
- ip);
+
+ g_slist_free_full (ip6_address_list, g_free);
+ }
+
+ if (!netspeed->devinfo->ip && !string) {
+ g_string_append (tooltip, "has no ip");
+ }
+
+ if (netspeed->devinfo->ip) {
+ format_ipv4 (netspeed->devinfo->ip, ipv4_text);
+ g_string_append (tooltip, ipv4_text);
+ }
+
+ if (string != NULL) {
+ g_string_append_printf (tooltip,
+ _("\n%s"),
+ string->str);
+ g_string_free (string, TRUE);
}
if (netspeed->show_sum) {