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:
Martin Baulig
1999-11-21 18:35:40 +00:00
committed by Martin Baulig
parent e5a7a5b0e5
commit b746f488b0
13 changed files with 217 additions and 23 deletions

View File

@@ -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

View 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

View File

@@ -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);

View File

@@ -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 */
};

View File

@@ -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;
};