1
1

Added support for reverse mode (-R for now).

Этот коммит содержится в:
sethdelliott 2010-07-01 00:01:57 +00:00
родитель abfced3c26
Коммит efb7bbe44b
3 изменённых файлов: 40 добавлений и 41 удалений

Просмотреть файл

@ -196,21 +196,19 @@ enum
TEST_START = 1, TEST_START = 1,
TEST_RUNNING = 2, TEST_RUNNING = 2,
RESULT_REQUEST = 3, RESULT_REQUEST = 3,
RESULT_RESPOND = 4, TEST_END = 4,
TEST_END = 5, STREAM_BEGIN = 5,
STREAM_BEGIN = 6, STREAM_RUNNING = 6,
STREAM_RUNNING = 7, STREAM_END = 7,
STREAM_END = 8, ALL_STREAMS_END = 8,
ALL_STREAMS_END = 9, PARAM_EXCHANGE = 9,
PARAM_EXCHANGE = 10, CREATE_STREAMS = 10,
PARAM_EXCHANGE_ACK = 11, SERVER_TERMINATE = 11,
CREATE_STREAMS = 12, CLIENT_TERMINATE = 12,
SERVER_TERMINATE = 13, EXCHANGE_RESULTS = 13,
CLIENT_TERMINATE = 14, DISPLAY_RESULTS = 14,
EXCHANGE_RESULTS = 15, IPERF_START = 15,
DISPLAY_RESULTS = 16, IPERF_DONE = 16,
IPERF_START = 17,
IPERF_DONE = 18,
ACCESS_DENIED = -1, ACCESS_DENIED = -1,
}; };

Просмотреть файл

@ -136,8 +136,8 @@ iperf_send(struct iperf_test *test)
reporter_interval = new_timer(test->reporter_interval, 0); reporter_interval = new_timer(test->reporter_interval, 0);
test->state = TEST_RUNNING; test->state = TEST_RUNNING;
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
perror("write TEST_RUNNING"); perror("Nwrite TEST_RUNNING");
exit(1); exit(1);
} }
@ -178,8 +178,8 @@ iperf_send(struct iperf_test *test)
free_timer(reporter_interval); free_timer(reporter_interval);
test->state = TEST_END; test->state = TEST_END;
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
perror("write TEST_END"); perror("Nwrite TEST_END");
return -1; return -1;
} }
test->stats_callback(test); test->stats_callback(test);
@ -270,8 +270,8 @@ package_parameters(struct iperf_test *test)
*pstring = (char) (strlen(pstring) - 1); *pstring = (char) (strlen(pstring) - 1);
if (write(test->ctrl_sck, pstring, (size_t) strlen(pstring)) < 0) { if (Nwrite(test->ctrl_sck, pstring, (size_t) strlen(pstring), Ptcp) < 0) {
perror("write pstring"); perror("Nwrite pstring");
return -1; return -1;
} }
@ -363,7 +363,6 @@ iperf_exchange_parameters(struct iperf_test * test)
package_parameters(test); package_parameters(test);
} else { } else {
parse_parameters(test); parse_parameters(test);
printf(" cookie: %s\n", test->default_settings->cookie); printf(" cookie: %s\n", test->default_settings->cookie);
@ -376,8 +375,8 @@ iperf_exchange_parameters(struct iperf_test * test)
// Send the control message to create streams and start the test // Send the control message to create streams and start the test
test->state = CREATE_STREAMS; test->state = CREATE_STREAMS;
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
perror("write CREATE_STREAMS"); perror("Nwrite CREATE_STREAMS");
return -1; return -1;
} }
@ -719,6 +718,9 @@ iperf_handle_message_client(struct iperf_test *test)
} }
switch (test->state) { switch (test->state) {
case PARAM_EXCHANGE:
iperf_exchange_parameters(test);
break;
case CREATE_STREAMS: case CREATE_STREAMS:
iperf_create_streams(test); iperf_create_streams(test);
break; break;
@ -727,9 +729,11 @@ iperf_handle_message_client(struct iperf_test *test)
case TEST_RUNNING: case TEST_RUNNING:
break; break;
case TEST_END: case TEST_END:
break; if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
case PARAM_EXCHANGE: perror("Nwrite TEST_END\n");
iperf_exchange_parameters(test); return -1;
}
test->stats_callback(test);
break; break;
case EXCHANGE_RESULTS: case EXCHANGE_RESULTS:
iperf_exchange_results(test); iperf_exchange_results(test);
@ -1146,8 +1150,8 @@ iperf_client_end(struct iperf_test *test)
} }
test->state = IPERF_DONE; test->state = IPERF_DONE;
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
perror("write IPERF_DONE"); perror("Nwrite IPERF_DONE");
return -1; return -1;
} }
@ -1172,12 +1176,12 @@ iperf_run_client(struct iperf_test * test)
// set error and return // set error and return
return -1; return -1;
} }
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
if (setjmp(env)) { if (setjmp(env)) {
fprintf(stderr, "Interrupt received. Exiting...\n"); fprintf(stderr, "Interrupt received. Exiting...\n");
test->state = CLIENT_TERMINATE; test->state = CLIENT_TERMINATE;
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
fprintf(stderr, "Unable to send CLIENT_TERMINATE message to serer\n"); fprintf(stderr, "Unable to send CLIENT_TERMINATE message to serer\n");
} }
exit(1); exit(1);

Просмотреть файл

@ -160,8 +160,8 @@ iperf_accept(struct iperf_test *test)
} }
} }
} else { } else {
if (write(s, &rbuf, sizeof(int)) < 0) { if (Nwrite(s, &rbuf, sizeof(int), Ptcp) < 0) {
perror("write"); perror("Nwrite ACCESS_DENIED");
return -1; return -1;
} }
close(s); close(s);
@ -183,9 +183,6 @@ iperf_handle_message_server(struct iperf_test *test)
} }
switch(test->state) { switch(test->state) {
case PARAM_EXCHANGE:
iperf_exchange_parameters(test);
break;
case TEST_START: case TEST_START:
break; break;
case TEST_RUNNING: case TEST_RUNNING:
@ -197,14 +194,14 @@ iperf_handle_message_server(struct iperf_test *test)
close(sp->socket); close(sp->socket);
} }
test->state = EXCHANGE_RESULTS; test->state = EXCHANGE_RESULTS;
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
perror("write EXCHANGE_RESULTS"); perror("Nwrite EXCHANGE_RESULTS");
exit(1); exit(1);
} }
iperf_exchange_results(test); iperf_exchange_results(test);
test->state = DISPLAY_RESULTS; test->state = DISPLAY_RESULTS;
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
perror("write DISPLAY_RESULTS"); perror("Nwrite DISPLAY_RESULTS");
exit(1); exit(1);
} }
test->stats_callback(test); test->stats_callback(test);
@ -283,7 +280,7 @@ iperf_run_server(struct iperf_test *test)
fprintf(stderr, "Interrupt received. Exiting...\n"); fprintf(stderr, "Interrupt received. Exiting...\n");
test->state = SERVER_TERMINATE; test->state = SERVER_TERMINATE;
if (test->ctrl_sck >= 0) { if (test->ctrl_sck >= 0) {
if (write(test->ctrl_sck, &test->state, sizeof(char)) < 0) { if (Nwrite(test->ctrl_sck, &test->state, sizeof(char), Ptcp) < 0) {
fprintf(stderr, "Unable to send SERVER_TERMINATE message to client\n"); fprintf(stderr, "Unable to send SERVER_TERMINATE message to client\n");
} }
} }