]> hackdaworld.org Git - my-code/hdw-sniff.git/commitdiff
?!? wtf :)
authorhackbard <hackbard>
Tue, 12 Nov 2002 00:53:33 +0000 (00:53 +0000)
committerhackbard <hackbard>
Tue, 12 Nov 2002 00:53:33 +0000 (00:53 +0000)
hdw-sniff.c

index 8cbfb491e6e7fbda3e4d659a86b9fdd5cb2af645..db285a2e75b7c53c3b40138088eef7a00b95efde 100644 (file)
@@ -97,7 +97,10 @@ int main(int argc, char *argv[]) {
        /* 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;
 }
@@ -191,15 +194,24 @@ void pcap_process(u_char *info,const struct pcap_pkthdr *pcap_header,
 
 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);