- Fix networking stuff on FreeBSD (Petr Holub)
authorRoman Bogorodskiy <mirrorbox@users.sourceforge.net>
Sat, 25 Mar 2006 15:30:59 +0000 (15:30 +0000)
committerRoman Bogorodskiy <mirrorbox@users.sourceforge.net>
Sat, 25 Mar 2006 15:30:59 +0000 (15:30 +0000)
- Minor style fixes

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@611 7f574dfc-610e-0410-a909-a81674777703

src/freebsd.c

index 5265065..414f79c 100644 (file)
@@ -97,8 +97,8 @@ update_uptime()
        time_t now;
        size_t size = sizeof (boottime);
 
-       if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
-           && (boottime.tv_sec != 0)) {
+       if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1) &&
+                       (boottime.tv_sec != 0)) {
                time(&now);
                info.uptime = now - boottime.tv_sec;
        } else {
@@ -163,12 +163,23 @@ update_net_stats()
                ns = get_net_stat((const char *) ifa->ifa_name);
 
                if (ifa->ifa_flags & IFF_UP) {
+                       struct ifaddrs *iftmp;
+
+                       ns->up = 1;
+                       ns->linkstatus = 1;
                        last_recv = ns->recv;
                        last_trans = ns->trans;
 
                        if (ifa->ifa_addr->sa_family != AF_LINK)
                                continue;
 
+                       for (iftmp = ifa->ifa_next; iftmp != NULL &&
+                               strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
+                               iftmp = iftmp->ifa_next)
+                               if (iftmp->ifa_addr->sa_family == AF_INET)
+                                       memcpy(&(ns->addr), iftmp->ifa_addr,
+                                               iftmp->ifa_addr->sa_len);
+
                        ifd = (struct if_data *) ifa->ifa_data;
                        r = ifd->ifi_ibytes;
                        t = ifd->ifi_obytes;
@@ -191,10 +202,12 @@ update_net_stats()
 
                        ns->last_read_trans = t;
 
-
                        /* calculate speeds */
                        ns->recv_speed = (ns->recv - last_recv) / delta;
                        ns->trans_speed = (ns->trans - last_trans) / delta;
+               } else {
+                       ns->up = 0;
+                       ns->linkstatus = 0;
                }
        }
 
@@ -465,8 +478,8 @@ get_freq(char *p_client_buffer, size_t client_buffer_size,
 {
        int freq;
 
-       if (!p_client_buffer || client_buffer_size <= 0
-                       || !p_format || divisor <= 0)
+       if (!p_client_buffer || client_buffer_size <= 0 ||
+                       !p_format || divisor <= 0)
                return;
 
        if (GETSYSCTL("dev.cpu.0.freq", freq) == 0)