From: Michael Tremer Date: Thu, 19 Sep 2024 08:20:03 +0000 (+0000) Subject: constants: Move all constants into their own header file X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa53d99a66a303de6700e03b6e88437d4960a29c;p=fireperf.git constants: Move all constants into their own header file Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index f1ed703..3a65503 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/client.c b/src/client.c index 691c661..35f9c92 100644 --- a/src/client.c +++ b/src/client.c @@ -26,6 +26,7 @@ #include #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 index 0000000..f6b3e42 --- /dev/null +++ b/src/constants.h @@ -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 . # +# # +#############################################################################*/ + +#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 */ diff --git a/src/ctx.h b/src/ctx.h index e31ddad..c772b35 100644 --- a/src/ctx.h +++ b/src/ctx.h @@ -23,7 +23,7 @@ #include -#define MAX_WORKERS 128 +#include "constants.h" // Forward declarations struct fireperf_random_pool; diff --git a/src/logging.c b/src/logging.c index 3aba649..128ee02 100644 --- a/src/logging.c +++ b/src/logging.c @@ -22,8 +22,8 @@ #include #include +#include "ctx.h" #include "logging.h" -#include "main.h" int fireperf_get_log_level(struct fireperf_ctx* ctx) { return ctx->loglevel; diff --git a/src/main.h b/src/main.h index ae779f3..203d9f1 100644 --- a/src/main.h +++ b/src/main.h @@ -23,23 +23,6 @@ #include -#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 diff --git a/src/server.c b/src/server.c index 01a2613..bab80f6 100644 --- a/src/server.c +++ b/src/server.c @@ -27,15 +27,14 @@ #include #include +#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; diff --git a/src/worker.c b/src/worker.c index cbb5ac1..d2d93f8 100644 --- a/src/worker.c +++ b/src/worker.c @@ -24,6 +24,8 @@ #include #include +#include "constants.h" +#include "ctx.h" #include "main.h" #include "logging.h" #include "worker.h"