Skip to content

Commit

Permalink
Merge branch 'ntop:dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaferret authored Jul 16, 2024
2 parents f9758fe + 4603c5d commit 9ce11dd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/ParsedFlowCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ParsedFlowCore {
u_int8_t l4_proto;
u_int32_t source_id;
u_int32_t device_ip;
u_int32_t probe_ip;
struct ndpi_in6_addr device_ipv6;
u_int16_t src_port, dst_port;
u_int32_t inIndex, outIndex;
Expand Down
2 changes: 2 additions & 0 deletions src/ParsedFlowCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ParsedFlowCore::ParsedFlowCore() {
src_tos = dst_tos = 0;
version = 0;
device_ip = 0;
probe_ip = 0;
src_port = dst_port = 0;
inIndex = outIndex = 0;
observationPointId = 0;
Expand All @@ -58,6 +59,7 @@ ParsedFlowCore::ParsedFlowCore(const ParsedFlowCore &pfc) {
memcpy(&device_ipv6, &pfc.device_ipv6, sizeof(device_ipv6));
version = pfc.version;
device_ip = pfc.device_ip;
probe_ip = pfc.probe_ip;
src_port = pfc.src_port, dst_port = pfc.dst_port;
inIndex = pfc.inIndex, outIndex = pfc.outIndex;
observationPointId = pfc.observationPointId;
Expand Down
4 changes: 2 additions & 2 deletions src/ParserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ bool ParserInterface::processFlow(ParsedFlow *zflow) {
*/
if (!flow_interfaces_stats)
flow_interfaces_stats = new (std::nothrow) FlowInterfacesStats();
are_limits_okay = flow_interfaces_stats->checkExporters(zflow->device_ip, zflow->inIndex);
are_limits_okay = flow_interfaces_stats->checkExporters(zflow->device_ip, zflow->inIndex, zflow->probe_ip);

if (are_limits_okay && (zflow->outIndex != zflow->inIndex))
are_limits_okay = flow_interfaces_stats->checkExporters(zflow->device_ip, zflow->outIndex);
are_limits_okay = flow_interfaces_stats->checkExporters(zflow->device_ip, zflow->outIndex, zflow->probe_ip);


if (!are_limits_okay) {
Expand Down
2 changes: 1 addition & 1 deletion src/ZCCollectorInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void ZCCollectorInterface::collect_flows() {
u_char *json = pfring_zc_pkt_buff_data(buffer, zq);
const char *master = "{ \"if.name\"";

ntop->getTrace()->traceEvent(TRACE_INFO, "%s", json);
ntop->getTrace()->traceEvent(TRACE_NORMAL, "%s", json);
// fprintf(stdout, "+"); fflush(stdout);

if (strncmp((char *)json, master, strlen(master)) == 0) {
Expand Down
11 changes: 6 additions & 5 deletions src/ZMQParserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,11 @@ bool ZMQParserInterface::parsePENNtopField(ParsedFlow *const flow,
break;

case NPROBE_IPV4_ADDRESS:
/* Do not override EXPORTER_IPV4_ADDRESS */
if (value->string && flow->device_ip == 0 &&
(flow->device_ip = ntohl(inet_addr(value->string))))
return false;
if (value->string) {
flow->probe_ip = ntohl(inet_addr(value->string));
if(flow->device_ip == 0 && (flow->device_ip = ntohl(inet_addr(value->string))))
return false;
}
break;

case SRC_FRAGMENTS:
Expand Down Expand Up @@ -1528,7 +1529,7 @@ bool ZMQParserInterface::matchPENNtopField(ParsedFlow *const flow,
return false;

case NPROBE_IPV4_ADDRESS:
return (flow->device_ip == ntohl(inet_addr(value->string)));
return (flow->probe_ip == ntohl(inet_addr(value->string)));

case SMTP_MAIL_FROM:
if (value->string && flow->getSMTPMailFrom())
Expand Down

0 comments on commit 9ce11dd

Please sign in to comment.