-2

I need to capture packets which are coming from interface (say eth0) and need to print those packet details (same as wireshark) through C language. Packet can be any general packet. is there any way to achieve this ?? (I don't want to use any application like wireshark for this purpose)

OS:Centos

  • Of course what the question describes is possible on most systems. However, an answer would require some information on the OS you plan to use. Can you edit your question and add that detail? – Mahonri Moriancumer May 01 '14 at 19:00
  • @Mahonri Moriancumer: Its centos, I have edited as per your advice as well thanks – Kaushik Koneru May 01 '14 at 19:07
  • 2
    have you looked at libpcap? – maha May 01 '14 at 19:17
  • @maha, Great tip! I just took a peek at http://www.tcpdump.org/pcap.html, which seems to be a great place to start! (You should post this as an answer so you can get the proper credit!) – Mahonri Moriancumer May 01 '14 at 19:36
  • @maha, thanks for the tip, Actually i have tried that but basically it expects a interface to be configured in L3. I need to capture packets from those interfaces where interface is not configured. – Kaushik Koneru May 01 '14 at 20:13

1 Answers1

1

Try having a look at libpcap. http://www.tcpdump.org/ I believe it will do what you want.

maha
  • 495
  • 4
  • 12