Merge commit 'local_master/1.3.5.1@6970' into trunk@12172
[iptables.git] / src / netflow.c
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: netflow.c,v 1.2.2.4 2004/02/02 08:06:24 sla Exp $
8 */
9
10 #include <common.h>
11
12 #include <netflow.h>
13
14 static uint16_t NetFlow1_Header[] = {
15         NETFLOW_VERSION,
16         NETFLOW_COUNT,
17         NETFLOW_UPTIME,
18         NETFLOW_UNIX_SECS,
19         NETFLOW_UNIX_NSECS
20 };
21
22 static uint16_t NetFlow1_Flow[] = {
23         NETFLOW_IPV4_SRC_ADDR,
24         NETFLOW_IPV4_DST_ADDR,
25         NETFLOW_IPV4_NEXT_HOP,
26         NETFLOW_INPUT_SNMP,
27         NETFLOW_OUTPUT_SNMP,
28         NETFLOW_PKTS_32,
29         NETFLOW_BYTES_32,
30         NETFLOW_FIRST_SWITCHED,
31         NETFLOW_LAST_SWITCHED,
32         NETFLOW_L4_SRC_PORT,
33         NETFLOW_L4_DST_PORT,
34         NETFLOW_PAD16,
35         NETFLOW_PROT,
36         NETFLOW_SRC_TOS,
37         NETFLOW_TCP_FLAGS,
38         NETFLOW_PAD8, NETFLOW_PAD8, NETFLOW_PAD8,
39         NETFLOW_PAD32
40 };
41
42 static uint16_t NetFlow5_Header[] = {
43         NETFLOW_VERSION,
44         NETFLOW_COUNT,
45         NETFLOW_UPTIME,
46         NETFLOW_UNIX_SECS,
47         NETFLOW_UNIX_NSECS,
48         NETFLOW_FLOW_SEQUENCE,
49         NETFLOW_ENGINE_TYPE,
50         NETFLOW_ENGINE_ID,
51         NETFLOW_PAD16
52 };
53
54 static uint16_t NetFlow5_Flow[] = {
55         NETFLOW_IPV4_SRC_ADDR,
56         NETFLOW_IPV4_DST_ADDR,
57         NETFLOW_IPV4_NEXT_HOP,
58         NETFLOW_INPUT_SNMP,
59         NETFLOW_OUTPUT_SNMP,
60         NETFLOW_PKTS_32,
61         NETFLOW_BYTES_32,
62         NETFLOW_FIRST_SWITCHED,
63         NETFLOW_LAST_SWITCHED,
64         NETFLOW_L4_SRC_PORT,
65         NETFLOW_L4_DST_PORT,
66         NETFLOW_PAD8,
67         NETFLOW_TCP_FLAGS,
68         NETFLOW_PROT,
69         NETFLOW_SRC_TOS,
70         NETFLOW_SRC_AS,
71         NETFLOW_DST_AS,
72         NETFLOW_SRC_MASK,
73         NETFLOW_DST_MASK,
74         NETFLOW_XID /* Whoo hoo! */
75 };
76
77 static uint16_t NetFlow7_Header[] = {
78         NETFLOW_VERSION,
79         NETFLOW_COUNT,
80         NETFLOW_UPTIME,
81         NETFLOW_UNIX_SECS,
82         NETFLOW_UNIX_NSECS,
83         NETFLOW_FLOW_SEQUENCE,
84         NETFLOW_PAD32
85 };
86
87 static uint16_t NetFlow7_Flow[] = {
88         NETFLOW_IPV4_SRC_ADDR,
89         NETFLOW_IPV4_DST_ADDR,
90         NETFLOW_IPV4_NEXT_HOP,
91         NETFLOW_INPUT_SNMP,
92         NETFLOW_OUTPUT_SNMP,
93         NETFLOW_PKTS_32,
94         NETFLOW_BYTES_32,
95         NETFLOW_FIRST_SWITCHED,
96         NETFLOW_LAST_SWITCHED,
97         NETFLOW_L4_SRC_PORT,
98         NETFLOW_L4_DST_PORT,
99         NETFLOW_FLAGS7_1,
100         NETFLOW_TCP_FLAGS,
101         NETFLOW_PROT,
102         NETFLOW_SRC_TOS,
103         NETFLOW_SRC_AS,
104         NETFLOW_DST_AS,
105         NETFLOW_SRC_MASK,
106         NETFLOW_DST_MASK,
107         NETFLOW_FLAGS7_2,
108         NETFLOW_ROUTER_SC
109 };
110
111 struct NetFlow NetFlow1 = {
112         NETFLOW1_VERSION,
113         NETFLOW1_HEADER_SIZE,
114         NETFLOW1_MAX_FLOWS,
115         NETFLOW1_FLOW_SIZE,
116         NETFLOW1_SEQ_OFFSET,
117         sizeof(NetFlow1_Header) / sizeof(uint16_t),
118         NetFlow1_Header,
119         sizeof(NetFlow1_Flow) / sizeof(uint16_t),
120         NetFlow1_Flow
121 };
122
123 struct NetFlow NetFlow5 = {
124         NETFLOW5_VERSION,
125         NETFLOW5_HEADER_SIZE,
126         NETFLOW5_MAX_FLOWS,
127         NETFLOW5_FLOW_SIZE,
128         NETFLOW5_SEQ_OFFSET,
129         sizeof(NetFlow5_Header) / sizeof(uint16_t),
130         NetFlow5_Header,
131         sizeof(NetFlow5_Flow) / sizeof(uint16_t),
132         NetFlow5_Flow
133 };
134
135 struct NetFlow NetFlow7 = {
136         NETFLOW7_VERSION,
137         NETFLOW7_HEADER_SIZE,
138         NETFLOW7_MAX_FLOWS,
139         NETFLOW7_FLOW_SIZE,
140         NETFLOW7_SEQ_OFFSET,
141         sizeof(NetFlow7_Header) / sizeof(uint16_t),
142         NetFlow7_Header,
143         sizeof(NetFlow7_Flow) / sizeof(uint16_t),
144         NetFlow7_Flow
145 };