Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

libpcap 1.4.0 fails to build: tag redeclared: bpf_program on Solaris 11 Sun Studio 12.3 #306

Closed
marksolaris opened this Issue · 9 comments

2 participants

@marksolaris

Latest OpenIndiana (Solaris 11)

host:/var/tmp/libpcap-1.4.0 root# uname -a
SunOS host 5.11 oi_151a7 i86pc i386 i86pc

# ls -alF /bin/cc
lrwxrwxrwx   1 root     root          29 Mar  1 15:11 /bin/cc -> /opt/solarisstudio12.3/bin/cc*

    setenv CC cc
    setenv CXX CC
    setenv LDFLAGS "-I/usr/local/include -L/usr/local/lib"
    setenv CPPFLAGS "-I/usr/local/include -L/usr/local/lib"

    cd /var/tmp
    rm -rf libpcap-1.4.0
    untgz /usr/local/src/net/libpcap-1.4.0.tar.gz
    cd libpcap-1.4.0
    ./configure
    gmake

host:/var/tmp/libpcap-1.4.0 root# gmake
cc -O -Kpic -I.  -I/usr/local/include -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -g -c ./pcap-bpf.c
"./pcap-bpf.c", line 22: warning:  attribute "unused" is unknown, ignored
cc -O -Kpic -I.  -I/usr/local/include -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -g -c ./fad-getad.c
"./fad-getad.c", line 36: warning:  attribute "unused" is unknown, ignored
"/usr/include/net/bpf.h", line 73: (struct) tag redeclared: bpf_program
"/usr/include/net/bpf.h", line 253: (struct) tag redeclared: bpf_insn
cc: acomp failed for ./fad-getad.c
gmake: *** [fad-getad.o] Error 2
host:/var/tmp/libpcap-1.4.0 root#

The same recipe works ok on Solaris 10 x86 and SPARC, but they don't have a /dev/bpf by default.

@marksolaris

The fix and explanation was located here:
https://svn.nmap.org/nmap/libpcap/NMAP_MODIFICATIONS/0004-Include-netpacket-packet.h-before-pcap-bpf.h.patch

Pasted for completeness reasons:

From: David Fifield <david@bamsoftware.com>
Date: Mon, 9 Apr 2012 19:48:21 -0700
Subject: [PATCH 4/4] Include <netpacket/packet.h> before "pcap/bpf.h".

On Solaris 11, <netpacket/packet.h> includes <net/bpf.h>, which defines
the symbols bpf_program and bpf_insn. The included "pcap/bpf.h" also
includes these symbols, and checks whether any bpf.h has already been
included; if so, it doesn't include itself. When the includes go in the
other order there is no such guard. This is the error I get on Solaris
11:

gcc -O2 -fpic -I.  -DHAVE_CONFIG_H  -D_U_="__attribute__((unused))" -g -O2 -c ./fad-getad.c
In file included from /usr/include/netpacket/packet.h:10:0,
                 from ./fad-getad.c:66:
/usr/include/net/bpf.h:73:8: error: redefinition of 'struct bpf_program'
./pcap/bpf.h:107:8: note: originally defined here
In file included from /usr/include/netpacket/packet.h:10:0,
                 from ./fad-getad.c:66:
/usr/include/net/bpf.h:253:8: error: redefinition of 'struct bpf_insn'
./pcap/bpf.h:109:9: note: originally defined here
---
 fad-getad.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git fad-getad.c fad-getad.c
index 742ae1f..519893a 100644
--- fad-getad.c
+++ fad-getad.c
@@ -54,12 +54,6 @@ static const char rcsid[] _U_ =
 #include <string.h>
 #include <ifaddrs.h>

-#include "pcap-int.h"
-
-#ifdef HAVE_OS_PROTO_H
-#include "os-proto.h"
-#endif
-
 #ifdef AF_PACKET
 # ifdef HAVE_NETPACKET_PACKET_H
 /* Solaris 11 and later, Linux distributions with newer glibc */
@@ -77,6 +71,12 @@ static const char rcsid[] _U_ =
 # endif /* HAVE_NETPACKET_PACKET_H */
 #endif /* AF_PACKET */

+#include "pcap-int.h"
+
+#ifdef HAVE_OS_PROTO_H
+#include "os-proto.h"
+#endif
+
@marksolaris marksolaris reopened this
@marksolaris

Is that what that button does... reopening so we can get a patch added and tracked here.

Quick and dirty fix, editing on the fly...

    cd /var/tmp
    rm -rf libpcap-1.4.0
    untgz /usr/local/src/net/libpcap-1.4.0.tar.gz
    cd libpcap-1.4.0
    perl -pe '(57 .. 62) && s%^.*%%' -i fad-getad.c
    perl -pe '($. == 80) && s/^/#include "pcap-int.h"\n#ifdef HAVE_OS_PROTO_H\n#include "os-proto.h"\n#endif\n/' -i fad-getad.c
    ./configure --prefix=/usr/local
    gmake
@marksolaris

A full list of the fixes needed to compile is shown at:

#307

@guyharris
Owner

On Solaris 11, <netpacket/packet.h> includes <net/bpf.h>,

On Solaris 11, neither "linux" nor "Lynx" should be defined, as SunOS 5.x != Linux; how, then, is <netpacket/packet.h> getting included in the first place?

@guyharris
Owner

The "fix and explanation" above says:

On Solaris 11, includes , which defines
the symbols bpf_program and bpf_insn. The included "pcap/bpf.h" also
includes these symbols, and checks whether any bpf.h has already been
included; if so, it doesn't include itself. When the includes go in the
other order there is no such guard. This is the error I get on Solaris
11:

@guyharris
Owner

So this was fixed in 12dbee2, which apparently didn't get into 1.4.0, so this should be fixed with a 1.4.1 release.

@marksolaris

The commit URL is bringing up a 404 page. I'm not able to eyeball it
.

@guyharris
Owner

The commit URLs is bringing up a 404 page. I'm not able to eyeball it

Either that was a "bpf.tcpdump.org repository SHAs don't work in the GitHub repository" issue or "that was in the 1.4 branch, which isn't in the GitHub repository" issue. I replaced it with the SHA for the commit in the GitHub repository.

@guyharris guyharris closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.