summaryrefslogtreecommitdiff
path: root/src/multichannel.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-04-24 10:55:33 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2012-05-28 12:34:32 +0200
commit1250135046b96f2778bda51517c8a722171a6c16 (patch)
tree84344a92d70fe82b717be1c5344f10eddd295351 /src/multichannel.c
parentfcd6f78d277113628205789c8aba9ab1f5152fc4 (diff)
downloadconntrack-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/multichannel.c')
-rw-r--r--src/multichannel.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/multichannel.c b/src/multichannel.c
index de69d5c..952b567 100644
--- a/src/multichannel.c
+++ b/src/multichannel.c
@@ -109,8 +109,9 @@ void multichannel_set_current_channel(struct multichannel *m, int i)
m->current = m->channel[i];
}
-void multichannel_change_current_channel(struct multichannel *m, int i)
+void
+multichannel_change_current_channel(struct multichannel *m, struct channel *c)
{
- if (m->current != m->channel[i])
- m->current = m->channel[i];
+ if (m->current != c)
+ m->current = c;
}