96995a87752fff96aa330b8efa806573a9265c27
[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 600
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 #define NETFLOW_PDU_SIZE 1464 
30
31 struct Time {
32         time_t sec;
33         long usec;
34 };
35
36 struct Flow {
37         /* input interface */
38         uint16_t iif;
39         /* output interface */
40         uint16_t oif;
41         /* ip src address */
42         struct in_addr sip;
43         /* ip dst address */
44         struct in_addr dip;
45         /* ip protocol */
46         uint8_t proto;
47         /* ip fragment id */
48         uint16_t id;
49         /* tcp/udp src port or icmp message type */
50         uint16_t sp;
51         /* tcp/udp dst port or icmp type sub-code */
52         uint16_t dp;
53         /* ip ToS */
54         uint16_t tos;
55         /* user credentials */
56         int xid;
57         /* tcp flags */
58         uint8_t tcp_flags;
59         /* number of packets */
60         unsigned long pkts;
61         /* sum of packets sizes */
62         unsigned long size;
63         /* fragment data size (for fragmented packets) */
64         unsigned long sizeF;
65         /* whole packet data size (for fragmented packets) */
66         unsigned long sizeP;
67         /* time of creation/flushing this flow */
68         struct Time ctime;
69         /* time of last modification this flow */
70         struct Time mtime;
71 #define FLOW_FRAG       0x0001
72 #define FLOW_FRAGMASK   0x0003
73 #define FLOW_TL         0x0004
74 #define FLOW_LASTFRAG   0x0008
75 #define FLOW_PENDING    0x8000
76         int flags;
77         struct Flow *next;
78 };
79
80 struct Flow_F {
81         /* input interface */
82         uint16_t iif;
83         /* output interface */
84         uint16_t oif;
85         /* ip src address */
86         struct in_addr sip;
87         /* ip dst address */
88         struct in_addr dip;
89         /* ip protocol */
90         uint8_t proto;
91         /* ip fragment id */
92         uint16_t id;
93 };
94
95 struct Flow_TL {
96         /* input interface */
97         uint16_t iif;
98         /* output interface */
99         uint16_t oif;
100         /* ip src address */
101         struct in_addr sip;
102         /* ip dst address */
103         struct in_addr dip;
104         /* ip protocol */
105         uint8_t proto;
106         /* ip fragment id */
107         uint16_t id;
108         /* tcp/udp src port or icmp message type */
109         uint16_t sp;
110         /* tcp/udp dst port or icmp type sub-code */
111         uint16_t dp;
112 };
113
114 #define SIGALRM_MASK 1
115 #define SIGTERM_MASK 2
116 #define SIGUSR1_MASK 4
117
118 struct peer {
119         int write_fd;
120         char *fname;
121         struct sockaddr_in addr;
122         struct sockaddr_in laddr;
123         int type;
124         uint32_t seq;
125         int fd;
126 };
127
128 struct snmp_rule {
129         char basename[IFNAMSIZ];
130         int len;
131         int base;
132 } snmp_rule_t;
133
134 #define PEER_MIRROR 0
135 #define PEER_ROTATE 1
136 #define PEER_FILE 2
137
138 #endif