the-tcpdump-group / tcpslice

tcpslice concatenates multiple pcap files together, or extracts time slices from one or more pcap files.
63 stars 22 forks source link

Really need to include pcap-int.h after system includes #6

Closed leres closed 4 years ago

leres commented 4 years ago

or else libpcap's portability.h causes things to go off the rails.

On FreeBSD 11.3-RELEASE the conflict is with string.h:

In file included from ./search.c:38:
/usr/include/string.h:92:9: error: expected ')'
size_t   strlcat(char * __restrict, const char * __restrict, size_t);
         ^
/usr/src/contrib/libpcap/portability.h:86:24: note: expanded from macro 'strlcat'
        strncat((x), (y), (z) - strlen((x)) - 1)
                              ^
/usr/include/string.h:92:9: note: to match this '('
/usr/src/contrib/libpcap/portability.h:86:9: note: expanded from macro 'strlcat'
        strncat((x), (y), (z) - strlen((x)) - 1)
               ^
In file included from ./search.c:38:
/usr/include/string.h:99:7: error: conflicting types for 'strncat'
char    *strncat(char * __restrict, const char * __restrict, size_t);
         ^
/usr/include/string.h:92:9: note: previous declaration is here
size_t   strlcat(char * __restrict, const char * __restrict, size_t);
         ^
/usr/src/contrib/libpcap/portability.h:86:2: note: expanded from macro 'strlcat'
        strncat((x), (y), (z) - strlen((x)) - 1)
        ^
2 errors generated.
*** [search.o] Error code 1

make[1]: stopped in /wrkdirs/usr/ports/net/tcpslice/work/tcpslice-2837b72
1 error

make[1]: stopped in /wrkdirs/usr/ports/net/tcpslice/work/tcpslice-2837b72
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/ports/net/tcpslice
guyharris commented 4 years ago

pcap-int isn't a public header, so it shouldn't include it, nor should it be including portability.h, which is also not a public header.

Instead, given that pcap files are not platform-dependent, it should define the pcap file data structures itself, as per the pcap-savefile man page or the RFC-style pcap file format specification (I plan to ask Van Jacobson and Steve McCanne if they want their names on it).

I'll do that.

guyharris commented 4 years ago

I'll do that.

Done, along with a bunch of other modernizations largely stolen from modernizations done to tcpdump. It builds on my FreeBSD 11.2 VM.

leres commented 4 years ago

pcap-int isn't a public header, so it shouldn't include it, nor should it be including portability.h, which is also not a public header.

I don't disagree with you, this was the minimal change that allowed the FreeBSD port to build without patching.

Instead, given that pcap files are not platform-dependent, it should define the pcap file data structures itself, as per the pcap-savefile man page or the RFC-style pcap file format specification (I plan to ask Van Jacobson and Steve McCanne if they want their names on it).

I don't know when dependency on pcap-int.h appeared but I just looked and it is not present in the original Network Research Group rcs repo version of search.c. There are only commits by Vern, Steve, and I ending around 2000. And I don't think we had any 64-bit systems at that point.

Rewriting the code to eliminate the dependency is clearly the best solution.

infrastation commented 2 years ago

For posterity, there is now a FAQ entry about this.