Networking Forums

Networking Forums > Computer Networking > Linux Networking > Getting/setting eth frame interface for raw socket

Reply
Thread Tools Display Modes

Getting/setting eth frame interface for raw socket

 
 
boltar2003@yahoo.co.uk
Guest
Posts: n/a

 
      09-30-2009, 11:19 AM
Hi

I've written a network monitoring app for linux that displays information about
ethernet frames it receives. It creates the socket as follows:

sock = socket(PF_PACKET,SOCK_RAW,htons(ETH_P_ALL))

My 1st question is , is there a simple way to get the interface name the
frame arrived on or would I have to issue an ioctl SIOCGIFCONF call
and loop through the list of interfaces comparing the MAC addresses?

My 2nd related question is - how can I specify what interface to send an
outgoing frame on when I update the code to write to the socket?

Thanks for any help.

B2003


 
Reply With Quote
 
 
 
 
boltar2003@yahoo.co.uk
Guest
Posts: n/a

 
      09-30-2009, 11:54 AM
On Wed, 30 Sep 2009 06:34:22 -0500
(E-Mail Removed) (Gordon Burditt) wrote:
>I'm not sure you can *TELL* the interface name the frame arrived
>on by looping through the list of interfaces comparing MAC addresses.


You can if it has arrived from an ethernet interface.

>Localhost doesn't have a MAC address.
>Lots of virtual interfaces like 'gif' don't either.
>Neither do some of the packets removed from the system, then re-injected
>into it (say, by a userland NATD daemon).
>What about broadcast packets?


None of the above work, which is why I was hoping that there was a way
of obtaining the packets interface directly but I suspect not.

B2003

 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SO_BINDTODEVICE socket option on an aliased interface Christophe Lohr Linux Networking 4 01-23-2009 09:19 PM
How to set VLAN priority for socket (not for interface) linux62i@yahoo.com Linux Networking 0 10-27-2006 11:57 AM
Packet socket attached to 802.11 interface? jski Wireless Internet 0 08-15-2006 07:10 PM
Setting DNS for an interface ? Polaris Windows Networking 4 10-11-2005 10:53 AM
Network interface bandwidth setting Ben B Linux Networking 5 01-05-2004 01:12 PM



1 2 3 4 5 6 7 8 9 10 11