2013-07-01 26 views
0

我只是從https://github.com/sam-github/libnet/tree/master/libnet git libnet項目,我一直在查看它提供的示例源。該示例獲取一個名爲「device」的cmd arg來初始化libnet。我發現「eth0」是Linux操作系統上的適當值,但我使用的是Windows 7,而我的問題是我可以在Windows上用作設備的值。libnet設備(網絡接口)命令行參數

l = libnet_init(
    LIBNET_RAW4,     /* injection type */ 
    device,      /* network interface */ 
    errbuf);      /* errbuf */ 

我嘗試了很多像適配器名稱,設備指數等數值的...但每次我得到這個錯誤:

libnet_init() failed: libnet_link_win32.c(): unable to open the driver, error Code : 14 

回答

1

我被同樣的問題混淆。 它可以這樣解決。

在LIB wpcap

有一個名爲pcap_findalldevs();

使用這樣的功能,你會succuss

int Value = pcap_findalldevs(&alldevs,errbuf); 
if(Value == -1) 
{ 
    fprintf(stderr,"Error in pcap_findalldevs: %s\n", errbuf); 
    exit(1); 
} 
char *device = NULL; 
device = alldevs->name; //get the first Card name 

    libnet_t *l 

l = libnet_init(
    LIBNET_LINK_ADV, 
    device,//use it here 
    error_information); 

這可能幫助你。祝你好運!