File: testgetifstats.c

package info (click to toggle)
miniupnpd 2.3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,040 kB
  • sloc: ansic: 28,571; sh: 2,024; makefile: 164
file content (41 lines) | stat: -rw-r--r-- 1,072 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
/* $Id: testgetifstats.c,v 1.6 2012/06/22 16:11:58 nanard Exp $ */
/* MiniUPnP project
 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
 * (c) 2006 Thomas Bernard
 * This software is subject to the conditions detailed
 * in the LICENCE file provided within the distribution */

#include <stdio.h>
#include <string.h>
#include <syslog.h>

#include "getifstats.h"

#if defined(__sun)
/* solaris 10 does not define LOG_PERROR */
#define LOG_PERROR 0
#endif

int
main(int argc, char **argv)
{
	int r;
	struct ifdata data;
	if(argc<2)
	{
		fprintf(stderr, "usage : %s <ifname>\n", argv[0]);
		return 1;
	}
	openlog("testgetifstats", LOG_CONS|LOG_PERROR, LOG_USER);
	memset(&data, 0, sizeof(data));
	r = getifstats(argv[1], &data);
	printf("getifstats() returned %d\n", r);
	printf("stats for interface %s :\n", argv[1]);
	printf("bitrate = %lu\n", data.baudrate);
	printf(" input packets : %9lu\t input bytes : %9lu\n",
	       data.ipackets, data.ibytes);
	printf("output packets : %9lu\toutput bytes : %9lu\n",
	       data.opackets, data.obytes);
	return 0;
}