summaryrefslogtreecommitdiffstats
path: root/src/server/sockhelper.h
diff options
context:
space:
mode:
authorSimon Rettberg2015-11-24 12:30:46 +0100
committerSimon Rettberg2015-11-24 12:30:46 +0100
commit7b51c287a60d2f202fb131eeed9d1bf19b65a7a3 (patch)
tree031573c708b50aeafe9a6fe6f0992b3ae6456e7c /src/server/sockhelper.h
parent[SERVER] Fix race condition potentially leading to use after release (diff)
downloaddnbd3-7b51c287a60d2f202fb131eeed9d1bf19b65a7a3.tar.gz
dnbd3-7b51c287a60d2f202fb131eeed9d1bf19b65a7a3.tar.xz
dnbd3-7b51c287a60d2f202fb131eeed9d1bf19b65a7a3.zip
[FUSE] Mid-refactoring, does not compile
Diffstat (limited to 'src/server/sockhelper.h')
-rw-r--r--src/server/sockhelper.h86
1 files changed, 0 insertions, 86 deletions
diff --git a/src/server/sockhelper.h b/src/server/sockhelper.h
deleted file mode 100644
index 3f4d485..0000000
--- a/src/server/sockhelper.h
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef SOCKHELPER_H_
-#define SOCKHELPER_H_
-
-/*
- * Helper functions for dealing with sockets. These functions should
- * abstract from the IP version by using getaddrinfo() and thelike.
- */
-
-#include <stdint.h>
-#include "../types.h"
-#include <sys/socket.h>
-#include <string.h>
-
-typedef struct _poll_list poll_list_t;
-
-/**
- * Connect to given dnbd3_host_t.
- * @param addr - address of host to connect to
- * @param connect_ms - timeout in milliseconds after which the connection attempt fails
- * @param rw_ms - read/write timeout in milliseconds to apply on successful connect
- * @return socket file descriptor, or -1 on error
- */
-int sock_connect(const dnbd3_host_t * const addr, const int connect_ms, const int rw_ms);
-
-void sock_setTimeout(const int sockfd, const int milliseconds);
-
-/**
- * Create new poll list.
- */
-poll_list_t* sock_newPollList();
-
-/**
- * Delete a poll list, closing all sockets first if necessary.
- */
-void sock_destroyPollList(poll_list_t *list);
-
-/**
- * Listen on all interfaces/available IP addresses, using the given protocol.
- * IPv4 and IPv6 are supported.
- * @param protocol_family PF_INET or PF_INET6
- * @param port port to listen on
- * @return the socket descriptor if successful, -1 otherwise.
- */
-int sock_listenAny(poll_list_t* list, uint16_t port);
-
-/**
- * Listen on a specific address and port.
- * @param addr pointer to a properly filled sockaddr_in or sockaddr_in6
- * @param addrlen length of the passed struct
- */
-bool sock_listen(poll_list_t* list, char* bind_addr, uint16_t port);
-
-/**
- * This is a multi-socket version of accept. Pass in an array of listening sockets.
- * If any of the sockets has an incoming connection, accept it and return the new socket's fd.
- * On error, return -1, just like accept().
- * @param sockets array of listening socket fds
- * @param socket_count number of sockets in that array
- * @return fd of new client socket, -1 on error
- */
-int sock_accept(poll_list_t *list, struct sockaddr_storage *addr, socklen_t *length_ptr);
-
-void sock_set_nonblock(int sock);
-
-void sock_set_block(int sock);
-
-/**
- * Add given socket to array. Take an existing empty slot ( == -1) if available,
- * append to end otherwise. Updates socket count variable passed by reference.
- *
- * @param poll_list_t list the poll list to add the socket to
- * @param sock socket fd to add
- * @param wantRead whether to set the EPOLLIN flag
- * @param wantWrite whether to set the EPOLLOUT flag
- * @return true on success, false iff the array is already full or socket is < 0
- */
-bool sock_append(poll_list_t *list, const int sock, bool wantRead, bool wantWrite);
-
-/**
- * Send the whole buffer, calling write() multiple times if neccessary.
- * Give up after calling write() maxtries times.
- * Set maxtries < 0 to try infinitely.
- */
-ssize_t sock_sendAll(int sock, void *buffer, size_t len, int maxtries);
-
-#endif /* SOCKHELPER_H_ */