]> git.ipfire.org Git - fireperf.git/commitdiff
constants: Move all constants into their own header file
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 19 Sep 2024 08:20:03 +0000 (08:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 19 Sep 2024 08:20:03 +0000 (08:20 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/client.c
src/constants.h [new file with mode: 0644]
src/ctx.h
src/logging.c
src/main.h
src/server.c
src/worker.c

index f1ed7039394cef8cdcb602e53fc5fcafa6124783..3a6550362b8489ab9a5b029673ca8434a74b0054 100644 (file)
@@ -62,6 +62,7 @@ bin_PROGRAMS = \
 fireperf_SOURCES = \
        src/client.c \
        src/client.h \
+       src/constants.h \
        src/ctx.c \
        src/ctx.h \
        src/logging.c \
index 691c661ab3ce01b93dbc18b5dfd4c5970a184548..35f9c92f6cac9b9a025d1c0a02a65a9adc3915f6 100644 (file)
@@ -26,6 +26,7 @@
 #include <unistd.h>
 
 #include "client.h"
+#include "constants.h"
 #include "ctx.h"
 #include "logging.h"
 #include "main.h"
diff --git a/src/constants.h b/src/constants.h
new file mode 100644 (file)
index 0000000..f6b3e42
--- /dev/null
@@ -0,0 +1,44 @@
+/*#############################################################################
+#                                                                             #
+# fireperf - A network benchmarking tool                                      #
+# Copyright (C) 2024 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_CONSTANTS_H
+#define FIREPERF_CONSTANTS_H
+
+#define DEFAULT_KEEPALIVE_COUNT                        3
+#define DEFAULT_KEEPALIVE_INTERVAL                    10
+#define DEFAULT_LOG_LEVEL                       LOG_INFO
+#define DEFAULT_PARALLEL                               1
+#define DEFAULT_PORT                                5001
+#define DEFAULT_LISTENING_SOCKETS                      1
+
+#define DEFAULT_RANDOM_POOL_SIZE         (SOCKET_SEND_BUFFER_SIZE * 512)
+
+#define MAX_PARALLEL                           (1 << 20)
+#define MAX_WORKERS                                  128
+
+// Socket buffer configuration
+#define SOCKET_BUFFER_SIZE                   (64 * 1024)
+#define SOCKET_RECV_BUFFER_SIZE       SOCKET_BUFFER_SIZE
+#define SOCKET_SEND_BUFFER_SIZE       SOCKET_BUFFER_SIZE
+#define SOCKET_BACKLOG                              1024
+
+#define EPOLL_MAX_EVENTS                             128
+
+#endif /* FIREPERF_CONSTANTS_H */
index e31ddad8362722d03a2d3f977aa93fa957e0880a..c772b35b2e94ee71d93bae42cbbaa23be4bbc222 100644 (file)
--- a/src/ctx.h
+++ b/src/ctx.h
@@ -23,7 +23,7 @@
 
 #include <netinet/in.h>
 
-#define MAX_WORKERS 128
+#include "constants.h"
 
 // Forward declarations
 struct fireperf_random_pool;
index 3aba649ac771d40131c430305bd20c8e29f2e2ea..128ee02e513cc1065089fde00dc6e2db96a8d699 100644 (file)
@@ -22,8 +22,8 @@
 #include <stdio.h>
 #include <syslog.h>
 
+#include "ctx.h"
 #include "logging.h"
-#include "main.h"
 
 int fireperf_get_log_level(struct fireperf_ctx* ctx) {
        return ctx->loglevel;
index ae779f31062f506188a3093c751035fde52c8985..203d9f127196b1799c8e36ba2e25bdae482e5a9c 100644 (file)
 
 #include <time.h>
 
-#define DEFAULT_KEEPALIVE_COUNT     3
-#define DEFAULT_KEEPALIVE_INTERVAL  10
-#define DEFAULT_LOG_LEVEL LOG_INFO
-#define DEFAULT_PARALLEL 1
-#define DEFAULT_PORT 5001
-#define DEFAULT_LISTENING_SOCKETS 1
-#define DEFAULT_RANDOM_POOL_SIZE       (SOCKET_SEND_BUFFER_SIZE * 512)
-
-#define MAX_PARALLEL (1 << 20)
-
-// Socket buffer configuration
-#define SOCKET_BUFFER_SIZE      (64 * 1024)
-#define SOCKET_RECV_BUFFER_SIZE SOCKET_BUFFER_SIZE
-#define SOCKET_SEND_BUFFER_SIZE SOCKET_BUFFER_SIZE
-
-#define EPOLL_MAX_EVENTS 128
-
 #include "ctx.h"
 
 // Struct to collect statistics
index 01a261338e0cbbb7d5859cbe046679f9725365d8..bab80f6f3a3ac9459cf46127526a0e19104f25ae 100644 (file)
 #include <time.h>
 #include <unistd.h>
 
+#include "constants.h"
+#include "ctx.h"
 #include "logging.h"
 #include "main.h"
 #include "server.h"
 #include "util.h"
 #include "worker.h"
 
-#define MAX_WORKERS       128
-#define SOCKET_BACKLOG   1024
-
 struct fireperf_server {
        // ctxiguration
        struct fireperf_ctx* ctx;
index cbb5ac1a9556467f6cf3beb5eca27c9133c622ca..d2d93f8bfd669b66cbff9376cb1a8a7914304e58 100644 (file)
@@ -24,6 +24,8 @@
 #include <sys/epoll.h>
 #include <unistd.h>
 
+#include "constants.h"
+#include "ctx.h"
 #include "main.h"
 #include "logging.h"
 #include "worker.h"