File: ntop.h

package info (click to toggle)
ntop 3:3.3-11
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,772 kB
  • ctags: 7,534
  • sloc: ansic: 71,427; sh: 16,772; awk: 1,504; perl: 792; makefile: 782; php: 123; python: 23; sql: 13; sed: 11
file content (565 lines) | stat: -rw-r--r-- 12,370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
/*
 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 *                          http://www.ntop.org
 *
 * Copyright (C) 1998-2007 Luca Deri <deri@ntop.org>
 *
 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/*

ntop's defines - what's what and what's where

ntop.h
  This is the 'control' for the various globals-*.h files.  It's a single 
  include to drag in the necessary headers, defines ntop data structures
  (e.g. the structs), etc. 

  A few globally #defined items which control expansion of the standard
  and system headers MUST be here.

  Any tests - #if () #error #endif type stuff goes here at the bottom.

  ntop.h includes 
     config.h -- generated by ./configure

     various standard and system headers

     globals-defines.h
          All of the #defines used by ntop should be here, except for those
          explicitly discussed below.

     globals-structtypes.h
          Every struct and typedef, including #define used instead of typedef.

   and

     globals-core.h
          This defines the extern functions, exported from one ntop source file to
          the others.
          "function" which are actually #define macros are here.

  All programs must include ntop.h.  Any program which requires the "reporting"
  functions also have to include globals-report.h.

*/

#ifndef NTOP_H
#define NTOP_H

#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif

/* See http://www.redhat.com/magazine/009jul05/features/execshield/ */
#ifndef _FORTIFY_SOURCE
#define _FORTIFY_SOURCE 2
#endif

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*  Standard header expansion control items                                */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#if defined(__linux__)
#ifndef LINUX
#define LINUX
#endif
#endif

#ifdef LINUX
/*
 * This allows to hide the (minimal) differences between linux and BSD
 */

#include <features.h>

#define __FAVOR_BSD
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#endif /* linux */

#ifdef __GNUC__
#define _UNUSED_ __attribute__((unused))
#else
#define _UNUSED_
#define __attribute__(a)
#endif

/*
   On some systems these defines make reentrant library
   routines available.

   Courtesy of Andreas Pfaller <apfaller@yahoo.com.au>.
*/
#if !defined(_REENTRANT)
#define _REENTRANT
#endif
#define _THREAD_SAFE


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*                                   includes                              */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* **************************************************************************************
 *
 *  Standard c headers (operating system/gcc supplied)
 *
 * **************************************************************************************/

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>

#ifndef WIN32
#include <unistd.h>
#endif

#include <string.h>

#if defined(__linux__)
#define _XOPEN_SOURCE /* glibc2 needs this */
#endif

#include <time.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>

#ifndef WIN32
#include <strings.h>
#endif

#include <limits.h>
#include <float.h>
#include <math.h>
#include <sys/types.h>

#ifndef WIN32
#include <sys/time.h>
#endif

#ifndef WIN32
#include <sys/wait.h>
#endif

#include <sys/stat.h>

#ifndef WIN32
#include <sys/ioctl.h>
#endif

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>      /* OpenBSD wants it */
#endif

#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#endif

#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif

#ifdef HAVE_SYS_LDR_H
#include <sys/ldr.h>
#endif

#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif

#ifdef HAVE_DL_H
#include <dl.h>
#endif

#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif

#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif

/* 
   Additions below courtesy of 
   Abdelkader Lahmadi <Abdelkader.Lahmadi@loria.fr> 
*/
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif

/*
   Courtesy of
   Brent L. Bates <blbates@vigyan.com>
*/
/*WARNING: There is nothing in ./configure to test for or enable this 
 * OTOP, there are no reported bugs either.
 *   -----Burton (4/2003)
 */
#ifdef HAVE_STANDARDS_H
#include <standards.h>
#endif

