summaryrefslogtreecommitdiff
path: root/src/tools/cbr/cbr.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-06-14 14:56:55 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-06-14 14:56:55 +0200
commit337ab9fe73b86306b72b9eaae3b7be759f7bbd36 (patch)
treed7b237631ef17df911ec4aef766aba085a63bd30 /src/tools/cbr/cbr.c
parent6019a5b1ee574c8cea485ce5ba68ff77a24b4786 (diff)
parent6271d09bdd17114c3095b7e819a7bcded14f26a5 (diff)
downloadouroboros-337ab9fe73b86306b72b9eaae3b7be759f7bbd36.tar.gz
ouroboros-337ab9fe73b86306b72b9eaae3b7be759f7bbd36.zip
Merge remote-tracking branch 'upstream/be' into be-llc
Diffstat (limited to 'src/tools/cbr/cbr.c')
-rw-r--r--src/tools/cbr/cbr.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c
index e36b1856..ab178ca3 100644
--- a/src/tools/cbr/cbr.c
+++ b/src/tools/cbr/cbr.c
@@ -30,9 +30,6 @@
#include <time.h>
#include <stdbool.h>
-#define SERVER_AP_NAME "cbr-server"
-#define CLIENT_AP_NAME "cbr-client"
-
#define BUF_SIZE 1500
#include "cbr_client.c"
@@ -49,6 +46,7 @@ static void usage(void)
printf("Usage: cbr [OPTION]...\n"
"Sends SDU's from client to server at a constant bit rate.\n\n"
" -l, --listen Run in server mode\n"
+ " -n, --server_apn Specify the name of the server.\n"
"\n"
"Server options:\n"
" -i, --interval Server report interval (s)\n"
@@ -66,14 +64,20 @@ static void usage(void)
int main(int argc, char ** argv)
{
- int duration = 60; /* One minute test */
- int size = 1000; /* 1000 byte SDU's */
- long rate = 1000000; /* 1 Mb/s */
- bool flood = false;
- bool sleep = false;
- char * rem;
+ int duration = 60; /* One minute test */
+ int size = 1000; /* 1000 byte SDU's */
+ long rate = 1000000; /* 1 Mb/s */
+ bool flood = false;
+ bool sleep = false;
+ int ret = 0;
+ char * rem = NULL;
+ char * s_apn = NULL;
bool server = false;
+
+ /* FIXME: should be argv[0] */
+ ap_init(argv[0]);
+
server_settings.interval = 1; /* One second reporting interval */
server_settings.timeout = 1;
@@ -88,6 +92,10 @@ int main(int argc, char ** argv)
strcmp(*argv, "--timeout") == 0) {
server_settings.timeout = strtol(*(++argv), &rem, 10);
--argc;
+ } else if (strcmp(*argv, "-n") == 0 ||
+ strcmp(*argv, "--server_apn") == 0) {
+ s_apn = *(++argv);
+ --argc;
} else if (strcmp(*argv, "-d") == 0 ||
strcmp(*argv, "--duration") == 0) {
duration = strtol(*(++argv), &rem, 10);
@@ -123,8 +131,18 @@ int main(int argc, char ** argv)
}
if (server) {
- return server_main();
+ ret = server_main();
+ } else {
+ if (s_apn == NULL) {
+ printf("No server specified.\n");
+ usage();
+ return 0;
+ }
+
+ ret = client_main(s_apn, duration, size, rate, flood, sleep);
}
- return client_main(duration, size, rate, flood, sleep);
+ ap_fini();
+
+ return ret;
}