我正在用C编写无线数据包嗅探器程序.我已经使用airmon-ng将我的无线接口设置为监控模式,现在我正在嗅探"mon0"接口.我正在使用linux(ubuntu 10.10).
我想将MAC地址设置为数据包的过滤器.我已经完成了如下所示,但它说"mon0没有分配IPV4地址"
pcap_lookupnet(dev,&net,&mask,errbuf);
printf("%s\n",errbuf);
/* Open the session in promiscuous mode */
handle = pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);
if (handle == NULL) {
printf("Couldn't open device %s: %s\n", dev, errbuf);
return 2;
}
if(pcap_compile(handle,&fp,argv[0],0,net)==-1){
fprintf(stderr,"Error calling pcap_compile\n");exit(1);}
if(pcap_setfilter(handle,&fp) == -1){
fprintf(stderr,"Error setting filter\n");exit(1);}
/* The call pcap_loop() and pass our callback function */
pcap_loop(handle, 10, my_callback, NULL);
Run Code Online (Sandbox Code Playgroud)
请帮帮我,我怎样才能设置过滤MAC地址?
我在C中编写自己的ToLower(char*str)实现.但是我在函数中遇到了分段错误.我写的功能是:
void ToLower(char *str)
{
while(*str != '\0')
{
if(*str >=65 && *str<=90)
{
// It fails in the below assignment
*str = *str + 32;
}
str++;
}
}
Run Code Online (Sandbox Code Playgroud)