]> hackdaworld.org Git - my-code/hdw-sniff.git/commitdiff
pcap_next -> pcap_loop
authorhackbard <hackbard>
Tue, 10 Sep 2002 23:35:56 +0000 (23:35 +0000)
committerhackbard <hackbard>
Tue, 10 Sep 2002 23:35:56 +0000 (23:35 +0000)
hdw-sniff.c

index 96ef4a22eb7488e1b82b2eaba231e9804ffdfab1..a20168852e88cf74a790536fc802a3bf8ef18844 100644 (file)
@@ -10,7 +10,7 @@
 /* IEEE 802.3 stuff -- i will concentrate on .11 stuff before! */
 #include <netinet/if_ether.h>  /* for ethhdr struct */
 #include <netinet/ip.h> /* ip */
-#include <netinet/in.h>        /* in_addr */
+#include <netinet/in.h>        /* 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 <interface> <monitor mode> <logfile>\n",argv[0]);
+               printf("usage: %s <interface> <monitor mode> <logfile>\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);i<pcap_header->caplen;i++)
                printf("%x ",*(package+i));
+       printf("\n");
 }