summaryrefslogtreecommitdiffstats
path: root/extensions/libct_proto_udp.c
diff options
context:
space:
mode:
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=pablo/emailAddress=pablo@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=pablo/emailAddress=pablo@netfilter.org>2005-12-03 22:33:53 +0000
committer/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=pablo/emailAddress=pablo@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=pablo/emailAddress=pablo@netfilter.org>2005-12-03 22:33:53 +0000
commit5891b45e0eee0307a29ed5103fe6d596f6a37ebd (patch)
tree4da61210c620c3dc173257bf556f83627e52f7d6 /extensions/libct_proto_udp.c
parent2082ea8a70a1c3b7c8b47115f00fcbe70fac9ffa (diff)
o Add support to filter events. ie: -p tcp --orig-port-dst 80 in
conjuction with -E to get all the requests to HTTP servers o Update manpage o Missing static function declaration in the protocol handlers o Use protocol flags defined in libnetfilter_conntrack o Kill leftover #include "conntrack.h" in the ICMP helper o Bumped version to 0.991
Diffstat (limited to 'extensions/libct_proto_udp.c')
-rw-r--r--extensions/libct_proto_udp.c71
1 files changed, 26 insertions, 45 deletions
diff --git a/extensions/libct_proto_udp.c b/extensions/libct_proto_udp.c
index 958d464..974e455 100644
--- a/extensions/libct_proto_udp.c
+++ b/extensions/libct_proto_udp.c
@@ -13,6 +13,7 @@
#include <netinet/in.h> /* For htons */
#include "conntrack.h"
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
+#include <libnetfilter_conntrack/libnetfilter_conntrack_udp.h>
static struct option opts[] = {
{"orig-port-src", 1, 0, '1'},
@@ -24,27 +25,7 @@ static struct option opts[] = {
{0, 0, 0, 0}
};
-enum udp_param_flags {
- ORIG_SPORT_BIT = 0,
- ORIG_SPORT = (1 << ORIG_SPORT_BIT),
-
- ORIG_DPORT_BIT = 1,
- ORIG_DPORT = (1 << ORIG_DPORT_BIT),
-
- REPL_SPORT_BIT = 2,
- REPL_SPORT = (1 << REPL_SPORT_BIT),
-
- REPL_DPORT_BIT = 3,
- REPL_DPORT = (1 << REPL_DPORT_BIT),
-
- MASK_SPORT_BIT = 4,
- MASK_SPORT = (1 << MASK_SPORT_BIT),
-
- MASK_DPORT_BIT = 5,
- MASK_DPORT = (1 << MASK_DPORT_BIT),
-};
-
-void help()
+static void help()
{
fprintf(stdout, "--orig-port-src original source port\n");
fprintf(stdout, "--orig-port-dst original destination port\n");
@@ -54,72 +35,72 @@ void help()
fprintf(stdout, "--mask-port-dst mask destination port\n");
}
-int parse_options(char c, char *argv[],
- struct nfct_tuple *orig,
- struct nfct_tuple *reply,
- struct nfct_tuple *mask,
- union nfct_protoinfo *proto,
- unsigned int *flags)
+static int parse_options(char c, char *argv[],
+ struct nfct_tuple *orig,
+ struct nfct_tuple *reply,
+ struct nfct_tuple *mask,
+ union nfct_protoinfo *proto,
+ unsigned int *flags)
{
switch(c) {
case '1':
if (optarg) {
orig->l4src.udp.port = htons(atoi(optarg));
- *flags |= ORIG_SPORT;
+ *flags |= UDP_ORIG_SPORT;
}
break;
case '2':
if (optarg) {
orig->l4dst.udp.port = htons(atoi(optarg));
- *flags |= ORIG_DPORT;
+ *flags |= UDP_ORIG_DPORT;
}
break;
case '3':
if (optarg) {
reply->l4src.udp.port = htons(atoi(optarg));
- *flags |= REPL_SPORT;
+ *flags |= UDP_REPL_SPORT;
}
break;
case '4':
if (optarg) {
reply->l4dst.udp.port = htons(atoi(optarg));
- *flags |= REPL_DPORT;
+ *flags |= UDP_REPL_DPORT;
}
break;
case '5':
if (optarg) {
mask->l4src.udp.port = htons(atoi(optarg));
- *flags |= MASK_SPORT;
+ *flags |= UDP_MASK_SPORT;
}
break;
case '6':
if (optarg) {
mask->l4dst.udp.port = htons(atoi(optarg));
- *flags |= MASK_DPORT;
+ *flags |= UDP_MASK_DPORT;
}
break;
}
return 1;
}
-int final_check(unsigned int flags,
- unsigned int command,
- struct nfct_tuple *orig,
- struct nfct_tuple *reply)
+static int final_check(unsigned int flags,
+ unsigned int command,
+ struct nfct_tuple *orig,
+ struct nfct_tuple *reply)
{
- if ((flags & (ORIG_SPORT|ORIG_DPORT))
- && !(flags & (REPL_SPORT|REPL_DPORT))) {
+ if ((flags & (UDP_ORIG_SPORT|UDP_ORIG_DPORT))
+ && !(flags & (UDP_REPL_SPORT|UDP_REPL_DPORT))) {
reply->l4src.udp.port = orig->l4dst.udp.port;
reply->l4dst.udp.port = orig->l4src.udp.port;
return 1;
- } else if (!(flags & (ORIG_SPORT|ORIG_DPORT))
- && (flags & (REPL_SPORT|REPL_DPORT))) {
+ } else if (!(flags & (UDP_ORIG_SPORT|UDP_ORIG_DPORT))
+ && (flags & (UDP_REPL_SPORT|UDP_REPL_DPORT))) {
orig->l4src.udp.port = reply->l4dst.udp.port;
orig->l4dst.udp.port = reply->l4src.udp.port;
return 1;
}
- if ((flags & (ORIG_SPORT|ORIG_DPORT))
- && ((flags & (REPL_SPORT|REPL_DPORT))))
+ if ((flags & (UDP_ORIG_SPORT|UDP_ORIG_DPORT))
+ && ((flags & (UDP_REPL_SPORT|UDP_REPL_DPORT))))
return 1;
return 0;
@@ -135,9 +116,9 @@ static struct ctproto_handler udp = {
.version = VERSION,
};
-void __attribute__ ((constructor)) init(void);
+static void __attribute__ ((constructor)) init(void);
-void init(void)
+static void init(void)
{
register_proto(&udp);
}