diff options
-rw-r--r-- | include/external.h | 18 | ||||
-rw-r--r-- | src/external_cache.c | 39 | ||||
-rw-r--r-- | src/external_inject.c | 37 | ||||
-rw-r--r-- | src/sync-mode.c | 22 |
4 files changed, 62 insertions, 54 deletions
diff --git a/include/external.h b/include/external.h index 6619967..eef0e42 100644 --- a/include/external.h +++ b/include/external.h @@ -7,15 +7,17 @@ struct external_handler { int (*init)(void); void (*close)(void); - void (*new)(struct nf_conntrack *ct); - void (*update)(struct nf_conntrack *ct); - void (*destroy)(struct nf_conntrack *ct); + struct { + void (*new)(struct nf_conntrack *ct); + void (*upd)(struct nf_conntrack *ct); + void (*del)(struct nf_conntrack *ct); - void (*dump)(int fd, int type); - void (*flush)(void); - int (*commit)(struct nfct_handle *h, int fd); - void (*stats)(int fd); - void (*stats_ext)(int fd); + void (*dump)(int fd, int type); + void (*flush)(void); + int (*commit)(struct nfct_handle *h, int fd); + void (*stats)(int fd); + void (*stats_ext)(int fd); + } ct; }; extern struct external_handler external_cache; 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), |