diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-04-24 10:55:33 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-05-28 12:34:32 +0200 |
commit | 1250135046b96f2778bda51517c8a722171a6c16 (patch) | |
tree | 84344a92d70fe82b717be1c5344f10eddd295351 /src/channel_tcp.c | |
parent | fcd6f78d277113628205789c8aba9ab1f5152fc4 (diff) | |
download | conntrack-tools-1250135046b96f2778bda51517c8a722171a6c16.tar.gz conntrack-tools-1250135046b96f2778bda51517c8a722171a6c16.zip |
conntrackd: generalize file descriptor infrastructure
This patch generalizes the select-based file descriptor infrastructure
by allowing you to register file descriptors and its callbacks. Instead
of hardcoding the descriptors that needs to be checked.
Now, struct fds_item contains a callback and pointer to data that is
passed to it:
struct fds_item {
struct list_head head;
int fd;
+ void (*cb)(void *data);
+ void *data;
};
Then, we check which ones are active in the select_main_step() function:
list_for_each_entry(cur, &STATE(fds)->list, head) {
if (FD_ISSET(cur->fd, &readfds))
cur->cb(cur->data);
}
And it invoked the corresponding callback.
I had to slightly modify the channel infrastructure to fit it into
the changes.
This modularity is required for the upcoming cthelper support.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/channel_tcp.c')
-rw-r--r-- | src/channel_tcp.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/channel_tcp.c b/src/channel_tcp.c index f132840..a84603c 100644 --- a/src/channel_tcp.c +++ b/src/channel_tcp.c @@ -137,6 +137,7 @@ channel_tcp_accept(struct channel *c) struct channel_ops channel_tcp = { .headersiz = 40, /* IP header (20 bytes) + TCP header 20 (bytes) */ + .type = CHANNEL_T_STREAM, .open = channel_tcp_open, .close = channel_tcp_close, .send = channel_tcp_send, |