diff options
author | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2008-01-05 16:41:15 +0000 |
---|---|---|
committer | /C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org> | 2008-01-05 16:41:15 +0000 |
commit | 1102a95296e39f671efe51bb6bd9b30e5c14c91e (patch) | |
tree | d1d42347ea82ce0075884acc23ffa7ba932fb3a1 /include | |
parent | 1c0b4d3721e40586219fb7676e61e6ba19affdd2 (diff) | |
download | conntrack-tools-1102a95296e39f671efe51bb6bd9b30e5c14c91e.tar.gz conntrack-tools-1102a95296e39f671efe51bb6bd9b30e5c14c91e.zip |
implement buffered connection logging to improve performance
Diffstat (limited to 'include')
-rw-r--r-- | include/buffer.h | 18 | ||||
-rw-r--r-- | include/conntrackd.h | 3 | ||||
-rw-r--r-- | include/log.h | 8 |
3 files changed, 28 insertions, 1 deletions
diff --git a/include/buffer.h b/include/buffer.h new file mode 100644 index 0000000..5b854f3 --- /dev/null +++ b/include/buffer.h @@ -0,0 +1,18 @@ +#ifndef _BUFFER_H_ +#define _BUFFER_H_ + +struct buffer { + unsigned char *data; + unsigned int size; + unsigned int cur_size; +}; + +struct buffer *buffer_create(unsigned int size); +int buffer_add(struct buffer *b, void *data, unsigned int size); +void buffer_flush(struct buffer *b, + void (*cb)(void *buffer_data, + void *data), + void *data); +unsigned int buffer_size(struct buffer *b); + +#endif diff --git a/include/conntrackd.h b/include/conntrackd.h index a4a91ea..3bfcf18 100644 --- a/include/conntrackd.h +++ b/include/conntrackd.h @@ -7,6 +7,7 @@ #include <stdio.h> #include <libnetfilter_conntrack/libnetfilter_conntrack.h> #include "cache.h" +#include "buffer.h" #include "debug.h" #include <signal.h> #include "state_helper.h" @@ -93,6 +94,7 @@ struct ct_conf { struct { char logfile[FILENAME_MAXLEN]; int syslog_facility; + unsigned int buffer_size; } stats; }; @@ -136,6 +138,7 @@ struct ct_sync_state { struct ct_stats_state { struct cache *cache; /* internal events cache (netlink) */ + struct buffer *buffer_log; }; union ct_state { diff --git a/include/log.h b/include/log.h index 467ae8f..b5bbddb 100644 --- a/include/log.h +++ b/include/log.h @@ -1,9 +1,15 @@ #ifndef _LOG_H_ #define _LOG_H_ +#include <stdio.h> + +struct buffer; +struct nf_conntrack; + int init_log(); void dlog(FILE *fd, int priority, char *format, ...); -void dlog_ct(FILE *fd, struct nf_conntrack *ct); +void dlog_buffered_ct(FILE *fd, struct buffer *b, struct nf_conntrack *ct); +void dlog_buffered_ct_flush(void *buffer_data, void *data); void close_log(); #endif |