summaryrefslogtreecommitdiffstats
path: root/include/libtf/io.h
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-11-25 15:11:20 +0200
committerTimo Teras <timo.teras@iki.fi>2009-11-25 15:11:20 +0200
commit2b19cc385163a43b1d559074a795a8aaab751185 (patch)
tree322473e3446153c1bbaac8d6d990734b09d15977 /include/libtf/io.h
parentfc1044daf51f32b9d85f8497e4e0bd5a3c1e7fe9 (diff)
downloadlibtf-2b19cc385163a43b1d559074a795a8aaab751185.tar.bz2
libtf-2b19cc385163a43b1d559074a795a8aaab751185.tar.xz
libtf: implement basic networking i/o
pretty much untested. also some slight changes to how scheduler is invoked.
Diffstat (limited to 'include/libtf/io.h')
-rw-r--r--include/libtf/io.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/include/libtf/io.h b/include/libtf/io.h
index 87a6c90..8f5b54d 100644
--- a/include/libtf/io.h
+++ b/include/libtf/io.h
@@ -20,6 +20,12 @@
#include <libtf/defines.h>
+/* Flags for tf_open_fd() */
+#define TF_FD_AUTOCLOSE 1
+#define TF_FD_STREAM_ORIENTED 2
+#define TF_FD_SET_CLOEXEC 4
+#define TF_FD_ALREADY_NONBLOCKING 8
+
struct tf_fiber;
struct tf_sockaddr {
@@ -27,7 +33,7 @@ struct tf_sockaddr {
struct sockaddr addr;
struct sockaddr_in in;
struct sockaddr_in6 in6;
- };
+ } u;
};
struct tf_fd {
@@ -43,28 +49,28 @@ void tf_poll_init(void);
int tf_poll(tf_mtime_diff_t timeout);
void tf_poll_close(void);
+int tf_open_fd(struct tf_fd *fd, int kfd, int flags);
int tf_open(struct tf_fd *fd, const char *pathname, int flags);
-int tf_open_fd(struct tf_fd *fd, int kfd);
int tf_close(struct tf_fd *fd);
-int tf_read(struct tf_fd *fd, void *buf, size_t count, int timeout);
-int tf_write(struct tf_fd *fd, const void *buf, size_t count, int timeout);
+int tf_read(struct tf_fd *fd, void *buf, size_t count, tf_mtime_diff_t timeout);
+int tf_write(struct tf_fd *fd, const void *buf, size_t count, tf_mtime_diff_t timeout);
int tf_socket(struct tf_fd *fd, int domain, int type, int protocol);
int tf_bind(struct tf_fd *fd, const struct tf_sockaddr *addr);
int tf_listen(struct tf_fd *fd, int backlog);
-int tf_accept(struct tf_fd *fd);
-int tf_connect(struct tf_fd *fd, const struct tf_sockaddr *addr, int timeout);
-ssize_t tf_recv(struct tf_fd *fd, void *buf, size_t count, int timeout);
-ssize_t tf_send(struct tf_fd *fd, const void *buf, size_t count, int timeout);
+int tf_accept(struct tf_fd *listen_fd, struct tf_fd *child_fd,
+ struct tf_sockaddr *from, tf_mtime_diff_t timeout);
+int tf_connect(struct tf_fd *fd, const struct tf_sockaddr *addr, tf_mtime_diff_t timeout);
+
ssize_t tf_recvmsg(struct tf_fd *fd,
struct tf_sockaddr *from, struct tf_sockaddr *to,
- void *buf, size_t count, int timeout);
+ void *buf, size_t count, tf_mtime_diff_t timeout);
ssize_t tf_sendmsg(struct tf_fd *fd,
struct tf_sockaddr *from, const struct tf_sockaddr *to,
- const void *buf, size_t count, int timeout);
+ const void *buf, size_t count, tf_mtime_diff_t timeout);
int tf_query_dns(const char *name, int num_res, struct tf_sockaddr *res,
- int timeout);
+ tf_mtime_diff_t timeout);
#endif