Split up log file into epochs so that we can throw away old data.
[fprobe-ulog.git] / src / fprobe-ulog.h
1 /*
2         Copyright (C) Slava Astashonok <sla@0n.ru>
3
4         This program is free software; you can redistribute it and/or
5         modify it under the terms of the GNU General Public License.
6
7         $Id: fprobe-ulog.h,v 1.1.2.3 2005/01/29 19:30:41 sla Exp $
8 */
9
10 #ifndef _FPROBE_ULOG_H_
11 #define _FPROBE_ULOG_H_
12
13 #include <my_inttypes.h>
14
15 #ifndef IP_OFFMASK
16 #define IP_OFFMASK 0x1fff
17 #endif
18
19 #define MAX_PATH_LEN 255
20 #define MAX_DIGIT 5
21
22 #define SCHED SCHED_FIFO
23 #define EMIT_TIMEOUT 5
24 #define UNPENDING_TIMEOUT 5
25 #define CAPTURE_SIZE 131072
26 #define THREADS 5
27 #define COPY_INTO 0
28 #define MOVE_INTO 1
29
30 struct Time {
31         time_t sec;
32         long usec;
33 };
34
35 struct Flow {
36         /* input interface */
37         uint16_t iif;
38         /* output interface */
39         uint16_t oif;
40         /* ip src address */
41         struct in_addr sip;
42         /* ip dst address */
43         struct in_addr dip;
44         /* ip protocol */
45         uint8_t proto;
46         /* ip fragment id */
47         uint16_t id;
48         /* tcp/udp src port or icmp message type */
49         uint16_t sp;
50         /* tcp/udp dst port or icmp type sub-code */
51         uint16_t dp;
52         /* ip ToS */
53         uint8_t tos;
54         /* tcp flags */
55         uint8_t tcp_flags;
56         /* number of packets */
57         unsigned long pkts;
58         /* sum of packets sizes */
59         unsigned long size;
60         /* fragment data size (for fragmented packets) */
61         unsigned long sizeF;
62         /* whole packet data size (for fragmented packets) */
63         unsigned long sizeP;
64         /* time of creation/flushing this flow */
65         struct Time ctime;
66         /* time of last modification this flow */
67         struct Time mtime;
68 #define FLOW_FRAG       0x0001
69 #define FLOW_FRAGMASK   0x0003
70 #define FLOW_TL         0x0004
71 #define FLOW_LASTFRAG   0x0008
72 #define FLOW_PENDING    0x8000
73         int flags;
74         struct Flow *next;
75 };
76
77 struct Flow_F {
78         /* input interface */
79         uint16_t iif;
80         /* output interface */
81         uint16_t oif;
82         /* ip src address */
83         struct in_addr sip;
84         /* ip dst address */
85         struct in_addr dip;
86         /* ip protocol */
87         uint8_t proto;
88         /* ip fragment id */
89         uint16_t id;
90 };
91
92 struct Flow_TL {
93         /* input interface */
94         uint16_t iif;
95         /* output interface */
96         uint16_t oif;
97         /* ip src address */
98         struct in_addr sip;
99         /* ip dst address */
100         struct in_addr dip;
101         /* ip protocol */
102         uint8_t proto;
103         /* ip fragment id */
104         uint16_t id;
105         /* tcp/udp src port or icmp message type */
106         uint16_t sp;
107         /* tcp/udp dst port or icmp type sub-code */
108         uint16_t dp;
109 };
110
111 #define SIGALRM_MASK 1
112 #define SIGTERM_MASK 2
113 #define SIGUSR1_MASK 4
114
115 struct peer {
116         int write_fd;
117         char *fname;
118         struct sockaddr_in addr;
119         struct sockaddr_in laddr;
120         int type;
121         uint32_t seq;
122         int fd;
123 };
124
125 struct snmp_rule {
126         char basename[IFNAMSIZ];
127         int len;
128         int base;
129 } snmp_rule_t;
130
131 #define PEER_MIRROR 0
132 #define PEER_ROTATE 1
133 #define PEER_FILE 2
134
135 #endif