-
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
-
you're in the wrong forum, and your code has many an error. however i am very generous soul.
i suspect that will solve your problem. the anglular brackets tell the compiler to look in all the usual places for the file.
-
>>> 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.
-
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
-
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.