7068506 Move libpcap from SFW to userland
authorRishi Srivatsavai <Rishi.Srivatsavai@oracle.com>
Thu, 21 Jul 2011 10:48:02 -0700
changeset 431 e60e527b8179
parent 430 51025776a91e
child 432 4eda6f0a3346
7068506 Move libpcap from SFW to userland 7011747 libpcap should use BIOCSETLIF and not BIOCSETIF 7033704 libpcap should support zonename prefix linknames
components/libpcap/Makefile
components/libpcap/libpcap.p5m
components/libpcap/license.pcap
components/libpcap/patches/10-biocsetlif.patch
components/libpcap/patches/20-zonenameprefix.patch
components/libpcap/patches/30-getifaddrs.patch
components/meta-packages/history/SUNWlibpcap.p5m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libpcap/Makefile	Thu Jul 21 10:48:02 2011 -0700
@@ -0,0 +1,52 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+include ../../make-rules/shared-macros.mk
+
+COMPONENT_NAME=		libpcap
+COMPONENT_VERSION=	1.1.1
+COMPONENT_SRC=		$(COMPONENT_NAME)-$(COMPONENT_VERSION)
+COMPONENT_ARCHIVE=	$(COMPONENT_SRC).tar.gz
+COMPONENT_ARCHIVE_HASH=	sha1:18581af5e78a40b7b2c9a6cd8ce40e7cb1cd9c63
+COMPONENT_ARCHIVE_URL=	http://www.tcpdump.org/release/$(COMPONENT_ARCHIVE)
+
+include ../../make-rules/prep.mk
+include ../../make-rules/configure.mk
+include ../../make-rules/ips.mk
+
+#
+# libpcap Makefile does not use CFLAGS when building shared library
+# so we require the following line to add the -m option to CC
+#
+CC += $(CC_BITS)
+CONFIGURE_OPTIONS  +=	CFLAGS="$(CFLAGS) -DHAVE_CONFIG_H"
+
+# common targets
+build:		$(BUILD_32_and_64)
+
+install:	$(INSTALL_32_and_64)
+
+BUILD_PKG_DEPENDENCIES =	$(BUILD_TOOLS)
+
+test:	$(NO_TESTS)
+
+include ../../make-rules/depend.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libpcap/libpcap.p5m	Thu Jul 21 10:48:02 2011 -0700
@@ -0,0 +1,112 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+<transform file path=usr.*/man/.+ -> default mangler.man.stability uncommitted>
+# The libpcap man pages should go in section 3pcap instead of
+# section 3, where "make install" puts them.
+<transform file path=usr/share/man/man3pcap/(.*) -> set action.hash usr/share/man/man3/%<1>>
+set name=pkg.fmri \
+    value=pkg:/system/library/libpcap@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.summary value="Packet capture library"
+set name=info.classification \
+    value=org.opensolaris.category.2008:System/Libraries
+set name=info.source_url value=$(COMPONENT_ARCHIVE_URL)
+set name=info.upstream_url value=http://www.tcpdump.org
+set name=opensolaris.arc_url \
+    value=http://arc.opensolaris.org/caselog/PSARC/2008/288
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+#
+dir path=usr
+dir path=usr/include
+dir path=usr/lib
+dir path=usr/lib/$(MACH64)
+dir path=usr/share
+dir path=usr/share/man
+dir path=usr/share/man/man3pcap
+#
+file path=usr/include/pcap-bpf.h
+file path=usr/include/pcap-namedb.h
+file path=usr/include/pcap.h
+file path=usr/include/pcap/bpf.h
+file path=usr/include/pcap/namedb.h
+file path=usr/include/pcap/pcap.h
+file path=usr/include/pcap/sll.h
+file path=usr/include/pcap/usb.h
+file path=usr/lib/$(MACH64)/libpcap.so.1.1.1
+file path=usr/lib/libpcap.so.1.1.1
+file path=usr/share/man/man3pcap/pcap.3pcap
+file path=usr/share/man/man3pcap/pcap_activate.3pcap
+file path=usr/share/man/man3pcap/pcap_breakloop.3pcap
+file path=usr/share/man/man3pcap/pcap_can_set_rfmon.3pcap
+file path=usr/share/man/man3pcap/pcap_close.3pcap
+file path=usr/share/man/man3pcap/pcap_compile.3pcap
+file path=usr/share/man/man3pcap/pcap_create.3pcap
+file path=usr/share/man/man3pcap/pcap_datalink.3pcap
+file path=usr/share/man/man3pcap/pcap_datalink_name_to_val.3pcap
+file path=usr/share/man/man3pcap/pcap_datalink_val_to_name.3pcap
+file path=usr/share/man/man3pcap/pcap_dump.3pcap
+file path=usr/share/man/man3pcap/pcap_dump_close.3pcap
+file path=usr/share/man/man3pcap/pcap_dump_file.3pcap
+file path=usr/share/man/man3pcap/pcap_dump_flush.3pcap
+file path=usr/share/man/man3pcap/pcap_dump_ftell.3pcap
+file path=usr/share/man/man3pcap/pcap_dump_open.3pcap
+file path=usr/share/man/man3pcap/pcap_file.3pcap
+file path=usr/share/man/man3pcap/pcap_fileno.3pcap
+file path=usr/share/man/man3pcap/pcap_findalldevs.3pcap
+file path=usr/share/man/man3pcap/pcap_free_datalinks.3pcap
+file path=usr/share/man/man3pcap/pcap_freealldevs.3pcap
+file path=usr/share/man/man3pcap/pcap_freecode.3pcap
+file path=usr/share/man/man3pcap/pcap_get_selectable_fd.3pcap
+file path=usr/share/man/man3pcap/pcap_geterr.3pcap
+file path=usr/share/man/man3pcap/pcap_inject.3pcap
+file path=usr/share/man/man3pcap/pcap_is_swapped.3pcap
+file path=usr/share/man/man3pcap/pcap_lib_version.3pcap
+file path=usr/share/man/man3pcap/pcap_list_datalinks.3pcap
+file path=usr/share/man/man3pcap/pcap_lookupdev.3pcap
+file path=usr/share/man/man3pcap/pcap_lookupnet.3pcap
+file path=usr/share/man/man3pcap/pcap_loop.3pcap
+file path=usr/share/man/man3pcap/pcap_major_version.3pcap
+file path=usr/share/man/man3pcap/pcap_next_ex.3pcap
+file path=usr/share/man/man3pcap/pcap_offline_filter.3pcap
+file path=usr/share/man/man3pcap/pcap_open_dead.3pcap
+file path=usr/share/man/man3pcap/pcap_open_live.3pcap
+file path=usr/share/man/man3pcap/pcap_open_offline.3pcap
+file path=usr/share/man/man3pcap/pcap_set_buffer_size.3pcap
+file path=usr/share/man/man3pcap/pcap_set_datalink.3pcap
+file path=usr/share/man/man3pcap/pcap_set_promisc.3pcap
+file path=usr/share/man/man3pcap/pcap_set_rfmon.3pcap
+file path=usr/share/man/man3pcap/pcap_set_snaplen.3pcap
+file path=usr/share/man/man3pcap/pcap_set_timeout.3pcap
+file path=usr/share/man/man3pcap/pcap_setdirection.3pcap
+file path=usr/share/man/man3pcap/pcap_setfilter.3pcap
+file path=usr/share/man/man3pcap/pcap_setnonblock.3pcap
+file path=usr/share/man/man3pcap/pcap_snapshot.3pcap
+file path=usr/share/man/man3pcap/pcap_stats.3pcap
+file path=usr/share/man/man3pcap/pcap_statustostr.3pcap
+file path=usr/share/man/man3pcap/pcap_strerror.3pcap
+legacy pkg=SUNWlibpcap desc="libpcap - 1.1.1" \
+    name="libpcap - a packet capture library"
+license license.pcap license=BSD
+link path=usr/lib/$(MACH64)/libpcap.so target=./libpcap.so.1.1.1
+link path=usr/lib/$(MACH64)/libpcap.so.1 target=./libpcap.so.1.1.1
+link path=usr/lib/libpcap.so target=./libpcap.so.1.1.1
+link path=usr/lib/libpcap.so.1 target=./libpcap.so.1.1.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libpcap/license.pcap	Thu Jul 21 10:48:02 2011 -0700
@@ -0,0 +1,37 @@
+Copyright (c) 1982 1986 1987 1988 1988 1989 1989 1990 1990 1991 1992 1992 1993 1993 1994 1994 1995 1995 1996 1997 The Regents of the University of California.  All rights reserved.
+
+Copyright 1991 by the Massachusetts Institute of Technology
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+
+Copyright (c) 2001 Atsushi Onoe
+Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+
+Copyright (c) 1997 Yen Yen Lim and North Dakota State University
+
+Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California)
+
+Copyright (c) 1996 Juniper Networks, Inc.  All rights reserved.
+Copyright (c) 2006 Paolo Abeni (Italy)
+
+Copyright (c) 2007 Fulko Hew, SITA INC Canada, Inc <[email protected]>
+
+Copyright 1989 by Carnegie Mellon.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+  
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+  3. The names of the authors may not be used to endorse or promote
+     products derived from this software without specific prior
+     written permission.
+  
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libpcap/patches/10-biocsetlif.patch	Thu Jul 21 10:48:02 2011 -0700
@@ -0,0 +1,71 @@
+--- libpcap-1.1.1/pcap-bpf.c	Thu Mar 11 17:56:54 2010
++++ patched-libpcap-1.1.1/pcap-bpf.c	Tue Jul 12 14:49:10 2011
+@@ -1392,7 +1392,15 @@
+ {
+ 	int status = 0;
+ 	int fd;
++#ifdef LIFNAMSIZ
++	struct lifreq ifr;
++	char *ifrname = ifr.lifr_name;
++	const size_t ifnamsiz = sizeof(ifr.lifr_name);
++#else
+ 	struct ifreq ifr;
++	char *ifrname = ifr.ifr_name;
++	const size_t ifnamsiz = sizeof(ifr.ifr_name);
++#endif
+ 	struct bpf_version bv;
+ #ifdef __APPLE__
+ 	int sockfd;
+@@ -1484,9 +1492,7 @@
+ 					 */
+ 					sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ 					if (sockfd != -1) {
+-						strlcpy(ifr.ifr_name,
+-						    p->opt.source,
+-						    sizeof(ifr.ifr_name));
++						strlcpy(ifrname, p->opt.source, ifnamsiz);
+ 						if (ioctl(sockfd, SIOCGIFFLAGS,
+ 						    (char *)&ifr) < 0) {
+ 							/*
+@@ -1608,7 +1614,7 @@
+ 			    pcap_strerror(errno));
+ 			goto bad;
+ 		}
+-		(void)strncpy(ifr.ifr_name, p->opt.source, sizeof(ifr.ifr_name));
++		(void)strncpy(ifrname, p->opt.source, ifrnamsiz);
+ 		if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
+ 			snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF: %s: %s",
+ 			    p->opt.source, pcap_strerror(errno));
+@@ -1638,9 +1644,14 @@
+ 			/*
+ 			 * Now bind to the device.
+ 			 */
+-			(void)strncpy(ifr.ifr_name, p->opt.source,
+-			    sizeof(ifr.ifr_name));
+-			if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0) {
++			(void)strncpy(ifrname, p->opt.source, ifnamsiz);
++#ifdef BIOCSETLIF
++			if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) < 0)
++#else
++
++			if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) < 0)
++#endif
++			{
+ 				status = check_setif_failure(p, errno);
+ 				goto bad;
+ 			}
+@@ -1667,9 +1678,12 @@
+ 				 */
+ 				(void) ioctl(fd, BIOCSBLEN, (caddr_t)&v);
+ 
+-				(void)strncpy(ifr.ifr_name, p->opt.source,
+-				    sizeof(ifr.ifr_name));
++				(void)strncpy(ifrname, p->opt.source, ifnamsiz);
++#ifdef BIOCSETLIF
++				if (ioctl(fd, BIOCSETLIF, (caddr_t)&ifr) >= 0)
++#else
+ 				if (ioctl(fd, BIOCSETIF, (caddr_t)&ifr) >= 0)
++#endif
+ 					break;	/* that size worked; we're done */
+ 
+ 				if (errno != ENOBUFS) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libpcap/patches/20-zonenameprefix.patch	Thu Jul 21 10:48:02 2011 -0700
@@ -0,0 +1,51 @@
+--- libpcap-1.1.1/pcap-bpf-patch1.c	Mon Jul 18 16:40:47 2011
++++ patched-libpcap-1.1.1/pcap-bpf.c	Mon Jul 18 16:38:14 2011
+@@ -155,6 +155,10 @@
+ 
+ #endif /* BIOCGDLTLIST */
+ 
++#if defined(sun) && defined(LIFNAMSIZ) && defined(lifr_zoneid)
++#include <zone.h>
++#endif
++
+ /*
+  * We include the OS's <net/bpf.h>, not our "pcap/bpf.h", so we probably
+  * don't get DLT_DOCSIS defined.
+@@ -1393,6 +1397,7 @@
+ 	int status = 0;
+ 	int fd;
+ #ifdef LIFNAMSIZ
++	char *zonesep;
+ 	struct lifreq ifr;
+ 	char *ifrname = ifr.lifr_name;
+ 	const size_t ifnamsiz = sizeof(ifr.lifr_name);
+@@ -1447,6 +1452,29 @@
+ 		goto bad;
+ 	}
+ 
++#if defined(LIFNAMSIZ) && defined(ZONENAME_MAX) && defined(lifr_zoneid)
++	/*
++	 * Check if the given source network device has a '/' separated
++	 * zonename prefix string. The zonename prefixed source device
++	 * can be used by libpcap consumers to capture network traffic
++	 * in non-global zones from the global zone on Solaris 11 and
++	 * above. If the zonename prefix is present then we strip the
++	 * prefix and pass the zone ID as part of lifr_zoneid.
++	 */
++	if ((zonesep = strchr(p->opt.source, '/')) != NULL) {
++		char zonename[ZONENAME_MAX];
++		int  znamelen;
++		char *lnamep;
++
++		znamelen = zonesep - p->opt.source;
++		(void) strlcpy(zonename, p->opt.source, znamelen + 1);
++		lnamep = strdup(zonesep + 1);
++		ifr.lifr_zoneid = getzoneidbyname(zonename);
++		free(p->opt.source);
++		p->opt.source = lnamep;
++	}
++#endif
++
+ 	p->md.device = strdup(p->opt.source);
+ 	if (p->md.device == NULL) {
+ 		snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libpcap/patches/30-getifaddrs.patch	Thu Jul 21 10:48:02 2011 -0700
@@ -0,0 +1,11 @@
+--- libpcap-1.1.1/fad-getad.c	Mon Apr  5 10:54:05 2010
++++ patched-libpcap-1.1.1/fad-getad.c	Wed Jul 20 14:50:56 2011
+@@ -64,7 +64,7 @@
+ # ifdef __Lynx__
+ /* LynxOS */
+ #  include <netpacket/if_packet.h>
+-# else
++# elif defined(linux)
+ /* Linux */
+ #  include <linux/types.h>
+ #  include <linux/if_packet.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/meta-packages/history/SUNWlibpcap.p5m	Thu Jul 21 10:48:02 2011 -0700
@@ -0,0 +1,32 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# Legacy package information for renamed SUNWlibpcap package
+#
+set name=pkg.fmri value=pkg:/[email protected],5.11-0.133
+set name=pkg.renamed value=true
+
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+
+depend fmri=system/library/[email protected] type=require