projects
/
my-code
/
hdw-sniff.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0e50ece
)
pcap_next -> pcap_loop
author
hackbard
<hackbard>
Tue, 10 Sep 2002 23:35:56 +0000
(23:35 +0000)
committer
hackbard
<hackbard>
Tue, 10 Sep 2002 23:35:56 +0000
(23:35 +0000)
hdw-sniff.c
patch
|
blob
|
history
diff --git
a/hdw-sniff.c
b/hdw-sniff.c
index
96ef4a2
..
a201688
100644
(file)
--- a/
hdw-sniff.c
+++ b/
hdw-sniff.c
@@
-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 */
/* 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 */
/* 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) {
/* 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) {
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;
/* 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");
++(*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 :) */
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 */
/* 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("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("all_hex_dump:\n");
for(i=sizeof(struct ethhdr);i<pcap_header->caplen;i++)
printf("%x ",*(package+i));
+ printf("\n");
}
}