Skip to content

Commit

Permalink
Dissolve code for output
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed Feb 3, 2024
1 parent 56919df commit a20249c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else
nflist = flist.c flist.h
endif
filter = grammar.y scanner.l nftree.c nftree.h ipconv.c ipconv.h rbtree.h filter.h
output = userio.c userio.h output_util.c output_util.h output_short.c output_short.h
output = userio.c userio.h output_short.c output_short.h
regex = sgregex/sgregex.c sgregex/sgregex.h
daemon = daemon.c daemon.h
version = version.c version.h
Expand Down
25 changes: 20 additions & 5 deletions src/lib/output_short.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Peter Haag
* Copyright (c) 2024, Peter Haag
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -43,12 +43,27 @@
#include "config.h"
#include "nfdump.h"
#include "nfxV3.h"
#include "output_util.h"
#include "userio.h"
#include "util.h"

#define IP_STRING_LEN (INET6_ADDRSTRLEN)

static char *FlagsString(uint16_t flags) {
static char string[16];

string[0] = flags & 128 ? 'C' : '.'; // Congestion window reduced - CWR
string[1] = flags & 64 ? 'E' : '.'; // ECN-Echo
string[2] = flags & 32 ? 'U' : '.'; // Urgent
string[3] = flags & 16 ? 'A' : '.'; // Ack
string[4] = flags & 8 ? 'P' : '.'; // Push
string[5] = flags & 4 ? 'R' : '.'; // Reset
string[6] = flags & 2 ? 'S' : '.'; // Syn
string[7] = flags & 1 ? 'F' : '.'; // Fin
string[8] = '\0';

return string;
} // End of FlagsString

static void stringEXgenericFlow(FILE *stream, record_map_t *r) {
elementHeader_t *elementHeader = r->offsetMap[EXgenericFlowID];
if (!elementHeader) return;
Expand Down Expand Up @@ -253,10 +268,10 @@ static void stringsEXflowMisc(FILE *stream, record_map_t *r) {
" fwd status = %3u\n"
" dst tos = %3u\n"
" direction = %3u\n"
" biFlow Dir = 0x%.2x %s\n"
" end reason = 0x%.2x %s\n",
" biFlow Dir = 0x%.2x\n"
" end reason = 0x%.2x\n",
flowMisc->input, flowMisc->output, flowMisc->srcMask, snet, flowMisc->srcMask, flowMisc->dstMask, dnet, flowMisc->dstMask, fwdStatus, tos,
flowMisc->dir, flowMisc->biFlowDir, biFlowString(flowMisc->biFlowDir), flowMisc->flowEndReason, FlowEndString(flowMisc->flowEndReason));
flowMisc->dir, flowMisc->biFlowDir, flowMisc->flowEndReason);

} // End of stringsEXflowMisc

Expand Down
2 changes: 1 addition & 1 deletion src/output/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ noinst_LIBRARIES = liboutput.a

liboutput_a_SOURCES = content_dns.c content_dns.h \
ja3.c ja3.h md5.c md5.h \
output.c output.h output_csv.c output_csv.h output_fmt.c \
output.c output.h output_util.c output_util.h output_csv.c output_csv.h output_fmt.c \
output_fmt.h output_json.c output_json.h output_pipe.c output_pipe.h \
output_raw.c output_raw.h

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit a20249c

Please sign in to comment.