head 1.10; access; symbols pkgsrc-2013Q2:1.10.0.26 pkgsrc-2013Q2-base:1.10 pkgsrc-2012Q4:1.10.0.24 pkgsrc-2012Q4-base:1.10 pkgsrc-2011Q4:1.10.0.22 pkgsrc-2011Q4-base:1.10 pkgsrc-2011Q2:1.10.0.20 pkgsrc-2011Q2-base:1.10 pkgsrc-2009Q4:1.10.0.18 pkgsrc-2009Q4-base:1.10 pkgsrc-2008Q4:1.10.0.16 pkgsrc-2008Q4-base:1.10 pkgsrc-2008Q3:1.10.0.14 pkgsrc-2008Q3-base:1.10 cube-native-xorg:1.10.0.12 cube-native-xorg-base:1.10 pkgsrc-2008Q2:1.10.0.10 pkgsrc-2008Q2-base:1.10 pkgsrc-2008Q1:1.10.0.8 pkgsrc-2008Q1-base:1.10 pkgsrc-2007Q4:1.10.0.6 pkgsrc-2007Q4-base:1.10 pkgsrc-2007Q3:1.10.0.4 pkgsrc-2007Q3-base:1.10 pkgsrc-2007Q2:1.10.0.2 pkgsrc-2007Q2-base:1.10 pkgsrc-2007Q1:1.9.0.12 pkgsrc-2007Q1-base:1.9 pkgsrc-2006Q4:1.9.0.10 pkgsrc-2006Q4-base:1.9 pkgsrc-2006Q3:1.9.0.8 pkgsrc-2006Q3-base:1.9 pkgsrc-2006Q2:1.9.0.6 pkgsrc-2006Q2-base:1.9 pkgsrc-2006Q1:1.9.0.4 pkgsrc-2006Q1-base:1.9 pkgsrc-2005Q4:1.9.0.2 pkgsrc-2005Q4-base:1.9 pkgsrc-2005Q3:1.8.0.16 pkgsrc-2005Q3-base:1.8 pkgsrc-2005Q2:1.8.0.14 pkgsrc-2005Q2-base:1.8 pkgsrc-2005Q1:1.8.0.12 pkgsrc-2005Q1-base:1.8 pkgsrc-2004Q4:1.8.0.10 pkgsrc-2004Q4-base:1.8 pkgsrc-2004Q3:1.8.0.8 pkgsrc-2004Q3-base:1.8 pkgsrc-2004Q2:1.8.0.6 pkgsrc-2004Q2-base:1.8 pkgsrc-2004Q1:1.8.0.4 pkgsrc-2004Q1-base:1.8 pkgsrc-2003Q4:1.8.0.2 pkgsrc-2003Q4-base:1.8 netbsd-1-6-1:1.7.0.2 netbsd-1-6-1-base:1.7 netbsd-1-6:1.1.1.1.0.4 netbsd-1-6-RELEASE-base:1.1 pkgviews:1.1.1.1.0.6 pkgviews-base:1.1 buildlink2-base:1.4 buildlink2:1.1.1.1.0.2 pkg-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.10 date 2007.05.23.13.05.37; author markd; state dead; branches; next 1.9; 1.9 date 2005.11.08.18.25.44; author joerg; state Exp; branches; next 1.8; 1.8 date 2003.03.11.13.10.26; author markd; state dead; branches; next 1.7; 1.7 date 2003.01.04.15.04.46; author skrll; state Exp; branches; next 1.6; 1.6 date 2003.01.02.09.12.35; author skrll; state Exp; branches; next 1.5; 1.5 date 2002.08.25.19.23.45; author jlam; state Exp; branches; next 1.4; 1.4 date 2002.08.21.16.00.13; author skrll; state Exp; branches; next 1.3; 1.3 date 2002.08.21.15.33.06; author skrll; state Exp; branches; next 1.2; 1.2 date 2002.08.20.11.48.25; author skrll; state Exp; branches; next 1.1; 1.1 date 2002.05.31.13.19.18; author skrll; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2002.05.31.13.19.18; author skrll; state Exp; branches 1.1.1.1.2.1 1.1.1.1.4.1; next ; 1.1.1.1.2.1 date 2002.05.31.13.19.18; author jlam; state dead; branches; next 1.1.1.1.2.2; 1.1.1.1.2.2 date 2002.06.23.19.05.49; author jlam; state Exp; branches; next 1.1.1.1.2.3; 1.1.1.1.2.3 date 2002.08.22.11.13.29; author jlam; state Exp; branches; next ; 1.1.1.1.4.1 date 2002.08.20.13.03.41; author wiz; state Exp; branches; next ; desc @@ 1.10 log @Update to KDE 3.5.7 KDE base * Various DragonFlyBSD fixes. * Removed "Serbia and Montenegro" (yu), added "Serbia" (rs) and "Montenegro" (me). Kicker * Added option to change the font color used by the taskbar applet. Kate * Fix not honoring current locale in some situations. KControl * Allow changing of font colors for taskbar. * Fix various crashes on KHotKeys. KDesktop * Use mkfontscale/mkfontdir to create fonts.scale/fonts.dir - as opposed to custom code. * Make kdesktop_lock honour kiosk switch user restriction. KWin * Option to turn off alt+tab outline. * Support for new windows types for compositing. * Fix bug in dead program detection in 64 bit architectures. * Fix crash on consecutive 'Show Desktop'. @ text @$NetBSD: patch-df,v 1.9 2005/11/08 18:25:44 joerg Exp $ --- ksysguard/ksysguardd/FreeBSD/ProcessList.c.orig 2005-08-18 00:27:47.000000000 +0000 +++ ksysguard/ksysguardd/FreeBSD/ProcessList.c @@@@ -217,23 +217,25 @@@@ updateProcess(int pid) ps->ppid = p.kp_eproc.e_ppid; ps->uid = p.kp_eproc.e_ucred.cr_uid; ps->gid = p.kp_eproc.e_pgid; +#if defined(__DragonFly__) + ps->priority = p.kp_thread.td_pri; +#else ps->priority = p.kp_proc.p_priority; +#endif ps->niceLevel = p.kp_proc.p_nice; #endif /* this isn't usertime -- it's total time (??) */ #if __FreeBSD_version >= 500015 ps->userTime = p.ki_runtime / 10000; -#elif __FreeBSD_version >= 300000 -#if defined(__DragonFly__) +#elif defined(__DragonFly__) if (!getrusage(p.kp_proc.p_pid, &pru)) { errx(1, "failed to get rusage info"); } ps->userTime = pru.ru_utime.tv_usec / 1000; /*p_runtime / 1000*/ -#else +#elif __FreeBSD_version >= 300000 ps->userTime = p.kp_proc.p_runtime / 10000; -#endif #else ps->userTime = p.kp_proc.p_rtime.tv_sec*100+p.kp_proc.p_rtime.tv_usec/100; #endif @ 1.9 log @Add support for building on DragonFly. Add mkfontdir as build tool, non-native bulk builds fail otherwise. @ text @d1 1 a1 1 $NetBSD$ @ 1.8 log @Update KDE to 3.1. Many bugfixes and functionality enhancements including: General New default widget style: Keramik New default icon theme: Crystal Created and enhanced framework to effectively disable certain features of the GUI, like for example shell access, disallowing to select custom wall papers. "Kiosk mode" Usability improvements: Kicker: Context menu, applet menus, wording and panel feature consistency improved Kicker: Redesigned control module. KCalc: Usability Improvements. KSnapshot: Usability Improvements. KsCD: User Interface Improvements in configuration and information dialogs kdelibs Extended the DCOP commandline client to enable nonGUI applications (such as shell scripts) to use DCOP send DCOP messages to multiple users and/or sessions concurrently Added to notification dialog to allow applications to configure their notifications with a common GUI. Added "Open File", "Open Destination" and "Keep window open" to download progress dialog. KDatePicker has now week number display and selection. Added KLocale support for setting/retrieving the first day of a week Support for "Multimedia keys" on your keyboard. Added on-demand icon loading support to improve startup performance of applications. KHTML: Improvements to printing support. Page Info and Frame info dialog. Auto-Scroll support of webpages using Shift combined with arrow keys. Many, many Bugfixes and improvements. Small codebase merges with Safari. The main merge is planned for a future release however, as it requires more testing. KIO: Modified thumbnail ioslave that can extract a thumbnail from the file directly if it contains one, rather than generating one itself. Added fish:// protocol slave, which can access remote filesystems via SSH and SCP Cleanups and Corrections in smtp:// protocol slave. Activated rtsp:// protocol slave. Added support for Public Key Authentication and interopability with newer versions of OpenSSH to sftp:// protocol slave. KSSL: SSL certificate policies can now be configured based on the host name @ text @d1 1 a1 1 $NetBSD: patch-df,v 1.7 2003/01/04 15:04:46 skrll Exp $ d3 23 a25 406 --- ksysguard/ksysguardd/FreeBSD/netdev.c.orig Tue Nov 5 02:41:09 2002 +++ ksysguard/ksysguardd/FreeBSD/netdev.c @@@@ -20,300 +20,265 @@@@ */ #include +#include #include +#include #include -#include - +#include #include -#include - -#include -#include +#include +#include #include -#include #include "Command.h" #include "ksysguardd.h" #include "netdev.h" +#define I_bytes 0 +#define I_packs 1 +#define I_errs 2 +#define I_mcasts 3 +#define I_lost 4 typedef struct { char name[32]; - u_long recBytes; - u_long recPacks; - u_long recErrs; - u_long recDrop; - u_long recMulticast; - u_long sentBytes; - u_long sentPacks; - u_long sentErrs; - u_long sentMulticast; - u_long sentColls; + u_long recv[5],Drecv[5],sent[5],Dsent[5]; } NetDevInfo; +#define LEN(X) (sizeof(X)/sizeof(X[0])) + #define MAXNETDEVS 64 -static NetDevInfo NetDevs[MAXNETDEVS]; +static NetDevInfo NetDevs[MAXNETDEVS], newval[MAXNETDEVS]; static int NetDevCnt = 0; -char **parseCommand(const char *cmd) -{ - char tmp_cmd[1024]; - char *begin; - static char sensor[100]; - static char interface[100]; - static char *retval[2]; - - strncpy(tmp_cmd, cmd, 1024); - - begin = rindex(tmp_cmd, '/'); - *begin = '\0'; - begin++; - strcpy(sensor, begin); - retval[1] = sensor; - - begin = rindex(tmp_cmd, '/'); - *begin = '\0'; - begin = rindex(tmp_cmd, '/'); - begin++; - strcpy(interface, begin); - retval[0] = interface; - return retval; -} - -int numActivIfaces(void) -{ - int counter = 0; - int name[6]; - int num_iface, i; +/* Read the system's traffic registers. + * Merely count the IFs if countp nonzero. + * Returns count of IFs read, or -1; the data are written into newval. + * Based on getifaddrs source; getifaddrs itself seems to + * compile incorrectly, omitting the traffic data. (It also + * does things this doesn't need, thus this is slightly more efficient.) + */ +static int readSys(int countp) { size_t len; - struct ifmibdata ifmd; - - len = sizeof(num_iface); - sysctlbyname("net.link.generic.system.ifcount", &num_iface, &len, NULL, 0); - - for (i = 1; i < num_iface + 1; i++) { - name[0] = CTL_NET; - name[1] = PF_LINK; - name[2] = NETLINK_GENERIC; - name[3] = IFMIB_IFDATA; - name[4] = i; - name[5] = IFDATA_GENERAL; - - len = sizeof(ifmd); - sysctl(name, 6, &ifmd, &len, NULL, 0); - if (ifmd.ifmd_flags & IFF_UP) - counter++; + char *bfr, *ptr; + struct rt_msghdr *rtm; + NetDevInfo *nv; + static int mib[] = { + /* see sysctl(3): */ + CTL_NET, + PF_ROUTE, + 0, /* `currently always 0' */ + 0, /* `may be set to 0 to select all address families' */ + NET_RT_IFLIST, + 0 /* ignored but six levels are needed */ + }; + + if (-1==sysctl(mib, LEN(mib), NULL, &len, NULL, 0)) + return -1; + if (!(bfr = malloc(len))) + return -1; + if (-1==sysctl(mib, LEN(mib), bfr, &len, NULL, 0)) { + free(bfr); + return -1; } + nv = newval; + for (ptr=bfr; ptrrtm_msglen) { + struct if_msghdr *ifm; + + rtm = (void*)ptr; /* chg ptr type to router msg */ + if (rtm->rtm_version != RTM_VERSION) continue; + if (rtm->rtm_type != RTM_IFINFO) continue; + ifm = (void*)rtm; /* chg ptr type to interface msg */ + if (!(ifm->ifm_flags & IFF_UP)) continue; + + if (!countp) { + /* a sdl is concat'd to the if msg */ + struct sockaddr_dl *sdl = (void*)(ifm+1); + + /* copy and terminate the name */ + /*fixme: check for overruns */ + memcpy(nv->name, sdl->sdl_data, sdl->sdl_nlen); + nv->name[sdl->sdl_nlen] = 0; + + /* copy the data */ + nv->recv[I_bytes] = ifm->ifm_data.ifi_ibytes; + nv->recv[I_packs] = ifm->ifm_data.ifi_ipackets; + nv->recv[I_errs] = ifm->ifm_data.ifi_ierrors; + nv->recv[I_mcasts] = ifm->ifm_data.ifi_imcasts; + nv->recv[I_lost] = ifm->ifm_data.ifi_iqdrops; + nv->sent[I_bytes] = ifm->ifm_data.ifi_obytes; + nv->sent[I_packs] = ifm->ifm_data.ifi_opackets; + nv->sent[I_errs] = ifm->ifm_data.ifi_oerrors; + nv->sent[I_mcasts] = ifm->ifm_data.ifi_omcasts; + nv->sent[I_lost] = ifm->ifm_data.ifi_collisions; + } - return counter; + /*fixme: guard against buffer overrun */ + nv++; + } + free(bfr); + return nv-newval; } + + + /* ------------------------------ public part --------------------------- */ -void initNetDev(void) -{ - int i; - char monitor[1024]; +static void prVal(const char*, int); +void printNetDevRecv(const char *cmd) { prVal(cmd,0); } +void printNetDevSent(const char *cmd) { prVal(cmd,1); } + +static void prInfo(const char*, int); +void printNetDevRecvInfo(const char *cmd) { prInfo(cmd,0); } +void printNetDevSentInfo(const char *cmd) { prInfo(cmd,1); } + +static struct { + char *label; + cmdExecutor read, inform; + struct { + char *label, *info; + int index; + } op[5]; +} opTable[] = { + {"receiver", + printNetDevRecv, printNetDevRecvInfo, + {{"data", "Received Data\t0\t0\tB/s\n", I_bytes}, + {"packets", "Received Packets\t0\t0\tHz\n", I_packs}, + {"errors", "Receiver Errors\t0\t0\tHz\n", I_errs}, + {"multicast", "Received Multicast Packets\t0\t0\tHz\n", I_mcasts}, + {"drops", "Receiver Drops\t0\t0\tHz\n", I_lost}}}, + {"transmitter", + printNetDevSent, printNetDevSentInfo, + {{"data", "Sent Data\t0\t0\tB/s\n", I_bytes}, + {"packets", "Sent Packets\t0\t0\tHz\n", I_packs}, + {"errors", "Transmitter Errors\t0\t0\tHz\n", I_errs}, + {"multicast", "Sent Multicast Packets\t0\t0\tHz\n", I_mcasts}, + {"collisions", "Transmitter Collisions\t0\t0\tHz\n", I_lost}}} +}; + + +static void prVal(const char *cmd, int N) { + char *p, *q, *r; + int i, d; - updateNetDev(); - - for (i = 0; i < NetDevCnt; i++) { - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/data", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/packets", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/errors", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/drops", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/multicast", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/data", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/packets", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/errors", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/multicast", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/collisions", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - } + if (!(p=rindex(cmd, '/'))) + return; + *p=0; + q=rindex(cmd, '/'); + *q=0; + r=rindex(cmd, '/'); + r++; + for (d=NetDevCnt; d--; ) + if (!strcmp(r, NetDevs[d].name)) + break; + *q=*p='/'; + + if (-1 == d) return; + + p++; + for (i=0; iDrecv[i] = q->recv[i]-p->recv[i]; + p->recv[i] = q->recv[i]; + p->Dsent[i] = q->sent[i]-p->sent[i]; + p->sent[i] = q->sent[i]; } } - - fprintf(CurrentClient, "\n"); } -void printNetDevSentBytesInfo(const char *cmd) -{ - char **retval; - - retval = parseCommand(cmd); - - if (retval[1] == NULL) - return; - if (!strncmp(retval[1], "data", 4)) - fprintf(CurrentClient, "Sent Data\t0\t0\tkBytes/s\n"); - if (!strncmp(retval[1], "packets", 7)) - fprintf(CurrentClient, "Sent Packets\t0\t0\t1/s\n"); - if (!strncmp(retval[1], "errors", 6)) - fprintf(CurrentClient, "Transmitter Errors\t0\t0\t1/s\n"); - if (!strncmp(retval[1], "multicast", 9)) - fprintf(CurrentClient, "Sent Multicast Packets\t0\t0\t1/s\n"); - if (!strncmp(retval[1], "collisions", 10)) - fprintf(CurrentClient, "Transmitter Collisions\t0\t0\t1/s\n"); +void checkNetDev(void) { + if (readSys(!0) != NetDevCnt) { + /* interface has been added or removed + so we do a reset */ + exitNetDev(); + initNetDev(); + } } + + +/* eof */ @ 1.7 log @Fix a couple of mistakes. @ text @d1 1 a1 1 $NetBSD$ @ 1.6 log @Update KDE to the 3.0.5a distribution. Packages are numbered 3.0.5.1 or 1.0.5.1 accordingly. Fixes and changes are: Multiple vulnerabilities. kdelibs KHTML : Fixed several crashes and misrenderings. rlogin.protocol: fixed command execution in specially crafted urls. kdebase KAddressbook: Don't squeeze columns on startup/properly restore column width settings. kdenetwork lisa, reslisa: Fixed several security vulnerabilities. kdesdk Cervisia: Show long lines in diff view always completely. @ text @d1 2 d4 2 a5 16 +++ ksysguard/ksysguardd/FreeBSD/netdev.c Tue Nov 26 11:56:27 2002 @@@@ -1,7 +1,7 @@@@ /* KSysGuard, the KDE System Guard - Copyright (c) 2001 Tobias Koenig + Copyright (c) 2001 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public @@@@ -16,304 +16,269 @@@@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: netdev.c,v 1.2.2.1 2002/10/10 05:11:28 garbanzo Exp $ + $Id: netdev.c,v 1.2 2001/09/18 14:03:53 tokoe Exp $ d8 1 a8 2 -#include +#include /* for sys/socket.h, ifaddrs.h */ d11 1 a11 1 +#include /* for sys/sysctl.h */ @ 1.5 log @Merge changes in packages from the buildlink2 branch that have buildlink2.mk files back into the main trunk. @ text @d1 17 a17 5 $NetBSD: patch-df,v 1.1.2.2 2002/08/22 11:13:29 jlam Exp $ --- ksysguard/ksysguardd/FreeBSD/netdev.c.orig Wed Aug 21 17:39:19 2002 +++ ksysguard/ksysguardd/FreeBSD/netdev.c @@@@ -20,15 +20,14 @@@@ d20 1 a20 1 -#include d25 3 a27 1 +#include d31 2 a36 3 -#include -#include -#include a37 1 - d40 1 a40 1 @@@@ -36,284 +35,250 @@@@ a42 1 - d76 1 a76 1 - static char* retval[2]; d92 1 a92 1 - d95 1 a95 1 @ 1.4 log @Arrggh... I've been looking at this screen for far too long today. Make sure the patch doesn't include an RCS Id. @ text @d1 1 a1 1 $NetBSD$ @ 1.3 log @Apply the fixes provided in pkg/17912 and pkg/17981 so that ksysguardd can show something useful. Both PRs are from Hume Smith PKGREVISION++ @ text @d3 5 a7 24 --- ksysguard/ksysguardd/FreeBSD/netdev.c.orig Tue Sep 18 15:03:53 2001 +++ ksysguard/ksysguardd/FreeBSD/netdev.c Tue Aug 20 13:51:32 2002 @@@@ -1,319 +1,263 @@@@ -/* - KSysGuard, the KDE System Guard - - Copyright (c) 2001 Tobias Koenig - - This program is free software; you can redistribute it and/or - modify it under the terms of version 2 of the GNU General Public - License as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - $Id: netdev.c,v 1.2 2001/09/18 14:03:53 tokoe Exp $ -*/ - d28 1 a28 1 #include "ksysguardd.h" d81 1 a81 1 d84 1 a84 1 - d273 1 a273 4 + +static void prInfo(const char *cmd, int N) { + char *p, *q; int i; d300 3 a302 2 + if (!(p=rindex(cmd, '/'))) return; + p++; d310 5 a322 3 - len = sizeof(num_iface); - sysctlbyname("net.link.generic.system.ifcount", &num_iface, &len, NULL, 0); - @ 1.2 log @Plug the memory leak introduced into ksysguardd. Fixes pkg/17962 from hclsmith at yahoo dot ca. One day I might even get round to finishing NetBSD support for ksysguardd. PKGREVISION++ @ text @d4 25 a28 7 +++ ksysguard/ksysguardd/FreeBSD/netdev.c @@@@ -20,4 +20,11 @@@@ */ +#if defined(__NetBSD__) +#include +#include a29 4 +#include +#include +#else #include d31 14 a44 4 @@@@ -30,4 +37,5 @@@@ #include #include +#endif d46 3 d50 115 a164 3 @@@@ -84,4 +92,17 @@@@ int numActivIfaces(void) { int counter = 0; d166 3 a168 2 +#if defined(__NetBSD__) + struct ifaddrs *ifap, *ifa; d170 4 a173 2 + if (getifaddrs(&ifap) != 0) + return 0; d175 16 a190 3 + for (ifa = ifap; ifa; ifa=ifa->ifa_next) { + if (ifa->ifa_flags & IFF_UP) + counter++; d192 8 a199 8 + freeifaddrs(ifap); +#else int name[6]; int num_iface, i; @@@@ -105,4 +126,5 @@@@ int numActivIfaces(void) counter++; } +#endif d201 35 a235 6 return counter; @@@@ -175,4 +197,16 @@@@ void exitNetDev(void) void updateNetDev(void) { +#if defined(__NetBSD__) + struct ifaddrs *ifap, *ifa; d237 31 a267 1 + if (getifaddrs(&ifap) != 0) d269 65 d335 167 a501 9 + for (ifa = ifap; ifa; ifa=ifa->ifa_next) { + if (ifa->ifa_flags & IFF_UP) + ; + } + freeifaddrs(ifap); +#else int name[6]; int num_iface, i; @@@@ -209,4 +243,5 @@@@ void updateNetDev(void) d504 2 a505 1 +#endif d508 30 @ 1.1 log @Initial revision @ text @d23 1 a23 1 @@@@ -84,4 +92,16 @@@@ d37 1 d41 1 a41 1 @@@@ -105,4 +125,5 @@@@ d47 1 a47 1 @@@@ -175,4 +196,15 @@@@ d60 1 d64 1 a64 1 @@@@ -209,4 +241,5 @@@@ @ 1.1.1.1 log @Initial import of a kdebase3 pkg @ text @@ 1.1.1.1.2.1 log @file patch-df was added on branch buildlink2 on 2002-06-23 19:05:49 +0000 @ text @d1 67 @ 1.1.1.1.2.2 log @Merge from pkgsrc-current to buildlink2 branch. @ text @a0 67 $NetBSD: patch-df,v 1.1.1.1.2.1 2002/06/23 19:05:49 jlam Exp $ --- ksysguard/ksysguardd/FreeBSD/netdev.c.orig Tue Sep 18 15:03:53 2001 +++ ksysguard/ksysguardd/FreeBSD/netdev.c @@@@ -20,4 +20,11 @@@@ */ +#if defined(__NetBSD__) +#include +#include +#include +#include +#include +#else #include #include @@@@ -30,4 +37,5 @@@@ #include #include +#endif @@@@ -84,4 +92,16 @@@@ { int counter = 0; + +#if defined(__NetBSD__) + struct ifaddrs *ifap, *ifa; + + if (getifaddrs(&ifap) != 0) + return 0; + + for (ifa = ifap; ifa; ifa=ifa->ifa_next) { + if (ifa->ifa_flags & IFF_UP) + counter++; + } +#else int name[6]; int num_iface, i; @@@@ -105,4 +125,5 @@@@ counter++; } +#endif return counter; @@@@ -175,4 +196,15 @@@@ void updateNetDev(void) { +#if defined(__NetBSD__) + struct ifaddrs *ifap, *ifa; + + if (getifaddrs(&ifap) != 0) + return; + + for (ifa = ifap; ifa; ifa=ifa->ifa_next) { + if (ifa->ifa_flags & IFF_UP) + ; + } +#else int name[6]; int num_iface, i; @@@@ -209,4 +241,5 @@@@ } } +#endif } @ 1.1.1.1.2.3 log @Merge changes from pkgsrc-current into the buildlink2 branch for the packages that have buildlink2.mk files. @ text @d1 1 a1 1 $NetBSD: patch-df,v 1.1.1.1.2.2 2002/08/22 11:13:29 jlam Exp $ d3 1 a3 1 --- ksysguard/ksysguardd/FreeBSD/netdev.c.orig Wed Aug 21 17:39:19 2002 d5 1 a5 1 @@@@ -20,15 +20,14 @@@@ d8 3 a10 2 -#include +#include /* for sys/socket.h, ifaddrs.h */ d12 4 d17 4 a20 14 +#include /* for sys/sysctl.h */ +#include +#include #include -#include -#include +#include +#include #include -#include -#include -#include -#include - a21 3 #include "Command.h" @@@@ -36,284 +35,250 @@@@ #include "netdev.h" d23 3 a25 115 - +#define I_bytes 0 +#define I_packs 1 +#define I_errs 2 +#define I_mcasts 3 +#define I_lost 4 typedef struct { char name[32]; - u_long recBytes; - u_long recPacks; - u_long recErrs; - u_long recDrop; - u_long recMulticast; - u_long sentBytes; - u_long sentPacks; - u_long sentErrs; - u_long sentMulticast; - u_long sentColls; + u_long recv[5],Drecv[5],sent[5],Dsent[5]; } NetDevInfo; +#define LEN(X) (sizeof(X)/sizeof(X[0])) + #define MAXNETDEVS 64 -static NetDevInfo NetDevs[MAXNETDEVS]; +static NetDevInfo NetDevs[MAXNETDEVS], newval[MAXNETDEVS]; static int NetDevCnt = 0; -char **parseCommand(const char *cmd) -{ - char tmp_cmd[1024]; - char *begin; - static char sensor[100]; - static char interface[100]; - static char* retval[2]; - - strncpy(tmp_cmd, cmd, 1024); - - begin = rindex(tmp_cmd, '/'); - *begin = '\0'; - begin++; - strcpy(sensor, begin); - retval[1] = sensor; - - begin = rindex(tmp_cmd, '/'); - *begin = '\0'; - begin = rindex(tmp_cmd, '/'); - begin++; - strcpy(interface, begin); - retval[0] = interface; - - return retval; -} -int numActivIfaces(void) -{ - int counter = 0; - int name[6]; - int num_iface, i; +/* Read the system's traffic registers. + * Merely count the IFs if countp nonzero. + * Returns count of IFs read, or -1; the data are written into newval. + * Based on getifaddrs source; getifaddrs itself seems to + * compile incorrectly, omitting the traffic data. (It also + * does things this doesn't need, thus this is slightly more efficient.) + */ +static int readSys(int countp) { size_t len; - struct ifmibdata ifmd; - - len = sizeof(num_iface); - sysctlbyname("net.link.generic.system.ifcount", &num_iface, &len, NULL, 0); - - for (i = 1; i < num_iface + 1; i++) { - name[0] = CTL_NET; - name[1] = PF_LINK; - name[2] = NETLINK_GENERIC; - name[3] = IFMIB_IFDATA; - name[4] = i; - name[5] = IFDATA_GENERAL; - - len = sizeof(ifmd); - sysctl(name, 6, &ifmd, &len, NULL, 0); - if (ifmd.ifmd_flags & IFF_UP) - counter++; + char *bfr, *ptr; + struct rt_msghdr *rtm; + NetDevInfo *nv; + static int mib[] = { + /* see sysctl(3): */ + CTL_NET, + PF_ROUTE, + 0, /* `currently always 0' */ + 0, /* `may be set to 0 to select all address families' */ + NET_RT_IFLIST, + 0 /* ignored but six levels are needed */ + }; + + if (-1==sysctl(mib, LEN(mib), NULL, &len, NULL, 0)) + return -1; + if (!(bfr = malloc(len))) + return -1; + if (-1==sysctl(mib, LEN(mib), bfr, &len, NULL, 0)) { + free(bfr); + return -1; } + nv = newval; + for (ptr=bfr; ptrrtm_msglen) { + struct if_msghdr *ifm; + + rtm = (void*)ptr; /* chg ptr type to router msg */ + if (rtm->rtm_version != RTM_VERSION) continue; + if (rtm->rtm_type != RTM_IFINFO) continue; + ifm = (void*)rtm; /* chg ptr type to interface msg */ + if (!(ifm->ifm_flags & IFF_UP)) continue; d27 2 a28 3 + if (!countp) { + /* a sdl is concat'd to the if msg */ + struct sockaddr_dl *sdl = (void*)(ifm+1); d30 2 a31 4 + /* copy and terminate the name */ + /*fixme: check for overruns */ + memcpy(nv->name, sdl->sdl_data, sdl->sdl_nlen); + nv->name[sdl->sdl_nlen] = 0; d33 3 a35 16 + /* copy the data */ + nv->recv[I_bytes] = ifm->ifm_data.ifi_ibytes; + nv->recv[I_packs] = ifm->ifm_data.ifi_ipackets; + nv->recv[I_errs] = ifm->ifm_data.ifi_ierrors; + nv->recv[I_mcasts] = ifm->ifm_data.ifi_imcasts; + nv->recv[I_lost] = ifm->ifm_data.ifi_iqdrops; + nv->sent[I_bytes] = ifm->ifm_data.ifi_obytes; + nv->sent[I_packs] = ifm->ifm_data.ifi_opackets; + nv->sent[I_errs] = ifm->ifm_data.ifi_oerrors; + nv->sent[I_mcasts] = ifm->ifm_data.ifi_omcasts; + nv->sent[I_lost] = ifm->ifm_data.ifi_collisions; + } - return counter; + /*fixme: guard against buffer overrun */ + nv++; d37 7 a43 3 + free(bfr); + return nv-newval; } d45 6 d52 1 a52 71 + + /* ------------------------------ public part --------------------------- */ -void initNetDev(void) -{ - int i; - char monitor[1024]; +static void prVal(const char*, int); +void printNetDevRecv(const char *cmd) { prVal(cmd,0); } +void printNetDevSent(const char *cmd) { prVal(cmd,1); } + +static void prInfo(const char*, int); +void printNetDevRecvInfo(const char *cmd) { prInfo(cmd,0); } +void printNetDevSentInfo(const char *cmd) { prInfo(cmd,1); } + +static struct { + char *label; + cmdExecutor read, inform; + struct { + char *label, *info; + int index; + } op[5]; +} opTable[] = { + {"receiver", + printNetDevRecv, printNetDevRecvInfo, + {{"data", "Received Data\t0\t0\tB/s\n", I_bytes}, + {"packets", "Received Packets\t0\t0\tHz\n", I_packs}, + {"errors", "Receiver Errors\t0\t0\tHz\n", I_errs}, + {"multicast", "Received Multicast Packets\t0\t0\tHz\n", I_mcasts}, + {"drops", "Receiver Drops\t0\t0\tHz\n", I_lost}}}, + {"transmitter", + printNetDevSent, printNetDevSentInfo, + {{"data", "Sent Data\t0\t0\tB/s\n", I_bytes}, + {"packets", "Sent Packets\t0\t0\tHz\n", I_packs}, + {"errors", "Transmitter Errors\t0\t0\tHz\n", I_errs}, + {"multicast", "Sent Multicast Packets\t0\t0\tHz\n", I_mcasts}, + {"collisions", "Transmitter Collisions\t0\t0\tHz\n", I_lost}}} +}; + + +static void prVal(const char *cmd, int N) { + char *p, *q, *r; + int i, d; - updateNetDev(); - - for (i = 0; i < NetDevCnt; i++) { - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/data", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/packets", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/errors", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/drops", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/receiver/multicast", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevRecBytes, printNetDevRecBytesInfo); - - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/data", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/packets", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/errors", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/multicast", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - snprintf(monitor, sizeof(monitor), "network/interfaces/%s/transmitter/collisions", NetDevs[i].name); - registerMonitor(monitor, "integer", printNetDevSentBytes, printNetDevSentBytesInfo); - } + if (!(p=rindex(cmd, '/'))) a53 9 + *p=0; + q=rindex(cmd, '/'); + *q=0; + r=rindex(cmd, '/'); + r++; + for (d=NetDevCnt; d--; ) + if (!strcmp(r, NetDevs[d].name)) + break; + *q=*p='/'; d55 8 a62 150 + if (-1 == d) return; + + p++; + for (i=0; iDrecv[i] = q->recv[i]-p->recv[i]; + p->recv[i] = q->recv[i]; + p->Dsent[i] = q->sent[i]-p->sent[i]; + p->sent[i] = q->sent[i]; } } - - fprintf(CurrentClient, "\n"); } -void printNetDevSentBytesInfo(const char *cmd) -{ - char **retval; - - retval = parseCommand(cmd); - - if (retval[1] == NULL) - return; - if (!strncmp(retval[1], "data", 4)) - fprintf(CurrentClient, "Sent Data\t0\t0\tkBytes/s\n"); - if (!strncmp(retval[1], "packets", 7)) - fprintf(CurrentClient, "Sent Packets\t0\t0\t1/s\n"); - if (!strncmp(retval[1], "errors", 6)) - fprintf(CurrentClient, "Transmitter Errors\t0\t0\t1/s\n"); - if (!strncmp(retval[1], "multicast", 9)) - fprintf(CurrentClient, "Sent Multicast Packets\t0\t0\t1/s\n"); - if (!strncmp(retval[1], "collisions", 10)) - fprintf(CurrentClient, "Transmitter Collisions\t0\t0\t1/s\n"); +void checkNetDev(void) { + if (readSys(!0) != NetDevCnt) { + /* interface has been added or removed + so we do a reset */ + exitNetDev(); + initNetDev(); + } } + + +/* eof */ @ 1.1.1.1.4.1 log @Pull up 1.4 Makefile 1.4 distinfo 1.2 patches/patch-df to the 1.6 branch, as requested by skrll: Plug the memory leak introduced into ksysguardd. Fixes pkg/17962 from hclsmith at yahoo dot ca. One day I might even get round to finishing NetBSD support for ksysguardd. PKGREVISION++ @ text @d1 1 a1 1 $NetBSD: patch-df,v 1.1 2002/05/31 13:19:18 skrll Exp $ d23 1 a23 1 @@@@ -84,4 +92,17 @@@@ int numActivIfaces(void) a36 1 + freeifaddrs(ifap); d40 1 a40 1 @@@@ -105,4 +126,5 @@@@ int numActivIfaces(void) d46 1 a46 1 @@@@ -175,4 +197,16 @@@@ void exitNetDev(void) a58 1 + freeifaddrs(ifap); d62 1 a62 1 @@@@ -209,4 +243,5 @@@@ void updateNetDev(void) @