From: Denis Ovsienko Date: Sat, 27 Jan 2024 22:31:41 +0000 (+0000) Subject: Retire Tru64 UNIX and Ultrix support. X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/1f67d31e1ea8af8dc9546bb102320a1825a15460 Retire Tru64 UNIX and Ultrix support. The last Tru64 UNIX release was in 2010, the last Ultrix release was in 1995; both operating systems have Packet Filter as the packet capture interface. See also commits f377e14, d4c9c24 and 25eb65a. In extract.h leave the condition that tests for __alpha or __alpha__ intact because Linux, NetBSD and OpenBSD still support Alpha hardware. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4296d787..e6a30353 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1887,7 +1887,6 @@ else() check_symbol_exists(BIOCSETIF "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;net/bpf.h;net/if.h" BPF_H_DEFINES_BIOCSETIF) endif(HAVE_SYS_IOCCOM_H) endif(HAVE_NET_BPF_H) - check_include_file(net/pfilt.h HAVE_NET_PFILT_H) check_include_file(linux/socket.h HAVE_LINUX_SOCKET_H) check_include_file(net/raw.h HAVE_NET_RAW_H) check_include_file(sys/dlpi.h HAVE_SYS_DLPI_H) @@ -1905,11 +1904,6 @@ else() # No prizes for guessing this one. # set(PCAP_TYPE linux) - elseif(HAVE_NET_PFILT_H) - # - # DEC OSF/1, Digital UNIX, Tru64 UNIX - # - set(PCAP_TYPE pf) elseif(HAVE_NET_RAW_H) # # IRIX snoop. @@ -3052,16 +3046,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "IRIX" OR CMAKE_SYSTEM_NAME STREQUAL "IRIX64") # set(MAN_FILE_FORMATS 4) set(MAN_MISC_INFO 5) -elseif(CMAKE_SYSTEM_NAME STREQUAL "OSF1") - # - # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX. - # Use Tru64 UNIX conventions for man pages; they're the same as the - # System V conventions except that they use section 8 for - # administrative commands and daemons. - # - set(MAN_FILE_FORMATS 4) - set(MAN_MISC_INFO 5) - set(MAN_DEVICES 7) elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") # # SunOS 5.x. @@ -3476,12 +3460,6 @@ if(NOT MSVC) # default, added to the run-time search path, so we don't need to # supply them. # - # For Tru64 UNIX, "-rpath" works with DEC's^WCompaq's^WHP's C - # compiler for Alpha, but isn't documented as working with GCC, and - # no GCC-compatible option is documented as working with the DEC - # compiler. If anybody needs this on Tru64/Alpha, they're welcome - # to figure out a way to make it work. - # # This must *not* depend on the compiler, as, on platforms where # there's a GCC-compatible compiler and a vendor compiler, we need # to work with both. diff --git a/INSTALL.md b/INSTALL.md index d5137a94..c3717e48 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -294,7 +294,6 @@ in `/usr/include/sys/dlpi.h`, and find the corresponding value. pcap-netmap.h - netmap support pcap-npf.c - Npcap capture support pcap-null.c - dummy monitor support (allows offline use of libpcap) - pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support pcap-rdmasniff.c - RDMA/InfiniBand capture support pcap-rdmasniff.h - RDMA/InfiniBand capture support pcap-rpcap.c - RPCAP protocol capture support diff --git a/Makefile.in b/Makefile.in index 807e8e8b..ceb96af3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -326,7 +326,6 @@ EXTRA_DIST = \ pcap-netmap.h \ pcap-npf.c \ pcap-null.c \ - pcap-pf.c \ pcap-rdmasniff.c \ pcap-rdmasniff.h \ pcap-rpcap.c \ diff --git a/README.md b/README.md index e38b9a15..3bb9af73 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,7 @@ with the underlying kernel subsystem, but this is not yet implemented. BPF is standard in 4.4BSD, BSD/OS, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, macOS, and Solaris 11; an older, modified and undocumented version -is standard in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the -packetfilter interface but has been extended to accept BPF filters -(which libpcap utilizes). +is standard in AIX. Linux has a number of BPF based systems, and libpcap does not support any of the eBPF mechanisms as yet, although it supports many of the diff --git a/aclocal.m4 b/aclocal.m4 index 34594aa6..a2ee768f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -160,28 +160,6 @@ AC_DEFUN(AC_LBL_C_INIT, $1="$$1 -xansi -signed -g3" ;; - osf*) - # - # Presumed to be DEC OSF/1, Digital UNIX, or - # Tru64 UNIX. - # - # The DEC C compiler, which is what we presume we're - # using, doesn't exit with a non-zero exit status if we - # hand it an invalid -W flag, can't be forced to do - # so, and doesn't handle GCC-style -W flags, so we - # don't want to try using GCC-style -W flags. - # - ac_lbl_cc_dont_try_gcc_dashW=yes - # - # -g is equivalent to -g2, which turns off - # optimization; we choose -g3, which generates - # debugging information but doesn't turn off - # optimization (even if the optimization would - # cause inaccuracies in debugging). - # - $1="$$1 -g3" - ;; - solaris*) # # Assumed to be Sun C, which requires -errwarn to force @@ -351,9 +329,9 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT, # case "$host_os" in - irix*|osf*|darwin*) + irix*|darwin*) # - # MIPS C for IRIX, DEC C, and clang all use -M. + # MIPS C for IRIX and Clang use -M. # ac_lbl_dependency_flag="-M" ;; @@ -461,7 +439,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, aix*) ;; - freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*|gnu*) + freebsd*|netbsd*|openbsd*|dragonfly*|linux*|haiku*|midipix*|gnu*) # # Platforms where the C compiler is GCC or accepts # compatible command-line arguments, and the linker @@ -571,16 +549,6 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, # ;; - osf*) - # - # Presumed to be DEC OSF/1, Digital UNIX, or - # Tru64 UNIX. - # - V_SHLIB_CMD="\$(CC)" - V_SHLIB_OPT="-shared" - V_SONAME_OPT="-soname " - ;; - solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic" V_SHLIB_CMD="\$(CC)" diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index 162a1af3..f1fece81 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -108,9 +108,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NET_IF_MEDIA_H 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NET_PFILT_H 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_NET_RAW_H 1 diff --git a/configure.ac b/configure.ac index 2765650f..af18a2ea 100644 --- a/configure.ac +++ b/configure.ac @@ -733,7 +733,6 @@ else [ac_cv_lbl_bpf_h_defines_biocsetif=no])) AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif) fi - AC_CHECK_HEADERS(net/pfilt.h) AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h) AC_CHECK_HEADERS(config/HaikuConfig.h) AC_CHECK_HEADERS(hurd.h) @@ -763,11 +762,6 @@ else # V_PCAP=linux VALGRINDTEST_SRC=valgrindtest.c - elif test "$ac_cv_header_net_pfilt_h" = yes; then - # - # DEC OSF/1, Digital UNIX, Tru64 UNIX - # - V_PCAP=pf elif test "$ac_cv_header_net_raw_h" = yes; then # # IRIX snoop. @@ -1113,13 +1107,6 @@ bpf) fi ;; -pf) - # - # Capture module - # - PLATFORM_C_SRC="pcap-pf.c" - ;; - snoop) # # Capture module @@ -2400,20 +2387,6 @@ linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*) DYEXT="so" ;; -osf*) - DYEXT="so" - - # - # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX. - # Use Tru64 UNIX conventions for man pages; they're the same as - # the System V conventions except that they use section 8 for - # administrative commands and daemons. - # - MAN_FILE_FORMATS=4 - MAN_MISC_INFO=5 - MAN_DEVICES=7 - ;; - solaris*) AC_DEFINE(HAVE_SOLARIS,1,[On solaris]) @@ -3112,12 +3085,6 @@ fi # With the HP-UX linker, directories specified with -L are, by default, # added to the run-time search path, so we don't need to supply them. # -# For Tru64 UNIX, "-rpath" works with DEC's^WCompaq's^WHP's C compiler -# for Alpha, but isn't documented as working with GCC, and no GCC- -# compatible option is documented as working with the DEC compiler. -# If anybody needs this on Tru64/Alpha, they're welcome to figure out a -# way to make it work. -# # This must *not* depend on the compiler, as, on platforms where there's # a GCC-compatible compiler and a vendor compiler, we need to work with # both. diff --git a/gencode.c b/gencode.c index 425eb3a5..d3c79e92 100644 --- a/gencode.c +++ b/gencode.c @@ -6864,15 +6864,6 @@ stringtoport(compiler_state_t *cstate, const char *string, size_t string_size, free(cpy); break; } -#if defined(ultrix) || defined(__osf__) - /* Special hack in case NFS isn't in /etc/services */ - if (strcmp(cpy, "nfs") == 0) { - val = 2049; - *proto = PROTO_UNDEF; - free(cpy); - break; - } -#endif bpf_set_error(cstate, "'%s' is not a valid port", cpy); free(cpy); longjmp(cstate->top_ctx, 1); diff --git a/nametoaddr.c b/nametoaddr.c index 42f309d3..35ec1101 100644 --- a/nametoaddr.c +++ b/nametoaddr.c @@ -298,7 +298,7 @@ pcap_nametonetaddr(const char *name) * getnetbyname() that uses thread-specific data, in which * case we're thread-safe (sufficiently recent FreeBSD, * sufficiently recent Darwin-based OS, sufficiently recent - * HP-UX, sufficiently recent Tru64 UNIX), or we have the + * HP-UX, or we have the * traditional getnetbyname() (everything else, including * current NetBSD and OpenBSD), in which case we're not * thread-safe. @@ -448,14 +448,6 @@ pcap_nametoport(const char *name, int *port, int *proto) *proto = IPPROTO_UDP; return 1; } -#if defined(ultrix) || defined(__osf__) - /* Special hack in case NFS isn't in /etc/services */ - if (strcmp(name, "nfs") == 0) { - *port = 2049; - *proto = PROTO_UNDEF; - return 1; - } -#endif return 0; } @@ -547,7 +539,7 @@ pcap_nametoproto(const char *str) * getprotobyname() that uses thread-specific data, in which * case we're thread-safe (sufficiently recent FreeBSD, * sufficiently recent Darwin-based OS, sufficiently recent - * HP-UX, sufficiently recent Tru64 UNIX, Windows), or we have + * HP-UX, Windows), or we have * the traditional getprotobyname() (everything else, including * current NetBSD and OpenBSD), in which case we're not * thread-safe. diff --git a/pcap-pf.c b/pcap-pf.c deleted file mode 100644 index 49322c80..00000000 --- a/pcap-pf.c +++ /dev/null @@ -1,682 +0,0 @@ -/* - * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may 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. - * - * packet filter subroutines for tcpdump - * Extraction/creation by Jeffrey Mogul, DECWRL - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -struct mbuf; -struct rtentry; -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/* - * Make "pcap.h" not include "pcap/bpf.h"; we are going to include the - * native OS version, as we need various BPF ioctls from it. - */ -#define PCAP_DONT_INCLUDE_PCAP_BPF_H -#include - -#include "pcap-int.h" - -#ifdef HAVE_OS_PROTO_H -#include "os-proto.h" -#endif - -/* - * FDDI packets are padded to make everything line up on a nice boundary. - */ -#define PCAP_FDDIPAD 3 - -/* - * Private data for capturing on Ultrix and DEC OSF/1^WDigital UNIX^W^W - * Tru64 UNIX packetfilter devices. - */ -struct pcap_pf { - int filtering_in_kernel; /* using kernel filter */ - u_long TotPkts; /* can't overflow for 79 hrs on ether */ - u_long TotAccepted; /* count accepted by filter */ - u_long TotDrops; /* count of dropped packets */ - long TotMissed; /* missed by i/f during this run */ - long OrigMissed; /* missed by i/f before this run */ -}; - -static int pcap_setfilter_pf(pcap_t *, struct bpf_program *); - -/* - * BUFSPACE is the size in bytes of the packet read buffer. Most tcpdump - * applications aren't going to need more than 200 bytes of packet header - * and the read shouldn't return more packets than packetfilter's internal - * queue limit (bounded at 256). - */ -#define BUFSPACE (200 * 256) - -static int -pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user) -{ - struct pcap_pf *pf = pc->priv; - register u_char *p, *bp; - register int cc, n, buflen, inc; - register struct enstamp *sp; - struct enstamp stamp; - register u_int pad; - - again: - cc = pc->cc; - if (cc == 0) { - cc = read(pc->fd, (char *)pc->buffer + pc->offset, pc->bufsize); - if (cc < 0) { - if (errno == EWOULDBLOCK) - return (0); - if (errno == EINVAL && - lseek(pc->fd, 0L, SEEK_CUR) + pc->bufsize < 0) { - /* - * Due to a kernel bug, after 2^31 bytes, - * the kernel file offset overflows and - * read fails with EINVAL. The lseek() - * to 0 will fix things. - */ - (void)lseek(pc->fd, 0L, SEEK_SET); - goto again; - } - pcapint_fmt_errmsg_for_errno(pc->errbuf, - sizeof(pc->errbuf), errno, "pf read"); - return (-1); - } - bp = pc->buffer + pc->offset; - } else - bp = pc->bp; - /* - * Loop through each packet. - * - * This assumes that a single buffer of packets will have - * <= INT_MAX packets, so the packet count doesn't overflow. - */ - n = 0; - pad = pc->fddipad; - while (cc > 0) { - /* - * Has "pcap_breakloop()" been called? - * If so, return immediately - if we haven't read any - * packets, clear the flag and return -2 to indicate - * that we were told to break out of the loop, otherwise - * leave the flag set, so that the *next* call will break - * out of the loop without having read any packets, and - * return the number of packets we've processed so far. - */ - if (pc->break_loop) { - if (n == 0) { - pc->break_loop = 0; - return (-2); - } else { - pc->cc = cc; - pc->bp = bp; - return (n); - } - } - if (cc < sizeof(*sp)) { - snprintf(pc->errbuf, sizeof(pc->errbuf), - "pf short read (%d)", cc); - return (-1); - } - if ((long)bp & 3) { - sp = &stamp; - memcpy((char *)sp, (char *)bp, sizeof(*sp)); - } else - sp = (struct enstamp *)bp; - if (sp->ens_stamplen != sizeof(*sp)) { - snprintf(pc->errbuf, sizeof(pc->errbuf), - "pf short stamplen (%d)", - sp->ens_stamplen); - return (-1); - } - - p = bp + sp->ens_stamplen; - buflen = sp->ens_count; - if (buflen > pc->snapshot) - buflen = pc->snapshot; - - /* Calculate inc before possible pad update */ - inc = ENALIGN(buflen + sp->ens_stamplen); - cc -= inc; - bp += inc; - pf->TotPkts++; - pf->TotDrops += sp->ens_dropped; - pf->TotMissed = sp->ens_ifoverflows; - if (pf->OrigMissed < 0) - pf->OrigMissed = pf->TotMissed; - - /* - * Short-circuit evaluation: if using BPF filter - * in kernel, no need to do it now - we already know - * the packet passed the filter. - * - * Note: the filter code was generated assuming - * that pc->fddipad was the amount of padding - * before the header, as that's what's required - * in the kernel, so we run the filter before - * skipping that padding. - */ - if (pf->filtering_in_kernel || - pcapint_filter(pc->fcode.bf_insns, p, sp->ens_count, buflen)) { - struct pcap_pkthdr h; - pf->TotAccepted++; - h.ts = sp->ens_tstamp; - h.len = sp->ens_count - pad; - p += pad; - buflen -= pad; - h.caplen = buflen; - (*callback)(user, &h, p); - if (++n >= cnt && !PACKET_COUNT_IS_UNLIMITED(cnt)) { - pc->cc = cc; - pc->bp = bp; - return (n); - } - } - } - pc->cc = 0; - return (n); -} - -static int -pcap_inject_pf(pcap_t *p, const void *buf, int size) -{ - int ret; - - ret = write(p->fd, buf, size); - if (ret == -1) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "send"); - return (-1); - } - return (ret); -} - -static int -pcap_stats_pf(pcap_t *p, struct pcap_stat *ps) -{ - struct pcap_pf *pf = p->priv; - - /* - * If packet filtering is being done in the kernel: - * - * "ps_recv" counts only packets that passed the filter. - * This does not include packets dropped because we - * ran out of buffer space. (XXX - perhaps it should, - * by adding "ps_drop" to "ps_recv", for compatibility - * with some other platforms. On the other hand, on - * some platforms "ps_recv" counts only packets that - * passed the filter, and on others it counts packets - * that didn't pass the filter....) - * - * "ps_drop" counts packets that passed the kernel filter - * (if any) but were dropped because the input queue was - * full. - * - * "ps_ifdrop" counts packets dropped by the network - * interface (regardless of whether they would have passed - * the input filter, of course). - * - * If packet filtering is not being done in the kernel: - * - * "ps_recv" counts only packets that passed the filter. - * - * "ps_drop" counts packets that were dropped because the - * input queue was full, regardless of whether they passed - * the userland filter. - * - * "ps_ifdrop" counts packets dropped by the network - * interface (regardless of whether they would have passed - * the input filter, of course). - * - * These statistics don't include packets not yet read from - * the kernel by libpcap, but they may include packets not - * yet read from libpcap by the application. - */ - ps->ps_recv = pf->TotAccepted; - ps->ps_drop = pf->TotDrops; - ps->ps_ifdrop = pf->TotMissed - pf->OrigMissed; - return (0); -} - -/* - * We include the OS's , not our "pcap/bpf.h", so we probably - * don't get DLT_DOCSIS defined. - */ -#ifndef DLT_DOCSIS -#define DLT_DOCSIS 143 -#endif - -static int -pcap_activate_pf(pcap_t *p) -{ - struct pcap_pf *pf = p->priv; - short enmode; - int backlog = -1; /* request the most */ - struct enfilter Filter; - struct endevp devparams; - int err; - - /* - * Initially try a read/write open (to allow the inject - * method to work). If that fails due to permission - * issues, fall back to read-only. This allows a - * non-root user to be granted specific access to pcap - * capabilities via file permissions. - * - * XXX - we should have an API that has a flag that - * controls whether to open read-only or read-write, - * so that denial of permission to send (or inability - * to send, if sending packets isn't supported on - * the device in question) can be indicated at open - * time. - * - * XXX - we assume here that "pfopen()" does not, in fact, modify - * its argument, even though it takes a "char *" rather than a - * "const char *" as its first argument. That appears to be - * the case, at least on Digital UNIX 4.0. - * - * XXX - is there an error that means "no such device"? Is - * there one that means "that device doesn't support pf"? - */ - p->fd = pfopen(p->opt.device, O_RDWR); - if (p->fd == -1 && errno == EACCES) - p->fd = pfopen(p->opt.device, O_RDONLY); - if (p->fd < 0) { - if (errno == EACCES) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "pf open: %s: Permission denied\n" -"your system may not be properly configured; see the packetfilter(4) man page", - p->opt.device); - err = PCAP_ERROR_PERM_DENIED; - } else { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "pf open: %s", p->opt.device); - err = PCAP_ERROR; - } - goto bad; - } - - /* - * Turn a negative snapshot value (invalid), a snapshot value of - * 0 (unspecified), or a value bigger than the normal maximum - * value, into the maximum allowed value. - * - * If some application really *needs* a bigger snapshot - * length, we should just increase MAXIMUM_SNAPLEN. - */ - if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN) - p->snapshot = MAXIMUM_SNAPLEN; - - pf->OrigMissed = -1; - enmode = ENTSTAMP|ENNONEXCL; - if (!p->opt.immediate) - enmode |= ENBATCH; - if (p->opt.promisc) - enmode |= ENPROMISC; - if (ioctl(p->fd, EIOCMBIS, (caddr_t)&enmode) < 0) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "EIOCMBIS"); - err = PCAP_ERROR; - goto bad; - } -#ifdef ENCOPYALL - /* Try to set COPYALL mode so that we see packets to ourself */ - enmode = ENCOPYALL; - (void)ioctl(p->fd, EIOCMBIS, (caddr_t)&enmode);/* OK if this fails */ -#endif - /* set the backlog */ - if (ioctl(p->fd, EIOCSETW, (caddr_t)&backlog) < 0) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "EIOCSETW"); - err = PCAP_ERROR; - goto bad; - } - /* discover interface type */ - if (ioctl(p->fd, EIOCDEVP, (caddr_t)&devparams) < 0) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "EIOCDEVP"); - err = PCAP_ERROR; - goto bad; - } - /* HACK: to compile prior to Ultrix 4.2 */ -#ifndef ENDT_FDDI -#define ENDT_FDDI 4 -#endif - switch (devparams.end_dev_type) { - - case ENDT_10MB: - p->linktype = DLT_EN10MB; - p->offset = 2; - /* - * This is (presumably) a real Ethernet capture; give it a - * link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so - * that an application can let you choose it, in case you're - * capturing DOCSIS traffic that a Cisco Cable Modem - * Termination System is putting out onto an Ethernet (it - * doesn't put an Ethernet header onto the wire, it puts raw - * DOCSIS frames out on the wire inside the low-level - * Ethernet framing). - */ - p->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); - if (p->dlt_list == NULL) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "malloc"); - err = PCAP_ERROR; - goto bad; - } - p->dlt_list[0] = DLT_EN10MB; - p->dlt_list[1] = DLT_DOCSIS; - p->dlt_count = 2; - break; - - case ENDT_FDDI: - p->linktype = DLT_FDDI; - break; - -#ifdef ENDT_SLIP - case ENDT_SLIP: - p->linktype = DLT_SLIP; - break; -#endif - -#ifdef ENDT_PPP - case ENDT_PPP: - p->linktype = DLT_PPP; - break; -#endif - -#ifdef ENDT_LOOPBACK - case ENDT_LOOPBACK: - /* - * It appears to use Ethernet framing, at least on - * Digital UNIX 4.0. - */ - p->linktype = DLT_EN10MB; - p->offset = 2; - break; -#endif - -#ifdef ENDT_TRN - case ENDT_TRN: - p->linktype = DLT_IEEE802; - break; -#endif - - default: - /* - * XXX - what about ENDT_IEEE802? The pfilt.h header - * file calls this "IEEE 802 networks (non-Ethernet)", - * but that doesn't specify a specific link layer type; - * it could be 802.4, or 802.5 (except that 802.5 is - * ENDT_TRN), or 802.6, or 802.11, or.... That's why - * DLT_IEEE802 was hijacked to mean Token Ring in various - * BSDs, and why we went along with that hijacking. - * - * XXX - what about ENDT_HDLC and ENDT_NULL? - * Presumably, as ENDT_OTHER is just "Miscellaneous - * framing", there's not much we can do, as that - * doesn't specify a particular type of header. - */ - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, - "unknown data-link type %u", devparams.end_dev_type); - err = PCAP_ERROR; - goto bad; - } - /* set truncation */ - if (p->linktype == DLT_FDDI) { - p->fddipad = PCAP_FDDIPAD; - - /* packetfilter includes the padding in the snapshot */ - p->snapshot += PCAP_FDDIPAD; - } else - p->fddipad = 0; - if (ioctl(p->fd, EIOCTRUNCATE, (caddr_t)&p->snapshot) < 0) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "EIOCTRUNCATE"); - err = PCAP_ERROR; - goto bad; - } - /* accept all packets */ - memset(&Filter, 0, sizeof(Filter)); - Filter.enf_Priority = 37; /* anything > 2 */ - Filter.enf_FilterLen = 0; /* means "always true" */ - if (ioctl(p->fd, EIOCSETF, (caddr_t)&Filter) < 0) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "EIOCSETF"); - err = PCAP_ERROR; - goto bad; - } - - if (p->opt.timeout != 0) { - struct timeval timeout; - timeout.tv_sec = p->opt.timeout / 1000; - timeout.tv_usec = (p->opt.timeout * 1000) % 1000000; - if (ioctl(p->fd, EIOCSRTIMEOUT, (caddr_t)&timeout) < 0) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "EIOCSRTIMEOUT"); - err = PCAP_ERROR; - goto bad; - } - } - - p->bufsize = BUFSPACE; - p->buffer = malloc(p->bufsize + p->offset); - if (p->buffer == NULL) { - pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, - errno, "malloc"); - err = PCAP_ERROR; - goto bad; - } - - /* - * "select()" and "poll()" work on packetfilter devices. - */ - p->selectable_fd = p->fd; - - p->read_op = pcap_read_pf; - p->inject_op = pcap_inject_pf; - p->setfilter_op = pcap_setfilter_pf; - p->setdirection_op = NULL; /* Not implemented. */ - p->set_datalink_op = NULL; /* can't change data link type */ - p->getnonblock_op = pcapint_getnonblock_fd; - p->setnonblock_op = pcapint_setnonblock_fd; - p->stats_op = pcap_stats_pf; - - return (0); - bad: - pcapint_cleanup_live_common(p); - return (err); -} - -pcap_t * -pcapint_create_interface(const char *device _U_, char *ebuf) -{ - pcap_t *p; - - p = PCAP_CREATE_COMMON(ebuf, struct pcap_pf); - if (p == NULL) - return (NULL); - - p->activate_op = pcap_activate_pf; - return (p); -} - -/* - * XXX - is there an error from pfopen() that means "no such device"? - * Is there one that means "that device doesn't support pf"? - */ -static int -can_be_bound(const char *name _U_) -{ - return (1); -} - -static int -get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_) -{ - /* - * Nothing we can do other than mark loopback devices as "the - * connected/disconnected status doesn't apply". - * - * XXX - is there a way to find out whether an adapter has - * something plugged into it? - */ - if (*flags & PCAP_IF_LOOPBACK) { - /* - * Loopback devices aren't wireless, and "connected"/ - * "disconnected" doesn't apply to them. - */ - *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE; - return (0); - } - return (0); -} - -int -pcapint_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf) -{ - return (pcapint_findalldevs_interfaces(devlistp, errbuf, can_be_bound, - get_if_flags)); -} - -static int -pcap_setfilter_pf(pcap_t *p, struct bpf_program *fp) -{ - struct pcap_pf *pf = p->priv; - struct bpf_version bv; - - /* - * See if BIOCVERSION works. If not, we assume the kernel doesn't - * support BPF-style filters (it's not documented in the bpf(7) - * or packetfilter(7) man pages, but the code used to fail if - * BIOCSETF worked but BIOCVERSION didn't, and I've seen it do - * kernel filtering in DU 4.0, so presumably BIOCVERSION works - * there, at least). - */ - if (ioctl(p->fd, BIOCVERSION, (caddr_t)&bv) >= 0) { - /* - * OK, we have the version of the BPF interpreter; - * is it the same major version as us, and the same - * or better minor version? - */ - if (bv.bv_major == BPF_MAJOR_VERSION && - bv.bv_minor >= BPF_MINOR_VERSION) { - /* - * Yes. Try to install the filter. - */ - if (ioctl(p->fd, BIOCSETF, (caddr_t)fp) < 0) { - pcapint_fmt_errmsg_for_errno(p->errbuf, - sizeof(p->errbuf), errno, "BIOCSETF"); - return (-1); - } - - /* - * OK, that succeeded. We're doing filtering in - * the kernel. (We assume we don't have a - * userland filter installed - that'd require - * a previous version check to have failed but - * this one to succeed.) - * - * XXX - this message should be supplied to the - * application as a warning of some sort, - * except that if it's a GUI application, it's - * not clear that it should be displayed in - * a window to annoy the user. - */ - fprintf(stderr, "tcpdump: Using kernel BPF filter\n"); - pf->filtering_in_kernel = 1; - - /* - * Discard any previously-received packets, - * as they might have passed whatever filter - * was formerly in effect, but might not pass - * this filter (BIOCSETF discards packets buffered - * in the kernel, so you can lose packets in any - * case). - */ - p->cc = 0; - return (0); - } - - /* - * We can't use the kernel's BPF interpreter; don't give - * up, just log a message and be inefficient. - * - * XXX - this should really be supplied to the application - * as a warning of some sort. - */ - fprintf(stderr, - "tcpdump: Requires BPF language %d.%d or higher; kernel is %d.%d\n", - BPF_MAJOR_VERSION, BPF_MINOR_VERSION, - bv.bv_major, bv.bv_minor); - } - - /* - * We couldn't do filtering in the kernel; do it in userland. - */ - if (pcapint_install_bpf_program(p, fp) < 0) - return (-1); - - /* - * XXX - this message should be supplied by the application as - * a warning of some sort. - */ - fprintf(stderr, "tcpdump: Filtering in user process\n"); - pf->filtering_in_kernel = 0; - return (0); -} - -/* - * Libpcap version string. - */ -const char * -pcap_lib_version(void) -{ - return (PCAP_VERSION_STRING); -} diff --git a/pcap.3pcap.in b/pcap.3pcap.in index ab84d26e..7d4f88ee 100644 --- a/pcap.3pcap.in +++ b/pcap.3pcap.in @@ -321,22 +321,6 @@ those capability bits to be given to particular accounts and to cause those bits to be set on a user's initial processes when they log in, in which case you must have CAP_NET_RAW in order to capture. .TP -.B Under ULTRIX and Digital UNIX/Tru64 UNIX: -Any user may capture network traffic. -However, no user (not even the super-user) can capture in promiscuous -mode on an interface unless the super-user has enabled promiscuous-mode -operation on that interface using -.IR pfconfig (8), -and no user (not even the super-user) can capture unicast traffic -received by or sent by the machine on an interface unless the super-user -has enabled copy-all-mode operation on that interface using -.IR pfconfig , -so -.I useful -packet capture on an interface probably requires that either -promiscuous-mode or copy-all-mode operation, or both modes of -operation, be enabled on that interface. -.TP .B Under BSD (this includes macOS): You must have read access to .I /dev/bpf* diff --git a/pcap_breakloop.3pcap b/pcap_breakloop.3pcap index b5e59883..ebea878c 100644 --- a/pcap_breakloop.3pcap +++ b/pcap_breakloop.3pcap @@ -84,7 +84,7 @@ If a non-zero packet buffer timeout is set on the and you are capturing on a network interface, the thread will be unblocked with the timeout expires. This is not guaranteed to happen unless at least one packet has arrived; the only platforms on which it -happens are macOS, the BSDs, Solaris 11, AIX, Tru64 UNIX, and Windows. +happens are macOS, the BSDs, Solaris 11, AIX, and Windows. .PP If you want to ensure that the loop will eventually be unblocked on any other platforms, or unblocked when capturing on a device other than a diff --git a/pcap_set_immediate_mode.3pcap.in b/pcap_set_immediate_mode.3pcap.in index 95c9cffb..ff15600e 100644 --- a/pcap_set_immediate_mode.3pcap.in +++ b/pcap_set_immediate_mode.3pcap.in @@ -68,19 +68,6 @@ turned on by using a read timeout of 0 when opening the device (this will not provide immediate delivery of packets on other platforms, so don't assume it's sufficient); .IP -on Digital UNIX/Tru64 UNIX, immediate mode must be turned on by doing a -.B BIOCMBIC -.BR ioctl (), -as documented in -.BR packetfilter (7), -to clear the -.B ENBATCH -flag on the descriptor returned by -.BR pcap_fileno (3PCAP), -after -.BR pcap_activate (3PCAP) -is called; -.IP on Windows, immediate mode must be turned on by calling .BR pcap_setmintocopy () with a size of 0.