Skip to content

Commit

Permalink
Add csv headers and config
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed Jun 10, 2024
1 parent 595c3bd commit 8b1416f
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 160 deletions.
7 changes: 5 additions & 2 deletions src/libnffile/conf/nfconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ int ConfOpen(char *filename, char *section) {
int ConfGetFormatEntry(char *format, char **key, char **value) {
static toml_table_t *fmtConf = NULL;
static int i = 0;

if (!nfconfFile.valid) return 0;

if (!fmtConf) {
Expand All @@ -160,16 +159,20 @@ int ConfGetFormatEntry(char *format, char **key, char **value) {
i = 0;
*key = NULL;
*value = NULL;
fmtConf = NULL;
i = 0;
return 0;
}
toml_datum_t fmtData = toml_string_in(fmtConf, fmtName);
if (fmtData.ok) {
dbg_printf("fmt: %s -> %s\n", fmtName, fmtData.u.s);
dbg_printf("Config %s: %s -> %s\n", format, fmtName, fmtData.u.s);
*value = strdup(fmtData.u.s);
} else {
i = 0;
*key = NULL;
*value = NULL;
fmtConf = NULL;
i = 0;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libnffile/conf/nfdump.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fmt.geolong = "%ts %td %pr %sc %gsap -> %dc %gdap %flg %pkt %byt %fl"
fmt.nokia = "%ts %te %flid %pr %sap -> %dap %isid %osid %nats"

# default csv format
csv.line = "%ts,%td,%pr,%sa,%sp,%da,%dp,%pkt,%byt,%fl"
csv.cvsline = "%ts,%td,%pr,%sa,%sp,%da,%dp,%pkt,%byt,%fl"

# OpenBSD pf logs
fmt.pflog = "%ts %pfact %pfrea %pfdir on %pfifn %pfrule %pr %sap -> %dap %pkt %byt"
Expand Down
3 changes: 2 additions & 1 deletion src/output/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ void PrintOutputHelp(void) {

for (int i = 0; printmap[i].printmode != NULL; i++) {
if (printmap[i].Format != NULL) {
printf("%10s : %s -o fmt %s\n", printmap[i].printmode, printmap[i].help, printmap[i].Format);
printf("%10s : %s -o %s %s\n", printmap[i].printmode, printmap[i].outputMode == MODE_CSV ? "csv" : "fmt", printmap[i].help,
printmap[i].Format);
} else {
printf("%10s : %s\n", printmap[i].printmode, printmap[i].help);
}
Expand Down
Loading

0 comments on commit 8b1416f

Please sign in to comment.