Microsoft Visual Studio 10.0 performs winpcap to obtain the network adapter code

Source: Internet
Author: User



WinPcap is an open source library based on the Win32 platform for capturing and analyzing network packets.



Most Web applications access the network through widely used operating system components, such as sockets. This is a simple implementation because the operating system has properly handled the underlying implementation details (such as protocol processing, encapsulation of packets, etc.) and provides a familiar interface to read and write files.



Sometimes, however, this "simple approach" does not meet the needs of the task because some applications require direct access to the packets in the network. That is, those applications need access to the original packets, i.e. packets that are not processed by the operating system using the network protocol.



The purpose of WINPCAP is to provide this access for WIN32 applications; WinPcap provides the following features


    • Captures the original packet, whether it is destined for a machine or is exchanged on other devices (shared media)

    • Filter packets based on user-specified rules before data packets is sent to an application

    • Send the original packet over the network

    • Collect and Count network traffic information


These features need to be implemented with a network device driver installed in the Win32 kernel, plus several dynamic-link library DLLs.



All of these features can be demonstrated through a powerful programming interface, easy to develop, and can be used on different operating systems. The main objective of this manual is to describe the use of these programming interfaces with the help of a number of program examples.



In general, the first thing to write a WinPcap-based application is to get a list of connected network adapters. Both Libpcap and WinPcap provide the PCAP_FINDALLDEVS_EX () function to implement this function: This function returns a list of pcap_if structures, each of which contains the details of an adapter. It is important to note that the data field name and description represent an adapter name and a description that people can understand.



First configure Microsoft Visual Studio 10.0



Item-->** Properties (ALT+F7)



Configuration Properties---inventory tools--input and output--embedded list--No



Item-->** Properties (ALT+F7)



Configuration Properties-->c/c++--> General--Additional include directory--



Item-->** Properties (ALT+F7)



Configuration Properties--linker--general--Additional library directories--



Item-->** Properties (ALT+F7)



Configuration Properties--linker--Add dependency--add "; Packet.lib;wpcap.lib "



Item-->** Properties (ALT+F7)



Configuration Properties-->c/c++--> Preprocessor---preprocessor definition--add "; Have_remote










Microsoft Visual Studio 10.0 performs winpcap to obtain the network adapter code


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.