add new_stream and accept callbacks to iperf_test
remove init callback from iperf_stream rework client initialization to take advantage of new_stream callback
Этот коммит содержится в:
родитель
c2b87ef8d9
Коммит
930b564653
@ -312,7 +312,6 @@ struct iperf_stream *iperf_new_tcp_stream(struct iperf_test *testp)
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
sp->accept = iperf_tcp_accept;
|
||||
sp->recv = iperf_tcp_recv;
|
||||
sp->send = iperf_tcp_send;
|
||||
sp->update_stats = iperf_tcp_update_stats;
|
||||
@ -687,26 +686,24 @@ main(int argc, char **argv)
|
||||
test->local_addr = (struct sockaddr_storage *) addr_local;
|
||||
test->remote_addr = (struct sockaddr_storage *) addr_remote;
|
||||
|
||||
switch(test->proto)
|
||||
{
|
||||
case Ptcp:
|
||||
test->accept = iperf_tcp_accept;
|
||||
test->new_stream = iperf_new_tcp_stream;
|
||||
break;
|
||||
case Pudp:
|
||||
test->accept = iperf_udp_accept;
|
||||
test->new_stream = ipref_new_udp_stream;
|
||||
break;
|
||||
}
|
||||
|
||||
if(test->role == 'c')
|
||||
{
|
||||
for(i=0;i<test->num_streams;i++)
|
||||
{
|
||||
sp = test->new_stream(test);
|
||||
sp->remote_port = temp.remote_port;
|
||||
switch(test->proto) {
|
||||
case Ptcp:
|
||||
sp = iperf_new_tcp_stream(test);
|
||||
break;
|
||||
|
||||
case Pudp:
|
||||
sp = iperf_new_udp_stream(test);
|
||||
break;
|
||||
|
||||
case default:
|
||||
fprintf(stderr, "invalid protocol\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
iperf_add_stream(test,sp);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ struct iperf_stream
|
||||
struct sockaddr_storage local_addr;
|
||||
struct sockaddr_storage remote_addr;
|
||||
|
||||
int *(*init)(struct iperf_stream *stream);
|
||||
int (*rcv)(struct iperf_stream *stream);
|
||||
int *(*snd)(struct iperf_stream *stream);
|
||||
int *(*update_stats)(struct iperf_stream *stream);
|
||||
@ -65,6 +64,9 @@ struct iperf_test
|
||||
|
||||
int listener_sock;
|
||||
|
||||
int *(*accept)(struct iperf_test *);
|
||||
int *(*new_stream)(struct iperf_test *);
|
||||
|
||||
int stats_interval; // time interval to gather stats -i
|
||||
void *(*stats_callback)(struct iperf_test *); // callback function pointer for stats
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user