File: ifstat.h

package info (click to toggle)
ifstat 1.1-8.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 364 kB
  • ctags: 261
  • sloc: ansic: 2,364; sh: 341; makefile: 112
file content (105 lines) | stat: -rw-r--r-- 3,012 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * ifstat - InterFace STATistics
 * Copyright (c) 2001, Gal Roualland <gael.roualland@dial.oleane.com>
 *
 * This program 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.
 *
 * 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: ifstat.h,v 1.21 2003/04/21 19:58:42 gael Exp $
 */

#ifndef IFSTAT_H
#define IFSTAT_H

#define IFSTAT_API      1

/* interface flags */
#define IFSTAT_LOOPBACK 1
#define IFSTAT_DOWN     2
#define IFSTAT_HASSTATS 4
#define IFSTAT_HASINDEX 8
#define IFSTAT_TOTAL  128

/* interface list */
struct ifstat_data {
  char *name;
  int namelen;
  unsigned long long obout, obin, bout, bin;
  int flags, index;
  struct ifstat_data *next;
};

struct ifstat_list {
  struct ifstat_data *first;
  int flags;
};

/* driver data */
struct ifstat_driver {
  char *name;
  /* driver initialisation, returns 1 if successfull */
  int (*open_driver) (struct ifstat_driver *driver,
		      char *options);

  /* scans list of known interfaces by the driver */
  int (*scan_interfaces) (struct ifstat_driver *driver,
			  struct ifstat_list *ifs);

  /* gathers stats and updates interface lists */
  int (*get_stats) (struct ifstat_driver *driver,
		    struct ifstat_list *ifs);

  /* frees/closes driver data */
  void (*close_driver) (struct ifstat_driver *driver);

  /* private driver data */
  void *data;
};

/* interface managing calls */
void ifstat_add_interface(struct ifstat_list *ifs, char *ifname, int flags);
void ifstat_free_interface(struct ifstat_data *data);

void ifstat_set_interface_stats(struct ifstat_data *data,
				unsigned long long bytesin,
				unsigned long long bytesout);

void ifstat_set_interface_index(struct ifstat_data *data,
				int index);

#define ifstat_get_interface_index(data) ((data)->index)
#define ifstat_get_interface_name(data) ((data)->name)

struct ifstat_data *ifstat_get_interface(struct ifstat_list *ifs,
					 char *ifname);

void ifstat_reset_interfaces(struct ifstat_list *ifs);

/* redefine those to override defaults if needed */
extern char *ifstat_progname;
extern void (*ifstat_error) (char *format, ...);
extern int ifstat_quiet;

/* version string */
extern const char *ifstat_version;

/* perror reporting --internal */
void ifstat_perror(char *);

/* searches for specified driver (NULL = default). Returns 1 if found */
int ifstat_get_driver(char *name, struct ifstat_driver *driver);
/* get driver list */
char *ifstat_list_drivers();

#endif