summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/ocbr/ocbr_client.c4
-rw-r--r--src/tools/oecho/oecho.c8
-rw-r--r--src/tools/operf/operf.c2
-rw-r--r--src/tools/operf/operf_client.c6
-rw-r--r--src/tools/oping/oping.c30
-rw-r--r--src/tools/oping/oping_client.c37
6 files changed, 47 insertions, 40 deletions
diff --git a/src/tools/ocbr/ocbr_client.c b/src/tools/ocbr/ocbr_client.c
index 9dd9904c..3da3beb7 100644
--- a/src/tools/ocbr/ocbr_client.c
+++ b/src/tools/ocbr/ocbr_client.c
@@ -98,7 +98,7 @@ int client_main(char * server,
sigaction(SIGHUP, &sig_act, NULL) ||
sigaction(SIGPIPE, &sig_act, NULL)) {
printf("Failed to install sighandler.\n");
- return -1;
+ return 2;
}
printf("Client started, duration %d, rate %lu b/s, size %d B.\n",
@@ -107,7 +107,7 @@ int client_main(char * server,
fd = flow_alloc(server, NULL, NULL);
if (fd < 0) {
printf("Failed to allocate flow.\n");
- return -1;
+ return 2;
}
clock_gettime(CLOCK_REALTIME, &start);
diff --git a/src/tools/oecho/oecho.c b/src/tools/oecho/oecho.c
index 14caab53..ef0a168f 100644
--- a/src/tools/oecho/oecho.c
+++ b/src/tools/oecho/oecho.c
@@ -101,20 +101,20 @@ static int client_main(void)
fd = flow_alloc("oecho", NULL, NULL);
if (fd < 0) {
printf("Failed to allocate flow.\n");
- return -1;
+ return 2;
}
if (flow_write(fd, message, strlen(message) + 1) < 0) {
printf("Failed to write packet.\n");
flow_dealloc(fd);
- return -1;
+ return 1;
}
count = flow_read(fd, buf, BUF_SIZE);
if (count < 0) {
printf("Failed to read packet.\n");
flow_dealloc(fd);
- return -1;
+ return 1;
}
printf("Server replied with %.*s\n", (int) count, buf);
@@ -126,7 +126,7 @@ static int client_main(void)
int main(int argc, char ** argv)
{
- int ret = -1;
+ int ret = 0;
bool server = false;
argc--;
diff --git a/src/tools/operf/operf.c b/src/tools/operf/operf.c
index 1872b351..0198e871 100644
--- a/src/tools/operf/operf.c
+++ b/src/tools/operf/operf.c
@@ -248,5 +248,5 @@ int main(int argc, char ** argv)
if (ret < 0)
exit(EXIT_FAILURE);
- exit(EXIT_SUCCESS);
+ exit(ret);
}
diff --git a/src/tools/operf/operf_client.c b/src/tools/operf/operf_client.c
index 7e8f1a9b..e478aeff 100644
--- a/src/tools/operf/operf_client.c
+++ b/src/tools/operf/operf_client.c
@@ -185,7 +185,7 @@ int client_main(void)
sigaction(SIGHUP, &sig_act, NULL) ||
sigaction(SIGPIPE, &sig_act, NULL)) {
printf("Failed to install sighandler.\n");
- return -1;
+ return 2;
}
client.sent = 0;
@@ -196,7 +196,7 @@ int client_main(void)
fd = flow_alloc(client.server_name, NULL, NULL);
if (fd < 0) {
printf("Failed to allocate flow.\n");
- return -1;
+ return 2;
}
if (client.conf.test_type == TEST_TYPE_BI)
@@ -207,7 +207,7 @@ int client_main(void)
if (flow_write(fd, &client.conf, sizeof(client.conf)) < 0) {
printf("Failed to send configuration.\n");
flow_dealloc(fd);
- return -1;
+ return 1;
}
sleep(1);
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index 763c0d62..16d36c51 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -96,6 +96,7 @@ struct {
bool timestamp;
bool flood;
bool flood_busy;
+ long duration;
qosspec_t qs;
/* stats */
@@ -175,18 +176,19 @@ int main(int argc,
argc--;
argv++;
- client.s_apn = NULL;
- client.interval = 1000;
- client.size = 64;
- client.count = INT_MAX;
- client.timestamp = false;
- client.flood = false;
+ client.s_apn = NULL;
+ client.interval = 1000;
+ client.size = 64;
+ client.count = INT_MAX;
+ client.timestamp = false;
+ client.flood = false;
client.flood_busy = false;
- client.qs = qos_raw;
- client.quiet = false;
- server.quiet = false;
- server.poll = false;
- server.busy = false;
+ client.duration = 0;
+ client.qs = qos_raw;
+ client.quiet = false;
+ server.quiet = false;
+ server.poll = false;
+ server.busy = false;
while (argc > 0) {
if ((strcmp(*argv, "-i") == 0 ||
@@ -249,7 +251,9 @@ int main(int argc,
}
if (duration > 0) {
- if (client.interval == 0)
+ if (client.flood || client.flood_busy)
+ client.duration = duration;
+ else if (client.interval == 0)
client.count = duration * 10;
else
client.count = duration / client.interval;
@@ -298,7 +302,7 @@ int main(int argc,
if (ret < 0)
exit(EXIT_FAILURE);
- exit(EXIT_SUCCESS);
+ exit(ret);
fail:
usage();
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index 23807f65..62b94e67 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -47,6 +47,7 @@ void shutdown_client(int signo, siginfo_t * info, void * c)
case SIGINT:
case SIGTERM:
case SIGHUP:
+ case SIGALRM:
stop = true;
default:
return;
@@ -284,18 +285,15 @@ static int flood_busy_ping(int fd)
msg->tv_sec = sent.tv_sec;
msg->tv_nsec = sent.tv_nsec;
- if (flow_write(fd, buf,
- client.size) < 0) {
- printf("Failed to send "
- "packet.\n");
+ if (flow_write(fd, buf, client.size) < 0) {
+ printf("Failed to send packet.\n");
break;
}
++client.sent;
do {
- n = flow_read(fd, buf,
- OPING_BUF_SIZE);
+ n = flow_read(fd, buf, OPING_BUF_SIZE);
} while (n == -EAGAIN && !stop);
if (n < 0)
@@ -315,9 +313,7 @@ static int flood_busy_ping(int fd)
update_rtt_stats(ms);
if (!client.quiet)
- print_rtt(client.size,
- ntohl(msg->id), ms,
- NULL);
+ print_rtt(client.size, ntohl(msg->id), ms, NULL);
}
return 0;
@@ -371,9 +367,7 @@ static int flood_ping(int fd)
update_rtt_stats(ms);
if (!client.quiet)
- print_rtt(client.size,
- ntohl(msg->id), ms,
- NULL);
+ print_rtt(client.size, ntohl(msg->id), ms, NULL);
}
return 0;
@@ -404,25 +398,34 @@ static int client_main(void)
if (sigaction(SIGINT, &sig_act, NULL) ||
sigaction(SIGTERM, &sig_act, NULL) ||
sigaction(SIGHUP, &sig_act, NULL) ||
- sigaction(SIGPIPE, &sig_act, NULL)) {
+ sigaction(SIGPIPE, &sig_act, NULL) ||
+ sigaction(SIGALRM, &sig_act, NULL)) {
printf("Failed to install sighandler.\n");
- return -1;
+ return 2;
}
if (client_init()) {
printf("Failed to initialize client.\n");
- return -1;
+ return 2;
}
fd = flow_alloc(client.s_apn, &client.qs, NULL);
if (fd < 0) {
printf("Failed to allocate flow: %d.\n", fd);
client_fini();
- return -1;
+ return 2;
}
fccntl(fd, FLOWSFLAGS, FLOWFRDWR | FLOWFRNOPART);
+ if (client.duration > 0) {
+ struct itimerval it;
+ memset(&it, 0, sizeof(it));
+ it.it_value.tv_sec = client.duration / 1000;
+ it.it_value.tv_usec = (client.duration % 1000) * 1000;
+ setitimer(ITIMER_REAL, &it, NULL);
+ }
+
clock_gettime(CLOCK_REALTIME, &tic);
if (client.flood_busy)
@@ -439,5 +442,5 @@ static int client_main(void)
flow_dealloc(fd);
client_fini();
- return 0;
+ return client.rcvd == client.sent ? 0 : 1;
}