dect
/
libpcap
Archived
13
0
Fork 0

Use <pcap-stdinc.h> only on Windows; on UNIX, selectively include, in

each source file, only the headers that file needs, and all the headers
it needs in order to compile on various platforms and not to get any
avoidable compiler warnings on those platforms (as well as any
incomplete structure definitions needed to avoid those warnings).

That also means that <pcap.h> doesn't include <pcap-stdinc.h> on UNIX;
we don't want it to include <pcap-stdinc.h>, at least on UNIX, as doing
so

	1) would mean we'd have to install that, so that programs can
	   build with libpcap

and

	2) would mean that programs including <pcap.h> would drag in a
	   bunch of header files that they don't need.

Put a newline at the end of "inet.c" - the Sun C compiler doesn't like
it if the last line doesn't end with a newline.
This commit is contained in:
guy 2002-08-02 03:44:19 +00:00
parent 3073e4c400
commit 309e386870
9 changed files with 89 additions and 29 deletions

View File

@ -40,11 +40,19 @@
#if !(defined(lint) || defined(KERNEL) || defined(_KERNEL))
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/bpf/net/bpf_filter.c,v 1.37 2002-08-01 08:33:12 risso Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/bpf/net/bpf_filter.c,v 1.38 2002-08-02 03:44:22 guy Exp $ (LBL)";
#endif
#ifdef WIN32
#include <pcap-stdinc.h>
#else /* WIN32 */
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#define SOLARIS (defined(sun) && (defined(__SVR4) || defined(__svr4__)))
#if defined(__hpux) || SOLARIS
# include <sys/sysmacros.h>
@ -57,6 +65,8 @@ static const char rcsid[] =
# define MLEN(m) ((m)->m_len)
#endif
#endif /* WIN32 */
#include <net/bpf.h>
#if !defined(KERNEL) && !defined(_KERNEL)
@ -74,6 +84,9 @@ static const char rcsid[] =
#endif
#ifndef LBL_ALIGN
#ifndef WIN32
#include <netinet/in.h>
#endif
#define EXTRACT_SHORT(p) ((u_short)ntohs(*(u_short *)p))
#define EXTRACT_LONG(p) (ntohl(*(u_int32 *)p))

View File

@ -21,19 +21,25 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.170 2002-08-01 08:33:01 risso Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.171 2002-08-02 03:44:19 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include <pcap-stdinc.h>
#ifdef __MINGW32__
#include "IP6_misc.h"
#endif
#else /* WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#ifdef __NetBSD__
#include <sys/param.h>
#endif
@ -42,6 +48,10 @@ struct mbuf; /* Squelch compiler warnings on some platforms for */
struct rtentry; /* declarations in <net/if.h> */
#include <net/if.h>
#include <netinet/in.h>
#endif /* WIN32 */
#include <stdlib.h>
#include <string.h>
#include <memory.h>
@ -59,8 +69,11 @@ struct rtentry; /* declarations in <net/if.h> */
#include "ppp.h"
#include "sll.h"
#include "arcnet.h"
#ifndef WIN32
#ifdef INET6
#include <netdb.h> /* for "struct addrinfo" */
#endif /*INET6*/
#endif /* WIN32 */
#include <pcap-namedb.h>
#define ETHERMTU 1500

View File

@ -22,22 +22,34 @@
*/
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.73 2002-08-01 08:33:02 risso Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.74 2002-08-02 03:44:20 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include <pcap-stdinc.h>
#else /* WIN32 */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#endif
#include <stdlib.h>
#ifndef WIN32
#if __STDC__
struct mbuf;
struct rtentry;
#endif
#include <net/if.h>
#include <netinet/in.h>
#endif /* WIN32 */
#include <stdio.h>
#include "pcap-int.h"

17
inet.c
View File

