LinuxQuestions.org
Visit Jeremy's Blog.
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-26-2009, 01:30 AM   #1
murugan86
LQ Newbie
 
Registered: Mar 2009
Posts: 1

Rep: Reputation: 0
Receive a packet from L2 header using socket


Hi,

I am figuring out a method to receive UDP packet belonging to a particular port from L2 header using sockets in Linux.

One method is by useing AF_INET/SOCK_RAW method, but i am not sure about how to configure socket call to receive udp stream belonging to one particular port.

another method is using normal UDP socket and use any advanced options to receive packet from L2 header. But will it be possible?

Do i need to use some other method other than sockets to do so?

Any suggestion or pointer is welcomed.

murugan
 
Old 03-26-2009, 10:48 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If you use SOCK_RAW (and I believe that you will need to), you bind your socket to an interface, and thus receive all traffic that has a the interface's MAC as a destination address, or is a broadcast packet. This includes IP and non-IP traffic. SOCK_RAW requires root privileges.
--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
receive packet failed on wlan0: Network is down juanjavier_xxx Linux - Wireless Networking 6 05-25-2007 11:40 PM
dump packet data to file, but no packet header Nathanael Linux - Networking 3 02-08-2006 10:27 AM
How to get the IP header of packet going through an interface thanh Programming 1 06-12-2004 12:26 PM
Packet socket and socket filtring Baran Linux - Newbie 4 10-09-2003 07:16 AM
Edit packet header? mudvayne Linux - Networking 4 03-28-2003 01:43 PM

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

All times are GMT -5. The time now is 06:15 PM.

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