summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-07-25 15:33:17 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-07-25 15:33:17 +0200
commit5cda45defd17211375236c41d4d98dee1a534672 (patch)
treed9f0725a51f895bda400cab7b8fdecbe8c08434a /src/fastd.h
parent900ac61351cabc78b5126adbe9c9936d1c3b5ca6 (diff)
downloadfastd-5cda45defd17211375236c41d4d98dee1a534672.tar
fastd-5cda45defd17211375236c41d4d98dee1a534672.zip
Move more code out of fastd.c
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/fastd.h b/src/fastd.h
index 1bbda28..ba74330 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -311,10 +311,14 @@ struct fastd_string_stack {
void fastd_send(fastd_context_t *ctx, const fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_buffer_t buffer);
void fastd_send_all(fastd_context_t *ctx, fastd_peer_t *source_peer, fastd_buffer_t buffer);
void fastd_send_handshake(fastd_context_t *ctx, const fastd_socket_t *sock, const fastd_peer_address_t *local_addr, const fastd_peer_address_t *remote_addr, fastd_buffer_t buffer);
+void fastd_receive(fastd_context_t *ctx, fastd_socket_t *sock);
+
void fastd_handle_receive(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer_t buffer);
bool fastd_socket_handle_binds(fastd_context_t *ctx);
fastd_socket_t* fastd_socket_open(fastd_context_t *ctx, fastd_peer_t *peer, int af);
+void fastd_socket_close(fastd_context_t *ctx, fastd_socket_t *sock);
+void fastd_socket_error(fastd_context_t *ctx, fastd_socket_t *sock);
void fastd_setfd(const fastd_context_t *ctx, int fd, int set, int unset);
void fastd_setfl(const fastd_context_t *ctx, int fd, int set, int unset);
@@ -460,20 +464,6 @@ static inline void fastd_string_stack_free(fastd_string_stack_t *str) {
}
}
-static inline void fastd_socket_close(fastd_context_t *ctx, fastd_socket_t *sock) {
- if (sock->fd >= 0) {
- if(close(sock->fd))
- pr_error_errno(ctx, "closing socket: close");
-
- sock->fd = -2;
- }
-
- if (sock->bound_addr) {
- free(sock->bound_addr);
- sock->bound_addr = NULL;
- }
-}
-
static inline bool timespec_after(const struct timespec *tp1, const struct timespec *tp2) {
return (tp1->tv_sec > tp2->tv_sec ||
(tp1->tv_sec == tp2->tv_sec && tp1->tv_nsec > tp2->tv_nsec));