@ -34,21 +34,31 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.51 2002-08-01 08:33:02 risso Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.52 2002-08-02 03:44:20 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include <pcap-stdinc.h>
#else /* WIN32 */
#include <sys/param.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
#include <sys/time.h> /* concession to AIX */
struct mbuf; /* Squelch compiler warnings on some platforms for */
struct rtentry; /* declarations in <net/if.h> */
#include <net/if.h>
#include <netinet/in.h>
#endif /* WIN32 */
#include <ctype.h>
#include <errno.h>
@ -56,6 +66,9 @@ struct rtentry; /* declarations in <net/if.h> */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include <unistd.h>
#endif /* WIN32 */
#ifdef HAVE_LIMITS_H
#include <limits.h>
#else
@ -646,4 +659,4 @@ pcap_lookupnet(device, netp, maskp, errbuf)
return (0);
}
#endif /* WIN32 */
#endif /* WIN32 */

View File

@ -24,19 +24,27 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.65 2002-08-01 08:33:03 risso Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.66 2002-08-02 03:44:20 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include <pcap-stdinc.h>
#ifdef __MINGW32__
#include "IP6_misc.h"
#endif
#else /* WIN32 */
#include <sys/param.h>
#include <sys/types.h> /* concession to AIX */
#include <sys/socket.h>
#include <sys/time.h>
#include <netinet/in.h>
#ifdef HAVE_ETHER_HOSTTON
#ifdef HAVE_NETINET_IF_ETHER_H
struct mbuf; /* Squelch compiler warnings on some platforms for */
@ -45,6 +53,9 @@ struct rtentry; /* declarations in <net/if.h> */
#include <netinet/if_ether.h>
#endif /* HAVE_NETINET_IF_ETHER_H */
#endif /* HAVE_ETHER_HOSTTON */
#include <arpa/inet.h>
#include <netdb.h>
#endif /* WIN32 */
#include <ctype.h>
#include <errno.h>

View File

@ -18,7 +18,6 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifdef WIN32
#define SIZEOF_CHAR 1
#define SIZEOF_SHORT 2
@ -42,22 +41,4 @@
#define vsnprintf _vsnprintf
#define inline __inline
#else
#include <unistd.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#include <arpa/inet.h>
#endif
#endif

11
pcap.c
View File

@ -33,18 +33,25 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.40 2002-08-01 08:33:04 risso Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.41 2002-08-02 03:44:21 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef WIN32
#include <pcap-stdinc.h>
#else /* WIN32 */
#include <sys/types.h>
#endif /* WIN32 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <fcntl.h>
#include <errno.h>
@ -347,7 +354,7 @@ pcap_close(pcap_t *p)
#endif
close(p->fd);
}
#else
#else /* WIN32 */
if (p->adapter != NULL) {
PacketCloseAdapter(p->adapter);
p->adapter = NULL;

7
pcap.h
View File

@ -31,13 +31,18 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.36 2002-08-01 08:33:04 risso Exp $ (LBL)
* @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.37 2002-08-02 03:44:21 guy Exp $ (LBL)
*/
#ifndef lib_pcap_h
#define lib_pcap_h
#ifdef WIN32
#include <pcap-stdinc.h>
#else /* WIN32 */
#include <sys/types.h>
#include <sys/time.h>
#endif /* WIN32 */
#include <net/bpf.h>

View File

@ -22,7 +22,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.88 2002-08-01 08:33:05 risso Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.89 2002-08-02 03:44:21 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -36,11 +36,16 @@ static const char rcsid[] =
#include "gencode.h"
#ifdef INET6
#ifdef WIN32
#include <pcap-stdinc.h>
#ifdef __MINGW32__
#include "IP6_misc.h"
#endif
#else /* WIN32 */
#include <sys/socket.h> /* for "struct sockaddr" in "struct addrinfo" */
#include <netdb.h> /* for "struct addrinfo" */
#endif /* WIN32 */
/* Workaround for AIX 4.3 */
#if !defined(AI_NUMERICHOST)