From: Michael Tremer Date: Mon, 25 Jan 2021 14:17:18 +0000 (+0000) Subject: Add scaffolding for client/server code X-Git-Tag: 0.1.0~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a8208259b760f1add1f2a1a0c821d6140f4f0404;p=fireperf.git Add scaffolding for client/server code Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index a2bb795..4956875 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,10 +60,14 @@ bin_PROGRAMS = \ fireperf fireperf_SOURCES = \ + src/client.c \ + src/client.h \ src/logging.c \ src/logging.h \ src/main.c \ - src/main.h + src/main.h \ + src/server.c \ + src/server.h # ------------------------------------------------------------------------------ diff --git a/src/client.c b/src/client.c new file mode 100644 index 0000000..3981960 --- /dev/null +++ b/src/client.c @@ -0,0 +1,29 @@ +/*############################################################################# +# # +# fireperf - A network benchmarking tool # +# Copyright (C) 2021 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#include "client.h" +#include "logging.h" +#include "main.h" + +int fireperf_client(struct fireperf_config* conf) { + DEBUG(conf, "Launching " PACKAGE_NAME " in client mode\n"); + + return 0; +} diff --git a/src/client.h b/src/client.h new file mode 100644 index 0000000..b1d83e5 --- /dev/null +++ b/src/client.h @@ -0,0 +1,28 @@ +/*############################################################################# +# # +# fireperf - A network benchmarking tool # +# Copyright (C) 2021 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#ifndef FIREPERF_CLIENT_H +#define FIREPERF_CLIENT_H + +#include "main.h" + +int fireperf_client(struct fireperf_config* conf); + +#endif /* FIREPERF_CLIENT_H */ diff --git a/src/main.c b/src/main.c index fae9b7b..eb634fc 100644 --- a/src/main.c +++ b/src/main.c @@ -24,8 +24,10 @@ #include #include +#include "client.h" #include "main.h" #include "logging.h" +#include "server.h" static int parse_address(const char* string, struct in6_addr* address6) { // Try parsing this address @@ -129,6 +131,7 @@ static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) { int main(int argc, char* argv[]) { struct fireperf_config conf = { .loglevel = DEFAULT_LOG_LEVEL, + .mode = FIREPERF_MODE_NONE, .port = DEFAULT_PORT, }; int r; @@ -138,15 +141,22 @@ int main(int argc, char* argv[]) { if (r) return r; - // Check if a mode has been selected - if (!conf.mode) { - fprintf(stderr, "No mode selected\n"); - return 2; - } - // Dump configuration DEBUG(&conf, "Configuration:\n"); DEBUG(&conf, " Port = %d\n", conf.port); - return 0; + switch (conf.mode) { + case FIREPERF_MODE_CLIENT: + return fireperf_client(&conf); + + case FIREPERF_MODE_SERVER: + return fireperf_server(&conf); + + case FIREPERF_MODE_NONE: + fprintf(stderr, "No mode selected\n"); + r = 2; + break; + } + + return r; } diff --git a/src/server.c b/src/server.c new file mode 100644 index 0000000..3fd9471 --- /dev/null +++ b/src/server.c @@ -0,0 +1,29 @@ +/*############################################################################# +# # +# fireperf - A network benchmarking tool # +# Copyright (C) 2021 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#include "logging.h" +#include "main.h" +#include "server.h" + +int fireperf_server(struct fireperf_config* conf) { + DEBUG(conf, "Launching " PACKAGE_NAME " in server mode\n"); + + return 0; +} diff --git a/src/server.h b/src/server.h new file mode 100644 index 0000000..9dc4a00 --- /dev/null +++ b/src/server.h @@ -0,0 +1,28 @@ +/*############################################################################# +# # +# fireperf - A network benchmarking tool # +# Copyright (C) 2021 IPFire Development Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +#############################################################################*/ + +#ifndef FIREPERF_SERVER_H +#define FIREPERF_SERVER_H + +#include "main.h" + +int fireperf_server(struct fireperf_config* conf); + +#endif /* FIREPERF_SERVER_H */