Skip to content

Commit

Permalink
Merge branch 'ntop:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowMan02 authored Nov 5, 2024
2 parents 1298f5b + db7f17b commit 3cce0c0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/LocalHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ void LocalHost::addInactiveData() {
#endif

ndpi_init_serializer(&host_json, ndpi_serialization_format_json);

ndpi_serialize_string_string(&host_json, "type", "host");
ndpi_serialize_string_string(&host_json, "ip", ip.print(buf, sizeof(buf)));

ndpi_serialize_string_uint64(&host_json, "first_seen", get_first_seen());
Expand Down Expand Up @@ -731,7 +733,7 @@ void LocalHost::lua_get_fingerprints(lua_State *vm) {
#ifdef NTOPNG_PRO
void LocalHost::dumpAssetInfo() {
char buf[64], mac_buf[32], *json_str = NULL,
*ip = printMask(buf, sizeof(buf)), *mac_ptr;
*ip = printMask(buf, sizeof(buf)), *mac_ptr;
ndpi_serializer device_json;
u_int32_t json_str_len = 0;

Expand Down Expand Up @@ -768,6 +770,7 @@ void LocalHost::dumpAssetInfo() {

if ((json_str != NULL) && (json_str_len > 0)) {
char key[64];

snprintf(key, sizeof(key), ASSET_LIST_INSERTION_KEY, iface->get_id());
ntop->getRedis()->rpush(key, json_str, 1024);
}
Expand Down
31 changes: 26 additions & 5 deletions src/Mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,32 @@ Mac::~Mac() {
if ((!broadcast_mac) && (!special_mac)) dumpToRedis();

if (!special_mac && ntop->getRedis() && ntop->getPrefs()->is_pro_edition()) {
char mac_addr[64], mac_disconnection_key[128];
char mac_addr[64], mac_disconnection_key[128], *mac, *json_str;
ndpi_serializer device_json;
u_int32_t json_str_len = 0;
char redis_key[64];

mac = print(mac_addr, sizeof(mac_addr));

ndpi_init_serializer(&device_json, ndpi_serialization_format_json);
ndpi_serialize_string_string(&device_json, "type", "mac");
ndpi_serialize_string_string(&device_json, "mac", mac);
ndpi_serialize_string_uint32(&device_json, "first_seen", first_seen);
ndpi_serialize_string_uint32(&device_json, "last_seen", last_seen);

json_str = ndpi_serializer_get_buffer(&device_json, &json_str_len);
if ((json_str != NULL) && (json_str_len > 0)) {
snprintf(redis_key, sizeof(redis_key), OFFLINE_LOCAL_HOSTS_MACS_QUEUE_NAME, iface->get_id());
ntop->getRedis()->lpush(redis_key, json_str, CONST_MAX_INACTIVE_HOSTS_MAC_QUEUE_LEN);
}

ndpi_term_serializer(&device_json);

/* Will be removed */
snprintf(mac_disconnection_key, sizeof(mac_disconnection_key),
(char *)MACS_DISCONNECTION, iface->get_id());
ntop->getRedis()->lpush(mac_disconnection_key,
print(mac_addr, sizeof(mac_addr)), 0 /* No Trim */);
(char *)MACS_DISCONNECTION, iface->get_id());

ntop->getRedis()->lpush(mac_disconnection_key, print(mac_addr, sizeof(mac_addr)), 0 /* No Trim */);
}

if (model) free(model);
Expand Down Expand Up @@ -544,7 +565,7 @@ bool Mac::is_hash_entry_state_idle_transition_ready() {
? "true"
: "false",
time(NULL), last_seen, ntop->getPrefs()->macAddressCacheDuration());
*/
*/
return ((getUses() == 0) && is_active_entry_now_idle(
ntop->getPrefs()->macAddressCacheDuration()));
}

0 comments on commit 3cce0c0

Please sign in to comment.