Skip to content

Commit 126268c

Browse files
committed
Align ftconv compression arguments with other nfdump binaries
1 parent a62fbd6 commit 126268c

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

man/ft2nfdump.1

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
.Nm
3636
.Op Fl r Ar ftfile
3737
.Fl w Ar nffile
38-
.Op Fl Ar z
39-
.Op Fl Ar j
40-
.Op Fl Ar y
38+
.Op Fl z=<compress>
4139
.Op Fl E
4240
.Op Fl c Ar num
4341
.Nm
@@ -61,12 +59,17 @@ expects the data at
6159
.It Fl w Ar nffile
6260
Writes netflow data to
6361
.Ar nffile
64-
.It Fl z
65-
Compress flows using LZO1X-1 compression. Fastest method
66-
.It Fl y
67-
Compress flows using LZ4 compression. Default if no other option is given.
68-
.It Fl j
69-
Compress flows using bz2 compression. Slowest but best compression.
62+
.It Fl z=lzo
63+
Compress flow files with LZO1X-1 compression. Fastest compression.
64+
.It Fl z=bz2
65+
Compress flow files with bz2 compression. Slow but most efficient. It is not recommended
66+
to use bz2 in a real time capturing.
67+
.It Fl z=lz4[:level]
68+
Compress flow files with LZ4 compression. Fast and efficient. Optional level should be between 1..10
69+
Changing the level results in smaller files but uses up more time to compress.
70+
.It Fl z=zstd[:level]
71+
Compress flow files with ZSTD compression. Fast and efficient. Optional level should be between 1..10
72+
Changing the level results in smaller files but uses up more time to compress.
7073
.It Fl c Ar num
7174
Limit the number of flows to the first
7275
.Ar num

src/ft2nfdump/ft2nfdump.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ int main(int argc, char **argv) {
285285
struct ftio ftio;
286286
struct stat statbuf;
287287
uint32_t limitflows;
288-
int i, extended, ret, fd, compress;
288+
int extended, ret, fd, compress;
289289

290290
/* init fterr */
291291
fterr_setid(argv[0]);
@@ -294,11 +294,12 @@ int main(int argc, char **argv) {
294294
limitflows = 0;
295295
char *ftfile = NULL;
296296
char *wfile = NULL;
297-
compress = LZ4_COMPRESSED;
297+
compress = NOT_COMPRESSED;
298298

299-
while ((i = getopt(argc, argv, "jyzEVc:hr:w:?")) != -1) switch (i) {
299+
int c;
300+
while ((c = getopt(argc, argv, "z::jyzEVc:hr:w:")) != EOF) {
301+
switch (c) {
300302
case 'h': /* help */
301-
case '?':
302303
usage(argv[0]);
303304
exit(0);
304305
break;
@@ -337,12 +338,14 @@ int main(int argc, char **argv) {
337338
}
338339
if (optarg == NULL) {
339340
compress = LZO_COMPRESSED;
341+
LogInfo("Legacy option -z defaults to -z=lzo. Use -z=lzo, -z=lz4, -z=bz2 or z=zstd for valid compression formats");
340342
} else {
341-
compress = ParseCompression(optarg);
342-
}
343-
if (compress == -1) {
344-
LogError("Usage for option -z: set -z=lzo, -z=lz4, -z=bz2 or z=zstd for valid compression formats");
345-
exit(EXIT_FAILURE);
343+
int ret = ParseCompression(optarg);
344+
if (ret == -1) {
345+
LogError("Usage for option -z: set -z=lzo, -z=lz4, -z=bz2 or z=zstd for valid compression formats");
346+
exit(EXIT_FAILURE);
347+
}
348+
compress = (unsigned)ret;
346349
}
347350
break;
348351
case 'r':
@@ -353,6 +356,7 @@ int main(int argc, char **argv) {
353356
}
354357
break;
355358
case 'w':
359+
CheckArgLen(optarg, MAXPATHLEN);
356360
wfile = optarg;
357361
break;
358362

@@ -362,7 +366,7 @@ int main(int argc, char **argv) {
362366
break;
363367

364368
} /* switch */
365-
// End while
369+
} // End while
366370

367371
if (argc - optind) fterr_errx(1, "Extra arguments starting with %s.", argv[optind]);
368372

0 commit comments

Comments
 (0)