#ifdef HAVE_CRYPT_H
/* Fix courtesy of Charles M. Gagnon <charlesg@unixrealm.com> */
#ifdef HAVE_OPENSSL
#define des_encrypt MOVE_AWAY_des_encrypt
#include <crypt.h>
#undef des_encrypt
#else
#include <crypt.h>
#endif
#endif

/*
 * thread management
 */
#ifdef MAKE_WITH_SCHED_YIELD

 #ifdef HAVE_SCHED_H
 # ifdef LINUX
 #  undef HAVE_SCHED_H      /* Linux doesn't seem to really like it */
 # else
 #  include <sched.h>
 # endif
 #endif

 #ifdef HAVE_SYS_SCHED_H
  #include <sys/sched.h>
 #endif

#endif /* MAKE_WITH_SCHED_YIELD */

#ifdef HAVE_PTHREAD_H
 #include <pthread.h>
 #ifndef _THREAD_SAFE
  #define _THREAD_SAFE
 #endif
#endif

#ifdef HAVE_IF_H
 #include "if.h"              /* OSF1 has it */
#endif

/* **************************************************************************************
 *
 *  universal headers for network programming code
 *
 * **************************************************************************************/

#ifndef WIN32
#include <sys/socket.h>
#endif

#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif

#ifndef WIN32
#include <netdb.h>
#include <netinet/in.h>

#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif

#include <net/if.h>

#ifdef HAVE_SCTP
#include <netinet/sctp.h>
#endif

/* 
   Additions below courtesy of 
   Abdelkader Lahmadi <Abdelkader.Lahmadi@loria.fr> 
   And thanks to Julien TOUCHE [julien.touche@lycos.com] for pointing out the
   sys/socket.h <-> net/route.h dependency under OpenBSD.
*/
#ifdef HAVE_NET_IF_DL_H
#include <net/if_dl.h>
#endif
#ifdef HAVE_NET_ROUTE_H
#include <net/route.h>
#endif

#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>

#ifndef HAVE_IPV6_H
#include <netinet/ip6.h>
#endif

#ifndef HAVE_ICMPV6_H
#include <netinet/icmp6.h>
#endif
#endif

#ifdef HAVE_NETINET_IF_ETHER_H
#include <netinet/if_ether.h>
#endif

#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif

#ifdef HAVE_NET_ETHERNET_H
#include <net/ethernet.h>
#endif

#ifdef HAVE_ETHERTYPE_H
#include <ethertype.h>
#endif

/*
 * #ifdefs below courtesy of
 * "David Masterson" <David.Masterson@kla-tencor.com>
 * Scott Renfro <scott@renfro.org> (MinGW)
 * Combined and revised 12-2003 for libpcap 0.8.x - BMSIII
 */
#if defined(WIN32) && defined(__GNUC__)
 #include "bpf.h"
 #include "pcap.h"
#endif

/* **************************************************************************************
 *
 *  OS Specific stuff
 *
 * **************************************************************************************/

#ifndef WIN32
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#endif

/*
 * MAC OSX for plugins
 */
#ifndef RTLD_NOW 
 #ifdef RTLD_LAZY
  #define RTLD_NOW RTLD_LAZY 
 #else
  #define RTLD_NOW 1 /* MacOS X Patch */
 #endif
#endif

/* **************************************************************************************
 *
 *  Feature specific stuff
 *
 * **************************************************************************************/

#if defined(HAVE_MYSQL_H) || defined(WIN32)
#if defined(WIN32)
#define my_socket_defined
#define my_socket int
#endif
#include <mysql.h> /* Headers for MySQL usage */
#include <errmsg.h>
#endif

#ifndef WIN32
#if defined(HAVE_SYS_SCHED_H) && !defined(FREEBSD)
#include <sys/sched.h>
#endif

#if defined(HAVE_SCHED_H)
#include <sched.h>
#endif

/*
 * Switched pthread with semaphore.
 * Courtesy of
 * Wayne Roberts <wroberts1@cx983858-b.orng1.occa.home.com>
 */
# include <pthread.h>

