Results 1 to 3 of 3
hi, i'm writing a portable x86 PC emulator in C. been working on it for about 7 or 8 months, and i've just added ethernet emulation using libpcap/winpcap.
on windows ...
- 06-23-2011 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 2
problem linking C program using libpcap on linux, works on windows.
hi, i'm writing a portable x86 PC emulator in C. been working on it for about 7 or 8 months, and i've just added ethernet emulation using libpcap/winpcap.
on windows using MinGW (i use the Dev-C++ IDE in win) it works perfectly, but when i try to compile it on a linux box (Debian 6.0 "Squeeze") i get some errors. i've got libpcap and libpcap-dev installed. here is what happens when i try to compile, including the gcc command line i'm using:
gcc adlib.c flags.c main.c ops.c ports.c video.c cpu.c grpops.c network.c packet.c render.c disk.c keyboard.c oplist.c parsecl.c speaker.c -o ./fake86-linux $(sdl-config --cflags --libs) $(pcap-config --cflags --libs)
and the output:
i've googled quite a bit and can't find any pages that have been able to help, and there's nothing relevant in the pcap docs either.Code:packet.c: In function initpcap: packet.c:44: error: PCAP_SRC_IF_STRING undeclared (first use in this function) packet.c:44: error: (Each undeclared identifier is reported only once packet.c:44: error: for each function it appears in.) packet.c:92: error: PCAP_OPENFLAG_PROMISCUOUS undeclared (first use in this function)
any ideas? thanks...
- 06-24-2011 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
It sounds like you have run into one of those platform dependencies you hear about when writing cross-platform code. These two symbols don't exist for Linux. In any case, do read the Linux pcap man page. It talks about how to set promiscuous mode:
In any case, it may be that you will either have to do some coding around the differences, or #ifdef out some code that won't be supported in Linux/Unix as it is in Windows. Welcome to the fun of cross-platform software development!Code:promiscuous mode On broadcast LANs such as Ethernet, if the network isn’t switched, or if the adapter is connected to a "mirror port" on a switch to which all packets passing through the switch are sent, a network adapter receives all packets on the LAN, including unicast or multicast packets not sent to a network address that the network adapter isn’t configured to recognize. Normally, the adapter will discard those packets; however, many network adapters support "promiscuous mode", which is a mode in which all packets, even if they are not sent to an address that the adapter recognizes, are provided to the host. This is useful for passively capturing traffic between two or more other hosts for analysis. Note that even if an application does not set promiscuous mode, the adapter could well be in promiscuous mode for some other reason. For now, this doesn’t work on the "any" device; if an argument of "any" or NULL is supplied, the setting of promiscuous mode is ignored. Promiscuous mode is set with pcap_set_promisc().
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-24-2011 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
That snippit was from the pcap man page. On your Linux system, execute the command: man pcap
There is a lot more information there, and indications at the bottom of the document of other subjects to peruse for more information.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote