diff --git a/ChangeLog b/ChangeLog index 7d44ff13..09681f92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +1998-10-25 Martin Baulig + + Added PPP/ISDN support. + + * include/glibtop/ppp.h: New file. + * features.def: Added new feature `ppp'. + + * acconfig.h (HAVE_I4B): Defined if we have the I4B package. + (HAVE_I4B_ACCT): Defined if we have ISDN statistics with I4B. + + * misc: New directory. + * misc/i4b_acct.txt: Read this file to get ISDN statistics on BSD. + + * lib/lib.awk: New type `ushort' for the features.def which is + `unsigned short'. + 1998-10-20 Martin Baulig * include/glibtop/proc_signal.h: Use a 2-element-array of diff --git a/Makefile.am b/Makefile.am index e4ef7194..b5bb98ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,8 @@ else examples_SUBDIRS = endif -SUBDIRS = po intl support macros include sysdeps lib src $(examples_SUBDIRS) +SUBDIRS = po intl support macros misc include sysdeps lib src \ + $(examples_SUBDIRS) include_HEADERS = glibtop.h diff --git a/acconfig.h b/acconfig.h index 85877346..8cc94644 100644 --- a/acconfig.h +++ b/acconfig.h @@ -141,3 +141,6 @@ #undef HAVE_XAUTH +/* Define if your have the I4B package. */ +#undef HAVE_I4B +#undef HAVE_I4B_ACCT diff --git a/configure.in b/configure.in index 538402af..668d9434 100644 --- a/configure.in +++ b/configure.in @@ -342,6 +342,7 @@ AC_OUTPUT([ Makefile po/Makefile.in intl/Makefile +misc/Makefile include/Makefile include/glibtop/Makefile sysdeps/Makefile diff --git a/examples/ChangeLog b/examples/ChangeLog index 747dda53..1d8905ba 100644 --- a/examples/ChangeLog +++ b/examples/ChangeLog @@ -1,3 +1,7 @@ +1998-10-25 Martin Baulig + + * first.c (glibtop_get_ppp): Get PPP/ISDN statistics. + 1998-09-28 Martin Baulig * Makefile.am: Install everything in $(libexecdir)/libgtop. diff --git a/examples/first.c b/examples/first.c index 0bc0a09e..547b78a0 100644 --- a/examples/first.c +++ b/examples/first.c @@ -172,6 +172,17 @@ main (int argc, char *argv []) printf ("\n"); + for (c = 0; c < PROFILE_COUNT; c++) + glibtop_get_ppp (&data.ppp, 0); + + printf ("PPP (0x%08lx): %lu, %lu, %lu\n", + (unsigned long) data.ppp.flags, + (unsigned long) data.ppp.state, + (unsigned long) data.ppp.bytes_in, + (unsigned long) data.ppp.bytes_out); + + printf ("\n"); + glibtop_get_sysdeps (&sysdeps); printf ("Sysdeps (0x%08lx): %lu, %lu, %lu, %lu, %lu, " diff --git a/features.def b/features.def index 4150e912..170f3e4d 100644 --- a/features.def +++ b/features.def @@ -17,3 +17,4 @@ void|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_c glibtop_map_entry *|proc_map|ulong(number,size,total)|pid_t(pid) glibtop_mountentry *|@mountlist|ulong(number,size,total)|int(all_fs) void|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir +void|ppp|ulong(state,bytes_in,bytes_out)|ushort(device) diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am index 329b8db0..95558e52 100644 --- a/include/glibtop/Makefile.am +++ b/include/glibtop/Makefile.am @@ -7,4 +7,4 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \ procsegment.h read.h sysdeps.h xmalloc.h global.h \ procsignal.h read_data.h union.h types.h gnuserv.h \ parameter.h mountlist.h fsusage.h procmap.h signal.h \ - inodedb.h sysinfo.h + inodedb.h sysinfo.h ppp.h diff --git a/include/glibtop/command.h b/include/glibtop/command.h index a2ec780a..f543b842 100644 --- a/include/glibtop/command.h +++ b/include/glibtop/command.h @@ -52,8 +52,9 @@ __BEGIN_DECLS #define GLIBTOP_CMND_MOUNTLIST 19 #define GLIBTOP_CMND_FSUSAGE 20 +#define GLIBTOP_CMND_PPP 21 -#define GLIBTOP_MAX_CMND 21 +#define GLIBTOP_MAX_CMND 22 #define _GLIBTOP_PARAM_SIZE 16 diff --git a/include/glibtop/ppp.h b/include/glibtop/ppp.h new file mode 100644 index 00000000..981d27d9 --- /dev/null +++ b/include/glibtop/ppp.h @@ -0,0 +1,83 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef __GLIBTOP_PPP_H__ +#define __GLIBTOP_PPP_H__ + +#include +#include + +__BEGIN_DECLS + +#define GLIBTOP_PPP_STATE 0 +#define GLIBTOP_PPP_BYTES_IN 1 +#define GLIBTOP_PPP_BYTES_OUT 2 + +#define GLIBTOP_MAX_PPP 3 + +typedef struct _glibtop_ppp glibtop_ppp; + +enum { + GLIBTOP_PPP_STATE_UNKNOWN = 0, + GLIBTOP_PPP_STATE_HANGUP, + GLIBTOP_PPP_STATE_ONLINE +}; + +struct _glibtop_ppp +{ + u_int64_t flags, + state, /* GLIBTOP_PPP_STATE */ + bytes_in, /* GLIBTOP_PPP_BYTES_IN */ + bytes_out; /* GLIBTOP_PPP_BYTES_OUT */ +}; + +#define glibtop_get_ppp(ppp,device) glibtop_get_ppp_l(glibtop_global_server, ppp, device) + +#if GLIBTOP_SUID_PPP +#define glibtop_get_ppp_r glibtop_get_ppp_p +#else +#define glibtop_get_ppp_r glibtop_get_ppp_s +#endif + +extern void glibtop_get_ppp_l __P((glibtop *, glibtop_ppp *, unsigned short)); + +#if GLIBTOP_SUID_PPP +extern void glibtop_init_ppp_p __P((glibtop *)); +extern void glibtop_get_ppp_p __P((glibtop *, glibtop_ppp *, unsigned short)); +#else +extern void glibtop_init_ppp_s __P((glibtop *)); +extern void glibtop_get_ppp_s __P((glibtop *, glibtop_ppp *, unsigned short)); +#endif + +#ifdef GLIBTOP_NAMES + +/* You need to link with -lgtop_names to get this stuff here. */ + +extern const char *glibtop_names_ppp []; +extern const unsigned glibtop_types_ppp []; +extern const char *glibtop_labels_ppp []; +extern const char *glibtop_descriptions_ppp []; + +#endif + +__END_DECLS + +#endif diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h index ad94f5d5..1d94bbab 100644 --- a/include/glibtop/sysdeps.h +++ b/include/glibtop/sysdeps.h @@ -46,8 +46,9 @@ __BEGIN_DECLS #define GLIBTOP_SYSDEPS_PROC_MAP 17 #define GLIBTOP_SYSDEPS_MOUNTLIST 18 #define GLIBTOP_SYSDEPS_FSUSAGE 19 +#define GLIBTOP_SYSDEPS_PPP 20 -#define GLIBTOP_MAX_SYSDEPS 20 +#define GLIBTOP_MAX_SYSDEPS 21 #define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1) @@ -79,7 +80,8 @@ struct _glibtop_sysdeps proc_segment, /* glibtop_proc_segment */ proc_map, /* glibtop_proc_map */ mountlist, /* glibtop_mountlist */ - fsusage; /* glibtop_fsusage */ + fsusage, /* glibtop_fsusage */ + ppp; /* glibtop_ppp */ }; #define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps_r(glibtop_global_server,sysdeps) diff --git a/include/glibtop/union.h b/include/glibtop/union.h index 6a3f7c85..aa420f2f 100644 --- a/include/glibtop/union.h +++ b/include/glibtop/union.h @@ -44,6 +44,8 @@ #include #include +#include + __BEGIN_DECLS typedef union _glibtop_union glibtop_union; @@ -69,6 +71,7 @@ union _glibtop_union glibtop_proc_map proc_map; glibtop_mountlist mountlist; glibtop_fsusage fsusage; + glibtop_ppp ppp; }; __END_DECLS diff --git a/lib/lib.awk b/lib/lib.awk index c41b00ac..4937b0a3 100644 --- a/lib/lib.awk +++ b/lib/lib.awk @@ -45,6 +45,7 @@ BEGIN { convert["ulong"] = "u_int64_t"; convert["pid_t"] = "pid_t"; convert["int"] = "int"; + convert["ushort"] = "unsigned short"; } function output(line) { diff --git a/misc/.cvsignore b/misc/.cvsignore new file mode 100644 index 00000000..3dda7298 --- /dev/null +++ b/misc/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +Makefile diff --git a/misc/Makefile.am b/misc/Makefile.am new file mode 100644 index 00000000..4f9aa50d --- /dev/null +++ b/misc/Makefile.am @@ -0,0 +1,2 @@ +EXTRA_DIST = i4b_acct.h i4b_acct.txt + diff --git a/misc/i4b_acct.h b/misc/i4b_acct.h new file mode 100644 index 00000000..b5c3e479 --- /dev/null +++ b/misc/i4b_acct.h @@ -0,0 +1,75 @@ +/* This file contains modified code from `/usr/src/i4b/driver/i4b_isppp.c' + * which belongs to the I4B package. + * + * The original copyright of this file [/usr/src/i4b/driver/i4b_isppp.c] is + * + * ----------------------------------------------------------------------------- + * + * Copyright (c) 1997 Joerg Wunsch. All rights reserved. + * + * Copyright (c) 1997, 1998 Hellmuth Michaelis. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * 4. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software and/or documentation. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * ----------------------------------------------------------------------------- + */ + +#define I4BISPPPACCT 1 /* enable accounting messages */ + +struct i4bisppp_softc { + /* + * struct sppp starts with a struct ifnet, but we gotta allocate + * more space for it. NB: do not relocate this union, it must + * be first in isppp_softc. The tls and tlf hooks below want to + * convert a ``struct sppp *'' into a ``struct isppp_softc *''. + */ + union { + struct ifnet scu_if; + struct sppp scu_sp; + } sc_if_un; +#define sc_if sc_if_un.scu_if + int sc_state; /* state of the interface */ +#ifndef __FreeBSD__ + int sc_unit; /* unit number for Net/OpenBSD */ +#endif + void *sc_cdp; /* ptr to call descriptor */ + +#ifdef I4BISPPPACCT + int sc_iinb; /* isdn driver # of inbytes */ + int sc_ioutb; /* isdn driver # of outbytes */ + int sc_inb; /* # of bytes rx'd */ + int sc_outb; /* # of bytes tx'd */ + int sc_linb; /* last # of bytes rx'd */ + int sc_loutb; /* last # of bytes tx'd */ + int sc_fn; /* flag, first null acct */ +#endif + +#if defined(__FreeBSD__) && __FreeBSD__ >= 3 + struct callout_handle sc_ch; +#endif +}; diff --git a/misc/i4b_acct.txt b/misc/i4b_acct.txt new file mode 100644 index 00000000..4fd7d024 --- /dev/null +++ b/misc/i4b_acct.txt @@ -0,0 +1,96 @@ +To get ISDN statistics with the I4B package do the following: + +* Look at the declaration of `struct i4bisppp_softc' in + /usr/src/i4b/driver/i4b_isppp.c. + + It is looking like this: + + struct i4bisppp_softc { + /* + * struct sppp starts with a struct ifnet, but we gotta allocate + * more space for it. NB: do not relocate this union, it must + * be first in isppp_softc. The tls and tlf hooks below want to + * convert a ``struct sppp *'' into a ``struct isppp_softc *''. + */ + union { + struct ifnet scu_if; + struct sppp scu_sp; + } sc_if_un; + #define sc_if sc_if_un.scu_if + int sc_state; /* state of the interface */ + #ifndef __FreeBSD__ + int sc_unit; /* unit number for Net/OpenBSD */ + #endif + call_desc_t *sc_cdp; /* ptr to call descriptor */ + + #ifdef I4BISPPPACCT + int sc_iinb; /* isdn driver # of inbytes */ + int sc_ioutb; /* isdn driver # of outbytes */ + int sc_inb; /* # of bytes rx'd */ + int sc_outb; /* # of bytes tx'd */ + int sc_linb; /* last # of bytes rx'd */ + int sc_loutb; /* last # of bytes tx'd */ + int sc_fn; /* flag, first null acct */ + #endif + + #if defined(__FreeBSD__) && __FreeBSD__ >= 3 + struct callout_handle sc_ch; + #endif + } i4bisppp_softc[NI4BISPPP]; + +* Create a new file /usr/include/machine/i4b_acct.h and put the declaration + of this structure in this file. + +* Replace `call_desc_t *' with `void *' in it. + +* The result should look like this: + + struct i4bisppp_softc { + /* + * struct sppp starts with a struct ifnet, but we gotta allocate + * more space for it. NB: do not relocate this union, it must + * be first in isppp_softc. The tls and tlf hooks below want to + * convert a ``struct sppp *'' into a ``struct isppp_softc *''. + */ + union { + struct ifnet scu_if; + struct sppp scu_sp; + } sc_if_un; + #define sc_if sc_if_un.scu_if + int sc_state; /* state of the interface */ + #ifndef __FreeBSD__ + int sc_unit; /* unit number for Net/OpenBSD */ + #endif + void *sc_cdp; /* ptr to call descriptor */ + + #ifdef I4BISPPPACCT + int sc_iinb; /* isdn driver # of inbytes */ + int sc_ioutb; /* isdn driver # of outbytes */ + int sc_inb; /* # of bytes rx'd */ + int sc_outb; /* # of bytes tx'd */ + int sc_linb; /* last # of bytes rx'd */ + int sc_loutb; /* last # of bytes tx'd */ + int sc_fn; /* flag, first null acct */ + #endif + + #if defined(__FreeBSD__) && __FreeBSD__ >= 3 + struct callout_handle sc_ch; + #endif + }; + +* Put a + + #define I4BISPPPACCT 1 /* enable accounting messages */ + + at the top of your /usr/include/machine/i4b_acct.h + +* This file should now look about like `misc/i4b_acct.h' in the LibGTop + source directory. + +* Done. + +This is necessary since LibGTop reads its data directly out of the kernel +and the `struct i4bisppp_softc' is only defined there and in no header file +(someone can tell the I4B people to put it in some header file ?). + +Martin diff --git a/src/daemon/server.c b/src/daemon/server.c index 577cb672..bd05e548 100644 --- a/src/daemon/server.c +++ b/src/daemon/server.c @@ -45,7 +45,8 @@ GLIBTOP_SUID_PROC_TIME + GLIBTOP_SUID_PROC_SIGNAL + GLIBTOP_SUID_PROC_KERNEL + GLIBTOP_SUID_PROC_SEGMENT + -GLIBTOP_SUID_PROC_MAP; +GLIBTOP_SUID_PROC_MAP + +GLIBTOP_SUID_PPP; #include #include diff --git a/src/daemon/slave.c b/src/daemon/slave.c index 09e24c92..5fdaac49 100644 --- a/src/daemon/slave.c +++ b/src/daemon/slave.c @@ -101,6 +101,7 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp, const void *parameter) { glibtop *server = glibtop_global_server; + unsigned short device; pid_t pid; switch (cmnd->command) { @@ -213,6 +214,13 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp, (server, &resp->u.data.proc_segment, pid); resp->offset = _offset_data (proc_segment); break; +#endif +#if GLIBTOP_SUID_PPP + case GLIBTOP_CMND_PPP: + memcpy (&device, parameter, sizeof (unsigned short)); + glibtop_get_ppp_p (server, &resp->u.data.ppp, device); + resp->offset = _offset_data (ppp); + break; #endif default: glibtop_error ("Child received unknown command %u", diff --git a/sysdeps/common/sysdeps_suid.c b/sysdeps/common/sysdeps_suid.c index 318c9388..05c6224e 100644 --- a/sysdeps/common/sysdeps_suid.c +++ b/sysdeps/common/sysdeps_suid.c @@ -73,6 +73,9 @@ glibtop_init_func_t _glibtop_init_hook_p [] = { #endif #if GLIBTOP_SUID_PROC_MAP glibtop_init_proc_map_p, +#endif +#if GLIBTOP_SUID_PPP + glibtop_init_ppp_p, #endif NULL }; diff --git a/sysdeps/freebsd/ChangeLog b/sysdeps/freebsd/ChangeLog index c50e49f5..d2f847ac 100644 --- a/sysdeps/freebsd/ChangeLog +++ b/sysdeps/freebsd/ChangeLog @@ -1,3 +1,12 @@ +1998-10-25 Martin Baulig + + * ppp.c: New file to get PPP/ISDN statistics. Currently this only + get ISDN statistics if you have the I4B package. + + To get the number of bytes transferred in/out you need to read the + file `misc/i4b_acct.txt' in the LibGTop source directory to see + how to enable this. + 1998-10-03 Martin Baulig * procstate.c (glibtop_get_procstate_s): Use correct values for diff --git a/sysdeps/freebsd/Makefile.am b/sysdeps/freebsd/Makefile.am index 945d4292..7d508540 100644 --- a/sysdeps/freebsd/Makefile.am +++ b/sysdeps/freebsd/Makefile.am @@ -10,7 +10,7 @@ libgtop_sysdeps_suid_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procmap.c + procsegment.c procmap.c ppp.c libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/freebsd/glibtop_server.h b/sysdeps/freebsd/glibtop_server.h index 199991ac..8ade7f5f 100644 --- a/sysdeps/freebsd/glibtop_server.h +++ b/sysdeps/freebsd/glibtop_server.h @@ -41,6 +41,7 @@ __BEGIN_DECLS #define GLIBTOP_SUID_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL) #define GLIBTOP_SUID_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT) #define GLIBTOP_SUID_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP) +#define GLIBTOP_SUID_PPP (1 << GLIBTOP_SYSDEPS_PPP) __END_DECLS diff --git a/sysdeps/freebsd/ppp.c b/sysdeps/freebsd/ppp.c new file mode 100644 index 00000000..f535e818 --- /dev/null +++ b/sysdeps/freebsd/ppp.c @@ -0,0 +1,131 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , October 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +#ifdef HAVE_I4B + +#include +#include +#include +#include + +#ifdef __FreeBSD__ +#include +#else +#include +#endif + +/* Read `misc/i4b_acct.txt' for details ... */ +#ifdef HAVE_I4B_ACCT +#include +#endif + +static const unsigned long _glibtop_sysdeps_ppp = +(1 << GLIBTOP_PPP_STATE); + +#ifdef HAVE_I4B_ACCT +static const unsigned long _glibtop_sysdeps_ppp_acct = +(1 << GLIBTOP_PPP_BYTES_IN) + (1 << GLIBTOP_PPP_BYTES_OUT); +#endif + +#endif /* HAVE_I4B */ + +/* nlist structure for kernel access */ +static struct nlist nlst [] = { +#ifdef HAVE_I4B + { "_i4bisppp_softc" }, +#endif + { 0 } +}; + +/* Init function. */ + +void +glibtop_init_ppp_p (glibtop *server) +{ +#ifdef HAVE_I4B +#ifdef HAVE_I4B_ACCT + server->sysdeps.ppp = _glibtop_sysdeps_ppp | + _glibtop_sysdeps_ppp_acct; +#else + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +#endif +#endif /* HAVE_I4B */ + + if (kvm_nlist (server->machine.kd, nlst) != 0) + glibtop_error_io_r (server, "kvm_nlist"); +} + +/* Provides information about ppp usage. */ + +void +glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ +#ifdef HAVE_I4B +#ifdef HAVE_I4B_ACCT + struct i4bisppp_softc data; +#else + struct sppp data; +#endif + int phase; + + glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PPP), 0); + + memset (buf, 0, sizeof (glibtop_ppp)); + + if (kvm_read (server->machine.kd, nlst [0].n_value, + &data, sizeof (data)) != sizeof (data)) + glibtop_error_io_r (server, "kvm_read (i4bisppp_softc)"); + +#ifdef HAVE_I4B_ACCT + phase = data.sc_if_un.scu_sp.pp_phase; +#else + phase = data.pp_phase; +#endif + + switch (phase) { + case PHASE_DEAD: + case PHASE_TERMINATE: + buf->state = GLIBTOP_PPP_STATE_HANGUP; + break; + case PHASE_ESTABLISH: + case PHASE_NETWORK: + buf->state = GLIBTOP_PPP_STATE_ONLINE; + break; + default: + buf->state = GLIBTOP_PPP_STATE_UNKNOWN; + break; + } + + buf->flags = _glibtop_sysdeps_ppp; + +#ifdef HAVE_I4B_ACCT + buf->bytes_in = data.sc_iinb; + buf->bytes_out = data.sc_ioutb; + buf->flags |= _glibtop_sysdeps_ppp_acct; +#endif +#endif /* HAVE_I4B */ +} diff --git a/sysdeps/kernel/ChangeLog b/sysdeps/kernel/ChangeLog index 75705a78..bbb1ec84 100644 --- a/sysdeps/kernel/ChangeLog +++ b/sysdeps/kernel/ChangeLog @@ -1,3 +1,7 @@ +1998-10-25 Martin Baulig + + * ppp.c: New file. Currently empty. + 1998-06-14 Martin Baulig * kernel.s: New file - declaration of the table () function diff --git a/sysdeps/kernel/Makefile.am b/sysdeps/kernel/Makefile.am index 9515f644..4be82da9 100644 --- a/sysdeps/kernel/Makefile.am +++ b/sysdeps/kernel/Makefile.am @@ -8,7 +8,7 @@ libgtop_sysdeps_la_SOURCES = open.c close.c kernel.s cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c siglist.c procmap.c + procsegment.c siglist.c procmap.c ppp.c libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/kernel/ppp.c b/sysdeps/kernel/ppp.c new file mode 100644 index 00000000..b81dfdb2 --- /dev/null +++ b/sysdeps/kernel/ppp.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , October 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_ppp = 0; + +/* Init function. */ + +void +glibtop_init_ppp_s (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +/* Provides PPP/ISDN information. */ + +void +glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + memset (buf, 0, sizeof (glibtop_ppp)); +} diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 0724df2b..789bc8d2 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,7 @@ +1998-10-25 Martin Baulig + + * ppp.c: New file. Currently empty. + 1998-10-11 Martin Baulig * procdata.c: Removed this obsolete file. diff --git a/sysdeps/linux/Makefile.am b/sysdeps/linux/Makefile.am index a99f5e86..38b33490 100644 --- a/sysdeps/linux/Makefile.am +++ b/sysdeps/linux/Makefile.am @@ -8,7 +8,8 @@ libgtop_sysdeps_la_SOURCES = open.c close.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procmap.c siglist.c sysinfo.c + procsegment.c procmap.c siglist.c sysinfo.c \ + ppp.c libgtop_sysdeps_la_LIBADD = @GLIB_LIBS@ libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/linux/ppp.c b/sysdeps/linux/ppp.c new file mode 100644 index 00000000..b81dfdb2 --- /dev/null +++ b/sysdeps/linux/ppp.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , October 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_ppp = 0; + +/* Init function. */ + +void +glibtop_init_ppp_s (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +/* Provides PPP/ISDN information. */ + +void +glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + memset (buf, 0, sizeof (glibtop_ppp)); +} diff --git a/sysdeps/names/Makefile.am b/sysdeps/names/Makefile.am index d282c559..c034b326 100644 --- a/sysdeps/names/Makefile.am +++ b/sysdeps/names/Makefile.am @@ -9,7 +9,7 @@ libgtop_names_la_SOURCES = cpu.c mem.c swap.c uptime.c loadavg.c \ proclist.c sysdeps.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c \ prockernel.c procsegment.c fsusage.c \ - mountlist.c procmap.c + mountlist.c procmap.c ppp.c libgtop_names_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/names/ppp.c b/sysdeps/names/ppp.c new file mode 100644 index 00000000..5a872589 --- /dev/null +++ b/sysdeps/names/ppp.c @@ -0,0 +1,46 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , April 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include + +const char *glibtop_names_ppp [GLIBTOP_MAX_PPP] = +{ + "state", "bytes_in", "bytes_out" +}; + +const unsigned glibtop_types_ppp [GLIBTOP_MAX_PPP] = +{ + GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG +}; + +const char *glibtop_labels_ppp [GLIBTOP_MAX_PPP] = +{ + N_("PPP State"), + N_("Input bytes"), + N_("Output bytes") +}; + +const char *glibtop_descriptions_ppp [GLIBTOP_MAX_PPP] = +{ + N_("PPP State"), + N_("Number of input bytes"), + N_("Number of output bytes") +}; diff --git a/sysdeps/osf1/ChangeLog b/sysdeps/osf1/ChangeLog new file mode 100644 index 00000000..37833c17 --- /dev/null +++ b/sysdeps/osf1/ChangeLog @@ -0,0 +1,5 @@ +1998-10-25 Martin Baulig + + * ChangeLog: New file. + * ppp.c: New file. + diff --git a/sysdeps/osf1/Makefile.am b/sysdeps/osf1/Makefile.am index e981e468..3bd53770 100644 --- a/sysdeps/osf1/Makefile.am +++ b/sysdeps/osf1/Makefile.am @@ -6,7 +6,7 @@ lib_LTLIBRARIES = libgtop_sysdeps.la libgtop_sysdeps_suid.la libgtop_sysdeps_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ - sem_limits.c + sem_limits.c ppp.c libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) libgtop_sysdeps_la_LIBADD = -lmach diff --git a/sysdeps/osf1/ppp.c b/sysdeps/osf1/ppp.c new file mode 100644 index 00000000..b81dfdb2 --- /dev/null +++ b/sysdeps/osf1/ppp.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , October 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_ppp = 0; + +/* Init function. */ + +void +glibtop_init_ppp_s (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +/* Provides PPP/ISDN information. */ + +void +glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + memset (buf, 0, sizeof (glibtop_ppp)); +} diff --git a/sysdeps/stub/ChangeLog b/sysdeps/stub/ChangeLog index 23d83483..68ebbf4d 100644 --- a/sysdeps/stub/ChangeLog +++ b/sysdeps/stub/ChangeLog @@ -1,3 +1,7 @@ +1998-10-25 Martin Baulig + + * ppp.c: New file. + 1998-08-24 Martin Baulig * *.c: Added initialization functions `glibtop_init__s'. diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am index 0266d8fd..e9636df1 100644 --- a/sysdeps/stub/Makefile.am +++ b/sysdeps/stub/Makefile.am @@ -8,7 +8,7 @@ libgtop_sysdeps_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c procmap.c + procsegment.c procmap.c ppp.c libgtop_sysdeps_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/stub/ppp.c b/sysdeps/stub/ppp.c new file mode 100644 index 00000000..b81dfdb2 --- /dev/null +++ b/sysdeps/stub/ppp.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , October 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_ppp = 0; + +/* Init function. */ + +void +glibtop_init_ppp_s (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +/* Provides PPP/ISDN information. */ + +void +glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + memset (buf, 0, sizeof (glibtop_ppp)); +} diff --git a/sysdeps/stub_suid/ChangeLog b/sysdeps/stub_suid/ChangeLog new file mode 100644 index 00000000..37833c17 --- /dev/null +++ b/sysdeps/stub_suid/ChangeLog @@ -0,0 +1,5 @@ +1998-10-25 Martin Baulig + + * ChangeLog: New file. + * ppp.c: New file. + diff --git a/sysdeps/stub_suid/Makefile.am b/sysdeps/stub_suid/Makefile.am index 1d0962dc..78acf9d1 100644 --- a/sysdeps/stub_suid/Makefile.am +++ b/sysdeps/stub_suid/Makefile.am @@ -12,7 +12,7 @@ libgtop_sysdeps_suid_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c + procsegment.c ppp.c libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) diff --git a/sysdeps/stub_suid/ppp.c b/sysdeps/stub_suid/ppp.c new file mode 100644 index 00000000..96b559fe --- /dev/null +++ b/sysdeps/stub_suid/ppp.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , October 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_ppp = 0; + +/* Init function. */ + +void +glibtop_init_ppp_p (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +/* Provides PPP/ISDN information. */ + +void +glibtop_get_ppp_p (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + memset (buf, 0, sizeof (glibtop_ppp)); +} diff --git a/sysdeps/sun4/ChangeLog b/sysdeps/sun4/ChangeLog index 3ca0b6df..48a1688a 100644 --- a/sysdeps/sun4/ChangeLog +++ b/sysdeps/sun4/ChangeLog @@ -1,3 +1,7 @@ +1998-10-25 Martin Baulig + + * ppp.c: New file. + 1998-08-25 Martin Baulig * *.c (glibtop_init_p): Using correct `(1 << GLIBTOP_SYSDPES_*)'. diff --git a/sysdeps/sun4/Makefile.am b/sysdeps/sun4/Makefile.am index 7135bde7..b4bb1dc2 100644 --- a/sysdeps/sun4/Makefile.am +++ b/sysdeps/sun4/Makefile.am @@ -12,7 +12,7 @@ libgtop_sysdeps_suid_la_SOURCES = open.c close.c cpu.c mem.c swap.c \ uptime.c loadavg.c shm_limits.c msg_limits.c \ sem_limits.c proclist.c procstate.c procuid.c \ proctime.c procmem.c procsignal.c prockernel.c \ - procsegment.c + procsegment.c ppp.c libgtop_sysdeps_suid_la_LDFLAGS = $(LT_VERSION_INFO) libgtop_sysdeps_suid_la_LIBADD = -lkvm diff --git a/sysdeps/sun4/ppp.c b/sysdeps/sun4/ppp.c new file mode 100644 index 00000000..b81dfdb2 --- /dev/null +++ b/sysdeps/sun4/ppp.c @@ -0,0 +1,42 @@ +/* $Id$ */ + +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the Gnome Top Library. + Contributed by Martin Baulig , October 1998. + + The Gnome Top Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Top Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +static const unsigned long _glibtop_sysdeps_ppp = 0; + +/* Init function. */ + +void +glibtop_init_ppp_s (glibtop *server) +{ + server->sysdeps.ppp = _glibtop_sysdeps_ppp; +} + +/* Provides PPP/ISDN information. */ + +void +glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device) +{ + memset (buf, 0, sizeof (glibtop_ppp)); +}