mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-04 17:47:03 +03:00
socket-util: drop getnameinfo_pretty()
This commit is contained in:
parent
01e4793de6
commit
92db49a0c2
@ -758,19 +758,6 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getnameinfo_pretty(int fd, char **ret) {
|
||||
union sockaddr_union sa;
|
||||
socklen_t salen = sizeof(sa);
|
||||
|
||||
assert(fd >= 0);
|
||||
assert(ret);
|
||||
|
||||
if (getsockname(fd, &sa.sa, &salen) < 0)
|
||||
return -errno;
|
||||
|
||||
return socknameinfo_pretty(&sa, salen, ret);
|
||||
}
|
||||
|
||||
int socket_address_unlink(SocketAddress *a) {
|
||||
assert(a);
|
||||
|
||||
|
@ -126,7 +126,6 @@ int getpeername_pretty(int fd, bool include_port, char **ret);
|
||||
int getsockname_pretty(int fd, char **ret);
|
||||
|
||||
int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret);
|
||||
int getnameinfo_pretty(int fd, char **ret);
|
||||
|
||||
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
|
||||
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
|
||||
|
@ -360,58 +360,6 @@ static void test_in_addr_ifindex_from_string_auto(void) {
|
||||
assert_se(in_addr_ifindex_from_string_auto("fe80::19%thisinterfacecantexist", &family, &ua, &ifindex) == -ENODEV);
|
||||
}
|
||||
|
||||
static void *connect_thread(void *arg) {
|
||||
union sockaddr_union *sa = arg;
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
||||
fd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
assert_se(fd >= 0);
|
||||
|
||||
assert_se(connect(fd, &sa->sa, sizeof(sa->in)) == 0);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void test_nameinfo_pretty(void) {
|
||||
_cleanup_free_ char *stdin_name = NULL, *localhost = NULL;
|
||||
|
||||
union sockaddr_union s = {
|
||||
.in.sin_family = AF_INET,
|
||||
.in.sin_port = 0,
|
||||
.in.sin_addr.s_addr = htobe32(INADDR_ANY),
|
||||
};
|
||||
int r;
|
||||
|
||||
union sockaddr_union c = {};
|
||||
socklen_t slen = sizeof(c.in), clen = sizeof(c.in);
|
||||
|
||||
_cleanup_close_ int sfd = -1, cfd = -1;
|
||||
r = getnameinfo_pretty(STDIN_FILENO, &stdin_name);
|
||||
log_info_errno(r, "No connection remote: %m");
|
||||
|
||||
assert_se(r < 0);
|
||||
|
||||
sfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
|
||||
assert_se(sfd >= 0);
|
||||
|
||||
assert_se(bind(sfd, &s.sa, sizeof(s.in)) == 0);
|
||||
|
||||
/* find out the port number */
|
||||
assert_se(getsockname(sfd, &s.sa, &slen) == 0);
|
||||
|
||||
assert_se(listen(sfd, 1) == 0);
|
||||
|
||||
assert_se(asynchronous_job(connect_thread, &s) == 0);
|
||||
|
||||
log_debug("Accepting new connection on fd:%d", sfd);
|
||||
cfd = accept4(sfd, &c.sa, &clen, SOCK_CLOEXEC);
|
||||
assert_se(cfd >= 0);
|
||||
|
||||
r = getnameinfo_pretty(cfd, &localhost);
|
||||
log_info("Connection from %s", localhost);
|
||||
assert_se(r == 0);
|
||||
}
|
||||
|
||||
static void test_sockaddr_equal(void) {
|
||||
union sockaddr_union a = {
|
||||
.in.sin_family = AF_INET,
|
||||
@ -561,8 +509,6 @@ int main(int argc, char *argv[]) {
|
||||
test_in_addr_ifindex_to_string();
|
||||
test_in_addr_ifindex_from_string_auto();
|
||||
|
||||
test_nameinfo_pretty();
|
||||
|
||||
test_sockaddr_equal();
|
||||
|
||||
test_sockaddr_un_len();
|
||||
|
Loading…
x
Reference in New Issue
Block a user