Fix UDP for IPv6 and dual-stack.
Этот коммит содержится в:
родитель
a27f6534b5
Коммит
111645ed0f
@ -71,28 +71,24 @@ iperf_handle_message_client(struct iperf_test *test)
|
||||
|
||||
switch (test->state) {
|
||||
case PARAM_EXCHANGE:
|
||||
if (iperf_exchange_parameters(test) < 0) {
|
||||
if (iperf_exchange_parameters(test) < 0)
|
||||
return -1;
|
||||
}
|
||||
if (test->on_connect)
|
||||
test->on_connect(test);
|
||||
break;
|
||||
case CREATE_STREAMS:
|
||||
if (iperf_create_streams(test) < 0) {
|
||||
if (iperf_create_streams(test) < 0)
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case TEST_START:
|
||||
if (iperf_init_test(test) < 0) {
|
||||
if (iperf_init_test(test) < 0)
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case TEST_RUNNING:
|
||||
break;
|
||||
case EXCHANGE_RESULTS:
|
||||
if (iperf_exchange_results(test) < 0) {
|
||||
if (iperf_exchange_results(test) < 0)
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case DISPLAY_RESULTS:
|
||||
if (test->on_test_finish)
|
||||
|
@ -133,7 +133,7 @@ iperf_accept(struct iperf_test *test)
|
||||
test->on_connect(test);
|
||||
}
|
||||
} else {
|
||||
// XXX: Do we even need to receive cookie if we're just going to deny anyways?
|
||||
/* XXX: Do we even need to receive cookie if we're just going to deny anyways? */
|
||||
if (Nread(s, cookie, COOKIE_SIZE, Ptcp) < 0) {
|
||||
i_errno = IERECVCOOKIE;
|
||||
return -1;
|
||||
|
@ -167,14 +167,14 @@ iperf_udp_send(struct iperf_stream *sp)
|
||||
int
|
||||
iperf_udp_accept(struct iperf_test *test)
|
||||
{
|
||||
struct sockaddr_in sa_peer;
|
||||
struct sockaddr_storage sa_peer;
|
||||
int buf;
|
||||
socklen_t len;
|
||||
int sz, s;
|
||||
|
||||
s = test->prot_listener;
|
||||
|
||||
len = sizeof sa_peer;
|
||||
len = sizeof(sa_peer);
|
||||
if ((sz = recvfrom(test->prot_listener, &buf, sizeof(buf), 0, (struct sockaddr *) &sa_peer, &len)) < 0) {
|
||||
i_errno = IESTREAMACCEPT;
|
||||
return -1;
|
||||
@ -195,6 +195,7 @@ iperf_udp_accept(struct iperf_test *test)
|
||||
test->max_fd = (test->max_fd < test->prot_listener) ? test->prot_listener : test->max_fd;
|
||||
|
||||
/* Let the client know we're ready "accept" another UDP "stream" */
|
||||
buf = 987654321;
|
||||
if (write(s, &buf, sizeof(buf)) < 0) {
|
||||
i_errno = IESTREAMWRITE;
|
||||
return -1;
|
||||
@ -229,22 +230,24 @@ iperf_udp_listen(struct iperf_test *test)
|
||||
int
|
||||
iperf_udp_connect(struct iperf_test *test)
|
||||
{
|
||||
int s, buf;
|
||||
int s, buf, sz;
|
||||
|
||||
if ((s = netdial(test->settings->domain, Pudp, test->bind_address, test->server_hostname, test->server_port)) < 0) {
|
||||
i_errno = IESTREAMCONNECT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Write to the UDP stream to give the server this stream's credentials */
|
||||
/* Write to the UDP stream to let the server know we're here. */
|
||||
buf = 123456789;
|
||||
if (write(s, &buf, sizeof(buf)) < 0) {
|
||||
// XXX: Should this be changed to IESTREAMCONNECT?
|
||||
i_errno = IESTREAMWRITE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Wait until the server confirms the client UDP write */
|
||||
// XXX: Should this read be TCP instead?
|
||||
if (read(s, &buf, sizeof(buf)) < 0) {
|
||||
if ((sz = recv(s, &buf, sizeof(buf), 0)) < 0) {
|
||||
i_errno = IESTREAMREAD;
|
||||
return -1;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user