X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Fsocket-util.c;h=73e19310e065eb2f112d207b13f23221085facf9;hp=1acab1ef95bab65534dad3bf0717a1b5e083235e;hb=6b05aab633fa55aa3070f186869d8fa219be2f38;hpb=b96ed50e3493103d075ff2ce4c3fbad8f26b2e22 diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 1acab1ef9..73e19310e 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - /*** This file is part of systemd. @@ -21,19 +19,22 @@ #include #include +#include #include #include #include #include +#include #include +#include #include -#include #include #include "alloc-util.h" #include "fd-util.h" #include "fileio.h" #include "formats-util.h" +#include "log.h" #include "macro.h" #include "missing.h" #include "parse-util.h" @@ -44,6 +45,7 @@ #include "user-util.h" #include "util.h" +#if 0 /// UNNEEDED by elogind int socket_address_parse(SocketAddress *a, const char *s) { char *e, *n; unsigned u; @@ -435,21 +437,16 @@ const char* socket_address_get_path(const SocketAddress *a) { return a->sockaddr.un.sun_path; } +#endif // 0 bool socket_ipv6_is_supported(void) { - _cleanup_free_ char *l = NULL; - - if (access("/sys/module/ipv6", F_OK) != 0) + if (access("/proc/net/sockstat6", F_OK) != 0) return false; - /* If we can't check "disable" parameter, assume enabled */ - if (read_one_line_file("/sys/module/ipv6/parameters/disable", &l) < 0) - return true; - - /* If module was loaded with disable=1 no IPv6 available */ - return l[0] == '0'; + return true; } +#if 0 /// UNNEEDED by elogind bool socket_address_matches_fd(const SocketAddress *a, int fd) { SocketAddress b; socklen_t solen; @@ -605,7 +602,7 @@ int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ return 0; } -int getpeername_pretty(int fd, char **ret) { +int getpeername_pretty(int fd, bool include_port, char **ret) { union sockaddr_union sa; socklen_t salen = sizeof(sa); int r; @@ -635,7 +632,7 @@ int getpeername_pretty(int fd, char **ret) { /* For remote sockets we translate IPv6 addresses back to IPv4 * if applicable, since that's nicer. */ - return sockaddr_pretty(&sa.sa, salen, true, true, ret); + return sockaddr_pretty(&sa.sa, salen, true, include_port, ret); } int getsockname_pretty(int fd, char **ret) { @@ -755,6 +752,7 @@ bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b return false; } +#endif // 0 int fd_inc_sndbuf(int fd, size_t n) { int r, value; @@ -791,6 +789,7 @@ int fd_inc_rcvbuf(int fd, size_t n) { return 1; } +#if 0 /// UNNEEDED by elogind static const char* const ip_tos_table[] = { [IPTOS_LOWDELAY] = "low-delay", [IPTOS_THROUGHPUT] = "throughput", @@ -799,6 +798,7 @@ static const char* const ip_tos_table[] = { }; DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(ip_tos, int, 0xff); +#endif // 0 int getpeercred(int fd, struct ucred *ucred) { socklen_t n = sizeof(struct ucred); @@ -867,12 +867,19 @@ int getpeersec(int fd, char **ret) { return 0; } -int send_one_fd(int transport_fd, int fd, int flags) { +int send_one_fd_sa( + int transport_fd, + int fd, + const struct sockaddr *sa, socklen_t len, + int flags) { + union { struct cmsghdr cmsghdr; uint8_t buf[CMSG_SPACE(sizeof(int))]; } control = {}; struct msghdr mh = { + .msg_name = (struct sockaddr*) sa, + .msg_namelen = len, .msg_control = &control, .msg_controllen = sizeof(control), }; @@ -894,6 +901,7 @@ int send_one_fd(int transport_fd, int fd, int flags) { return 0; } +#if 0 /// UNNEEDED by elogind int receive_one_fd(int transport_fd, int flags) { union { struct cmsghdr cmsghdr; @@ -935,3 +943,4 @@ int receive_one_fd(int transport_fd, int flags) { return *(int*) CMSG_DATA(found); } +#endif // 0