winPcap

This is a discussion on winPcap within the Windows Programming forums, part of the Platform Specific Boards category; hey all, I cant seem to use WinPcap with c++builder.WinPcap is an architecture for packet capture and network analysis for ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    2

    winPcap

    hey all,
    I cant seem to use WinPcap with c++builder.WinPcap is an architecture for packet capture and network analysis for the Win32 platforms. It includes a kernel-level packet filter, a low-level dynamic link library (packet.dll), and a high-level and system-independent library (wpcap.dll, based on libpcap version 0.6.2).

    Is it not possible or should I use microsft visual studio ? I get an error "unable to open include file 'pcap.h' ,when i try to include the header file "pcap.h".

    #include<stdio.h>
    #include "pcap.h"

    main()
    {
    printf("hello world");
    return 0;
    }


    Thanx

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    you're in the wrong forum, and your code has many an error. however i am very generous soul.

    Code:
    #include <pcap.h>
    i suspect that will solve your problem. the anglular brackets tell the compiler to look in all the usual places for the file.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> you're in the wrong forum,

    Well, s/he does say it is Win32 specific so, perhaps not, whatever.

    As Ben says, your compiler may well be looking in the wrong place. The angle brackets type header declaration tell the compiler to use the "normal search criteria" to find the file, this is usually some lib or bin directories set up by the environment, then some Windows directories, maybe some other places and finally the PATH environmental variable. If the file is in none of those places it will bomb out.

    The quoted variant, tells the compiler took look in the same directory as the source file.

    If substituting <> for "" does not fix it, put a copy of the header in the source directory and change it back to "".

    I've never heard of WinPcap.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    2
    hey adrian,
    Did try putting the header file in the source(bin) directory and changing it to <pcap.h> instead of "pcap.h",it gave me a lot of new compiler errors like declaration missing , ; missing etc , multiple declaration for bpf_u_int32. My guess is that it is unable to open the other library or include files that it references.

    I should have been more specific about what I was trying to achieve. I want to write a packet capturing program so that I can analyse the network packets(something along the lines of tcp/windump).

    #include<stdio.h>
    #include<pcap.h>
    int main()
    {
    char*dev,errbuf[PCAP_ERRBUF_SIZE];
    dev=pcap_lookupdev(errbuf);
    printf("device:%s\n",dev);
    return0;
    }

    What the above program does is that it finds out the device on which it has to sniff for packets. the string "dev" holds the name of the interface and errbuf string has the description of the error in case the command fails.

    This program compiled under linux gcc works fine but I am unable to compile it under windows. Linux uses libpcap instead of winpcap(obviously;-) )

    check this link if you want more info on WinPcap.

    http://winpcap.polito.it/install/default.htm

    p.s-benny ,I am new here so plz lemme know where I should post this,thanx

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    sorry, my bad one. i just saw your code and said to myself, not windows, because it was an entry point for a console application, not a win32 process. ie, you didn't include windows.h, and you had int main instead of int WINAPI WinMain(...).

    then i realized that that is probably your problem. create a win32 application and then try using your pcap.h file. most likely, it was intended for win32 use, so it assumes windows.h will be included.

    do this:

    Code:
    #include <windows.h>
    #include <stdlib.h>
    #include "pcap.h" //put in your project directory
    
    int main()
    {
    blah blah blah
    }
    or better yet create a window and have a usable GUI.
    good luck.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WinPCap - Packet data containing strings?
    By Glorfindel in forum C Programming
    Replies: 11
    Last Post: 02-11-2009, 02:34 PM
  2. Creating a cheat proxy with winpcap
    By *DEAD* in forum Networking/Device Communication
    Replies: 2
    Last Post: 06-01-2007, 07:34 AM
  3. winpcap?
    By kryptkat in forum Networking/Device Communication
    Replies: 4
    Last Post: 11-29-2006, 10:13 PM
  4. Problem With WinPcap library
    By DrMario in forum C Programming
    Replies: 0
    Last Post: 03-26-2005, 10:26 AM
  5. WinPcap Sniffer App Prob
    By GUI_XP in forum C++ Programming
    Replies: 3
    Last Post: 12-01-2002, 04:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21