블로그 이미지
송시혁

calendar

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

Notice

Tag

Recent Post

Recent Comment

Recent Trackback

Archive




#include
 <stdio.h>
#define WIN32
#include <pcap.h>



#pragma  comment(lib, "wpcap.lib"//윈도우용 gcc -o .. .. -lpcap

int main()
{
  
  pcap_if_t *alldevs;
  pcap_if_t *d;
  int inum;
  int i;
  pcap_t *adhandle;
  char CaEbuf[PCAP_ERRBUF_SIZE];  
  char * cPdev;

/*  cPdev=pcap_lookupdev(CaEbuf);

  if(0==cPdev)
  {
    printf("[%s]\n", CaEbuf);
    return 0;    
  }
  printf("lancard name:[%s]\n", cPdev);*/


  
  if( -1==pcap_findalldevs(&alldevs, CaEbuf) )//장치 전부 검색. 첫 번째 인자가 검색된 랜카드이름 정보.
  {
    printf("Error in pcap_findalldevs: %s\n", CaEbuf);
    return 0;
  }
  
  
  for(d=alldevs, i=0 ; d!=0 ; d=d->next)  //d가 0이 아니면 
  {

    //printf("%d. %s\n", ++i, d->name);//랜카드번호를 출력하는 부분.
    printf("Ethernet adapter %s\n", d->description);

    

    /*if (0!=d->description)
    {
      printf(" [%s]\n", d->description);//ethernet 설명 부분. 
    }
    else
    {
      printf(" [설명 없음]\n");
    }*/

  }
  
  return 0;
}






posted by 송시혁