Webpage: webpage-Winpcap-"Hello world !"

Source: Internet
Author: User

In the past, it was easy to see people use Winpcap. Today, some time has also been posted on the Internet ~~

We don't want "Hello World" anymore. If Winpcap doesn't come out, we just need a program that prints the list of available network cards on this machine. This is the most simple one.

Go to http://www.winpcap.org/install/bin/winpcap_4_0.exeand install Winpcap,

Go to the slave copy "and change the name. This is our first program, which is called test. Which of the following "udpdump. DSP and udpdump. change DSW to test. DSP "," test. DSW, and then use the notebook to open these two files. Replace "udpdump" into our "test ", in this case, the user's udpdump project becomes our test project. Use VC to open the test project. In the right pane, we can see the source file udpdump. c. Head file pcap. h. Delete the source file and add a main file to the file. CPP and fill in the following tokens:

Main. cpp:

# Include "pcap. H"

Void main (void)
...{
Pcap_if_t * alldevs;
Pcap_if_t * D;

Int I = 0;
Char errbuf [pcap_errbuf_size];
// Obtain the list
If (pcap_findalldevs (& alldevs, errbuf) =-1 )...{
Fprintf (stderr, "error in pcap_findalldevs: % s", errbuf );
Exit (1 );
}

// Outputs the list
For (D = alldevs; D = D-> next )...{
Printf ("% d. % s", ++ I, d-> name );
If (D-> description )...{
Printf ("(% s)", D-> description );
} Else ...{
// Y-no valid description
Printf ("(not described )");
}
}

If (I = 0 )...{
// Y-there is no valid interface, or it may be because there is no secure Winpcap
Printf ("interface not found! Confirm whether or not to install Winpcap. ");
Return;
}

// Release list
Pcap_freealldevs (alldevs );
}

 

The network card interface list of the organization, OK, operation, and current machine is displayed ~

 

// Note: If you are an XP sp2 workstation and cannot find any iphlpapi. Lib file during the creation, you need to install a package, big package, and

Http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm

Go to the next page ~~~

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.