diff --git a/include/Ntop.h b/include/Ntop.h index 2d9d3d5789..08018124ea 100644 --- a/include/Ntop.h +++ b/include/Ntop.h @@ -67,7 +67,9 @@ class Ntop { int udp_socket; NtopPro *pro; #ifdef NTOPNG_PRO +#ifndef WIN32 NagiosManager *nagios_manager; +#endif FlowChecker *flow_checker; #endif AddressTree *hostBlacklist, *hostBlacklistShadow; @@ -370,7 +372,9 @@ class Ntop { inline ExportInterface* get_export_interface() { return(export_interface); }; #ifdef NTOPNG_PRO +#ifndef WIN32 inline NagiosManager* getNagios() { return(nagios_manager); }; +#endif #endif void getUsers(lua_State* vm); diff --git a/include/ntop_defines.h b/include/ntop_defines.h index 987f5e428a..8ae8460c45 100644 --- a/include/ntop_defines.h +++ b/include/ntop_defines.h @@ -666,7 +666,9 @@ /* Macros */ #define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) +#ifndef _STATIC_ASSERT #define _STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1] +#endif #define _COMPILE_TIME_ASSERT3(X,L) _STATIC_ASSERT(X,static_assertion_at_line_##L) #define _COMPILE_TIME_ASSERT2(X,L) _COMPILE_TIME_ASSERT3(X,L) #define COMPILE_TIME_ASSERT(X) _COMPILE_TIME_ASSERT2(X,__LINE__) diff --git a/src/Lua.cpp b/src/Lua.cpp index d370230a35..44ef21eb60 100644 --- a/src/Lua.cpp +++ b/src/Lua.cpp @@ -5338,6 +5338,7 @@ static int ntop_interface_query_flow_alerts_raw(lua_State* vm) { /* ****************************************** */ #if NTOPNG_PRO +#ifndef WIN32 static int ntop_nagios_reload_config(lua_State* vm) { NagiosManager *nagios = ntop->getNagios(); @@ -5398,7 +5399,7 @@ static int ntop_nagios_withdraw_alert(lua_State* vm) { lua_pushnil(vm); return(CONST_LUA_OK); } - +#endif #endif /* ****************************************** */ @@ -5904,9 +5905,11 @@ static const luaL_Reg ntop_reg[] = { { "setAlertsTemporaryDisabled", ntop_temporary_disable_alerts }, #ifdef NTOPNG_PRO +#ifndef WIN32 { "sendNagiosAlert", ntop_nagios_send_alert }, { "withdrawNagiosAlert", ntop_nagios_withdraw_alert }, { "reloadNagiosConfig", ntop_nagios_reload_config }, +#endif { "checkProfileSyntax", ntop_check_profile_syntax }, { "reloadProfiles", ntop_reload_traffic_profiles }, #endif diff --git a/src/MacManufacturers.cpp b/src/MacManufacturers.cpp index c86783658f..40faa8cd2f 100644 --- a/src/MacManufacturers.cpp +++ b/src/MacManufacturers.cpp @@ -45,7 +45,7 @@ void MacManufacturers::init() { FILE *fd; char * line = NULL, *manuf = NULL, *cr; size_t len = 0; - ssize_t read; + ssize_t readb; u_int8_t mac[3]; char short_name[9]; mac_manufacturers_t *s; @@ -57,7 +57,7 @@ void MacManufacturers::init() { ntop->getTrace()->traceEvent(TRACE_ERROR, "Unable to read %s", manufacturers_file); if(fd) { - while ((read = getline(&line, &len, fd)) != -1) { + while ((readb = getline(&line, &len, fd)) != -1) { char *tab = strchr(line, '\t'); if((sscanf(line, "%02hhx:%02hhx:%02hhx", &mac[0], &mac[1], &mac[2]) == 3) && diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index fe18ff97d7..8c46b12676 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -5218,11 +5218,11 @@ bool NetworkInterface::processPacket(const struct bpf_timeval *when, if(!f) return(CONST_LUA_ERROR); if(ntop_lua_check(vm, __FUNCTION__, params+1, LUA_TNUMBER)) return(CONST_LUA_ERROR); - activityID = (UserActivityID)lua_tonumber(vm, ++params); + activityID = (UserActivityID)((int)lua_tonumber(vm, ++params)); if(activityID >= UserActivitiesN) return(CONST_LUA_ERROR); if(lua_type(vm, params+1) == LUA_TNUMBER) - filterID = (ActivityFilterID)lua_tonumber(vm, ++params); + filterID = (ActivityFilterID)((int)lua_tonumber(vm, ++params)); else return(CONST_LUA_ERROR); diff --git a/src/Ntop.cpp b/src/Ntop.cpp index 8a89d0be94..7adbffb83a 100644 --- a/src/Ntop.cpp +++ b/src/Ntop.cpp @@ -114,7 +114,9 @@ Ntop::Ntop(char *appName) { #ifdef NTOPNG_PRO pro = new NtopPro(); +#ifndef WIN32 nagios_manager = NULL; +#endif flow_checker = new FlowChecker(); if((pro == NULL) @@ -183,7 +185,11 @@ Ntop::~Ntop() { #ifdef NTOPNG_PRO if(pro) delete pro; +#ifdef WIN32 +#ifndef WIN32 if(nagios_manager) delete nagios_manager; +#endif +#endif if(flow_checker) delete flow_checker; #endif } @@ -246,12 +252,10 @@ void Ntop::registerPrefs(Prefs *_prefs, bool quick_registration) { #ifdef NTOPNG_PRO void Ntop::registerNagios(void) { - #ifndef WIN32 +#ifndef WIN32 if(nagios_manager) { delete nagios_manager; nagios_manager = NULL; } nagios_manager = new NagiosManager(); - #else - nagios_manager = NULL; - #endif +#endif } #endif diff --git a/src/PcapInterface.cpp b/src/PcapInterface.cpp index 804d896b47..12519383e0 100644 --- a/src/PcapInterface.cpp +++ b/src/PcapInterface.cpp @@ -183,7 +183,7 @@ static void* packetPollLoop(void* ptr) { hdr_copy.len = min(hdr->len, sizeof(pkt_copy) - 1); hdr_copy.caplen = min(hdr_copy.len, hdr_copy.caplen); memcpy(pkt_copy, pkt, hdr_copy.len); - iface->dissectPacket(&hdr_copy, (const u_char*)pkt_copy, &p, &srcHost); + iface->dissectPacket(&hdr_copy, (const u_char*)pkt_copy, &p, &srcHost, &dstHost, &flow); #else hdr->caplen = min_val(hdr->caplen, iface->getMTU()); iface->dissectPacket(hdr, pkt, &p, &srcHost, &dstHost, &flow); diff --git a/src/Utils.cpp b/src/Utils.cpp index 0bb7d8f72b..fc53a6bfe7 100755 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -2008,6 +2008,9 @@ u_int32_t Utils::getHostManagementIPv4Address() { /* ****************************************************** */ bool Utils::isInterfaceUp(char *ifname) { +#ifdef WIN32 + return(true); +#else struct ifreq ifr; char *colon; int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); @@ -2028,6 +2031,7 @@ bool Utils::isInterfaceUp(char *ifname) { close(sock); return(!!(ifr.ifr_flags & IFF_UP) ? true : false); +#endif } /* ****************************************************** */ diff --git a/src/main.cpp b/src/main.cpp index e5802cbf26..0a55867c0c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -168,7 +168,7 @@ int main(int argc, char *argv[]) } else { iface = NULL; -#if defined(NTOPNG_PRO) and !defined(WIN32) +#if defined(NTOPNG_PRO) && !defined(WIN32) if(strncmp(ifName, "bridge:", 7) == 0) iface = new PacketBridge(ifName); #endif @@ -313,10 +313,12 @@ int main(int argc, char *argv[]) ntop->getTrace()->traceEvent(TRACE_NORMAL, "Scripts/HTML pages directory: %s", ntop->get_install_dir()); +#ifndef WIN32 signal(SIGHUP, sighup); signal(SIGINT, sigproc); signal(SIGTERM, sigproc); signal(SIGINT, sigproc); +#endif #if defined(WIN32) && defined(DEMO_WIN32) ntop->getTrace()->traceEvent(TRACE_NORMAL, "-----------------------------------------------------------");