2
* Copyright (C) 1998-2001 Luca Deri <deri@ntop.org>
3
* Portions by Stefano Suin <stefano@ntop.org>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
char *version, *osName, *author, *buildDate;
29
char domainName[MAXHOSTNAMELEN], *shortDomainName;
30
HostTraffic *broadcastEntry, *otherHostEntry;
34
/* command line options */
35
u_short traceLevel, debugMode, useSyslog, accuracyLevel;
36
u_char stickyHosts, enableSuspiciousPacketDump;
37
char dbPath[200], accessLogPath[200], *rFileName, *pcapLog;
38
char mapperURL[256]; /* URL of the mapper CGI */
39
u_int maxHashSize, topHashSize;
40
u_int enableNetFlowSupport;
41
short usePersistentStorage;
42
int numericFlag, logTimeout, daemonMode, mergeInterfaces;
46
char *dataFileDirs[] = { ".", DATAFILE_DIR, NULL };
47
char *pluginDirs[] = { "./plugins", PLUGIN_DIR, NULL };
48
char *configFileDirs[] = { ".", CONFIGFILE_DIR, "/etc", NULL };
51
size_t allocatedMemory;
55
int sslInitialized, sslPort;
62
int isLsofPresent, isNmapPresent, filterExpressionInExtraFrame;
69
unsigned short numThreads;
70
PthreadMutex packetQueueMutex, hostsHashMutex, graphMutex;
71
PthreadMutex lsofMutex, addressResolutionMutex, hashResizeMutex;
73
pthread_t dequeueThreadId, handleWebConnectionsThreadId;
74
pthread_t thptUpdateThreadId, scanIdleThreadId, scanIdleSessionsThreadId;
75
pthread_t hostTrafficStatsThreadId, dbUpdateThreadId, lsofThreadId;
76
pthread_t purgeAddressThreadId;
78
PthreadMutex gdbmMutex;
79
#endif /* HAVE_GDBM_H */
82
#ifdef ASYNC_ADDRESS_RESOLUTION
83
sem_t queueAddressSem;
84
#endif /* ASYNC_ADDRESS_RESOLUTION */
85
#else /* USE_SEMAPHORES */
86
ConditionalVariable queueCondvar;
87
#ifdef ASYNC_ADDRESS_RESOLUTION
88
ConditionalVariable queueAddressCondvar;
89
#endif /* USE_SEMAPHORES */
91
#ifdef ASYNC_ADDRESS_RESOLUTION
92
pthread_t dequeueAddressThreadId;
93
TrafficCounter droppedAddresses;
94
PthreadMutex addressQueueMutex;
100
GDBM_FILE gdbm_file, pwFile, eventFile, hostsInfoFile;
105
ProcessInfo **processes;
106
u_short numProcesses;
107
ProcessInfoList *localPorts[TOP_IP_PORT];
112
FlowFilterList *flowsList;
113
FilterRuleChain *tcpChain, *udpChain, *icmpChain;
114
u_short ruleSerialIdentifier;
115
FilterRule* filterRulesList[MAX_NUM_RULES];
117
/* Address Resolution */
118
#if defined(ASYNC_ADDRESS_RESOLUTION)
119
u_int addressQueueLen, maxAddressQueueLen;
120
u_int addressQueueHead, addressQueueTail;
121
struct in_addr addressQueue[ADDRESS_QUEUE_LENGTH+1];
123
u_long numResolvedWithDNSAddresses, numKeptNumericAddresses, numResolvedOnCacheAddresses;
126
char *separator = " ";
127
int32_t thisZone; /* seconds offset from gmt to local time */
128
u_long numPurgedHosts, numTerminatedSessions;
131
time_t actTime, initialSniffTime, lastRefreshTime;
132
time_t nextSessionTimeoutScan;
133
struct timeval lastPktTime;
136
int deviceId; /* Set by processPacket() */
137
int numDevices, actualDeviceId;
138
NtopInterface *device;
140
/* Monitored Protocols */
141
char **protoIPTrafficInfos;
142
u_short numIpProtosToMonitor, numIpPortsToHandle;
143
PortMapper *ipPortMapper;
144
int numActServices, numIpPortMapperSlots;
145
unsigned long numHandledHTTPrequests;
146
ServiceEntry **udpSvc, **tcpSvc;
149
#if defined(MULTITHREADED)
150
PacketInformation packetQueue[PACKET_QUEUE_LENGTH+1];
151
u_int packetQueueLen, maxPacketQueueLen, packetQueueHead, packetQueueTail;
154
TransactionTime transTimeHash[NUM_TRANSACTION_ENTRIES];
156
u_int broadcastEntryIdx, otherHostEntryIdx;
157
u_char dummyEthAddress[ETHERNET_ADDRESS_LEN];
159
u_short mtuSize[] = {
160
8232, /* no link-layer encapsulation */
161
/* 1500 + 14 bytes header
162
Courtesy of Andreas Pfaller <a.pfaller@pop.gun.de> */
163
1500+sizeof(struct ether_header), /* Ethernet (10Mb) */
164
UNKNOWN_MTU, /* Experimental Ethernet (3Mb) */
165
UNKNOWN_MTU, /* Amateur Radio AX.25 */
166
17914, /* Proteon ProNET Token Ring */
167
UNKNOWN_MTU, /* Chaos */
168
4096+sizeof(struct tokenRing_header), /* IEEE 802 Networks */
169
UNKNOWN_MTU, /* ARCNET */
170
UNKNOWN_MTU, /* Serial Line IP */
171
UNKNOWN_MTU, /* Point-to-point Protocol */
172
4470, /* FDDI - Courtesy of Richard Parvass <Richard.Parvass@ReckittBenckiser.com> */
173
9180, /* LLC/SNAP encapsulated atm */
174
UNKNOWN_MTU, /* raw IP */
175
UNKNOWN_MTU, /* BSD/OS Serial Line IP */
176
UNKNOWN_MTU /* BSD/OS Point-to-point Protocol */
179
u_short headerSize[] = {
180
NULL_HDRLEN, /* no link-layer encapsulation */
181
sizeof(struct ether_header), /* Ethernet (10Mb) */
182
UNKNOWN_MTU, /* Experimental Ethernet (3Mb) */
183
UNKNOWN_MTU, /* Amateur Rdio AX.25 */
184
sizeof(struct tokenRing_header), /* Proteon ProNET Token Ring */
185
UNKNOWN_MTU, /* Chaos */
186
1492, /* IEEE 802 Networks */
187
UNKNOWN_MTU, /* ARCNET */
188
UNKNOWN_MTU, /* Serial Line IP */
189
PPP_HDRLEN, /* Point-to-point Protocol */
190
sizeof(struct fddi_header), /* FDDI */
191
0, /* LLC/SNAP encapsulated atm */
193
UNKNOWN_MTU, /* BSD/OS Serial Line IP */
194
UNKNOWN_MTU /* BSD/OS Point-to-point Protocol */
197
#ifdef ENABLE_NAPSTER
198
NapsterServer napsterSvr[MAX_NUM_NAPSTER_SERVER];
201
char *currentFilterExpression;