Lines 1-13
Link Here
|
1 |
/* Shared library add-on to iptables to add NETFLOW target support. */ |
1 |
/* |
|
|
2 |
* iptables helper for NETFLOW target |
3 |
* <abc@telekom.ru> |
4 |
* |
5 |
* |
6 |
* This file is part of NetFlow exporting module. |
7 |
* |
8 |
* This program is free software: you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License as published by |
10 |
* the Free Software Foundation, either version 2 of the License, or |
11 |
* (at your option) any later version. |
12 |
* |
13 |
* This program is distributed in the hope that it will be useful, |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
* GNU General Public License for more details. |
17 |
* |
18 |
* You should have received a copy of the GNU General Public License |
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 |
* |
21 |
*/ |
22 |
|
23 |
#include <stdio.h> |
24 |
#include <string.h> |
25 |
#include <stdlib.h> |
26 |
#include <getopt.h> |
27 |
#include <net/if.h> |
28 |
#include <sys/socket.h> |
29 |
#include <netinet/in.h> |
30 |
#include <arpa/inet.h> |
31 |
|
32 |
#define __EXPORTED_HEADERS__ |
33 |
#ifdef XTABLES |
2 |
#include <xtables.h> |
34 |
#include <xtables.h> |
|
|
35 |
#else |
36 |
#include <iptables.h> |
37 |
#endif |
38 |
|
39 |
#ifdef XTABLES_VERSION_CODE // since 1.4.1 |
40 |
#define MOD140 |
41 |
#define iptables_target xtables_target |
42 |
#endif |
43 |
|
44 |
#ifdef iptables_target // only in 1.4.0 |
45 |
#define MOD140 |
46 |
#endif |
47 |
|
48 |
#ifdef MOD140 |
49 |
#define ipt_entry_target xt_entry_target |
50 |
#define register_target xtables_register_target |
51 |
#define _IPT_ENTRY void |
52 |
#define _IPT_IP void |
53 |
#ifndef IPT_ALIGN |
54 |
#define IPT_ALIGN XT_ALIGN |
55 |
#endif |
56 |
#else // before 1.3.x |
57 |
#define _IPT_ENTRY struct ipt_entry |
58 |
#define _IPT_IP struct ipt_ip |
59 |
#endif |
60 |
|
61 |
#ifndef IPTABLES_VERSION |
62 |
#define IPTABLES_VERSION XTABLES_VERSION |
63 |
#endif |
64 |
|
65 |
static struct option opts[] = { |
66 |
{ 0 } |
67 |
}; |
68 |
|
69 |
static void help(void) |
70 |
{ |
71 |
printf("NETFLOW target\n"); |
72 |
} |
73 |
|
74 |
static int parse(int c, char **argv, int invert, unsigned int *flags, |
75 |
const _IPT_ENTRY *entry, |
76 |
struct ipt_entry_target **targetinfo) |
77 |
|
78 |
{ |
79 |
return 1; |
80 |
} |
81 |
|
82 |
static void final_check(unsigned int flags) |
83 |
{ |
84 |
} |
85 |
|
86 |
static void save(const _IPT_IP *ip, const struct ipt_entry_target *match) |
87 |
{ |
88 |
} |
89 |
|
90 |
static void print(const _IPT_IP *ip, |
91 |
const struct ipt_entry_target *target, |
92 |
int numeric) |
93 |
{ |
94 |
printf("NETFLOW "); |
95 |
} |
3 |
|
96 |
|
4 |
static struct xtables_target netflow = { |
97 |
static struct iptables_target netflow = { |
|
|
98 |
.next = NULL, |
5 |
.name = "NETFLOW", |
99 |
.name = "NETFLOW", |
6 |
.version = XTABLES_VERSION, |
100 |
.version = IPTABLES_VERSION, |
7 |
.family = NFPROTO_IPV4, |
101 |
.size = IPT_ALIGN(0), |
|
|
102 |
.userspacesize = IPT_ALIGN(0), |
103 |
.help = &help, |
104 |
.parse = &parse, |
105 |
.final_check = &final_check, |
106 |
.print = &print, |
107 |
.save = &save, |
108 |
.extra_opts = opts |
8 |
}; |
109 |
}; |
9 |
|
110 |
|
|
|
111 |
#ifndef _init |
112 |
#define _init __attribute__((constructor)) _INIT |
113 |
#endif |
10 |
void _init(void) |
114 |
void _init(void) |
11 |
{ |
115 |
{ |
12 |
xtables_register_target(&netflow); |
116 |
register_target(&netflow); |
13 |
} |
117 |
} |