summaryrefslogtreecommitdiffstats
path: root/src/poll.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-03-22 00:57:16 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-03-22 00:57:16 +0100
commitdf387f268f8d30d0a21731406bf6031cd6ba9588 (patch)
tree1f1465524c01826a61f7c5f7631c43cce41e6b62 /src/poll.h
parent5266f01d3295e7ac79cf25674167382b86817019 (diff)
downloadfastd-df387f268f8d30d0a21731406bf6031cd6ba9588.tar
fastd-df387f268f8d30d0a21731406bf6031cd6ba9588.zip
Refactor poll API
Diffstat (limited to 'src/poll.h')
-rw-r--r--src/poll.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/poll.h b/src/poll.h
index 823bcc8..fa870a9 100644
--- a/src/poll.h
+++ b/src/poll.h
@@ -36,22 +36,25 @@
#include "types.h"
+/** A file descriptor to poll on */
+struct fastd_poll_fd {
+ fastd_poll_type_t type; /**< What the file descriptor is used for */
+ int fd; /**< The file descriptor itself */
+};
+
+
/** Initializes the poll interface */
void fastd_poll_init(void);
/** Frees the poll interface */
void fastd_poll_free(void);
-/** Updates the file descriptor of the TUN/TAP interface from \e ctx.tunfd */
-void fastd_poll_set_fd_tuntap(void);
-/** Updates the file descriptor of the socket \e ctx.socks[i] */
-void fastd_poll_set_fd_sock(size_t i);
-/** Updates the file descriptor of the dynamic socket for the peer with index \e i in \e ctx.peers */
-void fastd_poll_set_fd_peer(size_t i);
-
-/** Must be called when a peer is added at the end of the peer list */
-void fastd_poll_add_peer(void);
-/** Must be called then the peer with the index \e i is deleted */
-void fastd_poll_delete_peer(size_t i);
+/** Returns a fastd_poll_fd_t structure */
+#define FASTD_POLL_FD(type, fd) ((fastd_poll_fd_t){type, fd})
+
+/** Registers a new file descriptor to poll on */
+void fastd_poll_fd_register(fastd_poll_fd_t *fd);
+/** Unregisters and closes a file descriptor */
+bool fastd_poll_fd_close(fastd_poll_fd_t *fd);
/** Waits for the next input event */
void fastd_poll_handle(void);