From 4f431119004577f213e3abd137aaa7f71bede8d3 Mon Sep 17 00:00:00 2001 From: sethdelliott Date: Sat, 26 Jun 2010 00:02:22 +0000 Subject: [PATCH] Removed unused functions from the iperf api code. --- src/iperf_api.c | 63 ------------------------------------------ src/iperf_api.h | 18 ++++-------- src/iperf_server_api.c | 28 ++----------------- src/iperf_server_api.h | 6 ++-- 4 files changed, 11 insertions(+), 104 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index a2ab5c2..aafbaf7 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -424,48 +424,6 @@ display_interval_list(struct iperf_stream_result * rp, int tflag) /************************************************************/ -/** - * receive_result_from_server - Receives result from server - */ - -void -receive_result_from_server(struct iperf_test * test) -{ - int result; - struct iperf_stream *sp; - int size = 0; - char *buf = NULL; - - printf("in receive_result_from_server \n"); - sp = test->streams; - size = MAX_RESULT_STRING; - - buf = (char *) malloc(size); - - printf("receive_result_from_server: send ALL_STREAMS_END to server \n"); - sp->settings->state = ALL_STREAMS_END; - sp->snd(sp); /* send message to server */ - - printf("receive_result_from_server: send RESULT_REQUEST to server \n"); - sp->settings->state = RESULT_REQUEST; - sp->snd(sp); /* send message to server */ - - /* receive from server */ - - printf("reading results (size=%d) back from server \n", size); - do { - result = recv(sp->socket, buf, size, 0); - } while (result == -1 && errno == EINTR); - printf("Got size of results from server: %d \n", result); - - printf(server_reporting, sp->socket); - puts(buf); /* prints results */ - free(buf); - -} - -/*************************************************************/ - /** * connect_msg -- displays connection message * denoting sender/receiver details @@ -878,20 +836,6 @@ print_interval_results(struct iperf_test * test, struct iperf_stream * sp) #endif } -/**************************************************************************/ -void -safe_strcat(char *s1, char *s2) -{ - if (strlen(s1) + strlen(s2) < MAX_RESULT_STRING) { - strcat(s1, s2); - } else { - printf("Error: results string too long \n"); - exit(-1); /* XXX: should return an error instead! */ - /* but code that calls this needs to check for error first */ - //return -1; - } -} - /**************************************************************************/ void iperf_free_stream(struct iperf_stream * sp) @@ -1103,12 +1047,5 @@ iperf_run_client(struct iperf_test * test) } } - /* End the iperf test and clean up client specific memory */ - /* XXX: Commented out until fixed. Probably should be controlled by ctrl_sck - if (iperf_client_end(test) < 0) { - return -1; - } - */ - return 0; } diff --git a/src/iperf_api.h b/src/iperf_api.h index 03628b1..23aa5e3 100644 --- a/src/iperf_api.h +++ b/src/iperf_api.h @@ -29,18 +29,6 @@ void add_to_interval_list(struct iperf_stream_result * rp, struct iperf_int */ void display_interval_list(struct iperf_stream_result * rp, int tflag); -/** - * send_result_to_client - sends result to client via - * a new TCP connection - */ -void send_result_to_client(struct iperf_stream * sp); - -/** - * receive_result_from_server - Receives result from server via - * a new TCP connection - */ -void receive_result_from_server(struct iperf_test * test); - /** * connect_msg -- displays connection message * denoting senfer/receiver details @@ -129,7 +117,6 @@ void iperf_free_stream(struct iperf_stream * sp); void get_tcpinfo(struct iperf_test *test, struct iperf_interval_results *rp); void print_tcpinfo(struct iperf_interval_results *); void build_tcpinfo_message(struct iperf_interval_results *r, char *message); -void safe_strcat(char *s1, char *s2); void print_interval_results(struct iperf_test * test, struct iperf_stream *sp); int iperf_connect(struct iperf_test *); int iperf_client_end(struct iperf_test *); @@ -138,6 +125,11 @@ int iperf_recv(struct iperf_test *); void sig_handler(int); void usage(); void usage_long(); +int all_data_sent(struct iperf_test *); +int package_parameters(struct iperf_test *); +int parse_parameters(struct iperf_test *); +int iperf_create_streams(struct iperf_test *); +int iperf_handle_message_client(struct iperf_test *); #endif diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 25c4c43..ad24d7c 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -44,31 +44,6 @@ jmp_buf env; -/* send_result_to_client - sends result string from server to client */ -void -send_result_to_client(struct iperf_stream * sp) -{ - int result; - int size = sp->settings->blksize; - - char *buf = (char *) malloc(size); - - if (!buf) - { - perror("malloc: unable to allocate transmit buffer"); - } - /* adding the string terminator to the message */ - buf[strlen((char *) sp->data)] = '\0'; - - memcpy(buf, sp->data, strlen((char *) sp->data)); - - printf("send_result_to_client: sending %d bytes \n", (int) strlen((char *) sp->data)); - result = send(sp->socket, buf, size, 0); - printf("RESULT SENT TO CLIENT\n"); - - free(buf); -} - int iperf_server_listen(struct iperf_test *test) { @@ -286,7 +261,8 @@ iperf_run_server(struct iperf_test *test) } } - printf("Test Complete. \n\n"); + // XXX: Need to put the above while loop into another control structure + // that initiates a new test upon each connection rather than dying. /* reset cookie when client is finished */ /* XXX: which cookie to reset, and why is it stored to 2 places? */ diff --git a/src/iperf_server_api.h b/src/iperf_server_api.h index aa997ed..e900f03 100644 --- a/src/iperf_server_api.h +++ b/src/iperf_server_api.h @@ -3,10 +3,12 @@ #include "iperf.h" -void send_result_to_client(struct iperf_stream *); - int iperf_run_server(struct iperf_test *); int iperf_server_listen(struct iperf_test *); +int iperf_acept(struct iperf_test *); + +int iperf_handle_message_server(struct iperf_test *); + #endif