]> git.ipfire.org Git - fireperf.git/commitdiff
Implement to configure parallelism
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Jan 2021 14:26:41 +0000 (14:26 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 25 Jan 2021 14:26:41 +0000 (14:26 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/main.c
src/main.h

index eb634fc300a5028307213bb21c9d26a8d21ae2d1..308a242a7180ea80a401c50c48473bfc544e21ca 100644 (file)
@@ -58,6 +58,7 @@ static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) {
        static struct option long_options[] = {
                {"client",     required_argument, 0, 'c'},
                {"debug",      no_argument,       0, 'd'},
+               {"parallel",   required_argument, 0, 'P'},
                {"port",       required_argument, 0, 'p'},
                {"server",     no_argument,       0, 's'},
                {0, 0, 0, 0},
@@ -67,7 +68,7 @@ static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) {
        int done = 0;
 
        while (!done) {
-               int c = getopt_long(argc, argv, "c:dp:s", long_options, &option_index);
+               int c = getopt_long(argc, argv, "c:dp:sP:", long_options, &option_index);
 
                // End
                if (c == -1)
@@ -105,6 +106,16 @@ static int parse_argv(int argc, char* argv[], struct fireperf_config* conf) {
                                conf->loglevel = LOG_DEBUG;
                                break;
 
+                       case 'P':
+                               conf->parallel = strtoul(optarg, NULL, 10);
+
+                               if (conf->parallel > MAX_PARALLEL) {
+                                       fprintf(stderr, "Number of parallel connections is too high: %lu\n",
+                                               conf->parallel);
+                                       return 2;
+                               }
+                               break;
+
                        case 'p':
                                conf->port = atoi(optarg);
 
index 9349036e814b95384ee2598031935bb7bf984042..06ec91481646092ab1313c20e4a9e1322c37d2c4 100644 (file)
 #include <netinet/in.h>
 
 #define DEFAULT_LOG_LEVEL LOG_INFO
+#define DEFAULT_PARALLEL 1
 #define DEFAULT_PORT 5001
 
+#define MAX_PARALLEL (1 << 20)
+
 struct fireperf_config {
        int loglevel;
        enum {
@@ -35,6 +38,7 @@ struct fireperf_config {
        } mode;
        struct in6_addr address;
        int port;
+       unsigned long parallel;
 };
 
 #endif /* FIREPERF_MAIN_H */