]> The Tcpdump Group git mirrors - libpcap/commitdiff
Merge pull request #865 from Oppen/misc-warnings
authorGuy Harris <[email protected]>
Wed, 16 Oct 2019 15:51:27 +0000 (08:51 -0700)
committerGitHub <[email protected]>
Wed, 16 Oct 2019 15:51:27 +0000 (08:51 -0700)
Remove dead stores.

configure
pcap-linux.c

index 88dbc00529c3530cd9449798d830bd0737cc1ba9..48849d65dfbcfd71dd0ca3eb1415bacb0602764c 100755 (executable)
--- a/configure
+++ b/configure
@@ -6606,11 +6606,6 @@ done
                # No prizes for guessing this one.
                #
                V_PCAP=linux
-
-               #
-               # XXX - this won't work with older kernels that have
-               # SOCK_PACKET sockets but not PF_PACKET sockets.
-               #
                VALGRINDTEST_SRC=valgrindtest.c
        elif test "$ac_cv_header_net_pfilt_h" = yes; then
                #
index 600af4aa9dd6dd224536d972d8459f97e69eafc1..0f8c104938894adda43c9e611d232b1f0bcc4671 100644 (file)
 typedef int            socklen_t;
 #endif
 
-#ifndef MSG_TRUNC
-/*
- * This is being compiled on a system that lacks MSG_TRUNC; define it
- * with the value it has in the 2.2 and later kernels, so that, on
- * those kernels, when we pass it in the flags argument to "recvfrom()"
- * we're passing the right value and thus get the MSG_TRUNC behavior
- * we want.  (We don't get that behavior on 2.0[.x] kernels, because
- * they didn't support MSG_TRUNC.)
- */
-#define MSG_TRUNC      0x20
-#endif
-
-#ifndef SOL_PACKET
-/*
- * This is being compiled on a system that lacks SOL_PACKET; define it
- * with the value it has in the 2.2 and later kernels, so that we can
- * set promiscuous mode in the good modern way rather than the old
- * 2.0-kernel crappy way.
- */
-#define SOL_PACKET     263
-#endif
-
 #define MAX_LINKHEADER_SIZE    256
 
 /*
@@ -211,7 +189,7 @@ typedef int         socklen_t;
 #define BIGGER_THAN_ALL_MTUS   (64*1024)
 
 /*
- * Private data for capturing on Linux SOCK_PACKET or PF_PACKET sockets.
+ * Private data for capturing on Linux PF_PACKET sockets.
  */
 struct pcap_linux {
        u_int   packets_read;   /* count of packets read with recvfrom() */
@@ -247,9 +225,8 @@ struct pcap_linux {
 /*
  * Stuff to do when we close.
  */
-#define MUST_CLEAR_PROMISC     0x00000001      /* clear promiscuous mode */
-#define MUST_CLEAR_RFMON       0x00000002      /* clear rfmon (monitor) mode */
-#define MUST_DELETE_MONIF      0x00000004      /* delete monitor-mode interface */
+#define MUST_CLEAR_RFMON       0x00000001      /* clear rfmon (monitor) mode */
+#define MUST_DELETE_MONIF      0x00000002      /* delete monitor-mode interface */
 
 /*
  * Prototypes for internal functions and methods.
@@ -1142,45 +1119,6 @@ static void      pcap_cleanup_linux( pcap_t *handle )
                 * There's something we have to do when closing this
                 * pcap_t.
                 */
-               if (handlep->must_do_on_close & MUST_CLEAR_PROMISC) {
-                       /*
-                        * We put the interface into promiscuous mode;
-                        * take it out of promiscuous mode.
-                        *
-                        * XXX - if somebody else wants it in promiscuous
-                        * mode, this code cannot know that, so it'll take
-                        * it out of promiscuous mode.  That's not fixable
-                        * in 2.0[.x] kernels.
-                        */
-                       memset(&ifr, 0, sizeof(ifr));
-                       pcap_strlcpy(ifr.ifr_name, handlep->device,
-                           sizeof(ifr.ifr_name));
-                       if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) == -1) {
-                               fprintf(stderr,
-                                   "Can't restore interface %s flags (SIOCGIFFLAGS failed: %s).\n"
-                                   "Please adjust manually.\n"
-                                   "Hint: This can't happen with Linux >= 2.2.0.\n",
-                                   handlep->device, strerror(errno));
-                       } else {
-                               if (ifr.ifr_flags & IFF_PROMISC) {
-                                       /*
-                                        * Promiscuous mode is currently on;
-                                        * turn it off.
-                                        */
-                                       ifr.ifr_flags &= ~IFF_PROMISC;
-                                       if (ioctl(handle->fd, SIOCSIFFLAGS,
-                                           &ifr) == -1) {
-                                               fprintf(stderr,
-                                                   "Can't restore interface %s flags (SIOCSIFFLAGS failed: %s).\n"
-                                                   "Please adjust manually.\n"
-                                                   "Hint: This can't happen with Linux >= 2.2.0.\n",
-                                                   handlep->device,
-                                                   strerror(errno));
-                                       }
-                               }
-                       }
-               }
-
 #ifdef HAVE_LIBNL
                if (handlep->must_do_on_close & MUST_DELETE_MONIF) {
                        ret = nl80211_init(handle, &nlstate, handlep->device);
@@ -2568,7 +2506,7 @@ scan_proc_net_dev(pcap_if_list_t *devlistp, char *errbuf)
 static const char any_descr[] = "Pseudo-device that captures on all interfaces";
 
 /*
- * A SOCK_PACKET or PF_PACKET socket can be bound to any network interface.
+ * A PF_PACKET socket can be bound to any network interface.
  */
 static int
 can_be_bound(const char *name _U_)