On Sun, Jul 07, 2002 at 02:54:48AM +0400, [EMAIL PROTECTED] wrote:
> glibc headers really used to be broken. I even have no idea _where_
> glibc hackers put SOL_PACKET. :-) SOL_* used to be defined in <sys/socket.h>,
> but glibc prefers to scatter them over various random places.
> Apparently, they created some strange bastard <netpacket/packet.h> to do this,
> but this file is chronically bogus and must not be used
> under any circumstances.

Yup, we don't use that in "pcap-linux.c"; a comment in "pcap-linux.c"
says

 * If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET
 * sockets rather than SOCK_PACKET sockets.
 *
 * To use them, we include <linux/if_packet.h> rather than
 * <netpacket/packet.h>; we do so because
 *   
 *      some Linux distributions (e.g., Slackware 4.0) have 2.2 or   
 *      later kernels and libc5, and don't provide a <netpacket/packet.h>
 *      file;
 *     
 *      not all versions of glibc2 have a <netpacket/packet.h> file  
 *      that defines stuff needed for some of the 2.4-or-later-kernel
 *      features, so if the system has a 2.4 or later kernel, we
 *      still can't use those features.
 *     
 * We're already including a number of other <linux/XXX.h> headers, and
 * this code is Linux-specific (no other OS has PF_PACKET sockets as
 * a raw packet capture mechanism), so it's not as if you gain any
 * useful portability by using <netpacket/packet.h>

It sounds from what you're saying as if there are even *more* reasons
not to use it.

> > One way to do that would be to include <linux/socket.h> header files;
> 
> Alas, this is impossible with glibc due to innumerous conflicts.

That's what I expected, so that's why I checked in:

> So:
> 
> >     #ifndef SOL_PACKET
> >     #define SOL_PACKET      263
> >     #endif
> 
> is the only working solution: ugly, terrible, not no other solution exists.

...that fix.

> > We may have to do the same for PACKET_MR_PROMISC, PACKET_MR_ALLMULTI,
> > and PACKET_ADD_MEMBERSHIP, but so it goes.
> 
> <linux/if_packet.h> can be included safely.

Good, because we've been including it for a while....

> The only problem
> is that it uses types sort of __u32 which are not defined in glibc,
> but this is easily worked around:
> 
> 
> #if defined(__GLIBC__) && __GLIBC__ >= 2
> 
> #ifndef __KERNEL_STRICT_NAMES
> #define __KERNEL_STRICT_NAMES 1
> #endif
> 
> #include <linux/types.h>
> #endif
> 
> #include <linux/if_packet.h>

Currently, we don't explicitly include <linux/types.h> before including
<linux/if_packet.h>; it may be that, at least in those kernels that have
PF_PACKET sockets, some other headers we include before it include
<linux/types.h>.
-
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

Reply via email to