From: hackbard Date: Tue, 10 Sep 2002 23:35:56 +0000 (+0000) Subject: pcap_next -> pcap_loop X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fhdw-sniff.git;a=commitdiff_plain;h=7bcd9bb684c81b49e4562d5151a25c37d3daa2e0 pcap_next -> pcap_loop --- diff --git a/hdw-sniff.c b/hdw-sniff.c index 96ef4a2..a201688 100644 --- a/hdw-sniff.c +++ b/hdw-sniff.c @@ -10,7 +10,7 @@ /* IEEE 802.3 stuff -- i will concentrate on .11 stuff before! */ #include /* for ethhdr struct */ #include /* ip */ -#include /* in_addr */ +#include /* in_addr , inet_ntoa */ /* IEEE 802.11 stuff -- will become one include later ... */ #include "ieee80211.h" /* from hunz's aeolus, short hostap_wlan.h */ @@ -29,7 +29,8 @@ int main(int argc, char *argv[]) { /* parse the arguments */ if(argc<3) { - printf("usage: %s \n",argv[0]); + printf("usage: %s \n", + argv[0]); return 0; } if(argc!=4) { @@ -64,8 +65,7 @@ int main(int argc, char *argv[]) { /* grab a package until user breaks */ count=0; p_count=&count; - pcap_dispatch(pcap_handle,-1,(pcap_handler)pcap_process, - (u_char *)&p_count); + pcap_loop(pcap_handle,-1,pcap_process,(u_char *)p_count); } @@ -84,14 +84,16 @@ void pcap_process(u_char *count,const struct pcap_pkthdr *pcap_header, ++(*p_count); printf("\n"); - printf("---> package %d ---- %s",count, - ctime((const time_t*)pcap_header->ts.tv_sec)); + printf("---> package %d ---- %s",*p_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); /* is ieee802.11 ? -- we assume yes :) */ - /* ... */ + if(atoi(argv[2])==1 && (strncmp(argv[1],"wlan",4)==0)) { + printf("debug: ieee802.11\n"); + } /* ieee802.3 */ @@ -122,12 +124,11 @@ void pcap_process(u_char *count,const struct pcap_pkthdr *pcap_header, printf("time2live = %x ip_proto = %x\n",ntohs(ip_hdr->ip_ttl), ntohs(ip_hdr->ip_p)); printf("chksum: %x\n",ntohs(ip_hdr->ip_sum)); - - } printf("all_hex_dump:\n"); for(i=sizeof(struct ethhdr);icaplen;i++) printf("%x ",*(package+i)); + printf("\n"); }