1/* 2 * Copyright (c) 2002 - 2003 3 * NetGroup, Politecnico di Torino (Italy) 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the Politecnico di Torino nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 *
| 1/* 2 * Copyright (c) 2002 - 2003 3 * NetGroup, Politecnico di Torino (Italy) 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the Politecnico di Torino nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 *
|
32 * $FreeBSD: head/contrib/tcpdump/tcpdump-stdinc.h 190207 2009-03-21 18:30:25Z rpaulo $ 33 * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.17 2006-05-19 17:55:34 hannes Exp $ (LBL)
| 32 * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.18 2007-11-24 18:13:33 mcr Exp $ (LBL)
|
34 */ 35 36/* 37 * Include the appropriate OS header files on Windows and various flavors 38 * of UNIX, and also define some additional items and include various 39 * non-OS header files on Windows, and; this isolates most of the platform 40 * differences to this one file. 41 */ 42 43#ifndef tcpdump_stdinc_h 44#define tcpdump_stdinc_h 45 46#ifdef WIN32 47 48#include <stdio.h> 49#include <winsock2.h> 50#include <Ws2tcpip.h> 51#include "bittypes.h" 52#include <ctype.h> 53#include <time.h> 54#include <io.h> 55#include <fcntl.h> 56#include <sys/types.h> 57#include <net/netdb.h> /* in wpcap's Win32/include */ 58
| 33 */ 34 35/* 36 * Include the appropriate OS header files on Windows and various flavors 37 * of UNIX, and also define some additional items and include various 38 * non-OS header files on Windows, and; this isolates most of the platform 39 * differences to this one file. 40 */ 41 42#ifndef tcpdump_stdinc_h 43#define tcpdump_stdinc_h 44 45#ifdef WIN32 46 47#include <stdio.h> 48#include <winsock2.h> 49#include <Ws2tcpip.h> 50#include "bittypes.h" 51#include <ctype.h> 52#include <time.h> 53#include <io.h> 54#include <fcntl.h> 55#include <sys/types.h> 56#include <net/netdb.h> /* in wpcap's Win32/include */ 57
|
| 58#ifndef NBBY 59#define NBBY 8 60#endif 61
|
59#if !defined(__MINGW32__) && !defined(__WATCOMC__) 60#undef toascii 61#define isascii __isascii 62#define toascii __toascii 63#define stat _stat 64#define open _open 65#define fstat _fstat 66#define read _read 67#define close _close 68#define O_RDONLY _O_RDONLY 69 70typedef short ino_t; 71#endif /* __MINGW32__ */ 72 73#ifdef __MINGW32__ 74#include <stdint.h> 75#endif 76 77/* Protos for missing/x.c functions (ideally <missing/addrinfo.h> 78 * should be used, but it clashes with <ws2tcpip.h>). 79 */ 80extern const char *inet_ntop (int, const void *, char *, size_t); 81extern int inet_pton (int, const char *, void *); 82extern int inet_aton (const char *cp, struct in_addr *addr); 83 84#ifndef INET6_ADDRSTRLEN 85#define INET6_ADDRSTRLEN 46 86#endif 87 88#ifndef toascii 89#define toascii(c) ((c) & 0x7f) 90#endif 91 92#ifndef caddr_t 93typedef char* caddr_t; 94#endif /* caddr_t */ 95 96#define MAXHOSTNAMELEN 64 97#define NI_MAXHOST 1025 98#define snprintf _snprintf 99#define vsnprintf _vsnprintf 100#define RETSIGTYPE void 101 102#else /* WIN32 */ 103 104#include <ctype.h> 105#include <unistd.h> 106#include <netdb.h> 107#if HAVE_INTTYPES_H 108#include <inttypes.h> 109#else 110#if HAVE_STDINT_H 111#include <stdint.h> 112#endif 113#endif 114#ifdef HAVE_SYS_BITYPES_H 115#include <sys/bitypes.h> 116#endif 117#include <sys/param.h> 118#include <sys/types.h> /* concession to AIX */ 119#include <sys/time.h> 120#include <sys/socket.h> 121#include <netinet/in.h> 122 123#ifdef TIME_WITH_SYS_TIME 124#include <time.h> 125#endif 126 127#include <arpa/inet.h> 128 129#endif /* WIN32 */ 130 131#ifdef INET6 132#include "ip6.h" 133#endif 134 135#if defined(WIN32) || defined(MSDOS) 136 #define FOPEN_READ_TXT "rt" 137 #define FOPEN_READ_BIN "rb" 138 #define FOPEN_WRITE_TXT "wt" 139 #define FOPEN_WRITE_BIN "wb" 140#else 141 #define FOPEN_READ_TXT "r" 142 #define FOPEN_READ_BIN FOPEN_READ_TXT 143 #define FOPEN_WRITE_TXT "w" 144 #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT 145#endif 146
| 62#if !defined(__MINGW32__) && !defined(__WATCOMC__) 63#undef toascii 64#define isascii __isascii 65#define toascii __toascii 66#define stat _stat 67#define open _open 68#define fstat _fstat 69#define read _read 70#define close _close 71#define O_RDONLY _O_RDONLY 72 73typedef short ino_t; 74#endif /* __MINGW32__ */ 75 76#ifdef __MINGW32__ 77#include <stdint.h> 78#endif 79 80/* Protos for missing/x.c functions (ideally <missing/addrinfo.h> 81 * should be used, but it clashes with <ws2tcpip.h>). 82 */ 83extern const char *inet_ntop (int, const void *, char *, size_t); 84extern int inet_pton (int, const char *, void *); 85extern int inet_aton (const char *cp, struct in_addr *addr); 86 87#ifndef INET6_ADDRSTRLEN 88#define INET6_ADDRSTRLEN 46 89#endif 90 91#ifndef toascii 92#define toascii(c) ((c) & 0x7f) 93#endif 94 95#ifndef caddr_t 96typedef char* caddr_t; 97#endif /* caddr_t */ 98 99#define MAXHOSTNAMELEN 64 100#define NI_MAXHOST 1025 101#define snprintf _snprintf 102#define vsnprintf _vsnprintf 103#define RETSIGTYPE void 104 105#else /* WIN32 */ 106 107#include <ctype.h> 108#include <unistd.h> 109#include <netdb.h> 110#if HAVE_INTTYPES_H 111#include <inttypes.h> 112#else 113#if HAVE_STDINT_H 114#include <stdint.h> 115#endif 116#endif 117#ifdef HAVE_SYS_BITYPES_H 118#include <sys/bitypes.h> 119#endif 120#include <sys/param.h> 121#include <sys/types.h> /* concession to AIX */ 122#include <sys/time.h> 123#include <sys/socket.h> 124#include <netinet/in.h> 125 126#ifdef TIME_WITH_SYS_TIME 127#include <time.h> 128#endif 129 130#include <arpa/inet.h> 131 132#endif /* WIN32 */ 133 134#ifdef INET6 135#include "ip6.h" 136#endif 137 138#if defined(WIN32) || defined(MSDOS) 139 #define FOPEN_READ_TXT "rt" 140 #define FOPEN_READ_BIN "rb" 141 #define FOPEN_WRITE_TXT "wt" 142 #define FOPEN_WRITE_BIN "wb" 143#else 144 #define FOPEN_READ_TXT "r" 145 #define FOPEN_READ_BIN FOPEN_READ_TXT 146 #define FOPEN_WRITE_TXT "w" 147 #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT 148#endif 149
|
| 150#if defined(__GNUC__) && defined(__i386__) && !defined(__ntohl) 151 #undef ntohl 152 #undef ntohs 153 #undef htonl 154 #undef htons 155 156 static __inline__ unsigned long __ntohl (unsigned long x); 157 static __inline__ unsigned short __ntohs (unsigned short x); 158 159 #define ntohl(x) __ntohl(x) 160 #define ntohs(x) __ntohs(x) 161 #define htonl(x) __ntohl(x) 162 #define htons(x) __ntohs(x) 163 164 static __inline__ unsigned long __ntohl (unsigned long x) 165 { 166 __asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */ 167 "rorl $16, %0\n\t" /* swap words */ 168 "xchgb %b0, %h0" /* swap higher bytes */ 169 : "=q" (x) : "0" (x)); 170 return (x); 171 } 172 173 static __inline__ unsigned short __ntohs (unsigned short x) 174 { 175 __asm__ ("xchgb %b0, %h0" /* swap bytes */ 176 : "=q" (x) : "0" (x)); 177 return (x); 178 } 179#endif 180
|
147#ifndef INET_ADDRSTRLEN 148#define INET_ADDRSTRLEN 16 149#endif 150 151#ifndef TRUE 152#define TRUE 1 153#endif 154 155#ifndef FALSE 156#define FALSE 0 157#endif 158 159#endif /* tcpdump_stdinc_h */
| 181#ifndef INET_ADDRSTRLEN 182#define INET_ADDRSTRLEN 16 183#endif 184 185#ifndef TRUE 186#define TRUE 1 187#endif 188 189#ifndef FALSE 190#define FALSE 0 191#endif 192 193#endif /* tcpdump_stdinc_h */
|