LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2006, 07:09 AM   #1
touqeeransar
LQ Newbie
 
Registered: Nov 2005
Distribution: Fedora Core 3
Posts: 7

Rep: Reputation: 0
How can I Write a sniffer program in System Programming


Hi guys can you help me How can I build a sniffer program.
 
Old 03-07-2006, 09:44 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
 
Old 03-07-2006, 11:39 AM   #3
touqeeransar
LQ Newbie
 
Registered: Nov 2005
Distribution: Fedora Core 3
Posts: 7

Original Poster
Rep: Reputation: 0
I am talking about Network Sniffing
 
Old 03-07-2006, 11:51 AM   #4
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Use libcap. It uses Berkeley packet filter

Code:
#include <pcap.h>
#include <net/if.h>
#include <netinet/in.h>
Use pcap_lookupdev to choose the interface
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
programming program help emokid Programming 4 07-12-2005 09:02 PM
Why Linux is best Operating System for Learning/Doing System Programming ? ubaid_t General 6 03-21-2004 02:10 PM
Need Help for "Packet Sniffer Programming" L1nuxbug Programming 6 02-21-2004 10:36 AM
Write to port (C program) dummyagain Programming 8 10-24-2003 10:50 AM
where can i find sniffer program on Linux Babba Linux - Newbie 1 01-24-2003 02:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration