tcpdump-stdinc.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2002 - 2003
00003  * NetGroup, Politecnico di Torino (Italy)
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  * notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  * notice, this list of conditions and the following disclaimer in the
00014  * documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the Politecnico di Torino nor the names of its
00016  * contributors may be used to endorse or promote products derived from
00017  * this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00023  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00025  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00026  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00027  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00029  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  *
00032  * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.12.2.5 2006/06/23 02:07:27 hannes Exp $ (LBL)
00033  */
00034 
00035 /*
00036  * Include the appropriate OS header files on Windows and various flavors
00037  * of UNIX, and also define some additional items and include various
00038  * non-OS header files on Windows, and; this isolates most of the platform
00039  * differences to this one file.
00040  */
00041 
00042 #ifndef tcpdump_stdinc_h
00043 #define tcpdump_stdinc_h
00044 
00045 #ifdef WIN32
00046 
00047 #include <stdio.h>
00048 #include <winsock2.h>
00049 #include <Ws2tcpip.h>
00050 #include "bittypes.h"
00051 #include <ctype.h>
00052 #include <time.h>
00053 #include <io.h>
00054 #include <fcntl.h>
00055 #include <sys/types.h>
00056 #include <net/netdb.h>  /* in wpcap's Win32/include */
00057 
00058 #if !defined(__MINGW32__) && !defined(__WATCOMC__)
00059 #undef toascii
00060 #define isascii __isascii
00061 #define toascii __toascii
00062 #define stat _stat
00063 #define open _open
00064 #define fstat _fstat
00065 #define read _read
00066 #define close _close
00067 #define O_RDONLY _O_RDONLY
00068 
00069 typedef short ino_t;
00070 #endif /* __MINGW32__ */
00071 
00072 #ifdef __MINGW32__
00073 #include <stdint.h>
00074 #endif
00075 
00076 /* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
00077  * should be used, but it clashes with <ws2tcpip.h>).
00078  */
00079 extern const char *inet_ntop (int, const void *, char *, size_t);
00080 extern int inet_pton (int, const char *, void *);
00081 extern int inet_aton (const char *cp, struct in_addr *addr);
00082 
00083 #ifndef INET6_ADDRSTRLEN
00084 #define INET6_ADDRSTRLEN 46
00085 #endif
00086 
00087 #ifndef toascii
00088 #define toascii(c) ((c) & 0x7f)
00089 #endif
00090 
00091 #ifndef caddr_t
00092 typedef char* caddr_t;
00093 #endif /* caddr_t */
00094 
00095 #define MAXHOSTNAMELEN  64
00096 #define NI_MAXHOST  1025
00097 #define snprintf _snprintf
00098 #define vsnprintf _vsnprintf
00099 #define RETSIGTYPE void
00100 
00101 #else /* WIN32 */
00102 
00103 #include <ctype.h>
00104 #include <unistd.h>
00105 #include <netdb.h>
00106 #if HAVE_INTTYPES_H
00107 #include <inttypes.h>
00108 #else
00109 #if HAVE_STDINT_H
00110 #include <stdint.h>
00111 #endif
00112 #endif
00113 #ifdef HAVE_SYS_BITYPES_H
00114 #include <sys/bitypes.h>
00115 #endif
00116 #include <sys/param.h>
00117 #include <sys/types.h>      /* concession to AIX */
00118 #include <sys/time.h>
00119 #include <sys/socket.h>
00120 #include <netinet/in.h>
00121 
00122 #ifdef TIME_WITH_SYS_TIME
00123 #include <time.h>
00124 #endif
00125 
00126 #include <arpa/inet.h>
00127 
00128 #endif /* WIN32 */
00129 
00130 #ifdef INET6
00131 #include "ip6.h"
00132 #endif
00133 
00134 #if defined(WIN32) || defined(MSDOS)
00135   #define FOPEN_READ_TXT   "rt"
00136   #define FOPEN_READ_BIN   "rb"
00137   #define FOPEN_WRITE_TXT  "wt"
00138   #define FOPEN_WRITE_BIN  "wb"
00139 #else
00140   #define FOPEN_READ_TXT   "r"
00141   #define FOPEN_READ_BIN   FOPEN_READ_TXT
00142   #define FOPEN_WRITE_TXT  "w"
00143   #define FOPEN_WRITE_BIN  FOPEN_WRITE_TXT
00144 #endif
00145 
00146 #if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl)
00147   #undef ntohl
00148   #undef ntohs
00149   #undef htonl
00150   #undef htons
00151 
00152   extern __inline__ unsigned long __ntohl (unsigned long x);
00153   extern __inline__ unsigned short __ntohs (unsigned short x);
00154 
00155   #define ntohl(x)  __ntohl(x)
00156   #define ntohs(x)  __ntohs(x)
00157   #define htonl(x)  __ntohl(x)
00158   #define htons(x)  __ntohs(x)
00159 
00160   extern __inline__ unsigned long __ntohl (unsigned long x)
00161   {
00162     __asm__ ("xchgb %b0, %h0\n\t"   /* swap lower bytes  */
00163              "rorl  $16, %0\n\t"    /* swap words        */
00164              "xchgb %b0, %h0"       /* swap higher bytes */
00165             : "=q" (x) : "0" (x));
00166     return (x);
00167   }
00168 
00169   extern __inline__ unsigned short __ntohs (unsigned short x)
00170   {
00171     __asm__ ("xchgb %b0, %h0"       /* swap bytes */
00172             : "=q" (x) : "0" (x));
00173     return (x);
00174   }
00175 #endif
00176 
00177 #ifndef INET_ADDRSTRLEN
00178 #define INET_ADDRSTRLEN 16
00179 #endif
00180 
00181 #ifndef TRUE
00182 #define TRUE 1
00183 #endif
00184 
00185 #ifndef FALSE
00186 #define FALSE 0
00187 #endif
00188 
00189 #endif /* tcpdump_stdinc_h */

Generated on Fri Jul 25 17:10:37 2008 for WifiScanner by  doxygen 1.5.5