Skip to content

Commit

Permalink
Improve ParsedFlow print. Moved to father to access all fields
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Jul 9, 2024
1 parent 4b5d715 commit f4a66f0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions include/ParsedFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class ParsedFlow : public ParsedFlowCore, public ParsedeBPF {
inline char* getRiskName() { return(ndpi_flow_risk_name); }
inline bool isSwapped() { return(is_swapped); }
inline FlowSource getFlowSource() { return(flow_source); }

void print();
};

#endif /* _PARSED_FLOW_H_ */
2 changes: 0 additions & 2 deletions include/ParsedFlowCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class ParsedFlowCore {
ParsedFlowCore(const ParsedFlowCore &pfc);
virtual ~ParsedFlowCore();
void swap();

void print();
};

#endif /* _PARSED_FLOW_CORE_H_ */
18 changes: 18 additions & 0 deletions src/ParsedFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,21 @@ void ParsedFlow::swap() {

is_swapped = true;
}

/* *************************************** */

void ParsedFlow::print() {
char buf1[32], buf2[32];

src_ip.print(buf1, sizeof(buf1));
dst_ip.print(buf2, sizeof(buf2));

ntop->getTrace()->traceEvent(
TRACE_NORMAL, "[src-ip: %s][src-port: %u][dst-ip: %s][dst-port: %u][first: %u][last: %u]",
src_ip.print(buf1, sizeof(buf1)),
ntohs(src_port),
dst_ip.print(buf2, sizeof(buf2)),
ntohs(dst_port),
first_switched,
last_switched);
}
13 changes: 0 additions & 13 deletions src/ParsedFlowCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,3 @@ void ParsedFlowCore::swap() {
dst_as = tmp_src_as, next_adjacent_as = tmp_prev_adjacent_as;
}

/* *************************************** */

void ParsedFlowCore::print() {
char buf1[32], buf2[32];

src_ip.print(buf1, sizeof(buf1));
dst_ip.print(buf2, sizeof(buf2));

ntop->getTrace()->traceEvent(
TRACE_NORMAL, "[src: %s][dst: %s][src_port: %u][dst_port: %u]",
src_ip.print(buf1, sizeof(buf1)), dst_ip.print(buf2, sizeof(buf2)),
ntohs(src_port), ntohs(dst_port));
}

0 comments on commit f4a66f0

Please sign in to comment.