![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Hobbyist Programmer
|
Trying to make a simple packet sniffer
So this is my first time out with libpcap. And sadly this is not compiling:
#include <stdio.h>
#include <pcap.h>
#define NUM_PACKETS 10
void pcap_handler_cb(u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data)
{
printf("Got packet: %d bytes captured:", pkt_header->caplen);
if (pkt_header->caplen > 2)
printf("%02X %02X ... \n", pkt_data[0], pkt_data[1]);
else
printf("...\n");
}
int main(int argc, char *argv[])
{
char errbuf[PCAP_ERRBUF_SIZE];
char *default_device;
pcap_t* ph;
default_device = pcap_lookupdev(errbuf);
if (!default_device)
{
fprintf(stderr, "%s\n", errbuf);
exit(1);
}
printf("Opening %s\n", default_device);
ph = pcap_open_live(default_device, BUFSIZ, 1, 0, errbuf);
printf("Capturing on %s\n", default_device);
pcap_loop(ph, NUM_PACKETS, pcap_handler_cb, NULL);
printf("Done.\n");
return 0;
}And when I try to compile it I get this: Quote:
![]() Now I only get these. Any idea how to fix 'er? Thanks.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
|
#2 |
|
Programmer
|
cc simpsnif.c -o simpsnif -l pcap
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
Thank you, that worked perfectly.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| very simple question. make button change number in edit box | nickm | Delphi | 2 | Apr 29th, 2006 10:47 PM |
| How would I make a simple macro | Xero | Other Programming Languages | 3 | Jan 28th, 2006 12:53 PM |
| Newbie: How to make simple Timer programe | smith000monday | Assembly | 0 | May 17th, 2005 2:54 AM |
| How do I make this work? simple problem | gardon | C++ | 5 | Feb 15th, 2005 7:34 AM |