Date: Sun, 1 Jan 2006 01:01:10 +0800 From: prime <guomingyan@gmail.com> To: freebsd-hackers@freebsd.org Subject: Re: Problem about libnet on FreeBSD 6.0 Message-ID: <1fa17f810512310901lbabc8ddj630fcf2a79691ba1@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
On 12/31/05, Gilbert Fernandes <gilbert.fernandes@spamcop.net> wrote: > > > ----- Message from guomingyan@gmail.com --------- > > Date: Sat, 31 Dec 2005 20:55:38 +0800 > > From: prime <guomingyan@gmail.com > > > Reply-To: prime <guomingyan@gmail.com> > > Subject: Re: Problem about libnet on FreeBSD 6.0 > > To: Gilbert Fernandes < gilbert.fernandes@spamcop.net> > > > > On 12/31/05, Gilbert Fernandes <gilbert.fernandes@spamcop.net> wrote: > > > > > > > I find that I can't include <net/ethernet.h> when I programming > > > > with libnet,because $(CC) complains that "struct ether_addr > > redefined". > > > > But I need some definitions in <net/ethernet.h>,struct ether_header > > etc. > > > > Currently,I just copy the definitions I need from > > <net/ethernet.h>,but > > > > it seems very ugly.Any one has some good ideas? > > > > > > Could you show us the include line you use ? > > > > > > #include "blabla" and > > > #include <blabla> > > > > > > will produce very different results as you know :) > > > > > > You do use #include <net/ethernet.h> ? > > > > > > -- > > > unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ; > > > fsck ; umount ; sleep > > > > > Here is my include lines, > > #include ...... > > #include <net/ethernet.h> > > #include <pcap.h> > > #include <libnet.h> > > ........... > > and this is the error, > > $(CC) said "/usr/local/include/./libnet/libnet-headers.h:393: error: > > redefinition of `struct ether_addr'" > > > > > > Thanks. > > -- > > Three passions, simple but overwhelmingly strong, have governed my life= : > > > the longing for love, the search for knowledge, and unbearable pity for > > the suffering of mankind. > > ---------Bertrand Russell > > > > > > ----- End message from guomingyan@gmail.com ----- > > Redefinition means that you have two declarations of the same > function. > > One of the files you are including IS already including net/ethernet > probably. > > Can you check ? :) > > -- > unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ; > fsck ; umount ; sleep > I can't agree more.Header files usually use "#ifndef XXX_H #define XXX_H ......... #endif" to avoid being included more than once.<net/ethernet.h> is not different= . it use "#ifndef _NET_ETHERNET_H_ #define _NET_ETHERNET_H_ ...... #endif" to avoid more than once include. In my opinion,struct ether_addr is defined both in <net/ethernet.h> and libnet-headers.h,and we need include these two header files at the same time. And here is my include lines #include <stdio.h> #include <stdlib.h> #include <limits.h> #include <errno.h> #include <signal.h> #include <sys/types.h> #include <sys/socket.h> #include <net/if_arp.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <net/ethernet.h> #include <pcap.h> #include <libnet.h> -- Three passions, simple but overwhelmingly strong, have governed my life: the longing for love, the search for knowledge, and unbearable pity for the suffering of mankind. ---------Bertrand Russell
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1fa17f810512310901lbabc8ddj630fcf2a79691ba1>