USNavalResearchLaboratory / mgen

Multi-Generator (MGEN) traffic generation tool
https://www.nrl.navy.mil/itd/ncs/products/mgen
Other
83 stars 25 forks source link

Compilation issue, SOCKET is already defined #12

Closed jordanauge closed 3 years ago

jordanauge commented 4 years ago

Hello,

I am facing a compilation issue with various releases of mgen on at least recent debian & ubuntu platforms:

git clone https://github.com/USNavalResearchLaboratory/mgen.git
cd mgen
git clone https://github.com/USNavalResearchLaboratory/protolib.git
cd makefiles
make -f Makefile.linux

which raises the following error:

In file included from /usr/include/pcap/pcap.h:87,
                 from /usr/include/pcap.h:43,
                 from ../include/mgenPattern.h:7,
                 from ../include/mgenEvent.h:5,
                 from ../src/common/mgenEvent.cpp:2:
../protolib/include/protoDispatcher.h:468:37: error: expected identifier before ‘int’
  468 |                 enum Type {GENERIC, SOCKET, CHANNEL, TIMER, EVENT};
      |                                     ^~~~~~
../protolib/include/protoDispatcher.h:468:37: error: expected ‘}’ before ‘int’
In file included from ../protolib/include/protokit.h:24,

This is due to the following line in pcap/socket.h:

#define SOCKET int

Simply renaming the enum variable solves the issue. Some earlier versions of mgen (such as the one shipped in debian 5.02b) do not present the problem, likely because of a different include pattern in protolib.

Thanks

weston-nrl commented 4 years ago

Is this on Ubuntu 20.04? I have not seen similar issues on 18.04 or 16.04.

bharnden commented 4 years ago

Yes this appears to be related to Ubuntu 20 and the default libpcap-dev library being 1.9.1.

Reverting to using 1.8.1 fixes the problem.

bebopagogo commented 4 years ago

This could be smited by the incantation:

ifdef EVIL

undef EVIL

endif

prior to the class ProtoDispatcher declaration. I.e., something like

ifdef SOCKET

undef SOCKET

typedef int SOCKET;

endif

I would prefer not to include the typedef unless it’s really needed as it is a bit presumptuous. But that typedef outside of the ProtoDispatcher scope should be compatible with the in-scope enum if it is needed where the pcap #define isn’t.

I don’t have an Ubuntu 20 handy to try this myself. Let me know if it works (preferably without the typedef) and I will roll it into the Protolib repo.

Sent from my iPhone

On Jul 17, 2020, at 3:15 PM, bharnden notifications@github.com wrote:  Yes this appears to be related to Ubuntu 20 and the default libpcap-dev library being 1.9.1.

Reverting to using 1.8.1 fixes the problem.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Kevlar commented 4 years ago

That typedef worked for me to build the latest checkout of mgen on Ubuntu20 using the default libpcap-dev version (1.9.1).