specify client-side port: UDP support
--cport can be specified for udp connections Signed-off-by: Kevin Constantine <kevin.constantine@gmail.com>
Этот коммит содержится в:
родитель
499b122230
Коммит
023fb45e7a
@ -268,7 +268,8 @@ iperf_connect(struct iperf_test *test)
|
||||
|
||||
/* Create and connect the control channel */
|
||||
if (test->ctrl_sck < 0)
|
||||
test->ctrl_sck = netdial(test->settings->domain, Ptcp, test->bind_address, test->server_hostname, test->server_port);
|
||||
// Create the control channel using an ephemeral port
|
||||
test->ctrl_sck = netdial(test->settings->domain, Ptcp, test->bind_address, NULL, test->server_hostname, test->server_port);
|
||||
if (test->ctrl_sck < 0) {
|
||||
i_errno = IECONNECT;
|
||||
return -1;
|
||||
|
@ -234,7 +234,7 @@ iperf_udp_connect(struct iperf_test *test)
|
||||
{
|
||||
int s, buf, sz;
|
||||
|
||||
if ((s = netdial(test->settings->domain, Pudp, test->bind_address, test->server_hostname, test->server_port)) < 0) {
|
||||
if ((s = netdial(test->settings->domain, Pudp, test->bind_address, test->bind_port, test->server_hostname, test->server_port)) < 0) {
|
||||
i_errno = IESTREAMCONNECT;
|
||||
return -1;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
/* make connection to server */
|
||||
int
|
||||
netdial(int domain, int proto, char *local, char *server, int port)
|
||||
netdial(int domain, int proto, char *local, int local_port, char *server, int port)
|
||||
{
|
||||
struct addrinfo hints, *local_res, *server_res;
|
||||
int s;
|
||||
@ -76,6 +76,13 @@ netdial(int domain, int proto, char *local, char *server, int port)
|
||||
}
|
||||
|
||||
if (local) {
|
||||
if (local_port) {
|
||||
struct sockaddr_in *lcladdr;
|
||||
lcladdr = (struct sockaddr_in *)local_res->ai_addr;
|
||||
lcladdr->sin_port = htons(local_port);
|
||||
local_res->ai_addr = (struct sockaddr *)lcladdr;
|
||||
}
|
||||
|
||||
if (bind(s, (struct sockaddr *) local_res->ai_addr, local_res->ai_addrlen) < 0) {
|
||||
close(s);
|
||||
freeaddrinfo(local_res);
|
||||
|
@ -10,7 +10,7 @@
|
||||
#ifndef __NET_H
|
||||
#define __NET_H
|
||||
|
||||
int netdial(int domain, int proto, char *local, char *server, int port);
|
||||
int netdial(int domain, int proto, char *local, int local_port, char *server, int port);
|
||||
int netannounce(int domain, int proto, char *local, int port);
|
||||
int Nread(int fd, char *buf, size_t count, int prot);
|
||||
int Nwrite(int fd, const char *buf, size_t count, int prot) /* __attribute__((hot)) */;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user