> On Wed, Jan 17, 2001 at 10:47:36PM +0100, Denis Ducamp wrote:
> > I took the last version from the cvs server and I'm pleased to say that it
> > works on libc5+2.2.17 kernel and libc5+2.4.0-test4 kernel.
>
> And Slackware 7.1 (glibc2.1.3 + kernel 2.2.16)
> And Slackware 7.0 (glibc2.1.2 + kernel 2.2.17)
...and not Red Hat 5.2(?) (glibc(?) whatever + kernel 2.0.something).
Unfortunately, whilst that system does define PF_PACKET (from
"/usr/include/socketbits.h" or something such as that), and does have a
<linux/if_packet.h> header file, <linux/if_packet.h>, not surprisingly,
doesn't define any PF_PACKET socket stuff, so "pcap-linux.c" fails to
compile.
Making the "#ifdef PF_PACKET" be "#ifdef HAVE_PF_PACKET_SOCKETS",
defining "HAVE_PF_PACKET_SOCKETS" if "HAVE_NETPACKET_PACKET_H" is
defined, and also defining it if "HAVE_NETPACKET_PACKET_H" isn't defined
but PF_PACKET is defined *AND* PACKET_HOST is defined after including
<linux/if_packet.h> seems to work both on RH 5.2 (no PF_PACKET support
in the resulting libpcap, as one would expect) and RH 6.x for some value
of "x" (the resulting libpcap does use PF_PACKET).
Hopefully no distribution will be *so* creative as to:
not have <netpacket/packet.h>;
define PF_PACKET and PACKET_HOST;
not declare "sockaddr_ll" or define all the other stuff needed
for PF_PACKET sockets in <linux/if_packet.h>.
I'll check that in this evening when I get home; if anybody has any
other Linux distributions with kernel/glibc combinations not already
tested, here's the patch to the code currently in the CVS tree:
Index: pcap-linux.c
===================================================================
RCS file: /tcpdump/master/libpcap/pcap-linux.c,v
retrieving revision 1.53
diff -c -r1.53 pcap-linux.c
*** pcap-linux.c 2001/01/17 07:42:37 1.53
--- pcap-linux.c 2001/01/17 22:25:23
***************
*** 76,81 ****
--- 76,86 ----
#ifdef HAVE_NETPACKET_PACKET_H
# include <netpacket/packet.h>
+
+ /*
+ * We assume this means we really do have PF_PACKET sockets.
+ */
+ # define HAVE_PF_PACKET_SOCKETS
#else
/*
* Oh, joy. Some Linux distributions have 2.2 or later kernels and
***************
*** 95,100 ****
--- 100,119 ----
*/
# ifdef PF_PACKET
# include <linux/if_packet.h>
+
+ /*
+ * However, on at least some Linux distributions (for example, Red Hat
+ * 5.2), there's no <netpacket/packet.h> file, but PF_PACKET is defined
+ * if you include <sys/socket.h>, but <linux/if_packet.h> doesn't define
+ * any of the PF_PACKET stuff such as "struct sockaddr_ll" or any of
+ * the PACKET_xxx stuff.
+ *
+ * So we check whether PACKET_HOST is defined, and assume that we have
+ * PF_PACKET sockets only if it is defined.
+ */
+ # ifdef PACKET_HOST
+ # define HAVE_PF_PACKET_SOCKETS
+ # endif /* PACKET_HOST */
# endif /* PF_PACKET */
#endif /* HAVE_NETPACKET_PACKET_H */
***************
*** 131,142 ****
/*
* Wrap some ioctl calls
*/
! #ifdef PF_PACKET
static int iface_get_id(int fd, const char *device, char *ebuf);
#endif
static int iface_get_mtu(int fd, const char *device, char *ebuf);
static int iface_get_arptype(int fd, const char *device, char *ebuf);
! #ifdef PF_PACKET
static int iface_bind(int fd, int ifindex, char *ebuf);
#endif
static int iface_bind_old(int fd, const char *device, char *ebuf);
--- 150,161 ----
/*
* Wrap some ioctl calls
*/
! #ifdef HAVE_PF_PACKET_SOCKETS
static int iface_get_id(int fd, const char *device, char *ebuf);
#endif
static int iface_get_mtu(int fd, const char *device, char *ebuf);
static int iface_get_arptype(int fd, const char *device, char *ebuf);
! #ifdef HAVE_PF_PACKET_SOCKETS
static int iface_bind(int fd, int ifindex, char *ebuf);
#endif
static int iface_bind_old(int fd, const char *device, char *ebuf);
***************
*** 242,248 ****
pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
{
int offset;
! #ifdef PF_PACKET
struct sockaddr_ll from;
struct sll_header *hdrp;
#else
--- 261,267 ----
pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
{
int offset;
! #ifdef HAVE_PF_PACKET_SOCKETS
struct sockaddr_ll from;
struct sll_header *hdrp;
#else
***************
*** 252,258 ****
int packet_len, caplen;
struct pcap_pkthdr pcap_header;
! #ifdef PF_PACKET
/*
* If this is a cooked device, leave extra room for a
* fake packet header.
--- 271,277 ----
int packet_len, caplen;
struct pcap_pkthdr pcap_header;
! #ifdef HAVE_PF_PACKET_SOCKETS
/*
* If this is a cooked device, leave extra room for a
* fake packet header.
***************
*** 291,297 ****
}
}
! #ifdef PF_PACKET
/*
* If this is from the loopback device, reject outgoing packets;
* we'll see the packet as an incoming packet as well, and
--- 310,316 ----
}
}
! #ifdef HAVE_PF_PACKET_SOCKETS
/*
* If this is from the loopback device, reject outgoing packets;
* we'll see the packet as an incoming packet as well, and
***************
*** 307,313 ****
return 0;
#endif
! #ifdef PF_PACKET
/*
* If this is a cooked device, fill in the fake packet header.
*/
--- 326,332 ----
return 0;
#endif
! #ifdef HAVE_PF_PACKET_SOCKETS
/*
* If this is a cooked device, fill in the fake packet header.
*/
***************
*** 627,633 ****
live_open_new(pcap_t *handle, char *device, int promisc,
int to_ms, char *ebuf)
{
! #ifdef PF_PACKET
int sock_fd = -1, device_id, mtu, arptype;
struct packet_mreq mr;
--- 646,652 ----
live_open_new(pcap_t *handle, char *device, int promisc,
int to_ms, char *ebuf)
{
! #ifdef HAVE_PF_PACKET_SOCKETS
int sock_fd = -1, device_id, mtu, arptype;
struct packet_mreq mr;
***************
*** 814,820 ****
#endif
}
! #ifdef PF_PACKET
/*
* Return the index of the given device name. Fill ebuf and return
* -1 on failure.
--- 833,839 ----
#endif
}
! #ifdef HAVE_PF_PACKET_SOCKETS
/*
* Return the index of the given device name. Fill ebuf and return
* -1 on failure.
***************
*** 1217,1223 ****
return ifr.ifr_hwaddr.sa_family;
}
! #ifdef PF_PACKET
static int
fix_program(pcap_t *handle, struct sock_fprog *fcode)
{
--- 1236,1242 ----
return ifr.ifr_hwaddr.sa_family;
}
! #ifdef HAVE_PF_PACKET_SOCKETS
static int
fix_program(pcap_t *handle, struct sock_fprog *fcode)
{
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe