Skip to content

Commit

Permalink
Merge pull request #8 from ntop/dev
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
SalvatoreCostantino authored Mar 29, 2019
2 parents a69ebbf + f5c269d commit 52a3014
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
12 changes: 8 additions & 4 deletions include/Flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Flow : public GenericHashEntry {
CounterTrend throughputTrend, goodputTrend, thptRatioTrend;
#endif
ndpi_protocol ndpiDetectedProtocol;
static const ndpi_protocol ndpiUnknownProtocol;
custom_app_t custom_app;
void *cli_id, *srv_id;
char *json_info, *host_server_name, *bt_hash;
Expand Down Expand Up @@ -330,25 +331,28 @@ class Flow : public GenericHashEntry {
inline time_t get_partial_last_seen() { return(get_last_seen()); };
inline u_int32_t get_duration() { return((u_int32_t)(get_last_seen()-get_first_seen())); };
inline char* get_protocol_name() { return(Utils::l4proto2name(protocol)); };
inline ndpi_protocol get_detected_protocol() { return(ndpiDetectedProtocol); };
inline ndpi_protocol get_detected_protocol() { return(isDetectionCompleted() ? ndpiDetectedProtocol : ndpiUnknownProtocol); };

inline Host* get_cli_host() { return(cli_host); };
inline Host* get_srv_host() { return(srv_host); };
inline char* get_json_info() { return(json_info); };
inline ndpi_protocol_breed_t get_protocol_breed() {
return(ndpi_get_proto_breed(iface->get_ndpi_struct(), ndpiDetectedProtocol.app_protocol));
return(ndpi_get_proto_breed(iface->get_ndpi_struct(), isDetectionCompleted() ? ndpiDetectedProtocol.app_protocol : NDPI_PROTOCOL_UNKNOWN));
};
inline const char * const get_protocol_breed_name() {
return(ndpi_get_proto_breed_name(iface->get_ndpi_struct(), get_protocol_breed()));
};
inline ndpi_protocol_category_t get_protocol_category() {
return(ndpi_get_proto_category(iface->get_ndpi_struct(), ndpiDetectedProtocol));
return(ndpi_get_proto_category(iface->get_ndpi_struct(),
isDetectionCompleted() ? ndpiDetectedProtocol : ndpiUnknownProtocol));
};
inline const char * const get_protocol_category_name() {
return(ndpi_category_get_name(iface->get_ndpi_struct(), get_protocol_category()));
};
char* get_detected_protocol_name(char *buf, u_int buf_len) {
return(ndpi_protocol2name(iface->get_ndpi_struct(), ndpiDetectedProtocol, buf, buf_len));
return(ndpi_protocol2name(iface->get_ndpi_struct(),
isDetectionCompleted() ? ndpiDetectedProtocol : ndpiUnknownProtocol,
buf, buf_len));
}

u_int32_t get_packetsLost();
Expand Down
22 changes: 18 additions & 4 deletions src/Flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@

#include "ntop_includes.h"

/* static so default is zero-initialization, let's just define it */

const ndpi_protocol Flow::ndpiUnknownProtocol = { NDPI_PROTOCOL_UNKNOWN,
NDPI_PROTOCOL_UNKNOWN,
NDPI_PROTOCOL_CATEGORY_UNSPECIFIED };

//#define DEBUG_DISCOVERY
//#define DEBUG_UA

Expand All @@ -40,8 +46,8 @@ Flow::Flow(NetworkInterface *_iface,
srv2cli_last_goodput_bytes = cli2srv_last_goodput_bytes = 0, good_ssl_hs = true,
flow_alerted = flow_dropped_counts_increased = false, vrfId = 0;

l7_protocol_guessed = detection_completed = false,
memset(&ndpiDetectedProtocol, 0, sizeof(ndpiDetectedProtocol)),
l7_protocol_guessed = detection_completed = false;
ndpiDetectedProtocol = ndpiUnknownProtocol;
doNotExpireBefore = iface->getTimeLastPktRcvd() + DONT_NOT_EXPIRE_BEFORE_SEC;

#ifdef HAVE_NEDGE
Expand Down Expand Up @@ -1379,7 +1385,11 @@ void Flow::update_pools_stats(const struct timeval *tv,
hp = iface->getHostPools();
if(hp) {
/* Client host */
if(cli_host && cli_host->getMac() && cli_host->getMac()->locate() == located_on_lan_interface) {
if(cli_host
#ifdef HAVE_NEDGE
&& cli_host->getMac() && (cli_host->getMac()->locate() == located_on_lan_interface)
#endif
) {
cli_host_pool_id = cli_host->get_host_pool();

/* Overall host pool stats */
Expand All @@ -1402,7 +1412,11 @@ void Flow::update_pools_stats(const struct timeval *tv,
}

/* Server host */
if(srv_host && srv_host->getMac() && srv_host->getMac()->locate() == located_on_lan_interface) {
if(srv_host
#ifdef HAVE_NEDGE
&& srv_host->getMac() && (srv_host->getMac()->locate() == located_on_lan_interface)
#endif
) {
srv_host_pool_id = srv_host->get_host_pool();

/* Update server pool stats only if the pool is not equal to the client pool */
Expand Down

0 comments on commit 52a3014

Please sign in to comment.