- count=0;
- while (count<MAX_PACKAGES) {
- count++;
- printf("\n");
- if((package=pcap_next(pcap_handle,&pcap_header))!=NULL) {
- printf("---> package %d ---- %s",count,
- ctime((const time_t*)&pcap_header.ts.tv_sec));
- printf("pcap header: ");
- printf("capture length=%d ",pcap_header.caplen);
- printf("length(off wire)=%d\n",pcap_header.len);
+ my_info_struct.count=0;
+ my_info_struct.mmode=argv[2][0];
+ strcpy(my_info_struct.dev,argv[1]);
+
+ /* prepare for select */
+ pcap_fd=pcap_fileno(pcap_handle);
+ FD_ZERO(&pcap_fd_set);
+ FD_SET(pcap_fd,&pcap_fd_set);
+ fd_set_tv.tv_sec=0;
+ fd_set_tv.tv_usec=500000;
+
+ /* 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 if((hop_channel(&my_info_struct,pcap_fd))==-1) {
+ printf("channelhopping failed, aborting\n");
+ return -1;
+ }