summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2011-10-27 12:04:50 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2012-01-10 01:54:45 +0100
commit395ac42f5f1844834698f29032b101c2890b6772 (patch)
treef305b2a1bea37516875d9125fee768dba89075d8 /src
parent65be3d49b0f4350a227dedd70ac17c7c9cf6274e (diff)
downloadconntrack-tools-395ac42f5f1844834698f29032b101c2890b6772.tar.gz
conntrack-tools-395ac42f5f1844834698f29032b101c2890b6772.zip
conntrackd: generalize external handlers to prepare expectation support
This patch contains cleanups to prepare the expectation support for external handlers. Mostly renamings. I have also updated the file headers to include Vyatta in the copyright statement. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/external_cache.c39
-rw-r--r--src/external_inject.c37
-rw-r--r--src/sync-mode.c22
3 files changed, 52 insertions, 46 deletions
diff --git a/src/external_cache.c b/src/external_cache.c
index 073f309..4b6fa6f 100644
--- a/src/external_cache.c
+++ b/src/external_cache.c
@@ -1,6 +1,7 @@
/*
- * (C) 2006-2009 by Pablo Neira Ayuso <pablo@netfilter.org>
- *
+ * (C) 2006-2011 by Pablo Neira Ayuso <pablo@netfilter.org>
+ * (C) 2011 by Vyatta Inc. <http://www.vyatta.com>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -43,7 +44,7 @@ static void external_cache_close(void)
cache_destroy(external);
}
-static void external_cache_new(struct nf_conntrack *ct)
+static void external_cache_ct_new(struct nf_conntrack *ct)
{
struct cache_object *obj;
int id;
@@ -66,12 +67,12 @@ retry:
}
}
-static void external_cache_upd(struct nf_conntrack *ct)
+static void external_cache_ct_upd(struct nf_conntrack *ct)
{
cache_update_force(external, ct);
}
-static void external_cache_del(struct nf_conntrack *ct)
+static void external_cache_ct_del(struct nf_conntrack *ct)
{
struct cache_object *obj;
int id;
@@ -83,12 +84,12 @@ static void external_cache_del(struct nf_conntrack *ct)
}
}
-static void external_cache_dump(int fd, int type)
+static void external_cache_ct_dump(int fd, int type)
{
cache_dump(external, fd, type);
}
-static int external_cache_commit(struct nfct_handle *h, int fd)
+static int external_cache_ct_commit(struct nfct_handle *h, int fd)
{
if (!cache_commit(external, h, fd)) {
dlog(LOG_NOTICE, "commit already in progress, skipping");
@@ -98,17 +99,17 @@ static int external_cache_commit(struct nfct_handle *h, int fd)
return LOCAL_RET_STOLEN;
}
-static void external_cache_flush(void)
+static void external_cache_ct_flush(void)
{
cache_flush(external);
}
-static void external_cache_stats(int fd)
+static void external_cache_ct_stats(int fd)
{
cache_stats(external, fd);
}
-static void external_cache_stats_ext(int fd)
+static void external_cache_ct_stats_ext(int fd)
{
cache_stats_extended(external, fd);
}
@@ -116,12 +117,14 @@ static void external_cache_stats_ext(int fd)
struct external_handler external_cache = {
.init = external_cache_init,
.close = external_cache_close,
- .new = external_cache_new,
- .update = external_cache_upd,
- .destroy = external_cache_del,
- .dump = external_cache_dump,
- .commit = external_cache_commit,
- .flush = external_cache_flush,
- .stats = external_cache_stats,
- .stats_ext = external_cache_stats_ext,
+ .ct = {
+ .new = external_cache_ct_new,
+ .upd = external_cache_ct_upd,
+ .del = external_cache_ct_del,
+ .dump = external_cache_ct_dump,
+ .commit = external_cache_ct_commit,
+ .flush = external_cache_ct_flush,
+ .stats = external_cache_ct_stats,
+ .stats_ext = external_cache_ct_stats_ext,
+ },
};
diff --git a/src/external_inject.c b/src/external_inject.c
index 56e24a3..ba5f3d1 100644
--- a/src/external_inject.c
+++ b/src/external_inject.c
@@ -1,6 +1,7 @@
/*
- * (C) 2009 by Pablo Neira Ayuso <pablo@netfilter.org>
- *
+ * (C) 2006-2011 by Pablo Neira Ayuso <pablo@netfilter.org>
+ * (C) 2011 by Vyatta Inc. <http://www.vyatta.com>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -59,7 +60,7 @@ static void external_inject_close(void)
nfct_close(inject);
}
-static void external_inject_new(struct nf_conntrack *ct)
+static void external_inject_ct_new(struct nf_conntrack *ct)
{
int ret, retry = 1;
@@ -87,7 +88,7 @@ retry:
}
}
-static void external_inject_upd(struct nf_conntrack *ct)
+static void external_inject_ct_upd(struct nf_conntrack *ct)
{
int ret;
@@ -128,7 +129,7 @@ static void external_inject_upd(struct nf_conntrack *ct)
dlog_ct(STATE(log), ct, NFCT_O_PLAIN);
}
-static void external_inject_del(struct nf_conntrack *ct)
+static void external_inject_ct_del(struct nf_conntrack *ct)
{
if (nl_destroy_conntrack(inject, ct) == -1) {
if (errno != ENOENT) {
@@ -141,21 +142,21 @@ static void external_inject_del(struct nf_conntrack *ct)
}
}
-static void external_inject_dump(int fd, int type)
+static void external_inject_ct_dump(int fd, int type)
{
}
-static int external_inject_commit(struct nfct_handle *h, int fd)
+static int external_inject_ct_commit(struct nfct_handle *h, int fd)
{
/* close the commit socket. */
return LOCAL_RET_OK;
}
-static void external_inject_flush(void)
+static void external_inject_ct_flush(void)
{
}
-static void external_inject_stats(int fd)
+static void external_inject_ct_stats(int fd)
{
char buf[512];
int size;
@@ -177,12 +178,14 @@ static void external_inject_stats(int fd)
struct external_handler external_inject = {
.init = external_inject_init,
.close = external_inject_close,
- .new = external_inject_new,
- .update = external_inject_upd,
- .destroy = external_inject_del,
- .dump = external_inject_dump,
- .commit = external_inject_commit,
- .flush = external_inject_flush,
- .stats = external_inject_stats,
- .stats_ext = external_inject_stats,
+ .ct = {
+ .new = external_inject_ct_new,
+ .upd = external_inject_ct_upd,
+ .del = external_inject_ct_del,
+ .dump = external_inject_ct_dump,
+ .commit = external_inject_ct_commit,
+ .flush = external_inject_ct_flush,
+ .stats = external_inject_ct_stats,
+ .stats_ext = external_inject_ct_stats,
+ },
};
diff --git a/src/sync-mode.c b/src/sync-mode.c
index 34d9706..7f019f7 100644
--- a/src/sync-mode.c
+++ b/src/sync-mode.c
@@ -88,13 +88,13 @@ do_channel_handler_step(int i, struct nethdr *net, size_t remain)
switch(net->type) {
case NET_T_STATE_NEW:
- STATE_SYNC(external)->new(ct);
+ STATE_SYNC(external)->ct.new(ct);
break;
case NET_T_STATE_UPD:
- STATE_SYNC(external)->update(ct);
+ STATE_SYNC(external)->ct.upd(ct);
break;
case NET_T_STATE_DEL:
- STATE_SYNC(external)->destroy(ct);
+ STATE_SYNC(external)->ct.del(ct);
break;
default:
STATE_SYNC(error).msg_rcv_malformed++;
@@ -387,7 +387,7 @@ static void run_sync(fd_set *readfds)
if (FD_ISSET(get_read_evfd(STATE_SYNC(commit).evfd), readfds)) {
read_evfd(STATE_SYNC(commit).evfd);
- STATE_SYNC(external)->commit(STATE_SYNC(commit).h, 0);
+ STATE_SYNC(external)->ct.commit(STATE_SYNC(commit).h, 0);
}
/* flush pending messages */
@@ -478,7 +478,7 @@ static int local_handler_sync(int fd, int type, void *data)
break;
case DUMP_EXTERNAL:
if (fork_process_new(CTD_PROC_ANY, 0, NULL, NULL) == 0) {
- STATE_SYNC(external)->dump(fd, NFCT_O_PLAIN);
+ STATE_SYNC(external)->ct.dump(fd, NFCT_O_PLAIN);
exit(EXIT_SUCCESS);
}
break;
@@ -490,7 +490,7 @@ static int local_handler_sync(int fd, int type, void *data)
break;
case DUMP_EXT_XML:
if (fork_process_new(CTD_PROC_ANY, 0, NULL, NULL) == 0) {
- STATE_SYNC(external)->dump(fd, NFCT_O_XML);
+ STATE_SYNC(external)->ct.dump(fd, NFCT_O_XML);
exit(EXIT_SUCCESS);
}
break;
@@ -499,7 +499,7 @@ static int local_handler_sync(int fd, int type, void *data)
del_alarm(&STATE_SYNC(reset_cache_alarm));
dlog(LOG_NOTICE, "committing external cache");
- ret = STATE_SYNC(external)->commit(STATE_SYNC(commit).h, fd);
+ ret = STATE_SYNC(external)->ct.commit(STATE_SYNC(commit).h, fd);
break;
case RESET_TIMERS:
if (!alarm_pending(&STATE_SYNC(reset_cache_alarm))) {
@@ -514,7 +514,7 @@ static int local_handler_sync(int fd, int type, void *data)
del_alarm(&STATE_SYNC(reset_cache_alarm));
dlog(LOG_NOTICE, "flushing caches");
STATE(mode)->internal->ct.flush();
- STATE_SYNC(external)->flush();
+ STATE_SYNC(external)->ct.flush();
break;
case FLUSH_INT_CACHE:
/* inmediate flush, remove pending flush scheduled if any */
@@ -524,14 +524,14 @@ static int local_handler_sync(int fd, int type, void *data)
break;
case FLUSH_EXT_CACHE:
dlog(LOG_NOTICE, "flushing external cache");
- STATE_SYNC(external)->flush();
+ STATE_SYNC(external)->ct.flush();
break;
case KILL:
killer(0);
break;
case STATS:
STATE(mode)->internal->ct.stats(fd);
- STATE_SYNC(external)->stats(fd);
+ STATE_SYNC(external)->ct.stats(fd);
dump_traffic_stats(fd);
multichannel_stats(STATE_SYNC(channel), fd);
dump_stats_sync(fd);
@@ -542,7 +542,7 @@ static int local_handler_sync(int fd, int type, void *data)
break;
case STATS_CACHE:
STATE(mode)->internal->ct.stats_ext(fd);
- STATE_SYNC(external)->stats_ext(fd);
+ STATE_SYNC(external)->ct.stats_ext(fd);
break;
case STATS_LINK:
multichannel_stats_extended(STATE_SYNC(channel),