Find the answer to your Linux question:
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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:
    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)
    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.

    any ideas? thanks...

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    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:

    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().
    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!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •