]> git.ipfire.org Git - fireperf.git/commitdiff
Add scaffolding for client/server code
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Jan 2021 14:17:18 +0000 (14:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Jan 2021 14:17:18 +0000 (14:17 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/client.c [new file with mode: 0644]
src/client.h [new file with mode: 0644]
src/main.c
src/server.c [new file with mode: 0644]
src/server.h [new file with mode: 0644]

index a2bb795c567eca2b84715d8d34b4bb7ca52a6b67..4956875942cbca3d9500555719c66d755359ffe0 100644 (file)
@@ -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 (file)
index 0000000..3981960
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#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 (file)
index 0000000..b1d83e5
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifndef FIREPERF_CLIENT_H
+#define FIREPERF_CLIENT_H
+
+#include "main.h"
+
+int fireperf_client(struct fireperf_config* conf);
+
+#endif /* FIREPERF_CLIENT_H */
index fae9b7b4a3c7dcd28e74cd981e7ad95813f0b4af..eb634fc300a5028307213bb21c9d26a8d21ae2d1 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+#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 (file)
index 0000000..3fd9471
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#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 (file)
index 0000000..9dc4a00
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifndef FIREPERF_SERVER_H
+#define FIREPERF_SERVER_H
+
+#include "main.h"
+
+int fireperf_server(struct fireperf_config* conf);
+
+#endif /* FIREPERF_SERVER_H */