Get a list of devices

Source: Internet
Author: User

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/4C/wKiom1gPDKegUJ9FAAAsmGzfaXs451.png-wh_500x0-wm_3 -wmp_4-s_3645182045.png "style=" Float:none; "title=" capture. PNG "alt=" Wkiom1gpdkeguj9faaasmgzfaxs451.png-wh_50 "/>

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/89/4A/wKioL1gPDKfQGQu8AAAuw3WZDDU154.png-wh_500x0-wm_3 -wmp_4-s_3082020317.png "style=" Float:none; "title=" 1.PNG "alt=" Wkiol1gpdkfqgqu8aaauw3wzddu154.png-wh_50 "/>


#include "stdafx.h"

#include "Pcap.h"



int _tmain (int argc, _tchar* argv[])

{

pcap_if_t *alldevs;

pcap_if_t *d;

int i=0;

Char Errbuf[pcap_errbuf_size];

/* Get a list of local machine devices */

if (PCAP_FINDALLDEVS_EX (pcap_src_if_string, NULL/* auth is not needed */, &alldevs, errbuf) = =-1)

{

fprintf (stderr, "Error in PCAP_FINDALLDEVS_EX:%s\n", errbuf);

Exit (1);

}

/* Print List */

for (d= Alldevs; d! = NULL; d= d->next)

{

printf ("%d.%s", ++i, D->name);

if (d->description)

printf ("(%s) \ n", d->description);

Else

printf ("(No description available) \ n");

}

if (i = = 0)

{

printf ("\nno Interfaces found! Make sure WinPcap is installed.\n ");

return 0;

}


/* No more device list required, release it */

Pcap_freealldevs (Alldevs);


}


Get a list of devices

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.