#endif /* WIN32 */

/*
 * Packet Capture Library by Lawrence Berkeley National Laboratory
 * Network Research Group
 */
#include "pcap.h"

#ifdef HAVE_OPENSSL
#include <openssl/rsa.h>
#include <openssl/crypto.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif /* HAVE_OPENSSL */

/* Compressed HTTP responses via zlib */
#include <zlib.h>

/*
 * gdbm
 */
#ifdef WIN32
#ifndef __GNUC__
#include <gdbmerrno.h>
#endif

#endif /* WIN32 */

#include <gdbm.h>

#ifdef HAVE_TCPD_H 
#include <tcpd.h>
#endif

/*
 *  Syslog stuff.  Any routine which expects to reference facilitynames must
 *                 define SYSLOG_NAMES before including ntop.h
 */
#ifdef HAVE_SYS_SYSLOG_H
#include <sys/syslog.h>
#else
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#endif

#ifdef HAVE_SHADOW_H
#include <shadow.h>
#endif

#ifdef HAVE_LIBPCRE
#include <pcre.h>
#endif

#ifndef EMBEDDED
#include "rrd.h"
#endif

#ifdef HAVE_GETOPT_H
#include "getopt.h"
#endif

/* **************************************************************************************
 *
 *  Used for debug
 *
 * **************************************************************************************/

#ifdef MAKE_WITH_SAFER_ROUTINES
#elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 1) 
#elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 2) 
#elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 3) 
 #include "leaks.h"
#elif defined(MEMORY_DEBUG) && (MEMORY_DEBUG == 4) 
 #include <mcheck.h>
#elif defined(MEMORY_DEBUG) 
#else
#endif /* MAKE_WITH_SAFER_ROUTINES / MEMORY_DEBUG */

/* **************************************************************************************
 *
 *  The ntop globals-xxxx includes
 *
 * **************************************************************************************/
#include "globals-defines.h"
#include "globals-structtypes.h"

/* The WIN32 specific stuff */
#ifdef WIN32
#include "ntop_win32.h"
#endif

/*
 * i18n
 */
#ifdef MAKE_WITH_I18N
#include <locale.h>
#include <langinfo.h>
#endif

/* Now the external functions, using the above... */
#include "globals-core.h"

/* **************************************************************************************
 *
 *  #define value tests 
 *
 *                              put 'em here so people aren't tempted to override them...
 *
 * **************************************************************************************/

#if DEFAULT_SNAPLEN > MAX_PACKET_LEN 
#error DEFAULT_SNAPLEN > MAX_PACKET_LEN
#endif

/* XML dump plugin...
 * Check if we have the required headers... 
 * otherwise all the code becomes nops
 */
#undef MAKE_WITH_XMLDUMP
#if defined(HAVE_GLIBCONFIG_H) &&             \
    defined(HAVE_GLIB_H) &&                   \
    defined(HAVE_GDOME_H) &&                  \
    defined(CONST_XMLDUMP_PLUGIN_NAME)
 #define MAKE_WITH_XMLDUMP
#endif

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

/*

    Declaration of POSIX directory browsing functions and types for Win32.

    Kevlin Henney (mailto:kevlin@acm.org), March 1997.

    Copyright Kevlin Henney, 1997. All rights reserved.

    Permission to use, copy, modify, and distribute this software and its
    documentation for any purpose is hereby granted without fee, provided
    that this copyright and permissions notice appear in all copies and
    derivatives, and that no charge may be made for the software and its
    documentation except to cover cost of distribution.
    
*/

#if defined(WIN32) && defined(__GNUC__)
#ifndef DIRENT_INCLUDED
#define DIRENT_INCLUDED

#include <io.h>

DIR           *opendir(const char *);
int           closedir(DIR *);
struct dirent *readdir(DIR *);
void          rewinddir(DIR *);

#endif
#endif /* WIN32 */

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

#define HAVE_RRD

#include "iface.h"


#endif /* NTOP_H */