summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2017-05-31 05:20:59 +0000
committerdelphij <delphij@FreeBSD.org>2017-05-31 05:20:59 +0000
commit4b7bf2a87440f1bc207c6b856bbe3f0ff00a539c (patch)
tree697c4c465034ee4bd79277857f775508ce3567b3 /lib
parentbfde52da67b17e680ca5da34f553788ce1cbf7ef (diff)
downloadFreeBSD-src-4b7bf2a87440f1bc207c6b856bbe3f0ff00a539c.zip
FreeBSD-src-4b7bf2a87440f1bc207c6b856bbe3f0ff00a539c.tar.gz
MFC r313695, r313760, r314769, r314863, r314865, r316125
r313695: MFV r313676: libpcap 1.8.1 r313760: MFV r313759: license change for a few headers (4 clause BSD to 3 clause BSD). X-MFC-with: r313695 r314769: Remove compatibility with old libpcap. Differential Revision: https://reviews.freebsd.org/D9606 r314863: Stop installing pcap-int.h, which is the internal interface for libpcap. Reference: https://github.com/the-tcpdump-group/libpcap/issues/560 PR: 217221 r314865: Bump __FreeBSD_version for removal of pcap-int.h. PR: 217221 r316125: MFV r316124: Fix build when WITHOUT_INET6. Reported by: Randy Westlund <rwestlun gmail com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libpcap/Makefile19
-rw-r--r--lib/libpcap/config.h43
-rw-r--r--lib/libpcap/pcap-netmap.c51
3 files changed, 42 insertions, 71 deletions
diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile
index 9b7ffe9..e402e7f 100644
--- a/lib/libpcap/Makefile
+++ b/lib/libpcap/Makefile
@@ -7,16 +7,16 @@ SHLIBDIR?= /lib
PACKAGE=lib${LIB}
LIB= pcap
-SRCS= grammar.y tokdefs.h version.h pcap-bpf.c \
- pcap-netmap.c \
+SRCS= grammar.y tokdefs.h pcap_version.h pcap-bpf.c \
+ pcap-netmap.c fad-helpers.c \
pcap.c pcap-common.c inet.c fad-getad.c gencode.c optimize.c nametoaddr.c \
etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c \
scanner.l sf-pcap.c sf-pcap-ng.c version.c
# Old compatibility headers
-INCS= pcap.h pcap-int.h pcap-namedb.h pcap-bpf.h
+INCS= pcap.h pcap-namedb.h pcap-bpf.h
-PCAPINCS= pcap/pcap.h pcap/namedb.h pcap/bpf.h
+PCAPINCS= pcap/pcap.h pcap/namedb.h pcap/bpf.h pcap/dlt.h pcap/export-defs.h
PCAPINCSDIR= ${INCLUDEDIR}/pcap
INCSGROUPS= INCS PCAPINCS
@@ -93,13 +93,14 @@ MLINKS= pcap_datalink_val_to_name.3 pcap_datalink_val_to_description.3 \
# Our man pages are a special copy from the distdir. See below.
CLEANFILES+=${MAN}
-CLEANFILES+=tokdefs.h version.h version.c
+CLEANFILES+=tokdefs.h scanner.h pcap_version.h version.c
-YFLAGS+=-p pcapyy
-LFLAGS+=-Ppcapyy
-CFLAGS+=-DHAVE_CONFIG_H -Dyylval=pcapyylval -I${.CURDIR} -I.
+YFLAGS+=-p pcap_
+LFLAGS+=-Ppcap_ --header-file=${.OBJDIR}/scanner.h --nounput
+CFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR} -I${.OBJDIR}
CFLAGS+=-D_U_="__attribute__((unused))"
CFLAGS+=-DHAVE_SNPRINTF -DHAVE_VSNPRINTF
+CFLAGS+=-DBUILDING_PCAP
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+=-DINET6
.endif
@@ -123,7 +124,7 @@ version.c: ${PCAP_DISTDIR}/VERSION
@rm -f $@
sed 's/.*/char pcap_version[] = "&";/' ${PCAP_DISTDIR}/VERSION > $@
-version.h: ${PCAP_DISTDIR}/VERSION
+pcap_version.h: ${PCAP_DISTDIR}/VERSION
@rm -f $@
sed 's/.*/char pcap_version_string[] = "libpcap version &";/' ${PCAP_DISTDIR}/VERSION > $@
diff --git a/lib/libpcap/config.h b/lib/libpcap/config.h
index 4033b27..de0ad67 100644
--- a/lib/libpcap/config.h
+++ b/lib/libpcap/config.h
@@ -2,7 +2,7 @@
/* This is an edited copy of the config.h generated by configure. */
/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.in by autoheader. */
+/* config.h.in. Generated from configure.ac by autoheader. */
/* Enable optimizer debugging */
/* #undef BDEBUG */
@@ -80,12 +80,18 @@
/* Define to 1 if you have the <linux/ethtool.h> header file. */
/* #undef HAVE_LINUX_ETHTOOL_H */
+/* Define to 1 if you have the <linux/if_bonding.h> header file. */
+/* #undef HAVE_LINUX_IF_BONDING_H */
+
/* Define to 1 if you have the <linux/if_packet.h> header file. */
/* #undef HAVE_LINUX_IF_PACKET_H */
/* Define to 1 if you have the <linux/net_tstamp.h> header file. */
/* #undef HAVE_LINUX_NET_TSTAMP_H */
+/* Define to 1 if you have the <linux/sockios.h> header file. */
+/* #undef HAVE_LINUX_SOCKIOS_H */
+
/* if tp_vlan_tci exists */
/* #undef HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI */
@@ -123,16 +129,13 @@
/* if there's an os_proto.h for this platform, to use additional prototypes */
/* #undef HAVE_OS_PROTO_H */
-/* Define to 1 if you have the <paths.h> header file. */
-#define HAVE_PATHS_H 1
-
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
#define HAVE_PF_NAT_THROUGH_PF_NORDR 1
-/* define if you have a Septel API */
+/* define if you have the Septel API */
/* #undef HAVE_SEPTEL_API */
-/* define if you have Myricom SNF API */
+/* define if you have the Myricom SNF API */
/* #undef HAVE_SNF_API */
/* Define to 1 if you have the `snprintf' function. */
@@ -168,6 +171,9 @@
/* Define to 1 if you have the `strlcpy' function. */
#define HAVE_STRLCPY 1
+/* Define to 1 if you have the `strtok_r' function. */
+#define HAVE_STRTOK_R 1
+
/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
/* #undef HAVE_STRUCT_BPF_TIMEVAL */
@@ -186,6 +192,9 @@
/* Define to 1 if you have the <sys/ioccom.h> header file. */
#define HAVE_SYS_IOCCOM_H 1
+/* Define to 1 if you have the <sys/select.h> header file. */
+#define HAVE_SYS_SELECT_H 1
+
/* Define to 1 if you have the <sys/sockio.h> header file. */
#define HAVE_SYS_SOCKIO_H 1
@@ -195,6 +204,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
+/* define if you have the TurboCap API */
+/* #undef HAVE_TC_API */
+
/* if if_packet.h has tpacket_stats defined */
/* #undef HAVE_TPACKET_STATS */
@@ -204,9 +216,6 @@
/* if struct usbdevfs_ctrltransfer has bRequestType */
/* #undef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE */
-/* define if version.h is generated in the build procedure */
-#define HAVE_VERSION_H 1
-
/* Define to 1 if you have the `vsnprintf' function. */
#define HAVE_VSNPRINTF 1
@@ -226,9 +235,6 @@
/* path for device for USB sniffing */
/* #undef LINUX_USB_MON_DEV */
-/* if we need a pcap_parse wrapper around yyparse */
-#define NEED_YYPARSE_WRAPPER 1
-
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
/* #undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON */
@@ -265,18 +271,15 @@
/* target host supports Bluetooth Monitor */
/* #undef PCAP_SUPPORT_BT_MONITOR */
-/* target host supports CAN sniffing */
-/* #undef PCAP_SUPPORT_CAN */
-
-/* target host supports canusb */
-/* #undef PCAP_SUPPORT_CANUSB */
-
/* support D-Bus sniffing */
/* #undef PCAP_SUPPORT_DBUS */
/* target host supports netfilter sniffing */
/* #undef PCAP_SUPPORT_NETFILTER */
+/* use Linux packet ring capture if available */
+#define PCAP_SUPPORT_PACKET_RING 1
+
/* target host supports USB sniffing */
/* #undef PCAP_SUPPORT_USB */
@@ -295,6 +298,10 @@
/* Enable parser debugging */
/* #undef YYDEBUG */
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+ `char[]'. */
+#define YYTEXT_POINTER 1
+
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
diff --git a/lib/libpcap/pcap-netmap.c b/lib/libpcap/pcap-netmap.c
index 19af71e..7d8cc7e 100644
--- a/lib/libpcap/pcap-netmap.c
+++ b/lib/libpcap/pcap-netmap.c
@@ -22,6 +22,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#ifdef HAVE_CONFIG_H
@@ -42,24 +44,7 @@
#include "pcap-int.h"
-/*
- * $FreeBSD$
- *
- * This code is meant to build also on other versions of libpcap.
- *
- * older libpcap miss p->priv, use p->md.device instead (and allocate).
- * Also opt.timeout was in md.timeout before.
- * Use #define PCAP_IF_UP to discriminate
- */
-#ifdef PCAP_IF_UP
#define NM_PRIV(p) ((struct pcap_netmap *)(p->priv))
-#define the_timeout opt.timeout
-#else
-#define HAVE_NO_PRIV
-#define NM_PRIV(p) ((struct pcap_netmap *)(p->md.device))
-#define SET_PRIV(p, x) p->md.device = (void *)x
-#define the_timeout md.timeout
-#endif
#if defined (linux)
/* On FreeBSD we use IFF_PPROMISC which is in ifr_flagshigh.
@@ -124,7 +109,7 @@ pcap_netmap_dispatch(pcap_t *p, int cnt, pcap_handler cb, u_char *user)
if (ret != 0)
break;
errno = 0;
- ret = poll(&pfd, 1, p->the_timeout);
+ ret = poll(&pfd, 1, p->opt.timeout);
}
return ret;
}
@@ -197,10 +182,6 @@ pcap_netmap_close(pcap_t *p)
}
}
nm_close(d);
-#ifdef HAVE_NO_PRIV
- free(pn);
- SET_PRIV(p, NULL); // unnecessary
-#endif
pcap_cleanup_live_common(p);
}
@@ -209,23 +190,19 @@ static int
pcap_netmap_activate(pcap_t *p)
{
struct pcap_netmap *pn = NM_PRIV(p);
- struct nm_desc *d = nm_open(p->opt.source, NULL, 0, NULL);
+ struct nm_desc *d = nm_open(p->opt.device, NULL, 0, NULL);
uint32_t if_flags = 0;
if (d == NULL) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"netmap open: cannot access %s: %s\n",
- p->opt.source, pcap_strerror(errno));
-#ifdef HAVE_NO_PRIV
- free(pn);
- SET_PRIV(p, NULL); // unnecessary
-#endif
+ p->opt.device, pcap_strerror(errno));
pcap_cleanup_live_common(p);
return (PCAP_ERROR);
}
if (0)
fprintf(stderr, "%s device %s priv %p fd %d ports %d..%d\n",
- __FUNCTION__, p->opt.source, d, d->fd,
+ __FUNCTION__, p->opt.device, d, d->fd,
d->first_rx_ring, d->last_rx_ring);
pn->d = d;
p->fd = d->fd;
@@ -261,23 +238,9 @@ pcap_netmap_create(const char *device, char *ebuf, int *is_ours)
*is_ours = (!strncmp(device, "netmap:", 7) || !strncmp(device, "vale", 4));
if (! *is_ours)
return NULL;
-#ifdef HAVE_NO_PRIV
- {
- void *pn = calloc(1, sizeof(struct pcap_netmap));
- if (pn == NULL)
- return NULL;
- p = pcap_create_common(device, ebuf);
- if (p == NULL) {
- free(pn);
- return NULL;
- }
- SET_PRIV(p, pn);
- }
-#else
- p = pcap_create_common(device, ebuf, sizeof (struct pcap_netmap));
+ p = pcap_create_common(ebuf, sizeof (struct pcap_netmap));
if (p == NULL)
return (NULL);
-#endif
p->activate_op = pcap_netmap_activate;
return (p);
}
OpenPOWER on IntegriCloud