如何在c++ builder中使用win32 API函数将网卡设置为混杂模式?
如何在c++ builder中使用win32 API函数将网卡设置为混杂模式?
在linux中可以使用以下程序:
int Set_Promisc(char *interface, int sock ) {
struct ifreq ifr;
strncpy(ifr.ifr_name, interface,strnlen(interface)+1);
if((ioctl(sock, SIOCGIFFLAGS, &ifr) == -1)) {
/*Could not retrieve flags for the interface*/
perror("Could not retrive flags for the interface");
exit(0);
}
printf("The interface is ::: %s\n", interface);
perror("Retrieved flags from interface successfully");
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl (sock, SIOCSIFFLAGS, &ifr) == -1 ) {
/*Could not set the flags on the interface */
perror("Could not set the PROMISC flag:");
exit(0);
}
printf("Setting interface ::: %s ::: to promisc",interface);
return(0);
}
在windows环境下应该如何进行??