From: Jonathan.Trowbridge <jon...@gm...> - 2008-05-12 00:58:28
|
Hey all, I just got my gumstix up and running smoothly and i wrote a small little sniffer to go along with it in C. It compiles fine without any errors and runs flawlessly on other Linux boxes. The only problem is when I run it on the gumstix it hangs and locks up the whole system. =[ I noticed that it hangs when it has to process alot of packets at once. I tried setting a timeout in pcap_open_live() but it didn't seem to work. If anyone could help me out and tell me why it's locking it up that'd be nice. =P Here's the code: <code> #include <stdio.h> #include <pcap.h> static char errbuf[PCAP_ERRBUF_SIZE]; static pcap_t *session; static const u_char *pkt_data; static struct pcap_pkthdr *pkt_header; int main(int argc, char *argv[]) { const char *dev = argv[1]; printf("Opening device[%s]...", dev); session = pcap_open_live(dev, 65535, 1, 0, errbuf); printf("Done.\n"); int z = 0; for(;z < 100;z++) { pcap_next_ex(session, &pkt_header, &pkt_data); printf("Length: %d\n", pkt_header->caplen); int i = 0, x = 0; for(;i < pkt_header->caplen;i++) { for(x = 0;x < 16;x++) { int value = pkt_data[i+x]; if(value >= 32 && value <= 126)printf("%c", pkt_data[i + x]); else printf("."); } printf(" "); for(x = 0;x < 16;x++) { if((x % 4) == 0)printf(" "); printf("%02X", pkt_data[i + x]); } i += 16; printf("\n"); } } }</code> -- View this message in context: http://www.nabble.com/Gumstix-freezes-with-sniffer-tp17179930p17179930.html Sent from the Gumstix mailing list archive at Nabble.com. |