Main Page   Modules   Data Structures   File List   Data Fields   Globals  

Using WinPcap in your programs
[WinPcap user's manual]


Modules

pktdump example
pcap_filter example

Detailed Description

 

How to create an application that uses wpcap.dll

To create an application that uses wpcap.dll with Microsoft Visual C++, follow the next steps:

Remember that:

Sample programs

A couple of sample programs are provided to show the usage of the WinPcap API. The source of the examples, along with all the files needed to compile and run them, can be found in the Developer's Pack.  For didactic purpose we provide here a browsable version of the code: it is possible to click on the variables and functions to jump the documentation of each of them. For a more complete and better documented set of samples, give a look at the tutorial section (WinPcap tutorial: a step by step guide to program WinPcap).  

 

pktdump example

This program reads the packets from a file or a network adapter, depending on a command line switch. If a source is not provided, the program shows a list of available adapters and gives the possibility to choose one of them. Once the capture is started, the program prints the timestamp, the length and the raw content of the packets. Once compiled, it can run on all the Win32 platforms. It can be compiled to run on Unix as well (the makefile is provided).  

pcap_filter example

This is a more complete example of libpcap usage. It shows, among other things, how to create and set filters and how to save a capture to disk. It can be compiled under Win32 or Unix (projects and makefiles are provided). Pcap_filter (pf.exe) is a general-purpose packet filtering application: its input parameters are a source of packets (it can be a physical interface or a file), a filter and an output file. It takes packets from the source until CTRL+C is pressed or the whole file is processed, applies the filter to the incoming packets and saves them to the output file if they satisfy the filter. Pcap_filter can be used to dump network data according to a particular filter, but also to extract a set of packets from a previously saved file. The format of both input and output files is the libpcap one, i.e. same of WinDump, tcpdump and many other network tools.


documentation. Copyright (c) 2002 Politecnico di Torino. All rights reserved.