How can I Write a sniffer program in System Programming
Hi guys can you help me How can I build a sniffer program.
|
a generic google on sniffer c program
I did not specifically search for rs232 sniffing, network sniffing or whatever, only tried to find some c-code. |
I am talking about Network Sniffing
|
Use libcap. It uses Berkeley packet filter
Code:
#include <pcap.h> Use pcap_open_live to get a packet capture descriptor Use pcap_lookupnet to get network information from interface Use pcap_compile to transform your filter text into a BPF filter Use pcap_setfilter to apply the filter Use pcap_loop to set a function that will be called on every packet matching the filter Compile with -lpcap man pcap will give you more information The other solution would be to redo everything but I don't think its interesting to reinvent the wheel.. Have fun |
All times are GMT -5. The time now is 04:07 AM. |