diff --git a/ChangeLog b/ChangeLog index cc9f098..ad6fed1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ v.0.5dev (ongoing development) + new driver shuttleVFD for USB-based Shuttle VFDs (Thien Vu) * enable building lcdproc client on FreeBSD AMD64 platform (M. Dolze) * Autoconf fixes for Net/FreeBSD (M. Dolze) + * fixes for the lcpdroc client iface screen on *BSD (M.Dolze) v.0.5.2 * fix switching on/off the Load screen in lcdproc client using the menu diff --git a/clients/lcdproc/machine_Darwin.c b/clients/lcdproc/machine_Darwin.c index 9ca08fb..c41cb24 100644 --- a/clients/lcdproc/machine_Darwin.c +++ b/clients/lcdproc/machine_Darwin.c @@ -479,7 +479,6 @@ static int swapmode(int *rettotal, int *retfree) /* Get network statistics */ int machine_get_iface_stats (IfaceInfo *interface) { - static int first_time = 1; /* is it first time we call this function? */ int rows; int name[6] = {CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT}; size_t len; @@ -487,7 +486,6 @@ int machine_get_iface_stats (IfaceInfo *interface) len = sizeof(rows); /* get number of interfaces */ - //if (sysctlbyname("net.link.generic.system.ifcount", &rows, &len, NULL, 0) == 0) { if (sysctl(name, 5, &rows, &len, 0, 0) == 0) { interface->status = down; /* set status down by default */ @@ -506,31 +504,32 @@ int machine_get_iface_stats (IfaceInfo *interface) } /* check if its interface name matches */ if (strcmp(ifmd.ifmd_name, interface->name) == 0) { - interface->last_online = time(NULL); /* save actual time */ - - if ((ifmd.ifmd_flags & IFF_UP) == IFF_UP) - interface->status = up; /* is up */ interface->rc_byte = ifmd.ifmd_data.ifi_ibytes; interface->tr_byte = ifmd.ifmd_data.ifi_obytes; interface->rc_pkt = ifmd.ifmd_data.ifi_ipackets; interface->tr_pkt = ifmd.ifmd_data.ifi_opackets; - if (first_time) { + if (interface->last_online == 0) { interface->rc_byte_old = interface->rc_byte; interface->tr_byte_old = interface->tr_byte; interface->rc_pkt_old = interface->rc_pkt; interface->tr_pkt_old = interface->tr_pkt; - first_time = 0; /* now it isn't first time */ } - return 1; + + if ((ifmd.ifmd_flags & IFF_UP) == IFF_UP) { + interface->status = up; /* is up */ + interface->last_online = time(NULL); /* save actual time */ + } + + return (TRUE); } } /* if we are here there is no interface with the given name */ - return 0; + return (TRUE); } else { perror("read sysctl IFMIB_IFCOUNT"); - return 0; + return (FALSE); } } /* get_iface_stats() */ diff --git a/clients/lcdproc/machine_FreeBSD.c b/clients/lcdproc/machine_FreeBSD.c index 4ca6771..ce00792 100644 --- a/clients/lcdproc/machine_FreeBSD.c +++ b/clients/lcdproc/machine_FreeBSD.c @@ -439,7 +439,6 @@ static int swapmode(int *retavail, int *retfree) */ int machine_get_iface_stats (IfaceInfo *interface) { - static int first_time = 1; /* is it first time we call this function? */ int rows; int name[6] = {CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_IFDATA, 0, IFDATA_GENERAL}; size_t len; @@ -461,31 +460,32 @@ int machine_get_iface_stats (IfaceInfo *interface) } /* check if its interface name matches */ if (strcmp(ifmd.ifmd_name, interface->name) == 0) { - interface->last_online = time(NULL); /* save actual time */ - - if ((ifmd.ifmd_flags & IFF_UP) == IFF_UP) - interface->status = up; /* is up */ interface->rc_byte = ifmd.ifmd_data.ifi_ibytes; interface->tr_byte = ifmd.ifmd_data.ifi_obytes; interface->rc_pkt = ifmd.ifmd_data.ifi_ipackets; interface->tr_pkt = ifmd.ifmd_data.ifi_opackets; - if (first_time) { + if (interface->last_online == 0) { interface->rc_byte_old = interface->rc_byte; interface->tr_byte_old = interface->tr_byte; interface->rc_pkt_old = interface->rc_pkt; interface->tr_pkt_old = interface->tr_pkt; - first_time = 0; /* now it isn't first time */ } - return 1; + + if ((ifmd.ifmd_flags & IFF_UP) == IFF_UP) { + interface->status = up; /* is up */ + interface->last_online = time(NULL); /* save actual time */ + } + + return (TRUE); } } /* if we are here there is no interface with the given name */ - return 0; + return (TRUE); } else { perror("read sysctlbyname"); - return 0; + return (FALSE); } } /* get_iface_stats() */ diff --git a/clients/lcdproc/machine_NetBSD.c b/clients/lcdproc/machine_NetBSD.c index 11abd72..5672fc9 100644 --- a/clients/lcdproc/machine_NetBSD.c +++ b/clients/lcdproc/machine_NetBSD.c @@ -380,7 +380,6 @@ int machine_get_uptime(double *up, double *idle) /* Get network statistics */ int machine_get_iface_stats (IfaceInfo *interface) { - static int first_time = 1; /* is it first time we call this function? */ struct ifaddrs *ifa, *ifa_ptr; struct if_data *ifd; @@ -397,30 +396,31 @@ int machine_get_iface_stats (IfaceInfo *interface) (ifa_ptr->ifa_addr->sa_family == AF_LINK)) { ifd = (struct if_data *)ifa_ptr->ifa_data; - interface->last_online = time(NULL); /* save actual time */ - - if ((ifa_ptr->ifa_flags & IFF_UP) == IFF_UP) - interface->status = up; /* is up */ interface->rc_byte = ifd->ifi_ibytes; interface->tr_byte = ifd->ifi_obytes; interface->rc_pkt = ifd->ifi_ipackets; interface->tr_pkt = ifd->ifi_opackets; - if (first_time) { + if (interface->last_online == 0) { interface->rc_byte_old = interface->rc_byte; interface->tr_byte_old = interface->tr_byte; interface->rc_pkt_old = interface->rc_pkt; interface->tr_pkt_old = interface->tr_pkt; - first_time = 0; /* now it isn't first time */ } - return 1; + + if ((ifa_ptr->ifa_flags & IFF_UP) == IFF_UP) { + interface->status = up; /* is up */ + interface->last_online = time(NULL); /* save actual time */ + } + + return (TRUE); } } freeifaddrs(ifa); /* if we are here there is no interface with the given name */ - return 0; + return (TRUE); } #endif /* __NetBSD__ */