Skip to content

Commit

Permalink
Introduced gateway into ipaddress
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoBiscosi committed Oct 4, 2024
1 parent e31842e commit e4632b3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ class Host : public GenericHashEntry,
void checkNameReset();
void checkDataReset();
void checkBroadcastDomain();
void checkGatewayInfo();
bool hasAnomalies() const;
void housekeep(time_t t); /* Virtual method, called in the datapath from
GenericHash::purgeIdle */
Expand Down
5 changes: 3 additions & 2 deletions include/IpAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct ipAddress {
multicastIP : 1, broadcastIP : 1, blacklistedIP : 1, localIP : 1;

u_int8_t dnsServer : 1, dhcpServer : 1, smtpServer : 1, ntpServer : 1,
imapServer : 1, popServer : 1, unused : 2;
imapServer : 1, popServer : 1, gateway: 1, unused : 1;
union {
struct ndpi_in6_addr ipv6;
u_int32_t ipv4; /* Host byte code */
Expand Down Expand Up @@ -132,7 +132,8 @@ class IpAddress {
inline void setPopServer() { addr.popServer = true; }
inline bool isNtpServer() const { return (addr.ntpServer); }
inline void setNtpServer() { addr.ntpServer = true; }
inline bool isGateway() { return false; }
inline bool isGateway() const { return (addr.gateway); }
inline void setGateway(bool is_gateway) { addr.gateway = is_gateway; }

char* print(char* str, u_int str_len, u_int8_t bitmask = 0xFF) const;
char* printMask(char* str, u_int str_len, bool isLocalIP);
Expand Down
2 changes: 2 additions & 0 deletions src/FlowAlertsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ FlowAlertsLoader::FlowAlertsLoader() {
LongLivedFlowAlert::getDefaultScore());
registerAlert(LowGoodputFlowAlert::getClassType(),
LowGoodputFlowAlert::getDefaultScore());
#if defined(HAVE_NEDGE)
registerAlert(NedgeBlockedFlowAlert::getClassType(),
NedgeBlockedFlowAlert::getDefaultScore());
#endif
registerAlert(NotPurgedAlert::getClassType(),
NotPurgedAlert::getDefaultScore());
registerAlert(RareDestinationAlert::getClassType(),
Expand Down
8 changes: 8 additions & 0 deletions src/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ void Host::periodic_stats_update(const struct timeval *tv) {
checkDataReset();
checkStatsReset();
checkBroadcastDomain();
checkGatewayInfo();

/* Update the pointer to the operating system according to what is specified
* in cur_os_type, if necessary */
Expand Down Expand Up @@ -2001,6 +2002,13 @@ void Host::checkBroadcastDomain() {

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

void Host::checkGatewayInfo() {
bool is_gateway = getDeviceType() == device_networking;
ip.setGateway(is_gateway);
}

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

void Host::freeHostNames() {
if (ssdpLocation) {
free(ssdpLocation);
Expand Down

0 comments on commit e4632b3

Please sign in to comment.