summaryrefslogtreecommitdiff
path: root/netspeed/src/backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'netspeed/src/backend.c')
-rw-r--r--netspeed/src/backend.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/netspeed/src/backend.c b/netspeed/src/backend.c
index f013c170..e1321497 100644
--- a/netspeed/src/backend.c
+++ b/netspeed/src/backend.c
@@ -88,7 +88,6 @@ is_dummy_device (const char* device)
return FALSE;
}
-
/* Check for all available devices. This really should be
* portable for at least all plattforms using the gnu c lib
* TODO: drop it, use glibtop_get_netlist directly / gchar**
@@ -105,6 +104,7 @@ get_available_devices (void)
for (dev = devices; *dev; ++dev) {
device_glist = g_list_prepend (device_glist, g_strdup (*dev));
}
+ device_glist = g_list_sort (device_glist, (GCompareFunc) g_strcmp0);
g_strfreev (devices);
@@ -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)
{
@@ -243,12 +278,6 @@ get_default_route (void)
return NULL;
}
-void
-free_devices_list (GList *list)
-{
- g_list_free_full (list, g_free);
-}
-
/* Frees a DevInfo struct and all the stuff it contains
*/
void
@@ -350,7 +379,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;
@@ -476,7 +504,6 @@ out_handle_destroy:
return err;
}
-
static void
nl80211_cleanup (struct nl80211_state *state)
{
@@ -788,7 +815,7 @@ get_wireless_info (DevInfo *devinfo)
ret = nl_recvmsgs_default (nlstate.sock);
nlmsg_free (msg);
if (ret < 0) {
- g_warning ("failed to recive netlink message");
+ g_warning ("failed to receive netlink message");
}
if (!devinfo->running)
@@ -812,7 +839,7 @@ get_wireless_info (DevInfo *devinfo)
ret = nl_recvmsgs_default (nlstate.sock);
nlmsg_free (msg);
if (ret < 0) {
- g_warning ("failed to recive netlink message");
+ g_warning ("failed to receive netlink message");
goto cleanup;
}
@@ -838,7 +865,7 @@ get_wireless_info (DevInfo *devinfo)
ret = nl_recvmsgs_default (nlstate.sock);
nlmsg_free (msg);
if (ret < 0) {
- g_warning ("failed to recive netlink message");
+ g_warning ("failed to receive netlink message");
}
cleanup: