mirror_iproute2/misc/lnstat.h
Natanael Copa dd9cc0ee81 iproute2: various header include fixes for compiling with musl libc
We need limits.h for LONG_MIN and LONG_MAX, sys/param.h for MIN and
sys/select for struct timeval.

This fixes the following compile errors with musl libc:

f_bpf.c: In function 'bpf_parse_opt':
f_bpf.c:181:12: error: 'LONG_MIN' undeclared (first use in this function)
   if (h == LONG_MIN || h == LONG_MAX) {
            ^
...

tc_util.o: In function `print_tcstats2_attr':
tc_util.c:(.text+0x13fe): undefined reference to `MIN'
tc_util.c:(.text+0x1465): undefined reference to `MIN'
tc_util.c:(.text+0x14ce): undefined reference to `MIN'
tc_util.c:(.text+0x154c): undefined reference to `MIN'
tc_util.c:(.text+0x160a): undefined reference to `MIN'
tc_util.o:tc_util.c:(.text+0x174e): more undefined references to `MIN' follow
...

tc_stab.o: In function `print_size_table':
tc_stab.c:(.text+0x40f): undefined reference to `MIN'
...

fdb.c:247:30: error: 'ULONG_MAX' undeclared (first use in this function)
        (vni >> 24) || vni == ULONG_MAX)
                              ^

lnstat.h:28:17: error: field 'last_read' has incomplete type
  struct timeval last_read;  /* last time of read */
                 ^

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2014-05-28 16:51:39 -07:00

45 lines
1.2 KiB
C

#ifndef _LNSTAT_H
#define _LNSTAT_H
#include <limits.h>
#include <sys/select.h>
#define LNSTAT_VERSION "0.02 041002"
#define PROC_NET_STAT "/proc/net/stat"
#define LNSTAT_MAX_FILES 32
#define LNSTAT_MAX_FIELDS_PER_LINE 32
#define LNSTAT_MAX_FIELD_NAME_LEN 32
struct lnstat_file;
struct lnstat_field {
struct lnstat_file *file;
unsigned int num; /* field number in line */
char name[LNSTAT_MAX_FIELD_NAME_LEN+1];
unsigned long values[2]; /* two buffers for values */
unsigned long result;
};
struct lnstat_file {
struct lnstat_file *next;
char path[PATH_MAX+1];
char basename[NAME_MAX+1];
struct timeval last_read; /* last time of read */
struct timeval interval; /* interval */
int compat; /* 1 == backwards compat mode */
FILE *fp;
unsigned int num_fields; /* number of fields */
struct lnstat_field fields[LNSTAT_MAX_FIELDS_PER_LINE];
};
struct lnstat_file *lnstat_scan_dir(const char *path, const int num_req_files,
const char **req_files);
int lnstat_update(struct lnstat_file *lnstat_files);
int lnstat_dump(FILE *outfd, struct lnstat_file *lnstat_files);
struct lnstat_field *lnstat_find_field(struct lnstat_file *lnstat_files,
const char *name);
#endif /* _LNSTAT_H */