{"client", required_argument, 0, 'c'},
{"close", no_argument, 0, 'x'},
{"debug", no_argument, 0, 'd'},
+ {"duplex", no_argument, 0, 'D'},
{"keepalive", no_argument, 0, 'k'},
{"parallel", required_argument, 0, 'P'},
{"port", required_argument, 0, 'p'},
int done = 0;
while (!done) {
- int c = getopt_long(argc, argv, "c:dkp:st:xzP:V", long_options, &option_index);
+ int c = getopt_long(argc, argv, "c:dkp:st:xzDP:V", long_options, &option_index);
// End
if (c == -1)
}
break;
+ case 'D':
+ conf->duplex = 1;
+ break;
+
case 'd':
conf->loglevel = LOG_DEBUG;
break;
free(bps);
}
- // Total bytes sent/received
- char* total_bytes = NULL;
- switch (mode) {
- case FIREPERF_MODE_CLIENT:
- total_bytes = format_size(stats->total_bytes_received, FIREPERF_FORMAT_BYTES);
- INFO(conf, " %-20s: %20s\n", "Total Bytes Received", total_bytes);
- break;
+ struct total_bytes {
+ const char* label;
+ size_t bytes;
+ } totals[] = {
+ { "Total Bytes Received", stats->total_bytes_received, },
+ { "Total Bytes Sent", stats->total_bytes_sent, },
+ { NULL },
+ };
- case FIREPERF_MODE_SERVER:
- total_bytes = format_size(stats->total_bytes_sent, FIREPERF_FORMAT_BYTES);
- INFO(conf, " %-20s: %20s\n", "Total Bytes Sent", total_bytes);
- break;
+ for (struct total_bytes* total = totals; total->label; total++) {
+ if (!total->bytes)
+ continue;
+
+ char* s = format_size(total->bytes, FIREPERF_FORMAT_BYTES);
+ INFO(conf, " %-20s: %20s\n", total->label, s);
+ free(s);
}
// Remember when this was printed last
stats->bytes_received = 0;
stats->bytes_sent = 0;
- // Cleanup
- if (total_bytes)
- free(total_bytes);
-
return 0;
}