diff options
author | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
commit | dbb41ce2b7f309d394054a6bd1e33afd578798a5 (patch) | |
tree | 6a31092063d9f2fb5ac5720ec6759040e793c3d5 /src/kernel/tests/include/safe_net_fn.h | |
parent | Set Linux kernel version to unknown if it is not detectable (diff) | |
download | xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.gz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.xz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.zip |
Move the source code of all xloop components to the common 'src' directory
Diffstat (limited to 'src/kernel/tests/include/safe_net_fn.h')
-rw-r--r-- | src/kernel/tests/include/safe_net_fn.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/kernel/tests/include/safe_net_fn.h b/src/kernel/tests/include/safe_net_fn.h new file mode 100644 index 0000000..2fda11f --- /dev/null +++ b/src/kernel/tests/include/safe_net_fn.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz> + * Copyright (c) 2015 Fujitsu Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef SAFE_NET_FN_H__ +#define SAFE_NET_FN_H__ + +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <sys/un.h> + +int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void), + int domain, int type, int protocol); + +int safe_socketpair(const char *file, const int lineno, int domain, int type, + int protocol, int sv[]); + +int safe_getsockopt(const char *file, const int lineno, int sockfd, int level, + int optname, void *optval, socklen_t *optlen); + +int safe_setsockopt(const char *file, const int lineno, int sockfd, int level, + int optname, const void *optval, socklen_t optlen); + +ssize_t safe_send(const char *file, const int lineno, char len_strict, + int sockfd, const void *buf, size_t len, int flags); + +ssize_t safe_sendto(const char *file, const int lineno, char len_strict, + int sockfd, const void *buf, size_t len, int flags, + const struct sockaddr *dest_addr, socklen_t addrlen); + +ssize_t safe_sendmsg(const char *file, const int lineno, size_t msg_len, + int sockfd, const struct msghdr *msg, int flags); + +ssize_t safe_recvmsg(const char *file, const int lineno, size_t msg_len, + int sockfd, struct msghdr *msg, int flags); + +int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void), + int socket, const struct sockaddr *address, + socklen_t address_len); + +int safe_listen(const char *file, const int lineno, void (cleanup_fn)(void), + int socket, int backlog); + +int safe_accept(const char *file, const int lineno, void (cleanup_fn)(void), + int sockfd, struct sockaddr *addr, socklen_t *addrlen); + +int safe_connect(const char *file, const int lineno, void (cleanup_fn)(void), + int sockfd, const struct sockaddr *addr, socklen_t addrlen); + +int safe_getsockname(const char *file, const int lineno, + void (cleanup_fn)(void), int sockfd, struct sockaddr *addr, + socklen_t *addrlen); + +int safe_gethostname(const char *file, const int lineno, + char *name, size_t size); + +int tst_getsockport(const char *file, const int lineno, int sockfd); + +unsigned short tst_get_unused_port(const char *file, const int lineno, + void (cleanup_fn)(void), unsigned short family, int type); + +char *tst_sock_addr(const struct sockaddr *sa, socklen_t salen, char *res, + size_t len); + +#endif /* SAFE_NET_FN_H__ */ |