diff options
author | Mattias Andrée <maandree@kth.se> | 2018-08-29 16:51:41 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-08-29 16:52:38 +0200 |
commit | 7f397be7159a28d459d8f4ba6b934ab86458d633 (patch) | |
tree | 87be67fa6baf8e5b6d548084b80bf038c9a91912 | |
parent | Add tests for strtotimespec and strtotimeval (diff) | |
download | libsimple-7f397be7159a28d459d8f4ba6b934ab86458d633.tar.gz libsimple-7f397be7159a28d459d8f4ba6b934ab86458d633.tar.bz2 libsimple-7f397be7159a28d459d8f4ba6b934ab86458d633.tar.xz |
Remove sendfd, recvfd, recvfrom_timestamped, and recv_timestamped for now
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | README | 18 | ||||
-rw-r--r-- | libsimple.h | 30 | ||||
-rw-r--r-- | recvfd.c | 53 | ||||
-rw-r--r-- | recvfrom_timestamped.c | 70 | ||||
-rw-r--r-- | sendfd.c | 44 |
6 files changed, 0 insertions, 218 deletions
@@ -32,9 +32,6 @@ OBJ =\ rawmemchr.o\ rawmemrchr.o\ rawmemrchr.o\ - recvfd.o\ - recvfrom_timestamped.o\ - sendfd.o\ strcaseends.o\ strcasestr.o\ strchrnul.o\ @@ -319,24 +319,6 @@ The following functions are defined (some as inline functions): libsimple.h defines `extern int libsimple_default_failure_exit`. - int libsimple_sendfd(int sock, int fd) - Send a file descriptor over a socket. - - int libsimple_recvfd(int sock) - Receive a file descriptor over a socket. - - ssize_t libsimple_recvfrom_timestamped(int, void *restrict, size_t, int, - struct sockaddr *restrict, socklen_t, struct timespec *restrict) - Like recvfrom except also returns the a SCM_TIMESTAMP or - SCM_TIMESTAMPNS timestamp, returns zero as the timestamp - if missing. - - ssize_t libsimple_recv_timestamped(int, void *restrict, size_t, int, - struct timespec *restrict) - Like recv except also returns the a SCM_TIMESTAMP or - SCM_TIMESTAMPNS timestamp, returns zero as the timestamp - if missing. - int libsimple_sumtimespec(struct timespec *, const struct timespec *, const struct timespec *) Returns the sum of two timestamps. diff --git a/libsimple.h b/libsimple.h index 6681aad..1d8abf5 100644 --- a/libsimple.h +++ b/libsimple.h @@ -1346,36 +1346,6 @@ libsimple_eprintf(const char *__fmt, ...) #endif -int libsimple_sendfd(int, int); -#ifndef sendfd -# define sendfd libsimple_sendfd -#endif - -_LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) -int libsimple_recvfd(int); -#ifndef recvfd -# define recvfd libsimple_recvfd -#endif - -_LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) -ssize_t libsimple_recvfrom_timestamped(int, void *restrict, size_t, int, struct sockaddr *restrict, - socklen_t, struct timespec *restrict); -#ifndef recvfrom_timestamped -# define recvfrom_timestamped libsimple_recvfrom_timestamped -#endif - -_LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) -static inline ssize_t -libsimple_recv_timestamped(int __fd, void *restrict __buf, size_t __n, /* TODO test */ - int __flags, struct timespec *restrict __ts) -{ - return libsimple_recvfrom_timestamped(__fd, __buf, __n, __flags, NULL, 0, __ts); -} -#ifndef recv_timestamped -# define recv_timestamped libsimple_recv_timestamped -#endif - - _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_sumtimespec(struct timespec *, const struct timespec *, const struct timespec *); #ifndef sumtimespec diff --git a/recvfd.c b/recvfd.c deleted file mode 100644 index cd8ecb6..0000000 --- a/recvfd.c +++ /dev/null @@ -1,53 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "libsimple.h" -#ifndef TEST - - -int -libsimple_recvfd(int sock) /* TODO test */ -{ - int fd; - char buf[1]; - struct iovec iov; - struct msghdr msg; - struct cmsghdr *cmsg; - char cms[CMSG_SPACE(sizeof(fd))]; - - iov.iov_base = buf; - iov.iov_len = 1; - - memset(&msg, 0, sizeof(msg)); - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - msg.msg_control = (caddr_t)cms; - msg.msg_controllen = sizeof(cms); - - switch (recvmsg(sock, &msg, 0)) { - case -1: - return -1; - case 0: - errno = ECONNRESET; - return -1; - default: - break; - } - - cmsg = CMSG_FIRSTHDR(&msg); - memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd)); - return fd; -} - - -#else -#include "test.h" - -int -main(void) -{ - return 0; -} - -#endif diff --git a/recvfrom_timestamped.c b/recvfrom_timestamped.c deleted file mode 100644 index 49e8e3f..0000000 --- a/recvfrom_timestamped.c +++ /dev/null @@ -1,70 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "libsimple.h" -#ifndef TEST - - -ssize_t -libsimple_recvfrom_timestamped(int fd, void *restrict buf, size_t n, int flags, struct sockaddr *restrict addr, /* TODO test */ - socklen_t addrlen, struct timespec *restrict ts) -{ - struct iovec iov; - struct msghdr msg; - struct cmsghdr *cmsg; - char cms[CMSG_SPACE(sizeof(*ts))]; - size_t r; - - iov.iov_base = buf; - iov.iov_len = n; - - memset(&msg, 0, sizeof(msg)); - msg.msg_name = addr; - msg.msg_namelen = addrlen; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - msg.msg_control = (caddr_t)cms; - msg.msg_controllen = sizeof(cms); - - switch ((r = recvmsg(fd, &msg, flags))) { - case -1: - return -1; - case 0: - errno = ECONNRESET; - return -1; - default: - break; - } - - if (!ts) - return r; - - cmsg = CMSG_FIRSTHDR(&msg); - if (cmsg && - cmsg->cmsg_level == SOL_SOCKET && - cmsg->cmsg_type == SCM_TIMESTAMPNS && - cmsg->cmsg_len == CMSG_LEN(sizeof(*ts))) { - memcpy(ts, CMSG_DATA(cmsg), sizeof(*ts)); - } else if (cmsg && - cmsg->cmsg_level == SOL_SOCKET && - cmsg->cmsg_type == SCM_TIMESTAMP && - cmsg->cmsg_len == CMSG_LEN(sizeof(*ts))) { - memcpy(ts, CMSG_DATA(cmsg), sizeof(*ts)); - ts->tv_nsec *= 1000; - } else { - memset(ts, 0, sizeof(*ts)); - } - - return r; -} - - -#else -#include "test.h" - -int -main(void) -{ - return 0; -} - -#endif diff --git a/sendfd.c b/sendfd.c deleted file mode 100644 index 5220761..0000000 --- a/sendfd.c +++ /dev/null @@ -1,44 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "libsimple.h" -#ifndef TEST - - -int -libsimple_sendfd(int sock, int fd) /* TODO test */ -{ - char buf[1]; - struct iovec iov; - struct msghdr msg; - struct cmsghdr *cmsg; - char cms[CMSG_SPACE(sizeof(fd))]; - - buf[0] = 0; - iov.iov_base = buf; - iov.iov_len = 1; - - memset(&msg, 0, sizeof(msg)); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_control = (caddr_t)cms; - msg.msg_controllen = CMSG_LEN(sizeof(fd)); - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); - - return -(sendmsg(sock, &msg, 0) != (ssize_t)iov.iov_len); -} - - -#else -#include "test.h" - -int -main(void) -{ - return 0; -} - -#endif |