~ubuntu-branches/ubuntu/wily/ntop/wily-proposed

« back to all changes in this revision

Viewing changes to ntop/globals-core.c

  • Committer: Bazaar Package Importer
  • Author(s): Dennis Schoen
  • Date: 2002-04-12 11:38:47 UTC
  • Revision ID: james.westby@ubuntu.com-20020412113847-4k4yydw0pzybc6g8
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 1998-2001 Luca Deri <deri@ntop.org>
 
3
 *                          Portions by Stefano Suin <stefano@ntop.org>
 
4
 *
 
5
 *                          http://www.ntop.org/
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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.
 
20
 */
 
21
 
 
22
#include "ntop.h"
 
23
 
 
24
/* general */
 
25
#ifdef WIN32
 
26
char *version, *osName, *author, *buildDate;
 
27
#endif
 
28
char *program_name;
 
29
char domainName[MAXHOSTNAMELEN], *shortDomainName;
 
30
HostTraffic *broadcastEntry, *otherHostEntry;
 
31
int ntop_argc;
 
32
char **ntop_argv;
 
33
 
 
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;
 
43
 
 
44
 
 
45
/* Search paths */
 
46
char *dataFileDirs[]   = { ".", DATAFILE_DIR, NULL };
 
47
char *pluginDirs[]     = { "./plugins", PLUGIN_DIR, NULL };
 
48
char *configFileDirs[] = { ".", CONFIGFILE_DIR, "/etc", NULL };
 
49
 
 
50
/* Debug */
 
51
size_t allocatedMemory;
 
52
 
 
53
/* SSL */
 
54
#ifdef HAVE_OPENSSL
 
55
int sslInitialized, sslPort;
 
56
#endif
 
57
 
 
58
/* Logging */
 
59
time_t nextLogTime;
 
60
 
 
61
/* Flags */
 
62
int isLsofPresent, isNmapPresent, filterExpressionInExtraFrame;
 
63
short capturePackets;
 
64
short endNtop;
 
65
 
 
66
 
 
67
/* Multithreading */
 
68
#ifdef MULTITHREADED
 
69
unsigned short numThreads;
 
70
PthreadMutex packetQueueMutex, hostsHashMutex, graphMutex;
 
71
PthreadMutex lsofMutex, addressResolutionMutex, hashResizeMutex;
 
72
 
 
73
pthread_t dequeueThreadId, handleWebConnectionsThreadId;
 
74
pthread_t thptUpdateThreadId, scanIdleThreadId, scanIdleSessionsThreadId;
 
75
pthread_t hostTrafficStatsThreadId, dbUpdateThreadId, lsofThreadId;
 
76
pthread_t purgeAddressThreadId;
 
77
#ifdef HAVE_GDBM_H
 
78
PthreadMutex gdbmMutex;
 
79
#endif /* HAVE_GDBM_H */
 
80
#ifdef USE_SEMAPHORES
 
81
sem_t queueSem;
 
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 */
 
90
#endif 
 
91
#ifdef ASYNC_ADDRESS_RESOLUTION
 
92
pthread_t dequeueAddressThreadId;
 
93
TrafficCounter droppedAddresses;
 
94
PthreadMutex addressQueueMutex;
 
95
#endif
 
96
#endif
 
97
 
 
98
/* Database */
 
99
#ifdef HAVE_GDBM_H
 
100
GDBM_FILE gdbm_file, pwFile, eventFile, hostsInfoFile;
 
101
#endif
 
102
 
 
103
/* lsof support */
 
104
u_short updateLsof;
 
105
ProcessInfo **processes;
 
106
u_short numProcesses;
 
107
ProcessInfoList *localPorts[TOP_IP_PORT];
 
108
 
 
109
 
 
110
/* Filter Chains */
 
111
u_short handleRules;
 
112
FlowFilterList *flowsList;
 
113
FilterRuleChain *tcpChain, *udpChain, *icmpChain;
 
114
u_short ruleSerialIdentifier;
 
115
FilterRule* filterRulesList[MAX_NUM_RULES];
 
116
 
 
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];
 
122
#endif
 
123
u_long numResolvedWithDNSAddresses, numKeptNumericAddresses, numResolvedOnCacheAddresses;
 
124
 
 
125
/* Misc */
 
126
char *separator = "&nbsp;";
 
127
int32_t thisZone; /* seconds offset from gmt to local time */
 
128
u_long numPurgedHosts, numTerminatedSessions;
 
129
 
 
130
/* Time */
 
131
time_t actTime, initialSniffTime, lastRefreshTime;
 
132
time_t nextSessionTimeoutScan;
 
133
struct timeval lastPktTime;
 
134
 
 
135
/* NICs */
 
136
int deviceId; /* Set by processPacket() */
 
137
int numDevices, actualDeviceId;
 
138
NtopInterface *device;
 
139
 
 
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;
 
147
 
 
148
/* Packet Capture */
 
149
#if defined(MULTITHREADED)
 
150
PacketInformation packetQueue[PACKET_QUEUE_LENGTH+1];
 
151
u_int packetQueueLen, maxPacketQueueLen, packetQueueHead, packetQueueTail;
 
152
#endif
 
153
 
 
154
TransactionTime transTimeHash[NUM_TRANSACTION_ENTRIES];
 
155
 
 
156
u_int broadcastEntryIdx, otherHostEntryIdx;
 
157
u_char dummyEthAddress[ETHERNET_ADDRESS_LEN];
 
158
 
 
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 */
 
177
};
 
178
 
 
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 */
 
192
  0,            /* raw IP */
 
193
  UNKNOWN_MTU,  /* BSD/OS Serial Line IP */
 
194
  UNKNOWN_MTU   /* BSD/OS Point-to-point Protocol */
 
195
};
 
196
 
 
197
#ifdef ENABLE_NAPSTER
 
198
NapsterServer napsterSvr[MAX_NUM_NAPSTER_SERVER];
 
199
#endif
 
200
 
 
201
char *currentFilterExpression;