/* do loopp */
while(1) {
if((select(pcap_fd+1,&pcap_fd_set,NULL,NULL,&fd_set_tv)) && (FD_ISSET(pcap_fd,&pcap_fd_set))) pcap_loop(pcap_handle,-1,pcap_process,(u_char *)&my_info_struct);
- else hop_channel(&my_info_struct,pcap_fd);
+ else if((hop_channel(&my_info_struct,pcap_fd))==-1) {
+ printf("channelhopping failed, aborting\n");
+ return -1;
+ }
}
return 0;
}
int hop_channel(struct info_struct *info,int pcap_fd) {
struct iwreq my_iwreq;
+ int foo_fd;
+ /* oder vielleicht doch pcap_fd ? */
+ if((foo_fd=socket(AF_INET,SOCK_DGRAM,0))==-1) {
+ printf("unable to create socket\n");
+ return -1;
+ }
if (info->channel==15) info->channel=1;
memset(&my_iwreq,0,sizeof(my_iwreq));
strcpy(my_iwreq.ifr_name,info->dev);
+ printf("debug: device = %s\n",my_iwreq.ifr_name);
my_iwreq.u.freq.e=0;
my_iwreq.u.freq.m=info->channel;
- if((ioctl(pcap_fd,SIOCSIWFREQ,& my_iwreq))==-1) {
+ // if((ioctl(foo_fd,SIOCSIWFREQ,&my_iwreq))==-1) {
+ if((ioctl(pcap_fd,SIOCSIWFREQ,&my_iwreq))==-1) {
printf("unable to hop channels\n");
+ perror("ioctl");
return -1;
}
printf("debug: hopped to channel %d\n",info->channel);