From 7834e92b218da69cd934679dec9c2d714d89d15e Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 13 Jun 2016 13:48:17 +0200 Subject: lib, irmd, tools, ipcpd: updates to dev API. The registration function has been moved to the irm tool, applications now need to be registered by an administrator. Currently only supports one instance per registered name, and an AP can be registered under only one name. The irmd can now start a registered server application on demand. For the full functionality of the tool, execute "irm register". AP name removed from flow allocation. Flow allocation does not send the source ap name as it is quite useless. The accept() call now only returns the AE name. --- src/tools/cbr/cbr.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src/tools/cbr/cbr.c') diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c index e36b1856..750b5a15 100644 --- a/src/tools/cbr/cbr.c +++ b/src/tools/cbr/cbr.c @@ -30,9 +30,6 @@ #include #include -#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,20 @@ 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; } -- cgit v1.2.3 From 95124310f647913a678060fc10155a0ad9311dba Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 14 Jun 2016 14:52:26 +0200 Subject: Fixed comments on #122 --- src/ipcpd/local/main.c | 2 +- src/irmd/main.c | 7 +++---- src/tools/cbr/cbr.c | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/tools/cbr/cbr.c') diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index e7db58b6..6357487f 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -520,7 +520,7 @@ static int ipcp_local_flow_dealloc(int port_id) bmp_release(_ap_instance->fds, fd); if (_ap_instance->in_out[fd] != -1) - _ap_instance->in_out[_ap_instance->in_out[fd]] =-1; + _ap_instance->in_out[_ap_instance->in_out[fd]] = -1; _ap_instance->in_out[fd] = -1; diff --git a/src/irmd/main.c b/src/irmd/main.c index fc856687..db96b6ed 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -705,7 +705,7 @@ static int ap_reg(char * name, /* we need to duplicate argv */ if (argc != 0) { - argv_dup = malloc ((argc + 2) * sizeof(*argv_dup)); + argv_dup = malloc((argc + 2) * sizeof(*argv_dup)); argv_dup[0] = strdup(api->name); for (i = 1; i <= argc; ++i) argv_dup[i] = strdup(argv[i - 1]); @@ -1108,7 +1108,7 @@ static int auto_execute(char * ap, char ** argv) execv(ap, argv); - LOG_DBG("Failed to execute."); + LOG_ERR("Failed to execute."); exit(EXIT_FAILURE); return 0; @@ -1161,8 +1161,7 @@ static struct port_map_entry * flow_req_arr(pid_t pid, while (rne->accept == false) pthread_cond_wait(&rne->acc_signal, &rne->acc_lock); - } - else { + } else { pthread_mutex_unlock(&rne->acc_lock); LOG_WARN("%s is not accepting flow allocations.", rne->name); diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c index 750b5a15..ab178ca3 100644 --- a/src/tools/cbr/cbr.c +++ b/src/tools/cbr/cbr.c @@ -132,9 +132,7 @@ int main(int argc, char ** argv) if (server) { ret = server_main(); - } else { - if (s_apn == NULL) { printf("No server specified.\n"); usage(); -- cgit v1.2.3