]> The Tcpdump Group git mirrors - libpcap/commitdiff
Isn't Linux fun? You might have a distribution whose kernel is a shiny
authorguy <guy>
Sat, 6 Jul 2002 21:22:35 +0000 (21:22 +0000)
committerguy <guy>
Sat, 6 Jul 2002 21:22:35 +0000 (21:22 +0000)
new 2.2-or-later kernel, with PF_PACKET sockets including SOL_PACKET,
but with an older version of the C library whose headers don't define
SOL_PACKET.

On those systems, define SOL_PACKET to have the value it has in the
2.2.0 kernel; this means we can get rid of the "#ifdef
SOL_PACKET"/#endif stuff wrapped around the code to turn promiscuous
mode on or off (we don't want that #ifdeffed out, as if it's absent we
won't pay attention to the "promiscuous mode" flag argument to
"pcap_open_live()").

pcap-linux.c

index a961415c6f46510fcc72ce587709b25bf98fda82..aed291fc9a45c16de47a8d4222e57053800f9765 100644 (file)
@@ -26,7 +26,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.81 2002-06-11 17:04:47 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.82 2002-07-06 21:22:35 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -156,6 +156,16 @@ typedef int                socklen_t;
 #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
 
 /*
@@ -1224,7 +1234,6 @@ live_open_new(pcap_t *handle, char *device, int promisc,
 
                /* Select promiscuous mode on/off */
 
-#ifdef SOL_PACKET
                /*
                 * Hmm, how can we set promiscuous mode on all interfaces?
                 * I am not sure if that is possible at all.
@@ -1243,7 +1252,6 @@ live_open_new(pcap_t *handle, char *device, int promisc,
                                break;
                        }
                }
-#endif
 
                /* Save the socket FD in the pcap structure */