-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
82 lines (75 loc) · 1.38 KB
/
common.h
File metadata and controls
82 lines (75 loc) · 1.38 KB
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
#ifndef COMMON_H
#define COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <error.h>
#include <pcap/pcap.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <time.h>
#include <sys/file.h>
#include <sys/statvfs.h>
#include <fcntl.h>
#include <signal.h>
#define DATABASEDIR "/home/fly100"
#define XMLBASEDIR "/var/www/dataxml"
#define DEFIFACE "eth0"
#define LOCKTRYLIMIT 5
#define MYSTATVERSION "1.11"
#define XMLVERSION 1
typedef struct {
char name[32];
int filled;
uint64_t rx;
uint64_t tx;
time_t date;
} FLOWBUF;
typedef struct {
time_t date;
uint64_t rx, tx;
int rxk, txk;
int used;
} DAY;
typedef struct {
time_t month;
uint64_t rx, tx;
int rxk, txk;
int used;
} MONTH;
typedef struct {
char interface[32];
char nick[32];
int active;
uint64_t totalrx, totaltx, currx, curtx;
int totalrxk, totaltxk;
time_t lastupdated, created;
DAY day[30];
MONTH month[12];
DAY top10[10];
uint64_t btime;
} DATA;
typedef enum PrintType {
PT_Info = 0,
PT_Error,
PT_Config,
PT_Multiline,
PT_ShortMultiline
} PrintType;
/*common functions*/
int printe(PrintType type);
int initbuf(void);
/*common variables*/
DATA data;
FLOWBUF flowbuf;
char dev[32];
char ipaddr[20];
char errorstring[512];
int debug;
FILE *dataxml;
#endif