Added new feature to get a list of network interface names.
1999-11-21 Martin Baulig <martin@home-of-linux.org> Added new feature to get a list of network interface names. * features.def: Added `interface_names' feature. * include/glibtop/interfaces.h: New file. * include/glibtop/sysdeps.h (GLIBTOP_SYSDEPS_INTERFACE_NAMES): Added. (glibtop_sysdeps): Added `interface_names'. * include/glibtop/union.h (glibtop_union): Added `interface_names'. * include/glibtop/command.h (GLIBTOP_CMND_INTERFACE_NAMES): Added.
This commit is contained in:
committed by
Martin Baulig
parent
e5a7a5b0e5
commit
b746f488b0
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
||||
1999-11-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
Added new feature to get a list of network interface names.
|
||||
|
||||
* features.def: Added `interface_names' feature.
|
||||
|
||||
* include/glibtop/interfaces.h: New file.
|
||||
|
||||
* include/glibtop/sysdeps.h (GLIBTOP_SYSDEPS_INTERFACE_NAMES): Added.
|
||||
(glibtop_sysdeps): Added `interface_names'.
|
||||
* include/glibtop/union.h (glibtop_union): Added `interface_names'.
|
||||
* include/glibtop/command.h (GLIBTOP_CMND_INTERFACE_NAMES): Added.
|
||||
|
||||
1999-11-21 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* include/glibtop/sysdeps.h (glibtop_init_func_t): Use `int'
|
||||
|
@@ -11,6 +11,10 @@ Please use LibGTop 1.0.x if you're not on a Solaris system
|
||||
IMPORTANT CHANGES SINCE 1.0:
|
||||
----------------------------
|
||||
|
||||
* All `glibtop_get_<feature>_* ()' and all `glibtop_init_<feature>_* ()'
|
||||
functions now have an `int' return value and return 0 on success and -1
|
||||
on failure.
|
||||
|
||||
* glibtop_cpu: Added `xcpu_flags'
|
||||
|
||||
* glibtop_proc_state: Changed `state' from char to unsigned and added
|
||||
|
@@ -19,4 +19,5 @@ glibtop_map_entry *|proc_map|ulong(number,size,total)|pid_t(pid)
|
||||
glibtop_mountentry *|@mountlist|ulong(number,size,total)|int(all_fs)
|
||||
retval|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir
|
||||
retval|netload|ulong(if_flags,mtu,subnet,address,packets_in,packets_out,packets_total,bytes_in,bytes_out,bytes_total,errors_in,errors_out,errors_total,collisions)|string|interface
|
||||
char *|interface_names|ulong(size)|unsigned(interface,number,strategy)
|
||||
retval|ppp|ulong(state,bytes_in,bytes_out)|ushort(device)
|
||||
|
@@ -58,9 +58,10 @@ BEGIN_LIBGTOP_DECLS
|
||||
#define GLIBTOP_CMND_MOUNTLIST 20
|
||||
#define GLIBTOP_CMND_FSUSAGE 21
|
||||
#define GLIBTOP_CMND_NETLOAD 22
|
||||
#define GLIBTOP_CMND_PPP 23
|
||||
#define GLIBTOP_CMND_INTERFACE_NAMES 23
|
||||
#define GLIBTOP_CMND_PPP 24
|
||||
|
||||
#define GLIBTOP_MAX_CMND 24
|
||||
#define GLIBTOP_MAX_CMND 25
|
||||
|
||||
#define _GLIBTOP_PARAM_SIZE 16
|
||||
|
||||
|
102
include/glibtop/interfaces.h
Normal file
102
include/glibtop/interfaces.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GLIBTOP_INTERFACES_H__
|
||||
#define __GLIBTOP_INTERFACES_H__
|
||||
|
||||
#include <glibtop.h>
|
||||
#include <glibtop/global.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
|
||||
#define GLIBTOP_INTERFACE_NAMES_NUMBER 0
|
||||
#define GLIBTOP_INTERFACE_NAMES_SIZE 1
|
||||
|
||||
#define GLIBTOP_MAX_INTERFACE_NAMES 2
|
||||
|
||||
typedef struct _glibtop_interface_names glibtop_interface_names;
|
||||
|
||||
typedef enum _glibtop_protocol glibtop_protocol;
|
||||
typedef enum _glibtop_interface glibtop_interface;
|
||||
|
||||
enum _glibtop_protocol {
|
||||
GLIBTOP_NETLOAD_DEFAULT = 0,
|
||||
GLIBTOP_NETLOAD_IPV4,
|
||||
GLIBTOP_NETLOAD_IPV6,
|
||||
GLIBTOP_NETLOAD_IPX,
|
||||
};
|
||||
|
||||
enum _glibtop_interface {
|
||||
GLIBTOP_INTERFACE_ALL = 0,
|
||||
GLIBTOP_INTERFACE_ETHERNET,
|
||||
GLIBTOP_INTERFACE_LOOPBACK,
|
||||
GLIBTOP_INTERFACE_DUMMY,
|
||||
GLIBTOP_INTERFACE_PPP,
|
||||
};
|
||||
|
||||
enum {
|
||||
GLIBTOP_INTERFACES_ALL = 0,
|
||||
GLIBTOP_INTERFACES_BEST_MATCHING,
|
||||
};
|
||||
|
||||
struct _glibtop_interface_names
|
||||
{
|
||||
u_int64_t flags,
|
||||
number, /* GLIBTOP_INTERFACES_NUMBER */
|
||||
size; /* GLIBTOP_INTERFACES_SIZE */
|
||||
};
|
||||
|
||||
#define glibtop_get_interface_names(buf, interface,number,strategy) glibtop_get_interface_names_l(glibtop_global_server, buf, interface, number, strategy)
|
||||
|
||||
#if GLIBTOP_SUID_INTERFACE_NAMES
|
||||
#define glibtop_get_interface_names_r glibtop_get_interface_names_p
|
||||
#else
|
||||
#define glibtop_get_interface_names_r glibtop_get_interface_names_s
|
||||
#endif
|
||||
|
||||
char *glibtop_get_interface_names_l (glibtop *server, glibtop_interface_names *buf, unsigned interface, unsigned number, unsigned strategy);
|
||||
|
||||
#if GLIBTOP_SUID_INTERFACES
|
||||
int glibtop_init_interface_names_p (glibtop *server);
|
||||
char *glibtop_get_interface_names_p (glibtop *server, glibtop_interface_names *buf, unsigned interface, unsigned number, unsigned strategy);
|
||||
#else
|
||||
int glibtop_init_interface_names_s (glibtop *server);
|
||||
char *glibtop_get_interface_names_s (glibtop *server, glibtop_interface_names *buf, unsigned interface, unsigned number, unsigned strategy);
|
||||
#endif
|
||||
|
||||
#ifdef GLIBTOP_NAMES
|
||||
|
||||
/* You need to link with -lgtop_names to get this stuff here. */
|
||||
|
||||
extern const char *glibtop_names_interface_names [];
|
||||
extern const unsigned glibtop_types_interface_names [];
|
||||
extern const char *glibtop_labels_interface_names [];
|
||||
extern const char *glibtop_descriptions_interface_names [];
|
||||
|
||||
#endif
|
||||
|
||||
END_LIBGTOP_DECLS
|
||||
|
||||
#endif
|
@@ -50,6 +50,8 @@ BEGIN_LIBGTOP_DECLS
|
||||
|
||||
typedef struct _glibtop_netload glibtop_netload;
|
||||
|
||||
#include <glibtop/interfaces.h>
|
||||
|
||||
enum {
|
||||
GLIBTOP_IF_FLAGS_UP = 1,
|
||||
GLIBTOP_IF_FLAGS_BROADCAST,
|
||||
@@ -91,9 +93,9 @@ struct _glibtop_netload
|
||||
#define glibtop_get_netload(netload,interface) glibtop_get_netload_l(glibtop_global_server, netload, interface)
|
||||
|
||||
#if GLIBTOP_SUID_NETLOAD
|
||||
#define glibtop_get_netload_r glibtop_get_netload_p
|
||||
#define glibtop_get_netload_r glibtop_get_netload_p
|
||||
#else
|
||||
#define glibtop_get_netload_r glibtop_get_netload_s
|
||||
#define glibtop_get_netload_r glibtop_get_netload_s
|
||||
#endif
|
||||
|
||||
int glibtop_get_netload_l (glibtop *server, glibtop_netload *buf, const char *interface);
|
||||
|
@@ -51,9 +51,10 @@ BEGIN_LIBGTOP_DECLS
|
||||
#define GLIBTOP_SYSDEPS_MOUNTLIST 18
|
||||
#define GLIBTOP_SYSDEPS_FSUSAGE 19
|
||||
#define GLIBTOP_SYSDEPS_NETLOAD 20
|
||||
#define GLIBTOP_SYSDEPS_PPP 21
|
||||
#define GLIBTOP_SYSDEPS_INTERFACE_NAMES 21
|
||||
#define GLIBTOP_SYSDEPS_PPP 22
|
||||
|
||||
#define GLIBTOP_MAX_SYSDEPS 24
|
||||
#define GLIBTOP_MAX_SYSDEPS 25
|
||||
|
||||
#define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1)
|
||||
|
||||
@@ -89,6 +90,7 @@ struct _glibtop_sysdeps
|
||||
mountlist, /* glibtop_mountlist */
|
||||
fsusage, /* glibtop_fsusage */
|
||||
netload, /* glibtop_netload */
|
||||
interface_names, /* glibtop_interface_names */
|
||||
ppp; /* glibtop_ppp */
|
||||
};
|
||||
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include <glibtop/fsusage.h>
|
||||
|
||||
#include <glibtop/netload.h>
|
||||
#include <glibtop/interfaces.h>
|
||||
#include <glibtop/ppp.h>
|
||||
|
||||
BEGIN_LIBGTOP_DECLS
|
||||
@@ -79,6 +80,7 @@ union _glibtop_union
|
||||
glibtop_mountlist mountlist;
|
||||
glibtop_fsusage fsusage;
|
||||
glibtop_netload netload;
|
||||
glibtop_interface_names interface_names;
|
||||
glibtop_ppp ppp;
|
||||
};
|
||||
|
||||
|
42
lib/lib.pl
42
lib/lib.pl
@@ -71,6 +71,7 @@ $convert{'int'} = 'int';
|
||||
$convert{'retval'} = 'int';
|
||||
$convert{'ushort'} = 'unsigned short';
|
||||
$convert{'unsigned'} = 'unsigned';
|
||||
$convert{'string'} = 'const char *';
|
||||
|
||||
while (<>) {
|
||||
chop; # strip record separator
|
||||
@@ -176,9 +177,12 @@ sub output {
|
||||
}
|
||||
}
|
||||
|
||||
print 'glibtop_get_' . $feature . '_l (glibtop *server, glibtop_' .
|
||||
|
||||
$feature . ' *buf' . $param_decl . ')';
|
||||
if ($line_fields[3] eq '') {
|
||||
print 'glibtop_get_' . $feature . '_l (glibtop *server' . $param_decl . ')';
|
||||
} else {
|
||||
print 'glibtop_get_' . $feature . '_l (glibtop *server, glibtop_' .
|
||||
$feature . ' *buf' . $param_decl . ')';
|
||||
}
|
||||
|
||||
print '{' . $send_ptr . '' . $send_size;
|
||||
if ($retval !~ /^void$/) {
|
||||
@@ -205,9 +209,12 @@ sub output {
|
||||
|
||||
&toupper($feature) . ',';
|
||||
print "\t\t\t\t" . $call_prefix_space . 'send_size, send_ptr,';
|
||||
print "\t\t\t\t" . $call_prefix_space . 'sizeof (glibtop_' . $feature .
|
||||
|
||||
'), buf,';
|
||||
if ($line_fields[3] eq '') {
|
||||
print "\t\t\t\t". $call_prefix_space . "0, NULL,";
|
||||
} else {
|
||||
print "\t\t\t\t" . $call_prefix_space . 'sizeof (glibtop_' . $feature .
|
||||
'), buf,';
|
||||
}
|
||||
print "\t\t\t\t" . $call_prefix_space . $retval_param . ');';
|
||||
|
||||
print "\t} else {";
|
||||
@@ -215,9 +222,14 @@ sub output {
|
||||
if ($orig !~ /^@/) {
|
||||
print '#if (!GLIBTOP_SUID_' . &toupper($feature) . ')';
|
||||
}
|
||||
print "\t\t" . $prefix . 'glibtop_get_' . $feature . '_s (server, buf' .
|
||||
|
||||
$call_param . ');';
|
||||
if ($line_fields[3] eq '') {
|
||||
print "\t\t" . $prefix . 'glibtop_get_' . $feature . '_s (server' .
|
||||
$call_param . ');';
|
||||
} else {
|
||||
print "\t\t" . $prefix . 'glibtop_get_' . $feature . '_s (server, buf' .
|
||||
$call_param . ');';
|
||||
}
|
||||
|
||||
if ($orig !~ /^@/) {
|
||||
print '#else';
|
||||
@@ -230,15 +242,17 @@ sub output {
|
||||
|
||||
print "\t}";
|
||||
|
||||
print '';
|
||||
print "\t/* Make sure that all required fields are present. */";
|
||||
print '';
|
||||
|
||||
print "\tif (buf->flags & server->required." . $feature . ')';
|
||||
print "\t\t_glibtop_missing_feature (server, \"" . $feature .
|
||||
if (!($line_fields[3] eq '')) {
|
||||
print "\t/* Make sure that all required fields are present. */";
|
||||
print '';
|
||||
|
||||
"\", buf->flags,";
|
||||
print "\t\t\t\t\t &server->required." . $feature . ');';
|
||||
print "\tif (buf->flags & server->required." . $feature . ')';
|
||||
print "\t\t_glibtop_missing_feature (server, \"" . $feature .
|
||||
"\", buf->flags,";
|
||||
print "\t\t\t\t\t &server->required." . $feature . ');';
|
||||
}
|
||||
|
||||
if ($retval !~ /^void$/) {
|
||||
print "\n\t/* Now we can return. */";
|
||||
|
@@ -52,6 +52,7 @@ GLIBTOP_SUID_PROC_SEGMENT +
|
||||
GLIBTOP_SUID_PROC_ARGS +
|
||||
GLIBTOP_SUID_PROC_MAP +
|
||||
GLIBTOP_SUID_NETLOAD +
|
||||
GLIBTOP_SUID_INTERFACE_NAMES +
|
||||
GLIBTOP_SUID_PPP;
|
||||
|
||||
#include <fcntl.h>
|
||||
|
@@ -10,7 +10,7 @@ libgtop_names_la_SOURCES = cpu.c mem.c swap.c uptime.c loadavg.c \
|
||||
proctime.c procmem.c procsignal.c \
|
||||
prockernel.c procsegment.c fsusage.c \
|
||||
mountlist.c procargs.c procmap.c netload.c \
|
||||
ppp.c
|
||||
interfaces.c ppp.c
|
||||
|
||||
libgtop_names_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||
|
||||
|
48
sysdeps/names/interfaces.c
Normal file
48
sysdeps/names/interfaces.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
LibGTop is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
LibGTop 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 LibGTop; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glibtop/interfaces.h>
|
||||
|
||||
const char *glibtop_names_interface_names[GLIBTOP_MAX_INTERFACE_NAMES] =
|
||||
{
|
||||
"number", "size"
|
||||
};
|
||||
|
||||
const unsigned glibtop_types_interface_names[GLIBTOP_MAX_INTERFACE_NAMES] =
|
||||
{
|
||||
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG
|
||||
};
|
||||
|
||||
const char *glibtop_labels_interface_names[GLIBTOP_MAX_INTERFACE_NAMES] =
|
||||
{
|
||||
N_ ("Number"),
|
||||
N_ ("Size")
|
||||
};
|
||||
|
||||
const char *glibtop_descriptions_interface_names[GLIBTOP_MAX_INTERFACE_NAMES] =
|
||||
{
|
||||
N_ ("Number"),
|
||||
N_ ("Size")
|
||||
};
|
@@ -31,7 +31,8 @@ const char *glibtop_names_sysdeps[GLIBTOP_MAX_SYSDEPS] =
|
||||
"loadavg", "shm_limits", "msg_limits", "sem_limits", "proclist",
|
||||
"proc_state", "proc_uid", "proc_mem", "proc_time",
|
||||
"proc_signal", "proc_kernel", "proc_segment", "proc_args",
|
||||
"proc_map", "mountlist", "fsusage", "netload", "ppp"
|
||||
"proc_map", "mountlist", "fsusage", "netload", "interface_names",
|
||||
"ppp"
|
||||
};
|
||||
|
||||
const unsigned glibtop_types_sysdeps[GLIBTOP_MAX_SYSDEPS] =
|
||||
@@ -43,7 +44,8 @@ const unsigned glibtop_types_sysdeps[GLIBTOP_MAX_SYSDEPS] =
|
||||
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
|
||||
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
|
||||
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
|
||||
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG
|
||||
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
|
||||
GLIBTOP_TYPE_ULONG
|
||||
};
|
||||
|
||||
const char *glibtop_labels_sysdeps[GLIBTOP_MAX_SYSDEPS] =
|
||||
@@ -71,6 +73,7 @@ const char *glibtop_labels_sysdeps[GLIBTOP_MAX_SYSDEPS] =
|
||||
N_ ("Mount List"),
|
||||
N_ ("File System Usage"),
|
||||
N_ ("Network Load"),
|
||||
N_ ("Interface Names"),
|
||||
N_ ("PPP Statistics")
|
||||
};
|
||||
|
||||
@@ -99,5 +102,6 @@ const char *glibtop_descriptions_sysdeps[GLIBTOP_MAX_SYSDEPS] =
|
||||
N_ ("List of currently mounted filesystems"),
|
||||
N_ ("File System Usage"),
|
||||
N_ ("Network Load"),
|
||||
N_ ("Interface Names"),
|
||||
N_ ("PPP Statistics")
|
||||
};
|
||||
|
Reference in New Issue
Block a user